// ------------------------------------------------------------------------- // ----- RpcTofHitProducerIdeal source file ----- // ----- Created 07/03/06 by V. Friese ----- // modified 04/12/07 by A. Galoyan // ------------------------------------------------------------------------- #include "TClonesArray.h" #include "CbmRootManager.h" #include "CbmRunAna.h" #include "CbmRuntimeDb.h" #include "CbmRun.h" #include "PndRpcHitProducerIdeal.h" #include "PndRpcHit.h" #include "PndRpcPoint.h" #include "TVector3.h" #include "TRandom.h" // ----- Default constructor ------------------------------------------- PndRpcHitProducerIdeal::PndRpcHitProducerIdeal() : CbmTask("Ideal TOF Hit Producer") { } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndRpcHitProducerIdeal::~PndRpcHitProducerIdeal() { } // ------------------------------------------------------------------------- // ----- Public method Init -------------------------------------------- InitStatus PndRpcHitProducerIdeal::Init() { // Get RootManager std::cout << " INITIALIZATION OF Ideal Tof Hit Producer**"<< std::endl; CbmRootManager* ioman = CbmRootManager::Instance(); if ( ! ioman ) { cout << "-E- PndRpcHitProducerIdeal::Init: " << "RootManager not instantised!" << endl; return kFATAL; } // Get input array fPointArray = (TClonesArray*) ioman->GetObject("PndRpcPoint"); if ( ! fPointArray ) { cout << "-W- PndRpcHitProducerIdeal::Init: " << "No PndRpcPoint array!" << endl; return kERROR; } // Create and register output array fHitArray = new TClonesArray("PndRpcHit"); ioman->Register("PndRpcHit", "PNDRPC", fHitArray, kTRUE); cout << "-I- PndRpcHitProducerIdeal: Intialisation successfull" << endl; return kSUCCESS; } // ------------------------------------------------------------------------- // ----- Public method Exec -------------------------------------------- void PndRpcHitProducerIdeal::Exec(Option_t* opt) { // Reset output array if ( ! fHitArray ) Fatal("Exec", "No PndRpcHitArray"); fHitArray->Clear(); // Declare some variables PndRpcPoint* point = NULL; Int_t detID = 0; // Detector ID Int_t trackID = 0; // Track index Double_t x, y, z; // Position Double_t dx = 0.0001; // Position error Double_t tof = 0.; // Time of flight TVector3 pos, dpos; // Position and error vectors // Loop over PndRpcPoints Int_t nPoints = fPointArray->GetEntriesFast(); for (Int_t iPoint=0; iPointAt(iPoint); if ( ! point) continue; // Detector ID detID = point->GetDetId(); // MCTrack ID trackID = point->GetTrackID(); // Determine hit position x = point->GetX(); y = point->GetY(); z = point->GetZ(); // Time of flight tof = point->GetTime(); Double_t sig_t=0.075; // sigma_tof=75 ps Double_t tof_s = gRandom->Gaus(tof, sig_t); // Smear(tof, sig_t); pos.SetXYZ(x,y,z); dpos.SetXYZ(dx, dx, dx); // Create new hit new ((*fHitArray)[iPoint]) PndRpcHit(detID, pos, dpos, tof_s, iPoint); } // Loop over MCPoints // Event summary cout << "-I- PndRpcHitProducerIdeal: " << nPoints << " PndRpcPoints, " << nPoints << " Hits created." << endl; } // ------------------------------------------------------------------------- /* // ----- Private Method Smear---------------------------------------------- Double_t PndRpcIdealHitProducer::Smear(Double_t tof, Double_t sig_t) { Double_t tof_n = gRandom->Gaus(tof, sig_t); return tof_n; } */ ClassImp(PndRpcHitProducerIdeal)