///////////////////////////////////////////////////////////// // // PndSciT // // // created by A. Sanchez // /////////////////////////////////////////////////////////////// #include "PndSciT.h" #include "PndSciTPoint.h" #include "FairGeoTransform.h" #include "FairGeoInterface.h" #include "FairGeoLoader.h" #include "FairGeoNode.h" #include "FairGeoMedium.h" #include "FairGeoInterface.h" #include "FairGeoMedia.h" //#include "PndGeoSciT.h" #include "FairGeoRootBuilder.h" #include "PndStack.h" #include "FairRootManager.h" #include "FairVolume.h" #include "FairRuntimeDb.h" #include "FairRun.h" #include "PndDetectorList.h" #include "TClonesArray.h" #include "TGeoManager.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "TString.h" #include "TList.h" #include "TGeoBBox.h" #include "TGeoMCGeometry.h" #include "TObjArray.h" #include "TGeoVoxelFinder.h" #include "TGeoMatrix.h" //#include "FairGeoG3Builder.h" #include #include #include using std::cout; using std::endl; using std::ostringstream; // ----- Default constructor ------------------------------------------- PndSciT::PndSciT() : FairDetector(), fSciTCollection(0), fVolumeID(-1), pvId(0) { fSciTCollection = new TClonesArray("PndSciTPoint"); fVerboseLevel = 0; fListOfSensitives.push_back("SciTil");//Root_Test.root } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ PndSciT::PndSciT(const char* name, Bool_t active) : FairDetector(name, active), fSciTCollection(0), fVolumeID(-1), pvId(0) { fSciTCollection = new TClonesArray("PndSciTPoint"); fVerboseLevel = 0; fListOfSensitives.push_back("SciTil");//Root_Test.root } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndSciT::~PndSciT() { if (fSciTCollection) { fSciTCollection->Delete(); delete fSciTCollection; } } // ------------------------------------------------------------------------- // ----- Public method Intialize --------------------------------------- void PndSciT::Initialize() { // Init function FairDetector::Initialize(); FairRun* sim = FairRun::Instance(); FairRuntimeDb* rtdb=sim->GetRuntimeDb(); par=(PndGeoSciTPar*)(rtdb->getContainer("PndGeoSciTPar")); par->setChanged(); par->setInputVersion(sim->GetRunId(),1); TGeoMedium *pv= gGeoManager->GetMedium("polyvinyltoluene"); pvId= pv->GetId(); std::cout<<" -I- Initializing PndSciT()"<CurrentVolName(); Int_t nSiL = -1; Double_t beta, gamma; TString nam; ostringstream FullName,matName; Int_t medId = gMC->CurrentMedium(); TVector3 radt; if(medId==pvId){ if ( gMC->IsTrackEntering() ) { fELoss = 0.; fEventID = gMC->CurrentEvent(); fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); gMC->TrackPosition(fPosIn); gMC->TrackMomentum(fMomIn); } // Sum energy loss for all steps in the active volume fELoss += gMC->Edep(); // Set additional parameters at exit of active volume. Create CbmStsPoint. TLorentzVector PL; gMC->TrackMomentum(PL); if ( (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() )) { fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); Int_t cp=-1; fVolumeID = vol->getCopyNo(); FullName <CurrentVolPath(); nam = FullName.str(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); if (fELoss == 0. ) return kFALSE; AddHit(fTrackID, fEventID,fVolumeID, FullName.str(), TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, fLength,fELoss); PndStack* stack = (PndStack*) gMC->GetStack(); stack->AddPoint(kTOF); ResetParameters(); } } //return kTRUE; return kTRUE; }//ProcessHits // ---------------------------------------------------------------------------- // ----- Public method EndOfEvent ----------------------------------------- void PndSciT::EndOfEvent() { if (fVerboseLevel) Print(); Reset(); } // ---------------------------------------------------------------------------- // ----- Public method Register ------------------------------------------- void PndSciT::Register() { FairRootManager::Instance()->Register("SciTPoint","PndSciT", fSciTCollection, kTRUE); } // ---------------------------------------------------------------------------- // ----- Public method GetCollection -------------------------------------- TClonesArray* PndSciT::GetCollection(Int_t iColl) const { if (iColl == 0) return fSciTCollection; return NULL; } // ---------------------------------------------------------------------------- // ----- Public method Print ---------------------------------------------- void PndSciT::Print() const { Int_t nHits = fSciTCollection->GetEntriesFast(); cout << "-I- PndSciT: " << nHits << " points registered in this event." << endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ---------------------------------------------------------------------------- // ----- Public method Reset ---------------------------------------------- void PndSciT::Reset() { fSciTCollection->Clear(); fPosIndex = 0; } // ---------------------------------------------------------------------------- // ----- Public method CopyClones ----------------------------------------- void PndSciT::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset ) { Int_t nEntries = cl1->GetEntriesFast(); //cout << "-I- PndSciT: " << nEntries << " entries to add." << endl; TClonesArray& clref = *cl2; PndSciTPoint* oldpoint = NULL; for (Int_t i=0; iAt(i); Int_t index = oldpoint->GetTrackID() + offset; oldpoint->SetTrackID(index); new (clref[fPosIndex]) PndSciTPoint(*oldpoint); fPosIndex++; } cout << " -I- PndSciT: " << cl2->GetEntriesFast() << " merged entries." << endl; } // ---------------------------------------------------------------------------- // ----- Public method ConstructGeometry ---------------------------------- void PndSciT::ConstructGeometry() { TString fileName=GetGeometryFileName(); if(fileName.EndsWith(".root")){ ConstructRootGeometry(); }else { cout<<" geometry format not supported"<