Belle II Software development
PhysicsObjectsDQMModule.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 : PhysicsObjectsDQMModule.cc
10// Description : Module to monitor physics objects on HLT
11//-
12
13#include <dqm/modules/PhysicsObjectsDQM/PhysicsObjectsDQMModule.h>
14#include <analysis/dataobjects/ParticleList.h>
15#include <analysis/variables/EventShapeVariables.h>
16#include <analysis/ContinuumSuppression/FoxWolfram.h>
17#include <analysis/utility/PCmsLabTransform.h>
18#include <mdst/dataobjects/Track.h>
19#include <framework/datastore/StoreArray.h>
20#include <analysis/ClusterUtility/ClusterUtils.h>
21#include <framework/datastore/StoreObjPtr.h>
22#include <framework/gearbox/Const.h>
23#include <mdst/dataobjects/SoftwareTriggerResult.h>
24#include <hlt/softwaretrigger/calculations/utilities.h>
25#include <TDirectory.h>
26#include <map>
27
28using namespace Belle2;
29
30//-----------------------------------------------------------------
31// Register the Module
32//-----------------------------------------------------------------
33REG_MODULE(PhysicsObjectsDQM);
34
35//-----------------------------------------------------------------
36// Implementation
37//-----------------------------------------------------------------
38
40{
41 //Set module properties
42
43 setDescription("Monitor Physics Objects Quality");
45
46 addParam("TriggerIdentifier", m_triggerIdentifier,
47 "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_hadron"));
48 addParam("TriggerIdentifierMuMu", m_triggerIdentifierMuMu,
49 "Trigger identifier string used to select events for the mumu histograms",
50 std::string("software_trigger_cut&skim&accept_mumutight"));
51 addParam("TriggerIdentifierBhabha", m_triggerIdentifierBhabha,
52 "Trigger identifier string used to select events for the bhabha histograms",
53 std::string("software_trigger_cut&skim&accept_bhabha_all"));
54 addParam("TriggerIdentifierHadronb2", m_triggerIdentifierHadronb2,
55 "Trigger identifier string used to select events for the hadronb2 histograms",
56 std::string("software_trigger_cut&skim&accept_hadronb2"));
57 addParam("PI0PListName", m_pi0PListName, "Name of the pi0 particle list", std::string("pi0:physDQM"));
58 addParam("KS0PListName", m_ks0PListName, "Name of the KS0 particle list", std::string("K_S0:physDQM"));
59 addParam("UpsPListName", m_upsPListName, "Name of the Ups particle list", std::string("Upsilon:physDQM"));
60
61 addParam("UpsBhabhaPListName", m_upsBhabhaPListName, "Name of the Ups bhabha particle list", std::string("Upsilon:ephysDQM"));
62 addParam("UpsHadPListName", m_hadbphysDQM, "Name of the pi hadron particle list", std::string("pi+:hadbphysDQM"));
63}
64
66{
67 TDirectory* oldDir = gDirectory;
68 oldDir->mkdir("PhysicsObjects");
69 oldDir->cd("PhysicsObjects");
70
71 m_h_mKS0 = new TH1F("mKS0", "KS0 Invariant Mass", 20, 0.48, 0.52);
72 m_h_mKS0->SetXTitle("M(K_{S}^{0}) [GeV]");
73
74 m_h_mPI0 = new TH1F("mPI0", "pi0 Invariant Mass", 25, 0.10, 0.15);
75 m_h_mPI0->SetXTitle("M(#pi^{0}) [GeV]");
76
77 m_h_mUPS = new TH1F("mUPS", "Ups Invariant Mass", 500, 9, 12);
78 m_h_mUPS->SetXTitle("M(#mu#mu) [GeV]");
79
80 m_h_R2 = new TH1F("R2", "Event Level R2", 36, 0, 1.2);
81 m_h_R2->SetXTitle("R2");
82
83 m_h_mUPSe = new TH1F("mUPSe", "Ups ee Invariant Mass", 500, 9, 12);
84 m_h_mUPSe->SetXTitle("M(ee) [GeV]");
85
86 m_h_physicsresults = new TH1F("physicsresults", "Event physics results", 10, 0, 10);
87 m_h_physicsresults->SetXTitle("Event physics results");
88 m_h_physicsresults->GetXaxis()->SetBinLabel(2, "Hadron");
89 m_h_physicsresults->GetXaxis()->SetBinLabel(3, "Hadronb2");
90 m_h_physicsresults->GetXaxis()->SetBinLabel(4, "Hadronb2_tight");
91 m_h_physicsresults->GetXaxis()->SetBinLabel(5, "mumu_tight");
92 m_h_physicsresults->GetXaxis()->SetBinLabel(6, "bhabha_all");
93 oldDir->cd();
94}
95
96
98{
99 REG_HISTOGRAM
100
102 result.isOptional();
103}
104
105
107{
108 m_h_mKS0->Reset();
109 m_h_mPI0->Reset();
110 m_h_mUPS->Reset();
111 m_h_R2->Reset();
112 m_h_physicsresults->Reset();
113}
114
115
117{
118}
119
120
122{
123}
124
125
127{
129 if (!result.isValid()) {
130 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
131 return;
132 }
133
134 const std::map<std::string, int>& results = result->getResults();
135
136 if (results.find(m_triggerIdentifier) == results.end()) {
137 //Cannot find the m_triggerIdentifier, move on to mumu
138 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifier);
139 } else {
140 const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
141 if (accepted != false) {
142
143 m_h_physicsresults->Fill(1); //hadron events
144
147
148 double R2 = Belle2::Variable::foxWolframR2(nullptr);
149 m_h_R2->Fill(R2);
150
151 if (pi0Particles.isValid() && abs(pi0Particles->getPDGCode()) == Const::pi0.getPDGCode()) {
152 for (unsigned int i = 0; i < pi0Particles->getListSize(); i++) {
153 Particle* pi0 = pi0Particles->getParticle(i);
154 m_h_mPI0->Fill(pi0->getMass());
155 }
156 }
157 if (ks0Particles.isValid() && abs(ks0Particles->getPDGCode()) == Const::Kshort.getPDGCode()) {
158 for (unsigned int i = 0; i < ks0Particles->getListSize(); i++) {
159 Particle* ks0 = ks0Particles->getParticle(i);
160 m_h_mKS0->Fill(ks0->getMass());
161 }
162 }
163 }
164 }
165 if (results.find(m_triggerIdentifierMuMu) == results.end()) {
166 //Cannot find the m_triggerIdentifierMuMu, stop now
167 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierMuMu);
168 return;
169 } else {
170 const bool accepted = (result->getResult(m_triggerIdentifierMuMu) == SoftwareTriggerCutResult::c_accept);
171 if (accepted != false) {
172 m_h_physicsresults->Fill(4); //mumu events
174 if (UpsParticles.isValid()) {
175 for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
176 Particle* Ups = UpsParticles->getParticle(i);
177 m_h_mUPS->Fill(Ups->getMass());
178 }
179 }
180 }
181 }
182 //bhabha, hadrons
183 if (results.find(m_triggerIdentifierBhabha) == results.end()) {
184 //Cannot find the m_triggerIdentifierBhahba, stop now
185 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierBhabha);
186 return;
187 } else {
188 const bool accepted = (result->getResult(m_triggerIdentifierBhabha) == SoftwareTriggerCutResult::c_accept);
189 if (accepted != false) {
190 m_h_physicsresults->Fill(5); //bhabha events
192 if (UpsbhabhaParticles.isValid()) {
193 for (unsigned int i = 0; i < UpsbhabhaParticles->getListSize(); i++) {
194 Particle* Upse = UpsbhabhaParticles->getParticle(i);
195 m_h_mUPSe->Fill(Upse->getMass());
196 }
197 }
198 }
199 }
200
201 if (results.find(m_triggerIdentifierHadronb2) == results.end()) {
202 //Cannot find the m_triggerIdentifierHadronb2, stop now
203 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierHadronb2);
204 return;
205 } else {
206 const bool accepted = (result->getResult(m_triggerIdentifierHadronb2) == SoftwareTriggerCutResult::c_accept);
207 if (accepted != false) {
208
209 m_h_physicsresults->Fill(2); //hadronb2 events
210
211 //variables for hadronb2 tight
213 std::vector<ROOT::Math::XYZVector> m_pionHadv3;
214 double EsumPiHad = 0.;
215 for (unsigned int i = 0; i < hadpiParticles->getListSize(); i++) {
216 const Particle* parPiHad = hadpiParticles->getParticle(i);
217 ROOT::Math::PxPyPzEVector V4PiHad = PCmsLabTransform::labToCms(parPiHad->get4Vector());
218 m_pionHadv3.push_back(parPiHad->getMomentum());
219 EsumPiHad += V4PiHad.E();
220 }
221 //EnECLClustersLE
222 double eneclClusters = 0.;
223 StoreArray<ECLCluster> eclClusters;
224 ClusterUtils Cl;
225 double EsumGamma = 0.;
226 if (eclClusters.isValid()) {
227 for (int ncl = 0; ncl < eclClusters.getEntries(); ncl++) {
228 if (eclClusters[ncl]->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
229 && eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1) {
230 eneclClusters += eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
231 if (!eclClusters[ncl]->getRelatedFrom<Track>()) {
232 ROOT::Math::PxPyPzEVector V4Gamma_CMS = PCmsLabTransform::labToCms(Cl.Get4MomentumFromCluster(eclClusters[ncl],
234 EsumGamma += V4Gamma_CMS.E();
235 }
236 }
237 }
238 }
239 double visibleEnergyCMSnorm = (EsumPiHad + EsumGamma) / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
240 double EsumCMSnorm = eneclClusters / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
241 FoxWolfram fw(m_pionHadv3);
243 double R2 = fw.getR(2);
244 bool hadronb_tag = visibleEnergyCMSnorm > 0.4 && EsumCMSnorm > 0.2 && R2 < 0.2;
245 if (hadronb_tag) {
246 m_h_physicsresults->Fill(3); //hadronb2 tight events
247 }
248
249 }
250 }
251
252
253
254}
Class to provide momentum-related information from ECLClusters.
Definition: ClusterUtils.h:36
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
Definition: ClusterUtils.cc:25
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ParticleType pi0
neutral pion particle
Definition: Const.h:674
static const ParticleType Kshort
K^0_S particle.
Definition: Const.h:677
@ c_nPhotons
CR is split into n photons (N1)
Class to calculate the Fox-Wolfram moments up to order 8.
Definition: FoxWolfram.h:28
double getR(int i) const
Returns the i-th moment normalized to the 0th-order moment.
Definition: FoxWolfram.h:89
void calculateBasicMoments()
Method to perform the calculation of the moments up to order 4, which are the most relevant ones.
Definition: FoxWolfram.cc:14
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 store reconstructed particles.
Definition: Particle.h:75
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:547
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
Definition: Particle.h:560
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:507
TH1F * m_h_mUPS
Ups invariant mass.
std::string m_ks0PListName
Name of the KS0 particle list.
void initialize() override
Initializer.
void event() override
This method is called for each event.
void endRun() override
This method is called if the current run ends.
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_mPI0
PI0 invariant mass.
TH1F * m_h_mUPSe
Ups ee invariant mass.
void beginRun() override
Called when entering a new run.
TH1F * m_h_physicsresults
event physics results
TH1F * m_h_mKS0
KS0 invariant mass.
std::string m_upsPListName
Name of the Ups particle list.
std::string m_hadbphysDQM
Name of the pi hadron particle list.
std::string m_upsBhabhaPListName
Name of the Ups bhabha particle list.
std::string m_triggerIdentifierHadronb2
Trigger identifier string used to select events for the hadronb2 histograms.
std::string m_triggerIdentifierMuMu
Trigger identifier string used to select events for the mumu histograms.
std::string m_pi0PListName
Name of the pi0 particle list.
void defineHisto() override
Definition of the histograms.
std::string m_triggerIdentifierBhabha
Trigger identifier string used to select events for the ee 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
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
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
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
@ c_accept
Accept this event.
Abstract base class for different kinds of events.