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