Belle II Software development
PhysicsObjectsMiraBelleBhabhaModule.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/PhysicsObjectsMiraBelleBhabhaModule.h>
10#include <analysis/dataobjects/ParticleList.h>
11#include <analysis/variables/TrackVariables.h>
12#include <analysis/utility/PCmsLabTransform.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15#include <mdst/dataobjects/Track.h>
16#include <mdst/dataobjects/TrackFitResult.h>
17#include <mdst/dataobjects/EventLevelTrackingInfo.h>
18#include <mdst/dataobjects/PIDLikelihood.h>
19#include <top/variables/TOPDigitVariables.h>
20#include <arich/dataobjects/ARICHLikelihood.h>
21#include <mdst/dataobjects/SoftwareTriggerResult.h>
22#include <TDirectory.h>
23#include <TMath.h>
24#include <map>
25
26using namespace Belle2;
27
28REG_MODULE(PhysicsObjectsMiraBelleBhabha);
29
31{
32 setDescription("Monitor Physics Objects Quality");
34
35 addParam("TriggerIdentifier", m_triggerIdentifier,
36 "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_bhabha_all"));
37 addParam("ePListName", m_ePListName, "Name of the electron particle list", std::string("e+:physMiraBelle"));
38 addParam("bhabhaPListName", m_bhabhaPListName, "Name of the bhabha events particle list", std::string("Upsilon:ephysMiraBelle"));
39
40}
41
43{
44 TDirectory* oldDir = gDirectory;
45 oldDir->mkdir("PhysicsObjectsMiraBelleBhabha");
46 oldDir->cd("PhysicsObjectsMiraBelleBhabha");
47
48 m_h_npxd = new TH1F("hist_npxd", "hist_npxd", 100, 0, 5);
49 m_h_npxd->SetXTitle("hist_npxd");
50 m_h_nsvd = new TH1F("hist_nsvd", "hist_nsvd", 100, 0, 16);
51 m_h_nsvd->SetXTitle("hist_nsvd");
52 m_h_ncdc = new TH1F("hist_ncdc", "hist_ncdc", 100, 0, 80);
53 m_h_ncdc->SetXTitle("hist_ncdc");
54 m_h_topdig = new TH1F("hist_topdig", "hist_topdig", 120, 0, 120);
55 m_h_topdig->SetXTitle("hist_topdig");
56 m_h_DetPhotonARICH = new TH1F("hist_DetPhotonARICH", "hist_DetPhotonARICH", 70, 0, 70);
57 m_h_DetPhotonARICH->SetXTitle("hist_DetPhotonARICH");
58 m_h_Pval = new TH1F("hist_Pval", "hist_Pval", 100, 0, 1);
59 m_h_Pval->SetXTitle("hist_Pval");
60 m_h_dD0 = new TH1F("hist_dD0", "hist_dD0", 100, -0.02, 0.02);
61 m_h_dD0->SetXTitle("hist_dD0");
62 m_h_dZ0 = new TH1F("hist_dZ0", "hist_dZ0", 100, -0.05, 0.05);
63 m_h_dZ0->SetXTitle("hist_dZ0");
64 m_h_dPtcms = new TH1F("hist_dPtcms", "hist_dPtcms", 100, -0.5, 0.5);
65 m_h_dPtcms->SetXTitle("hist_dPtcms");
66 m_h_nExtraCDCHits = new TH1F("hist_nExtraCDCHits", "hist_nExtraCDCHits", 500, 0, 5000);
67 m_h_nExtraCDCHits->SetXTitle("hist_nExtraCDCHits");
68 m_h_nECLClusters = new TH1F("hist_nECLClusters", "hist_nECLClusters", 100, 0, 60);
69 m_h_nECLClusters->SetXTitle("hist_nECLClusters");
70 m_h_electronid = new TH1F("hist_electronid", "hist_electronid", 20, 0, 1);
71 m_h_electronid->SetXTitle("hist_electronid");
72 m_h_inv_p = new TH1F("hist_inv_p", "hist_inv_p", 400, 0, 12);
73 m_h_inv_p->SetXTitle("hist_inv_p");
74 m_h_ndf = new TH1F("hist_ndf", "hist_ndf", 100, 0, 80);
75 m_h_ndf->SetXTitle("hist_ndf");
76 m_h_D0 = new TH1F("hist_D0", "hist_D0", 100, -0.1, 0.1);
77 m_h_D0->SetXTitle("hist_D0");
78 m_h_Z0 = new TH1F("hist_Z0", "hist_Z0", 100, -0.3, 0.3);
79 m_h_Z0->SetXTitle("hist_Z0");
80 m_h_theta = new TH1F("hist_theta", "hist_theta in CMS", 32, 10, 170);
81 m_h_theta->SetXTitle("hist_theta");
82 m_h_theta_lab = new TH1F("hist_theta_lab", "hist_theta in lab frame", 180, 0, 180);
83 m_h_theta_lab->SetXTitle("hist_theta_lab");
84 m_h_Phi0 = new TH1F("hist_Phi0", "hist_Phi0 in lab frame", 72, -180, 180);
85 m_h_Phi0->SetXTitle("hist_Phi0");
86 m_h_Pt = new TH1F("hist_Pt", "hist_Pt", 100, 0, 10);
87 m_h_Pt->SetXTitle("hist_Pt");
88 m_h_Mom = new TH1F("hist_Mom", "hist_Mom", 100, 0, 10);
89 m_h_Mom->SetXTitle("hist_Mom");
90 m_h_dPhicms = new TH1F("hist_dPhicms", "hist_dPhicms: 180#circ - |#phi_{1} - #phi_{2}|", 100, -10, 10);
91 m_h_dPhicms->SetXTitle("hist_dPhicms");
92 m_h_dThetacms = new TH1F("hist_dThetacms", "hist_dThetacms: |#theta_{1} + #theta_{2}| - 180#circ", 100, -10, 10);
93 m_h_dThetacms->SetXTitle("hist_dThetacms");
94
95 oldDir->cd();
96}
97
98
100{
101 REG_HISTOGRAM
102
104 result.isOptional();
105}
106
108{
109 m_h_npxd->Reset();
110 m_h_nsvd->Reset();
111 m_h_ncdc->Reset();
112 m_h_topdig->Reset();
113 m_h_DetPhotonARICH->Reset();
114 m_h_Pval->Reset();
115 m_h_dD0->Reset();
116 m_h_dZ0->Reset();
117 m_h_dPtcms->Reset();
118 m_h_nExtraCDCHits->Reset();
119 m_h_nECLClusters->Reset();
120 m_h_electronid->Reset();
121 m_h_inv_p->Reset();
122 m_h_ndf->Reset();
123 m_h_D0->Reset();
124 m_h_Z0->Reset();
125 m_h_theta->Reset();
126 m_h_theta_lab->Reset();
127 m_h_Phi0->Reset();
128 m_h_Pt->Reset();
129 m_h_Mom->Reset();
130 m_h_dPhicms->Reset();
131 m_h_dThetacms->Reset();
132}
133
135{
136
138 if (!result.isValid()) {
139 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
140 return;
141 }
142
143 const std::map<std::string, int>& results = result->getResults();
144 if (results.find(m_triggerIdentifier) == results.end()) {
145 B2WARNING("PhysicsObjectsMiraBelleBhabha: Can't find trigger identifier: " << m_triggerIdentifier);
146 return;
147 }
148
149 // apply software trigger
150 const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
151 if (accepted == false) return;
152
153 // for resolution (difference b/w 2 tracks)
154 double d0[2] = {};
155 double z0[2] = {};
156 double ptcms[2] = {};
157 double phicms[2] = {};
158 double thetacms[2] = {};
159
160 //get the bhabha events for beam energy check
162 if (UpsParticles.isValid()) {
163 for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
164 Particle* Ups = UpsParticles->getParticle(i);
165 m_h_inv_p->Fill(Ups->getMass());
166 }
167 }
168
169 // get electrons
170 StoreObjPtr<ParticleList> electronParticles(m_ePListName);
171 for (unsigned int i = 0; i < electronParticles->getListSize(); i++) {
172 Particle* electron = electronParticles->getParticle(i);
173 const Belle2::Track* track = electron->getTrack();
174 if (!track) {
175 continue;
176 }
177
178 // Detector hits
179 m_h_npxd->Fill(Belle2::Variable::trackNPXDHits(electron));
180 m_h_nsvd->Fill(Belle2::Variable::trackNSVDHits(electron));
181 m_h_ncdc->Fill(Belle2::Variable::trackNCDCHits(electron));
182 m_h_topdig->Fill(Belle2::Variable::TOPVariable::topDigitCount(electron));
183 ARICHLikelihood* lkh = track->getRelated<ARICHLikelihood>();
184 if (lkh) {
185 m_h_DetPhotonARICH->Fill(lkh->getDetPhot());
186 }
187
188 // electron ID
189 PIDLikelihood* pid_lkh = track->getRelated<PIDLikelihood>();
190 if (pid_lkh) {
192 }
193
194 // Track variables
195 const TrackFitResult* fitresult = track->getTrackFitResult(Belle2::Const::pion);
196 if (fitresult) {
197 // Pvalue
198 double pval = fitresult->getPValue();
199 m_h_Pval->Fill(pval);
200 // separate electron+ and electron-
201 int index = fitresult->getChargeSign() > 0 ? 0 : 1;
202 d0[index] = fitresult->getD0();
203 z0[index] = fitresult->getZ0();
204 m_h_D0->Fill(d0[index]);
205 m_h_Z0->Fill(z0[index]);
206 // Momentum
207 ptcms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Pt();//CMS
208 phicms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Phi() * TMath::RadToDeg();
209 thetacms[index] = Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Theta() * TMath::RadToDeg();
210 m_h_Pt->Fill(fitresult->get4Momentum().Pt());//Lab
211 m_h_theta->Fill(Belle2::PCmsLabTransform::labToCms(fitresult->get4Momentum()).Theta() * TMath::RadToDeg());//CMS
212 m_h_theta_lab->Fill(fitresult->get4Momentum().Theta() * TMath::RadToDeg());//Lab
213 m_h_Phi0->Fill(fitresult->get4Momentum().Phi() * TMath::RadToDeg());//Lab
214 m_h_Mom->Fill(fitresult->get4Momentum().P());//Lab
215 }
216 }
217 // Resolution
218 m_h_dD0->Fill((d0[0] + d0[1]) / sqrt(2));
219 m_h_dZ0->Fill((z0[0] - z0[1]) / sqrt(2));
220 m_h_dPtcms->Fill((ptcms[0] - ptcms[1]) / sqrt(2));
221 m_h_dPhicms->Fill(180 - abs(phicms[0] - phicms[1]));
222 m_h_dThetacms->Fill(abs(thetacms[0] + thetacms[1]) - 180);
223 // Event level information
225 if (elti) {
226 m_h_nExtraCDCHits->Fill(elti->getNCDCHitsNotAssigned());
227 }
228 //nECLClustersLE
229 double neclClusters = -1.;
230 StoreArray<ECLCluster> eclClusters;
231 if (eclClusters.isValid()) {
232 const unsigned int numberOfECLClusters = std::count_if(eclClusters.begin(), eclClusters.end(),
233 [](const ECLCluster & eclcluster) {
234 return (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
235 and eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1);
236 });
237 neclClusters = numberOfECLClusters;
238 }
239 m_h_nECLClusters->Fill(neclClusters);
240}
241
243{
244}
245
247{
248}
249
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 pion
charged pion particle
Definition: Const.h:661
static const ChargedStable electron
electron particle
Definition: Const.h:659
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
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:76
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition: Particle.cc:916
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:527
TH1F * m_h_dZ0
histogram for Z0 difference between e+ and e-
TH1F * m_h_DetPhotonARICH
histogram for number of photon in ARICH associated with electron track
TH1F * m_h_dPhicms
histogram for phi difference between e+ and e- in CMS
TH1F * m_h_Mom
histogram for Momentum of electron track
void event() override
This method is called for each event.
TH1F * m_h_dPtcms
histogram for Pt difference between e+ and e-
TH1F * m_h_theta
histogram for theta of electron track
TH1F * m_h_ncdc
histogram for number of CDC hits associated with electron track
void endRun() override
This method is called if the current run ends.
TH1F * m_h_npxd
histogram for number of PXD hits associated with electron 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_dThetacms
histogram for theta difference between e+ and e- in CMS
void beginRun() override
Called when entering a new run.
TH1F * m_h_theta_lab
histogram for theta of electron track in lab frame
TH1F * m_h_nsvd
histogram for number of SVD hits associated with electron 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 e+ and e-
TH1F * m_h_topdig
histogram for TOP digits associated with electron track
TH1F * m_h_inv_p
histogram for invariant mass of di-electron
TH1F * m_h_Pval
histogram for Pvalue of tracks in CDC
TH1F * m_h_Phi0
histogram for phi of electron track
std::string m_bhabhaPListName
Name of the e+e- (Upsilon) particle list.
void defineHisto() override
Definition of the histograms.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
bool isValid() const
Check whether 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.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:649
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
@ c_accept
Accept this event.
Abstract base class for different kinds of events.