16 #include "FairGeoInterface.h"
17 #include "FairGeoLoader.h"
18 #include "FairGeoNode.h"
19 #include "FairGeoRootBuilder.h"
20 #include "FairRootManager.h"
21 #include "FairRuntimeDb.h"
22 #include "FairVolume.h"
24 #include "TClonesArray.h"
25 #include "TLorentzVector.h"
26 #include "TParticle.h"
27 #include "TVirtualMC.h"
28 #include "TGeoMatrix.h"
29 #include "TObjArray.h"
31 #include "TGeoMedium.h"
32 #include "TGeoVolume.h"
42 #define innerStrawDiameter 1.
47 : fTrackID(0), fVolumeID(0), fPosInLocal(0,0,0), fPosOutLocal(0,0,0),
48 fMomIn(0,0,0), fMomOut(0,0,0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0),
49 fSttCollection(0), fpostot(0,0,0), fpostotin(0,0,0), fpostotout(0,0,0), fPassNodes(new TObjArray()), fGeoType(0), fInFlag(0)
60 : FairDetector(name, active),
61 fTrackID(0), fVolumeID(0), fPosInLocal(0,0,0), fPosOutLocal(0,0,0),
62 fMomIn(0,0,0), fMomOut(0,0,0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0),
63 fSttCollection(0), fpostot(0,0,0), fpostotin(0,0,0), fpostotout(0,0,0), fPassNodes(new TObjArray()), fGeoType(0), fInFlag(0)
88 std::cout <<
"-I- Initializing PndStt()" << std::endl;
92 std::cout <<
" -E- No gGeoManager in PndStt::Initialize()! aborting" << std::endl;
107 gMC->TrackPosition(entryPosition);
108 positionInMother[0] = entryPosition.X();
109 positionInMother[1] = entryPosition.Y();
110 positionInMother[2] = entryPosition.Z();
111 gMC->Gmtod(positionInMother, positionInStraw, 1);
113 return positionInStraw[0] * positionInStraw[0] +
114 positionInStraw[1] * positionInStraw[1];
124 pos = aSrc.find(aDelim);
126 aDest = aSrc.substr(0, pos);
128 if(pos != string::npos)
129 aSrc = aSrc.substr(pos + 1);
145 while(
Split(sub, aSrc, aDelim))
163 TString vol_name(gMC->CurrentVolName());
165 gMC->GetTransformation(gMC->CurrentVolPath(), M);
174 Double_t globalPos[3] = { 0., 0., 0.};
175 Double_t localPos[3] = { 0., 0., 0. };
178 if (gMC->TrackCharge() != 0.)
180 if ( gMC->IsTrackEntering())
185 fTime = gMC->TrackTime() * 1.0e09;
187 gMC->TrackPosition(globalPos[0], globalPos[1], globalPos[2]);
188 gMC->TrackMomentum(mom);
190 fpostotin.SetXYZ(globalPos[0], globalPos[1], globalPos[2]);
191 fMomIn.SetXYZ(mom.X(), mom.Y(), mom.Z());
193 gMC->Gmtod(globalPos, localPos, 1);
194 fPosInLocal.SetXYZ(localPos[0], localPos[1], localPos[2]);
201 if ( (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared())
206 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
208 fMass = gMC->TrackMass();
209 gMC->TrackPosition(globalPos[0], globalPos[1], globalPos[2]);
210 gMC->TrackMomentum(mom);
212 fpostotout.SetXYZ(globalPos[0], globalPos[1], globalPos[2]);
213 fMomOut.SetXYZ(mom.X(), mom.Y(), mom.Z());
215 gMC->Gmtod(globalPos, localPos, 1);
216 fPosOutLocal.SetXYZ(localPos[0], localPos[1], localPos[2]);
272 FairRootManager::Instance()->Register(
"STTPoint",
"Stt",
fSttCollection, kTRUE);
296 cout <<
"-I- PndStt: " << nHits <<
" points registered in this event." << endl;
320 nEntries = cl1->GetEntriesFast();
322 cout <<
"-I- PndStt: " << nEntries <<
" entries to add." << endl;
324 TClonesArray& clref = *cl2;
328 for (Int_t
i=0;
i<nEntries;
i++)
333 index = oldpoint->GetTrackID() +
offset;
335 oldpoint->SetTrackID(index);
339 cout <<
"-I- PndStt: " << cl2->GetEntriesFast() <<
" merged entries."
349 TString fileName = GetGeometryFileName();
350 if (fileName.EndsWith(
".root"))
353 }
else if (fileName.Contains(
"straws_skewed_blocks_35cm_pipe.geo"))
358 cout <<
"-E- STT: this geometry is not supported now" << endl;
362 FairRun *
fRun = FairRun::Instance();
363 FairRuntimeDb *
rtdb = FairRun::Instance()->GetRuntimeDb();
372 ConstructRootGeometry();
382 FairGeoLoader*
geoLoad = FairGeoLoader::Instance();
383 FairGeoInterface*
geoFace = geoLoad->getGeoInterface();
385 Geo->setGeomFile(GetGeometryFileName());
386 geoFace->addGeoModule(Geo);
388 Bool_t rc = geoFace->readSet(Geo);
389 if (rc) Geo->create(geoLoad->getGeoBuilder());
392 TList* volList = Geo->getListOfVolumes();
393 FairRun *fRun = FairRun::Instance();
394 FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb();
396 TListIter iter(volList);
398 if (GetGeometryFileName().Contains(
"straws_skewed_blocks_35cm_pipe.geo"))
401 cout <<
"-E- STT: this geometry is not supported now" << endl;
405 cout <<
"-I- STT total number of tubes: " << tubecounter << endl;
407 par->setInputVersion(fRun->GetRunId(), 1);
409 ProcessNodes(volList);
411 cout <<
"-I- PndStt::ConstructGeometry : STT total number of tubes: " << tubecounter << endl;
413 par->setInputVersion(fRun->GetRunId(), 1);
423 TVector3
pos, TVector3 posInLocal, TVector3 posOutLocal,
424 TVector3 momIn, TVector3 momOut,
431 size = clref.GetEntriesFast();
435 length, eLoss, mass);
451 if (fVerboseLevel>0) {
452 std::cout<<
"- I - PndSTTDetector: fListOfSensitives contains:";
455 std::cout<<std::endl;
Int_t FillSttTubeParametersType2(PndGeoSttPar *par)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
virtual void Initialize()
virtual void Print() const
void SetDefaultSensorNames()
void CreateUniqueSensorId(TString startName, std::vector< std::string > listOfSensitives)
Has to be called during simulation to create unique sensor id.
Int_t fVolumeID
track index
TGeoManager * gGeoManager
Int_t FillSttTubeParameters(PndGeoSttPar *par, TList *volList)
void AddPoint(DetectorId iDet)
Int_t GetTubeIDFromPath(TString path)
std::vector< std::string > fListOfSensitives
Double_t fMass
energy loss
PndSttPoint * AddHit(Int_t trackID, Int_t detID, Int_t tubeID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass)
TVector3 fpostot
Hit collection.
virtual void EndOfEvent()
bool Split(std::string &aDest, std::string &aSrc, char aDelim)
float GetSquaredDistanceFromWire()
void SetTubeID(Int_t tubeid)
TVector3 fPosInLocal
volume id
Int_t GetShortID(TString path)
for a given path the (unique) position of the sensor path in the fSensorNamePar-List is given...
static PndGeoHandling * Instance()
bool CheckIfSensitive(std::string name)
TClonesArray * fSttCollection
virtual Bool_t ProcessHits(FairVolume *vol=0)
virtual void ConstructGeometry()
std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim)
TVector3 fMomIn
exit position in straw frame
TVector3 fPosOutLocal
entry position in straw frame
FairGeoInterface * geoFace
virtual TClonesArray * GetCollection(Int_t iColl) const