Belle II Software  release-06-01-15
TrackDQMModule.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/TrackDQMModule.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(TrackDQM)
25 
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
31 {
32  setDescription("DQM of finding tracks, their momentum, "
33  "Number of hits in tracks, "
34  "Number of tracks. "
35  );
36 }
37 
38 //------------------------------------------------------------------
39 // Function to define histograms
40 //-----------------------------------------------------------------
41 
43 {
45 
46  // eventLevelTrackingInfo is currently only set by VXDTF2, if VXDTF2 is not in path the StoreObject is not there
47  m_eventLevelTrackingInfo.isOptional();
48 }
49 
51 {
53 
54  if (VXD::GeoCache::getInstance().getGeoTools()->getNumberOfLayers() == 0)
55  B2FATAL("Missing geometry for VXD.");
56 
57  // Create a separate histogram directories and cd into it.
58  TDirectory* originalDirectory = gDirectory;
59 
60  TDirectory* TracksDQM = originalDirectory->GetDirectory("TracksDQM");
61  if (!TracksDQM)
62  TracksDQM = originalDirectory->mkdir("TracksDQM");
63 
64  TDirectory* TracksDQMAlignment = originalDirectory->GetDirectory("TracksDQMAlignment");
65  if (!TracksDQMAlignment)
66  TracksDQMAlignment = originalDirectory->mkdir("TracksDQMAlignment");
67 
68  TracksDQM->cd();
69  DefineTracks();
70  DefineHits();
71  DefineMomentumAngles();
72  DefineMomentumCoordinates();
73  DefineHelixParametersAndCorrelations();
74  DefineTrackFitStatus();
75  DefineTRClusters();
76  DefineUBResidualsVXD();
77  DefineHalfShellsVXD();
78 
79  DefineFlags();
80 
81  TracksDQMAlignment->cd();
82  Define1DSensors();
83  Define2DSensors();
84 
85  originalDirectory->cd();
86 
87  for (auto change : m_histogramParameterChanges)
88  ProcessHistogramParameterChange(get<0>(change), get<1>(change), get<2>(change));
89 }
90 
92 {
94  if (!histogramsDefined)
95  return;
96 
97  TrackDQMEventProcessor eventProcessor = TrackDQMEventProcessor(this, m_recoTracksStoreArrayName, m_tracksStoreArrayName);
98 
99  eventProcessor.Run();
100 
101  if (m_eventLevelTrackingInfo.isValid())
102  m_trackingErrorFlags->Fill((double)m_eventLevelTrackingInfo->hasAnErrorFlag());
103  else
104  m_trackingErrorFlags->Fill(0.0);
105 }
106 
108 {
109  // only monitor if any flag was set so only 2 bins needed
110  const char* flagTitle =
111  "Tracking error summary. Mean = errors/event (should be 0 or very close to 0); Error occured yes or no; Number of events";
112 
113  m_trackingErrorFlags = Create("NumberTrackingErrorFlags", flagTitle, 2, -0.5, 1.5, "", "");
114 
115  m_trackingErrorFlags->GetXaxis()->SetBinLabel(1, "No Error");
116  m_trackingErrorFlags->GetXaxis()->SetBinLabel(2, "Error occured");
117 }
virtual void Run()
Call this to start processing the event data and filling histograms.
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.
DQM of tracks their momentum, Number of hits in tracks, Number of tracks.
virtual void initialize() override
Module functions.
virtual void event() override
This method is called for each event.
virtual void DefineFlags()
All the following Define- functions should be used in the defineHisto() function to define histograms...
virtual 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.