29#include "TClonesArray.h"
33#include "TGeoManager.h"
45#include <boost/assign/list_of.hpp>
53using boost::assign::list_of;
58 : FairTask(
"CbmRichMCbmAerogelAna")
66 , fNofDrawnRichTofEv(0)
68 , fOutputDir(
"result")
74 cout <<
"CbmRichMCbmAerogelAna::Init" << endl;
76 FairRootManager* ioman = FairRootManager::Instance();
77 if (
nullptr == ioman) {
78 Fatal(
"CbmRichMCbmQaReal::Init",
"RootManager not instantised!");
88 fRichHits = (TClonesArray*) ioman->GetObject(
"RichHit");
90 Fatal(
"CbmRichMCbmAerogelAna::Init",
"No Rich Hits!");
93 fRichRings = (TClonesArray*) ioman->GetObject(
"RichRing");
95 Fatal(
"CbmRichMCbmAerogelAna::Init",
"No Rich Rings!");
110 fCbmEvent =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"CbmEvent"));
112 Fatal(
"fTofDigis::Init",
"No Event!");
124 fHM->
Create1<TH1D>(
"fhNofEvents",
"fhNofEvents;Entries", 1, 0.5, 1.5);
125 fHM->
Create1<TH1D>(
"fhNofCbmEvents",
"fhNofCbmEvents;Entries", 1, 0.5, 1.5);
126 fHM->
Create1<TH1D>(
"fhNofCbmEventsRing",
"fhNofCbmEventsRing;Entries", 1, 0.5, 1.5);
128 fHM->
Create1<TH1D>(
"fhHitsInTimeslice",
"fhHitsInTimeslice;Timeslice;#Hits", 200, 1, 200);
131 fHM->
Create1<TH1D>(
"fhNofRichDigisInTimeslice",
"fhNofRichDigisInTimeslice;# RICH digis / timeslice;Entries", 100,
133 fHM->
Create1<TH1D>(
"fhNofRichHitsInTimeslice",
"fhNofRichHitsInTimeslice;# RICH hits / timeslice;Entries", 100, -0.5,
135 fHM->
Create1<TH1D>(
"fhNofRichRingsInTimeslice",
"fhNofRichRingsInTimeslice;# RICH rings / timeslice;Entries", 10,
139 fHM->
Create2<TH2D>(
"fhRichHitXY",
"fhRichHitXY;RICH hit X [cm];RICH hit Y [cm];Entries", 67, -20.1 +
fXOffsetHisto,
141 fHM->
Create2<TH2D>(
"fhEventRichHitXY",
"fhEventRichHitXY;RICH hit X [cm];RICH hit Y [cm];Entries", 67,
145 fHM->
Create1<TH1D>(
"fhEventRichHitY",
"fhEventRichHitY;RICH hit Y [cm];Entries", 84, -25.2, 25.2);
148 fHM->
Create1<TH1D>(
"fhRichHitY",
"fhRichHitY;RICH hit Y [cm];Entries", 84, -25.2, 25.2);
151 fHM->
Create1<TH1D>(
"fhRichDigisToT",
"fhRichDigisToT;ToT [ns];Entries", 601, 9.975, 40.025);
152 fHM->
Create1<TH1D>(
"fhRichHitToT",
"fhRichHitToT;ToT [ns];Entries", 601, 9.975, 40.025);
155 fHM->
Create2<TH2D>(
"fhRichRingXY",
"fhRichRingXY;Ring center X [cm];Ring center Y [cm];Entries", 100,
157 fHM->
Create1<TH1D>(
"fhRichRingRadius",
"fhRichRingRadius;Ring radius [cm];Entries", 100, 0., 7.);
158 fHM->
Create1<TH1D>(
"fhNofHitsInRing",
"fhNofHitsInRing;# hits in ring;Entries", 50, -0.5, 49.5);
161 fHM->
Create2<TH2D>(
"fhEventRichRingXY",
"fhEventRichRingXY;Ring center X [cm];Ring center Y [cm];Entries", 100,
163 fHM->
Create1<TH1D>(
"fhEventRichRingRadius",
"fhEventRichRingRadius;Ring radius [cm];Entries", 100, 0., 7.);
164 fHM->
Create1<TH1D>(
"fhEventNofHitsInRing",
"fhEventNofHitsInRing;# hits in ring;Entries", 50, -0.5, 49.5);
165 fHM->
Create1<TH1D>(
"fhEventNofHitsInRingTop",
"fhEventNofHitsInRingTop;# hits in ring;Entries", 50, -0.5, 49.5);
166 fHM->
Create1<TH1D>(
"fhEventNofHitsInRingBottom",
"fhEventNofHitsInRingBottom;# hits in ring;Entries", 50, -0.5, 49.5);
168 fHM->
Create1<TH1D>(
"fhEventRichHitToT",
"fhRichHitToT;ToT [ns];Entries", 601, 9.975, 40.025);
170 fHM->
Create1<TH1D>(
"fhEventRichRingRadiusTop",
"fhEventRichRingRadiusTop;Ring radius [cm];Entries", 100, 0., 7.);
171 fHM->
Create1<TH1D>(
"fhEventRichRingRadiusBottom",
"fhEventRichRingRadiusBottom;Ring radius [cm];Entries", 100, 0.,
174 fHM->
Create1<TH1D>(
"fhNofRingsTopBottom",
"fhNofRingsTopBottom;Entries", 2, -0.5, 1.5);
181 fHM->
H1(
"fhNofEvents")->Fill(1);
182 cout <<
"CbmRichMCbmAerogelAna, event No. " <<
fEventNum << endl;
187 fHM->
H1(
"fhRichDigisToT")->Fill(richDigi->
GetToT());
191 int nofRichHits =
fRichHits->GetEntriesFast();
192 fHM->
H1(
"fhNofRichHitsInTimeslice")->Fill(nofRichHits);
194 for (
int iH = 0; iH < nofRichHits; iH++) {
196 fHM->
H2(
"fhRichHitXY")->Fill(richHit->
GetX(), richHit->
GetY());
198 fHM->
H1(
"fhRichHitX")->Fill(richHit->
GetX());
199 fHM->
H1(
"fhRichHitY")->Fill(richHit->
GetY());
205 auto fNCbmEvent =
fCbmEvent->GetEntriesFast();
207 for (
int i = 0; i < fNCbmEvent; i++) {
208 fHM->
H1(
"fhNofCbmEvents")->Fill(1);
210 std::vector<int> ringIndx;
211 std::vector<int> evRichHitIndx;
216 evRichHitIndx.push_back(iRichHit);
218 int nofRichRings =
fRichRings->GetEntriesFast();
219 for (
int l = 0; l < nofRichRings; l++) {
222 for (
int m = 0; m < NofRingHits; m++) {
223 auto RingHitIndx = ring->
GetHit(m);
224 if (RingHitIndx == iRichHit) {
226 for (
auto check : ringIndx) {
232 if (used ==
false) ringIndx.push_back(l);
243 if (ringIndx.size() > 0) {
248 fHM->
H1(
"fhEventRichHitToT")->Fill(richHit->
GetToT());
249 fHM->
H2(
"fhEventRichHitXY")->Fill(richHit->
GetX(), richHit->
GetY());
250 fHM->
H1(
"fhEventRichHitX")->Fill(richHit->
GetX());
251 fHM->
H1(
"fhEventRichHitY")->Fill(richHit->
GetY());
258 if (ring ==
nullptr)
continue;
268 fHM->
H1(
"fhNofRingsTopBottom")->Fill(0);
273 fHM->
H1(
"fhNofRingsTopBottom")->Fill(1);
278 fHM->
H1(
"fhNofCbmEventsRing")->Fill(1);
288 int nofRichRings =
fRichRings->GetEntriesFast();
290 for (
int i = 0; i < nofRichRings; i++) {
292 if (ring ==
nullptr)
continue;
306 double nofEvents =
fHM->
H1(
"fhNofCbmEvents")->GetEntries();
310 fHM->
CreateCanvas(
"rich_mcbm_fhNofCbmEvents",
"rich_mcbm_fhNofCbmEvents", 600, 600);
315 fHM->
CreateCanvas(
"rich_mcbm_fhNofCbmEventsRing",
"rich_mcbm_fhNofCbmEventsRing", 600, 600);
320 fHM->
CreateCanvas(
"rich_mcbm_fhNofEvents",
"rich_mcbm_fhNofEvents", 600, 600);
326 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_XY",
"rich_mcbm_XY", 1200, 600);
336 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_XY_inEvent",
"rich_mcbm_XY_inEvent", 1200, 600);
346 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_X_and_Y_inEvent",
"rich_mcbm_X_and_Y_inEvent", 1200, 600);
355 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_X_and_Y_inEventWithRing",
"rich_mcbm_X_and_Y_inEventWithRing", 1200, 600);
373 TCanvas* c =
fHM->
CreateCanvas(
"rich_ToT_Event",
"rich_ToT_Event", 1200, 600);
383 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_rings",
"rich_mcbm_rings", 1200, 600);
392 TCanvas* c =
fHM->
CreateCanvas(
"rich_mcbm_rings_inEvent",
"rich_mcbm_rings_inEvent", 1200, 600);
401 TCanvas* c =
fHM->
CreateCanvas(
"rich_Aerogel_Top_Bottom_Hits",
"rich_Aerogel_Top_Bottom_Hits", 1200, 600);
405 unsigned int sumHitsTop = 0;
406 for (
unsigned int i = 1; i <= 50; i++) {
407 sumHitsTop +=
fHM->
H1(
"fhEventNofHitsInRingTop")->GetBinContent(i) * (i - 1);
409 std::cout <<
"Sum Hits Top: " << sumHitsTop << std::endl;
413 unsigned int sumHitsBottom = 0;
414 for (
unsigned int i = 1; i <= 50; i++) {
415 sumHitsBottom +=
fHM->
H1(
"fhEventNofHitsInRingBottom")->GetBinContent(i) * (i - 1);
417 std::cout <<
"Sum Hits Bottom: " << sumHitsBottom << std::endl;
421 TCanvas* c =
fHM->
CreateCanvas(
"rich_Aerogel_Top_Bottom_Radius",
"rich_Aerogel_Top_Bottom_Radius", 1200, 600);
431 fHM->
CreateCanvas(
"rich_Aerogel_#RingsTopVsBottom",
"rich_Aerogel_#RingsTopVsBottom", 1200, 600);
432 fHM->
H1(
"fhNofRingsTopBottom")->Draw(
"HIST TEXT");
440 std::cout <<
"Drawing Hists...";
442 std::cout <<
"DONE!" << std::endl;
446 std::cout <<
"Canvas saved to Images!" << std::endl;
451 TFile* oldFile = gFile;
452 TDirectory* oldir = gDirectory;
454 std::string s =
fOutputDir +
"/RecoHists.root";
455 TFile* outFile =
new TFile(s.c_str(),
"RECREATE");
456 if (outFile->IsOpen()) {
458 std::cout <<
"Written to Root-file \"" << s <<
"\" ...";
460 std::cout <<
"Done!" << std::endl;
464 gDirectory->cd(oldir->GetPath());
474 TFile* oldFile = gFile;
475 TDirectory* oldDir = gDirectory;
477 if (
fHM !=
nullptr)
delete fHM;
480 TFile* file =
new TFile(fileName.c_str());
495 if ((hit->
GetToT() > 23.7) && (hit->
GetToT() < 30.0)) check =
true;
ClassImp(CbmConverterManager)
@ kTof
Time-of-flight Detector.
@ kRich
Ring-Imaging Cherenkov Detector.
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
FairTask for matching RECO data to MC.
Convert internal data classes to cbmroot common data classes.
Ring finder implementation based on Hough Transform method.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Class characterising one event by a collection of links (indices) to data objects,...
size_t GetNofData() const
uint32_t GetIndex(ECbmDataType type, uint32_t iData)
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
void ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void WriteToFile()
Write all objects to current opened file.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
void DrawFromFile(const string &fileName, const string &outputDir)
Draw histogram from file.
bool doToT(CbmRichHit *hit)
CbmDigiManager * fDigiMan
void DrawHist()
Draw histograms.
CbmRichMCbmAerogelAna()
Standard constructor.
virtual void Finish()
Inherited from FairTask.
void InitHistograms()
Initialize histograms.
Bool_t cutRadius(CbmRichRing *ring)
virtual void Exec(Option_t *option)
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
TClonesArray * fRichRings
uint32_t GetHit(int32_t i) const
int32_t GetNofHits() const