29#include "TClonesArray.h"
33#include "TGeoManager.h"
45#include <boost/assign/list_of.hpp>
53using boost::assign::list_of;
58 : FairTask(
"CbmRichMCbmAerogelAna")
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,
143 fHM->Create1<TH1D>(
"fhEventRichHitX",
"fhEventRichHitX;RICH hit X [cm];Entries", 67, -20.1 +
fXOffsetHisto,
145 fHM->Create1<TH1D>(
"fhEventRichHitY",
"fhEventRichHitY;RICH hit Y [cm];Entries", 84, -25.2, 25.2);
146 fHM->Create1<TH1D>(
"fhRichHitX",
"fhRichHitX;RICH hit X [cm];Entries", 67, -20.1 +
fXOffsetHisto,
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);
193 fHM->H1(
"fhHitsInTimeslice")->Fill(
fEventNum, nofRichHits);
194 for (
int iH = 0; iH < nofRichHits; iH++) {
196 fHM->H2(
"fhRichHitXY")->Fill(richHit->
GetX(), richHit->
GetY());
197 fHM->H1(
"fhRichHitToT")->Fill(richHit->
GetToT());
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;
261 fHM->H1(
"fhEventRichRingRadius")->Fill(ring->
GetRadius());
266 fHM->H1(
"fhEventNofHitsInRingTop")->Fill(ring->
GetNofHits());
267 fHM->H1(
"fhEventRichRingRadiusTop")->Fill(ring->
GetRadius());
268 fHM->H1(
"fhNofRingsTopBottom")->Fill(0);
271 fHM->H1(
"fhEventNofHitsInRingBottom")->Fill(ring->
GetNofHits());
272 fHM->H1(
"fhEventRichRingRadiusBottom")->Fill(ring->
GetRadius());
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();
307 fHM->ScaleByPattern(
"fh_.*", 1. / nofEvents);
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);
364 TCanvas* c =
fHM->CreateCanvas(
"rich_ToT",
"rich_ToT", 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);
395 DrawH1(
fHM->H1(
"fhEventRichRingRadius"));
401 TCanvas* c =
fHM->CreateCanvas(
"rich_Aerogel_Top_Bottom_Hits",
"rich_Aerogel_Top_Bottom_Hits", 1200, 600);
404 DrawH1(
fHM->H1(
"fhEventNofHitsInRingTop"));
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;
412 DrawH1(
fHM->H1(
"fhEventNofHitsInRingBottom"));
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);
424 DrawH1(
fHM->H1(
"fhEventRichRingRadiusTop"));
426 DrawH1(
fHM->H1(
"fhEventRichRingRadiusBottom"));
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());
481 fHM->ReadFromFile(file);
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 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) const
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