#include "CbmRichSmallPrototypeQa.h" #include "TH1D.h" #include "TH1.h" #include "TCanvas.h" #include "TClonesArray.h" #include "TF1.h" #include "TStyle.h" #include "CbmMCTrack.h" #include "FairTrackParam.h" #include "CbmRichHit.h" #include "FairMCPoint.h" #include "CbmDrawHist.h" #include "CbmTrackMatchNew.h" #include "CbmRichRing.h" #include "CbmRichHit.h" #include "CbmMatchRecoToMC.h" #include "CbmRichGeoManager.h" #include "CbmRichPoint.h" #include "utils/CbmRichDraw.h" #include "CbmUtils.h" #include "CbmHistManager.h" #include #include #include #include using namespace std; using boost::assign::list_of; CbmRichSmallPrototypeQa::CbmRichSmallPrototypeQa() : FairTask("CbmRichSmallPrototypeQa"), fHM(NULL), fEventNum(0), fOutputDir(""), fMCTracks(NULL), fSTSPoints(NULL), fSTSDigis(NULL), fSTSHits(NULL), fSTSTrack(NULL), fRichPoints(NULL), fRichDigis(NULL), fRichHits(NULL), fRichRings(NULL), fTRDPoints(NULL), fTRDHits(NULL), fTRDTrack(NULL), fToFPoints(NULL), fToFHits(NULL), fToFTrack(NULL), fCanvas() //fMinNofHits(7), //fNofHitsInRingMap() { } InitStatus CbmRichSmallPrototypeQa::Init() { cout << "CbmRichSmallPrototypeQa::Init"<GetObject("MCTrack"); if (NULL == fMCTracks) { Fatal("CbmRichSmallPrototypeQa::Init", "No MC Tracks!"); } fRichPoints =(TClonesArray*) ioman->GetObject("RichPoint"); if (NULL == fRichPoints) { Fatal("CbmRichSmallPrototypeQa::Init", "No Rich Points!");} fRichDigis =(TClonesArray*) ioman->GetObject("RichDigi"); if (NULL == fRichDigis) { Fatal("CbmRichSmallPrototypeQa::Init", "No Rich Digis!");} fRichHits = (TClonesArray*) ioman->GetObject("RichHit"); if ( NULL == fRichHits) { Fatal("CbmRichSmallPrototypeQa::Init","No RichHits!"); } fRichRings = (TClonesArray*) ioman->GetObject("RichRing"); if ( NULL == fRichRings) { Fatal("CbmRichSmallPrototypeQa::Init","No RichRings!"); } InitHistograms(); return kSUCCESS; } void CbmRichSmallPrototypeQa::Exec( Option_t* option) { fEventNum++; cout << "CbmRichSmallPrototypeQa, event No. " << fEventNum << endl; Int_t nofMCTracks = fMCTracks->GetEntriesFast(); Int_t nofRichPoints = fRichPoints->GetEntriesFast(); Int_t nofRichDigis = fRichDigis->GetEntriesFast(); Int_t nofRichHits = fRichHits->GetEntriesFast(); Int_t nofRichRings = fRichRings->GetEntriesFast(); // fHM->H1("fh_nof_mc_tracks")->Fill(nofMCTracks); fHM->H1("fh_nof_rich_points")->Fill(nofRichPoints); fHM->H1("fh_nof_rich_digis")->Fill(nofRichDigis); fHM->H1("fh_nof_rich_hits")->Fill(nofRichHits); fHM->H1("fh_nof_rich_rings")->Fill(nofRichRings); for (int i=0; iAt(i)); //CbmRichHit* richHit = static_cast(fRichHits -> At(i)); } /* for (int i=0; iAt(i)); Double_t momentum = mctrack->GetP(); fHM->H1("fh_mc_mom_all")->Fill(momentum); Double_t pdg = mctrack->GetPdgCode(); fHM->H1("fh_mc_pdg_all")->Fill(pdg); if(pdg == 211) { fHM->H1("fh_mc_mom_pion")->Fill(momentum); } else if(pdg == -11) { fHM->H1("fh_mc_mom_elec")->Fill(momentum); } Double_t startx = mctrack->GetStartX(); Double_t starty = mctrack->GetStartY(); fHM->H2("fh_mc_startxy")->Fill(startx, starty); Double_t startz = mctrack->GetStartZ(); fHM->H1("fh_mc_startz")->Fill(startz); Double_t motherid; CbmMCTrack* gamma= (CbmMCTrack*) (fMCTracks->At(i)); Double_t particles = gamma->GetPdgCode(); if(particles == 11) { motherid = gamma->GetMotherId(); if(motherid >= 0) { CbmMCTrack* gamma1= (CbmMCTrack*) (fMCTracks->At(motherid)); if(gamma1!=0) { Double_t gammapdg = gamma1->GetPdgCode(); if(gammapdg == 22) { Double_t gammax = gamma->GetStartX(); Double_t gammay = gamma->GetStartY(); fHM->H2("fh_mc_gammaxy")->Fill(gammax, gammay); Double_t gammaz = gamma->GetStartZ(); fHM->H1("fh_mc_gammaz")->Fill(gammaz); } } } } } */ for(int i=0; iAt(i)); Double_t xrichp = richpoints->GetX(); Double_t yrichp = richpoints->GetY(); fHM->H2("fh_dis_rich_points")->Fill(xrichp, yrichp); } for(int i=0; iAt(i)); Double_t xrichh = richhits->GetX(); Double_t yrichh = richhits->GetY(); fHM->H2("fh_dis_rich_hits")->Fill(xrichh, yrichh); } for( int i=0; iAt(i)); Double_t pdg = mctrack->GetPdgCode(); if (pdg == 2212) { Double_t startx = mctrack->GetStartX(); Double_t starty = mctrack->GetStartY(); fHM->H2("fh_proton_startxy")->Fill(startx, starty); } } for(int i=0; iAt(i)); Double_t radius = ringradius->GetRadius(); fHM->H1("fh_rich_ring_radius")->Fill(radius); } } void CbmRichSmallPrototypeQa::InitHistograms() { fHM = new CbmHistManager(); //MC Tracks /* fHM->Create1("fh_nof_mc_tracks", "fh_nof_mc_tracks;Nof MC Tracks;Yield", 300, 0., 3000.); fHM->Create1("fh_mc_mom_all", "fh_mc_mom_all;Momentum;Yield", 270, 0., 27.); fHM->Create1("fh_mc_pdg_all", "fh_mc_pdg_all;PDG Codes;Yield", 1000, -700., 700.); fHM->Create1("fh_mc_mom_pion", "fh_mc_mom_pion;Momentum;Yield", 270, 0., 27.); fHM->Create1("fh_mc_mom_elec", "fh_mc_mom_elec;Momentum;Yield", 270, 0., 27.); fHM->Create2("fh_mc_startxy", "fh_mc_startxy; Start x; Start y", 3000, 0., 300., 3000, 0., 300.); fHM->Create1("fh_mc_startz", "fh_mc_startz; Start z", 3000, 0., 300.); fHM->Create2("fh_mc_gammaxy", "fh_mc_gammaxy;x;y", 3000, 0., 300., 3000., 0., 300.); fHM->Create1("fh_mc_gammaz", "fh_mc_gammaz; z", 3000, 0., 300.); */ //RICH fHM->Create1("fh_nof_rich_points", "fh_nof_rich_points;Nof Rich Points;Yield", 300, 0., 2000.); fHM->Create1("fh_nof_rich_digis", "fh_nof_rich_digis;Nof Rich Digis;Yield", 300, 0., 1000.); fHM->Create1("fh_nof_rich_hits", "fh_nof_rich_hits;Nof Rich hits;Yield", 300, 0., 350.); fHM->Create1("fh_nof_rich_rings", "fh_nof_rich_rings;Nof Rich rings;Yield", 5, -0.5, 4.5); fHM->Create1("fh_rich_ring_radius","fh_rich_ring_radius; Ring Radius; Yield", 6, -0.5, 5.5); fHM->Create2("fh_dis_rich_points", "fh_dis_rich_points; x; y", 300, -7., 7., 300, -7., 7.); fHM->Create2("fh_dis_rich_hits", "fh_dis_rich_hits; x; y", 50, -10., 10., 50, -10., 10.); fHM->Create2("fh_proton_startxy","fh_proton_startxy; x; y;", 100, -5.,5, 100, -5., 5.); } void CbmRichSmallPrototypeQa::DrawHist() { cout.precision(4); SetDefaultDrawStyle(); fHM->ScaleByPattern("", 1./fEventNum); { TCanvas* c = CreateCanvas("rich_sp_nof_rich_hits_points", "rich_sp_nof_rich_hits_points", 800, 800); c->Divide(1,2); c->cd(1); DrawH1andFitGauss(fHM->H1("fh_nof_rich_hits")); //gPad->SetLogy(true); c->cd(2); DrawH1andFitGauss(fHM->H1("fh_nof_rich_points")); /* fHM->H1("fh_nof_rich_hits")->Fit("gaus"); TF1 * func = fHM->H1("fh_nof_rich_hits")->GetFunction("gaus"); double m = func->GetParameter(1) ; double sigma = func->GetParameter(2); cout << "mean: "<< m << " sigma: " << sigma << endl; */ } /* { TCanvas* c = CreateCanvas("rich_sp_nof_mc_tracks", "rich_sp_nof_mc_tracks", 800, 800); gStyle->SetOptTitle(1); DrawH1andFitGauss(fHM->H1("fh_nof_mc_tracks")); fHM->H1("fh_nof_mc_tracks")->SetTitle("MC Track"); } */ /* { TCanvas* c=CreateCanvas("rich_sp_rich_nof", "rich_sp_rich_nof", 1600, 800); c->Divide(2,2); c->cd(1); gStyle->SetOptTitle(1); DrawH1andFitGauss(fHM->H1("fh_nof_rich_points")); c->cd(2); gStyle->SetOptTitle(1); DrawH1andFitGauss(fHM->H1("fh_nof_rich_digis")); c->cd(3); gStyle->SetOptTitle(1); DrawH1andFitGauss(fHM->H1("fh_nof_rich_hits")); c->cd(4); gStyle->SetOptTitle(1); DrawH1andFitGauss(fHM->H1("fh_nof_rich_rings")); } */ /* { TCanvas* c=CreateCanvas("mc_track_mom","mc_track_mom", 1600, 800); c->Divide(2,2); c->cd(1); gStyle->SetOptTitle(1); DrawH1(list_of(fHM->H1("fh_mc_mom_all"))(fHM->H1("fh_mc_mom_pion"))(fHM->H1("fh_mc_mom_elec")), list_of("fh_mc_mom_all")("fh_mc_mom_pion")("fh_mc_mom_elec"), kLinear, kLog); c->cd(2); gStyle->SetOptTitle(1); DrawH1(fHM->H1("fh_mc_pdg_all")); c->cd(3); gStyle->SetOptTitle(1); DrawH2(fHM->H2("fh_mc_startxy")); c->cd(4); gStyle->SetOptTitle(1); DrawH1(fHM->H1("fh_mc_startz"), kLinear, kLog); } */ { TCanvas* c=CreateCanvas("rich_dis_of_points_and_hits", "rich_dis_of_points_hits", 1200, 400); c->Divide(2,1); c->cd(1); DrawH2(fHM->H2("fh_dis_rich_points")); fHM->H2("fh_dis_rich_points")->SetTitle("Rich Points"); c->cd(2); DrawH2(fHM->H2("fh_dis_rich_hits")); fHM->H2("fh_dis_rich_hits")->SetTitle("Rich Hits"); } { TCanvas* c=CreateCanvas("fh_proton_startxy", "fh_proton_startxy", 400, 400); DrawH2(fHM->H2("fh_proton_startxy")); fHM->H2("fh_proton_startxy")->SetTitle("Startproton"); } { TCanvas* c=CreateCanvas("rich_rings", "rich_rings", 800, 400); c->Divide(2,1); c->cd(1); DrawH1(fHM->H1("fh_nof_rich_rings")); fHM->H1("fh_nof_rich_rings")->SetTitle("Nof Rich Rings"); c->cd(2); DrawH1(fHM->H1("fh_rich_ring_radius")); fHM->H1("fh_rich_ring_radius")->SetTitle("Ring Radius"); } } void CbmRichSmallPrototypeQa::Finish() { DrawHist(); SaveCanvasToImage(); fHM->WriteToFile(); } TCanvas* CbmRichSmallPrototypeQa::CreateCanvas( const string& name, const string& title, int width, int height) { TCanvas* c = new TCanvas(name.c_str(), title.c_str(), width, height); fCanvas.push_back(c); return c; } void CbmRichSmallPrototypeQa::SaveCanvasToImage() { for (int i = 0; i < fCanvas.size(); i++) { Cbm::SaveCanvasAsImage(fCanvas[i], fOutputDir); } } ClassImp(CbmRichSmallPrototypeQa)