11 #include "TClonesArray.h" 12 #include "TParticle.h" 13 #include "TVirtualMC.h" 16 #include "FairRootManager.h" 17 #include "FairLogger.h" 20 : FairDetector(
"ERND", kTRUE)
22 LOG(INFO) <<
" ERND::ERND()" << FairLogger::endl;
23 fNDPoints =
new TClonesArray(
"ERNDPoint");
24 flGeoPar =
new TList();
25 flGeoPar->SetName( GetName());
29 ERND::ERND(
const char* name, Bool_t active, Int_t verbose)
30 : FairDetector(name, active,verbose)
32 fNDPoints =
new TClonesArray(
"ERNDPoint");
33 flGeoPar =
new TList();
34 flGeoPar->SetName( GetName());
46 FairDetector::Initialize();
63 static const Double_t dP = 1.16;
64 static const Double_t BirkC1 = 0.027/dP;
65 static const Double_t BirkC2 = 0.0/(dP * dP);
69 static Int_t mot0TrackID;
71 static TLorentzVector posIn, posOut;
72 static TLorentzVector momIn, momOut;
73 static Double32_t time;
74 static Double32_t length;
75 static Double32_t eLoss;
76 static Int_t stilbenNr;
77 static Double_t lightYield;
79 gMC->SetMaxStep(
fStep);
81 if ( gMC->IsTrackEntering() ) {
84 eventID = gMC->CurrentEvent();
85 gMC->TrackPosition(posIn);
86 gMC->TrackMomentum(momIn);
87 trackID = gMC->GetStack()->GetCurrentTrackNumber();
88 time = gMC->TrackTime() * 1.0e09;
89 length = gMC->TrackLength();
90 mot0TrackID = gMC->GetStack()->GetCurrentTrack()->GetMother(0);
91 pdg = gMC->TrackPid();
92 gMC->CurrentVolOffID(3,stilbenNr);
94 const Double_t stepEloss = gMC->Edep() * 1000;
96 Double_t curLightYield = 0.;
99 if (gMC->TrackCharge()!=0) {
100 Double_t BirkC1Mod = 0;
102 if (TMath::Abs(gMC->TrackCharge())>=2)
103 BirkC1Mod=BirkC1*7.2/12.6;
107 if (gMC->TrackStep()>0)
109 Double_t dedxcm = stepEloss/gMC->TrackStep();
110 curLightYield = stepEloss /(1.+BirkC1Mod*dedxcm+BirkC2*dedxcm*dedxcm);
111 lightYield+=curLightYield;
115 if (gMC->IsTrackExiting() ||
116 gMC->IsTrackStop() ||
117 gMC->IsTrackDisappeared())
119 gMC->TrackPosition(posOut);
120 gMC->TrackMomentum(momOut);
122 if (eLoss > 0. && gMC->TrackCharge()!=0){
123 AddPoint( eventID, trackID, mot0TrackID, pdg,
124 TVector3(posIn.X(), posIn.Y(), posIn.Z()),
125 TVector3(posOut.X(), posOut.Y(), posOut.Z()),
126 TVector3(momIn.Px(), momIn.Py(), momIn.Pz()),
127 TVector3(momOut.Px(), momOut.Py(), momOut.Pz()),
128 time, length, eLoss, stilbenNr, lightYield);
135 LOG(DEBUG) <<
"ND Points Count: " << fNDPoints->GetEntriesFast() << FairLogger::endl;
141 FairRootManager* ioman = FairRootManager::Instance();
143 Fatal(
"Init",
"IO manager is not set");
144 ioman->Register(
"NDPoint",
"ND", fNDPoints, kTRUE);
155 for (Int_t i_point = 0; i_point < fNDPoints->GetEntriesFast(); i_point++){
166 LOG(DEBUG) <<
" ERND::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)" 168 Int_t nEntries = cl1->GetEntriesFast();
169 LOG(DEBUG) <<
"decector: " << nEntries <<
" entries to add" << FairLogger::endl;
170 TClonesArray& clref = *cl2;
172 for (Int_t i=0; i<nEntries; i++) {
174 Int_t index = oldpoint->GetTrackID() + offset;
175 oldpoint->SetTrackID(index);
176 new (clref[cl2->GetEntriesFast()])
ERNDPoint(*oldpoint);
178 LOG(DEBUG) <<
"decector: " << cl2->GetEntriesFast() <<
" merged entries" << FairLogger::endl;
185 TVector3 posOut, TVector3 momIn,
186 TVector3 momOut, Double_t time,
187 Double_t length, Double_t eLoss, Int_t stilbenNr, Float_t lightYield) {
188 TClonesArray& clref = *fNDPoints;
189 Int_t size = clref.GetEntriesFast();
190 return new(clref[size])
ERNDPoint(eventID, trackID, mot0trackID, pdg,
191 posIn, posOut, momIn, momOut, time, length, eLoss,stilbenNr,lightYield);
196 TString fileName = GetGeometryFileName();
197 if(fileName.EndsWith(
".root")) {
198 LOG(DEBUG) <<
"Constructing ERND geometry from ROOT file " << fileName.Data() << FairLogger::endl;
199 ConstructRootGeometry();
201 LOG(DEBUG) <<
"Geometry file name is not set" << FairLogger::endl;
208 TString volName = name;
209 if(volName.Contains(
"crystal")) {
virtual Bool_t ProcessHits(FairVolume *vol=0)
virtual Bool_t CheckIfSensitive(std::string name)
virtual void EndOfEvent()
ERNDPoint * AddPoint(Int_t eventID, Int_t trackID, Int_t mot0trackID, Int_t pdg, TVector3 posIn, TVector3 pos_out, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Int_t stilbenNr, Float_t lightYield)
Max lengt of step of track propagetion in sensetive volume.
virtual void Print(const Option_t *opt=0) const
virtual void Initialize()
Initialize ERND data.
virtual void Register()
Registers the point collection in the ROOT manager.
Double_t fStep
The point collection.
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the point collection.
virtual void Reset()
Clears the point collection.
virtual void Print(Option_t *option="") const
Screen output of hit collection.
virtual void ConstructGeometry()
Constructs the ERND geometry.