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"
35#include "TGeoMatrix.h"
43#define kN kNumberOfECALSensitiveVolumes
47 : FairDetector(
"ECAL", kTRUE,
kecal),
58 fEcalCollection(new TClonesArray(
"ecalPoint")),
59 fLiteCollection(new TClonesArray(
"ecalPoint")),
122ecal::ecal(
const char* name, Bool_t active,
const char* fileGeo)
123 : FairDetector(name, active,
kecal),
134 fEcalCollection(new TClonesArray(
"ecalPoint")),
135 fLiteCollection(new TClonesArray(
"ecalPoint")),
197 Info(
"ecal",
"Geometry is read from file %s.", fileGeo);
201 Fatal(
"ecal",
" Can't read geometry from %s.", fileGeo);
268 nm=
"cf["; nm+=i; nm+=
"]";
270 nm=
"nh[";nm+=i; nm+=
"]";
272 nm=
"lightmap["; nm+=i; nm+=
"]";
283 Info(
"ecal",
"Size of cell of type %d is %f cm.", i,
fXCell[i]);
291 FairDetector::Initialize();
347 Double_t el=oldHit->GetEnergyLoss();
348 Double_t ttime=gMC->TrackTime()*1.0e9;
349 oldHit->SetEnergyLoss(el+edep);
350 if(ttime<oldHit->GetTime())
351 oldHit->SetTime(ttime);
360 FairRun* fRun = FairRun::Instance();
364 mediumID = gGeoManager->GetMedium(
"Scintillator")->GetId();
366 mediumID = gGeoManager->GetMedium(
"Lead")->GetId();
368 mediumID = gGeoManager->GetMedium(
"Tyvek")->GetId();
370 mediumID = gGeoManager->GetMedium(
"SensVacuum")->GetId();
372 mediumID = gGeoManager->GetMedium(
"ECALAir")->GetId();
374 mediumID = gGeoManager->GetMedium(
"ECALFiber")->GetId();
376 mediumID = gGeoManager->GetMedium(
"ECALTileEdging")->GetId();
378 mediumID = gGeoManager->GetMedium(
"ECALSteel")->GetId();
389 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
390 fTime = gMC->TrackTime()*1.0e09;
393 TParticle* bp=gMC->GetStack()->GetCurrentTrack();
394 gMC->TrackPosition(bx, by, bz);
396 gMC->CurrentVolID(volID);
399 if (Ecal.CompareTo(gMC->CurrentVolName())==0) {
400 if (gMC->IsTrackEntering()) {
413 if (
fELoss<=0)
return kFALSE;
418 TParticle* p=gMC->GetStack()->GetCurrentTrack();
429 gMC->TrackPosition(x, y, z);
442 gMC->CurrentVolOffID(3, mx); mx--;
443 gMC->CurrentVolOffID(4, my); my--;
444 gMC->CurrentVolOffID(2, cell); cell--;
448 gMC->CurrentVolOffID(2, mx); mx--;
449 gMC->CurrentVolOffID(3, my); my--;
450 gMC->CurrentVolOffID(1, cell); cell--;
452 Int_t
id=(my*100+mx)*100+cell+1;
454 if (Ecal.CompareTo(gMC->CurrentVolName())==0&&
fELoss<1e-19)
456 cout <<
"neg id "<<mx<<
" "<<my<<
" "<<cell<<
" "<<gMC->CurrentVolName()<<
" "<<gMC->CurrentVolOffName(1)<<
" "<<gMC->CurrentVolOffName(2)<<
" "<<
fELoss<<
" "<<
fELoss*1e10<<endl;
490 if (px>=0&&px<1&&py>=0&&py<1)
519 for(i=
kN-1;i>-1;i--) {
531 gMC->TrackPosition(
fPos);
532 gMC->TrackMomentum(
fMom);
534 Double_t mass = gMC->TrackMass();
536 Double_t ekin = TMath::Sqrt(
fMom.Px()*
fMom.Px() +
539 mass * mass ) - mass;
548 fELoss, part->GetPdgCode());
550 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
558 if (point->GetTrackID()==TrackId&&point->GetDetectorID()==VolId)
570 static Float_t zmin=
fZEcal-0.0001;
574 TParticle* part=gMC->GetStack()->GetCurrentTrack();
575 fTrackID=gMC->GetStack()->GetCurrentTrackNumber();
580 while (part->GetFirstMother()>=0&&part->Vz()>=zmin&&part->Vz()<=zmax&&TMath::Abs(part->Vx())<=xecal&&TMath::Abs(part->Vy())<=yecal)
589 if (
fTrackID<0) cout<<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!fTrackID="<<
fTrackID<<endl;
606 if (fVerboseLevel)
Print();
641 cout <<
"-I- ecal: " << nHits <<
" points registered in this event.";
645 cout <<
"-I- ecal: " << nLiteHits <<
" lite points registered in this event.";
650 for (i=0;i<nHits;i++)
652 for (i=0;i<nLiteHits;i++)
661 Int_t nEntries = cl1->GetEntriesFast();
664 cout <<
"-I- ecal: " << nEntries <<
" entries to add." << endl;
665 TClonesArray& clref = *cl2;
666 if (cl1->GetClass()==ecalPoint::Class()) {
668 for (i=0; i<nEntries; i++) {
670 index = oldpoint->GetTrackID()+offset;
671 oldpoint->SetTrackID(index);
675 cout <<
"-I- ecal: " << cl2->GetEntriesFast() <<
" merged entries."
678 else if (cl1->GetClass()==ecalPoint::Class()) {
680 for (i=0; i<nEntries; i++) {
682 index = oldpoint->GetTrackID()+offset;
683 oldpoint->SetTrackID(index);
687 cout <<
"-I- ecal: " << cl2->GetEntriesFast() <<
" merged entries."
696 FairRootManager::Instance()->Register(
"EcalPoint",
"Ecal",
fEcalCollection,kTRUE);
697 FairRootManager::Instance()->Register(
"EcalPointLite",
"EcalLite",
fLiteCollection,kTRUE);
705 FairGeoLoader*geoLoad = FairGeoLoader::Instance();
706 FairGeoInterface *geoFace = geoLoad->getGeoInterface();
707 FairGeoMedia *Media = geoFace->getMedia();
708 FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
710 TGeoVolume *top=gGeoManager->GetTopVolume();
714 FairGeoMedium *CbmMedium;
723 Double_t moduleth=thickness*
fNLayers;
733 par[2]=moduleth/2.0+0.1;
734 volume=gGeoManager->Volume(
"Ecal",
"BOX", gGeoManager->GetMedium(
"SensVacuum")->GetId(), par, 3);
735 gGeoManager->Node(
"Ecal", 1, top->GetName(), 0.0,0.0,
fZEcal+par[2]-0.05, 0, kTRUE, buf, 0);
736 volume->SetVisLeaves(kTRUE);
737 volume->SetVisContainers(kFALSE);
738 volume->SetVisibility(kFALSE);
739 AddSensitiveVolume(volume);
751 TGeoVolume* vol=
new TGeoVolumeAssembly(
"EcalStructure");
753 vol->SetMedium(gGeoManager->GetMedium(
"SensVacuum"));
763 nm=volume->GetName();
766 gGeoManager->Node(nm.Data(), i+1,
"EcalStructure", 0.0, y, 0.0, 0, kTRUE, buf, 0);
771 gGeoManager->Node(
"EcalStructure", 1,
"Ecal",
fDX,
fDY, 0.0, 0, kTRUE, buf, 0);
779 list<pair<Int_t, TGeoVolume*> >::const_iterator p=
fRawNumber.begin();
780 pair<Int_t, TGeoVolume*> out;
797 TString nm=
"ECALRaw"; nm+=num;
799 TGeoVolume* vol=
new TGeoVolumeAssembly(nm);
801 vol->SetMedium(gGeoManager->GetMedium(
"SensVacuum"));
807 gGeoManager->Node(md.Data(),i+1, nm.Data(), x, 0.0, 0.0, 0, kTRUE, buf, 0);
830 TVector3 mom, Double_t time, Double_t length,
831 Double_t eLoss, Int_t pdgcode)
834 Int_t size = clref.GetEntriesFast();
835 return new(clref[size])
ecalPoint(trackID, detID, pos, mom,
836 time, length, eLoss, pdgcode);
844 Int_t size = clref.GetEntriesFast();
845 return new(clref[size])
ecalPoint(trackID, detID, time, eLoss);
855 TString nm=
"EcalModule"; nm+=type;
857 TString cellname=
"EcalCell"; cellname+=type;
865 Double_t moduleth=thickness*
fNLayers;
870 nm1=
"EcalModuleSteelTape1_";
871 fSteelTapes[0]=
new TGeoVolume(nm1.Data(), st1, gGeoManager->GetMedium(
"ECALSteel"));
876 nm1=
"EcalModuleSteelTape2_";
877 fSteelTapes[1]=
new TGeoVolume(nm1.Data(), st2, gGeoManager->GetMedium(
"ECALSteel"));
882 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
883 modulev->SetLineColor(kYellow);
892 gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
894 nm1=
"EcalModuleSteelTape1_";
897 nm1=
"EcalModuleSteelTape2_";
910 TString nm=
"EcalModule"; nm+=type;
912 TString cellname=
"EcalCell"; cellname+=type;
920 Double_t moduleth=thickness*
fNLayers;
924 TGeoVolume* modulev=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
925 modulev->SetLineColor(kYellow);
934 gGeoManager->Node(cellname.Data(), n, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
943 if (
fCells[type]!=NULL)
return;
951 TString nm=
"EcalCell"; nm+=type;
952 TString scin=
"ScTile"; scin+=type; scin+=
"_edging";
953 TString lead=
"LeadTile"; lead+=type;
954 TString tyvek=
"TvTile"; tyvek+=type;
956 Double_t moduleth=thickness*
fNLayers;
959 TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
962 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);
977 if (
fCells[type]!=NULL)
return;
985 TString nm=
"EcalCell"; nm+=type;
986 TString scin=
"ScTile"; scin+=type;
987 TString lead=
"LeadTile"; lead+=type;
988 TString tyvek=
"TvTile"; tyvek+=type;
990 Double_t moduleth=thickness*
fNLayers;
993 TGeoVolume* cellv=gGeoManager->Volume(nm.Data(),
"BOX", gGeoManager->GetMedium(
"ECALAir")->GetId(), par, 3);
996 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);
1011 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
1012 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
1013 static FairGeoMedia *media=geoFace->getMedia();
1014 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
1016 FairGeoMedium *CbmMedium=media->getMedium(name);
1020 Fatal(
"InitMedium",
"Material %s not defined in media file.", name);
1023 TGeoMedium* medium=gGeoManager->GetMedium(name);
1025 return CbmMedium->getMediumIndex();
1027 return geoBuild->createMedium(CbmMedium);
1034 Info(
"InitMedia",
"Initializing media.");
1052 case 0:
if (
fScTiles[type]!=NULL)
return;
break;
1053 case 1:
if (
fPbTiles[type]!=NULL)
return;
break;
1054 case 2:
if (
fTvTiles[type]!=NULL)
return;
break;
1055 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1060 TGeoTranslation** tr;
1061 TGeoTranslation* tm;
1074 TGeoVolume* edgingv;
1082 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1085 if (thickness<=0.0)
return;
1089 nm1=
"ECALHole_"; nm1+=material;
1090 nm2=
"ECALFiber_"; nm2+=material;
1093 TGeoTube* holetube=
new TGeoTube(0,
fHoleRad, thickness);
1094 fHoleVol[material]=
new TGeoVolume(nm1.Data(), holetube, gGeoManager->GetMedium(
"ECALAir"));
1102 TGeoTube* fibertube=
new TGeoTube(0,
fFiberRad, thickness);
1103 fFiberVol[material]=
new TGeoVolume(nm2.Data(), fibertube, gGeoManager->GetMedium(
"ECALFiber"));
1104 gGeoManager->Node(nm2.Data(), 1, nm1.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1134 case 0: nm=
"ScTile"; medium=
"Scintillator";
break;
1135 case 1: nm=
"LeadTile"; medium=
"Lead";
break;
1136 case 2: nm=
"TvTile"; medium=
"Tyvek";
break;
1137 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1142 tile=
new TGeoBBox(
fXCell[type]/2.0,
fYCell[type]/2.0, thickness);
1145 tilev=
new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1148 nm1=
"ECALHole_"; nm1+=material;
1152 x=(i-nh/2+0.5)*
fXCell[type]/nh;
1153 y=(j-nh/2+0.5)*
fYCell[type]/nh;
1154 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), x, y, 0.0, 0, kTRUE, buf, 0);
1157 if (nh%2==0&&
fCF[type]!=0)
1158 gGeoManager->Node(nm1.Data(), j*nh+i+1, nm.Data(), 0.0, 0.0, 0.0, 0, kTRUE, buf, 0);
1175 AddSensitiveVolume(tilev);
1178 edgingv=
new TGeoVolume(nm+
"_edging", edging, gGeoManager->GetMedium(
"ECALTileEdging"));
1179 edgingv->AddNode(tilev, 1);
1199 case 0:
if (
fScTiles[type]!=NULL)
return;
break;
1200 case 1:
if (
fPbTiles[type]!=NULL)
return;
break;
1201 case 2:
if (
fTvTiles[type]!=NULL)
return;
break;
1202 default: Error(
"ConstructTileSimple",
"Can't construct a tile of type %d.", material);
1207 TGeoTranslation** tr;
1208 TGeoTranslation* tm;
1221 TGeoVolume* edgingv;
1229 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1232 if (thickness<=0.0)
return;
1236 case 0: nm=
"ScTile"; medium=
"Scintillator";
break;
1237 case 1: nm=
"LeadTile"; medium=
"Lead";
break;
1238 case 2: nm=
"TvTile"; medium=
"Tyvek";
break;
1239 default: Error(
"ConstructTile",
"Can't construct a tile of type %d.", material);
1244 tilev=
new TGeoVolume(nm, tile, gGeoManager->GetMedium(medium));
1248 AddSensitiveVolume(tilev);
1272 cerr <<
"ecal::GetCellCoordInf(): Can't get geometry information." << endl;
1277 Int_t cell=volid%100-1; volid=volid-cell-1; volid/=100;
1278 Int_t mx=volid%100; volid-=mx; volid/=100;
1279 Int_t my=volid%100; volid-=my; volid/=100;
1280 Int_t type=inf->
GetType(mx, my);
1289 x=mx*modulesize-xcalosize/2.0+cx*modulesize/type+1.0; x+=dx;
1290 y=my*modulesize-ycalosize/2.0+cy*modulesize/type+1.0; y+=dy;
1315 cerr <<
"ecal::GetCellCoordInf(): Can't get geometry information." << endl;
1319 all=TVector3(x,y,inf->
GetZPos());
Double_t GetHadronCut() const
char GetType(Int_t x, Int_t y) const
Double_t GetTyveec() const
TString GetStringVariable(const char *key)
void AddVariable(const char *key, const char *value)
Double_t GetVariableStrict(const char *key)
Double_t GetEcalSize(Int_t num) const
Double_t GetElectronCut() const
static ecalInf * GetInstance(const char *filename)
Double_t Data(Double_t x, Double_t y)
Bool_t FillLitePoint(Int_t volnum)
virtual void Print() const
virtual void Initialize()
virtual void SetSpecialPhysicsCuts()
Int_t fCF[cMaxModuleType]
virtual void FinishPrimary()
virtual void BeginEvent()
std::list< std::pair< Int_t, TGeoVolume * > > fRawNumber
Number of mudules with type.
Int_t InitMedium(const char *name)
void ConstructTile(Int_t type, Int_t material)
ecalLightMap * fLightMaps[cMaxModuleType]
TGeoVolume * fHoleVol[3]
Tyvek sheets.
Float_t fYCell[cMaxModuleType]
virtual Bool_t ProcessHits(FairVolume *vol=NULL)
void ConstructCellSimple(Int_t type)
TClonesArray * fLiteCollection
Int_t GetVolType(Int_t volnum)
void ConstructCell(Int_t type)
TGeoVolume * fTileEdging[cMaxModuleType]
Pb tiles.
virtual void ChangeHit(ecalPoint *oldHit=NULL)
TGeoVolume * fSteelTapes[2]
Fiber volume.
virtual void ConstructGeometry()
Int_t fVolArr[kNumberOfECALSensitiveVolumes]
TGeoTranslation ** fHolePos[cMaxModuleType]
Steel tapes.
ecalPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgcode)
TGeoVolume * ConstructRaw(Int_t number)
Float_t fXCell[cMaxModuleType]
TGeoVolume * fCells[cMaxModuleType]
Calorimeter Modules.
static Bool_t GetCellCoord(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t &tenergy)
TString fLightMapNames[cMaxModuleType]
void ConstructModule(Int_t type)
void SetEcalCuts(Int_t medium)
TGeoVolume * fPbTiles[cMaxModuleType]
Edging of scintillator tiles.
TGeoVolume * fScTiles[cMaxModuleType]
Calorimeter Cells.
Int_t fNH[cMaxModuleType]
void ConstructTileSimple(Int_t type, Int_t material)
ecalPoint * AddLiteHit(Int_t trackID, Int_t detID, Double32_t time, Double32_t eLoss)
TGeoVolume * fTvTiles[cMaxModuleType]
Scintillator tiles.
virtual void EndOfEvent()
Int_t fStructureId
List of constructed raws.
TGeoVolume * fModules[cMaxModuleType]
TGeoVolume * fFiberVol[3]
Hole volume.
ecalPoint * FindHit(Int_t VolId, Int_t TrackId)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t &tenergy)
void ConstructModuleSimple(Int_t type)
TClonesArray * fEcalCollection
Int_t fModulesWithType[cMaxModuleType]
Positions of holes.
virtual TClonesArray * GetCollection(Int_t iColl) const
static Bool_t GetCellCoordForPy(Int_t fVolID, TVector3 &all)
const Int_t cMaxModuleType