Belle II Software  release-06-02-00
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 
18 using namespace Belle2;
19 using namespace Belle2::HistogramFactory;
20 using namespace std;
21 using boost::format;
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
28 {
30 
31  addParam("tracksStoreArrayName", m_tracksStoreArrayName, "StoreArray name where the merged Tracks are written.",
33  addParam("recoTracksStoreArrayName", m_recoTracksStoreArrayName, "StoreArray name where the merged RecoTracks are written.",
35  addParam("histogramParameterChanges", m_histogramParameterChanges, "Changes of default parameters of histograms.",
37 }
38 
40 {
41 
42 }
43 
45 {
47  if (!recoTracks.isOptional()) {
48  B2WARNING("Missing recoTracks array, " + getName() + " is skipped.");
49  return;
50  }
51 
53  if (!Tracks.isOptional()) {
54  B2WARNING("Missing Tracks array, " + getName() + " is skipped.");
55  return;
56  }
57 
58  // Register histograms (calls back defineHisto)
59  REG_HISTOGRAM
60 }
61 
62 //------------------------------------------------------------------
63 // Function to define histograms
64 //-----------------------------------------------------------------
65 
67 {
68  histogramsDefined = true;
69 }
70 
72 {
74  if (!recoTracks.isOptional()) {
75  B2DEBUG(22, "Missing recoTracks array in beginRun() for " + getName());
76  return;
77  }
79  if (!tracks.isOptional()) {
80  B2DEBUG(22, "Missing recoTracks array in beginRun() for " + getName());
81  return;
82  }
83 
84  for (TH1* histogram : m_histograms)
85  histogram->Reset();
86 }
87 
88 
90 {
91  if (!histogramsDefined) {
92  B2ERROR("Histograms not defined in " + this->getName() + " module, event processing is skipped!");
93  return;
94  }
95 }
96 
97 TH1F* DQMHistoModuleBase::Create(string name, string title, int nbinsx, double xlow, double xup, string xTitle, 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 
108 TH2F* DQMHistoModuleBase::Create(string name, string title, int nbinsx, double xlow, double xup, int nbinsy, double ylow,
109  double yup, string xTitle, string yTitle, 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 
132 TH1F** DQMHistoModuleBase::CreateLayers(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
133  double xup, string xTitle, 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  string name = str(nameTemplate % layerNumber);
144  string title = str(titleTemplate % layerNumber);
145  output[layerIndex] = Create(name, title, nbinsx, xlow, xup, xTitle, yTitle);
146  }
147 
148  return output;
149 }
150 
151 TH2F** DQMHistoModuleBase::CreateLayers(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
152  double xup, int nbinsy, double ylow, double yup, string xTitle, string yTitle, 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  string name = str(nameTemplate % layerNumber);
163  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 
170 TH1F** DQMHistoModuleBase::CreateSensors(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
171  double xup, string xTitle, 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  string name = str(nameTemplate % SensorNameDescription(sensorID));
182  string title = str(titleTemplate % SensorTitleDescription(sensorID));
183  output[sensorIndex] = Create(name, title, nbinsx, xlow, xup, xTitle, yTitle);
184  }
185 
186  return output;
187 }
188 
189 TH2F** DQMHistoModuleBase::CreateSensors(boost::format nameTemplate, boost::format titleTemplate, int nbinsx, double xlow,
190  double xup, int nbinsy, double ylow, double yup, string xTitle, string yTitle, 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  string name = str(nameTemplate % SensorNameDescription(sensorID));
201  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(D0_2d).yAxis(Z0_2d).CreateTH2F("Helix2dD0Z0",
290  "z0 vs d0, z0 of the perigee vs the signed distance of the perigee in r-phi");
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  string name = str(format("CorrelationsPhiLayers_%1%_%2%") % layerNumber % (layerNumber + 1));
396  string title = str(format("Correlations in Phi for Layers %1% %2%") % layerNumber % (layerNumber + 1));
397  string xTitle = str(format("angle layer %1% [deg]") % layerNumber);
398  string yTitle = str(format("angle layer %1% [deg]") % (layerNumber + 1));
399  m_TRClusterCorrelationsPhi[layerIndex] = Create(name.c_str(), title.c_str(), nbins, -range, range, nbins, -range, range,
400  xTitle.c_str(), yTitle.c_str(), "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.c_str(), title.c_str(), nbins / 2, .0, range, nbins / 2, .0, range,
406  xTitle.c_str(), yTitle.c_str(), "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 
443 void 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 
451 void 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  TVector3 mom = tfr->getMomentum();
464 
465  float px = mom.Px();
466  float py = mom.Py();
467  float pz = mom.Pz();
468 
469  float Phi = atan2(py, px);
470  float pxy = sqrt(px * px + py * py);
471  float Theta = atan2(pxy, pz);
472 
473  m_MomPhi->Fill(Phi / Unit::deg);
474  m_MomTheta->Fill(Theta / Unit::deg);
475  m_MomCosTheta->Fill(cos(Theta));
476 }
477 
479 {
480  TVector3 mom = tfr->getMomentum();
481 
482  m_MomX->Fill(mom.Px());
483  m_MomY->Fill(mom.Py());
484  m_MomZ->Fill(mom.Pz());
485  m_Mom->Fill(mom.Mag());
486  m_MomPt->Fill(mom.Pt());
487 }
488 
490 {
491  m_D0->Fill(tfr->getD0());
492  m_Z0->Fill(tfr->getZ0());
493  m_Phi->Fill(tfr->getPhi() / Unit::deg);
494  m_Omega->Fill(tfr->getOmega());
495  m_TanLambda->Fill(tfr->getTanLambda());
496 
497  m_PhiD0->Fill(tfr->getPhi0() / Unit::deg, tfr->getD0());
498  m_D0Z0->Fill(tfr->getZ0(), tfr->getD0());
499 }
500 
502 {
503  float NDF = tfs->getNdf();
504  m_NDF->Fill(NDF);
505 
506  m_Chi2->Fill(tfs->getChi2());
507  if (NDF) {
508  float Chi2NDF = tfs->getChi2() / NDF;
509  m_Chi2NDF->Fill(Chi2NDF);
510  }
511 
512  m_PValue->Fill(tfs->getPVal());
513 }
514 
515 void DQMHistoModuleBase::FillTRClusterCorrelations(float phi_deg, float phiPrev_deg, float theta_deg, float thetaPrev_deg,
516  int correlationIndex)
517 {
518  m_TRClusterCorrelationsPhi[correlationIndex]->Fill(phiPrev_deg, phi_deg);
519  m_TRClusterCorrelationsTheta[correlationIndex]->Fill(thetaPrev_deg, theta_deg);
520 }
521 
522 void DQMHistoModuleBase::FillUBResidualsPXD(TVector3 residual_um)
523 {
524  m_UBResidualsPXD->Fill(residual_um.x(), residual_um.y());
525  m_UBResidualsPXDU->Fill(residual_um.x());
526  m_UBResidualsPXDV->Fill(residual_um.y());
527 }
528 
529 void DQMHistoModuleBase::FillUBResidualsSVD(TVector3 residual_um)
530 {
531  m_UBResidualsSVD->Fill(residual_um.x(), residual_um.y());
532  m_UBResidualsSVDU->Fill(residual_um.x());
533  m_UBResidualsSVDV->Fill(residual_um.y());
534 }
535 
536 void DQMHistoModuleBase::FillHalfShellsPXD(TVector3 globalResidual_um, bool isNotYang)
537 {
538  if (isNotYang) {
539  m_UBResidualsPXDX_Yin->Fill(globalResidual_um.x());
540  m_UBResidualsPXDY_Yin->Fill(globalResidual_um.y());
541  m_UBResidualsPXDZ_Yin->Fill(globalResidual_um.z());
542  } else {
543  m_UBResidualsPXDX_Yang->Fill(globalResidual_um.x());
544  m_UBResidualsPXDY_Yang->Fill(globalResidual_um.y());
545  m_UBResidualsPXDZ_Yang->Fill(globalResidual_um.z());
546  }
547 }
548 
549 void DQMHistoModuleBase::FillHalfShellsSVD(TVector3 globalResidual_um, bool isNotMat)
550 {
551  if (isNotMat) {
552  m_UBResidualsSVDX_Pat->Fill(globalResidual_um.x());
553  m_UBResidualsSVDY_Pat->Fill(globalResidual_um.y());
554  m_UBResidualsSVDZ_Pat->Fill(globalResidual_um.z());
555  } else {
556  m_UBResidualsSVDX_Mat->Fill(globalResidual_um.x());
557  m_UBResidualsSVDY_Mat->Fill(globalResidual_um.y());
558  m_UBResidualsSVDZ_Mat->Fill(globalResidual_um.z());
559  }
560 }
561 
562 void DQMHistoModuleBase::FillUB1DResidualsSensor(TVector3 residual_um, int sensorIndex)
563 {
564  m_UBResidualsSensorU[sensorIndex]->Fill(residual_um.x());
565  m_UBResidualsSensorV[sensorIndex]->Fill(residual_um.y());
566 }
567 
568 void DQMHistoModuleBase::FillUB2DResidualsSensor(TVector3 residual_um, int sensorIndex)
569 {
570  m_UBResidualsSensor[sensorIndex]->Fill(residual_um.x(), residual_um.y());
571 }
572 
573 void DQMHistoModuleBase::FillTRClusterHitmap(float phi_deg, float theta_deg, int layerIndex)
574 {
575  m_TRClusterHitmap[layerIndex]->Fill(phi_deg, theta_deg);
576 }
577 
578 void DQMHistoModuleBase::ComputeMean(TH1F* output, TH2F* input, bool onX)
579 {
580  output->Reset();
581  int nbinsi = onX ? input->GetNbinsX() : input->GetNbinsY();
582  int nbinsy = onX ? input->GetNbinsY() : input->GetNbinsX();
583  TAxis* axis = onX ? input->GetYaxis() : input->GetXaxis();
584 
585  for (int i = 1; i <= nbinsi; i++) {
586  float sum = 0;
587  float count = 0;
588 
589  for (int j = 1; j <= nbinsy; j++) {
590  float value = onX ? input->GetBinContent(i, j) : input->GetBinContent(j, i);
591  sum += value * axis->GetBinCenter(j);
592  count += value;
593  }
594 
595  output->SetBinContent(i, count != 0 ? sum / count : 0);
596  }
597 }
598 
599 void DQMHistoModuleBase::ProcessHistogramParameterChange(const string& name, const string& parameter, const string& value)
600 {
601  TH1* histogram = nullptr;
602 
603  for (auto adept : m_histograms)
604  if (adept->GetName() == name) {
605  histogram = adept;
606  break;
607  }
608 
609  if (!histogram) {
610  B2WARNING("Histogram " + name + " not found, parameter change is skipped in " + getName() + ".");
611  } else {
612  try {
613  EditHistogramParameter(histogram, parameter, value);
614  } catch (const invalid_argument& e) {
615  B2WARNING("Value " + value + " of parameter " + parameter + " for histogram " + histogram->GetName() +
616  " could not be parsed, parameter change is skipped in " + getName() + ".");
617  } catch (const out_of_range& e) {
618  B2WARNING("Value " + value + " of parameter " + parameter + " for histogram " + histogram->GetName() +
619  " is out of range, parameter change is skipped in " + getName() + ".");
620  }
621  }
622 }
623 
624 void DQMHistoModuleBase::EditHistogramParameter(TH1* histogram, const string& parameter, string value)
625 {
626  if (parameter == "title") {
627  histogram->SetTitle(value.c_str());
628  return;
629  }
630  if (parameter == "nbinsx") {
631  auto axis = histogram->GetXaxis();
632  axis->Set(stoi(value), axis->GetXmin(), axis->GetXmax());
633  return;
634  }
635  if (parameter == "xlow") {
636  auto axis = histogram->GetXaxis();
637  axis->Set(axis->GetNbins(), stod(value), axis->GetXmax());
638  return;
639  }
640  if (parameter == "xup") {
641  auto axis = histogram->GetXaxis();
642  axis->Set(axis->GetNbins(), axis->GetXmin(), stod(value));
643  return;
644  }
645  if (parameter == "xTitle") {
646  histogram->GetXaxis()->SetTitle(value.c_str());
647  return;
648  }
649  if (parameter == "yTitle") {
650  histogram->GetYaxis()->SetTitle(value.c_str());
651  return;
652  }
653 
654  if (dynamic_cast<TH2F*>(histogram) == nullptr) {
655  B2WARNING("Parameter " + parameter + " not found in histogram " + histogram->GetName() + ", parameter change is skipped in " +
656  getName() + ".");
657  return;
658  }
659 
660  if (parameter == "nbinsy") {
661  auto axis = histogram->GetYaxis();
662  axis->Set(stoi(value), axis->GetXmin(), axis->GetXmax());
663  return;
664  }
665  if (parameter == "ylow") {
666  auto axis = histogram->GetYaxis();
667  axis->Set(axis->GetNbins(), stod(value), axis->GetXmax());
668  return;
669  }
670  if (parameter == "yup") {
671  auto axis = histogram->GetYaxis();
672  axis->Set(axis->GetNbins(), axis->GetXmin(), stod(value));
673  return;
674  }
675  if (parameter == "zTitle") {
676  histogram->GetZaxis()->SetTitle(value.c_str());
677  return;
678  }
679 
680  B2WARNING("Parameter " + parameter + " not found in histogram " + histogram->GetName() + ", parameter change is skipped in " +
681  getName() + ".");
682 }
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.
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.
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 FillUBResidualsSVD(TVector3 residual_um)
Fill histograms with unbiased residuals in SVD sensors.
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.
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 FillHalfShellsPXD(TVector3 globalResidual_um, bool isNotYang)
Fill histograms with unbiased residuals for half-shells for PXD 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 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).
virtual void FillUBResidualsPXD(TVector3 residual_um)
Fill histograms with unbiased residuals in PXD sensors.
virtual void FillUB2DResidualsSensor(TVector3 residual_um, int sensorIndex)
Fill 2D histograms with unbiased residuals for individual sensors.
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_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.
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_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.
virtual void FillHalfShellsSVD(TVector3 globalResidual_um, bool isNotMat)
Fill histograms with unbiased residuals for half-shells for SVD sensors.
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.
virtual void FillUB1DResidualsSensor(TVector3 residual_um, int sensorIndex)
Fill 1D histograms with unbiased residuals for individual sensors.
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 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 corelations 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 DefineHelixParametersAndCorrelations()
Define histograms with helix parameters and their correlations.
TH1F * m_Z0
z0 - the z0 coordinate of the perigee (beam spot position)
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
@ 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
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
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.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
double getTanLambda() const
Getter for tanLambda.
double getZ0() const
Getter for z0.
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:175
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition: GeoCache.h:147
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
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
virtual double getPVal() const
Get the p value of the fit.
Definition: FitStatus.h:128
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:120
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:122
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.