///////////////////////////////////////////////////////////// // RpcBarrelTofDetector // // Class for RpcBarrelTofDetector // ///////////////////////////////////////////////////////////// #include using std::cout; using std::endl; #include "TClonesArray.h" #include "TGeoMCGeometry.h" #include "TGeoManager.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "CbmGeoInterface.h" #include "CbmGeoLoader.h" #include "CbmGeoNode.h" #include "CbmGeoRootBuilder.h" #include "CbmStack.h" #include "CbmRootManager.h" #include "CbmVolume.h" #include "PndRpcGeo.h" #include "PndRpcDetector.h" #include "PndRpcPoint.h" #include "CbmGeoG3Builder.h" #include "CbmRuntimeDb.h" #include "PndRpcGeoPar.h" #include "TObjArray.h" #include "CbmRun.h" // ----- Default constructor ------------------------------------------- PndRpcDetector::PndRpcDetector() { fRpcPointCollection = new TClonesArray("PndRpcPoint"); fPosIndex = 0; // fDetectorID = 0; fVerboseLevel = 2; } // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ PndRpcDetector::PndRpcDetector(const char* name, Bool_t active) : CbmDetector(name, active) { fRpcPointCollection = new TClonesArray("PndRpcPoint"); fPosIndex = 0; // fDetectorID = 0; fVerboseLevel = 2; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndRpcDetector::~PndRpcDetector() { if (fRpcPointCollection) { fRpcPointCollection->Delete(); delete fRpcPointCollection; } } // ------------------------------------------------------------------------- // ----- Public method Intialize // --------------------------------------- void PndRpcDetector::Initialize() { CbmDetector::Initialize(); CbmRun* sim = CbmRun::Instance(); CbmRuntimeDb* rtdb=sim->GetRuntimeDb(); PndRpcGeoPar *par=(PndRpcGeoPar*)(rtdb->getContainer("PndRpcGeoPar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); } //-------------------------------------------------------- /* void RpcDetector::BeginEvent(){ //cout<<">>>>>>>>>>>>>>>>>>>>inizio evento "<IsTrackEntering() ) { //a fELoss = 0.; fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); gMC->TrackPosition(fPos); gMC->TrackMomentum(fMom); // GeV fEventID = gMC->CurrentEvent(); // fmass = gMC->TrackMass(); // mass (GeV) // fcharge = gMC->TrackCharge(); // charge? // Sum energy loss for all steps in the active volume //a fELoss += gMC->Edep(); fELoss = gMC->Edep(); //a // Set additional parameters at exit of active volume. if ( gMC->TrackCharge()!=0){ //a && //a gMC->IsTrackExiting() || //a gMC->IsTrackStop() || //a gMC->IsTrackDisappeared() ) fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); // trk ID TString Volname = gMC->CurrentVolName(); // Volname = vol->getName(); region = Volname[5]-'0'; gMC->CurrentVolID(gap); gMC->CurrentVolOffID(1, cell); gMC->CurrentVolOffID(2, module); fVolumeID = ((region-1)<<24) + ((module-1)<<14)+((cell-1)<<4)+(gap-1); AddHit(fTrackID, fVolumeID, TVector3(fPos.X(), fPos.Y(), fPos.Z()), TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength, fELoss,fEventID); cout << "PARAMETERS ----------" << endl; cout << "trk " << fTrackID << " vol " << fVolumeID <GetStack(); //a stack->AddPoint(kTOF); } } // TO BE SET AS DEBUG ResetParameters(); return kTRUE; } // ---------------------------------------------------------------------------- // ----- Public method EndOfEvent ----------------------------------------- void PndRpcDetector::EndOfEvent() { if (fVerboseLevel) Print(); Reset(); } // ---------------------------------------------------------------------------- // ----- Public method Register ------------------------------------------- void PndRpcDetector::Register() { CbmRootManager::Instance()->Register("PndRpcPoint","Rpc", fRpcPointCollection, kTRUE); } // ---------------------------------------------------------------------------- // ----- Public method GetCollection -------------------------------------- TClonesArray* PndRpcDetector::GetCollection(Int_t iColl) const { if (iColl == 0) return fRpcPointCollection; return NULL; } // ---------------------------------------------------------------------------- // ----- Public method Print ---------------------------------------------- void PndRpcDetector::Print() const { Int_t nHits = fRpcPointCollection->GetEntriesFast(); cout << "-I- RpcDetector: " << nHits << " points registered in this event." << endl; if (fVerboseLevel>1) for (Int_t i=0; iPrint(); } // ---------------------------------------------------------------------------- // ----- Public method Reset ---------------------------------------------- void PndRpcDetector::Reset() { fRpcPointCollection->Clear(); fPosIndex = 0; } // ---------------------------------------------------------------------------- // ----- Public method CopyClones ----------------------------------------- void PndRpcDetector::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset ) { Int_t nEntries = cl1->GetEntriesFast(); cout << "-I- RpcTofDetector: " << nEntries << " entries to add." << endl; TClonesArray& clref = *cl2; PndRpcPoint* oldpoint = NULL; for (Int_t i=0; iAt(i); Int_t index = oldpoint->GetTrackID() + offset; oldpoint->SetTrackID(index); new (clref[fPosIndex]) PndRpcPoint(*oldpoint); fPosIndex++; } cout << " -I- RpcTofDetector: " << cl2->GetEntriesFast() << " merged entries." << endl; } // ---------------------------------------------------------------------------- // ----- Public method ConstructGeometry ---------------------------------- void PndRpcDetector::ConstructGeometry() { Int_t count=0; Int_t count_tot=0; std::cout<<" --- Building RpcTof Geometry ---"<getGeoInterface(); PndRpcGeo* rpcGeo = new PndRpcGeo(); rpcGeo->setGeomFile(GetGeometryFileName()); std::cout<<"Geometry filename = "<addGeoModule(rpcGeo); Bool_t rc = geoIFace->readSet(rpcGeo); if (rc) rpcGeo->create(geoLoad->getGeoBuilder()); else std::cerr<<"RpcTofDetector:: geometry could not be read!"<getListOfVolumes(); std::cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<GetEntries()<<" volumes"<GetRuntimeDb(); PndRpcGeoPar* par=(PndRpcGeoPar*)(rtdb->getContainer("PndRpcGeoPar")); TObjArray *fSensNodes = par->GetGeoSensitiveNodes(); TObjArray *fPassNodes = par->GetGeoPassiveNodes(); TListIter iter(volList); CbmGeoNode* node = NULL; CbmGeoVolume *aVol=NULL; while( (node = (CbmGeoNode*)iter.Next()) ) { std::cout<<"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<< node->GetName()< ( node ); if ( node->isSensitive() ) { fSensNodes->AddLast( aVol ); count++; }else{ fPassNodes->AddLast( aVol ); } count_tot++; } ProcessNodes( volList ); par->setChanged(); par->setInputVersion(fRun->GetRunId(),1); // set active/inactive std::cout<<"koniec"<1) return new(clref[size]) PndRpcPoint(trackID, detID, pos, mom, time, length, eLoss, eventID); } // ---------------------------------------------------------------------------- ClassImp(PndRpcDetector)