Belle II Software release-09-00-07
PhysicsObjectsMiraBelleModule.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 <dqm/modules/PhysicsObjectsMiraBelle/PhysicsObjectsMiraBelleModule.h>
10#include <analysis/dataobjects/ParticleList.h>
11#include <analysis/variables/ContinuumSuppressionVariables.h>
12#include <analysis/variables/TrackVariables.h>
13#include <analysis/utility/PCmsLabTransform.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/datastore/StoreArray.h>
16#include <mdst/dataobjects/Track.h>
17#include <mdst/dataobjects/TrackFitResult.h>
18#include <mdst/dataobjects/KLMCluster.h>
19#include <mdst/dataobjects/HitPatternCDC.h>
20#include <mdst/dataobjects/HitPatternVXD.h>
21#include <mdst/dataobjects/EventLevelTrackingInfo.h>
22#include <mdst/dataobjects/PIDLikelihood.h>
23#include <mdst/dataobjects/TRGSummary.h>
24#include <top/variables/TOPDigitVariables.h>
25#include <arich/modules/arichDQM/ARICHDQMModule.h>
26#include <arich/dataobjects/ARICHLikelihood.h>
27#include <klm/dataobjects/KLMMuidLikelihood.h>
28#include <mdst/dataobjects/SoftwareTriggerResult.h>
29#include <TDirectory.h>
30#include <TMath.h>
31#include <map>
32
33using namespace Belle2;
34
35REG_MODULE(PhysicsObjectsMiraBelle);
36
38{
39 setDescription("Monitor Physics Objects Quality");
41
42 addParam("TriggerIdentifierHLT", m_triggerIdentifierHLT,
43 "Trigger identifier string used to select events for the selectmumu efficiency histograms",
44 std::string("software_trigger_cut&filter&total_result"));
45 addParam("TriggerIdentifier", m_triggerIdentifier,
46 "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_mumutight"));
47 addParam("MuPListName", m_muPListName, "Name of the muon particle list", std::string("mu+:physMiraBelle"));
48 addParam("MuMuPListName", m_mumuPListName, "Name of the di-muon particle list", std::string("Upsilon:physMiraBelle"));
49 addParam("Z0PListName", m_Z0PListName, "Name of the di-muon particle list for HLT efficiency", std::string("Z0:physMiraBelle"));
50
51}
52
54{
55 TDirectory* oldDir = gDirectory;
56 oldDir->mkdir("PhysicsObjectsMiraBelle");
57 oldDir->cd("PhysicsObjectsMiraBelle");
58
59 m_h_npxd = new TH1F("hist_npxd", "hist_npxd", 100, 0, 5);
60 m_h_npxd->SetXTitle("hist_npxd");
61 m_h_nsvd = new TH1F("hist_nsvd", "hist_nsvd", 100, 0, 16);
62 m_h_nsvd->SetXTitle("hist_nsvd");
63 m_h_ncdc = new TH1F("hist_ncdc", "hist_ncdc", 100, 0, 80);
64 m_h_ncdc->SetXTitle("hist_ncdc");
65 m_h_topdig = new TH1F("hist_topdig", "hist_topdig", 120, 0, 120);
66 m_h_topdig->SetXTitle("hist_topdig");
67 m_h_DetPhotonARICH = new TH1F("hist_DetPhotonARICH", "hist_DetPhotonARICH", 70, 0, 70);
68 m_h_DetPhotonARICH->SetXTitle("hist_DetPhotonARICH");
69 m_h_klmTotalHits = new TH1F("hist_klmTotalHits", "hist_klmTotalHits", 15, 0, 15);
70 m_h_klmTotalHits->SetXTitle("hist_klmTotalHits");
71 m_h_Pval = new TH1F("hist_Pval", "hist_Pval", 100, 0, 1);
72 m_h_Pval->SetXTitle("hist_Pval");
73 m_h_dD0 = new TH1F("hist_dD0", "hist_dD0", 100, -0.02, 0.02);
74 m_h_dD0->SetXTitle("hist_dD0");
75 m_h_dZ0 = new TH1F("hist_dZ0", "hist_dZ0", 100, -0.05, 0.05);
76 m_h_dZ0->SetXTitle("hist_dZ0");
77 m_h_dPtcms = new TH1F("hist_dPtcms", "hist_dPtcms", 100, -0.5, 0.5);
78 m_h_dPtcms->SetXTitle("hist_dPtcms");
79 m_h_nExtraCDCHits = new TH1F("hist_nExtraCDCHits", "hist_nExtraCDCHits", 500, 0, 5000);
80 m_h_nExtraCDCHits->SetXTitle("hist_nExtraCDCHits");
81 m_h_nECLClusters = new TH1F("hist_nECLClusters", "hist_nECLClusters", 100, 0, 60);
82 m_h_nECLClusters->SetXTitle("hist_nECLClusters");
83 m_h_muid = new TH1F("hist_muid", "hist_muid", 20, 0, 1);
84 m_h_muid->SetXTitle("hist_muid");
85 m_h_inv_p = new TH1F("hist_inv_p", "hist_inv_p", 400, 8, 12);
86 m_h_inv_p->SetXTitle("hist_inv_p");
87 m_h_ndf = new TH1F("hist_ndf", "hist_ndf", 100, 0, 80);
88 m_h_ndf->SetXTitle("hist_ndf");
89 m_h_D0 = new TH1F("hist_D0", "hist_D0", 100, -0.1, 0.1);
90 m_h_D0->SetXTitle("hist_D0");
91 m_h_Z0 = new TH1F("hist_Z0", "hist_Z0", 100, -0.3, 0.3);
92 m_h_Z0->SetXTitle("hist_Z0");
93 m_h_theta = new TH1F("hist_theta", "hist_theta in CMS", 32, 10, 170);
94 m_h_theta->SetXTitle("hist_theta");
95 m_h_theta_lab = new TH1F("hist_theta_lab", "hist_theta in lab frame", 180, 0, 180);
96 m_h_theta_lab->SetXTitle("hist_theta_lab");
97 m_h_Phi0 = new TH1F("hist_Phi0", "hist_Phi0 in lab frame", 72, -180, 180);
98 m_h_Phi0->SetXTitle("hist_Phi0");
99 m_h_Pt = new TH1F("hist_Pt", "hist_Pt", 100, 0, 10);
100 m_h_Pt->SetXTitle("hist_Pt");
101 m_h_Mom = new TH1F("hist_Mom", "hist_Mom", 100, 0, 10);
102 m_h_Mom->SetXTitle("hist_Mom");
103 m_h_klmClusterLayers = new TH1F("hist_klmClusterLayers", "hist_klmClusterLayers", 16, 0, 16);
104 m_h_klmClusterLayers->SetXTitle("hist_klmClusterLayers");
105 m_h_klmTotalBarrelHits = new TH1F("hist_klmTotalBarrelHits", "hist_klmTotalBarrelHits", 16, 0, 16);
106 m_h_klmTotalBarrelHits->SetXTitle("hist_klmTotalBarrelHits");
107 m_h_klmTotalEndcapHits = new TH1F("hist_klmTotalEndcapHits", "hist_klmTotalEndcapHits", 16, 0, 16);
108 m_h_klmTotalEndcapHits->SetXTitle("hist_klmTotalEndcapHits");
109 m_h_dPhicms = new TH1F("hist_dPhicms", "hist_dPhicms: 180#circ - |#phi_{1} - #phi_{2}|", 100, -10, 10);
110 m_h_dPhicms->SetXTitle("hist_dPhicms");
111 m_h_dThetacms = new TH1F("hist_dThetacms", "hist_dThetacms: |#theta_{1} + #theta_{2}| - 180#circ", 100, -10, 10);
112 m_h_dThetacms->SetXTitle("hist_dThetacms");
113 m_h_hltEff = new TH1F("hist_hltEff", "hist_hltEff", 10, 0, 10);
114 m_h_hltEff->SetXTitle("hist_hltEff");
115 m_h_hltEff->GetXaxis()->SetBinLabel(2, "dimuon_ECLMuonPair");
116 m_h_hltEff->GetXaxis()->SetBinLabel(3, "dimuon_ECLMuonPairSelectmumu");
117
118 oldDir->cd();
119}
120
121
123{
124 REG_HISTOGRAM
125
127 result.isOptional();
128}
129
131{
132 m_h_npxd->Reset();
133 m_h_nsvd->Reset();
134 m_h_ncdc->Reset();
135 m_h_topdig->Reset();
136 m_h_DetPhotonARICH->Reset();
137 m_h_klmTotalHits->Reset();
138 m_h_Pval->Reset();
139 m_h_dD0->Reset();
140 m_h_dZ0->Reset();
141 m_h_dPtcms->Reset();
142 m_h_nExtraCDCHits->Reset();
143 m_h_nECLClusters->Reset();
144 m_h_muid->Reset();
145 m_h_inv_p->Reset();
146 m_h_ndf->Reset();
147 m_h_D0->Reset();
148 m_h_Z0->Reset();
149 m_h_theta->Reset();
150 m_h_theta_lab->Reset();
151 m_h_Phi0->Reset();
152 m_h_Pt->Reset();
153 m_h_Mom->Reset();
154 m_h_klmClusterLayers->Reset();
155 m_h_klmTotalBarrelHits->Reset();
156 m_h_klmTotalEndcapHits->Reset();
157 m_h_dPhicms->Reset();
158 m_h_dThetacms->Reset();
159 m_h_hltEff->Reset();
160}
161
163{
164
166 if (!result.isValid()) {
167 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
168 return;
169 }
170
171 const std::map<std::string, int>& results = result->getResults();
172
173 //--- Monitor efficiency of selectmumu filter line with dimuons ---//
174 if (results.find(m_triggerIdentifierHLT) == results.end()) {
175 //Cannot find the m_triggerIdentifierHLT
176 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierHLT);
177 } else {
178
179 // Tag filter line
180 if (results.find(m_filter_singlemuon) != results.end()) {
181 m_singlemuon_tag = (result->getNonPrescaledResult(m_filter_singlemuon) == SoftwareTriggerCutResult::c_accept);
182 }
183
184 // Reference filter line
185 if (results.find(m_filter_selectmumu) != results.end()) {
186 m_selectmumu_tag = (result->getNonPrescaledResult(m_filter_selectmumu) == SoftwareTriggerCutResult::c_accept);
187 }
188
189 // Target filter line
190 if (results.find(m_filter_eclmuonpair) != results.end()) {
192 }
193
194 // L1 lines for back-to-back activity in KLM
195 bool L1_mu_b2b = false;
196 bool L1_mu_eb2b = false;
197
198 StoreObjPtr<TRGSummary> m_trgSummary;
199 if (m_trgSummary.isValid()) {
200 try {
201 L1_mu_b2b = m_trgSummary->testFtdl("mu_b2b");
202 } catch (const std::exception&) {
203 L1_mu_b2b = false;
204 }
205 try {
206 L1_mu_eb2b = m_trgSummary->testFtdl("mu_eb2b");
207 } catch (const std::exception&) {
208 L1_mu_eb2b = false;
209 }
210 }
211
212 //get the di-muons for selectmumu filter efficiency
214 if (Z0Particles.isValid() && Z0Particles->getListSize() > 0) {
215 // Count number of events in different categories
216 if (m_eclmuonpair_tag && m_singlemuon_tag && (L1_mu_b2b || L1_mu_eb2b)) {
217 m_h_hltEff->Fill(1);
219 m_h_hltEff->Fill(2);
220 }
221 }
222 }
223
224 if (results.find(m_triggerIdentifier) == results.end()) {
225 B2WARNING("PhysicsObjectsMiraBelle: Can't find trigger identifier: " << m_triggerIdentifier);
226 return;
227 }
228
229 // apply software trigger
230 const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
231 if (accepted == false) return;
232
233 // for resolution (difference b/w 2 tracks)
234 double d0[2] = {};
235 double z0[2] = {};
236 double ptcms[2] = {};
237 double phicms[2] = {};
238 double thetacms[2] = {};
239
240 //get the di-muons for beam energy check
242 if (UpsParticles.isValid()) {
243 for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
244 Particle* Ups = UpsParticles->getParticle(i);
245 m_h_inv_p->Fill(Ups->getMass());
246 }
247 }
248
249 // get muons
251 for (unsigned int i = 0; i < muParticles->getListSize(); i++) {
252 Particle* mu = muParticles->getParticle(i);
253 const Belle2::Track* track = mu->getTrack();
254 if (!track) {
255 continue;
256 }
257
258 // Detector hits
259 m_h_npxd->Fill(Belle2::Variable::trackNPXDHits(mu));
260 m_h_nsvd->Fill(Belle2::Variable::trackNSVDHits(mu));
261 m_h_ncdc->Fill(Belle2::Variable::trackNCDCHits(mu));
262 m_h_topdig->Fill(Belle2::Variable::TOPVariable::topDigitCount(mu));
263 ARICHLikelihood* lkh = track->getRelated<ARICHLikelihood>();
264 if (lkh) {
265 m_h_DetPhotonARICH->Fill(lkh->getDetPhot());
266 }
267
268 // KLM total hits
269 KLMMuidLikelihood* muid = track->getRelatedTo<KLMMuidLikelihood>();
270 if (muid) {
271 unsigned int bklm_hit = muid->getTotalBarrelHits();
272 unsigned int eklm_hit = muid->getTotalEndcapHits();
273 m_h_klmTotalBarrelHits->Fill(bklm_hit);
274 m_h_klmTotalEndcapHits->Fill(eklm_hit);
275 m_h_klmTotalHits->Fill(bklm_hit + eklm_hit);
276 }
277
278 // KLM Cluster layers
279 KLMCluster* klmc = track->getRelated<KLMCluster>();
280 if (klmc) {
281 m_h_klmClusterLayers->Fill(klmc->getLayers());
282 }
283
284 // muon ID
285 PIDLikelihood* pid_lkh = track->getRelated<PIDLikelihood>();
286 if (pid_lkh) {
288 }
289
290 // Track variables
291 const TrackFitResult* fitresult = track->getTrackFitResult(Belle2::Const::pion);
292 if (fitresult) {
293 // Pvalue
294 double pval = fitresult->getPValue();
295 m_h_Pval->Fill(pval);
296 // separate mu+ and mu-
297 int index = fitresult->getChargeSign() > 0 ? 0 : 1;
298 d0[index] = fitresult->getD0();
299 z0[index] = fitresult->getZ0();
300 m_h_D0->Fill(d0[index]);
301 m_h_Z0->Fill(z0[index]);
302 // Momentum
303 ptcms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Pt();//CMS
304 phicms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Phi() * TMath::RadToDeg();
305 thetacms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Theta() * TMath::RadToDeg();
306 m_h_Pt->Fill(fitresult->get4Momentum().Pt());//Lab
307 m_h_theta->Fill(Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Theta() * TMath::RadToDeg());//CMS
308 m_h_theta_lab->Fill(fitresult->get4Momentum().Theta() * TMath::RadToDeg());//Lab
309 m_h_Phi0->Fill(fitresult->get4Momentum().Phi() * TMath::RadToDeg());//Lab
310 m_h_Mom->Fill(fitresult->get4Momentum().P());//Lab
311 }
312 }
313 // Resolution
314 m_h_dD0->Fill((d0[0] + d0[1]) / sqrt(2));
315 m_h_dZ0->Fill((z0[0] - z0[1]) / sqrt(2));
316 m_h_dPtcms->Fill((ptcms[0] - ptcms[1]) / sqrt(2));
317 m_h_dPhicms->Fill(180 - abs(phicms[0] - phicms[1]));
318 m_h_dThetacms->Fill(abs(thetacms[0] + thetacms[1]) - 180);
319 // Event level information
321 if (elti) {
322 m_h_nExtraCDCHits->Fill(elti->getNCDCHitsNotAssigned());
323 }
324 //nECLClustersLE
325 double neclClusters = -1.;
326 StoreArray<ECLCluster> eclClusters;
327 if (eclClusters.isValid()) {
328 const unsigned int numberOfECLClusters = std::count_if(eclClusters.begin(), eclClusters.end(),
329 [](const ECLCluster & eclcluster) {
330 return (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
331 and eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1);
332 });
333 neclClusters = numberOfECLClusters;
334 }
335 m_h_nECLClusters->Fill(neclClusters);
336}
337
339{
340}
341
343{
344}
345
This is a class to store ARICH likelihoods in the datastore.
float getDetPhot() const
Return number of detected photons for a given particle.
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
ECL cluster data.
Definition: ECLCluster.h:27
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
KLM cluster data.
Definition: KLMCluster.h:28
int getLayers() const
Get number of layers with hits.
Definition: KLMCluster.h:66
Class to store the likelihoods from KLM with additional informations related to the extrapolation.
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
static ROOT::Math::PxPyPzMVector labToCms(const ROOT::Math::PxPyPzMVector &vec)
Transforms Lorentz vector into CM System.
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Definition: PIDLikelihood.h:29
double getProbability(const Const::ChargedStable &p1, const Const::ChargedStable &p2, Const::PIDDetectorSet set=Const::PIDDetectorSet::set()) const
Return combined likelihood probability for a particle being p1 and not p2, assuming equal prior proba...
Class to store reconstructed particles.
Definition: Particle.h:75
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition: Particle.cc:845
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:507
TH1F * m_h_dZ0
histogram for Z0 difference between mu+ and mu-
TH1F * m_h_D0
histogram for D0 of muon track
TH1F * m_h_hltEff
histogram for efficiency of selectmumu filter line
std::string m_muPListName
Name of the mu+ particle list.
TH1F * m_h_Pt
histogram for Pt of muon track
TH1F * m_h_DetPhotonARICH
histogram for number of photon in ARICH associated with muon track
TH1F * m_h_klmTotalEndcapHits
histogram for number of EKLM hits associated with muon track
TH1F * m_h_dPhicms
histogram for phi difference between mu+ and mu- in CMS
TH1F * m_h_Mom
histogram for Momentum of muon track
void event() override
This method is called for each event.
TH1F * m_h_dPtcms
histogram for Pt difference between mu+ and mu-
TH1F * m_h_theta
histogram for theta of muon track
TH1F * m_h_ncdc
histogram for number of CDC hits associated with muon track
std::string m_Z0PListName
Name of the mu+mu- (Z0) particle list.
void endRun() override
This method is called if the current run ends.
TH1F * m_h_npxd
histogram for number of PXD hits associated with muon track
void terminate() override
This method is called at the end of the event processing.
std::string m_triggerIdentifier
Trigger identifier string used to select events for the histograms.
TH1F * m_h_klmTotalBarrelHits
histogram for number of BKLM hits associated with muon track
TH1F * m_h_dThetacms
histogram for theta difference between mu+ and mu- in CMS
void beginRun() override
Called when entering a new run.
TH1F * m_h_theta_lab
histogram for theta of muon track in lab frame
TH1F * m_h_klmTotalHits
histogram for number of KLM hits associated with muon track
std::string m_filter_singlemuon
Trigger identifier string to get filter lines for selectmumu efficiency monitor.
TH1F * m_h_nsvd
histogram for number of SVD hits associated with muon track
bool m_eclmuonpair_tag
Flag for target filter line.
std::string m_mumuPListName
Name of the mu+mu- (Upsilon) particle list.
std::string m_filter_eclmuonpair
Target filter line.
TH1F * m_h_Z0
histogram for Z0 of muon track
TH1F * m_h_nExtraCDCHits
histogram for number of CDC hits not associated with any tracks
TH1F * m_h_dD0
histogram for D0 difference between mu+ and mu-
TH1F * m_h_topdig
histogram for TOP digits associated with muon track
TH1F * m_h_inv_p
histogram for invariant mass of di-muon
std::string m_triggerIdentifierHLT
Trigger identifier string used to select events for selectmumu efficiency monitor.
TH1F * m_h_klmClusterLayers
histogram for number of KLM layers with cluster associated with muon track
TH1F * m_h_Pval
histogram for Pvalue of tracks in CDC
TH1F * m_h_Phi0
histogram for phi of muon track
TH1F * m_h_nECLClusters
histogram for ECL clusters
void defineHisto() override
Definition of the histograms.
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
iterator end()
Return iterator to last entry +1.
Definition: StoreArray.h:320
iterator begin()
Return iterator to first entry.
Definition: StoreArray.h:318
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
Class that bundles various TrackFitResults.
Definition: Track.h:25
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
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
@ c_accept
Accept this event.
Abstract base class for different kinds of events.