///////////////////////////////////////////////////////////// // // CbmHypHitProducer // // Filler of CbmHypHit // // // /////////////////////////////////////////////////////////////// #include "TClonesArray.h" #include "CbmRootManager.h" #include "CbmDetector.h" #include "CbmHypHitProducer.h" #include "CbmHypHit.h" #include "CbmHypPoint.h" #include "TGeoManager.h" #include "TGeoVolume.h" #include "TGeoNode.h" #include "TGeoMatrix.h" #include "TVector3.h" #include "CbmRun.h" #include "CbmRuntimeDb.h" // ----- Default constructor ------------------------------------------- CbmHypHitProducer::CbmHypHitProducer(const char* fileGeo) : CbmTask("Ideal HYP hit Producer") { fFileGeo=fileGeo; eneThr = 0.001; // Energy threshold for emc pad } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmHypHitProducer::~CbmHypHitProducer() { } // ------------------------------------------------------------------------- // ----- Public method Init -------------------------------------------- InitStatus CbmHypHitProducer::Init() { cout << " INITIALIZATION *********************" << endl; //CbmDetector::Initialize(); //CbmRun* sim = CbmRun::Instance(); //CbmRuntimeDb* rtdb=sim->GetRuntimeDb(); // Get RootManager CbmRootManager* ioman = CbmRootManager::Instance(); if ( ! ioman ) { cout << "-E- CbmHypHitProducer::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array fPointArray = (TClonesArray*) ioman->GetObject("HypPoint"); if ( ! fPointArray ) { cout << "-W- CbmHypHitProducer::Init: " << "No HypPoint array!" << endl; return kERROR; } // Create and register output array fDigiArray = new TClonesArray("CbmHypHit"); ioman->Register("HypHit","Hyp",fDigiArray,kTRUE); CreateStructure(); cout << "-I- CbmHypHitProducer: Intialization successfull" << endl; return kSUCCESS; } // ------------------------------------------------------------------------- // ----- Public method Exec -------------------------------------------- void CbmHypHitProducer::Exec(Option_t* opt) { //cout << " DIGI EXECUTION *********************" << endl; // Reset output array if ( ! fDigiArray ) Fatal("Exec", "No DigiArray"); fDigiArray->Clear(); // Declare some variables CbmHypPoint* point = NULL; map fTrackEnergy; fTrackEnergy.clear(); map::const_iterator p; // Loop over HypPoints Int_t nPoints = fPointArray->GetEntriesFast(); for (Int_t iPoint=0; iPointAt(iPoint); fTrackEnergy[point->GetDetectorID()] += point->GetEnergyLoss(); } // Loop over HypPoint // Loop to register HypHit for(p=fTrackEnergy.begin(); p!=fTrackEnergy.end(); ++p) { if ((*p).second>eneThr) AddHit(1, (*p).first, (*p).second); } } // ------------------------------------------------------------------------- // ----- Public method Create Structure -------------------------------------------- void CbmHypHitProducer::CreateStructure() { TString work = getenv("VMCWORKDIR"); work = work + "/geometry/" + fFileGeo; cout << "-I- Hyp geometry loaded from: " << work << endl; Int_t detId = -1; CbmHypReader read(work); for(Int_t module=1; module<=read.GetMaxModules(); module++) for(Int_t row=1; row<=read.GetMaxRows(module); row++) for(Int_t crystal=1; crystal<=read.GetMaxCrystals(module,row); crystal++) { DataG4 data = read.GetData(module,row,crystal); for(Int_t copy=1; copy<=20; copy++) { detId = module*100000000 + row*1000000 + copy*10000 + crystal; emcX[detId] = data.posX; emcY[detId] = data.posY; emcZ[detId] = data.posZ; emcTheta[detId] = data.theta; emcTau[detId] = data.tau; if (module==3) emcPhi[detId] = fmod(data.phi+90.*(copy-1),360); else emcPhi[detId] = fmod(data.phi+22.5*(copy-1),360); } } } // ----- Private method AddDigi -------------------------------------------- CbmHypHit* CbmHypHitProducer::AddHit(Int_t trackID,Int_t detID, Float_t energy){ // It fills the CbmHypHit category // cout << "CbmHypHitProducer: track " << trackID << " evt " << eventID << " sec " << sec << " plane " << pla << " strip " << strip << "box " << box << " tube " << tub << endl; TClonesArray& clref = *fDigiArray; Int_t size = clref.GetEntriesFast(); return new(clref[size]) CbmHypHit(trackID, detID, energy, emcX[detID], emcY[detID], emcZ[detID], emcTheta[detID], emcPhi[detID], emcTau[detID]); } // ---- ClassImp(CbmHypHitProducer)