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("produceTRClusterPlots", m_produceTRCluster, "If True, produce 2D track-related Cluster plots (correlations and hitmaps)",
35 addParam("produce1Dresiduals", m_produce1Dres, "If True, produce 1D residual plots for each VXD sensor", m_produce1Dres);
36 addParam("produce2Dresiduals", m_produce2Dres, "If True, produce 2D residual plots for each VXD sensor", m_produce2Dres);
37 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory for the histograms", m_histogramDirectoryName);
38 addParam("histogramTitleSuffix", m_histogramTitleSuffix,
39 "Optional suffix to be appended to the title of the histograms."
40 " Applied only to those histograms whose content depend on the track StoreArray chosen.",
42}
43
44//------------------------------------------------------------------
45// Function to define histograms
46//-----------------------------------------------------------------
47
49{
51 m_eventLevelTrackingInfo.isOptional();
52}
53
55{
57
58 if (VXD::GeoCache::getInstance().getGeoTools()->getNumberOfLayers() == 0)
59 B2FATAL("Missing geometry for VXD.");
60
61 // Create a separate histogram directories and cd into it.
62 TDirectory* originalDirectory = gDirectory;
63
64 TDirectory* TracksDQM = originalDirectory->GetDirectory(m_histogramDirectoryName.c_str());
65 if (!TracksDQM)
66 TracksDQM = originalDirectory->mkdir(m_histogramDirectoryName.c_str());
67
68 TracksDQM->cd();
70 DefineHits();
75
83
84 originalDirectory->cd();
85
86 for (auto change : m_histogramParameterChanges)
87 ProcessHistogramParameterChange(std::get<0>(change), std::get<1>(change), std::get<2>(change));
88
89 // Add the title suffix (if a suffix was provided via the module parameter)
90 for (TH1* hist : m_histograms) {
91 // Skip histograms whose content does *not* depend on the list (StoreArray)
92 // of tracks used as input to this module
93 if (hist->GetName() == std::string("NumberTrackingErrorFlags"))
94 continue;
95 if (hist->GetName() == std::string("TrackingErrorFlagsReasons"))
96 continue;
97 std::string newTitle = hist->GetTitle() + m_histogramTitleSuffix;
98 hist->SetTitle(newTitle.c_str());
99 }
100}
101
103{
106 return;
107
108 bool runningOnHLT = false;
109
112
113 if (m_produce2Dres)
114 eventProcessor.produce2Dres();
115 if (m_produce1Dres)
116 eventProcessor.produce1Dres();
118 eventProcessor.produceTRClusters();
119
120
121 eventProcessor.Run();
122
123 if (m_eventLevelTrackingInfo.isValid()) {
124 if (m_eventLevelTrackingInfo->hasAnErrorFlag()) {
125 m_trackingErrorFlags->Fill(1);
126 if (m_eventLevelTrackingInfo->hasUnspecifiedTrackFindingFailure())
128 if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
130 if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
132 if (m_eventLevelTrackingInfo->hasPXDCKFAbortionFlag())
134 if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag())
136 } else {
137 m_trackingErrorFlags->Fill(0);
139 }
140 } else
141 m_trackingErrorFlags->Fill(0);
142}
143
145{
146 // only monitor if any flag was set so only 2 bins needed
148 Create("NumberTrackingErrorFlags",
149 "Tracking error summary. Mean = errors/event (should be 0 or very close to 0);Error occurred yes or no;Number of events",
150 2, -0.5, 1.5, "Error occurred yes or no", "Number of events");
151 m_trackingErrorFlags->GetXaxis()->SetBinLabel(1, "No Error");
152 m_trackingErrorFlags->GetXaxis()->SetBinLabel(2, "Error occurred");
153
154
156 Create("TrackingErrorFlagsReasons",
157 "Tracking errors by reason. A single event may fall in multiple bins.;Type of error occurred;Number of events",
158 6, -0.5, 5.5, "Type of error occurred", "Number of events");
159 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(1, "No Error");
160 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(2, "Unspecified PR");
161 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(3, "VXDTF2");
162 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(4, "SVDCKF");
163 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(5, "PXDCKF");
164 m_trackingErrorFlagsReasons->GetXaxis()->SetBinLabel(6, "SpacePoint");
165
166}
void produce1Dres()
Call this if you want to produce 1D Track Residual plots for each VXD sensor.
void produceTRClusters()
Call this if you want to produce 2D Track-Related Cluster plots.
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
bool m_produceTRCluster
if True, the module produces the 2D Track-Related Cluster plots
void initialize() override
Module functions.
StoreObjPtr< EventLevelTrackingInfo > m_eventLevelTrackingInfo
Access 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.