Belle II Software development
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
15using namespace Belle2;
16using namespace Belle2::HistogramFactory;
17using boost::format;
18
19//-----------------------------------------------------------------
20// Register the Module
21//-----------------------------------------------------------------
22
23REG_MODULE(TrackingExpressRecoDQM);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
32 setDescription("Data Quality Monitoring of the tracking run on ExpressReco.");
33 addParam("produce1Dresiduals", m_produce1Dres, "If True, produce 1D residual plots for each VXD sensor", m_produce1Dres);
34 addParam("produce2Dresiduals", m_produce2Dres, "If True, produce 2D residual plots for each VXD sensor", m_produce2Dres);
35 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory for the histograms", m_histogramDirectoryName);
36 addParam("histogramTitleSuffix", m_histogramTitleSuffix,
37 "Optional suffix to be appended to the title of the histograms."
38 " Applied only to those histograms whose content depend on the track StoreArray chosen.",
40}
41
42//------------------------------------------------------------------
43// Function to define histograms
44//-----------------------------------------------------------------
45
47{
49 m_eventLevelTrackingInfo.isOptional();
50}
51
53{
55
56 if (VXD::GeoCache::getInstance().getGeoTools()->getNumberOfLayers() == 0)
57 B2FATAL("Missing geometry for VXD.");
58
59 // Create a separate histogram directories and cd into it.
60 TDirectory* originalDirectory = gDirectory;
61
62 TDirectory* TracksDQM = originalDirectory->GetDirectory(m_histogramDirectoryName.c_str());
63 if (!TracksDQM)
64 TracksDQM = originalDirectory->mkdir(m_histogramDirectoryName.c_str());
65
66 TracksDQM->cd();
68 DefineHits();
74
80
81 originalDirectory->cd();
82
83 for (auto change : m_histogramParameterChanges)
84 ProcessHistogramParameterChange(std::get<0>(change), std::get<1>(change), std::get<2>(change));
85
86 // Add the title suffix (if a suffix was provided via the module parameter)
87 for (TH1* hist : m_histograms) {
88 // Skip histograms whose content does *not* depend on the list (StoreArray)
89 // of tracks used as input to this module
90 if (hist->GetName() == std::string("NumberTrackingErrorFlags"))
91 continue;
92 if (hist->GetName() == std::string("TrackingErrorFlagsReasons"))
93 continue;
94 std::string newTitle = hist->GetTitle() + m_histogramTitleSuffix;
95 hist->SetTitle(newTitle.c_str());
96 }
97}
98
100{
103 return;
104
105 bool runningOnHLT = false;
106
109
110 if (m_produce2Dres)
111 eventProcessor.produce2Dres();
112 if (m_produce1Dres)
113 eventProcessor.produce1Dres();
114
115 eventProcessor.Run();
116
117 if (m_eventLevelTrackingInfo.isValid()) {
118 if (m_eventLevelTrackingInfo->hasAnErrorFlag()) {
119 m_trackingErrorFlags->Fill(1);
120 if (m_eventLevelTrackingInfo->hasUnspecifiedTrackFindingFailure())
122 if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
124 if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
126 if (m_eventLevelTrackingInfo->hasPXDCKFAbortionFlag())
128 if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag())
130 } else {
131 m_trackingErrorFlags->Fill(0);
133 }
134 } else
135 m_trackingErrorFlags->Fill(0);
136}
137
139{
140 // only monitor if any flag was set so only 2 bins needed
142 Create("NumberTrackingErrorFlags",
143 "Tracking error summary. Mean = errors/event (should be 0 or very close to 0);Error occured yes or no;Number of events",
144 2, -0.5, 1.5, "Error occured yes or no", "Number of events");
145 m_trackingErrorFlags->GetXaxis()->SetBinLabel(1, "No Error");
146 m_trackingErrorFlags->GetXaxis()->SetBinLabel(2, "Error occured");
147
148
150 Create("TrackingErrorFlagsReasons",
151 "Tracking errors by reason. A single event may fall in multiple bins.;Type of error occurred;Number of events",
152 6, -0.5, 5.5, "Type of error occurred", "Number of events");
153 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(1, "No Error");
154 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(2, "Unspecified PR");
155 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(3, "VXDTF2");
156 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(4, "SVDCKF");
157 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(5, "PXDCKF");
158 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(6, "SpacePoint");
159
160}
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 Define1DSensors()
Define 1D histograms with unbiased residuals for individual sensors.
bool histogramsDefined
True if the defineHisto() was called.
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.
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.
void ProcessHistogramParameterChange(const std::string &name, const std::string &parameter, const std::string &value)
Process one change in histogram parameters.
virtual void event() override
This method is called for each event.
virtual void DefineTrackFitStatus()
Define histograms which require FitStatus.
std::string m_tracksStoreArrayName
StoreArray name where Tracks are written.
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 DefineHits()
Define histograms with numbers of hits.
virtual void DefineTracks()
All the following Define- functions should be used in the defineHisto() function to define histograms...
virtual void Define2DSensors()
Define 2D histograms with unbiased residuals for individual sensors.
void runningOnHLT()
function called when the module is run on HLT
std::string m_recoTracksStoreArrayName
StoreArray name where RecoTracks are written.
virtual void DefineHelixParametersAndCorrelations()
Define histograms with helix parameters and their correlations.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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
The purpose of this class is to process one event() in TrackDQMModule.
TH1F * m_trackingErrorFlagsReasons
Monitors the Error flags set by the tracking code.
bool m_produce1Dres
if True, the module produces the 1D Track Residual plot for each VXD sensor
void initialize() override
Module functions.
StoreObjPtr< EventLevelTrackingInfo > m_eventLevelTrackingInfo
Acccess to the EventLevelTrackingInfo object in the datastore.
void event() override
fill of the histograms happens here
TH1F * m_trackingErrorFlags
Monitors the Error flags set by the tracking code.
bool m_produce2Dres
if True, the module produces the 2D Track Residual plot for each VXD sensor
std::string m_histogramDirectoryName
Name of the directory for the histograms.
virtual void DefineAbortFlagsHistograms()
Defines the histograms for the tracking abort flags.
std::string m_histogramTitleSuffix
Optional suffix for the histogram's title.
void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
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.