Belle II Software  release-06-02-00
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 
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);
42  setPropertyFlags(c_ParallelProcessingCertified);
43 }
44 
45 CDCDQMModule::~CDCDQMModule()
46 {
47 }
48 
49 void CDCDQMModule::defineHisto()
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 
65 void CDCDQMModule::initialize()
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 
78 void CDCDQMModule::beginRun()
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 
92 void CDCDQMModule::event()
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 
154 void CDCDQMModule::endRun()
155 {
156  m_hNEvents->SetBinContent(1, m_nEvents);
157 }
158 
159 void CDCDQMModule::terminate()
160 {
161 }
Make summary of data quality from reconstruction.
Definition: CDCDQMModule.h:41
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.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
@ 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
#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.