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 (static_cast<TH1D*>(fBasic->FindObject("hTrkPerEvtStats")))->Fill(0.0);
86 continue;
87 }
88
89 const Track* track = dedxTrack->getRelatedFrom<Track>();
90 if (!track) {
91 (static_cast<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 (static_cast<TH1D*>(fBasic->FindObject("hTrkPerEvtStats")))->Fill(2.0);
103 continue;
104 }
105
106 bool IsTrkSelected = IsSelectedTrack(mTrack);
107 if (!IsTrkSelected) {
108 (static_cast<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 (static_cast<TH1D*>(fBasic->FindObject(Form("hEOverP_AR"))))->Fill(double(fTrkEoverP));
120 }
121 } else {
122 (static_cast<TH1D*>(fBasic->FindObject("hTrkPerEvtStats")))->Fill(4.0);
123 continue;
124
125 }
126
127 (static_cast<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 (static_cast<TH1D*>(fBasic->FindObject(Form("hP_Positron_AR"))))->Fill(TrkMom);
152 (static_cast<TH1D*>(fBasic->FindObject(Form("hdEdx_Positron_AR"))))->Fill(TrkdEdxnosat);
153 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", iMomBin))))->Fill(TrkdEdxnosat);
154 } else if (TrkCharge < 0) {
155 (static_cast<TH1D*>(fBasic->FindObject(Form("hP_Electron_AR"))))->Fill(TrkMom);
156 (static_cast<TH1D*>(fBasic->FindObject(Form("hdEdx_Electron_AR"))))->Fill(TrkdEdxnosat);
157 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", iMomBin))))->Fill(TrkdEdxnosat);
158 }
159
160 (static_cast<TH1D*>(fBasic->FindObject(Form("hdEdx_AR"))))->Fill(double(TrkdEdxnosat));
161 (static_cast<TH2D*>(fBasic->FindObject(Form("hdEdxvsPhi_AR"))))->Fill(double(mTrack->getPhi()), double(TrkdEdxnosat));
162 (static_cast<TH2D*>(fBasic->FindObject(Form("hPvsdEdx_AR"))))->Fill(TrkMom * TrkCharge, double(TrkdEdxnosat));
163 (static_cast<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 // cppcheck-suppress variableScope ; kept next to the related declarations for readability
172 double ChiPi = dedxTrack->getChi(2);
173 // cppcheck-suppress variableScope ; kept next to the related declarations for readability
174 double ChiK = dedxTrack->getChi(3);
175 // cppcheck-suppress variableScope ; kept next to the related declarations for readability
176 double ChiP = dedxTrack->getChi(4);
177 // double ChiD = dedxTrack->getChi(5);
178
179 (static_cast<TH2D*>(fBasic->FindObject(Form("hPvsdEdx_hadAR"))))->Fill(TrkMom, TrkdEdx);
180
181 if ((TrkMom < 0.40) && (fTrkEoverP < 0.4) && (TrkdEdx < (0.6 + 0.10 / (TrkMom * TrkMom)))
182 && (TrkdEdx > (0.4 + 0.012 / (TrkMom * TrkMom)))) {
183 (static_cast<TH1D*>(fBasic->FindObject(Form("hPionChiallP"))))->Fill(ChiPi);
184 if (TrkMom < 0.300)(static_cast<TH1D*>(fBasic->FindObject(Form("hPionChiLowP"))))->Fill(ChiPi);
185 else (static_cast<TH1D*>(fBasic->FindObject(Form("hPionChiHighP"))))->Fill(ChiPi);
186 (static_cast<TH2D*>(fBasic->FindObject(Form("hPvsdEdxPion_hadAR"))))->Fill(TrkMom, TrkdEdx);
187 }
188
189 if ((TrkMom < 0.40) && (TrkdEdx > 1.35) && (TrkdEdx < (0.6 + 0.40 / (TrkMom * TrkMom)))
190 && (TrkdEdx > (0.6 + 0.10 / (TrkMom * TrkMom)))) {
191 (static_cast<TH1D*>(fBasic->FindObject(Form("hKaonChiallP"))))->Fill(ChiK);
192 if (TrkMom < 0.350)(static_cast<TH1D*>(fBasic->FindObject(Form("hKaonChiLowP"))))->Fill(ChiK);
193 else (static_cast<TH1D*>(fBasic->FindObject(Form("hKaonChiHighP"))))->Fill(ChiK);
194 (static_cast<TH2D*>(fBasic->FindObject(Form("hPvsdEdxKaon_hadAR"))))->Fill(TrkMom, TrkdEdx);
195 }
196
197 if ((TrkMom < 0.80) && (TrkdEdx > 1.35) && (TrkdEdx < (0.6 + 1.20 / (TrkMom * TrkMom)))
198 && (TrkdEdx > (0.6 + 0.40 / (TrkMom * TrkMom)))) {
199 (static_cast<TH1D*>(fBasic->FindObject(Form("hProtonChiallP"))))->Fill(ChiP);
200 if (TrkMom < 0.600)(static_cast<TH1D*>(fBasic->FindObject(Form("hProtonChiLowP"))))->Fill(ChiP);
201 else (static_cast<TH1D*>(fBasic->FindObject(Form("hProtonChiHighP"))))->Fill(ChiP);
202 (static_cast<TH2D*>(fBasic->FindObject(Form("hPvsdEdxProton_hadAR"))))->Fill(TrkMom, TrkdEdx);
203 }
204 }
205
206}
207
208
209
210//----------------------------------
212{
213 if (fCollType != "hadron")ExtractHistograms("PR");
214}
215
216
217//----------------------------------------------------------------------------------
218void CDCDedxValidationModule::DefineHistograms(TString level = "XR", Int_t iR = 123)
219{
220 if (level == "AR") {
221
222 TH1D* hTrkPerEvtStats = new TH1D("hTrkPerEvtStats", "Track selections", 6, -0.5, 5.5);
223 hTrkPerEvtStats->GetXaxis()->SetBinLabel(1, "no dedxobject");
224 hTrkPerEvtStats->GetXaxis()->SetBinLabel(2, "no assoc-track");
225 hTrkPerEvtStats->GetXaxis()->SetBinLabel(3, "no TrackFit");
226 hTrkPerEvtStats->GetXaxis()->SetBinLabel(4, "no pass cuts");
227 hTrkPerEvtStats->GetXaxis()->SetBinLabel(5, "no eclCluster");
228 hTrkPerEvtStats->GetXaxis()->SetBinLabel(6, "Selected");
229 hTrkPerEvtStats->SetFillColor(kRed);
230 hTrkPerEvtStats->SetFillStyle(3015);
231 hTrkPerEvtStats->SetMinimum(0);
232 fBasic->Add(hTrkPerEvtStats);
233
234 if (fCollType == "radbhabha" or fCollType == "bhabha") {
235
236 TH1D* hdEdx_AR = new TH1D("hdEdx_AR", "dE/dx (nohad sat)", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
237 hdEdx_AR->GetXaxis()->SetTitle(Form("dE/dx truncMean of %s tracks", fCollType.data()));
238 hdEdx_AR->GetYaxis()->SetTitle("Entries");
239 fBasic->Add(hdEdx_AR);
240
241 TH1D* hEOverP_AR = new TH1D("hEOverP_AR", "E/p distribution", 100, 0.5, 1.5);
242 hEOverP_AR->GetXaxis()->SetTitle("E/p distribution");
243 hEOverP_AR->GetYaxis()->SetTitle("Entries");
244 fBasic->Add(hEOverP_AR);
245
246 TH1D* hRunGainPR = new TH1D("hRunGainPR", "bla-bla", fnRuns, -0.5, fnRuns - 0.5);
247 hRunGainPR->SetTitle("Run gain variation vs. RunNumber;Run Numbers;dE/dx mean");
248 hRunGainPR->GetYaxis()->SetRangeUser(0.85, 1.15);
249 fBasic->Add(hRunGainPR);
250
251 TH1D* hP_Electron_AR = new TH1D("hP_Electron_AR", "bla-bla", 320, 0.0, 8.0);
252 hP_Electron_AR->SetTitle("Momentum distribution of e-; Momentum of (e-); Entries");
253 fBasic->Add(hP_Electron_AR);
254
255 TH1D* hP_Positron_AR = new TH1D("hP_Positron_AR", "bla-bla", 320, 0.0, 8.0);
256 hP_Positron_AR->SetTitle("Momentum distribution of e+;Momentum of (e+);Entries");
257 fBasic->Add(hP_Positron_AR);
258
259 TH1D* hdEdx_Electron_AR = new TH1D("hdEdx_Electron_AR", "bla-bla", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
260 hdEdx_Electron_AR->SetTitle("dE/dx (nohad sat) of e- ;dE/dx distribution (e-);Entries");
261 fBasic->Add(hdEdx_Electron_AR);
262
263 TH1D* hdEdx_Positron_AR = new TH1D("hdEdx_Positron_AR", "bla-bla", fnBinsdedx, fnBinsdedxLE, fnBinsdedxUE);
264 hdEdx_Positron_AR->SetTitle("dE/dx (nohad sat) of e+;dE/dx distribution (e+);Entries");
265 fBasic->Add(hdEdx_Positron_AR);
266
267 TH2D* hPvsdEdx_AR = new TH2D("hPvsdEdx_AR", "bla-bla", 320, -8.0, 8.0, 100, 0.0, 2.0);
268 hPvsdEdx_AR->SetTitle("dE/dx band plots for e+ and e-; Momentum of (e+(right)) and e-);dE/dx");
269 fBasic->Add(hPvsdEdx_AR);
270
271 TH2D* hdEdxvsPhi_AR = new TH2D("hdEdxvsPhi_AR", "dE/dx (no had sat) vs #phi", 64, -3.14, 3.14, 200, 0., 2.0);
272 hdEdxvsPhi_AR->SetTitle("dE/dx (no Had Sat) vs #phi;track #phi;dE/dx");
273 fBasic->Add(hdEdxvsPhi_AR);
274
275 TH2D* hPvsCosth_AR = new TH2D("hPvsCosth_AR", "cos(#theta) vs. p: all Runs", 2 * 48, -10., 10., 60, -1.2, 1.2);
276 hPvsCosth_AR->GetXaxis()->SetTitle(Form("Momentum of %s tracks", fCollType.data()));
277 hPvsCosth_AR->GetYaxis()->SetTitle("cos(#theta)");
278 fBasic->Add(hPvsCosth_AR);
279
280
281 TH1D* hdEdx_Posi_Pbin_AR[32], *hdEdx_Elec_Pbin_AR[32];
282 for (int ip = 0; ip < 32; ip++) {
283
284 hdEdx_Posi_Pbin_AR[ip] = new TH1D(Form("hdEdx_Posi_Pbin_AR%d", ip), Form("hdEdx_Posi_Pbin_AR%d", ip), fnBinsdedx, fnBinsdedxLE,
286 hdEdx_Posi_Pbin_AR[ip]->GetXaxis()->SetTitle("dE/dx distribution (e+)");
287 hdEdx_Posi_Pbin_AR[ip]->GetYaxis()->SetTitle("Entries");
288 hdEdx_Posi_Pbin_AR[ip]->SetTitle(Form("Momentum range %0.03f to %0.03f", ip * 0.250, (ip + 1) * 0.250));
289 fPRdEdxinP->Add(hdEdx_Posi_Pbin_AR[ip]);
290
291 hdEdx_Elec_Pbin_AR[ip] = new TH1D(Form("hdEdx_Elec_Pbin_AR%d", ip), Form("hdEdx_Elec_Pbin_AR%d", ip), fnBinsdedx, fnBinsdedxLE,
293 hdEdx_Elec_Pbin_AR[ip]->GetXaxis()->SetTitle("dE/dx distribution (e-)");
294 hdEdx_Elec_Pbin_AR[ip]->GetYaxis()->SetTitle("Entries");
295 hdEdx_Elec_Pbin_AR[ip]->SetTitle(Form("Momentum range %0.03f to %0.03f", ip * 0.250, (ip + 1) * 0.250));
296
297 }
298
299 for (int ip = 0; ip < 32; ip++) fPRdEdxinP->Add(hdEdx_Elec_Pbin_AR[ip]); //Adding later for simplicity
300
301 hdEdx_PR.reserve(fnRuns);
302 }
303
304 if (fCollType == "hadron") {
305
306 TH2D* hPvsdEdx_hadAR = new TH2D("hPvsdEdx_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
307 hPvsdEdx_hadAR->SetTitle("dE/dx band plot; Momentum;dE/dx");
308 fBasic->Add(hPvsdEdx_hadAR);
309
310 TH2D* hPvsdEdxPion_hadAR = new TH2D("hPvsdEdxPion_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
311 hPvsdEdxPion_hadAR->SetTitle("dE/dx band plot (Pion); Momentum;dE/dx");
312 hPvsdEdxPion_hadAR->SetMarkerColor(kRed);
313 fBasic->Add(hPvsdEdxPion_hadAR);
314
315 TH2D* hPvsdEdxKaon_hadAR = new TH2D("hPvsdEdxKaon_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
316 hPvsdEdxKaon_hadAR->SetTitle("dE/dx band plot (Kaon); Momentum;dE/dx");
317 hPvsdEdxKaon_hadAR->SetMarkerColor(kGreen);
318 fBasic->Add(hPvsdEdxKaon_hadAR);
319
320 TH2D* hPvsdEdxProton_hadAR = new TH2D("hPvsdEdxProton_hadAR", "bla-bla", 500, 0.10, 15.0, 750, 0.05, 15);
321 hPvsdEdxProton_hadAR->SetTitle("dE/dx band plot (Proton); Momentum;dE/dx");
322 hPvsdEdxKaon_hadAR->SetMarkerColor(kBlue);
323 fBasic->Add(hPvsdEdxProton_hadAR);
324
325 //Pions chi values
326 TH1D* hPionChiallP = new TH1D("hPionChiallP", "bla-bla", 240, -6.0, 6.0);
327 hPionChiallP->SetTitle("Chi value (Pion);chi value; Entries");
328 fBasic->Add(hPionChiallP);
329
330 TH1D* hPionChiLowP = new TH1D("hPionChiLowP", "bla-bla", 240, -6.0, 6.0);
331 hPionChiLowP->SetTitle("Chi value (Pion), Momentum (0-300) MeV; chi value; Entries");
332 fBasic->Add(hPionChiLowP);
333
334 TH1D* hPionChiHighP = new TH1D("hPionChiHighP", "bla-bla", 240, -6.0, 6.0);
335 hPionChiHighP->SetTitle("Chi value (Pion), Momentum (300-400) MeV; chi value; Entries");
336 fBasic->Add(hPionChiHighP);
337
338 //Kaons chi values
339 TH1D* hKaonChiallP = new TH1D("hKaonChiallP", "bla-bla", 240, -6.0, 6.0);
340 hKaonChiallP->SetTitle("Chi value (Kaon);chi value; Entries");
341 fBasic->Add(hKaonChiallP);
342
343 TH1D* hKaonChiLowP = new TH1D("hKaonChiLowP", "bla-bla", 240, -6.0, 6.0);
344 hKaonChiLowP->SetTitle("Chi value (Kaon), Momentum (0-350) MeV; chi value; Entries");
345 fBasic->Add(hKaonChiLowP);
346
347 TH1D* hKaonChiHighP = new TH1D("hKaonChiHighP", "bla-bla", 240, -6.0, 6.0);
348 hKaonChiHighP->SetTitle("Chi value (Kaon), Momentum (350-800) MeV; chi value; Entries");
349 fBasic->Add(hKaonChiHighP);
350
351 //Protons chi values
352 TH1D* hProtonChiallP = new TH1D("hProtonChiallP", "bla-bla", 240, -6.0, 6.0);
353 hProtonChiallP->SetTitle("Chi value (Proton);chi value; Entries");
354 fBasic->Add(hProtonChiallP);
355
356 TH1D* hProtonChiLowP = new TH1D("hProtonChiLowP", "bla-bla", 240, -6.0, 6.0);
357 hProtonChiLowP->SetTitle("Chi value (Proton), Momentum (0-600) MeV; chi value; Entries");
358 fBasic->Add(hProtonChiLowP);
359
360 TH1D* hProtonChiHighP = new TH1D("hProtonChiHighP", "bla-bla", 240, -6.0, 6.0);
361 hProtonChiHighP->SetTitle("Chi value (Proton), Momentum (600-800) MeV; chi value; Entries");
362 fBasic->Add(hProtonChiHighP);
363 }
364 } else if (level == "PR") {
365 if (fCollType != "hadron") {
366 hdEdx_PR[iR] = new TH1D(Form("hdEdx_Run%d", fCurrentRunNum), Form("dE/dx (no had sat): Run # = %d", fCurrentRunNum), fnBinsdedx,
368 hdEdx_PR[iR]->GetXaxis()->SetTitle(Form("dE/dx trucMean of %s tracks", fCollType.data()));
369 hdEdx_PR[iR]->GetYaxis()->SetTitle("Entries");
370 fPRdEdx->Add(hdEdx_PR[iR]);
371 }
372 } else {
373 B2ERROR("Run Gain: Enter AR or PR mode only");
374 }
375}
376
377
378//-----------------------------------------------------------------------
380{
381
382 if (level == "PR") {
383
384 Double_t mean = 0., meanError = 0.;
385 Double_t sigma = 0., sigmaError = 0.;
386
387 if (hdEdx_PR[fiRun]->GetEntries() > 100) {
388 Int_t fitStatus = -1;
389 fitStatus = hdEdx_PR[fiRun]->Fit("gaus", "Q"); //Q = No printing
390 if (fitStatus == 0) {
391 TF1* fit = static_cast<TF1*>(hdEdx_PR[fiRun]->GetFunction("gaus"));
392 mean = fit->GetParameter(1);
393 meanError = fit->GetParError(1);
394 sigma = fit->GetParameter(2);
395 sigmaError = fit->GetParError(2);
396 hdEdx_PR[fiRun]->GetXaxis()->SetRangeUser(mean - 7 * sigma, mean + 7 * sigma);
397 fit->Clear();
398 }
399 }
400
401 TotRunN.push_back(fCurrentRunNum);
402 TotMean.push_back(mean);
403 TotMeanE.push_back(meanError);
404 TotSigma.push_back(sigma);
405 TotSigmaE.push_back(sigmaError);
406
407 if (fiRun % 10 == 0)(static_cast<TH1D*>(fBasic->FindObject("hRunGainPR")))->GetXaxis()->SetBinLabel(fiRun + 1, Form("%d",
408 TotRunN.at(fiRun)));
409 (static_cast<TH1D*>(fBasic->FindObject("hRunGainPR")))->SetBinContent(fiRun + 1, fcRunGain);
410 (static_cast<TH1D*>(fBasic->FindObject("hRunGainPR")))->SetBinError(fiRun + 1,
411 0.001 * fcRunGain); // no meaning but histogramming only
412
413 } else if (level == "AR") {
414
415 const Int_t allNRun = TotMean.size();
416 (static_cast<TH1D*>(fBasic->FindObject("hRunGainPR")))->GetXaxis()->SetRange(1, allNRun);
417
418 TH1D* hFitdEdxMeanPR = new TH1D("hFitdEdxMeanPR", "dE/dx(nohad-sat) #mu via fit vs. Runs", allNRun, 0, allNRun);
419 hFitdEdxMeanPR->GetYaxis()->SetRangeUser(0.90, 1.10);
420 hFitdEdxMeanPR->SetMarkerStyle(21);
421 hFitdEdxMeanPR->SetMarkerColor(kRed);
422 hFitdEdxMeanPR->SetMarkerSize(1);
423 hFitdEdxMeanPR->GetXaxis()->SetTitle("Run numbers");
424 hFitdEdxMeanPR->GetYaxis()->SetTitle("dEdx mean (fit)");
425 hFitdEdxMeanPR->GetXaxis()->LabelsOption("v");
426
427 TH1D* hFitdEdxSigmaPR = new TH1D("hFitdEdxSigmaPR", "dE/dx(nohad-sat) #sigma via fit vs. Runs", allNRun, 0, allNRun);
428 hFitdEdxSigmaPR->GetYaxis()->SetRangeUser(0, 0.30);
429 hFitdEdxSigmaPR->SetMarkerStyle(21);
430 hFitdEdxSigmaPR->SetMarkerColor(kRed);
431 hFitdEdxSigmaPR->SetMarkerSize(1);
432 hFitdEdxSigmaPR->GetXaxis()->SetTitle("Run numbers");
433 hFitdEdxSigmaPR->GetYaxis()->SetTitle("dEdx sigma (fit)");
434 hFitdEdxSigmaPR->GetXaxis()->LabelsOption("v");
435
436 for (Int_t i = 0; i < allNRun; i++) {
437
438 if (i % 10 == 0)hFitdEdxMeanPR->GetXaxis()->SetBinLabel(i + 1, Form("%d", TotRunN.at(i)));
439 hFitdEdxMeanPR->SetBinContent(i + 1, TotMean.at(i));
440 hFitdEdxMeanPR->SetBinError(i + 1, TotMeanE.at(i));
441
442 if (i % 10 == 0)hFitdEdxSigmaPR->GetXaxis()->SetBinLabel(i + 1, Form("%d", TotRunN.at(i)));
443 hFitdEdxSigmaPR->SetBinContent(i + 1, TotSigma.at(i));
444 hFitdEdxSigmaPR->SetBinError(i + 1, TotSigmaE.at(i));
445 }
446
447 fBasic->Add(hFitdEdxMeanPR);
448 fBasic->Add(hFitdEdxSigmaPR);
449
450 TH1D* hdEdxFit_allRun = static_cast<TH1D*>((fBasic->FindObject(Form("hdEdx_AR"))->Clone("hdEdxFit_allRun")));
451 if (hdEdxFit_allRun->GetEntries() > 100) {
452 hdEdxFit_allRun->Fit("gaus", "Q");
453 TF1* hGfit = static_cast<TF1*>(hdEdxFit_allRun->GetFunction("gaus"));
454 Double_t meanGFit = hGfit->GetParameter(1);
455 Double_t sigmaGFit = hGfit->GetParameter(2);
456 hdEdxFit_allRun->GetXaxis()->SetRangeUser(meanGFit - 7 * sigmaGFit, meanGFit + 7 * sigmaGFit);
457 hdEdxFit_allRun->SetFillColor(kYellow);
458 hdEdxFit_allRun->SetStats(kTRUE);
459 fBasic->Add(hdEdxFit_allRun);
460 }
461
462 TH1D* hdEdxMeanVsMomentum = new TH1D("hdEdxMeanVsMomentum", "dEdx-mean vs P bins (BW = 250MeV)", 64, -8.0, 8.0);
463 hdEdxMeanVsMomentum->GetXaxis()->SetTitle("Track Momentum");
464 hdEdxMeanVsMomentum->GetYaxis()->SetTitle("dEdx Mean");
465
466 TH1D* hdEdxSigmaVsMomentum = new TH1D("hdEdxSigmaVsMomentum", "dEdx-sigma vs P bins (BW = 250MeV)", 64, -8.0, 8.0);
467 hdEdxSigmaVsMomentum->GetXaxis()->SetTitle("Track Momentum");
468 hdEdxSigmaVsMomentum->GetYaxis()->SetTitle("dEdx Sigma");
469
470 for (int ip = 0; ip < 32; ip++) {
471 Int_t nTrack = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->GetEntries();
472 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->SetFillColor(kYellow);
473 Double_t iPMean = 1.0, iPSigma = 0.0;
474 if (nTrack > 100) {
475 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->Fit("gaus", "0");
476 iPMean = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->GetFunction("gaus")->GetParameter(1);
477 iPSigma = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->GetFunction("gaus")->GetParameter(2);
478 }
479 hdEdxMeanVsMomentum->SetBinContent(32 + ip + 1, iPMean);
480 hdEdxSigmaVsMomentum->SetBinContent(32 + ip + 1, iPSigma);
481 }
482
483 for (int ip = 0; ip < 32; ip++) {
484 Int_t nTrack = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Posi_Pbin_AR%d", ip))))->GetEntries();
485 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip))))->SetFillColor(kYellow);
486 Double_t iPMean = 1.0, iPSigma = 0.0;
487
488 if (nTrack > 100) {
489 (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip))))->Fit("gaus", "0");
490 iPMean = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip))))->GetFunction("gaus")->GetParameter(1);
491 iPSigma = (static_cast<TH1D*>(fPRdEdxinP->FindObject(Form("hdEdx_Elec_Pbin_AR%d", ip))))->GetFunction("gaus")->GetParameter(2);
492 }
493 hdEdxMeanVsMomentum->SetBinContent(32 - ip, iPMean);
494 hdEdxSigmaVsMomentum->SetBinContent(32 - ip, iPSigma);
495 }
496
497 fBasic->Add(hdEdxSigmaVsMomentum);
498 fBasic->Add(hdEdxMeanVsMomentum);
499 } else {
500 B2ERROR("RunGain >> NO-REQUEST-FOUND for PR or AR level plots, exiting..");
501 }
502}
503
504//-----------------------------------------
506{
507
508 B2INFO("Terminating plots for all runs ");
509 fFileOutput = new TFile(Form("fvalidate%s", fOutFileName.data()), "RECREATE");
510 if (fCollType != "hadron")ExtractHistograms("AR");
511 fFileOutput->cd();
512 fBasic->Write("ARBasics", 1);
513 if (fCollType == "radbhabha" or fCollType == "bhabha") {
514 fPRdEdx->Write("PRdedx", 1);
515 fPRdEdxinP->Write("MeanSigmavsP", 1);
516 }
517 fFileOutput->Close();
518}
519
520//-----------------------------------------
522{
523
524 if (std::abs(mTrack->getD0()) >= fD0Window || std::abs(mTrack->getZ0()) >= fZ0Window)return kFALSE;
525 return kTRUE;
526
527}
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
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
void FillHistograms(const CDCDedxTrack *dedxTrack, const TrackFitResult *mTrack)
Filling histograms This will fill histogram defined histograms in above function.
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:662
static const ChargedStable electron
electron particle
Definition Const.h:660
ECL cluster data.
Definition ECLCluster.h:27
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
Definition ECLCluster.h:360
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.