Belle II Software  release-06-02-00
TrackingExpressRecoDQMModule.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/modules/trackingDQM/TrackingExpressRecoDQMModule.h>
10 #include <tracking/modules/trackingDQM/TrackDQMEventProcessor.h>
11 #include <tracking/dqmUtils/HistogramFactory.h>
12 
13 #include <TDirectory.h>
14 
15 using namespace Belle2;
16 using namespace Belle2::HistogramFactory;
17 using namespace std;
18 using boost::format;
19 
20 //-----------------------------------------------------------------
21 // Register the Module
22 //-----------------------------------------------------------------
23 
24 REG_MODULE(TrackingExpressRecoDQM)
25 
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
31 {
32  setPropertyFlags(c_ParallelProcessingCertified);
33  setDescription("Data Quality Monitoring of the tracking run on ExpressReco.");
34  addParam("produce1Dresiduals", m_produce1Dres, "If True, produce 1D residual plots for each VXD sensor", m_produce1Dres);
35  addParam("produce2Dresiduals", m_produce2Dres, "If True, produce 2D residual plots for each VXD sensor", m_produce2Dres);
36  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory for the histograms", m_histogramDirectoryName);
37  addParam("histogramTitleSuffix", m_histogramTitleSuffix,
38  "Optional suffix to be appended to the title of the histograms."
39  " Applied only to those histograms whose content depend on the track StoreArray chosen.",
40  m_histogramTitleSuffix);
41 }
42 
43 //------------------------------------------------------------------
44 // Function to define histograms
45 //-----------------------------------------------------------------
46 
48 {
50  m_eventLevelTrackingInfo.isOptional();
51 }
52 
54 {
56 
57  if (VXD::GeoCache::getInstance().getGeoTools()->getNumberOfLayers() == 0)
58  B2FATAL("Missing geometry for VXD.");
59 
60  // Create a separate histogram directories and cd into it.
61  TDirectory* originalDirectory = gDirectory;
62 
63  TDirectory* TracksDQM = originalDirectory->GetDirectory(m_histogramDirectoryName.c_str());
64  if (!TracksDQM)
65  TracksDQM = originalDirectory->mkdir(m_histogramDirectoryName.c_str());
66 
67  TracksDQM->cd();
68  DefineTracks();
69  DefineHits();
70  DefineHelixParametersAndCorrelations();
71  DefineTrackFitStatus();
72  DefineTRClusters();
73  DefineUBResidualsVXD();
74  DefineHalfShellsVXD();
75 
76  DefineAbortFlagsHistograms();
77  if (m_produce1Dres)
78  Define1DSensors();
79  if (m_produce2Dres)
80  Define2DSensors();
81 
82  originalDirectory->cd();
83 
84  for (auto change : m_histogramParameterChanges)
85  ProcessHistogramParameterChange(get<0>(change), get<1>(change), get<2>(change));
86 
87  // Add the title suffix (if a suffix was provided via the module parameter)
88  for (TH1* hist : m_histograms) {
89  // Skip histograms whose content does *not* depend on the list (StoreArray)
90  // of tracks used as input to this module
91  if (hist->GetName() == string("NumberTrackingErrorFlags"))
92  continue;
93  if (hist->GetName() == string("TrackingErrorFlagsReasons"))
94  continue;
95  string newTitle = hist->GetTitle() + m_histogramTitleSuffix;
96  hist->SetTitle(newTitle.c_str());
97  }
98 }
99 
101 {
103  if (!histogramsDefined)
104  return;
105 
106  bool runningOnHLT = false;
107 
108  TrackDQMEventProcessor eventProcessor = TrackDQMEventProcessor(this, m_recoTracksStoreArrayName, m_tracksStoreArrayName,
109  runningOnHLT);
110 
111  if (m_produce2Dres)
112  eventProcessor.produce2Dres();
113  if (m_produce1Dres)
114  eventProcessor.produce1Dres();
115 
116  eventProcessor.Run();
117 
118  if (m_eventLevelTrackingInfo.isValid()) {
119  if (m_eventLevelTrackingInfo->hasAnErrorFlag()) {
120  m_trackingErrorFlags->Fill(1);
121  if (m_eventLevelTrackingInfo->hasUnspecifiedTrackFindingFailure())
122  m_trackingErrorFlagsReasons->Fill(1);
123  if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
124  m_trackingErrorFlagsReasons->Fill(2);
125  if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
126  m_trackingErrorFlagsReasons->Fill(3);
127  if (m_eventLevelTrackingInfo->hasPXDCKFAbortionFlag())
128  m_trackingErrorFlagsReasons->Fill(4);
129  if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag())
130  m_trackingErrorFlagsReasons->Fill(5);
131  } else {
132  m_trackingErrorFlags->Fill(0);
133  m_trackingErrorFlagsReasons->Fill(0);
134  }
135  } else
136  m_trackingErrorFlags->Fill(0);
137 }
138 
140 {
141  // only monitor if any flag was set so only 2 bins needed
142  m_trackingErrorFlags =
143  Create("NumberTrackingErrorFlags",
144  "Tracking error summary. Mean = errors/event (should be 0 or very close to 0);Error occured yes or no;Number of events",
145  2, -0.5, 1.5, "Error occured yes or no", "Number of events");
146  m_trackingErrorFlags->GetXaxis()->SetBinLabel(1, "No Error");
147  m_trackingErrorFlags->GetXaxis()->SetBinLabel(2, "Error occured");
148 
149 
150  m_trackingErrorFlagsReasons =
151  Create("TrackingErrorFlagsReasons",
152  "Tracking errors by reason. A single event may fall in multiple bins.;Type of error occurred;Number of events",
153  6, -0.5, 5.5, "Type of error occurred", "Number of events");
154  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(1, "No Error");
155  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(2, "Unspecified PR");
156  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(3, "VXDTF2");
157  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(4, "SVDCKF");
158  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(5, "PXDCKF");
159  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(6, "SpacePoint");
160 
161 }
void produce1Dres()
Call this if you want to produce 1D Track Residual plots for each VXD sensor.
virtual void Run()
Call this to start processing the event data and filling histograms.
void produce2Dres()
Call this if you want to produce 2D Track Residual plots for each VXD sensor.
This class serves as a base for the TrackDQMModule and AlignDQMModule (and possibly other DQM histogr...
virtual void initialize() override
Initializer.
virtual void event() override
This method is called for each event.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
The purpose of this class is to process one event() in TrackDQMModule.
void initialize() override
Module functions.
void event() override
fill of the histograms happens here
virtual void DefineAbortFlagsHistograms()
Defines the histograms for the tracking abort flags.
void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
#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.