#include "PndMvdDigiAna.h" #include "PndMvdDigiPixel.h" #include "PndMvdDigiStrip.h" #include "PndMvdMCPoint.h" #include "CbmRunAna.h" #include "CbmRuntimeDb.h" #include "CbmGeoNode.h" #include "CbmGeoVector.h" #include "PndStringVector.h" #include "CbmRootManager.h" #include "TClonesArray.h" #include "TArrayD.h" #include "TGeoManager.h" #include "TCanvas.h" using std::string; PndMvdDigiAna::PndMvdDigiAna() : CbmTask("PndMvd Digi Ana") { // fBranchName = "MVDDigiPixel"; fBranchName = "MVDDigiStrip"; fPixelPos = new TH3F("pPos","pPos",200,-15,15,200,-15,15,200,-20,20); fStripPos = new TH3F("sPos","sPos",128,0,127,16,0,15,200,0,20); // fHitArray = new TClonesArray("PndMvdDigiPixel"); // fPixelArray = new TClonesArray("PndMvdDigiPixel"); } // ------------------------------------------------------------------------- PndMvdDigiAna::PndMvdDigiAna(TString DetName) : CbmTask("MVD Digi Ana") { // fBranchName = "MVDDigiPixel"; fBranchName = "MVDDigiStrip"; fDetName = DetName; fPixelPos = new TH3F("pPos","pPos",200,-15,15,200,-15,15,200,-20,20); fStripPos = new TH3F("sPos","sPos",128,0,127,16,0,15,200,0,20); } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndMvdDigiAna::~PndMvdDigiAna() { } // ------------------------------------------------------------------------- // ----- Initialization of Parameter Containers ------------------------- void PndMvdDigiAna::SetParContainers() { // Get Base Container CbmRunAna* ana = CbmRunAna::Instance(); CbmRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar = (PndMvdGeoPar*)(rtdb->getContainer("PndMvdGeoPar")); fDigiPar = (PndMvdPixelDigiPar*)(rtdb->getContainer("PndMvdDigiPar")); } InitStatus PndMvdDigiAna::ReInit() { CbmRunAna* ana = CbmRunAna::Instance(); CbmRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar=(PndMvdGeoPar*)(rtdb->getContainer("PndMvdGeoPar")); fDigiPar = (PndMvdPixelDigiPar*)(rtdb->getContainer("PndMvdDigiPar")); return kSUCCESS; } // ----- Public method Init -------------------------------------------- InitStatus PndMvdDigiAna::Init() { CbmRootManager* ioman = CbmRootManager::Instance(); if ( ! ioman ) { std::cout << "-E- PndMvdDigiAna::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- PndMvdDigiAna::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- PndMvdDigiAna: Intialisation successfull" << std::endl; return kSUCCESS; } // ------------------------------------------------------------------------- void PndMvdDigiAna::Exec(Option_t* opt) { // Reset output array std::cout << "Within Exec! " << fHitArray << " " << fPixelArray << std::endl; if ( ! fHitArray ) Fatal("Exec", "No HitArray"); // Loop over PndMvdMCPoints Int_t nPoints = fHitArray->GetEntriesFast(); PndMvdDigiStrip* hit = 0; for (Int_t iPoint = 0, iPixel = 0; iPoint < nPoints; iPoint++) { // hit = (PndMvdDigiPixel*) fHitArray->At(iPoint); hit = (PndMvdDigiStrip*) 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(); PndStringVector sAna(det,"/"); std::vector sVector = sAna.GetStringVector(); if (sVector[sVector.size()-1].find("Strip") != string::npos){ fStripPos->Fill(hit->GetChannel(), hit->GetFE(), 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()<mkdir("PndMvdDigiAna"); file->cd("PndMvdDigiAna"); fStripPos->Write(); delete fStripPos; fStripPos=NULL; fPixelPos->Write(); delete fPixelPos; fPixelPos=NULL; file->Close(); delete file; } void PndMvdDigiAna::PrintHistograms(const TString& outpsfile) { TCanvas* can1 = new TCanvas("can1","MVD digitization analysis",0,0,600,800); Int_t a = 2, b = 4, zaehl = 1; can1->Divide(a,b); can1->Print(outpsfile+"[");//opens the ps file, no writing if(zaehl>(a*b)) // new page {zaehl=1;can1->Print(outpsfile);can1->Clear("D");} can1->cd(zaehl); fStripPos->DrawCopy(); delete fStripPos; fStripPos=NULL; if(zaehl>(a*b)) // new page {zaehl=1;can1->Print(outpsfile);can1->Clear("D");} can1->cd(zaehl); fPixelPos->DrawCopy(); delete fPixelPos; fPixelPos=NULL; // finish plotting can1->Print(outpsfile);//writes in file can1->Print(outpsfile+"]");//closes the file delete can1; } ClassImp(PndMvdDigiAna)