///////////////////////////////////////////////////////////// // PndTpcTBDetector // // Class for PndTpcTBDetector // ///////////////////////////////////////////////////////////// #include "PndTpcTBDetector.h" #include "FairRootManager.h" #include "FairVolume.h" #include "PndDetectorList.h" #include "PndTpcTBMCPoint.h" #include "PndStack.h" #include "PndTpcAlignmentManager.h" #include "TClonesArray.h" #include "TVirtualMC.h" #include "TGeoManager.h" #include #include #include class FairGeoLoader; class FairGeoMedia; class FairRunSim; class FairGeoInterface; class FairGeoRootBuilder; class FairGeoNode; class FairRun; class FairRuntimeDb; class FairGeoVolume; class TGeoVoxelFinder; class TObjArray; class TList; class TGeoMatrix; class TParticle; class TLorentzVector; class TKey; // ----- Default constructor ------------------------------------------- PndTpcTBDetector::PndTpcTBDetector() : fUseRadDamOption(false) { fPndTpcTBCollection = new TClonesArray("PndTpcTBMCPoint"); fPosIndex = 0; fListOfSensitives.push_back("Sensor"); if (fVerboseLevel>0) { std::cout<<"-I- PndTpcTBDetector: fListOfSensitives contains:"; for(Int_t k=0;kDelete(); delete fPndTpcTBCollection; } // delete fGeoH; } // ------------------------------------------------------------------------- void PndTpcTBDetector::Initialize() { std::cout<<" -I- Initializing PndTpcTBDetector()"<IsTrackEntering() ) { // Set parameters at entrance of volume. Reset ELoss. fELoss = 0.; fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); gMC->TrackPosition(fPosIn); gMC->TrackMomentum(fMomIn); } // Sum energy loss for all steps in the active volume // What is the active volume? fELoss += gMC->Edep(); // Create PndTpcTBMCPoint at exit of active volume if (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared() ) { fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); /* if(0==fGeoH) { std::cout<<" -E- No PndTpcTBGeoHandling loaded."< 1){ std::cout <CurrentVolPath()<getMCid()<GetID(gMC->CurrentVolPath())<TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); if (fUseRadDamOption == false){ if (fELoss == 0.) return kFALSE; } TString detPath = gMC->CurrentVolPath(); AddHit(fTrackID, kGEM, detPath,//fGeoH->GetID(detPath), TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()), TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, fLength, fELoss); //------------------------------ //Not needed, only bookkeeping? //------------------------------- // Increment number of PndTpcTB points for TParticle // //PndStack* stack = (PndStack*) gMC->GetStack(); //stack->AddPoint(kGEM); ResetParameters(); } return kTRUE; } // ------------------------------------------------------------------------- // ----- Public method EndOfEvent -------------------------------------- void PndTpcTBDetector::EndOfEvent() { if (fVerboseLevel) Print(); fPndTpcTBCollection->Clear(); fPosIndex = 0; } // ------------------------------------------------------------------------- void PndTpcTBDetector::FinishRun() { } // ----- Public method Register ---------------------------------------- void PndTpcTBDetector::Register() { FairRootManager::Instance()->Register("GEMPoint", "PndTpcTB", fPndTpcTBCollection, kTRUE); } // ------------------------------------------------------------------------- // ----- Public method GetCollection ----------------------------------- TClonesArray* PndTpcTBDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fPndTpcTBCollection; else return NULL; } // ------------------------------------------------------------------------- // ----- Public method Print ------------------------------------------- void PndTpcTBDetector::Print() const { Int_t nHits = fPndTpcTBCollection->GetEntriesFast(); std::cout << "-I- PndTpcTBDetector: " << nHits << " points registered in this event." << std::endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ------------------------------------------------------------------------- // ----- Public method Reset ------------------------------------------- void PndTpcTBDetector::Reset() { fPndTpcTBCollection->Clear(); ResetParameters(); } // ------------------------------------------------------------------------- // ----- Public method CopyClones -------------------------------------- void PndTpcTBDetector::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) { Int_t nEntries = cl1->GetEntriesFast(); std::cout << "-I- PndTpcTBDetector: " << nEntries << " entries to add." << std::endl; TClonesArray& clref = *cl2; PndTpcTBMCPoint *oldpoint = NULL; for (Int_t i=0; iAt(i); Int_t index = oldpoint->GetTrackID() + offset; oldpoint->SetTrackID(index); new (clref[fPosIndex]) PndTpcTBMCPoint(*oldpoint); fPosIndex++; } std::cout << "-I- PndTpcTBDetector: " << cl2->GetEntriesFast() << " merged entries." << std::endl; } // ------------------------------------------------------------------------- void PndTpcTBDetector::ConstructGeometry(){ TString fileName=GetGeometryFileName(); // if(fileName.EndsWith(".geo")){ // ConstructASCIIGeometry(); // }else if(fileName.EndsWith(".root")){ ConstructRootGeometry(); }else{ std::cout<< "Geometry format not supported " <= 2) std::cout << "-I- PndTpcTBDetector: Adding Point at (" << posIn.X() << ", " << posIn.Y() << ", " << posIn.Z() << ") cm,"<