Belle II Software development
DQMHistAnalysisTrackingER.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 <dqm/analysis/modules/DQMHistAnalysisTrackingER.h>
10
11#include <TROOT.h>
12
13#include <string>
14
15using namespace std;
16using namespace Belle2;
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
21REG_MODULE(DQMHistAnalysisTrackingER);
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
29{
30
31 setDescription("DQM Analysis Module of the Tracking ER Plots.");
32
33 addParam("onTimeHalfWidth", m_onTimeHalfWidth, "a cluster is on time if within ± onTimeHalfWidth [ns]", float(m_onTimeHalfWidth));
34
35}
36
38{
39
40 gROOT->cd();
41
42 // add MonitoringObject
43 m_monObj = getMonitoringObject("trackingER");
44
45}
46
47
49{
50 // Repeat this for all tracks (no suffix) and tracks from IP (_FromIP suffix)
51 for (const string suffix : {"_FromIP", "_NotFromIP"}) {
52 //compute fraction of tracks with no PXD hits
53 TH1* hNoPXDHits = findHist("TrackingERDQM" + suffix + "/NoOfHitsInTrack_PXD");
54 if (hNoPXDHits != nullptr) {
55 int nTracks = hNoPXDHits->GetEntries();
56 int nTracksNoPXD = hNoPXDHits->GetBinContent(1);
57 if (nTracks > 0)
58 m_monObj->setVariable("tracksNoPXDHit" + suffix, (double)nTracksNoPXD / nTracks);
59 }
60
61 // add average number of tracks per event to Mirabelle
62 TH1* hnTracks = findHist("TrackingERDQM" + suffix + "/NoOfTracks");
63 if (hnTracks != nullptr) {
64 double averageNTracks = hnTracks->GetMean();
65 m_monObj->setVariable("nTracksPerEvent" + suffix, averageNTracks);
66 }
67 TH1* hnVXDTracks = findHist("TrackingERDQM" + suffix + "/NoOfTracksInVXDOnly");
68 if (hnVXDTracks != nullptr) {
69 double averageNVXDTracks = hnVXDTracks->GetMean();
70 m_monObj->setVariable("nVXDTracksPerEvent" + suffix, averageNVXDTracks);
71 }
72 TH1* hnCDCTracks = findHist("TrackingERDQM" + suffix + "/NoOfTracksInCDCOnly");
73 if (hnCDCTracks != nullptr) {
74 double averageNCDCTracks = hnCDCTracks->GetMean();
75 m_monObj->setVariable("nCDCTracksPerEvent" + suffix, averageNCDCTracks);
76 }
77 TH1* hnVXDCDCTracks = findHist("TrackingERDQM" + suffix + "/NoOfTracksInVXDCDC");
78 if (hnVXDCDCTracks != nullptr) {
79 double averageNVXDCDCTracks = hnVXDCDCTracks->GetMean();
80 m_monObj->setVariable("nVXDCDCTracksPerEvent" + suffix, averageNVXDCDCTracks);
81 }
82 }
83
84 //fraction of offtime SVD hits
85 //considering L3V and L456V clusters (separately)
86
87 TH1* hSVDL3VTime = findHist("SVDClsTrk/SVDTRK_ClusterTimeV3");
88 if (hSVDL3VTime != nullptr) {
89 int all = hSVDL3VTime->GetEntries();
90 if (all > 0) {
91 int bin_min = hSVDL3VTime->GetXaxis()->FindBin(-m_onTimeHalfWidth);
92 int bin_max = hSVDL3VTime->GetXaxis()->FindBin(+m_onTimeHalfWidth);
93 int offtime = all - hSVDL3VTime->Integral(bin_min, bin_max);
94 double offtimeL3Hits = (double)offtime / all;
95 m_monObj->setVariable("offtimeL3Hits", offtimeL3Hits);
96 }
97 }
98
99 TH1* hSVDL456VTime = findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
100 if (hSVDL456VTime != nullptr) {
101 int all = hSVDL456VTime->GetEntries();
102 if (all > 0) {
103 int bin_min = hSVDL456VTime->GetXaxis()->FindBin(-m_onTimeHalfWidth);
104 int bin_max = hSVDL456VTime->GetXaxis()->FindBin(+m_onTimeHalfWidth);
105 int offtime = all - hSVDL456VTime->Integral(bin_min, bin_max);
106 double offtimeL456Hits = (double)offtime / all;
107 m_monObj->setVariable("offtimeL456Hits", offtimeL456Hits);
108 }
109 }
110
111 // Compute tracking abort rate for Mirabelle
112 // Using the _FromIP suffix: these histograms are event-based, so it does not make any difference
113 TH1* hAbort = findHist("TrackingERDQM_FromIP/NumberTrackingErrorFlags");
114 TH1* hAbortReasons = findHist("TrackingERDQM_FromIP/TrackingErrorFlagsReasons");
115 if (hAbort != nullptr) {
116 double nEvents = hAbort->GetEntries();
117 if (nEvents > 0) {
118 m_monObj->setVariable("abortRate", hAbort->GetMean());
119 if (hAbortReasons != nullptr) {
120 m_monObj->setVariable("abortRateUnspecifiedPR", hAbortReasons->GetBinContent(2) / nEvents);
121 m_monObj->setVariable("abortRateVXDTF2", hAbortReasons->GetBinContent(3) / nEvents);
122 m_monObj->setVariable("abortRateSVDCKF", hAbortReasons->GetBinContent(4) / nEvents);
123 m_monObj->setVariable("abortRatePXDCKF", hAbortReasons->GetBinContent(5) / nEvents);
124 m_monObj->setVariable("abortRateSpacePoint", hAbortReasons->GetBinContent(6) / nEvents);
125
126 // Scale the bin contents to contain relative instead of absolute values.
127 for (int i = 1; i <= 6; i++) {
128 hAbortReasons->SetBinContent(i, hAbortReasons->GetBinContent(i) / nEvents);
129 }
130 }
131 }
132 }
133}
The base class for the histogram analysis module.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void initialize() override final
Module function initialize.
float m_onTimeHalfWidth
[ns], cluster is on time if within ± onTimeHalfWidth
MonitoringObject * m_monObj
Monitoring Object to be produced by this module, which contain defined canvases and monitoring variab...
void event() override final
Module function event.
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.