Belle II Software  release-06-00-14
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 <top/variables/TOPDigitVariables.h>
24 #include <arich/modules/arichDQM/ARICHDQMModule.h>
25 #include <arich/dataobjects/ARICHLikelihood.h>
26 #include <klm/dataobjects/KLMMuidLikelihood.h>
27 #include <mdst/dataobjects/SoftwareTriggerResult.h>
28 #include <TDirectory.h>
29 #include <map>
30 
31 using namespace Belle2;
32 
33 REG_MODULE(PhysicsObjectsMiraBelle)
34 
36 {
37  setDescription("Monitor Physics Objects Quality");
38  setPropertyFlags(c_ParallelProcessingCertified);
39 
40  addParam("TriggerIdentifier", m_triggerIdentifier,
41  "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_mumutight"));
42  addParam("MuPListName", m_muPListName, "Name of the muon particle list", std::string("mu+:physMiraBelle"));
43  addParam("MuMuPListName", m_mumuPListName, "Name of the di-muon particle list", std::string("Upsilon:physMiraBelle"));
44 }
45 
47 {
48  TDirectory* oldDir = gDirectory;
49  oldDir->mkdir("PhysicsObjectsMiraBelle")->cd();
50 
51  m_h_npxd = new TH1F("hist_npxd", "hist_npxd", 100, 0, 5);
52  m_h_npxd->SetXTitle("hist_npxd");
53  m_h_nsvd = new TH1F("hist_nsvd", "hist_nsvd", 100, 0, 16);
54  m_h_nsvd->SetXTitle("hist_nsvd");
55  m_h_ncdc = new TH1F("hist_ncdc", "hist_ncdc", 100, 0, 80);
56  m_h_ncdc->SetXTitle("hist_ncdc");
57  m_h_topdig = new TH1F("hist_topdig", "hist_topdig", 120, 0, 120);
58  m_h_topdig->SetXTitle("hist_topdig");
59  m_h_DetPhotonARICH = new TH1F("hist_DetPhotonARICH", "hist_DetPhotonARICH", 70, 0, 70);
60  m_h_DetPhotonARICH->SetXTitle("hist_DetPhotonARICH");
61  m_h_klmTotalHits = new TH1F("hist_klmTotalHits", "hist_klmTotalHits", 15, 0, 15);
62  m_h_klmTotalHits->SetXTitle("hist_klmTotalHits");
63  m_h_Pval = new TH1F("hist_Pval", "hist_Pval", 100, 0, 1);
64  m_h_Pval->SetXTitle("hist_Pval");
65  m_h_dD0 = new TH1F("hist_dD0", "hist_dD0", 100, -0.02, 0.02);
66  m_h_dD0->SetXTitle("hist_dD0");
67  m_h_dZ0 = new TH1F("hist_dZ0", "hist_dZ0", 100, -0.05, 0.05);
68  m_h_dZ0->SetXTitle("hist_dZ0");
69  m_h_dPtcms = new TH1F("hist_dPtcms", "hist_dPtcms", 100, -0.5, 0.5);
70  m_h_dPtcms->SetXTitle("hist_dPtcms");
71  m_h_nExtraCDCHits = new TH1F("hist_nExtraCDCHits", "hist_nExtraCDCHits", 100, 0, 1600);
72  m_h_nExtraCDCHits->SetXTitle("hist_nExtraCDCHits");
73  m_h_nECLClusters = new TH1F("hist_nECLClusters", "hist_nECLClusters", 100, 0, 60);
74  m_h_nECLClusters->SetXTitle("hist_nECLClusters");
75  m_h_muid = new TH1F("hist_muid", "hist_muid", 20, 0, 1);
76  m_h_muid->SetXTitle("hist_muid");
77  m_h_inv_p = new TH1F("hist_inv_p", "hist_inv_p", 400, 8, 12);
78  m_h_inv_p->SetXTitle("hist_inv_p");
79  m_h_ndf = new TH1F("hist_ndf", "hist_ndf", 100, 0, 80);
80  m_h_ndf->SetXTitle("hist_ndf");
81  m_h_D0 = new TH1F("hist_D0", "hist_D0", 100, -0.1, 0.1);
82  m_h_D0->SetXTitle("hist_D0");
83  m_h_Z0 = new TH1F("hist_Z0", "hist_Z0", 100, -0.3, 0.3);
84  m_h_Z0->SetXTitle("hist_Z0");
85  m_h_theta = new TH1F("hist_theta", "hist_theta", 36, 10, 170);
86  m_h_theta->SetXTitle("hist_theta");
87  m_h_Phi0 = new TH1F("hist_Phi0", "hist_Phi0", 72, -180, 180);
88  m_h_Phi0->SetXTitle("hist_Phi0");
89  m_h_Pt = new TH1F("hist_Pt", "hist_Pt", 100, 0, 10);
90  m_h_Pt->SetXTitle("hist_Pt");
91  m_h_Mom = new TH1F("hist_Mom", "hist_Mom", 100, 0, 10);
92  m_h_Mom->SetXTitle("hist_Mom");
93  m_h_klmClusterLayers = new TH1F("hist_klmClusterLayers", "hist_klmClusterLayers", 16, 0, 16);
94  m_h_klmClusterLayers->SetXTitle("hist_klmClusterLayers");
95  m_h_klmTotalBarrelHits = new TH1F("hist_klmTotalBarrelHits", "hist_klmTotalBarrelHits", 16, 0, 16);
96  m_h_klmTotalBarrelHits->SetXTitle("hist_klmTotalBarrelHits");
97  m_h_klmTotalEndcapHits = new TH1F("hist_klmTotalEndcapHits", "hist_klmTotalEndcapHits", 16, 0, 16);
98  m_h_klmTotalEndcapHits->SetXTitle("hist_klmTotalEndcapHits");
99  m_h_dPhicms = new TH1F("hist_dPhicms", "hist_dPhicms", 100, -1, 1);
100  m_h_dPhicms->SetXTitle("hist_dPhicms");
101 
102  oldDir->cd();
103 }
104 
105 
107 {
108  REG_HISTOGRAM
109 
111  result.isOptional();
112 }
113 
115 {
116  m_h_npxd->Reset();
117  m_h_nsvd->Reset();
118  m_h_ncdc->Reset();
119  m_h_topdig->Reset();
120  m_h_DetPhotonARICH->Reset();
121  m_h_klmTotalHits->Reset();
122  m_h_Pval->Reset();
123  m_h_dD0->Reset();
124  m_h_dZ0->Reset();
125  m_h_dPtcms->Reset();
126  m_h_nExtraCDCHits->Reset();
127  m_h_nECLClusters->Reset();
128  m_h_muid->Reset();
129  m_h_inv_p->Reset();
130  m_h_ndf->Reset();
131  m_h_D0->Reset();
132  m_h_Z0->Reset();
133  m_h_theta->Reset();
134  m_h_Phi0->Reset();
135  m_h_Pt->Reset();
136  m_h_Mom->Reset();
137  m_h_klmClusterLayers->Reset();
138  m_h_klmTotalBarrelHits->Reset();
139  m_h_klmTotalEndcapHits->Reset();
140  m_h_dPhicms->Reset();
141 }
142 
144 {
145 
147  if (!result.isValid()) {
148  B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
149  return;
150  }
151 
152  const std::map<std::string, int>& results = result->getResults();
153  if (results.find(m_triggerIdentifier) == results.end()) {
154  B2WARNING("PhysicsObjectsMiraBelle: Can't find trigger identifier: " << m_triggerIdentifier);
155  return;
156  }
157 
158  // apply software trigger
159  const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
160  if (accepted == false) return;
161 
162  // for resolution (difference b/w 2 tracks)
163  double d0[2] = {};
164  double z0[2] = {};
165  double ptcms[2] = {};
166  double phicms[2] = {};
167 
168  //get the di-muons for beam energy check
170  if (UpsParticles.isValid()) {
171  for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
172  Particle* Ups = UpsParticles->getParticle(i);
173  m_h_inv_p->Fill(Ups->getMass());
174  }
175  }
176 
177  // get muons
179  for (unsigned int i = 0; i < muParticles->getListSize(); i++) {
180  Particle* mu = muParticles->getParticle(i);
181  const Belle2::Track* track = mu->getTrack();
182  if (!track) {
183  continue;
184  }
185 
186  // Detector hits
187  m_h_npxd->Fill(Belle2::Variable::trackNPXDHits(mu));
188  m_h_nsvd->Fill(Belle2::Variable::trackNSVDHits(mu));
189  m_h_ncdc->Fill(Belle2::Variable::trackNCDCHits(mu));
190  m_h_topdig->Fill(Belle2::Variable::TOPVariable::topDigitCount(mu));
191  ARICHLikelihood* lkh = track->getRelated<ARICHLikelihood>();
192  if (lkh) {
193  m_h_DetPhotonARICH->Fill(lkh->getDetPhot());
194  }
195 
196  // KLM total hits
197  KLMMuidLikelihood* muid = track->getRelatedTo<KLMMuidLikelihood>();
198  if (muid) {
199  unsigned int bklm_hit = muid->getTotalBarrelHits();
200  unsigned int eklm_hit = muid->getTotalEndcapHits();
201  m_h_klmTotalBarrelHits->Fill(bklm_hit);
202  m_h_klmTotalEndcapHits->Fill(eklm_hit);
203  m_h_klmTotalHits->Fill(bklm_hit + eklm_hit);
204  }
205 
206  // KLM Cluster layers
207  KLMCluster* klmc = track->getRelated<KLMCluster>();
208  if (klmc) {
209  m_h_klmClusterLayers->Fill(klmc->getLayers());
210  }
211 
212  // muon ID
213  PIDLikelihood* pid_lkh = track->getRelated<PIDLikelihood>();
214  if (pid_lkh) {
216  }
217 
218  // Track variables
219  const TrackFitResult* fitresult = track->getTrackFitResult(Belle2::Const::pion);
220  if (fitresult) {
221  // Pvalue
222  double pval = fitresult->getPValue();
223  m_h_Pval->Fill(pval);
224  // separate mu+ and mu-
225  int index = fitresult->getChargeSign() > 0 ? 0 : 1;
226  d0[index] = fitresult->getD0();
227  z0[index] = fitresult->getZ0();
228  m_h_D0->Fill(d0[index]);
229  m_h_Z0->Fill(z0[index]);
230  // Momentum
231  ptcms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Pt();//CMS
232  phicms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Phi();
233  m_h_Pt->Fill(fitresult->get4Momentum().Pt());//Lab
234  m_h_theta->Fill(Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Theta());//CMS
235  m_h_Phi0->Fill(fitresult->get4Momentum().Phi());//Lab
236  m_h_Mom->Fill(fitresult->get4Momentum().P());//Lab
237  }
238  }
239  // Resolution
240  m_h_dD0->Fill((d0[0] + d0[1]) / sqrt(2));
241  m_h_dZ0->Fill((z0[0] - z0[1]) / sqrt(2));
242  m_h_dPtcms->Fill((ptcms[0] - ptcms[1]) / sqrt(2));
243  m_h_dPhicms->Fill(180 - abs(phicms[0] - phicms[1]));
244  // Event level information
246  if (elti) {
247  m_h_nExtraCDCHits->Fill(elti->getNCDCHitsNotAssigned());
248  }
249  //nECLClustersLE
250  double neclClusters = -1.;
251  StoreArray<ECLCluster> eclClusters;
252  if (eclClusters.isValid()) {
253  const unsigned int numberOfECLClusters = std::count_if(eclClusters.begin(), eclClusters.end(),
254  [](const ECLCluster & eclcluster) {
255  return (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
256  and eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1);
257  });
258  neclClusters = numberOfECLClusters;
259  }
260  m_h_nECLClusters->Fill(neclClusters);
261 }
262 
264 {
265 }
266 
268 {
269 }
270 
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:541
static const ChargedStable pion
charged pion particle
Definition: Const.h:542
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.
static TLorentzVector labToCms(const TLorentzVector &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:26
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...
Definition: PIDLikelihood.h:83
Class to store reconstructed particles.
Definition: Particle.h:74
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition: Particle.cc:814
float getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:445
TH1F * m_h_dZ0
histogram for Z0 difference between mu+ and mu-
TH1F * m_h_D0
histogram for D0 of muon track
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
void initialize() override
Function for dynamic initialization of module.
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
Function to process event record.
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
void endRun() override
Function to process end_run record.
TH1F * m_h_npxd
histogram for number of PXD hits associated with muon track
void terminate() override
Function to terminate module.
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
void beginRun() override
Function to process begin_run record.
TH1F * m_h_klmTotalHits
histogram for number of KLM hits associated with muon track
TH1F * m_h_nsvd
histogram for number of SVD hits associated with muon track
std::string m_mumuPListName
Name of the mu+mu- (Upsilon) particle list.
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
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
Function to define 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:95
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:110
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.
TLorentzVector 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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
@ c_accept
Accept this event.
Abstract base class for different kinds of events.