#include "TClonesArray.h" #include "TArrayD.h" #include "TGeoManager.h" #include "CbmRootManager.h" #include "MvdDigiAna.h" #include "MvdDigiPixel.h" #include "MvdPoint.h" #include "CbmRunAna.h" #include "CbmRuntimeDb.h" #include "CbmGeoNode.h" #include "CbmGeoVector.h" #include "StringVector.h" MvdDigiAna::MvdDigiAna() : CbmTask("Mvd Digi Ana") { fBranchName = "MVDDigiPixel"; fPixelPos = new TH3F("pPos","pPos",200,-15,15,200,-15,15,200,-20,20); fStripPos = new TH3F("sPos","sPos",200,-15,15,200,-15,15,200,-20,20); // fHitArray = new TClonesArray("MvdDigiPixel"); // fPixelArray = new TClonesArray("MvdDigiPixel"); } // ------------------------------------------------------------------------- MvdDigiAna::MvdDigiAna(TString DetName) : CbmTask("MVD Digi Ana") { fBranchName = "MVDDigiPixel"; fDetName = DetName; fPixelPos = new TH3F("pPos","pPos",200,-15,15,200,-15,15,200,-20,20); fStripPos = new TH3F("sPos","sPos",200,-15,15,200,-15,15,200,-20,20); } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- MvdDigiAna::~MvdDigiAna() { } // ------------------------------------------------------------------------- // ----- Initialization of Parameter Containers ------------------------- void MvdDigiAna::SetParContainers() { // Get Base Container CbmRunAna* ana = CbmRunAna::Instance(); CbmRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar = (MvdGeoPar*)(rtdb->getContainer("MvdGeoPar")); } InitStatus MvdDigiAna::ReInit() { CbmRunAna* ana = CbmRunAna::Instance(); CbmRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar=(MvdGeoPar*)(rtdb->getContainer("MvdGeoPar")); return kSUCCESS; } // ----- Public method Init -------------------------------------------- InitStatus MvdDigiAna::Init() { CbmRootManager* ioman = CbmRootManager::Instance(); if ( ! ioman ) { std::cout << "-E- MvdDigiAna::Init: " << "RootManager not instantiated!" << std::endl; return kFATAL; } std::cout << "within init" << std::endl; // Get input array fHitArray = (TClonesArray*) ioman->GetObject(fBranchName); if ( ! fHitArray ) { std::cout << "-W- MvdDigiAna::Init: " << "No MVDHit array!" << std::endl; return kERROR; } // register output histograms ioman->Register("MVDHist1", "MVD", fStripPos, kTRUE); ioman->Register("MVDHist2", "MVD", fPixelPos, kTRUE); std::cout << "-I- MvdDigiAna: Intialisation successfull" << std::endl; return kSUCCESS; } // ------------------------------------------------------------------------- void MvdDigiAna::Exec(Option_t* opt) { // Reset output array std::cout << "Within Exec! " << fHitArray << " " << fPixelArray << std::endl; if ( ! fHitArray ) Fatal("Exec", "No HitArray"); // Loop over MvdPoints Int_t nPoints = fHitArray->GetEntriesFast(); MvdDigiPixel* hit = 0; for (Int_t iPoint = 0, iPixel = 0; iPoint < nPoints; iPoint++) { hit = (MvdDigiPixel*) fHitArray->At(iPoint); if ( !hit){ std::cout<< "No Hit!" << std::endl; continue; } // std::cout << "****Hit Point: " << std::endl; // hit->Print(""); std::string det = hit->GetDetName().Data(); StringVector sAna(det,"/"); std::vector sVector = sAna.GetStringVector(); if (sVector[sVector.size()-1].find("Strip") != string::npos){ fStripPos->Fill(hit->GetPixelColumn(), hit->GetPixelRow(), hit->GetCharge()); std::cout << "Strip Found" << std::endl; std::cout<<"col "<GetPixelColumn()<<"\trow " <GetPixelRow()<<" charge "<GetCharge()<Fill(hit->GetPixelColumn(), hit->GetPixelRow(), hit->GetCharge()); std::cout << "Pixel Found" << std::endl; std::cout<<"col "<GetPixelColumn()<<"\trow " <GetPixelRow()<<" charge "<GetCharge()<