9 #include "ERDetector.h" 11 #include "TGeoMatrix.h" 12 #include "TVirtualMC.h" 15 #include "FairRuntimeDb.h" 16 #include "FairRootManager.h" 17 #include "FairLogger.h" 19 #include "ERDetectorGeoPar.h" 22 : FairDetector(
"ERDetector", kTRUE, -1)
24 flGeoPar =
new TList();
25 flGeoPar->SetName( GetName());
30 : FairDetector(Name, Active, DetId)
32 flGeoPar =
new TList();
33 flGeoPar->SetName( GetName());
38 TString fileName = GetGeometryFileName();
39 if(fileName.EndsWith(
".root")) {
40 LOG(INFO) <<
"Constructing geometry from ROOT file " << fileName.Data() << FairLogger::endl;
41 ConstructRootGeometry();
43 else if (fileName.EndsWith(
".gdml")) {
44 LOG(INFO) <<
"Constructing geometry from GDML file " << fileName.Data() << FairLogger::endl;
45 TGeoRotation *zeroRotation =
new TGeoRotation();
46 zeroRotation->RotateX(0.);
47 zeroRotation->RotateY(0.);
48 zeroRotation->RotateZ(0.);
49 ConstructGDMLGeometry(
new TGeoCombiTrans(.0,.0,.0, zeroRotation));
52 LOG(FATAL) <<
"Geometry file name is not set" << FairLogger::endl;
61 if (fSenVolumes.size() > iColl){
62 auto it = fSenVolumes.begin();
63 for (Int_t i = 0; i<iColl; i++){it++;}
72 FairDetector::Initialize();
73 FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
78 FairRootManager* ioman = FairRootManager::Instance();
80 LOG(FATAL) <<
"IO manager is not set" << FairLogger::endl;
82 for(
const auto &itSen: fSenVolumes){
83 ioman->Register(fName+itSen.first+TString(
"Point"),fName, itSen.second, kTRUE);
89 static const Double_t dP = 1.032 ;
90 static const Double_t BirkC1 = 0.013/dP;
91 static const Double_t BirkC2 = 9.6e-6/(dP * dP);
96 if (gMC->IsTrackEntering()) {
102 Double_t curLightYield = 0.;
105 if (gMC->TrackCharge()!=0) {
106 Double_t BirkC1Mod = 0;
108 if (TMath::Abs(gMC->TrackCharge())>=2)
109 BirkC1Mod=BirkC1*7.2/12.6;
113 if (gMC->TrackStep()>0){
114 Double_t dedxcm=gMC->Edep()*1000./gMC->TrackStep();
115 curLightYield=gMC->Edep()*1000./(1.+BirkC1Mod*dedxcm+BirkC2*dedxcm*dedxcm);
116 curLightYield /= 1000.;
121 if (gMC->IsTrackExiting() ||
122 gMC->IsTrackStop() ||
123 gMC->IsTrackDisappeared()) {
138 for(
const auto &itSen: fSenVolumes){
139 TClonesArray* points = itSen.second;
140 for (Int_t i_point = 0; i_point < points->GetEntriesFast(); i_point++) {
148 for(
const auto &itSen: fSenVolumes){
149 TClonesArray* points = itSen.second;
158 Int_t nEntries = cl1->GetEntriesFast();
159 LOG(DEBUG) <<
"ERDetector: " << nEntries <<
" entries to add" << FairLogger::endl;
160 TClonesArray& clref = *cl2;
162 for (Int_t i=0; i<nEntries; i++) {
163 oldpoint = (
ERPoint*) cl1->At(i);
164 Int_t index = oldpoint->GetTrackID() + offset;
165 oldpoint->SetTrackID(index);
166 new (clref[cl2->GetEntriesFast()])
ERPoint(*oldpoint);
168 LOG(DEBUG) <<
"ERDetector: " << cl2->GetEntriesFast() <<
" merged entries" << FairLogger::endl;
173 TString curVolName = name;
174 for(
const auto &volNameSubsting:
fSenNames){
175 if(curVolName.Contains(volNameSubsting)){
176 fSenVolumes[curVolName] =
new TClonesArray(
"ERPoint");
187 gMC->TrackPosition(
fPosIn);
188 gMC->TrackMomentum(
fMomIn);
189 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
190 fTimeIn = gMC->TrackTime() * 1.0e09;
192 fMot0TrackID = gMC->GetStack()->GetCurrentTrack()->GetMother(0);
193 fMass = gMC->ParticleMass(gMC->TrackPid());
194 Int_t curVolId, corOffVolId;
195 curVolId = gMC->CurrentVolID(
fVolNb);
197 gMC->GetTransformation(gMC->CurrentVolPath(), matrix);
198 Double_t globalPos[3],localPos[3];
199 fPosIn.Vect().GetXYZ(globalPos);
200 matrix.MasterToLocal(globalPos,localPos);
201 fPosInLocal.SetXYZ(localPos[0],localPos[1],localPos[2]);
207 fTimeOut = gMC->TrackTime() * 1.0e09;
210 TClonesArray* points = fSenVolumes[gMC->CurrentVolName()];
219 TClonesArray& clref = *points;
220 Int_t size = clref.GetEntriesFast();
TLorentzVector fMomOut
point start momentum
TLorentzVector fMomIn
point start momentum
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Copies the points collection with a given track index offset.
Int_t fTrackID
track index
virtual void Reset()
Clears the point and steps collections Virtual from FairDetector.
Float_t fFullLY
Sum Light Yield in event in sensetive volume.
virtual void Print(Option_t *option="") const
Screen log Prints NeuRadPoint information Virtual from TObject.
Double_t fLightYield
light yield
virtual TClonesArray * GetCollection(Int_t iColl) const
Get array of ERNeuRadPoint.
void StartNewPoint()
Start new point creation. Reinit current point data.
virtual void Print(const Option_t *opt=0) const
Float_t fFullEnergy
Sum Edep in event in sensetive volume.
void FinishNewPoint()
Finish point creation. Call AddPoint()
virtual void EndOfEvent()
Action at end of event Short status log and Reset(). Virtual from FairDetector.
ERDetector()
Default constructor.
virtual void Initialize()
Initialisation class method FairDetector::Initialize() is called. NeuRadGeoPar init from RuntimeDB Vi...
TVector3 fPosInLocal
point position in sensetive volume CS
Int_t fMot0TrackID
0th mother track index
std::vector< TString > fSenNames
Sensetive volumes sustring, that user set.
Int_t fEventID
event index
Int_t fVerbose
Verbosity level.
virtual Bool_t CheckIfSensitive(std::string name)
Check whether a volume is sensitive.
virtual Bool_t ProcessHits(FairVolume *vol=0)
Virtual method Defines the action to be taken when a step is inside the active volume. Creates a ERNeuRadPoint and adds it to the collection.
Int_t fVolNb
number of fiber in pixel
The data class for storing pieces of charged tracks in sensitive volumes in NeuRad.
virtual void ConstructGeometry()
ERPoint * AddPoint(TClonesArray *points)
Adds a Point to the Point Collection.
TLorentzVector fPosIn
point start position
virtual void Register()
Register output array (NeuRadPoint) to the I/O manager Abstract from FairDetector.
void AddSensetive(TString name)
Add sensetive volume name. Create new points collection.
Double32_t fTimeOut
point finish time
Double32_t fTimeIn
point start time
The base class for detector simulation in er sim.
Double32_t fELoss
energy loss
Double32_t fTrackLength
track length from his origin
TLorentzVector fPosOut
point finish position