Belle II Software  release-06-00-14
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 }
38 
39 //------------------------------------------------------------------
40 // Function to define histograms
41 //-----------------------------------------------------------------
42 
44 {
46  m_eventLevelTrackingInfo.isOptional();
47 }
48 
50 {
52 
53  if (VXD::GeoCache::getInstance().getGeoTools()->getNumberOfLayers() == 0)
54  B2FATAL("Missing geometry for VXD.");
55 
56  // Create a separate histogram directories and cd into it.
57  TDirectory* originalDirectory = gDirectory;
58 
59  TDirectory* TracksDQM = originalDirectory->GetDirectory(m_histogramDirectoryName.c_str());
60  if (!TracksDQM)
61  TracksDQM = originalDirectory->mkdir(m_histogramDirectoryName.c_str());
62 
63  TracksDQM->cd();
64  DefineTracks();
65  DefineHits();
66  DefineHelixParametersAndCorrelations();
67  DefineTrackFitStatus();
68  DefineTRClusters();
69  DefineUBResidualsVXD();
70  DefineHalfShellsVXD();
71 
72  DefineAbortFlagsHistograms();
73  if (m_produce1Dres)
74  Define1DSensors();
75  if (m_produce2Dres)
76  Define2DSensors();
77 
78  originalDirectory->cd();
79 
80  for (auto change : m_histogramParameterChanges)
81  ProcessHistogramParameterChange(get<0>(change), get<1>(change), get<2>(change));
82 }
83 
85 {
87  if (!histogramsDefined)
88  return;
89 
90  bool runningOnHLT = false;
91 
92  TrackDQMEventProcessor eventProcessor = TrackDQMEventProcessor(this, m_recoTracksStoreArrayName, m_tracksStoreArrayName,
93  runningOnHLT);
94 
95  if (m_produce2Dres)
96  eventProcessor.produce2Dres();
97  if (m_produce1Dres)
98  eventProcessor.produce1Dres();
99 
100  eventProcessor.Run();
101 
102  if (m_eventLevelTrackingInfo.isValid()) {
103  if (m_eventLevelTrackingInfo->hasAnErrorFlag()) {
104  m_trackingErrorFlags->Fill(1);
105  if (m_eventLevelTrackingInfo->hasUnspecifiedTrackFindingFailure())
106  m_trackingErrorFlagsReasons->Fill(1);
107  if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
108  m_trackingErrorFlagsReasons->Fill(2);
109  if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
110  m_trackingErrorFlagsReasons->Fill(3);
111  if (m_eventLevelTrackingInfo->hasPXDCKFAbortionFlag())
112  m_trackingErrorFlagsReasons->Fill(4);
113  if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag())
114  m_trackingErrorFlagsReasons->Fill(5);
115  } else {
116  m_trackingErrorFlags->Fill(0);
117  m_trackingErrorFlagsReasons->Fill(0);
118  }
119  } else
120  m_trackingErrorFlags->Fill(0);
121 }
122 
124 {
125  // only monitor if any flag was set so only 2 bins needed
126  m_trackingErrorFlags =
127  Create("NumberTrackingErrorFlags",
128  "Tracking error summary. Mean = errors/event (should be 0 or very close to 0);Error occured yes or no;Number of events",
129  2, -0.5, 1.5, "Error occured yes or no", "Number of events");
130  m_trackingErrorFlags->GetXaxis()->SetBinLabel(1, "No Error");
131  m_trackingErrorFlags->GetXaxis()->SetBinLabel(2, "Error occured");
132 
133 
134  m_trackingErrorFlagsReasons =
135  Create("TrackingErrorFlagsReasons",
136  "Tracking errors by reason. A single event may fall in multiple bins.;Type of error occurred;Number of events",
137  6, -0.5, 5.5, "Type of error occurred", "Number of events");
138  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(1, "No Error");
139  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(2, "Unspecified PR");
140  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(3, "VXDTF2");
141  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(4, "SVDCKF");
142  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(5, "PXDCKF");
143  m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(6, "SpacePoint");
144 
145 }
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
Module functions.
virtual void event() override
Function to process event record.
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.