Belle II Software development
CDCDedxValidation.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <cdc/modules/CDCDedxValidation/CDCDedxValidation.h>
10
11#include <mdst/dataobjects/Track.h>
12#include <mdst/dataobjects/ECLCluster.h>
13
14#include <TF1.h>
15#include <TH2D.h>
16
17#include <cmath>
18
19using namespace Belle2;
20
21
22REG_MODULE(CDCDedxValidation);
23
24//-------------------------------------------------
27 fD0Window(1.0),
28 fZ0Window(1.0),
29 fnRunCounter(0),
30 fiRun(0),
31 fnBinsdedx(120),
32 fnBinsdedxLE(0.4),
33 fnBinsdedxUE(1.6)
34{
35 setDescription("Make data quality monitoring plots for CDC dE/dx");
36 addParam("outputFileName", fOutFileName, "Name for output file", std::string("CDCdEdxValidation.root"));
37 addParam("SampleType", fCollType, "Switch to hadron (false) vs bhabha files", std::string("temp"));
38 addParam("fnRuns", fnRuns, "Number of input runs");
39
40}
41
42//-----------------------------------------
44{
45
46 m_cdcDedxTracks.isRequired();
47
48 if (fCollType != "radbhabha" and fCollType != "bhabha" and fCollType != "hadron") {
49 printf("Wrong input file type (%s): choose bhabha or radbhabha or hadron \n", fCollType.data());
50 return;
51 } else {
52 fBasic = new TList(); fBasic->SetOwner(); fBasic->SetName("AllRunBasics");
53 fPRdEdx = new TList(); fPRdEdx->SetOwner(); fPRdEdx->SetName("PerRunDEdx");
54 fPRdEdxinP = new TList(); fPRdEdxinP->SetOwner(); fPRdEdxinP->SetName("PerRundEdxinP");
55 DefineHistograms("AR", 0);
56 }
57}
58
59
60//---------------------------------------
62{
63
64 StoreObjPtr<EventMetaData> eventMetaDataPtr;
65 fCurrentRunNum = eventMetaDataPtr->getRun();
66
68 fcRunGain = -1.0;
69
71
73}
74
75
76//------------------------------------
78{
79
80 //Loop over CDC Tracks
81 for (Int_t idedx = 0; idedx < m_cdcDedxTracks.getEntries(); idedx++) {
82
83 CDCDedxTrack* dedxTrack = m_cdcDedxTracks[idedx];
84 if (!dedxTrack) {
85 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(0.0);
86 continue;
87 }
88
89 const Track* track = dedxTrack->getRelatedFrom<Track>();
90 if (!track) {
91 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(1.0);
92 continue;
93 }
94
95 const TrackFitResult* mTrack = NULL;
96 if (fCollType == "bhabha" || fCollType == "radbhabha") {
97 mTrack = track->getTrackFitResultWithClosestMass(Const::electron);
98 } else {
99 mTrack = track->getTrackFitResultWithClosestMass(Const::pion);
100 }
101 if (!mTrack) {
102 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(2.0);
103 continue;
104 }
105
106 bool IsTrkSelected = IsSelectedTrack(mTrack);
107 if (!IsTrkSelected) {
108 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(3.0);
109 continue;
110 }
111
112 if (dedxTrack->getNLayerHits() <= 20) continue;
113
114 const ECLCluster* eclCluster = track->getRelated<ECLCluster>();
115 if (eclCluster and eclCluster->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) {
117 if (fCollType == "bhabha" || fCollType == "radbhabha") {
118 if (std::abs(fTrkEoverP - 1.0) >= 0.2)continue;
119 ((TH1D*)fBasic->FindObject(Form("hEOverP_AR")))->Fill(double(fTrkEoverP));
120 }
121 } else {
122 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(4.0);
123 continue;
124
125 }
126
127 ((TH1D*)fBasic->FindObject("hTrkPerEvtStats"))->Fill(5.0);
128 FillHistograms(dedxTrack, mTrack);
129 }
130}
131
132//----------------------------------------------------------------------------------------------------
134{
135
136 fcRunGain = dedxTrack->getRunGain();
137
138 Int_t TrkCharge = mTrack->getChargeSign();
139 Double_t TrkdEdxnosat = dedxTrack->getDedxNoSat();
140 Double_t TrkdEdx = dedxTrack->getDedx();
141 Double_t TrkCosTheta = dedxTrack->getCosTheta();
142 Double_t TrkMom = dedxTrack->getMomentum();
143
144 if (TrkMom >= 8.00)TrkMom = 7.999;
145 Double_t BWMom = 0.250; //in GeV
146 Int_t iMomBin = Int_t(TrkMom / BWMom);
147
148 if (fCollType == "radbhabha" or fCollType == "bhabha") {
149
150 if (TrkCharge > 0) {
151 ((TH1D*)fBasic->FindObject(Form("hP_Positron_AR")))->Fill(TrkMom);
152 ((TH1D*)fBasic->FindObject(Form("hdEdx_Positron_AR")))->Fill(TrkdEdxnosat);
153 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", iMomBin)))->Fill(TrkdEdxnosat);
154 } else if (TrkCharge < 0) {
155 ((TH1D*)fBasic->FindObject(Form("hP_Electron_AR")))->Fill(TrkMom);
156 ((TH1D*)fBasic->FindObject(Form("hdEdx_Electron_AR")))->Fill(TrkdEdxnosat);
157 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", iMomBin)))->Fill(TrkdEdxnosat);
158 }
159
160 ((TH1D*)fBasic->FindObject(Form("hdEdx_AR")))->Fill(double(TrkdEdxnosat));
161 ((TH2D*)fBasic->FindObject(Form("hdEdxvsPhi_AR")))->Fill(double(mTrack->getPhi()), double(TrkdEdxnosat));
162 ((TH2D*)fBasic->FindObject(Form("hPvsdEdx_AR")))->Fill(TrkMom * TrkCharge, double(TrkdEdxnosat));
163 ((TH2D*)fBasic->FindObject(Form("hPvsCosth_AR")))->Fill(TrkMom * TrkCharge, double(TrkCosTheta));
164
165 hdEdx_PR[fiRun]->Fill(double(TrkdEdxnosat));
166
167 } else if (fCollType == "hadron") {
168
169 // double ChiE = dedxTrack->getChi(0);
170 // double ChiMu = dedxTrack->getChi(1);
171 double ChiPi = dedxTrack->getChi(2);
172 double ChiK = dedxTrack->getChi(3);
173 double ChiP = dedxTrack->getChi(4);
174 // double ChiD = dedxTrack->getChi(5);
175
176 ((TH2D*)fBasic->FindObject(Form("hPvsdEdx_hadAR")))->Fill(TrkMom, TrkdEdx);
177
178 if ((TrkMom < 0.40) && (fTrkEoverP < 0.4) && (TrkdEdx < (0.6 + 0.10 / (TrkMom * TrkMom)))
179 && (TrkdEdx > (0.4 + 0.012 / (TrkMom * TrkMom)))) {
180 ((TH1D*)fBasic->FindObject(Form("hPionChiallP")))->Fill(ChiPi);
181 if (TrkMom < 0.300)((TH1D*)fBasic->FindObject(Form("hPionChiLowP")))->Fill(ChiPi);
182 else ((TH1D*)fBasic->FindObject(Form("hPionChiHighP")))->Fill(ChiPi);
183 ((TH2D*)fBasic->FindObject(Form("hPvsdEdxPion_hadAR")))->Fill(TrkMom, TrkdEdx);
184 }
185
186 if ((TrkMom < 0.40) && (TrkdEdx > 1.35) && (TrkdEdx < (0.6 + 0.40 / (TrkMom * TrkMom)))
187 && (TrkdEdx > (0.6 + 0.10 / (TrkMom * TrkMom)))) {
188 ((TH1D*)fBasic->FindObject(Form("hKaonChiallP")))->Fill(ChiK);
189 if (TrkMom < 0.350)((TH1D*)fBasic->FindObject(Form("hKaonChiLowP")))->Fill(ChiK);
190 else ((TH1D*)fBasic->FindObject(Form("hKaonChiHighP")))->Fill(ChiK);
191 ((TH2D*)fBasic->FindObject(Form("hPvsdEdxKaon_hadAR")))->Fill(TrkMom, TrkdEdx);
192 }
193
194 if ((TrkMom < 0.80) && (TrkdEdx > 1.35) && (TrkdEdx < (0.6 + 1.20 / (TrkMom * TrkMom)))
195 && (TrkdEdx > (0.6 + 0.40 / (TrkMom * TrkMom)))) {
196 ((TH1D*)fBasic->FindObject(Form("hProtonChiallP")))->Fill(ChiP);
197 if (TrkMom < 0.600)((TH1D*)fBasic->FindObject(Form("hProtonChiLowP")))->Fill(ChiP);
198 else ((TH1D*)fBasic->FindObject(Form("hProtonChiHighP")))->Fill(ChiP);
199 ((TH2D*)fBasic->FindObject(Form("hPvsdEdxProton_hadAR")))->Fill(TrkMom, TrkdEdx);
200 }
201 }
202
203}
204
205
206
207//----------------------------------
209{
210 if (fCollType != "hadron")ExtractHistograms("PR");
211}
212
213
214//----------------------------------------------------------------------------------
215void CDCDedxValidationModule::DefineHistograms(TString level = "XR", Int_t iR = 123)
216{
217 if (level == "AR") {
218
219 TH1D* hTrkPerEvtStats = new TH1D("hTrkPerEvtStats", "Track selections", 6, -0.5, 5.5);
220 hTrkPerEvtStats->GetXaxis()->SetBinLabel(1, "no dedxobject");
221 hTrkPerEvtStats->GetXaxis()->SetBinLabel(2, "no assoc-track");
222 hTrkPerEvtStats->GetXaxis()->SetBinLabel(3, "no TrackFit");
223 hTrkPerEvtStats->GetXaxis()->SetBinLabel(4, "no pass cuts");
224 hTrkPerEvtStats->GetXaxis()->SetBinLabel(5, "no eclCluster");
225 hTrkPerEvtStats->GetXaxis()->SetBinLabel(6, "Selected");
226 hTrkPerEvtStats->SetFillColor(kRed);
227 hTrkPerEvtStats->SetFillStyle(3015);
228 hTrkPerEvtStats->SetMinimum(0);
229 fBasic->Add(hTrkPerEvtStats);
230
231 if (fCollType == "radbhabha" or fCollType == "bhabha") {
232
233 TH1D* hdEdx_AR = new TH1D("hdEdx_AR", "dE/dx (nohad sat)", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
234 hdEdx_AR->GetXaxis()->SetTitle(Form("dE/dx truncMean of %s tracks", fCollType.data()));
235 hdEdx_AR->GetYaxis()->SetTitle("Entries");
236 fBasic->Add(hdEdx_AR);
237
238 TH1D* hEOverP_AR = new TH1D("hEOverP_AR", "E/p distribution", 100, 0.5, 1.5);
239 hEOverP_AR->GetXaxis()->SetTitle("E/p distribution");
240 hEOverP_AR->GetYaxis()->SetTitle("Entries");
241 fBasic->Add(hEOverP_AR);
242
243 TH1D* hRunGainPR = new TH1D("hRunGainPR", "bla-bla", fnRuns, -0.5, fnRuns - 0.5);
244 hRunGainPR->SetTitle("Run gain variation vs. RunNumber;Run Numbers;dE/dx mean");
245 hRunGainPR->GetYaxis()->SetRangeUser(0.85, 1.15);
246 fBasic->Add(hRunGainPR);
247
248 TH1D* hP_Electron_AR = new TH1D("hP_Electron_AR", "bla-bla", 320, 0.0, 8.0);
249 hP_Electron_AR->SetTitle("Momentum distribution of e-; Momentum of (e-); Entries");
250 fBasic->Add(hP_Electron_AR);
251
252 TH1D* hP_Positron_AR = new TH1D("hP_Positron_AR", "bla-bla", 320, 0.0, 8.0);
253 hP_Positron_AR->SetTitle("Momentum distribution of e+;Momentum of (e+);Entries");
254 fBasic->Add(hP_Positron_AR);
255
256 TH1D* hdEdx_Electron_AR = new TH1D("hdEdx_Electron_AR", "bla-bla", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
257 hdEdx_Electron_AR->SetTitle("dE/dx (nohad sat) of e- ;dE/dx distribution (e-);Entries");
258 fBasic->Add(hdEdx_Electron_AR);
259
260 TH1D* hdEdx_Positron_AR = new TH1D("hdEdx_Positron_AR", "bla-bla", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
261 hdEdx_Positron_AR->SetTitle("dE/dx (nohad sat) of e+;dE/dx distribution (e+);Entries");
262 fBasic->Add(hdEdx_Positron_AR);
263
264 TH2D* hPvsdEdx_AR = new TH2D("hPvsdEdx_AR", "bla-bla", 320, -8.0, 8.0, 100, 0.0, 2.0);
265 hPvsdEdx_AR->SetTitle("dE/dx band plots for e+ and e-; Momentum of (e+(right)) and e-);dE/dx");
266 fBasic->Add(hPvsdEdx_AR);
267
268 TH2D* hdEdxvsPhi_AR = new TH2D("hdEdxvsPhi_AR", "dE/dx (no had sat) vs #phi", 64, -3.14, 3.14, 200, 0., 2.0);
269 hdEdxvsPhi_AR->SetTitle("dE/dx (no Had Sat) vs #phi;track #phi;dE/dx");
270 fBasic->Add(hdEdxvsPhi_AR);
271
272 TH2D* hPvsCosth_AR = new TH2D("hPvsCosth_AR", "cos(#theta) vs. p: all Runs", 2 * 48, -10., 10., 60, -1.2, 1.2);
273 hPvsCosth_AR->GetXaxis()->SetTitle(Form("Momentum of %s tracks", fCollType.data()));
274 hPvsCosth_AR->GetYaxis()->SetTitle("cos(#theta)");
275 fBasic->Add(hPvsCosth_AR);
276
277
278 TH1D* hdEdx_Posi_Pbin_AR[32], *hdEdx_Elec_Pbin_AR[32];
279 for (int ip = 0; ip < 32; ip++) {
280
281 hdEdx_Posi_Pbin_AR[ip] = new TH1D(Form("hdEdx_Posi_Pbin_AR%d", ip), Form("hdEdx_Posi_Pbin_AR%d", ip), fnBinsdedx, fnBinsdedxLE,
283 hdEdx_Posi_Pbin_AR[ip]->GetXaxis()->SetTitle("dE/dx distribution (e+)");
284 hdEdx_Posi_Pbin_AR[ip]->GetYaxis()->SetTitle("Entries");
285 hdEdx_Posi_Pbin_AR[ip]->SetTitle(Form("Momentum range %0.03f to %0.03f", ip * 0.250, (ip + 1) * 0.250));
286 fPRdEdxinP->Add(hdEdx_Posi_Pbin_AR[ip]);
287
288 hdEdx_Elec_Pbin_AR[ip] = new TH1D(Form("hdEdx_Elec_Pbin_AR%d", ip), Form("hdEdx_Elec_Pbin_AR%d", ip), fnBinsdedx, fnBinsdedxLE,
290 hdEdx_Elec_Pbin_AR[ip]->GetXaxis()->SetTitle("dE/dx distribution (e-)");
291 hdEdx_Elec_Pbin_AR[ip]->GetYaxis()->SetTitle("Entries");
292 hdEdx_Elec_Pbin_AR[ip]->SetTitle(Form("Momentum range %0.03f to %0.03f", ip * 0.250, (ip + 1) * 0.250));
293
294 }
295
296 for (int ip = 0; ip < 32; ip++) fPRdEdxinP->Add(hdEdx_Elec_Pbin_AR[ip]); //Adding later for simplicity
297
298 hdEdx_PR.reserve(fnRuns);
299 }
300
301 if (fCollType == "hadron") {
302
303 TH2D* hPvsdEdx_hadAR = new TH2D("hPvsdEdx_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
304 hPvsdEdx_hadAR->SetTitle("dE/dx band plot; Momentum;dE/dx");
305 fBasic->Add(hPvsdEdx_hadAR);
306
307 TH2D* hPvsdEdxPion_hadAR = new TH2D("hPvsdEdxPion_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
308 hPvsdEdxPion_hadAR->SetTitle("dE/dx band plot (Pion); Momentum;dE/dx");
309 hPvsdEdxPion_hadAR->SetMarkerColor(kRed);
310 fBasic->Add(hPvsdEdxPion_hadAR);
311
312 TH2D* hPvsdEdxKaon_hadAR = new TH2D("hPvsdEdxKaon_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
313 hPvsdEdxKaon_hadAR->SetTitle("dE/dx band plot (Kaon); Momentum;dE/dx");
314 hPvsdEdxKaon_hadAR->SetMarkerColor(kGreen);
315 fBasic->Add(hPvsdEdxKaon_hadAR);
316
317 TH2D* hPvsdEdxProton_hadAR = new TH2D("hPvsdEdxProton_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
318 hPvsdEdxProton_hadAR->SetTitle("dE/dx band plot (Proton); Momentum;dE/dx");
319 hPvsdEdxKaon_hadAR->SetMarkerColor(kBlue);
320 fBasic->Add(hPvsdEdxProton_hadAR);
321
322 //Pions chi values
323 TH1D* hPionChiallP = new TH1D("hPionChiallP", "bla-bla", 240, -6.0, 6.0);
324 hPionChiallP->SetTitle("Chi value (Pion);chi value; Entries");
325 fBasic->Add(hPionChiallP);
326
327 TH1D* hPionChiLowP = new TH1D("hPionChiLowP", "bla-bla", 240, -6.0, 6.0);
328 hPionChiLowP->SetTitle("Chi value (Pion), Momentum (0-300) MeV; chi value; Entries");
329 fBasic->Add(hPionChiLowP);
330
331 TH1D* hPionChiHighP = new TH1D("hPionChiHighP", "bla-bla", 240, -6.0, 6.0);
332 hPionChiHighP->SetTitle("Chi value (Pion), Momentum (300-400) MeV; chi value; Entries");
333 fBasic->Add(hPionChiHighP);
334
335 //Kaons chi values
336 TH1D* hKaonChiallP = new TH1D("hKaonChiallP", "bla-bla", 240, -6.0, 6.0);
337 hKaonChiallP->SetTitle("Chi value (Kaon);chi value; Entries");
338 fBasic->Add(hKaonChiallP);
339
340 TH1D* hKaonChiLowP = new TH1D("hKaonChiLowP", "bla-bla", 240, -6.0, 6.0);
341 hKaonChiLowP->SetTitle("Chi value (Kaon), Momentum (0-350) MeV; chi value; Entries");
342 fBasic->Add(hKaonChiLowP);
343
344 TH1D* hKaonChiHighP = new TH1D("hKaonChiHighP", "bla-bla", 240, -6.0, 6.0);
345 hKaonChiHighP->SetTitle("Chi value (Kaon), Momentum (350-800) MeV; chi value; Entries");
346 fBasic->Add(hKaonChiHighP);
347
348 //Protons chi values
349 TH1D* hProtonChiallP = new TH1D("hProtonChiallP", "bla-bla", 240, -6.0, 6.0);
350 hProtonChiallP->SetTitle("Chi value (Proton);chi value; Entries");
351 fBasic->Add(hProtonChiallP);
352
353 TH1D* hProtonChiLowP = new TH1D("hProtonChiLowP", "bla-bla", 240, -6.0, 6.0);
354 hProtonChiLowP->SetTitle("Chi value (Proton), Momentum (0-600) MeV; chi value; Entries");
355 fBasic->Add(hProtonChiLowP);
356
357 TH1D* hProtonChiHighP = new TH1D("hProtonChiHighP", "bla-bla", 240, -6.0, 6.0);
358 hProtonChiHighP->SetTitle("Chi value (Proton), Momentum (600-800) MeV; chi value; Entries");
359 fBasic->Add(hProtonChiHighP);
360 }
361 } else if (level == "PR") {
362 if (fCollType != "hadron") {
363 hdEdx_PR[iR] = new TH1D(Form("hdEdx_Run%d", fCurrentRunNum), Form("dE/dx (no had sat): Run # = %d", fCurrentRunNum), fnBinsdedx,
365 hdEdx_PR[iR]->GetXaxis()->SetTitle(Form("dE/dx trucMean of %s tracks", fCollType.data()));
366 hdEdx_PR[iR]->GetYaxis()->SetTitle("Entries");
367 fPRdEdx->Add(hdEdx_PR[iR]);
368 }
369 } else {
370 B2ERROR("Run Gain: Enter AR or PR mode only");
371 }
372}
373
374
375//-----------------------------------------------------------------------
377{
378
379 if (level == "PR") {
380
381 Double_t mean = 0., meanError = 0.;
382 Double_t sigma = 0., sigmaError = 0.;
383
384 if (hdEdx_PR[fiRun]->GetEntries() > 100) {
385 Int_t fitStatus = -1;
386 fitStatus = hdEdx_PR[fiRun]->Fit("gaus", "Q"); //Q = No printing
387 if (fitStatus == 0) {
388 TF1* fit = (TF1*)hdEdx_PR[fiRun]->GetFunction("gaus");
389 mean = fit->GetParameter(1);
390 meanError = fit->GetParError(1);
391 sigma = fit->GetParameter(2);
392 sigmaError = fit->GetParError(2);
393 hdEdx_PR[fiRun]->GetXaxis()->SetRangeUser(mean - 7 * sigma, mean + 7 * sigma);
394 fit->Clear();
395 }
396 }
397
398 TotRunN.push_back(fCurrentRunNum);
399 TotMean.push_back(mean);
400 TotMeanE.push_back(meanError);
401 TotSigma.push_back(sigma);
402 TotSigmaE.push_back(sigmaError);
403
404 if (fiRun % 10 == 0)((TH1D*)fBasic->FindObject("hRunGainPR"))->GetXaxis()->SetBinLabel(fiRun + 1, Form("%d", TotRunN.at(fiRun)));
405 ((TH1D*)fBasic->FindObject("hRunGainPR"))->SetBinContent(fiRun + 1, fcRunGain);
406 ((TH1D*)fBasic->FindObject("hRunGainPR"))->SetBinError(fiRun + 1, 0.001 * fcRunGain); // no meaning but histogramming only
407
408 } else if (level == "AR") {
409
410 const Int_t allNRun = TotMean.size();
411 ((TH1D*)fBasic->FindObject("hRunGainPR"))->GetXaxis()->SetRange(1, allNRun);
412
413 TH1D* hFitdEdxMeanPR = new TH1D("hFitdEdxMeanPR", "dE/dx(nohad-sat) #mu via fit vs. Runs", allNRun, 0, allNRun);
414 hFitdEdxMeanPR->GetYaxis()->SetRangeUser(0.90, 1.10);
415 hFitdEdxMeanPR->SetMarkerStyle(21);
416 hFitdEdxMeanPR->SetMarkerColor(kRed);
417 hFitdEdxMeanPR->SetMarkerSize(1);
418 hFitdEdxMeanPR->GetXaxis()->SetTitle("Run numbers");
419 hFitdEdxMeanPR->GetYaxis()->SetTitle("dEdx mean (fit)");
420 hFitdEdxMeanPR->GetXaxis()->LabelsOption("v");
421
422 TH1D* hFitdEdxSigmaPR = new TH1D("hFitdEdxSigmaPR", "dE/dx(nohad-sat) #sigma via fit vs. Runs", allNRun, 0, allNRun);
423 hFitdEdxSigmaPR->GetYaxis()->SetRangeUser(0, 0.30);
424 hFitdEdxSigmaPR->SetMarkerStyle(21);
425 hFitdEdxSigmaPR->SetMarkerColor(kRed);
426 hFitdEdxSigmaPR->SetMarkerSize(1);
427 hFitdEdxSigmaPR->GetXaxis()->SetTitle("Run numbers");
428 hFitdEdxSigmaPR->GetYaxis()->SetTitle("dEdx sigma (fit)");
429 hFitdEdxSigmaPR->GetXaxis()->LabelsOption("v");
430
431 for (Int_t i = 0; i < allNRun; i++) {
432
433 if (i % 10 == 0)hFitdEdxMeanPR->GetXaxis()->SetBinLabel(i + 1, Form("%d", TotRunN.at(i)));
434 hFitdEdxMeanPR->SetBinContent(i + 1, TotMean.at(i));
435 hFitdEdxMeanPR->SetBinError(i + 1, TotMeanE.at(i));
436
437 if (i % 10 == 0)hFitdEdxSigmaPR->GetXaxis()->SetBinLabel(i + 1, Form("%d", TotRunN.at(i)));
438 hFitdEdxSigmaPR->SetBinContent(i + 1, TotSigma.at(i));
439 hFitdEdxSigmaPR->SetBinError(i + 1, TotSigmaE.at(i));
440 }
441
442 fBasic->Add(hFitdEdxMeanPR);
443 fBasic->Add(hFitdEdxSigmaPR);
444
445 TH1D* hdEdxFit_allRun = (TH1D*)(fBasic->FindObject(Form("hdEdx_AR"))->Clone("hdEdxFit_allRun"));
446 if (hdEdxFit_allRun->GetEntries() > 100) {
447 hdEdxFit_allRun->Fit("gaus", "Q");
448 TF1* hGfit = (TF1*)hdEdxFit_allRun->GetFunction("gaus");
449 Double_t meanGFit = hGfit->GetParameter(1);
450 Double_t sigmaGFit = hGfit->GetParameter(2);
451 hdEdxFit_allRun->GetXaxis()->SetRangeUser(meanGFit - 7 * sigmaGFit, meanGFit + 7 * sigmaGFit);
452 hdEdxFit_allRun->SetFillColor(kYellow);
453 hdEdxFit_allRun->SetStats(kTRUE);
454 fBasic->Add(hdEdxFit_allRun);
455 }
456
457 TH1D* hdEdxMeanVsMomentum = new TH1D("hdEdxMeanVsMomentum", "dEdx-mean vs P bins (BW = 250MeV)", 64, -8.0, 8.0);
458 hdEdxMeanVsMomentum->GetXaxis()->SetTitle("Track Momentum");
459 hdEdxMeanVsMomentum->GetYaxis()->SetTitle("dEdx Mean");
460
461 TH1D* hdEdxSigmaVsMomentum = new TH1D("hdEdxSigmaVsMomentum", "dEdx-sigma vs P bins (BW = 250MeV)", 64, -8.0, 8.0);
462 hdEdxSigmaVsMomentum->GetXaxis()->SetTitle("Track Momentum");
463 hdEdxSigmaVsMomentum->GetYaxis()->SetTitle("dEdx Sigma");
464
465 for (int ip = 0; ip < 32; ip++) {
466 Int_t nTrack = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->GetEntries();
467 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->SetFillColor(kYellow);
468 Double_t iPMean = 1.0, iPSigma = 0.0;
469 if (nTrack > 100) {
470 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->Fit("gaus", "0");
471 iPMean = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->GetFunction("gaus")->GetParameter(1);
472 iPSigma = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->GetFunction("gaus")->GetParameter(2);
473 }
474 hdEdxMeanVsMomentum->SetBinContent(32 + ip + 1, iPMean);
475 hdEdxSigmaVsMomentum->SetBinContent(32 + ip + 1, iPSigma);
476 }
477
478 for (int ip = 0; ip < 32; ip++) {
479 Int_t nTrack = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip)))->GetEntries();
480 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip)))->SetFillColor(kYellow);
481 Double_t iPMean = 1.0, iPSigma = 0.0;
482
483 if (nTrack > 100) {
484 ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip)))->Fit("gaus", "0");
485 iPMean = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip)))->GetFunction("gaus")->GetParameter(1);
486 iPSigma = ((TH1D*)fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip)))->GetFunction("gaus")->GetParameter(2);
487 }
488 hdEdxMeanVsMomentum->SetBinContent(32 - ip, iPMean);
489 hdEdxSigmaVsMomentum->SetBinContent(32 - ip, iPSigma);
490 }
491
492 fBasic->Add(hdEdxSigmaVsMomentum);
493 fBasic->Add(hdEdxMeanVsMomentum);
494 } else {
495 B2ERROR("RunGain >> NO-REQUEST-FOUND for PR or AR level plots, exiting..");
496 }
497}
498
499//-----------------------------------------
501{
502
503 B2INFO("Terminating plots for all runs ");
504 fFileOutput = new TFile(Form("fvalidate%s", fOutFileName.data()), "RECREATE");
505 if (fCollType != "hadron")ExtractHistograms("AR");
506 fFileOutput->cd();
507 fBasic->Write("ARBasics", 1);
508 if (fCollType == "radbhabha" or fCollType == "bhabha") {
509 fPRdEdx->Write("PRdedx", 1);
510 fPRdEdxinP->Write("MeanSigmavsP", 1);
511 }
512 fFileOutput->Close();
513}
514
515//-----------------------------------------
517{
518
519 if (std::abs(mTrack->getD0()) >= fD0Window || std::abs(mTrack->getZ0()) >= fZ0Window)return kFALSE;
520 return kTRUE;
521
522}
double R
typedef autogenerated by FFTW
Debug output for CDCDedxPID module.
double getDedx() const
Get dE/dx truncated mean for this track.
int getNLayerHits() const
Return the number of layer hits for this track.
double getCosTheta() const
Return cos(theta) for this track.
double getRunGain() const
Return the run gain for this track.
double getChi(int i) const
Return the PID (chi) value.
double getDedxNoSat() const
Get dE/dx truncated mean without the saturation correction for this track.
double getMomentum() const
Return the track momentum valid in the CDC.
std::vector< Double_t > TotMean
Mean of dedx by Fit.
Double_t fnBinsdedxUE
up edge of dedx
void FillHistograms(CDCDedxTrack *dedxTrack, const TrackFitResult *mTrack)
Filling histograms This will fill histogram defined histograms in above function.
TFile * fFileOutput
Write final objects to file for RG.
std::string fOutFileName
name of output ROOT file
Double_t fcRunGain
existing run gain
Int_t fCurrentRunNum
current run number
Int_t fnRunCounter
Total runs used counter.
TList * fBasic
List of basic histos.
virtual void initialize() override
Initialize This is inherited from base class.
std::vector< TH1D * > hdEdx_PR
histogram array per run
virtual void event() override
function to execute event (event by event) This is inherited from base class
std::vector< Double_t > TotSigma
Sigma of dedx by Fit.
CDCDedxValidationModule()
Default constructor contain list of members with initial values.
TList * fPRdEdxinP
list per run dedx in P histos
Double_t fTrkEoverP
E/p ratio for cut.
virtual void endRun() override
function is called after each event This is inherited from base class
std::vector< Int_t > TotRunN
veector array of runs processed
virtual void terminate() override
Terminate after all data processed This is inherited from base class.
std::vector< Double_t > TotSigmaE
Sigma Error of dedx by Fit.
std::vector< Double_t > TotMeanE
Mean Error of dedx by Fit.
virtual void beginRun() override
Function to execute each run This is inherited from base class.
StoreArray< CDCDedxTrack > m_cdcDedxTracks
Data members for objects, cuts and others.
Double_t fnBinsdedxLE
low edge of dedx
TList * fPRdEdx
List of per run dedx histos.
void ExtractHistograms(TString level)
Extracting histogram and some calculation Higher level histograms are filled after each run or full p...
void DefineHistograms(TString level, Int_t iR)
Definition of histograms This contain a list of histogram for validation.
Int_t fnRuns
Number of runs ref.
Int_t fiRun
Current run number.
Int_t fnBinsdedx
nbin of dedx range
std::string fCollType
collision type
Bool_t IsSelectedTrack(const TrackFitResult *mTrack)
Track selection A clean way to implement selections on tracks (so far few only)
static const ChargedStable pion
charged pion particle
Definition Const.h:661
static const ChargedStable electron
electron particle
Definition Const.h:659
ECL cluster data.
Definition ECLCluster.h:27
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
Definition ECLCluster.h:351
double getEnergy(EHypothesisBit hypothesis) const
Return Energy (GeV).
Definition ECLCluster.cc:23
@ c_nPhotons
CR is split into n photons (N1)
Definition ECLCluster.h:41
HistoModule()
Constructor.
Definition HistoModule.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Values of the result of a track fit with a given particle hypothesis.
double getPhi() const
Getter for phi0 with CDF naming convention.
short getChargeSign() const
Return track charge (1 or -1).
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
Definition Track.h:25
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.