CbmRoot
Loading...
Searching...
No Matches
CbmMvdReadoutSimple.cxx
Go to the documentation of this file.
1/* Copyright (C) 2016-2021 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdReadoutSimple source file -----
7// ----- Created 17/10/16 by P. Sitzmann -----
8// -------------------------------------------------------------------------
10
11#include "CbmMvdPoint.h" // for CbmMvdPoint
12
13#include <FairRootManager.h> // for FairRootManager
14#include <Logger.h> // for Logger, LOG
15
16#include <TAxis.h> // for TAxis
17#include <TCanvas.h> // for TCanvas
18#include <TClonesArray.h> // for TClonesArray
19#include <TF1.h> // for TF1
20#include <TFile.h> // for TFile
21#include <TH1.h> // for TH1F, TH1I
22#include <TH2.h> // for TH2F, TH2I
23#include <TString.h> // for Form
24
25// ----- Default constructor -------------------------------------------
27// -------------------------------------------------------------------------
28
29// ----- Standard constructor ------------------------------------------
30CbmMvdReadoutSimple::CbmMvdReadoutSimple(const char* name, Int_t iVerbose)
31 : FairTask(name, iVerbose)
32 , foutFile(nullptr)
33 , fshow(kFALSE)
34 , fMvdMCBank()
35 , fMvdMCHitsStations()
36 , fWordsPerRegion(nullptr)
37 , fWordsPerRegion2(nullptr)
38 , fWordsPerWorstRegion(nullptr)
39 , fWordsPerSuperRegion(nullptr)
40 , fWorstSuperPerEvent(nullptr)
41 , fMvdBankDist(nullptr)
42 , fMvdMCWorst(nullptr)
43 , fMvdMCWorstDelta(nullptr)
44 , fMvdDataLoadPerSensor(nullptr)
45 , fMvdDataLoadHotSensor(nullptr)
46 , fMvdDataPerRegion()
47 , fMvdDataPerSuperRegion()
48 , fMcPoints()
49 , fListMCTracks()
50 , fEventNumber(0)
51{
52}
53// -------------------------------------------------------------------------
54
55// ----- Destructor ----------------------------------------------------
57// -------------------------------------------------------------------------
58
59// -------------------------------------------------------------------------
61{
62 FairRootManager* ioman = FairRootManager::Instance();
63 if (!ioman) { LOG(fatal) << "RootManager not instantised!"; }
64
65 fMcPoints = (TClonesArray*) ioman->GetObject("MvdPoint"); // PileUp Mc points
66 fListMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
67
68 if (!fMcPoints) LOG(fatal) << "Mvd Pile Up Mc array missing";
69
71
72 return kSUCCESS;
73}
74// -------------------------------------------------------------------------
75
76// -------------------------------------------------------------------------
78{
79 for (Int_t i = 0; i < 63; i++) {
80 fMvdMCBank[i] = new TH2F(Form("fMvdMCBank%d", i), "Mvd mc distribution worst spot only delta electrons", 300, -2, 0,
81 1500, 3.5, 0);
82 }
83
84 fMvdMCHitsStations[0] = new TH2F("fMvdMCStation0", "Mvd mc distribution", 2, -2.5, -0.5, 3, -0.5, 2.5);
85 fMvdMCHitsStations[1] = new TH2F("fMvdMCStation1", "Mvd mc distribution", 4, -4.5, -0.5, 6, -0.5, 5.5);
86 fMvdMCHitsStations[2] = new TH2F("fMvdMCStation2", "Mvd mc distribution", 6, -7.5, -1.5, 9, -1.5, 7.5);
87 fMvdMCHitsStations[3] = new TH2F("fMvdMCStation3", "Mvd mc distribution", 8, -9.5, -1.5, 12, -1.5, 10.5);
88
89 fWordsPerRegion = new TH1F("fWordsPerRegion", "Words send to a region", 65, 0, 64);
90 fWordsPerRegion->GetXaxis()->SetTitle("Regionnumber");
91 fWordsPerRegion->GetYaxis()->SetTitle("Average Entries per Region");
92
94 new TH2F("fWordsPerRegion2", "Words send to a region, errors sigma of gauss fit", 64, 0, 63, 150, 0, 15);
95 fWordsPerRegion2->GetXaxis()->SetTitle("Regionnumber");
96 fWordsPerRegion2->GetYaxis()->SetTitle("Average Entries per Region");
97
98 fWordsPerWorstRegion = new TH1F("fWordsPerWorstRegion", "Most worst send to a region per Event", 65, 0, 64);
99 fWordsPerWorstRegion->GetXaxis()->SetTitle("words");
100 fWordsPerWorstRegion->GetYaxis()->SetTitle("Entries");
101
102 fWordsPerSuperRegion = new TH1F("fWordsPerSuperRegion", "Words send to a super region", 1000, 0, 400);
103 fWordsPerSuperRegion->GetXaxis()->SetTitle("words");
104 fWordsPerSuperRegion->GetYaxis()->SetTitle("Entries");
105
106 fWorstSuperPerEvent = new TH1F("fWorstSuperRegion", "Most words send to super region per Event", 1000, 0, 400);
107 fWorstSuperPerEvent->GetXaxis()->SetTitle("words");
108 fWorstSuperPerEvent->GetYaxis()->SetTitle("Entries");
109
110 fMvdMCWorst = new TH2F("fMvdMCWorst", "Mvd mc distribution worst spot", 300, -2, 0, 1500, 3.5, 0);
111 fMvdMCWorst->GetYaxis()->SetTitle("y [cm]");
112 fMvdMCWorst->GetXaxis()->SetTitle("x [cm]");
113
115 new TH2F("fMvdMCWorstDelta", "Mvd mc distribution worst spot only delta electrons", 300, -2, 0, 1500, 3.5, 0);
116 fMvdMCWorstDelta->GetYaxis()->SetTitle("y [cm]");
117 fMvdMCWorstDelta->GetXaxis()->SetTitle("x [cm]");
118
119 fMvdDataLoadPerSensor = new TH1I("fMvdDataLoadPerSensor", "Mvd Dataload per Sensor", 300, 0, 300);
120 fMvdDataLoadPerSensor->GetXaxis()->SetTitle("Sensor number");
121 fMvdDataLoadPerSensor->GetYaxis()->SetTitle("Entries");
122
123 fMvdDataLoadHotSensor = new TH1I("fMvdDataLoadHotSensor", "Mvd Dataload in worst Sensor", 2000, 0, 2000);
124 fMvdDataLoadHotSensor->GetXaxis()->SetTitle("number of words");
125 fMvdDataLoadHotSensor->GetYaxis()->SetTitle("Entries");
126
127 fMvdBankDist = new TH2I("fMvdBankDist", "Avarage Hits per Region", 63, 0, 63, 50, 0, 50);
128 fMvdBankDist->GetXaxis()->SetTitle("Region number");
129 fMvdBankDist->GetYaxis()->SetTitle("Entries");
130
131 for (Int_t i = 0; i < 64; i++) {
132 fMvdDataPerRegion[i] = new TH1F(Form("fMvdDataPerRegion[%d]", i), Form("Words send to region %d", i), 100, 0, 100);
133 fMvdDataPerRegion[i]->GetXaxis()->SetTitle("Words");
134 fMvdDataPerRegion[i]->GetYaxis()->SetTitle("Entries");
135 }
136
137
138 for (Int_t i = 0; i < 16; i++) {
140 new TH1F(Form("fMvdDataPerSuperRegion[%d]", i), Form("Words send to superregion %d", i), 400, 0, 400);
141 fMvdDataPerSuperRegion[i]->GetXaxis()->SetTitle("Words");
142 fMvdDataPerSuperRegion[i]->GetYaxis()->SetTitle("Entries");
143 }
144}
145// -------------------------------------------------------------------------
146
147
148// -------------------------------------------------------------------------
149void CbmMvdReadoutSimple::Exec(Option_t* /*opt*/)
150{
151 fEventNumber++;
152
153 Float_t wordsPerRegion[64] = {0};
154 Float_t wordsPerSuper[16] = {0};
155
156 Float_t yPosMin = -0.73;
157 Float_t yPosMax = 2.5;
158
159 for (Int_t k = 0; k < fMcPoints->GetEntriesFast(); k++) {
160 CbmMvdPoint* curPoint = (CbmMvdPoint*) fMcPoints->At(k);
161 fMvdDataLoadPerSensor->Fill(curPoint->GetStationNr(), 1.5);
162
163 if (curPoint->GetZ() < 8) {
164 if (curPoint->GetX() > -1.93 && curPoint->GetX() <= -0.55 && curPoint->GetY() >= yPosMin
165 && curPoint->GetY() <= yPosMax) {
166 fMvdMCWorst->Fill(curPoint->GetX(), curPoint->GetY());
167 if (curPoint->GetTrackID() == -3) fMvdMCWorstDelta->Fill(curPoint->GetX(), curPoint->GetY());
168 for (Int_t nRegion = 0; nRegion < 64; nRegion++) {
169 if (curPoint->GetY() >= (yPosMin + (nRegion * 0.05))
170 && curPoint->GetY() < (yPosMin + ((nRegion + 1) * 0.05))) {
171 fMvdMCBank[nRegion]->Fill(curPoint->GetX(), curPoint->GetY());
172 wordsPerRegion[nRegion] = wordsPerRegion[nRegion] + 1.5;
173 if (wordsPerRegion[nRegion] > 100) LOG(info) << " Region " << nRegion << " has an overflow";
174 fWordsPerRegion->Fill(nRegion, 1.5);
175 break;
176 }
177 }
178 }
179 }
180 if (curPoint->GetZ() < 8) {
181 if (curPoint->GetX() < -0.5 && curPoint->GetY() > -0.5)
182 fMvdMCHitsStations[0]->Fill(curPoint->GetX(), curPoint->GetY());
183 }
184 else if (curPoint->GetZ() < 13) {
185 if (curPoint->GetX() < -0.5 && curPoint->GetY() > -1.5)
186 fMvdMCHitsStations[1]->Fill(curPoint->GetX(), curPoint->GetY());
187 }
188 else if (curPoint->GetZ() < 18) {
189 if (curPoint->GetX() < -1.5 && curPoint->GetY() > -1.5)
190 fMvdMCHitsStations[2]->Fill(curPoint->GetX(), curPoint->GetY());
191 }
192 else {
193 if (curPoint->GetX() < -1.5 && curPoint->GetY() > -1.5)
194 fMvdMCHitsStations[3]->Fill(curPoint->GetX(), curPoint->GetY());
195 }
196 }
197 LOG(info) << "//--------------- New Event " << fEventNumber << " -----------------------\\";
198
199 Int_t i = 0;
200 Int_t wordsInWorst = 0;
201 Int_t wordsInWorstReg = 0;
202 Int_t wordsTotal = 0;
203
204 for (Int_t supReg = 0; supReg < 16; supReg++) {
205 for (Int_t k = 0; k < 4; k++) {
206 wordsPerSuper[supReg] += wordsPerRegion[i];
207 fMvdDataPerRegion[i]->Fill(wordsPerRegion[i]);
208 if (wordsPerRegion[i] > wordsInWorstReg) wordsInWorstReg = wordsPerRegion[i];
209 LOG(debug) << "Words in Region " << i << ": " << wordsPerRegion[i];
210 i++;
211 }
212
213 LOG(debug) << " Words in super region " << supReg << ": " << wordsPerSuper[supReg];
214 if (wordsPerSuper[supReg] > 400) LOG(info) << "SuperRegion " << supReg << " has an overflow";
215 fWordsPerSuperRegion->Fill(wordsPerSuper[supReg]);
216 fMvdDataPerSuperRegion[supReg]->Fill(wordsPerSuper[supReg]);
217
218 if (wordsPerSuper[supReg] > wordsInWorst) wordsInWorst = wordsPerSuper[supReg];
219
220 wordsTotal += wordsPerSuper[supReg];
221 }
222
223 fWorstSuperPerEvent->Fill(wordsInWorst);
224 fWordsPerWorstRegion->Fill(wordsInWorstReg);
225 fMvdDataLoadHotSensor->Fill(wordsTotal);
226
227 LOG(info) << "//--------------- End Event -----------------------\\";
228}
229// -------------------------------------------------------------------------
230
231// -------------------------------------------------------------------------
233{
234 foutFile->cd();
235
236 Float_t scale = 1. / (Float_t) fEventNumber;
237 for (Int_t iPad = 0; iPad < 4; iPad++) {
238 fMvdMCHitsStations[iPad]->Scale(scale);
239 }
240 fMvdDataLoadPerSensor->Scale(scale);
241 fWordsPerRegion->Scale(scale);
242
243
244 if (fshow) DrawHistograms();
246}
247// -------------------------------------------------------------------------
248
249// -------------------------------------------------------------------------
251{
252
253 for (Int_t iPad = 0; iPad < 4; iPad++) {
254 fMvdMCHitsStations[iPad]->Write();
255 }
256
257 fMvdDataLoadPerSensor->Write();
258
259 fMvdDataLoadHotSensor->Write();
260
261 fWordsPerSuperRegion->Write();
262
263 fWorstSuperPerEvent->Write();
264
265 fWordsPerRegion->Write();
266
267 fWordsPerWorstRegion->Write();
268
269 for (Int_t i = 0; i < 64; i++) {
270 fMvdDataPerRegion[i]->Fit("gaus");
271 TF1* func = fMvdDataPerRegion[i]->GetFunction("gaus");
272 Double_t param0 = func->GetParameter(0);
273 Double_t param1 = func->GetParameter(1);
274 Double_t param2 = func->GetParameter(2);
275 Double_t chi2 = func->GetChisquare();
276 LOG(info) << " // - " << i << " -- param 0 = " << param0 << " -- param 1 = " << param1 << " -- param 2 = " << param2
277 << " -- chi2 = " << chi2;
278 fWordsPerRegion2->Fill(i, param1);
279 fWordsPerRegion2->SetBinError(i, 0, param1, param2);
280 fMvdDataPerRegion[i]->Write();
281 }
282 fWordsPerRegion2->Write();
283
284 for (Int_t i = 0; i < 16; i++)
285 fMvdDataPerSuperRegion[i]->Write();
286}
287// -------------------------------------------------------------------------
288
289// -------------------------------------------------------------------------
291{
292 TCanvas* mcCanvas1 = new TCanvas();
293 mcCanvas1->Divide(2, 2);
294 for (Int_t iPad = 0; iPad < 4; iPad++) {
295 mcCanvas1->cd(iPad + 1);
296 fMvdMCHitsStations[iPad]->Draw("COLZ");
297 }
298
299 TCanvas* dataLoad = new TCanvas();
300 dataLoad->Divide(2, 1);
301 dataLoad->cd(1);
302 fMvdDataLoadPerSensor->Draw("BAR");
303 dataLoad->cd(2);
304 fMvdDataLoadHotSensor->Draw("BAR");
305
306 TCanvas* mcCanvas2 = new TCanvas();
307 mcCanvas2->Divide(1, 2);
308 mcCanvas2->cd(1);
309 fWordsPerSuperRegion->Draw();
310 mcCanvas2->cd(2);
311 fWorstSuperPerEvent->Draw();
312
313 /*
314TCanvas* mcCanvas3 = new TCanvas();
315fMvdMCHitsStations[0]->Draw("COLZ");
316
317TCanvas* mcCanvas4 = new TCanvas();
318mcCanvas4->Divide(8,8);
319for(Int_t pad = 0; pad < 63; pad++)
320 {
321 mcCanvas4->cd(pad+1);
322 fMvdMCBank[pad]->Draw("COL");
323 fMvdMCBank[pad]->Write();
324 LOG(info) << "Bank " << pad << " avarage Entries " << fMvdMCBank[pad]->GetEntries()/fEventNumber;
325 fMvdBankDist->Fill(pad, fMvdMCBank[pad]->GetEntries()/fEventNumber);
326 }
327TCanvas* mcCanvas5 = new TCanvas();
328fMvdBankDist->Draw();
329
330TCanvas* mcCanvas6 = new TCanvas();
331fMvdMCWorst->Draw("COL");
332fMvdMCWorst->Write();
333*/
334
335 TCanvas* regionCanvas = new TCanvas();
336 regionCanvas->Divide(1, 2);
337 regionCanvas->cd(1);
338 fWordsPerRegion->Draw();
339 regionCanvas->cd(2);
340 fWordsPerRegion2->Draw();
341
342 TCanvas* regionsCanvas[64];
343 TCanvas* supregionsCanvas[16];
344
345 for (Int_t i = 0; i < 64; i++) {
346 regionsCanvas[i] = new TCanvas();
347 regionsCanvas[i]->cd();
348 fMvdDataPerRegion[i]->Draw();
349 }
350
351 for (Int_t i = 0; i < 16; i++) {
352 supregionsCanvas[i] = new TCanvas();
353 supregionsCanvas[i]->cd();
354 fMvdDataPerSuperRegion[i]->Draw();
355 }
356}
357// -------------------------------------------------------------------------
358
ClassImp(CbmMvdReadoutSimple)
int32_t GetStationNr() const
Definition CbmMvdPoint.h:75
void Exec(Option_t *opt)
TClonesArray * fListMCTracks