Belle II Software development
CosmicRayHLTDQMModule.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// File : CosmicRayHLTDQMModule.cc
10// Description : Module to monitor Cosmic Ray on HLT
11//-
12
13#include <hlt/softwaretrigger/modules/dqm/CosmicRayHLTDQMModule.h>
14
15// framework - DataStore
16#include <framework/datastore/StoreArray.h>
17
18#include <mdst/dataobjects/Track.h>
19#include <ecl/dataobjects/ECLShower.h>
20#include <mdst/dataobjects/ECLCluster.h>
21#include <mdst/dataobjects/TrackFitResult.h>
22#include <mdst/dataobjects/HitPatternCDC.h>
23#include <klm/dataobjects/KLMHit2d.h>
24
25#include <TDirectory.h>
26
27#include <string>
28
29using namespace Belle2;
30using namespace SoftwareTrigger;
31
32
33//-----------------------------------------------------------------
34// Register the Module
35//-----------------------------------------------------------------
36REG_MODULE(CosmicRayHLTDQM);
37
38//-----------------------------------------------------------------
39// Implementation
40//-----------------------------------------------------------------
41
43{
44 //Set module properties
45
46 setDescription("Monitor recontruction of cosmic ray on HLT");
48
49 addParam("histogramDirectoryName", m_param_histogramDirectoryName,
50 "Cosmic Ray DQM histograms on HLT will be put into this directory", std::string("CosmicRay_HLT"));
51
52}
53
54CosmicRayHLTDQMModule::~CosmicRayHLTDQMModule()
55{
56}
57
59{
60 // Create a separate histogram directory and cd into it.
61 TDirectory* oldDir = gDirectory;
62 oldDir->mkdir(m_param_histogramDirectoryName.c_str())->cd();
63 //CDC
64 h_d0 = new TH1F("r0", "Signed distance to the POCA in the r-phi plane", 100, -100, 100);
65 h_d0->SetXTitle("r0 (cm)");
66 h_z0 = new TH1F("z0", "z coordinate of the POCA", 100, -500, 500);
67 h_z0->SetXTitle("z0 (cm)");
68 h_phi0 = new TH1F("phi0", "Angle of the transverse momentum in the r-phi plane", 100, -1, 1);
69 h_phi0->SetXTitle("#phi0 (rad.)");
70 h_ncdchits = new TH1F("ncdchits", "Number of CDC hits associated to CDC track", 100, 0, 100);
71 h_ncdchits->SetXTitle("#phi0 (rad.)");
72 h_pValue = new TH1F("pValue", "chi2 probability of the track fit", 100, 0, 1);
73 h_pValue->SetXTitle("chi2 Probability");
74 h_ntrk = new TH1F("ntrk", "number of charged tracks", 10, 0, 10);
75 h_ntrk->SetXTitle("Ntrk");
76 h_p[0] = new TH1F("px", "track momentum in X direction", 100, -10, 10);
77 h_p[0]->SetXTitle("Px (GeV)");
78 h_p[1] = new TH1F("py", "track momentum in Y direction", 100, -10, 10);
79 h_p[1]->SetXTitle("Py (GeV)");
80 h_p[2] = new TH1F("pz", "track momentum in Z direction", 100, -10, 10);
81 h_p[2]->SetXTitle("Pz (GeV)");
82 h_p[3] = new TH1F("p", "track momentum", 100, 0, 20);
83 h_p[3]->SetXTitle("P (GeV)");
84 h_p[4] = new TH1F("pt", "transverse momentum of track", 100, 0, 20);
85 h_p[4]->SetXTitle("Pt (GeV)");
86 h_charge = new TH1F("charge", "the charge of track", 8, -1.5, 2.5);
87 h_charge->SetXTitle("Charge");
88
89 //ECL Clusters
90 h_ncluster = new TH1F("neclcluster", "number of ECL cluster", 30, 0, 30);
91 h_ncluster->SetXTitle("Number of ECL N1 Clusters");
92 h_e_eclcluster = new TH1F("e_ecluster", "energy of ECL cluster", 100, 0, 1.0);
93 h_e_eclcluster->SetXTitle("E (GeV)");
94 h_phi_eclcluster = new TH1F("phi_eclcluster", "phi angle of ECLCluster position", 100, -3.2, 3.2);
95 h_phi_eclcluster->SetXTitle("#phi (rad.)");
96 h_theta_eclcluster = new TH1F("theta_eclcluster", "theta angle of ECLCluster position", 100, 0, 3.2);
97 h_theta_eclcluster->SetXTitle("#theta (rad.)");
98 h_E1oE9_eclcluster = new TH1F("e1v9_eclcluster", "the E1/E9 energy ratio", 100, 0., 1.);
99 h_E1oE9_eclcluster->SetXTitle("E1/E9");
100 h_Time_eclcluster = new TH1F("Time_eclcluster", "the ecl cluster time", 100, -1000., 1000.);
101 h_Time_eclcluster->SetXTitle("Time (ns)");
102
103 // ECL Showers
104 h_nshower = new TH1F("neclshower", "number of ECL showers", 30, 0, 30);
105 h_nshower->SetXTitle("Number of ECL N1 Showers");
106 h_time_eclshower = new TH1F("time_eclshoer", "the ECL shower time", 100, -1000., 1000.);
107 h_time_eclshower->SetXTitle("Time (ns)");
108 h_e_eclshower = new TH1F("e_eshower", "energy of ECL shower", 100, 0, 1.0);
109 h_e_eclshower->SetXTitle("E (GeV)");
110
111 //KLM
112 h_nbklmhit = new TH1F("nbklmhit", "number of 2D hits on barrel KLM", 30, 0, 30);
113 h_nbklmhit->SetXTitle("Nhits (BKLM)");
114 h_layerId_bklmhit = new TH1F("layerId_bklmhit", "layer ID of 2D hits on barrel KLM", 18, 0, 18);
115 h_layerId_bklmhit->SetXTitle("Layer ID (BKLM)");
116 h_sectorId_bklmhit = new TH1F("sectorId_bklmhit", "sector ID of 2D hits on barrel KLM", 10, 0, 10);
117 h_sectorId_bklmhit->SetXTitle("Sector ID (BKLM)");
118 h_neklmhit = new TH1F("neklmhit", "number of 2D hits on endcap KLM", 30, 0, 30);
119 h_neklmhit->SetXTitle("Nhits (EKLM)");
120 h_layerId_eklmhit = new TH1F("layerId_eklmhit", "layer ID of 2D hits on endcap KLM", 18, 0, 18);
121 h_layerId_eklmhit->SetXTitle("Layer ID (EKLM)");
122 h_sectorId_eklmhit = new TH1F("sectorId_eklmhit", "sector ID of 2D hits on endcap KLM", 10, 0, 10);
123 h_sectorId_eklmhit->SetXTitle("Sector ID (EKLM)");
124 oldDir->cd();
125}
126
127
129{
130 // Register histograms (calls back defineHisto)
131 REG_HISTOGRAM
132}
133
135{
136
137//Monitor CDC Tracks
138 StoreArray<Track> tracks;
139 if (tracks.isValid()) {
140 h_ntrk->Fill(tracks.getEntries());
141 for (const auto& track : tracks) {
142 const auto* trackFit = track.getTrackFitResult(Const::muon);
143 if (!trackFit) continue;
144 h_d0->Fill(trackFit->getD0());
145 h_z0->Fill(trackFit->getZ0());
146 h_phi0->Fill(trackFit->getPhi0());
147 h_ncdchits->Fill(trackFit->getHitPatternCDC().getNHits());
148 h_p[0]->Fill((trackFit->getMomentum()).X());
149 h_p[1]->Fill((trackFit->getMomentum()).Y());
150 h_p[2]->Fill((trackFit->getMomentum()).Z());
151 h_p[3]->Fill((trackFit->getMomentum()).R());
152 h_p[4]->Fill((trackFit->getMomentum()).Rho());
153 h_pValue->Fill(trackFit->getPValue());
154 h_charge->Fill(trackFit->getChargeSign());
155 }
156 }
157
158 //Monitor ECL N1 Clusters
159 StoreArray<ECLCluster> eclClusters;
160 if (eclClusters.isValid()) {
161 int nECLClusters = 0;
162 for (const auto& eclCluster : eclClusters) {
163 if (eclCluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) {
164 h_e_eclcluster->Fill(eclCluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons));
165 h_phi_eclcluster->Fill(eclCluster.getPhi());
166 h_theta_eclcluster->Fill(eclCluster.getTheta());
167 h_E1oE9_eclcluster->Fill(eclCluster.getE1oE9());
168 h_Time_eclcluster->Fill(eclCluster.getTime());
169 nECLClusters++;
170 }
171 }
172 h_ncluster->Fill(nECLClusters);
173 }
174
175 // Monitor ECL N1 Showers (without timing and energy cut)
176 StoreArray<ECLShower> eclShowers;
177 if (eclShowers.isValid()) {
178 int nECLShowers = 0;
179 for (const auto& eclShower : eclShowers) {
180 if (eclShower.getHypothesisId() == ECLShower::c_nPhotons) {
181 h_e_eclshower->Fill(eclShower.getEnergy());
182 h_time_eclshower->Fill(eclShower.getTime());
183 nECLShowers++;
184 }
185 }
186 h_nshower->Fill(nECLShowers);
187 }
188
189
190//Monitor KLM
191 StoreArray<KLMHit2d> klmHits;
192 if (klmHits.isValid()) {
193 int nBKLMHits = 0;
194 int nEKLMHits = 0;
195 for (const auto& klmHit : klmHits) {
196 if (klmHit.getSubdetector() == KLMElementNumbers::c_BKLM) {
197 h_layerId_bklmhit->Fill(klmHit.getLayer());
198 h_sectorId_bklmhit->Fill(klmHit.getSector());
199 } else {
200 h_layerId_eklmhit->Fill(klmHit.getLayer());
201 h_sectorId_eklmhit->Fill(klmHit.getSector());
202 }
203 }
204 h_nbklmhit->Fill(nBKLMHits);
205 h_neklmhit->Fill(nEKLMHits);
206 }
207}
static const ChargedStable muon
muon particle
Definition: Const.h:660
@ c_nPhotons
CR is split into n photons (N1)
@ c_nPhotons
CR is split into n photons (N1)
Definition: ECLShower.h:42
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
@ 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
TH1F * h_pValue
chi2 probalility of the track fit
TH1F * h_sectorId_eklmhit
sector ID of hits in eKLM
TH1F * h_sectorId_bklmhit
sector ID of hits in bKLM
TH1F * h_ncdchits
Number of CDC hits associated to CDC track.
virtual void initialize() override
Module functions to be called from main process.
virtual void event() override
Module functions to be called from event process.
TH1F * h_d0
Signed distance to the POCA in the r-phi plane.
TH1F * h_theta_eclcluster
theta angle of ECLCluster position
TH1F * h_phi_eclcluster
phi angle of ECLCluster position
TH1F * h_phi0
Angle of the transverse momentum in the r-phi plane.
std::string m_param_histogramDirectoryName
Directory to put the generated histograms.
TH1F * h_p[5]
momentum information of track
virtual void defineHisto() override
Histogram definition.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
bool isValid() const
Check wether the array was registered.
Definition: StoreArray.h:288
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.