13 #include "ERSensPlane.h" 15 #include "TClonesArray.h" 16 #include "TLorentzVector.h" 17 #include "TParticle.h" 19 #include "TVirtualMC.h" 20 #include "TGeoMatrix.h" 22 #include "FairRootManager.h" 23 #include "FairLogger.h" 25 #include "ERSensPlanePoint.h" 29 : FairDetector(
"ERSensPlane", kTRUE)
31 fPoints =
new TClonesArray(
"ERSensPlanePoint", 1000);
32 fPositionRotation =
new TGeoCombiTrans(
"ERSensPlanePosRot", 0., 0., 0.,
33 new TGeoRotation(
"ERSensPlaneRot", 0., 0., 0.));
39 : FairDetector(name, active)
41 fPoints =
new TClonesArray(
"ERSensPlanePoint", 1000);
42 fPositionRotation =
new TGeoCombiTrans(
"ERSensPlanePosRot", 0., 0., 0.,
43 new TGeoRotation(
"ERSensPlaneRot", 0., 0., 0.));
54 if (fPositionRotation) {
55 delete fPositionRotation;
61 void ERSensPlane::SetDetectorPosition(Double_t x, Double_t y, Double_t z)
63 fPositionRotation->SetDx(x);
64 fPositionRotation->SetDy(y);
65 fPositionRotation->SetDz(z);
70 void ERSensPlane::Initialize()
72 FairDetector::Initialize();
81 static Int_t mot0TrackID;
83 static TLorentzVector posIn, posOut;
84 static TLorentzVector momIn, momOut;
85 static Double32_t time;
86 static Double32_t length;
87 static Double32_t eLoss;
91 if (gMC->IsTrackEntering()) {
94 eventID = gMC->CurrentEvent();
95 gMC->TrackPosition(posIn);
96 gMC->TrackMomentum(momIn);
97 trackID = gMC->GetStack()->GetCurrentTrackNumber();
98 time = gMC->TrackTime() * 1.0e09;
99 length = gMC->TrackLength();
100 mot0TrackID = gMC->GetStack()->GetCurrentTrack()->GetMother(0);
101 mass = gMC->ParticleMass(gMC->TrackPid());
104 eLoss += gMC->Edep();
106 if (gMC->IsTrackExiting() ||
107 gMC->IsTrackStop() ||
108 gMC->IsTrackDisappeared())
110 gMC->TrackPosition(posOut);
111 gMC->TrackMomentum(momOut);
118 TVector3(posIn.X(), posIn.Y(), posIn.Z()),
119 TVector3(posOut.X(), posOut.Y(), posOut.Z()),
120 TVector3(momIn.Px(), momIn.Py(), momIn.Pz()),
121 TVector3(momOut.Px(), momOut.Py(), momOut.Pz()),
133 void ERSensPlane::BeginEvent() {
138 void ERSensPlane::EndOfEvent() {
145 void ERSensPlane::Register() {
146 FairRootManager* ioman = FairRootManager::Instance();
147 if (!ioman) Fatal(
"Init",
"IO manager is not set");
148 ioman->Register(
"ERSensPlanePoint",
"ERSensPlane", fPoints, kTRUE);
153 TClonesArray* ERSensPlane::GetCollection(Int_t iColl)
const {
163 void ERSensPlane::Print(Option_t *option)
const {
168 void ERSensPlane::Reset() {
175 void ERSensPlane::CopyClones(TClonesArray* cl1,
182 void ERSensPlane::ConstructGeometry()
184 TString fileName = GetGeometryFileName();
185 if (fileName ==
"") {
186 LOG(FATAL) <<
"ERSensPlane geometry file name is not set." << FairLogger::endl;
187 }
else if(fileName.EndsWith(
".root")) {
188 LOG(INFO) <<
"Constructing ERSensPlane geometry from ROOT file " << fileName.Data() << FairLogger::endl;
189 ConstructRootGeometry((TGeoMatrix*)(fPositionRotation));
190 }
else if(fileName.EndsWith(
".gdml")) {
191 LOG(INFO) <<
"Constructing ERSensPlane geometry from GDML file " << fileName.Data() << FairLogger::endl;
192 ConstructGDMLGeometry(fPositionRotation);
194 LOG(FATAL) <<
"ERSensPlane geometry file name is not correct." << FairLogger::endl;
200 Bool_t ERSensPlane::CheckIfSensitive(std::string name)
221 TClonesArray& clref = *fPoints;
222 Int_t size = clref.GetEntriesFast();
virtual Bool_t ProcessHits(FairVolume *vol=0)