13#include "FairGeoInterface.h"
14#include "FairGeoLoader.h"
15#include "FairGeoNode.h"
16#include "FairGeoRootBuilder.h"
17#include "FairRuntimeDb.h"
18#include "FairRootManager.h"
20#include "FairRunAna.h"
22#include "FairVolume.h"
23#include "FairGeoMedium.h"
24#include "FairGeoMedia.h"
26#include "TClonesArray.h"
27#include "TGeoMCGeometry.h"
28#include "TGeoManager.h"
30#include "TVirtualMC.h"
34#include "TGeoMatrix.h"
42#define kN kNumberOfHCALSensitiveVolumes
46 : FairDetector(
"HCAL", kTRUE,
khcal),
57 fHcalCollection(new TClonesArray(
"hcalPoint")),
58 fLiteCollection(new TClonesArray(
"hcalPoint")),
71 fThicknessAbsorber(0.),
115hcal::hcal(
const char* name, Bool_t active,
const char* fileGeo)
116 : FairDetector(name, active,
khcal),
127 fHcalCollection(new TClonesArray(
"hcalPoint")),
128 fLiteCollection(new TClonesArray(
"hcalPoint")),
141 fThicknessAbsorber(0.),
184 Info(
"hcal",
"Geometry is read from file %s.", fileGeo);
188 Fatal(
"hcal",
" Can't read geometry from %s.", fileGeo);
241 Fatal(
"hcal",
"Wrong module type");
255 Info(
"hcal",
"Size of cell of type %d is %f cm.", i,
fXCell);
262 FairDetector::Initialize();
318 Double_t el=oldHit->GetEnergyLoss();
319 Double_t ttime=gMC->TrackTime()*1.0e9;
320 oldHit->SetEnergyLoss(el+edep);
321 if(ttime<oldHit->GetTime())
322 oldHit->SetTime(ttime);
328 FairRun* fRun = FairRun::Instance();
332 mediumID = gGeoManager->GetMedium(
"Scintillator")->GetId();
334 mediumID = gGeoManager->GetMedium(
fAbsorber)->GetId();
336 mediumID = gGeoManager->GetMedium(
"Tyvek")->GetId();
338 mediumID = gGeoManager->GetMedium(
"SensVacuum")->GetId();
340 mediumID = gGeoManager->GetMedium(
"ECALAir")->GetId();
342 mediumID = gGeoManager->GetMedium(
"ECALFiber")->GetId();
344 mediumID = gGeoManager->GetMedium(
"ECALTileEdging")->GetId();
346 mediumID = gGeoManager->GetMedium(
"ECALSteel")->GetId();
356 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
357 fTime = gMC->TrackTime()*1.0e09;
361 if (Hcal.CompareTo(gMC->CurrentVolName())==0) {
362 if (gMC->IsTrackEntering()) {
374 if (
fELoss<=0)
return kFALSE;
379 TParticle* p=gMC->GetStack()->GetCurrentTrack();
390 gMC->TrackPosition(x, y, z);
403 gMC->CurrentVolOffID(1, layer); layer--;
404 gMC->CurrentVolOffID(2, mx); mx--;
405 gMC->CurrentVolOffID(3, my); my--;
409 gMC->CurrentVolOffID(0, layer); layer--;
410 gMC->CurrentVolOffID(1, mx); mx--;
411 gMC->CurrentVolOffID(2, my); my--;
413 Int_t
id=(my*100+mx)*10;
446 if (px>=0&&px<1&&py>=0&&py<1)
475 for(i=
kN-1;i>-1;i--) {
487 gMC->TrackPosition(
fPos);
488 gMC->TrackMomentum(
fMom);
490 Double_t mass = gMC->TrackMass();
492 Double_t ekin = TMath::Sqrt(
fMom.Px()*
fMom.Px() +
495 mass * mass ) - mass;
504 fELoss, part->GetPdgCode());
506 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
514 if (point->GetTrackID()==TrackId&&point->GetDetectorID()==VolId)
526 static Float_t zmin=
fZHcal-0.0001;
530 TParticle* part=gMC->GetStack()->GetCurrentTrack();
531 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
536 while (part->GetFirstMother()>=0&&part->Vz()>=zmin&&part->Vz()<=zmax&&TMath::Abs(part->Vx())<=xhcal&&TMath::Abs(part->Vy())<=yhcal)
545 if (
fTrackID<0) cout<<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!fTrackID="<<
fTrackID<<endl;
562 if (fVerboseLevel)
Print();
597 cout <<
"-I- hcal: " << nHits <<
" points registered in this event.";
601 cout <<
"-I- hcal: " << nLiteHits <<
" lite points registered in this event.";
606 for (i=0;i<nHits;i++)
608 for (i=0;i<nLiteHits;i++)
617 Int_t nEntries = cl1->GetEntriesFast();
620 cout <<
"-I- hcal: " << nEntries <<
" entries to add." << endl;
621 TClonesArray& clref = *cl2;
622 if (cl1->GetClass()==hcalPoint::Class()) {
624 for (i=0; i<nEntries; i++) {
626 index = oldpoint->GetTrackID()+offset;
627 oldpoint->SetTrackID(index);
631 cout <<
"-I- hcal: " << cl2->GetEntriesFast() <<
" merged entries."
634 else if (cl1->GetClass()==hcalPoint::Class()) {
636 for (i=0; i<nEntries; i++) {
638 index = oldpoint->GetTrackID()+offset;
639 oldpoint->SetTrackID(index);
643 cout <<
"-I- hcal: " << cl2->GetEntriesFast() <<
" merged entries."
652 FairRootManager::Instance()->Register(
"HcalPoint",
"Hcal",
fHcalCollection,kTRUE);
653 FairRootManager::Instance()->Register(
"HcalPointLite",
"HcalLite",
fLiteCollection,kTRUE);
661 FairGeoLoader*geoLoad = FairGeoLoader::Instance();
662 FairGeoInterface *geoFace = geoLoad->getGeoInterface();
663 FairGeoMedia *Media = geoFace->getMedia();
664 FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
666 TGeoVolume *top=gGeoManager->GetTopVolume();
670 FairGeoMedium *CbmMedium;
679 Double_t moduleth=thickness*
fNLayers;
692 Double_t fudgeFactor = 6.34 / 13.7 ;
693 par[2] = par[2]*fudgeFactor;
694 volume=gGeoManager->Volume(
"Hcal",
"BOX", gGeoManager->GetMedium(
"iron")->GetId(), par, 3);
695 gGeoManager->Node(
"Hcal", 1, top->GetName(), 0.0,0.0,
fZHcal, 0, kTRUE, buf, 0);
699 volume=gGeoManager->Volume(
"Hcal",
"BOX", gGeoManager->GetMedium(
"SensVacuum")->GetId(), par, 3);
700 gGeoManager->Node(
"Hcal", 1, top->GetName(), 0.0,0.0,
fZHcal, 0, kTRUE, buf, 0);
701 volume->SetVisLeaves(kTRUE);
702 volume->SetVisContainers(kFALSE);
703 volume->SetVisibility(kFALSE);
706 AddSensitiveVolume(volume);
716 TGeoVolume* vol=
new TGeoVolumeAssembly(
"HcalStructure");
718 vol->SetMedium(gGeoManager->GetMedium(
"SensVacuum"));
726 nm=volume->GetName();
728 gGeoManager->Node(nm.Data(), i+1,
"HcalStructure", 0.0, y, 0.0, 0, kTRUE, buf, 0);
732 gGeoManager->Node(
"HcalStructure", 1,
"Hcal",
fDX,
fDY, 0.0, 0, kTRUE, buf, 0);
741 list<pair<Int_t, TGeoVolume*> >::const_iterator p=
fRawNumber.begin();
742 pair<Int_t, TGeoVolume*> out;
759 TString nm=
"HCALRaw"; nm+=num;
761 TGeoVolume* vol=
new TGeoVolumeAssembly(nm);
763 vol->SetMedium(gGeoManager->GetMedium(
"SensVacuum"));
769 gGeoManager->Node(md.Data(),i+1, nm.Data(), x, 0.0, 0.0, 0, kTRUE, buf, 0);
792 TVector3 mom, Double_t time, Double_t length,
793 Double_t eLoss, Int_t pdgcode)
796 Int_t size = clref.GetEntriesFast();
797 return new(clref[size])
hcalPoint(trackID, detID, pos, mom,
798 time, length, eLoss, pdgcode);
806 Int_t size = clref.GetEntriesFast();
807 return new(clref[size])
hcalPoint(trackID, detID, time, eLoss);
820 TString nm=
"HcalModule";
822 TString cellname=
"HcalCell";
823 TString scin=
"ScTile";
824 TString lead=
"LeadTile";
825 TString tyvek=
"TvTile";
833 Double_t moduleth=thickness*
fNLayers;
839 nm1=
"HcalModuleSteelTape1";
840 fSteelTapes[0]=
new TGeoVolume(nm1.Data(), st1, gGeoManager->GetMedium(
"ECALSteel"));
845 nm1=
"HcalModuleSteelTape2";
846 fSteelTapes[1]=
new TGeoVolume(nm1.Data(), st2, gGeoManager->GetMedium(
"ECALSteel"));
851 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
852 modulev->SetLineColor(kOrange+3);
855 gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*
fNLayers/2.0+
fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
864 nm1=
"HcalModuleSteelTape1";
867 nm1=
"HcalModuleSteelTape2";
885 TString nm=
"HcalModule";
887 TString cellname=
"HcalCell";
888 TString scin=
"ScTile";
889 TString lead=
"LeadTile";
890 TString tyvek=
"TvTile";
898 Double_t moduleth=thickness*
fNLayers;
902 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
903 modulev->SetLineColor(kOrange+3);
906 gGeoManager->Node(scin.Data(), i+1, nm.Data(), 0.0, 0.0, -thickness*
fNLayers/2.0+
fThicknessScin/2.0+i*thickness, 0, kTRUE, buf, 0);
923 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
924 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
925 static FairGeoMedia *media=geoFace->getMedia();
926 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
928 FairGeoMedium *CbmMedium=media->getMedium(name);
932 Fatal(
"InitMedium",
"Material %s not defined in media file.", name);
935 TGeoMedium* medium=gGeoManager->GetMedium(name);
937 return CbmMedium->getMediumIndex();
939 return geoBuild->createMedium(CbmMedium);
946 Info(
"InitMedia",
"Initializing media.");
964 case 0:
if (
fScTile!=NULL)
return;
break;
965 case 1:
if (
fPbTile!=NULL)
return;
break;
966 case 2:
if (
fTvTile!=NULL)
return;
break;
967 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
972 TGeoTranslation** tr;
994 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
997 if (thickness<=0.0)
return;
1001 nm1=
"ECALHole_"; nm1+=material;
1002 nm2=
"ECALFiber_"; nm2+=material;
1005 TGeoTube* holetube=
new TGeoTube(0,
fHoleRad, thickness);
1006 fHoleVol[material]=
new TGeoVolume(nm1.Data(), holetube, gGeoManager->GetMedium(
"ECALAir"));
1014 TGeoTube* fibertube=
new TGeoTube(0,
fFiberRad, thickness);
1015 fFiberVol[material]=
new TGeoVolume(nm2.Data(), fibertube, gGeoManager->GetMedium(
"ECALFiber"));
1016 gGeoManager->Node(nm2.Data(), 1, nm1.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1046 case 0: nm=
"ScTile"; medium=
"Scintillator";
break;
1047 case 1: nm=
"LeadTile"; medium=
fAbsorber;
break;
1048 case 2: nm=
"TvTile"; medium=
"Tyvek";
break;
1049 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1056 tilev=
new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1059 nm1=
"ECALHole_"; nm1+=material;
1063 x=(i-nh/2+0.5)*
fXCell/nh;
1064 y=(j-nh/2+0.5)*
fYCell/nh;
1065 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
1068 if (nh%2==0&&
fCF!=0)
1069 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1086 AddSensitiveVolume(tilev);
1089 edgingv=
new TGeoVolume(nm+
"_edging", edging, gGeoManager->GetMedium(
"ECALTileEdging"));
1090 edgingv->AddNode(tilev, 1);
1110 case 0:
if (
fScTile!=NULL)
return;
break;
1111 case 1:
if (
fPbTile!=NULL)
return;
break;
1112 case 2:
if (
fTvTile!=NULL)
return;
break;
1113 default: Error(
"ConstructTileSimple",
"Can't construct a tile of type %d.", material);
1118 TGeoTranslation** tr;
1119 TGeoTranslation* tm;
1132 TGeoVolume* edgingv;
1140 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1143 if (thickness<=0.0)
return;
1147 case 0: nm=
"ScTile"; medium=
"Scintillator";
break;
1148 case 1: nm=
"LeadTile"; medium=
fAbsorber;
break;
1149 case 2: nm=
"TvTile"; medium=
"Tyvek";
break;
1150 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1154 tilev=
new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1158 AddSensitiveVolume(tilev);
1182 cerr <<
"hcal::GetCellCoordInf(): Can't get geometry information." << endl;
1187 section=volid%10; volid=volid-section; volid/=10;
1188 Int_t mx=volid%100; volid-=mx; volid/=100;
1189 Int_t my=volid%100; volid-=my; volid/=100;
1195 x=mx*modulesize-xcalosize/2.0+1.0; x+=dx;
1196 y=my*modulesize-ycalosize/2.0+1.0; y+=dy;
Double_t GetAbsorber() const
Int_t GetN1Layers() const
static hcalInf * GetInstance(const char *filename)
Double_t GetVariableStrict(const char *key)
Double_t GetHcalSize(Int_t num) const
Double_t GetTyveec() const
Double_t GetElectronCut() const
Double_t GetHadronCut() const
char GetType(Int_t x, Int_t y) const
TString GetStringVariable(const char *key)
Double_t Data(Double_t x, Double_t y)
std::list< std::pair< Int_t, TGeoVolume * > > fRawNumber
Number of mudules.
virtual void EndOfEvent()
void ConstructTileSimple(Int_t material)
virtual void FinishPrimary()
static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t §ion)
virtual void ChangeHit(hcalPoint *oldHit=NULL)
void ConstructTile(Int_t material)
virtual void SetSpecialPhysicsCuts()
TClonesArray * fHcalCollection
Bool_t FillLitePoint(Int_t volnum)
Int_t GetVolType(Int_t volnum)
static Bool_t GetCellCoord(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t §ion)
virtual void ConstructGeometry()
TGeoVolume * fScTile
Calorimeter Modules.
void SetHcalCuts(Int_t medium)
hcalPoint * AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
TGeoVolume * fTileEdging
Pb tiles.
virtual Bool_t ProcessHits(FairVolume *vol=NULL)
TGeoVolume * fPbTile
Edging of scintillator tiles.
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
TGeoVolume * fSteelTapes[2]
Fiber volume.
virtual void Print() const
hcalPoint * FindHit(Int_t VolId, Int_t TrackId)
TGeoVolume * ConstructRaw(Int_t number)
Int_t fVolArr[kNumberOfHCALSensitiveVolumes]
TGeoVolume * fHoleVol[3]
Tyvek sheets.
Int_t fModules
Positions of holes.
TClonesArray * fLiteCollection
hcalPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgcode)
virtual TClonesArray * GetCollection(Int_t iColl) const
Float_t fThicknessAbsorber
Int_t InitMedium(const char *name)
virtual void Initialize()
TGeoVolume * fTvTile
Scintillator tiles.
void ConstructModuleSimple()
TGeoVolume * fFiberVol[3]
Hole volume.
Int_t fStructureId
List of constructed raws.
virtual void BeginEvent()