CbmRoot
Loading...
Searching...
No Matches
CbmRichUrqmdTest.cxx
Go to the documentation of this file.
1/* Copyright (C) 2012-2024 UGiessen/JINR-LIT, Giessen/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Andrey Lebedev, Martin Beyer */
4
5#include "CbmRichUrqmdTest.h"
6
7#include "CbmDigiManager.h"
8#include "CbmDrawHist.h"
9#include "CbmHistManager.h"
10#include "CbmMCDataArray.h"
11#include "CbmMCDataManager.h"
12#include "CbmMCEventList.h"
13#include "CbmMCTrack.h"
14#include "CbmMatchRecoToMC.h"
15#include "CbmRichDetectorData.h"
16#include "CbmRichDigi.h"
18#include "CbmRichDraw.h"
19#include "CbmRichGeoManager.h"
20#include "CbmRichHit.h"
21#include "CbmRichPoint.h"
22#include "CbmRichRing.h"
23#include "CbmRichUtil.h"
24#include "CbmTrackMatchNew.h"
25#include "CbmUtils.h"
26#include "FairMCPoint.h"
27#include "FairTrackParam.h"
28#include "TCanvas.h"
29#include "TClonesArray.h"
30#include "TH1.h"
31#include "TH1D.h"
32#include "TStyle.h"
33
34#include <TFile.h>
35
36#include <iostream>
37#include <sstream>
38#include <string>
39
40using namespace std;
41using namespace Cbm;
42
43CbmRichUrqmdTest::CbmRichUrqmdTest() : FairTask("CbmRichUrqmdTest") {}
44
46
48{
49 fMcTracks = InitOrFatalMc("MCTrack", "CbmRichUrqmdTest::Init");
50 fRichPoints = InitOrFatalMc("RichPoint", "CbmRichUrqmdTest::Init");
51 fRichHits = GetOrFatal<TClonesArray>("RichHit", "CbmRichUrqmdTest::Init");
52 fRichRings = GetOrFatal<TClonesArray>("RichRing", "CbmRichUrqmdTest::Init");
53 fRichRingMatches = GetOrFatal<TClonesArray>("RichRingMatch", "CbmRichUrqmdTest::Init");
54 fRichProjections = GetOrFatal<TClonesArray>("RichProjection", "CbmRichUrqmdTest::Init");
55 fEventList = GetOrFatal<CbmMCEventList>("MCEventList.", "CbmRichUrqmdTest::Init");
56
58 fDigiMan->Init();
59
60 fVertexZStsSlices = {make_pair(0., 5.), make_pair(5., 15.), make_pair(15., 25.), make_pair(25., 35.),
61 make_pair(35., 45.), make_pair(45., 55.), make_pair(55., 65.), make_pair(65., 75.),
62 make_pair(75., 85.), make_pair(85., 95.), make_pair(95., 105.)};
63
65
66
67 return kSUCCESS;
68}
69
70void CbmRichUrqmdTest::Exec(Option_t* /*option*/)
71{
72 fEventNum++;
73
74 LOG(info) << "CbmRichUrqmdTest, event No. " << fEventNum;
75
77 NofRings();
80 Vertex();
82}
83
85{
86 fNofHitsInRingMap.clear();
87 int nofRichHits = fRichHits->GetEntriesFast();
88 for (int iHit = 0; iHit < nofRichHits; iHit++) {
89 const CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iHit));
90 if (nullptr == hit) continue;
92
93 for (const auto& motherId : motherIds) {
94 fNofHitsInRingMap[motherId]++;
95 }
96 }
97}
98
100{
101 fHM = new CbmHistManager();
102
103 fHM->Create1<TH1D>("fh_vertex_z", "fh_vertex_z;Z [cm];# vertices/ev.", 400, -50., 350);
104 fHM->Create1<TH1D>("fh_vertex_z_sts", "fh_vertex_z_sts;Z [cm];# vertices/ev.", 320, -50., 110.);
105 fHM->Create2<TH2D>("fh_vertex_xy", "fh_vertex_xy;X [cm];Y [cm];# vertices/ev.", 100, -200., 200., 100, -200., 200.);
106 fHM->Create2<TH2D>("fh_vertex_zy", "fh_vertex_zy;Z [cm];Y [cm];# vertices/ev.", 400, -50., 350, 100, -200., 200.);
107 fHM->Create2<TH2D>("fh_vertex_zx", "fh_vertex_zx;Z [cm];X [cm];# vertices/ev.", 400, -50., 350, 100, -200., 200.);
108
109 vector<string> vertexZTypes{"z60_140", "z140_330", "z140_190"};
110 for (const string& t : vertexZTypes) {
111 fHM->Create2<TH2D>("fh_vertex_xy_" + t, "fh_vertex_xy_" + t + ";X [cm];Y [cm];# vertices/ev.", 100, -200., 200.,
112 100, -200., 200.);
113 }
114
115 for (auto pair : fVertexZStsSlices) {
116 string name = "fh_vertex_xy_z" + to_string(pair.first) + "_" + to_string(pair.second);
117 fHM->Create2<TH2D>(name, name + ";x [cm];y [cm];# vertices/ev.", 100, -100., 100., 100, -100., 100.);
118 }
119
120 vector<string> nofRingsTypes{"1hit", "7hits", "prim_1hit", "prim_7hits", "target_1hit", "target_7hits"};
121 for (const string& t : nofRingsTypes) {
122 double nofBins = (t == "1hit" || t == "7hits") ? 30 : 100;
123 fHM->Create1<TH1D>("fh_nof_rings_" + t, "fh_nof_rings_" + t + ";# particles/ev.;Yield", nofBins, -.5,
124 nofBins - 0.5);
125 }
126
127 vector<string> momP{"fh_secel_mom", "fh_gamma_target_mom", "fh_gamma_nontarget_mom",
128 "fh_pi_mom", "fh_kaon_mom", "fh_mu_mom"};
129 for (const string& t : momP) {
130 fHM->Create1<TH1D>(t, t + ";P [GeV/c];Number per event", 100, 0., 20);
131 }
132
133 fHM->Create1<TH1D>("fh_nof_points_per_event_src", "fh_nof_points_per_event_src;Particle;# MC points/ev.", 7, .5, 7.5);
134 fHM->Create1<TH1D>("fh_nof_hits_per_event", "fh_nof_hits_per_event;# hits/ev.;Yield", 200, 0, 2000);
135 fHM->Create1<TH1D>("fh_nof_points_per_event", "fh_nof_points_per_event;# points/ev.;Yield", 200, 0, 10000);
136 fHM->Create1<TH1D>("fh_nof_hits_per_pmt", "fh_nof_hits_per_pmt;# hits/PMT;% of total", 65, -0.5, 64.5);
137
138 vector<double> xPmtBins = CbmRichUtil::GetPmtHistXbins();
139 vector<double> yPmtBins = CbmRichUtil::GetPmtHistYbins();
140
141 // before drawing this histogram must be normalized by 1/64
142 fHM->Create2<TH2D>("fh_hitrate_xy", "fh_hitrate_xy;X [cm];Y [cm];# hits/pixel/s", xPmtBins, yPmtBins);
143
144 fHM->Create2<TH2D>("fh_hits_xy", "fh_hits_xy;X [cm];Y [cm];# hits/PMT/ev.", xPmtBins, yPmtBins);
145
146 vector<string> pointXYTypes{"", "_pions", "_gamma_target", "_gamma_nontarget"};
147 for (const string& t : pointXYTypes) {
148 fHM->Create2<TH2D>("fh_points_xy" + t, "fh_points_xy" + t + ";X [cm];Y [cm];# MC points/PMT/ev.", xPmtBins,
149 yPmtBins);
150 }
151
152 vector<string> skippedPmtTypes{"10", "20", "30"};
153 for (const string& t : skippedPmtTypes) {
154 fHM->Create2<TH2D>("fh_skipped_pmt_xy_" + t,
155 "fh_skipped_pmt_xy_" + t + ";X [cm];Y [cm];# skipped PMTs (>" + t + " hits) [%]", xPmtBins,
156 yPmtBins);
157 }
158
159 fHM->Create1<TH1D>("fh_nof_proj_per_event", "fh_nof_proj_per_event;# tracks/ev.;Yield", 600, -.5, 599.5);
160 fHM->Create2<TH2D>("fh_proj_xy", "fh_proj_xy;X [cm];Y [cm];# tracks/cm^{2}/ev.", 240, -120, 120, 420, -210, 210);
161}
162
164{
165 int nofRings = fRichRings->GetEntriesFast();
166 int nRings1hit = 0, nRings7hits = 0;
167 int nRingsPrim1hit = 0, nRingsPrim7hits = 0;
168 int nRingsTarget1hit = 0, nRingsTarget7hits = 0;
169 for (int iR = 0; iR < nofRings; iR++) {
170 const CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(iR));
171 if (ring == nullptr) continue;
172 const CbmTrackMatchNew* ringMatch = static_cast<CbmTrackMatchNew*>(fRichRingMatches->At(iR));
173 if (ringMatch == nullptr || ringMatch->GetNofLinks() < 1) continue;
174
175 auto matchedLink = ringMatch->GetMatchedLink();
176 const CbmMCTrack* mcTrack = static_cast<CbmMCTrack*>(fMcTracks->Get(matchedLink));
177 if (mcTrack == nullptr) continue;
178 int motherId = mcTrack->GetMotherId();
179 int pdgAbs = std::abs(mcTrack->GetPdgCode());
180 double mom = mcTrack->GetP();
181 TVector3 vert;
182 mcTrack->GetStartVertex(vert);
183 double dZ = vert.Z();
184
185 if (motherId == -1 && pdgAbs == 11) continue; // do not calculate embedded electrons
186
187 int nofHits = ring->GetNofHits();
188 if (nofHits >= 1) nRings1hit++;
189 if (nofHits >= fMinNofHits) nRings7hits++;
190
191 if (motherId == -1 && nofHits >= 1) nRingsPrim1hit++;
192 if (motherId == -1 && nofHits >= fMinNofHits) nRingsPrim7hits++;
193
194 if (dZ < 0.1 && nofHits >= 1) nRingsTarget1hit++;
195 if (dZ < 0.1 && nofHits >= fMinNofHits) nRingsTarget7hits++;
196
197 if (nofHits >= 1) {
198 if (motherId != -1) {
199 int motherPdg = -1;
200 const CbmMCTrack* mother = static_cast<CbmMCTrack*>(fMcTracks->Get(matchedLink));
201 if (mother != nullptr) motherPdg = mother->GetPdgCode();
202 if (motherId != -1 && pdgAbs == 11 && motherPdg != 22) fHM->H1("fh_secel_mom")->Fill(mom);
203
204 if (motherId != -1 && pdgAbs == 11 && motherPdg == 22) {
205 if (dZ < 0.1) {
206 fHM->H1("fh_gamma_target_mom")->Fill(mom);
207 }
208 else {
209 fHM->H1("fh_gamma_nontarget_mom")->Fill(mom);
210 }
211 }
212 }
213 if (pdgAbs == 211) fHM->H1("fh_pi_mom")->Fill(mom);
214 if (pdgAbs == 321) fHM->H1("fh_kaon_mom")->Fill(mom);
215 if (pdgAbs == 13) fHM->H1("fh_mu_mom")->Fill(mom);
216 }
217 }
218 fHM->H1("fh_nof_rings_1hit")->Fill(nRings1hit);
219 fHM->H1("fh_nof_rings_7hits")->Fill(nRings7hits);
220
221 fHM->H1("fh_nof_rings_prim_1hit")->Fill(nRingsPrim1hit);
222 fHM->H1("fh_nof_rings_prim_7hits")->Fill(nRingsPrim7hits);
223
224 fHM->H1("fh_nof_rings_target_1hit")->Fill(nRingsTarget1hit);
225 fHM->H1("fh_nof_rings_target_7hits")->Fill(nRingsTarget7hits);
226}
227
229{
230 int nofHits = fRichHits->GetEntriesFast();
231 fHM->H1("fh_nof_hits_per_event")->Fill(nofHits);
232 map<int, int> digisPerPmtMap;
233 for (int iH = 0; iH < nofHits; iH++) {
234 const CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iH));
235 if (hit == nullptr) continue;
236 fHM->H2("fh_hits_xy")->Fill(hit->GetX(), hit->GetY());
237 fHM->H2("fh_hitrate_xy")->Fill(hit->GetX(), hit->GetY());
238
239 int digiInd = hit->GetRefId();
240 const CbmRichDigi* richDigi = fDigiMan->Get<CbmRichDigi>(digiInd);
241 if (richDigi == nullptr) continue;
243 if (pixelData == nullptr) continue;
244 int pmtId = pixelData->fPmtId;
245 digisPerPmtMap[pmtId]++;
246 }
247
248 for (auto const& it : digisPerPmtMap) {
249 int pmtId = it.first;
250 int nofDigis = it.second;
252 TVector3 inPos(pmtData->fX, pmtData->fY, pmtData->fZ);
253 TVector3 outPos;
255 if (nofDigis > 10) fHM->H2("fh_skipped_pmt_xy_10")->Fill(outPos.X(), outPos.Y());
256 if (nofDigis > 20) fHM->H2("fh_skipped_pmt_xy_20")->Fill(outPos.X(), outPos.Y());
257 if (nofDigis > 30) fHM->H2("fh_skipped_pmt_xy_30")->Fill(outPos.X(), outPos.Y());
258 }
259
260 vector<int> allPmtIds = CbmRichDigiMapManager::GetInstance().GetPmtIds();
261 for (int pmtId : allPmtIds) {
262 fHM->H1("fh_nof_hits_per_pmt")->Fill(digisPerPmtMap[pmtId]);
263 }
264
265 int nofEvents = fEventList->GetNofEvents();
266 for (int iE = 0; iE < nofEvents; iE++) {
267 int fileId = fEventList->GetFileIdByIndex(iE);
268 int eventId = fEventList->GetEventIdByIndex(iE);
269 int nofPoints = fRichPoints->Size(fileId, eventId);
270 fHM->H1("fh_nof_points_per_event")->Fill(nofPoints);
271 for (int i = 0; i < nofPoints; i++) {
272 const CbmRichPoint* point = static_cast<CbmRichPoint*>(fRichPoints->Get(fileId, eventId, i));
273 if (point == nullptr) continue;
274 fHM->H1("fh_nof_points_per_event_src")->Fill(1);
275
276 int mcPhotonTrackId = point->GetTrackID();
277 if (mcPhotonTrackId < 0) continue;
278 const CbmMCTrack* mcPhotonTrack = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, mcPhotonTrackId));
279 if (mcPhotonTrack == nullptr) continue;
280 int motherPhotonId = mcPhotonTrack->GetMotherId();
281 if (motherPhotonId < 0) continue;
282 const CbmMCTrack* mcTrack = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, motherPhotonId));
283 if (mcTrack == nullptr) continue;
284 int motherId = mcTrack->GetMotherId();
285
286 int pdgAbs = std::abs(mcTrack->GetPdgCode());
287 TVector3 vert;
288 mcTrack->GetStartVertex(vert);
289 double dZ = vert.Z();
290
291 if (motherId == -1 && pdgAbs == 11) continue; // do not calculate embedded electrons
292
293 if (motherId != -1) {
294 int motherPdg = -1;
295 const CbmMCTrack* mother = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, motherId));
296 if (mother != nullptr) motherPdg = mother->GetPdgCode();
297 if (motherId != -1 && pdgAbs == 11 && motherPdg != 22) fHM->H1("fh_nof_points_per_event_src")->Fill(2);
298
299 if (motherId != -1 && pdgAbs == 11 && motherPdg == 22) {
300 if (dZ < 0.1) {
301 fHM->H1("fh_nof_points_per_event_src")->Fill(3);
302 }
303 else {
304 fHM->H1("fh_nof_points_per_event_src")->Fill(4);
305 }
306 }
307 }
308 if (pdgAbs == 211) fHM->H1("fh_nof_points_per_event_src")->Fill(5);
309 if (pdgAbs == 321) fHM->H1("fh_nof_points_per_event_src")->Fill(6);
310 if (pdgAbs == 13) fHM->H1("fh_nof_points_per_event_src")->Fill(7);
311 }
312 }
313}
314
316{
317 int nofEvents = fEventList->GetNofEvents();
318 for (int iE = 0; iE < nofEvents; iE++) {
319 int fileId = fEventList->GetFileIdByIndex(iE);
320 int eventId = fEventList->GetEventIdByIndex(iE);
321 int nofPoints = fRichPoints->Size(fileId, eventId);
322 for (int i = 0; i < nofPoints; i++) {
323 const CbmRichPoint* point = static_cast<CbmRichPoint*>(fRichPoints->Get(fileId, eventId, i));
324 if (point == nullptr) continue;
325
326 int iMCTrack = point->GetTrackID();
327 const CbmMCTrack* track = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, iMCTrack));
328 if (track == nullptr) continue;
329
330 int iMother = track->GetMotherId();
331 if (iMother == -1) continue;
332
333 const CbmMCTrack* track2 = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, iMother));
334 if (track2 == nullptr) continue;
335 int pdgAbs = std::abs(track2->GetPdgCode());
336 int motherId = track2->GetMotherId();
337 TVector3 inPos(point->GetX(), point->GetY(), point->GetZ());
338 TVector3 outPos;
340
341 fHM->H2("fh_points_xy")->Fill(outPos.X(), outPos.Y());
342 if (motherId != -1) {
343 int motherPdg = -1;
344 const CbmMCTrack* mother = static_cast<CbmMCTrack*>(fMcTracks->Get(fileId, eventId, motherId));
345 if (mother != nullptr) motherPdg = mother->GetPdgCode();
346 TVector3 vert;
347 track2->GetStartVertex(vert);
348 if (motherId != -1 && pdgAbs == 11 && motherPdg == 22) {
349 if (vert.Z() < 0.1) {
350 fHM->H2("fh_points_xy_gamma_target")->Fill(outPos.X(), outPos.Y());
351 }
352 else {
353 fHM->H2("fh_points_xy_gamma_nontarget")->Fill(outPos.X(), outPos.Y());
354 }
355 }
356 }
357 if (pdgAbs == 211) fHM->H2("fh_points_xy_pions")->Fill(outPos.X(), outPos.Y());
358 }
359 }
360}
361
363{
364 if (fRichProjections == nullptr) return;
365 int nofProj = fRichProjections->GetEntriesFast();
366 int nofGoodProj = 0;
367 for (int i = 0; i < nofProj; i++) {
368 FairTrackParam* proj = (FairTrackParam*) fRichProjections->At(i);
369 if (proj == nullptr) continue;
370 fHM->H2("fh_proj_xy")->Fill(proj->GetX(), proj->GetY());
371 if (proj->GetX() != 0 && proj->GetY() != 0) nofGoodProj++;
372 }
373 fHM->H1("fh_nof_proj_per_event")->Fill(nofGoodProj);
374}
375
377{
378 int nofEvents = fEventList->GetNofEvents();
379 for (int iE = 0; iE < nofEvents; iE++) {
380 int fileId = fEventList->GetFileIdByIndex(iE);
381 int eventId = fEventList->GetEventIdByIndex(iE);
382
383 int nMcTracks = fMcTracks->Size(fileId, eventId);
384 for (int i = 0; i < nMcTracks; i++) {
385 //At least one hit in RICH
386 CbmLink val(1., i, eventId, fileId);
387 if (fNofHitsInRingMap[val] < 1) continue;
388 const CbmMCTrack* mctrack = static_cast<CbmMCTrack*>(fMcTracks->Get(val));
389 TVector3 v;
390 mctrack->GetStartVertex(v);
391 fHM->H1("fh_vertex_z")->Fill(v.Z());
392 fHM->H1("fh_vertex_z_sts")->Fill(v.Z());
393 fHM->H2("fh_vertex_xy")->Fill(v.X(), v.Y());
394 fHM->H2("fh_vertex_zy")->Fill(v.Z(), v.Y());
395 fHM->H2("fh_vertex_zx")->Fill(v.Z(), v.X());
396 if (v.Z() >= 60 && v.Z() <= 140) fHM->H2("fh_vertex_xy_z60_140")->Fill(v.X(), v.Y());
397 if (v.Z() >= 140 && v.Z() <= 330) fHM->H2("fh_vertex_xy_z140_330")->Fill(v.X(), v.Y());
398 if (v.Z() >= 140 && v.Z() <= 190) fHM->H2("fh_vertex_xy_z140_190")->Fill(v.X(), v.Y());
399
400 for (auto pair : fVertexZStsSlices) {
401 string name = "fh_vertex_xy_z" + to_string(pair.first) + "_" + to_string(pair.second);
402 if (v.Z() > pair.first && v.Z() <= pair.second) {
403 fHM->H2(name)->Fill(v.X(), v.Y());
404 }
405 }
406 }
407 }
408}
409
411{
412 cout.precision(4);
413
415
416 {
417 fHM->Scale("fh_vertex_z", 1. / fEventNum);
418 fHM->CreateCanvas("richurqmd_vertex_z", "richurqmd_vertex_z", 1000, 1000);
419 DrawH1(fHM->H1("fh_vertex_z"), kLinear, kLog, "hist");
420 }
421
422 {
423 fHM->Scale("fh_vertex_z_sts", 1. / fEventNum);
424 fHM->CreateCanvas("richurqmd_vertex_z_sts", "richurqmd_vertex_z_sts", 1000, 1000);
425 DrawH1(fHM->H1("fh_vertex_z_sts"), kLinear, kLog, "hist");
426 }
427
428
429 {
430 fHM->Scale("fh_vertex_xy", 1. / fEventNum);
431 fHM->Scale("fh_vertex_zy", 1. / fEventNum);
432 fHM->Scale("fh_vertex_zx", 1. / fEventNum);
433 TCanvas* c = fHM->CreateCanvas("richurqmd_vertex_xyz", "richurqmd_vertex_xyz", 1800, 600);
434 c->Divide(3, 1);
435 c->cd(1);
436 DrawH2(fHM->H2("fh_vertex_xy"), kLinear, kLinear, kLog);
437 c->cd(2);
438 DrawH2(fHM->H2("fh_vertex_zy"), kLinear, kLinear, kLog);
439 c->cd(3);
440 DrawH2(fHM->H2("fh_vertex_zx"), kLinear, kLinear, kLog);
441 }
442
443 {
444 gStyle->SetOptTitle(1);
445
446 TCanvas* c = fHM->CreateCanvas("richurqmd_vertex_sts_xyz", "richurqmd_vertex_sts_xyz", 1600, 1200);
447 c->Divide(4, 3);
448 int i = 1;
449 for (auto pair : fVertexZStsSlices) {
450 string name = "fh_vertex_xy_z" + to_string(pair.first) + "_" + to_string(pair.second);
451 fHM->Scale(name, 1. / fEventNum);
452 c->cd(i++);
453 DrawH2(fHM->H2(name), kLinear, kLinear, kLog);
454 DrawTextOnPad(to_string(pair.first) + " cm < Z < " + to_string(pair.second) + " cm", 0.3, 0.9, 0.7, 0.98);
455 }
456
457 gStyle->SetOptTitle(0);
458 }
459
460 vector<string> vertexZTypes{"z60_140", "z140_330", "z140_190"};
461 for (const string& t : vertexZTypes) {
462 string name = "richurqmd_vertex_xy_" + t;
463 fHM->Scale("fh_vertex_xy_" + t, 1. / fEventNum);
464 fHM->CreateCanvas(name, name, 1000, 1000);
465 DrawH2(fHM->H2("fh_vertex_xy_" + t));
466 }
467
468 {
469 fHM->Scale("fh_nof_points_per_event_src", 1. / fEventNum);
470 fHM->CreateCanvas("richurqmd_nof_points_per_event_src", "richurqmd_nof_points_per_event_src", 1000, 1000);
471 //gStyle->SetPaintTextFormat("4.1f");
472 string labels[7] = {"all",
473 "e^{#pm}_{sec} other",
474 "e^{#pm}_{target} from #gamma",
475 "e^{#pm}_{not target} from #gamma",
476 "#pi^{#pm}",
477 "K^{#pm}",
478 "#mu^{#pm}"};
479 for (int i = 1; i <= 7; i++) {
480 fHM->H1("fh_nof_points_per_event_src")->GetXaxis()->SetBinLabel(i, labels[i - 1].c_str());
481 }
482 fHM->H1("fh_nof_points_per_event_src")->GetXaxis()->SetLabelSize(0.05);
483 //fHM->H1("fh_nof_points_per_event_src")->SetMarkerSize(0.15);
484 DrawH1(fHM->H1("fh_nof_points_per_event_src"), kLinear, kLog, "hist text0");
485 }
486
487 {
488 vector<string> nofRingsTypes{"", "_prim", "_target"};
489 for (const string& t : nofRingsTypes) {
490 string cName = "richurqmd_nof_rings" + t;
491 string h1Name = "fh_nof_rings" + t + "_1hit";
492 string h7Name = "fh_nof_rings" + t + "_7hits";
493 fHM->CreateCanvas(cName, cName, 1000, 1000);
494 fHM->NormalizeToIntegral(h1Name);
495 fHM->NormalizeToIntegral(h7Name);
496 stringstream ss1, ss2;
497 ss1 << "At least 1 hit (" << fHM->H1(h1Name)->GetMean() << ")";
498 ss2 << "At least 7 hits (" << fHM->H1(h7Name)->GetMean() << ")";
499 DrawH1({fHM->H1(h1Name), fHM->H1(h7Name)}, {ss1.str(), ss2.str()}, kLinear, kLinear, true, 0.4, 0.85, 0.99, 0.99,
500 "hist");
501 }
502 }
503
504 {
505 fHM->CreateCanvas("richurqmd_sources_mom", "richurqmd_sources_mom", 1000, 1000);
506 fHM->Scale("fh_gamma_target_mom", 1. / fEventNum);
507 fHM->Scale("fh_gamma_nontarget_mom", 1. / fEventNum);
508 fHM->Scale("fh_secel_mom", 1. / fEventNum);
509 fHM->Scale("fh_pi_mom", 1. / fEventNum);
510 fHM->Scale("fh_kaon_mom", 1. / fEventNum);
511 fHM->Scale("fh_mu_mom", 1. / fEventNum);
512 stringstream ss1, ss2, ss3, ss4, ss5, ss6;
513 ss1 << "e^{#pm}_{target} from #gamma (" << fHM->H1("fh_gamma_target_mom")->GetEntries() / fEventNum << ")";
514 ss2 << "e^{#pm}_{not target} from #gamma (" << fHM->H1("fh_gamma_nontarget_mom")->GetEntries() / fEventNum << ")";
515 ss3 << "e^{#pm}_{sec} other (" << fHM->H1("fh_secel_mom")->GetEntries() / fEventNum << ")";
516 ss4 << "#pi^{#pm} (" << fHM->H1("fh_pi_mom")->GetEntries() / fEventNum << ")";
517 ss5 << "K^{#pm} (" << fHM->H1("fh_kaon_mom")->GetEntries() / fEventNum << ")";
518 ss6 << "#mu^{#pm} (" << fHM->H1("fh_mu_mom")->GetEntries() / fEventNum << ")";
519 DrawH1(fHM->H1Vector({"fh_gamma_target_mom", "fh_gamma_nontarget_mom", "fh_secel_mom", "fh_pi_mom", "fh_kaon_mom",
520 "fh_mu_mom"}),
521 {ss1.str(), ss2.str(), ss3.str(), ss4.str(), ss5.str(), ss6.str()}, kLinear, kLog, true, 0.5, 0.7, 0.99,
522 0.99, "hist");
523 }
524
525 {
526 TCanvas* c = fHM->CreateCanvas("richurqmd_hits_xy", "richurqmd_hits_xy", 1000, 1000);
527 TH2* clone = fHM->H2Clone("fh_hits_xy");
528 clone->Scale(1. / (fEventNum));
529 CbmRichDraw::DrawPmtH2(clone, c, true);
530 }
531
532 {
533 TCanvas* c = fHM->CreateCanvas("richurqmd_occupancy_xy", "richurqmd_occupancy_xy", 1000, 1000);
534 TH2* clone = fHM->H2Clone("fh_hits_xy");
535 clone->GetZaxis()->SetTitle("Occupancy:# hits/PMT/ev./64 [%]");
536 clone->Scale(100. / (fEventNum * 64.));
537 CbmRichDraw::DrawPmtH2(clone, c, true);
538 }
539
540 {
541 vector<string> skippedPmtTypes{"10", "20", "30"};
542 for (const string& t : skippedPmtTypes) {
543 string name = "richurqmd_skipped_pmt_xy_" + t;
544 TCanvas* c = fHM->CreateCanvas(name, name, 1000, 1000);
545 fHM->Scale("fh_skipped_pmt_xy_" + t, 100. / fEventNum);
546 CbmRichDraw::DrawPmtH2(fHM->H2("fh_skipped_pmt_xy_" + t), c, true);
547 }
548 }
549
550 {
551 fHM->CreateCanvas("richurqmd_nof_hits_per_pmt", "richurqmd_nof_hits_per_pmt", 1000, 1000);
552 fHM->NormalizeToIntegral("fh_nof_hits_per_pmt");
553 DrawH1(fHM->H1("fh_nof_hits_per_pmt"), kLinear, kLog, "hist");
554 fHM->H1("fh_nof_hits_per_pmt")->SetStats(true);
555 }
556
557 {
558 vector<string> pointXYTypes{"", "_pions", "_gamma_target", "_gamma_nontarget"};
559 for (const string& t : pointXYTypes) {
560 string name = "richurqmd_points_xy" + t;
561 TCanvas* c = fHM->CreateCanvas(name, name, 1000, 1000);
562 fHM->Scale("fh_points_xy" + t, 1. / fEventNum);
563 CbmRichDraw::DrawPmtH2(fHM->H2("fh_points_xy" + t), c, true);
564 }
565 }
566
567 {
568 fHM->CreateCanvas("richurqmd_nof_hits_per_event", "richurqmd_nof_hits_per_event", 1000, 1000);
569 fHM->NormalizeToIntegral("fh_nof_hits_per_event");
570 DrawH1(fHM->H1("fh_nof_hits_per_event"), kLinear, kLinear, "hist");
571 fHM->H1("fh_nof_hits_per_event")->SetStats(true);
572 cout << "Mean number of hits per event = " << fHM->H1("fh_nof_hits_per_event")->GetMean() << endl;
573 }
574
575 {
576 fHM->CreateCanvas("richurqmd_nof_points_per_event", "richurqmd_nof_points_per_event", 1000, 1000);
577 fHM->NormalizeToIntegral("fh_nof_points_per_event");
578 DrawH1(fHM->H1("fh_nof_points_per_event"), kLinear, kLinear, "hist");
579 fHM->H1("fh_nof_points_per_event")->SetStats(true);
580 cout << "Mean number of points per event = " << fHM->H1("fh_nof_points_per_event")->GetMean() << endl;
581 }
582
583 {
584 TCanvas* c = fHM->CreateCanvas("richurqmd_hitrate_xy", "richurqmd_hitrate_xy", 1000, 1000);
585 fHM->Scale("fh_hitrate_xy", 1e7 / (fEventNum * 64.));
586 CbmRichDraw::DrawPmtH2(fHM->H2("fh_hitrate_xy"), c, true);
587 //DrawH2(fHM->H2("fh_hitrate_xy"));
588 }
589
590 {
591 TCanvas* c = fHM->CreateCanvas("richurqmd_proj_xy", "richurqmd_proj_xy", 1000, 1000);
592 fHM->Scale("fh_proj_xy", 1. / fEventNum);
593 CbmRichDraw::DrawPmtH2(fHM->H2("fh_proj_xy"), c);
594 }
595
596 {
597 fHM->CreateCanvas("richurqmd_nof_proj_per_event", "richurqmd_nof_proj_per_event", 1000, 1000);
598 fHM->Scale("fh_nof_proj_per_event", 1. / fEventNum);
599 DrawH1(fHM->H1("fh_nof_proj_per_event"), kLinear, kLinear, "hist");
600 fHM->H1("fh_nof_proj_per_event")->SetStats(true);
601 cout << "Number of track projections per event = " << fHM->H1("fh_nof_proj_per_event")->GetMean() << endl;
602 }
603}
604
606{
607 TDirectory* oldir = gDirectory;
608 TFile* outFile = FairRootManager::Instance()->GetOutFile();
609 if (outFile != nullptr) {
610 outFile->mkdir(GetName());
611 outFile->cd(GetName());
612 fHM->WriteToFile();
613 }
614
615 DrawHist();
617 fHM->Clear();
618 gDirectory->cd(oldir->GetPath());
619}
620
ClassImp(CbmConverterManager)
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void SetDefaultDrawStyle()
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.
@ kLinear
Definition CbmDrawHist.h:69
@ kLog
Definition CbmDrawHist.h:68
Histogram manager.
FairTask for matching RECO data to MC.
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
Histogram manager.
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.
std::vector< TH1 * > H1Vector(const std::vector< std::string > &names) const
Return vector of pointers to TH1 histogram.
void Clear(Option_t *="")
Clear memory. Remove all histograms and canvases.
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 Scale(const std::string &histName, Double_t scale)
Scale histogram.
void WriteToFile()
Write all objects to current opened file.
void NormalizeToIntegral(const std::string &histName)
Normalize histogram to integral.
TH2 * H2Clone(const std::string &name) const
Return clone of TH2 histogram.
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.
int32_t GetRefId() const
Definition CbmHit.h:73
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
int32_t GetFileIdByIndex(uint32_t index)
File number by index @value File number for event at given index in list.
int32_t GetEventIdByIndex(uint32_t index)
Event number by index @value Event number for event at given index in list.
std::size_t GetNofEvents() const
Number of events in the list @value Number of events.
double GetP() const
Definition CbmMCTrack.h:98
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
void GetStartVertex(TVector3 &vertex) const
Definition CbmMCTrack.h:176
static std::vector< CbmLink > GetMcTrackMotherIdsForRichHit(CbmDigiManager *digiMan, const CbmRichHit *hit, CbmMCDataArray *richPoints, CbmMCDataArray *mcTracks)
Get CbmLinks of Mother MC Tracks for RICH hit.
int32_t GetNofLinks() const
Definition CbmMatch.h:42
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
static CbmRichDigiMapManager & GetInstance()
Return Instance of CbmRichGeoManager.
std::vector< Int_t > GetPmtIds()
Return ids for all pmts.
CbmRichPixelData * GetPixelDataByAddress(Int_t address)
Return CbmRichDataPixel by digi address.
CbmRichPmtData * GetPmtDataById(Int_t id)
Return CbmRichDataPmt by id.
int32_t GetAddress() const
Definition CbmRichDigi.h:43
static void DrawPmtH2(TH2 *h, TCanvas *c, Bool_t usePmtBins=false)
Definition CbmRichDraw.h:23
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
static CbmRichGeoManager & GetInstance()
int32_t GetNofHits() const
Definition CbmRichRing.h:37
CbmHistManager * fHM
std::vector< std::pair< int, int > > fVertexZStsSlices
TClonesArray * fRichRings
CbmMCDataArray * fRichPoints
virtual void Exec(Option_t *option)
Inherited from FairTask.
virtual InitStatus Init()
Inherited from FairTask.
void DrawHist()
Draw histograms.
CbmMCEventList * fEventList
TClonesArray * fRichHits
CbmRichUrqmdTest()
Standard constructor.
TClonesArray * fRichProjections
void InitHistograms()
Initialize histograms.
std::string fOutputDir
virtual void Finish()
Inherited from FairTask.
CbmMCDataArray * fMcTracks
virtual ~CbmRichUrqmdTest()
Standard destructor.
std::map< CbmLink, int > fNofHitsInRingMap
TClonesArray * fRichRingMatches
CbmDigiManager * fDigiMan
static std::vector< double > GetPmtHistYbins()
static std::vector< double > GetPmtHistXbins()
T * GetOrFatal(const std::string &objName, const std::string &description="")
Definition CbmUtils.h:60
CbmMCDataArray * InitOrFatalMc(const std::string &objName, const std::string &description)
Definition CbmUtils.cxx:28
Hash for CbmL1LinkKey.