Belle II Software  release-08-00-10
CDCDQMModule.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 // Own include
10 #include <cdc/modules/cdcDQM/CDCDQMModule.h>
11 
12 // CDC
13 
14 // Dataobject classes
15 #include <framework/database/DBObjPtr.h>
16 
17 #include <TF1.h>
18 #include <TVector3.h>
19 #include <TDirectory.h>
20 
21 #include <fstream>
22 #include <math.h>
23 
24 #include <cdc/dataobjects/WireID.h>
25 #include <cdc/geometry/CDCGeometryPar.h>
26 
27 using namespace std;
28 using namespace Belle2;
29 using namespace CDC;
30 
31 //-----------------------------------------------------------------
32 // Register module
33 //-----------------------------------------------------------------
34 
35 REG_MODULE(CDCDQM);
36 
37 CDCDQMModule::CDCDQMModule() : HistoModule()
38 {
39  // set module description (e.g. insert text)
40  setDescription("Make summary of data quality.");
41  addParam("MinHits", m_minHits, "Include only events with more than MinHits hits in ARICH", 0);
43 }
44 
46 {
47 }
48 
50 {
51 
52  TDirectory* oldDir = gDirectory;
53 
54  oldDir->mkdir("CDC");
55  oldDir->cd("CDC");
56  m_hNEvents = new TH1F("hNEvents", "hNEvents", 10, 0, 10);
57  m_hNEvents->GetXaxis()->SetBinLabel(1, "number of events");
58  m_hOcc = new TH1F("hOcc", "hOccupancy", 150, 0, 1.5);
59  m_hADC = new TH2F("hADC", "hADC", 300, 0, 300, 200, 0, 1000);
60  m_hTDC = new TH2F("hTDC", "hTDC", 300, 0, 300, 1000, 4200, 5200);
61  m_hHit = new TH2F("hHit", "hHit", 56, 0, 56, 400, 0, 400);
62  oldDir->cd();
63 }
64 
66 {
67  REG_HISTOGRAM
68  m_cdcHits.isOptional();
69  m_cdcRawHits.isOptional();
70  m_trgSummary.isOptional();
71 
72  if (!m_Tracks.isOptional()) {
73  B2WARNING("Missing Tracks array");
74  return;
75  }
76 }
77 
79 {
80  if (!m_RecoTracks.isOptional()) {
81  B2DEBUG(22, "Missing recoTracks array in beginRun() ");
82  return;
83  }
84 
85  m_hNEvents->Reset();
86  m_hADC->Reset();
87  m_hTDC->Reset();
88  m_hHit->Reset();
89  m_hOcc->Reset();
90 }
91 
93 {
94  static CDCGeometryPar& cdcgeo = CDCGeometryPar::Instance();
95  const int nWires = 14336;
96  setReturnValue(1);
97  if (!m_trgSummary.isValid() || (m_trgSummary->getTimType() == Belle2::TRGSummary::TTYP_RAND)) {
98  setReturnValue(0);
99  return;
100  }
101 
102  if (m_cdcHits.getEntries() < m_minHits) {
103 
104  setReturnValue(0); return;
105  }
106  m_nEvents += 1;
107  m_hOcc->Fill(static_cast<float>(m_cdcHits.getEntries()) / nWires);
108 
109  for (const auto& hit : m_cdcHits) {
110  int lay = hit.getICLayer();
111  int wire = hit.getIWire();
112  m_hHit->Fill(lay, wire);
113  }
114 
115  // ADC vs layer 2D histogram with only good track related hits
116  for (const auto& b2track : m_Tracks) {
117  const Belle2::TrackFitResult* fitresult = b2track.getTrackFitResultWithClosestMass(Const::pion);
118  if (!fitresult) {
119  B2WARNING("No track fit result found.");
120  continue;
121  }
122 
123  Belle2::RecoTrack* track = b2track.getRelatedTo<Belle2::RecoTrack>(m_recoTrackArrayName);
124  if (!track) {
125  B2WARNING("Can not access RecoTrack of this Belle2::Track");
126  continue;
127  }
128  const genfit::FitStatus* fs = track->getTrackFitStatus();
129  if (!fs) continue;
130  int ndf = fs->getNdf();
131  if (ndf < 20) continue; // require high NDF track
132 
133  // Fill histograms of ADC/TDC if hits are associated with track
134  for (const RecoHitInformation::UsedCDCHit* hit : track->getCDCHitList()) {
135  const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(hit));
136  if (!tp) continue;
137  UChar_t lay = hit->getICLayer();
138  UShort_t IWire = hit->getIWire();
139  UShort_t adc = hit->getADCCount();
140  unsigned short tdc = hit->getTDCCount();
141  unsigned short tot = hit->getTOT();
142  WireID wireid(lay, IWire);
143  unsigned short bid = cdcgeo.getBoardID(wireid);
144  if (tot > 4) {
145  m_hADC->Fill(bid, adc);
146  }
147  if (adc > 50 && tot > 1) {
148  m_hTDC->Fill(bid, tdc);
149  }
150  }
151  }
152 }
153 
155 {
156  m_hNEvents->SetBinContent(1, m_nEvents);
157 }
158 
160 {
161 }
std::string m_recoTrackArrayName
Belle2::RecoTrack StoreArray name.
Definition: CDCDQMModule.h:97
void initialize() override
Initialize the Module.
Definition: CDCDQMModule.cc:65
int m_minHits
Minimum hits for processing.
Definition: CDCDQMModule.h:105
void event() override
Event processor.
Definition: CDCDQMModule.cc:92
StoreArray< CDCRawHit > m_cdcRawHits
CDC raw hits.
Definition: CDCDQMModule.h:93
void endRun() override
End-of-run action.
StoreObjPtr< TRGSummary > m_trgSummary
Trigger summary.
Definition: CDCDQMModule.h:94
void terminate() override
Termination action.
TH1F * m_hNEvents
Histogram of num.
Definition: CDCDQMModule.h:100
TH2F * m_hTDC
Histogram of TDC with track associated hits for all boards (0-299)
Definition: CDCDQMModule.h:102
void beginRun() override
Called when entering a new run.
Definition: CDCDQMModule.cc:78
StoreArray< CDCHit > m_cdcHits
CDC hits.
Definition: CDCDQMModule.h:92
virtual ~CDCDQMModule()
Destructor.
Definition: CDCDQMModule.cc:45
TH2F * m_hADC
Histogram of ADC with track associated hits for all boards (0-299)
Definition: CDCDQMModule.h:101
TH1F * m_hOcc
Histogram of occupancy.
Definition: CDCDQMModule.h:104
StoreArray< RecoTrack > m_RecoTracks
RecoTracks.
Definition: CDCDQMModule.h:96
StoreArray< Track > m_Tracks
Tracks.
Definition: CDCDQMModule.h:95
TH2F * m_hHit
Histogram of hits for all layers (0-55)
Definition: CDCDQMModule.h:103
void defineHisto() override
Histogram definitions.
Definition: CDCDQMModule.cc:49
Long64_t m_nEvents
Number of events processed.
Definition: CDCDQMModule.h:99
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
The Class for CDC Geometry Parameters.
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
static const ChargedStable pion
charged pion particle
Definition: Const.h:652
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
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
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
@ 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
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
@ TTYP_RAND
random trigger events
Definition: TRGSummary.h:67
Values of the result of a track fit with a given particle hypothesis.
Class to identify a wire inside the CDC.
Definition: WireID.h:34
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
double getNdf() const
Get the degrees of freedom of the fit.
Definition: FitStatus.h:122
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:46
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.