// ------------------------------------------------------------------------- // ----- CbmStsHitProducerIdeal source file ----- // ----- Created 10/01/06 by V. Friese ----- // ------------------------------------------------------------------------- #include "TClonesArray.h" #include "CbmRootManager.h" #include "PndTofHitProducerIdeal.h" #include "PndTofHit.h" //#include "PndTofHitInfo.h" #include "PndTofPoint.h" #include "CbmRunAna.h" #include "CbmRuntimeDb.h" // ----- Default constructor ------------------------------------------- PndTofHitProducerIdeal::PndTofHitProducerIdeal() : CbmTask("Ideal PndTof Hit Producer") { fBranchName = "TofPoint"; fBranchName2 = "TofSciFPoint"; } // ------------------------------------------------------------------------- // ----- Default constructor ------------------------------------------- PndTofHitProducerIdeal::PndTofHitProducerIdeal(Double_t dt, Double_t dt2) : CbmTask("Ideal PndTof Hit Producer") { fBranchName = "TofPoint"; fBranchName2 = "TofSciFPoint"; fdt= dt; fdt2= dt2; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndTofHitProducerIdeal::~PndTofHitProducerIdeal() { } // ----- Public method Init -------------------------------------------- InitStatus PndTofHitProducerIdeal::Init() { // Get RootManager CbmRootManager* ioman = CbmRootManager::Instance(); if ( ! ioman ) { std::cout << "-E- PndTofHitProducerIdeal::Init: " << "RootManager not instantiated!" << std::endl; return kFATAL; } // Get input array fPointArray = (TClonesArray*) ioman->GetObject(fBranchName); if ( ! fPointArray ) { std::cout << "-W- PndTofHitProducerIdeal::Init: " << "No TofPoint array!" << std::endl; return kERROR; } fsciFPointArray = (TClonesArray*) ioman->GetObject(fBranchName2); if ( ! fsciFPointArray ) { std::cout << "-W- PndTofHitProducerIdeal::Init: " << "No TofSciFPoint array!" << std::endl; return kERROR; } // Create and register output array fHitArray = new TClonesArray("PndTofHit"); ioman->Register("TofHit", "Tof", fHitArray, kTRUE); //std::cout << "-I- PndTofHitProducerIdeal: Intialisation successfull" << std::endl; //return kSUCCESS; // Create and register output array fsciFHitArray = new TClonesArray("PndTofHit"); ioman->Register("TofSciFHit", "Tof", fsciFHitArray, kTRUE); std::cout << "-I- PndTofHitProducerIdeal: Intialisation successfull" << std::endl; return kSUCCESS; } // ------------------------------------------------------------------------- void PndTofHitProducerIdeal::SetParContainers() { // Get Base Container CbmRunAna* ana = CbmRunAna::Instance(); CbmRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar = (PndGeoTofPar*)(rtdb->getContainer("PndGeoTofPar")); } // ----- Public method Exec -------------------------------------------- void PndTofHitProducerIdeal::Exec(Option_t* opt) { // Reset output array if ( ! fHitArray ) Fatal("Exec", "No HitArray"); fHitArray->Clear(); fsciFHitArray->Clear(); // Declare some variables PndTofPoint *point = 0; PndTofPoint *sciFpoint = 0; Int_t detID = 0, // Detector ID trackID = 0; // Track index Int_t scidetID = 0, // Detector ID scitrackID = 0; // Track index Double_t time = 0.; Double_t scitime = 0.; Double_t t2 = 0.; Double_t t1 = 0.; // Loop over TofPoints Int_t nPoints = fPointArray->GetEntriesFast(); for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) { point = (PndTofPoint*) fPointArray->At(iPoint); std::cout << " Ideal Hit Producer -Point-: " << point << std::endl; if ( ! point) continue; // Detector ID detID = point->GetVolumeID(); // MCTrack ID trackID = point->GetTrackID(); TVector3 dpos; TVector3 position(point->GetXin(), point->GetYin(), point->GetZin()); //point->Position(pos); std::cout<<" x "<GetXin()<<" y " <GetYin()<<" z "<< point->GetZin()<GetTime(); t1 = 0.1;//100 ps time resolution smear(time,t1); // Create new hit new ((*fHitArray)[iPoint]) PndTofHit(trackID, detID, point->GetDetName(),time, t1, position,dpos,iPoint, point->GetEnergyLoss(),1); std::cout << "Hit created for module: " << point->GetDetName() << std::endl; } // Loop over MCPoints // Loop over TofsciFPoints Int_t nFPoints = fsciFPointArray->GetEntriesFast(); for (Int_t iFPoint = 0; iFPoint < nFPoints; iFPoint++) { sciFpoint = (PndTofPoint*) fsciFPointArray->At(iFPoint); std::cout << " Ideal Hit Producer -Point-: " << sciFpoint << std::endl; if ( ! point) continue; // Detector ID scidetID = sciFpoint->GetVolumeID(); // MCTrack ID scitrackID = sciFpoint->GetTrackID(); TVector3 dpos2; TVector3 pos(sciFpoint->GetXin(), sciFpoint->GetYin(), sciFpoint->GetZin()); //point->Position(pos); std::cout<<" x "<GetXin()<<" y " <GetYin()<<" z "<< sciFpoint->GetZin()<GetTime(); t2 = 1;//100 ps time resolution smear(scitime,t2); // Create new hit new ((*fsciFHitArray)[iFPoint]) PndTofHit(scitrackID, scidetID, sciFpoint->GetDetName(), scitime, t2, pos,dpos2,iFPoint, sciFpoint->GetEnergyLoss(),1); std::cout << "sciFHit created for module: " << sciFpoint->GetDetName() << std::endl; } // Event summary std::cout << "-I- PndTofHitProducerIdeal: " << nPoints << " TofPoints, " << nPoints << " Hits created." << std::endl; // Event summary std::cout << "-I- PndTofHitProducerIdeal: " << nFPoints << " SciFTofPoints, " << nFPoints << "sciF Hits created." << std::endl; } // ------------------------------------------------------------------------- void PndTofHitProducerIdeal::smear(Double_t& time, Double_t& fdt) { /// smear a 3d vector Double_t t = time; // y=pos.y(), // z=pos.z(), Double_t sigt = fdt; //sigy=dpos.y(), // sigz=dpos.z(); sigt=gRandom->Gaus(0,sigt); //sigy=gRandom->Gaus(0,sigy); //sigz=gRandom->Gaus(0,sigz); t += sigt; //y += sigy; //z += sigz; time = t; return; } ClassImp(PndTofHitProducerIdeal)