Belle II Software development
DQMHistoModuleBase.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 <tracking/dqmUtils/DQMHistoModuleBase.h>
10#include <tracking/dqmUtils/HistogramFactory.h>
11
12#include <framework/datastore/StoreArray.h>
13#include <vxd/geometry/GeoTools.h>
14#include <vxd/geometry/SensorInfoBase.h>
15
16#include <TDirectory.h>
17
18using namespace Belle2;
19using namespace Belle2::HistogramFactory;
20using boost::format;
21
22//-----------------------------------------------------------------
23// Implementation
24//-----------------------------------------------------------------
25
27{
29
30 addParam("tracksStoreArrayName", m_tracksStoreArrayName, "StoreArray name where the merged Tracks are written.",
32 addParam("recoTracksStoreArrayName", m_recoTracksStoreArrayName, "StoreArray name where the merged RecoTracks are written.",
34 addParam("histogramParameterChanges", m_histogramParameterChanges, "Changes of default parameters of histograms.",
36}
37
39{
40
41}
42
44{
46 if (!recoTracks.isOptional()) {
47 B2WARNING("Missing recoTracks array, " + getName() + " is skipped.");
48 return;
49 }
50
52 if (!Tracks.isOptional()) {
53 B2WARNING("Missing Tracks array, " + getName() + " is skipped.");
54 return;
55 }
56
57 // Register histograms (calls back defineHisto)
58 REG_HISTOGRAM
59}
60
61//------------------------------------------------------------------
62// Function to define histograms
63//-----------------------------------------------------------------
64
66{
67 histogramsDefined = true;
68}
69
71{
73 if (!recoTracks.isOptional()) {
74 B2DEBUG(22, "Missing recoTracks array in beginRun() for " + getName());
75 return;
76 }
78 if (!tracks.isOptional()) {
79 B2DEBUG(22, "Missing recoTracks array in beginRun() for " + getName());
80 return;
81 }
82
83 for (TH1* histogram : m_histograms)
84 histogram->Reset();
85}
86
87
89{
90 if (!histogramsDefined) {
91 B2ERROR("Histograms not defined in " + this->getName() + " module, event processing is skipped!");
92 return;
93 }
94}
95
96TH1F* DQMHistoModuleBase::Create(std::string name, std::string title, int nbinsx, double xlow, double xup, std::string xTitle,
97 std::string yTitle)
98{
99 TH1F* histogram = new TH1F(name.c_str(), title.c_str(), nbinsx, xlow, xup);
100 histogram->GetXaxis()->SetTitle(xTitle.c_str());
101 histogram->GetYaxis()->SetTitle(yTitle.c_str());
102
103 m_histograms.push_back(histogram);
104
105 return histogram;
106}
107
108TH2F* DQMHistoModuleBase::Create(std::string name, std::string title, int nbinsx, double xlow, double xup, int nbinsy, double ylow,
109 double yup, std::string xTitle, std::string yTitle, std::string zTitle)
110{
111 TH2F* histogram = new TH2F(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
112 histogram->GetXaxis()->SetTitle(xTitle.c_str());
113 histogram->GetYaxis()->SetTitle(yTitle.c_str());
114 histogram->GetZaxis()->SetTitle(zTitle.c_str());
115
116 m_histograms.push_back(histogram);
117
118 return histogram;
119}
120
122{
123 return str(format("%1%_%2%_%3%") % sensorID.getLayerNumber() % sensorID.getLadderNumber() % sensorID.getSensorNumber());
124}
125
127{
128 return str(format("Layer %1% Ladder %2% Sensor %3%") % sensorID.getLayerNumber() % sensorID.getLadderNumber() %
129 sensorID.getSensorNumber());
130}
131
132TH1F** DQMHistoModuleBase::CreateLayers(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
133 double xup, std::string xTitle, std::string yTitle)
134{
136 auto gTools = geo.getGeoTools();
137
138 TH1F** output = new TH1F*[gTools->getNumberOfLayers()];
139
140 for (VxdID layer : geo.getLayers()) {
141 int layerNumber = layer.getLayerNumber();
142 int layerIndex = gTools->getLayerIndex(layerNumber);
143 std::string name = str(nameTemplate % layerNumber);
144 std::string title = str(titleTemplate % layerNumber);
145 output[layerIndex] = Create(name, title, nbinsx, xlow, xup, xTitle, yTitle);
146 }
147
148 return output;
149}
150
151TH2F** DQMHistoModuleBase::CreateLayers(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
152 double xup, int nbinsy, double ylow, double yup, std::string xTitle, std::string yTitle, std::string zTitle)
153{
155 auto gTools = geo.getGeoTools();
156
157 TH2F** output = new TH2F*[gTools->getNumberOfLayers()];
158
159 for (VxdID layer : geo.getLayers()) {
160 int layerNumber = layer.getLayerNumber();
161 int layerIndex = gTools->getLayerIndex(layerNumber);
162 std::string name = str(nameTemplate % layerNumber);
163 std::string title = str(titleTemplate % layerNumber);
164 output[layerIndex] = Create(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup, xTitle, yTitle, zTitle);
165 }
166
167 return output;
168}
169
170TH1F** DQMHistoModuleBase::CreateSensors(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
171 double xup, std::string xTitle, std::string yTitle)
172{
174 auto gTools = geo.getGeoTools();
175 int nVXDSensors = gTools->getNumberOfSensors();
176
177 TH1F** output = new TH1F*[nVXDSensors];
178
179 for (int sensorIndex = 0; sensorIndex < nVXDSensors; sensorIndex++) {
180 VxdID sensorID = gTools->getSensorIDFromIndex(sensorIndex);
181 std::string name = str(nameTemplate % SensorNameDescription(sensorID));
182 std::string title = str(titleTemplate % SensorTitleDescription(sensorID));
183 output[sensorIndex] = Create(name, title, nbinsx, xlow, xup, xTitle, yTitle);
184 }
185
186 return output;
187}
188
189TH2F** DQMHistoModuleBase::CreateSensors(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
190 double xup, int nbinsy, double ylow, double yup, std::string xTitle, std::string yTitle, std::string zTitle)
191{
193 auto gTools = geo.getGeoTools();
194 int nVXDSensors = gTools->getNumberOfSensors();
195
196 TH2F** output = new TH2F*[nVXDSensors];
197
198 for (int sensorIndex = 0; sensorIndex < nVXDSensors; sensorIndex++) {
199 VxdID sensorID = gTools->getSensorIDFromIndex(sensorIndex);
200 std::string name = str(nameTemplate % SensorNameDescription(sensorID));
201 std::string title = str(titleTemplate % SensorTitleDescription(sensorID));
202 output[sensorIndex] = Create(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup, xTitle, yTitle, zTitle);
203 }
204
205 return output;
206}
207
209{
210 m_MomPhi = Create("MomPhi", "Track Azimuthal Angle", 180, -180, 180, "Mom Phi", "counts");
211 m_MomTheta = Create("MomTheta", "Track Polar Angle", 90, 0, 180, "Mom Theta", "counts");
212 m_MomCosTheta = Create("MomCosTheta", "Cosine of the Track Polar Angle", 100, -1, 1, "Mom CosTheta", "counts");
213}
214
216{
217 m_PValue = Create("PValue", "Track Fit P value", 100, 0, 1, "p-value", "counts");
218 m_Chi2 = Create("Chi2", "Track Fit Chi2", 200, 0, 150, "Chi2", "counts");
219 m_NDF = Create("NDF", "Track Fit NDF", 200, 0, 200, "NDF", "counts");
220 m_Chi2NDF = Create("Chi2NDF", "Track Fit Chi2/NDF", 200, 0, 10, "Chi2/NDF", "counts");
221}
222
224{
225 double residualRange = 400; // in um
226
227 auto residualU = Axis(200, -residualRange, residualRange, "residual U [#mum]");
228 auto residualV = Axis(residualU).title("residual V [#mum]");
229
230 auto factory = Factory(this);
231 factory.xAxisDefault(residualU).yAxisDefault(residualV).zTitleDefault("counts");
232
233 if (! m_hltDQM)
234 m_UBResidualsPXD = factory.CreateTH2F("UBResidualsPXD", "PXD Unbiased Residuals");
235 m_UBResidualsSVD = factory.CreateTH2F("UBResidualsSVD", "SVD Unbiased Residuals");
236
237 factory.xAxisDefault(residualU).yTitleDefault("counts");
238
239 if (! m_hltDQM)
240 m_UBResidualsPXDU = factory.CreateTH1F("UBResidualsPXDU", "PXD Unbiased residuals in U");
241 m_UBResidualsSVDU = factory.CreateTH1F("UBResidualsSVDU", "SVD Unbiased residuals in U");
242
243 factory.xAxisDefault(residualV);
244
245 if (! m_hltDQM)
246 m_UBResidualsPXDV = factory.CreateTH1F("UBResidualsPXDV", "PXD Unbiased residuals in V");
247 m_UBResidualsSVDV = factory.CreateTH1F("UBResidualsSVDV", "SVD Unbiased residuals in V");
248}
249
251{
252
253 int iZ0Range = 200;
254 double fZ0Range = 10.0; // Half range in cm
255 int iD0Range = 200;
256 double fD0Range = 2.0; // Half range in cm
257 int iPhiRange = 72;
258 double fPhiRange = 180.0; // Half range in deg
259 int iLambdaRange = 400;
260 double fLambdaRange = 4.0;
261 int iOmegaRange = 400;
262 double fOmegaRange = 0.1;
263
264 auto phi = Axis(iPhiRange, -fPhiRange, fPhiRange, "#phi [deg]");
265 auto D0 = Axis(iD0Range, -fD0Range, fD0Range, "d0 [cm]");
266 auto D0_2d = Axis(50, -0.5, 0.5, "d0 [cm]");
267 auto Z0 = Axis(iZ0Range, -fZ0Range, fZ0Range, "z0 [cm]");
268 auto Z0_2d = Axis(100, -2, 2, "z0 [cm]");
269 auto tanLambda = Axis(iLambdaRange, -fLambdaRange, fLambdaRange, "Tan Lambda");
270 auto omega = Axis(iOmegaRange, -fOmegaRange, fOmegaRange, "Omega");
271
272 auto factory = Factory(this);
273
274 factory.yTitleDefault("Arb. Units");
275
276 m_Z0 = factory.xAxis(Z0).CreateTH1F("HelixZ0", "z0, the z coordinate of the perigee");
277 m_D0 = factory.xAxis(D0).CreateTH1F("HelixD0", "d0, the signed distance of the perigee in the r-phi plane");
278 m_Phi = factory.xAxis(phi).CreateTH1F("HelixPhi",
279 "Phi0, momentum azymuthal angle at the perigee");
280 m_Omega = factory.xAxis(omega).CreateTH1F("HelixOmega",
281 "Omega, the curvature of the track, sign defined by the charge of the particle");
282 m_TanLambda = factory.xAxis(tanLambda).CreateTH1F("HelixTanLambda", "TanLambda, the slope of the track in the r-z plane");
283
284
285 factory.zTitleDefault("Arb. Units");
286
287 m_PhiD0 = factory.xAxis(phi).yAxis(D0_2d).CreateTH2F("Helix2dPhiD0",
288 "d0 vs Phi0, the signed distance of the perigee in the r-phi plane vs. momentum azymuthal angle at the perigee");
289 m_D0Z0 = factory.xAxis(Z0_2d).yAxis(D0_2d).CreateTH2F("Helix2dD0Z0",
290 "d0 vs z0, the signed distance of the perigee in r-phi vs. z0 of the perigee");
291
292}
293
295{
296 int iMomRange = 100;
297 double fMomRange = 6.0;
298
299 auto momentum = Axis(2 * iMomRange, -fMomRange, fMomRange, "Momentum [GeV/c]");
300 auto pt_momentum = Axis(iMomRange, 0, fMomRange, "Momentum [GeV/c]");
301 auto factory = Factory(this).xAxisDefault(momentum).yTitleDefault("counts");
302
303 m_MomX = factory.CreateTH1F("TrackMomentumX", "Track Momentum X");
304 m_MomY = factory.CreateTH1F("TrackMomentumY", "Track Momentum Y");
305 m_MomZ = factory.CreateTH1F("TrackMomentumZ", "Track Momentum Z");
306 m_MomPt = factory.xAxis(pt_momentum).yTitle("counts").CreateTH1F("TrackMomentumPt", "Track Momentum pT");
307 m_Mom = factory.xlow(.0).CreateTH1F("TrackMomentumMag", "Track Momentum Magnitude");
308}
309
311{
312 int iHitsInSVD = 20;
313 int iHitsInCDC = 200;
314 int iHits = 200;
315
316 auto factory = Factory(this).xlowDefault(0).xTitleDefault("# hits").yTitleDefault("counts");
317
318 if (! m_hltDQM) {
319 int iHitsInPXD = 10;
320 m_HitsPXD = factory.nbinsx(iHitsInPXD).xup(iHitsInPXD).CreateTH1F("NoOfHitsInTrack_PXD", "Number of PXD Hits per Track");
321 }
322 m_HitsSVD = factory.nbinsx(iHitsInSVD).xup(iHitsInSVD).CreateTH1F("NoOfHitsInTrack_SVD", "Number of SVD Hits per Track");
323 m_HitsCDC = factory.nbinsx(iHitsInCDC).xup(iHitsInCDC).CreateTH1F("NoOfHitsInTrack_CDC", "Number of CDC Hits per Track");
324 m_Hits = factory.nbinsx(iHits).xup(iHits).CreateTH1F("NoOfHitsInTrack", "Number of Hits per Track");
325}
326
328{
329 int iTracks = 30;
330
331 auto tracks = Axis(iTracks, 0, iTracks, "# tracks");
332 auto factory = Factory(this).xAxisDefault(tracks).yTitleDefault("counts");
333
334 m_TracksVXD = factory.CreateTH1F("NoOfTracksInVXDOnly", "Number of VXD-Only Tracks per Event");
335 m_TracksCDC = factory.CreateTH1F("NoOfTracksInCDCOnly", "Number of CDC-Only Tracks per Event");
336 m_TracksVXDCDC = factory.CreateTH1F("NoOfTracksInVXDCDC", "Number of VXD+CDC Tracks per Event");
337 m_Tracks = factory.CreateTH1F("NoOfTracks", "Number of Tracks per Event");
338}
339
341{
342
343 double residualRange = 400; // in um
344 auto residual = Axis(200, -residualRange, residualRange, "residual [#mum]");
345 auto factory = Factory(this).xAxisDefault(residual).yTitleDefault("counts");
346
347 if (! m_hltDQM) {
348 m_UBResidualsPXDX_Yin = factory.CreateTH1F("UBResidualsPXDX_Yin", "PXD-Yin Unbiased Residuals in X");
349 m_UBResidualsPXDX_Yang = factory.CreateTH1F("UBResidualsPXDX_Yang", "PXD-Yang Unbiased Residuals in X");
350 }
351 m_UBResidualsSVDX_Pat = factory.CreateTH1F("UBResidualsSVDX_Pat", "SVD-Pat Unbiased Residuals in X");
352 m_UBResidualsSVDX_Mat = factory.CreateTH1F("UBResidualsSVDX_Mat", "SVD-Mat Unbiased Residuals in X");
353
354 if (! m_hltDQM) {
355 m_UBResidualsPXDY_Yin = factory.CreateTH1F("UBResidualsPXDY_Yin", "PXD-Yin Unbiased Residuals in Y");
356 m_UBResidualsPXDY_Yang = factory.CreateTH1F("UBResidualsPXDY_Yang", "PXD-Yang Unbiased Residuals in Y");
357 }
358 m_UBResidualsSVDY_Pat = factory.CreateTH1F("UBResidualsSVDY_Pat", "SVD-Pat Unbiased Residuals in Y");
359 m_UBResidualsSVDY_Mat = factory.CreateTH1F("UBResidualsSVDY_Mat", "SVD-Mat Unbiased Residuals in Y");
360
361 if (! m_hltDQM) {
362 m_UBResidualsPXDZ_Yin = factory.CreateTH1F("UBResidualsPXDZ_Yin", "PXD-Yin Unbiased Residuals in Z");
363 m_UBResidualsPXDZ_Yang = factory.CreateTH1F("UBResidualsPXDZ_Yang", "PXD-Yang Unbiased Residuals in Z");
364 }
365 m_UBResidualsSVDZ_Pat = factory.CreateTH1F("UBResidualsSVDZ_Pat", "SVD-Pat Unbiased Residuals in Z");
366 m_UBResidualsSVDZ_Mat = factory.CreateTH1F("UBResidualsSVDZ_Mat", "SVD-Mat Unbiased Residuals in Z");
367
368}
369
371{
372 double range = 180; // in um
373 int nbins = 360;
374
375 auto gTools = VXD::GeoCache::getInstance().getGeoTools();
376
377 int nVXDLayers = gTools->getNumberOfLayers();
379
380 m_TRClusterCorrelationsPhi = new TH2F*[nVXDLayers - 1];
381 m_TRClusterCorrelationsTheta = new TH2F*[nVXDLayers - 1];
382
384 m_TRClusterHitmap = CreateLayers(format("TRClusterHitmapLayer%1%"), format("Cluster Hitmap for layer %1%"), nbins, -range, range,
385 nbins / 2, .0, range, "Phi angle [deg]", "Theta angle [deg]", "counts");
386
387 for (VxdID layer : geo.getLayers()) {
388 int layerNumber = layer.getLayerNumber();
389 if (layerNumber == gTools->getLastLayer())
390 continue;
391
392 int layerIndex = gTools->getLayerIndex(layerNumber);
393
395 std::string name = str(format("CorrelationsPhiLayers_%1%_%2%") % layerNumber % (layerNumber + 1));
396 std::string title = str(format("Correlations in Phi for Layers %1% %2%") % layerNumber % (layerNumber + 1));
397 std::string xTitle = str(format("angle layer %1% [deg]") % layerNumber);
398 std::string yTitle = str(format("angle layer %1% [deg]") % (layerNumber + 1));
399 m_TRClusterCorrelationsPhi[layerIndex] = Create(name, title, nbins, -range, range, nbins, -range, range,
400 xTitle, yTitle, "counts");
401
403 name = str(format("CorrelationsThetaLayers_%1%_%2%") % layerNumber % (layerNumber + 1));
404 title = str(format("Correlations in Theta for Layers %1% %2%") % layerNumber % (layerNumber + 1));
405 m_TRClusterCorrelationsTheta[layerIndex] = Create(name, title, nbins / 2, .0, range, nbins / 2, .0, range,
406 xTitle, yTitle, "counts");
407 }
408}
409
411{
412
413 double residualRange = 400; // in um
414
415 auto residualU = Axis(200, -residualRange, residualRange, "residual U [#mum]");
416 auto residualV = Axis(residualU).title("residual V [#mum]");
417
418 auto factory = Factory(this);
419
420 factory.yTitleDefault("counts");
421
422 m_UBResidualsSensorU = factory.xAxis(residualU).CreateSensorsTH1F(format("UBResidualsU_%1%"),
423 format("VXD Unbiased U Residuals for sensor %1%"));
424 m_UBResidualsSensorV = factory.xAxis(residualV).CreateSensorsTH1F(format("UBResidualsV_%1%"),
425 format("VXD Unbiased V Residuals for sensor %1%"));
426
427}
428
430{
431
432 double residualRange = 400; // in um
433
434 auto residualU = Axis(200, -residualRange, residualRange, "residual U [#mum]");
435 auto residualV = Axis(residualU).title("residual V [#mum]");
436
437 auto factory = Factory(this);
438
439 m_UBResidualsSensor = factory.xAxis(residualU).yAxis(residualV).zTitle("counts").CreateSensorsTH2F(format("UBResiduals_%1%"),
440 format("VXD Unbiased Residuals for sensor %1%"));
441}
442
443void DQMHistoModuleBase::FillTrackIndexes(int iTrack, int iTrackVXD, int iTrackCDC, int iTrackVXDCDC)
444{
445 m_Tracks->Fill(iTrack);
446 m_TracksVXD->Fill(iTrackVXD);
447 m_TracksCDC->Fill(iTrackCDC);
448 m_TracksVXDCDC->Fill(iTrackVXDCDC);
449}
450
451void DQMHistoModuleBase::FillHitNumbers(int nPXD, int nSVD, int nCDC)
452{
453 if (! m_hltDQM)
454 m_HitsPXD->Fill(nPXD);
455 else nPXD = 0;
456 m_HitsSVD->Fill(nSVD);
457 m_HitsCDC->Fill(nCDC);
458 m_Hits->Fill(nPXD + nSVD + nCDC);
459}
460
462{
463 const ROOT::Math::XYZVector mom = tfr->getMomentum();
464
465 // don't fill NAN or INF
467 checkVariableForNANOrINF(mom.Phi()) or checkVariableForNANOrINF(mom.Theta())) {
468 return;
469 }
470
471 float Phi = mom.Phi();
472 float Theta = mom.Theta();
473
474 m_MomPhi->Fill(Phi / Unit::deg);
475 m_MomTheta->Fill(Theta / Unit::deg);
476 m_MomCosTheta->Fill(cos(Theta));
477}
478
480{
481 const ROOT::Math::XYZVector& mom = tfr->getMomentum();
482
483 // don't fill NAN or INF, Mag is NAN/INF if any component is, no need to check
484 if (checkVariableForNANOrINF(mom.X()) or checkVariableForNANOrINF(mom.Y()) or
485 checkVariableForNANOrINF(mom.Z()) or checkVariableForNANOrINF(mom.Rho())) {
486 return;
487 }
488
489 m_MomX->Fill(mom.X());
490 m_MomY->Fill(mom.Y());
491 m_MomZ->Fill(mom.Z());
492 m_Mom->Fill(mom.R());
493 m_MomPt->Fill(mom.Rho());
494}
495
497{
498 // don't fill NAN or INF
501 return;
502 }
503
504 m_D0->Fill(tfr->getD0());
505 m_Z0->Fill(tfr->getZ0());
506 m_Phi->Fill(tfr->getPhi() / Unit::deg);
507 m_Omega->Fill(tfr->getOmega());
508 m_TanLambda->Fill(tfr->getTanLambda());
509
510 m_PhiD0->Fill(tfr->getPhi0() / Unit::deg, tfr->getD0());
511 m_D0Z0->Fill(tfr->getZ0(), tfr->getD0());
512}
513
514void DQMHistoModuleBase::FillTrackFitStatus(const genfit::FitStatus* tfs)
515{
516 // don't fill NAN or INF
517 if (checkVariableForNANOrINF(tfs->getChi2()) or checkVariableForNANOrINF(tfs->getNdf())) {
518 return;
519 }
520
521 float NDF = tfs->getNdf();
522 m_NDF->Fill(NDF);
523 float chi2 = tfs->getChi2();
524 m_Chi2->Fill(chi2);
525 if (NDF > 0) {
526 float Chi2NDF = chi2 / NDF;
527 m_Chi2NDF->Fill(Chi2NDF);
528 }
529
530 m_PValue->Fill(tfs->getPVal());
531}
532
533void DQMHistoModuleBase::FillTRClusterCorrelations(float phi_deg, float phiPrev_deg, float theta_deg, float thetaPrev_deg,
534 int correlationIndex)
535{
536 m_TRClusterCorrelationsPhi[correlationIndex]->Fill(phiPrev_deg, phi_deg);
537 m_TRClusterCorrelationsTheta[correlationIndex]->Fill(thetaPrev_deg, theta_deg);
538}
539
541{
542 if (checkVariableForNANOrINF(residual_um.X()) or checkVariableForNANOrINF(residual_um.Y())) {
543 return;
544 }
545 m_UBResidualsPXD->Fill(residual_um.x(), residual_um.y());
546 m_UBResidualsPXDU->Fill(residual_um.x());
547 m_UBResidualsPXDV->Fill(residual_um.y());
548}
549
551{
552 if (checkVariableForNANOrINF(residual_um.X()) or checkVariableForNANOrINF(residual_um.Y())) {
553 return;
554 }
555 m_UBResidualsSVD->Fill(residual_um.x(), residual_um.y());
556 m_UBResidualsSVDU->Fill(residual_um.x());
557 m_UBResidualsSVDV->Fill(residual_um.y());
558}
559
560void DQMHistoModuleBase::FillHalfShellsPXD(const B2Vector3D& globalResidual_um, bool isNotYang)
561{
562 if (checkVariableForNANOrINF(globalResidual_um.X()) or
563 checkVariableForNANOrINF(globalResidual_um.Y()) or
564 checkVariableForNANOrINF(globalResidual_um.Z())) {
565 return;
566 }
567 if (isNotYang) {
568 m_UBResidualsPXDX_Yin->Fill(globalResidual_um.x());
569 m_UBResidualsPXDY_Yin->Fill(globalResidual_um.y());
570 m_UBResidualsPXDZ_Yin->Fill(globalResidual_um.z());
571 } else {
572 m_UBResidualsPXDX_Yang->Fill(globalResidual_um.x());
573 m_UBResidualsPXDY_Yang->Fill(globalResidual_um.y());
574 m_UBResidualsPXDZ_Yang->Fill(globalResidual_um.z());
575 }
576}
577
578void DQMHistoModuleBase::FillHalfShellsSVD(const B2Vector3D& globalResidual_um, bool isNotMat)
579{
580 if (checkVariableForNANOrINF(globalResidual_um.X()) or
581 checkVariableForNANOrINF(globalResidual_um.Y()) or
582 checkVariableForNANOrINF(globalResidual_um.Z())) {
583 return;
584 }
585 if (isNotMat) {
586 m_UBResidualsSVDX_Pat->Fill(globalResidual_um.x());
587 m_UBResidualsSVDY_Pat->Fill(globalResidual_um.y());
588 m_UBResidualsSVDZ_Pat->Fill(globalResidual_um.z());
589 } else {
590 m_UBResidualsSVDX_Mat->Fill(globalResidual_um.x());
591 m_UBResidualsSVDY_Mat->Fill(globalResidual_um.y());
592 m_UBResidualsSVDZ_Mat->Fill(globalResidual_um.z());
593 }
594}
595
596void DQMHistoModuleBase::FillUB1DResidualsSensor(const B2Vector3D& residual_um, int sensorIndex)
597{
598 if (checkVariableForNANOrINF(residual_um.X()) or checkVariableForNANOrINF(residual_um.Y())) {
599 return;
600 }
601 m_UBResidualsSensorU[sensorIndex]->Fill(residual_um.x());
602 m_UBResidualsSensorV[sensorIndex]->Fill(residual_um.y());
603}
604
605void DQMHistoModuleBase::FillUB2DResidualsSensor(const B2Vector3D& residual_um, int sensorIndex)
606{
607 if (checkVariableForNANOrINF(residual_um.X()) or checkVariableForNANOrINF(residual_um.Y())) {
608 return;
609 }
610 m_UBResidualsSensor[sensorIndex]->Fill(residual_um.x(), residual_um.y());
611}
612
613void DQMHistoModuleBase::FillTRClusterHitmap(float phi_deg, float theta_deg, int layerIndex)
614{
615 m_TRClusterHitmap[layerIndex]->Fill(phi_deg, theta_deg);
616}
617
618void DQMHistoModuleBase::ComputeMean(TH1F* output, TH2F* input, bool onX)
619{
620 output->Reset();
621 int nbinsi = onX ? input->GetNbinsX() : input->GetNbinsY();
622 int nbinsy = onX ? input->GetNbinsY() : input->GetNbinsX();
623 TAxis* axis = onX ? input->GetYaxis() : input->GetXaxis();
624
625 for (int i = 1; i <= nbinsi; i++) {
626 float sum = 0;
627 float count = 0;
628
629 for (int j = 1; j <= nbinsy; j++) {
630 float value = onX ? input->GetBinContent(i, j) : input->GetBinContent(j, i);
631 sum += value * axis->GetBinCenter(j);
632 count += value;
633 }
634
635 output->SetBinContent(i, count != 0 ? sum / count : 0);
636 }
637}
638
639void DQMHistoModuleBase::ProcessHistogramParameterChange(const std::string& name, const std::string& parameter,
640 const std::string& value)
641{
642 TH1* histogram = nullptr;
643
644 for (auto adept : m_histograms)
645 if (adept->GetName() == name) {
646 histogram = adept;
647 break;
648 }
649
650 if (!histogram) {
651 B2WARNING("Histogram " + name + " not found, parameter change is skipped in " + getName() + ".");
652 } else {
653 try {
654 EditHistogramParameter(histogram, parameter, value);
655 } catch (const std::invalid_argument& e) {
656 B2WARNING("Value " + value + " of parameter " + parameter + " for histogram " + histogram->GetName() +
657 " could not be parsed, parameter change is skipped in " + getName() + ".");
658 } catch (const std::out_of_range& e) {
659 B2WARNING("Value " + value + " of parameter " + parameter + " for histogram " + histogram->GetName() +
660 " is out of range, parameter change is skipped in " + getName() + ".");
661 }
662 }
663}
664
665void DQMHistoModuleBase::EditHistogramParameter(TH1* histogram, const std::string& parameter, std::string value)
666{
667 if (parameter == "title") {
668 histogram->SetTitle(value.c_str());
669 return;
670 }
671 if (parameter == "nbinsx") {
672 auto axis = histogram->GetXaxis();
673 axis->Set(stoi(value), axis->GetXmin(), axis->GetXmax());
674 return;
675 }
676 if (parameter == "xlow") {
677 auto axis = histogram->GetXaxis();
678 axis->Set(axis->GetNbins(), stod(value), axis->GetXmax());
679 return;
680 }
681 if (parameter == "xup") {
682 auto axis = histogram->GetXaxis();
683 axis->Set(axis->GetNbins(), axis->GetXmin(), stod(value));
684 return;
685 }
686 if (parameter == "xTitle") {
687 histogram->GetXaxis()->SetTitle(value.c_str());
688 return;
689 }
690 if (parameter == "yTitle") {
691 histogram->GetYaxis()->SetTitle(value.c_str());
692 return;
693 }
694
695 if (dynamic_cast<TH2F*>(histogram) == nullptr) {
696 B2WARNING("Parameter " + parameter + " not found in histogram " + histogram->GetName() + ", parameter change is skipped in " +
697 getName() + ".");
698 return;
699 }
700
701 if (parameter == "nbinsy") {
702 auto axis = histogram->GetYaxis();
703 axis->Set(stoi(value), axis->GetXmin(), axis->GetXmax());
704 return;
705 }
706 if (parameter == "ylow") {
707 auto axis = histogram->GetYaxis();
708 axis->Set(axis->GetNbins(), stod(value), axis->GetXmax());
709 return;
710 }
711 if (parameter == "yup") {
712 auto axis = histogram->GetYaxis();
713 axis->Set(axis->GetNbins(), axis->GetXmin(), stod(value));
714 return;
715 }
716 if (parameter == "zTitle") {
717 histogram->GetZaxis()->SetTitle(value.c_str());
718 return;
719 }
720
721 B2WARNING("Parameter " + parameter + " not found in histogram " + histogram->GetName() + ", parameter change is skipped in " +
722 getName() + ".");
723}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:427
DataType z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:429
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
DataType x() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:425
TH1F * m_Hits
Number of all hits in tracks.
virtual void Define1DSensors()
Define 1D histograms with unbiased residuals for individual sensors.
TH1F * m_UBResidualsSVDV
Unbiased residuals for SVD v.
bool histogramsDefined
True if the defineHisto() was called.
TH1F * m_MomTheta
Track momentum Pt.Theta.
TH1F * m_Tracks
Number of all finding tracks.
bool checkVariableForNANOrINF(const double var)
Check a variable for whether or not it is NAN or INF.
TH1F * m_UBResidualsPXDY_Yang
Unbiased residuals in Y for PXD for Yang.
TH1F * m_MomPt
Track momentum Pt.
TH1F * m_TanLambda
TanLambda - the slope of the track in the r-z plane.
TH1F ** m_UBResidualsSensorU
Unbiased residuals for PXD and SVD u per sensor.
virtual void FillHitNumbers(int nPXD, int nSVD, int nCDC)
Fill histograms with numbers of hits.
TH1F * m_UBResidualsPXDZ_Yang
Unbiased residuals in Z for PXD for Yang.
static std::string SensorTitleDescription(VxdID sensorID)
Creates string description of the sensor from given sensor ID to be used in a histogram title.
TH1F * m_UBResidualsPXDU
Unbiased residuals for PXD u.
std::vector< std::tuple< std::string, std::string, std::string > > m_histogramParameterChanges
Used for changing parameters of histograms via the ProcessHistogramParameterChange function.
virtual void DefineHalfShellsVXD()
Define histograms with unbiased residuals for half-shells for PXD and SVD sensors.
TH1F * m_TracksCDC
Number of tracks only with CDC.
TH1F * m_UBResidualsSVDY_Pat
Unbiased residuals in Y for PXD for Pat.
TH1F * m_HitsSVD
Number of hits on SVD.
virtual void initialize() override
Initializer.
virtual void DefineUBResidualsVXD()
Define histograms with unbiased residuals in PXD and SVD sensors.
std::vector< TH1 * > m_histograms
All histograms created via the Create- functions are automatically added to this set.
virtual void DefineTRClusters()
Define histograms with correlations between neighbor layers and cluster hitmap in IP angle range.
TH2F ** m_TRClusterHitmap
Track related clusters - hitmap in IP angle range.
void ProcessHistogramParameterChange(const std::string &name, const std::string &parameter, const std::string &value)
Process one change in histogram parameters.
TH1F * m_UBResidualsSVDZ_Mat
Unbiased residuals in Z for PXD for Mat.
TH1F * m_Omega
Omega - the curvature of the track.
virtual void event() override
This method is called for each event.
TH2F * m_UBResidualsPXD
Unbiased residuals for PXD u vs v.
static std::string SensorNameDescription(VxdID sensorID)
Creates string description of the sensor from given sensor ID to be used in a histogram name.
TH1F * m_TracksVXD
Number of tracks only with VXD.
TH1F * m_UBResidualsSVDX_Mat
Unbiased residuals in X for PXD for Mat.
virtual TH1F ** CreateSensors(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow, double xup, std::string xTitle, std::string yTitle)
Function to create array of TH1F histograms, one for each sensor.
TH1F * m_UBResidualsPXDX_Yang
Unbiased residuals in X for PXD for Yang.
virtual void DefineTrackFitStatus()
Define histograms which require FitStatus.
virtual void FillHalfShellsSVD(const B2Vector3D &globalResidual_um, bool isNotMat)
Fill histograms with unbiased residuals for half-shells for SVD sensors.
std::string m_tracksStoreArrayName
StoreArray name where Tracks are written.
TH1F * m_Mom
Track momentum Magnitude.
TH1F * m_UBResidualsPXDX_Yin
half-shells
TH1F * m_UBResidualsSVDU
Unbiased residuals for SVD u.
TH2F * m_PhiD0
d0 vs Phi - the signed distance to the IP in the r-phi plane
virtual void FillUB2DResidualsSensor(const B2Vector3D &residual_um, int sensorIndex)
Fill 2D histograms with unbiased residuals for individual sensors.
virtual void FillUBResidualsPXD(const B2Vector3D &residual_um)
Fill histograms with unbiased residuals in PXD sensors.
virtual TH1F * Create(std::string name, std::string title, int nbinsx, double xlow, double xup, std::string xTitle, std::string yTitle)
Function to create TH1F and add it to the vector of histograms (m_histograms).
TH1F * m_MomX
Track momentum Pt.X.
virtual void FillTrackFitStatus(const genfit::FitStatus *tfs)
Fill histograms which require FitStatus.
virtual void FillTRClusterHitmap(float phi_deg, float theta_deg, int layerIndex)
Fill cluster hitmap in IP angle range.
TH1F * m_UBResidualsSVDX_Pat
Unbiased residuals in X for PXD for Pat.
TH2F ** m_TRClusterCorrelationsPhi
Track related clusters - neighbor correlations in Phi.
TH1F * m_UBResidualsSVDZ_Pat
Unbiased residuals in Z for PXD for Pat.
TH2F * m_UBResidualsSVD
Unbiased residuals for SVD u vs v.
TH1F * m_MomPhi
Track momentum Pt.Phi.
TH1F * m_Phi
Phi - the angle of the transverse momentum in the r-phi plane, with CDF naming convention.
virtual void beginRun() override
Called when entering a new run.
TH1F * m_MomCosTheta
Track momentum Pt.CosTheta.
virtual void DefineHits()
Define histograms with numbers of hits.
virtual void FillHelixParametersAndCorrelations(const TrackFitResult *tfr)
Fill histograms with helix parameters and their correlations.
TH2F ** m_UBResidualsSensor
Unbiased residuals for PXD and SVD u vs v per sensor.
TH1F * m_HitsCDC
Number of hits on CDC.
virtual void DefineMomentumCoordinates()
Define histograms with track momentum Pt.
virtual void FillMomentumCoordinates(const TrackFitResult *tfr)
Fill histograms with track momentum Pt.
TH1F ** m_UBResidualsSensorV
Unbiased residuals for PXD and SVD v per sensor.
static void ComputeMean(TH1F *output, TH2F *input, bool onX=true)
Creates a graph of means by given axis from given TH2F histogram.
virtual void DefineTracks()
All the following Define- functions should be used in the defineHisto() function to define histograms...
bool m_hltDQM
True if the DQM module is run on HLT.
TH2F * m_D0Z0
z0 vs d0 - signed distance to the IP in r-phi vs.
virtual void FillHalfShellsPXD(const B2Vector3D &globalResidual_um, bool isNotYang)
Fill histograms with unbiased residuals for half-shells for PXD sensors.
virtual void Define2DSensors()
Define 2D histograms with unbiased residuals for individual sensors.
TH1F * m_UBResidualsPXDY_Yin
Unbiased residuals in Y for PXD for Yin.
TH1F * m_MomY
Track momentum Pt.Y.
TH1F * m_UBResidualsSVDY_Mat
Unbiased residuals in Y for PXD for Mat.
virtual void DefineMomentumAngles()
Define histograms with track momentum Pt.
virtual TH1F ** CreateLayers(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow, double xup, std::string xTitle, std::string yTitle)
Function to create array of TH1F histograms, one for each layer.
virtual void FillTrackIndexes(int iTrack, int iTrackVXD, int iTrackCDC, int iTrackVXDCDC)
Fill histograms with track indexes.
TH1F * m_HitsPXD
Number of hits on PXD.
TH1F * m_UBResidualsPXDZ_Yin
Unbiased residuals in Z for PXD for Yin.
std::string m_recoTracksStoreArrayName
StoreArray name where RecoTracks are written.
TH1F * m_TracksVXDCDC
Number of full tracks with VXD+CDC.
TH1F * m_MomZ
Track momentum Pt.Z.
TH1F * m_D0
d0 - the signed distance to the IP in the r-phi plane
TH1F * m_UBResidualsPXDV
Unbiased residuals for PXD v.
TH2F ** m_TRClusterCorrelationsTheta
Track related clusters - neighbor correlations in Theta.
virtual void FillTRClusterCorrelations(float phi_deg, float phiPrev_deg, float theta_deg, float thetaPrev_deg, int correlationIndex)
Fill histograms with correlations between neighbor layers.
virtual void FillMomentumAngles(const TrackFitResult *tfr)
Fill histograms with track momentum Pt.
virtual void FillUBResidualsSVD(const B2Vector3D &residual_um)
Fill histograms with unbiased residuals in SVD sensors.
virtual void DefineHelixParametersAndCorrelations()
Define histograms with helix parameters and their correlations.
TH1F * m_Z0
z0 - the z0 coordinate of the perigee (beam spot position)
virtual void FillUB1DResidualsSensor(const B2Vector3D &residual_um, int sensorIndex)
Fill 1D histograms with unbiased residuals for individual sensors.
void EditHistogramParameter(TH1 *histogram, const std::string &parameter, std::string value)
On given histogram sets given parameter to given value.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
This class unites some parameters for Factory which describe one axis of histogram.
Axis & title(std::string title)
Set value of title.
This class is used for creating TH1F and TH2F objects.
Factory & xTitleDefault(std::string xTitle)
Sets xTitle permanently.
Factory & xlowDefault(double xlow)
Sets xlow permanently.
Factory & yTitleDefault(std::string yTitle)
Sets yTitle permanently.
Factory & xAxisDefault(const Axis &axis)
Permanently copies parameters for x axis from given Axis.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Values of the result of a track fit with a given particle hypothesis.
double getPhi() const
Getter for phi0 with CDF naming convention.
double getOmega() const
Getter for omega.
double getD0() const
Getter for d0.
double getTanLambda() const
Getter for tanLambda.
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.
double getPhi0() const
Getter for phi0.
static const double deg
degree to radians
Definition: Unit.h:109
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
Definition: GeoCache.cc:176
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:142
unsigned short getNumberOfSensors() const
Get total number of sensors.
Definition: GeoTools.h:128
unsigned short getNumberOfLayers() const
Get number of VXD layers.
Definition: GeoTools.h:41
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
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:560
Abstract base class for different kinds of events.