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/variables/BelleVariables.h>
17#include <analysis/ContinuumSuppression/FoxWolfram.h>
18#include <analysis/utility/PCmsLabTransform.h>
19#include <mdst/dataobjects/Track.h>
20#include <framework/datastore/StoreArray.h>
21#include <analysis/ClusterUtility/ClusterUtils.h>
22#include <framework/datastore/StoreObjPtr.h>
23#include <framework/gearbox/Const.h>
24#include <mdst/dataobjects/SoftwareTriggerResult.h>
25#include <mdst/dataobjects/TRGSummary.h>
26#include <hlt/softwaretrigger/calculations/utilities.h>
27#include <TDirectory.h>
28#include <map>
29
30using namespace Belle2;
31
32//-----------------------------------------------------------------
33// Register the Module
34//-----------------------------------------------------------------
35REG_MODULE(PhysicsObjectsDQM);
36
37//-----------------------------------------------------------------
38// Implementation
39//-----------------------------------------------------------------
40
42{
43 //Set module properties
44
45 setDescription("Monitor Physics Objects Quality");
47
48 addParam("TriggerIdentifier", m_triggerIdentifier,
49 "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_hadron"));
50 addParam("TriggerIdentifierMuMu", m_triggerIdentifierMuMu,
51 "Trigger identifier string used to select events for the mumu histograms",
52 std::string("software_trigger_cut&skim&accept_mumutight"));
53 addParam("TriggerIdentifierBhabha", m_triggerIdentifierBhabha,
54 "Trigger identifier string used to select events for the bhabha histograms",
55 std::string("software_trigger_cut&skim&accept_bhabha_all"));
56 addParam("TriggerIdentifierHadronb2", m_triggerIdentifierHadronb2,
57 "Trigger identifier string used to select events for the hadronb2 histograms",
58 std::string("software_trigger_cut&skim&accept_hadronb2"));
59 addParam("TriggerIdentifierHLT", m_triggerIdentifierHLT,
60 "Trigger identifier string used to select events for the HLTprefilter histograms",
61 std::string("software_trigger_cut&filter&total_result"));
62 addParam("PI0PListName", m_pi0PListName, "Name of the pi0 particle list", std::string("pi0:physDQM"));
63 addParam("KS0PListName", m_ks0PListName, "Name of the KS0 particle list", std::string("K_S0:physDQM"));
64 addParam("UpsPListName", m_upsPListName, "Name of the Ups particle list", std::string("Upsilon:physDQM"));
65
66 addParam("UpsBhabhaPListName", m_upsBhabhaPListName, "Name of the Ups bhabha particle list", std::string("Upsilon:ephysDQM"));
67 addParam("UpsHadPListName", m_hadbphysDQM, "Name of the pi hadron particle list", std::string("pi+:hadbphysDQM"));
68}
69
71{
72 TDirectory* oldDir = gDirectory;
73 oldDir->mkdir("PhysicsObjects");
74 oldDir->cd("PhysicsObjects");
75
76 m_h_mKS0 = new TH1F("mKS0", "KS0 Invariant Mass", 20, 0.48, 0.52);
77 m_h_mKS0->SetXTitle("M(K_{S}^{0}) [GeV]");
78
79 m_h_mPI0 = new TH1F("mPI0", "pi0 Invariant Mass", 25, 0.10, 0.15);
80 m_h_mPI0->SetXTitle("M(#pi^{0}) [GeV]");
81
82 m_h_mUPS = new TH1F("mUPS", "Ups Invariant Mass", 500, 9, 12);
83 m_h_mUPS->SetXTitle("M(#mu#mu) [GeV]");
84
85 m_h_R2 = new TH1F("R2", "Event Level R2", 36, 0, 1.2);
86 m_h_R2->SetXTitle("R2");
87
88 m_h_mUPSe = new TH1F("mUPSe", "Ups ee Invariant Mass", 500, 9, 12);
89 m_h_mUPSe->SetXTitle("M(ee) [GeV]");
90
91 m_h_physicsresults = new TH1F("physicsresults", "Event physics results", 10, 0, 10);
92 m_h_physicsresults->SetXTitle("Event physics results");
93 m_h_physicsresults->GetXaxis()->SetBinLabel(2, "Hadron");
94 m_h_physicsresults->GetXaxis()->SetBinLabel(3, "Hadronb2");
95 m_h_physicsresults->GetXaxis()->SetBinLabel(4, "Hadronb2_tight");
96 m_h_physicsresults->GetXaxis()->SetBinLabel(5, "mumu_tight");
97 m_h_physicsresults->GetXaxis()->SetBinLabel(6, "bhabha_all");
98
99// Monitoring variables for prefilter
100 m_h_nKshortAllH = new TH1F("hist_nKshortAllH", "hist_nKshortAllH", 50, 0.45, 0.55);
101 m_h_nKshortActiveH = new TH1F("hist_nKshortActiveH", "hist_nKshortActiveH", 50, 0.45, 0.55);
102 m_h_nKshortActiveNotTimeH = new TH1F("hist_nKshortActiveNotTimeH", "hist_nKshortActiveNotTimeH", 50, 0.45, 0.55);
103 m_h_nKshortActiveNotCDCECLH = new TH1F("hist_nKshortActiveNotCDCECLH", "hist_nKshortActiveNotCDCECLH", 50, 0.45, 0.55);
104
105 oldDir->cd();
106}
107
108
110{
111 REG_HISTOGRAM
112
114 result.isOptional();
115 m_l1Trigger.isOptional();
116}
117
118
120{
121 m_h_mKS0->Reset();
122 m_h_mPI0->Reset();
123 m_h_mUPS->Reset();
124 m_h_R2->Reset();
125 m_h_physicsresults->Reset();
126 m_h_nKshortAllH->Reset();
127 m_h_nKshortActiveH->Reset();
130}
131
132
136
137
141
142
144{
146 if (!result.isValid()) {
147 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
148 return;
149 }
150
151 const std::map<std::string, int>& results = result->getResults();
152
153 //--- HLTPrefilter monitoring ---//
154 // Check if events pass HLT cut //
155 if (results.find(m_triggerIdentifierHLT) == results.end()) {
156 //Cannot find the m_triggerIdentifierHLT
157 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierHLT);
158 } else {
159 const bool HLT_accept = (result->getResult(m_triggerIdentifierHLT) == SoftwareTriggerCutResult::c_accept);
160 if (HLT_accept != false) {
161
162 //find out if events are in the passive veto (false) or in the active veto window (true)
163 bool inActiveInjectionVeto = false; //events accepted in the passive veto window but not in the active
164 try {
165 if (m_l1Trigger->testInput("passive_veto") == 1 && m_l1Trigger->testInput("cdcecl_veto") == 0)
166 inActiveInjectionVeto = true; //events in active veto
167 } catch (const std::exception&) {}
168
169 if (results.find(m_prefilter_Injection_Strip) != results.end()) {
171 }
172 if (results.find(m_prefilter_CDCECL_Cut) != results.end()) {
173 m_CDCECLCut = (result->getNonPrescaledResult(m_prefilter_CDCECL_Cut) == SoftwareTriggerCutResult::c_accept);
174 }
175
176 // Iterate over Ks particle list //
178
179 if (ks0Particles.isValid() && abs(ks0Particles->getPDGCode()) == Const::Kshort.getPDGCode()) {
180 for (unsigned int i = 0; i < ks0Particles->getListSize(); i++) {
181 Particle* mergeKsCand = ks0Particles->getParticle(i);
182 const double isKsCandGood = Variable::goodBelleKshort(mergeKsCand);
183
184 if (isKsCandGood) {
185 m_h_nKshortAllH->Fill(mergeKsCand->getMass()); // Fill all Ks events
186 if (inActiveInjectionVeto) {
187 m_h_nKshortActiveH->Fill(mergeKsCand->getMass()); // Fill Ks events from active veto
188 if (!m_TimingCut)
189 m_h_nKshortActiveNotTimeH->Fill(mergeKsCand->getMass()); // Fill Ks events retained after timing cut of HLTprefilter
190 if (!m_CDCECLCut)
191 m_h_nKshortActiveNotCDCECLH->Fill(mergeKsCand->getMass()); // Fill Ks events retained after CDC-ECL cut of HLTprefilter
192 }
193 }
194 }
195 }
196 }
197 }
198
199 if (results.find(m_triggerIdentifier) == results.end()) {
200 //Cannot find the m_triggerIdentifier, move on to mumu
201 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifier);
202 } else {
203 const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
204 if (accepted != false) {
205
206 m_h_physicsresults->Fill(1); //hadron events
207
210
211 double R2 = Belle2::Variable::foxWolframR2(nullptr);
212 m_h_R2->Fill(R2);
213
214 if (pi0Particles.isValid() && abs(pi0Particles->getPDGCode()) == Const::pi0.getPDGCode()) {
215 for (unsigned int i = 0; i < pi0Particles->getListSize(); i++) {
216 Particle* pi0 = pi0Particles->getParticle(i);
217 m_h_mPI0->Fill(pi0->getMass());
218 }
219 }
220 if (ks0Particles.isValid() && abs(ks0Particles->getPDGCode()) == Const::Kshort.getPDGCode()) {
221 for (unsigned int i = 0; i < ks0Particles->getListSize(); i++) {
222 Particle* ks0 = ks0Particles->getParticle(i);
223 m_h_mKS0->Fill(ks0->getMass());
224 }
225 }
226 }
227 }
228 if (results.find(m_triggerIdentifierMuMu) == results.end()) {
229 //Cannot find the m_triggerIdentifierMuMu, stop now
230 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierMuMu);
231 return;
232 } else {
233 const bool accepted = (result->getResult(m_triggerIdentifierMuMu) == SoftwareTriggerCutResult::c_accept);
234 if (accepted != false) {
235 m_h_physicsresults->Fill(4); //mumu events
237 if (UpsParticles.isValid()) {
238 for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
239 Particle* Ups = UpsParticles->getParticle(i);
240 m_h_mUPS->Fill(Ups->getMass());
241 }
242 }
243 }
244 }
245 //bhabha, hadrons
246 if (results.find(m_triggerIdentifierBhabha) == results.end()) {
247 //Cannot find the m_triggerIdentifierBhahba, stop now
248 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierBhabha);
249 return;
250 } else {
251 const bool accepted = (result->getResult(m_triggerIdentifierBhabha) == SoftwareTriggerCutResult::c_accept);
252 if (accepted != false) {
253 m_h_physicsresults->Fill(5); //bhabha events
255 if (UpsbhabhaParticles.isValid()) {
256 for (unsigned int i = 0; i < UpsbhabhaParticles->getListSize(); i++) {
257 Particle* Upse = UpsbhabhaParticles->getParticle(i);
258 m_h_mUPSe->Fill(Upse->getMass());
259 }
260 }
261 }
262 }
263
264 if (results.find(m_triggerIdentifierHadronb2) == results.end()) {
265 //Cannot find the m_triggerIdentifierHadronb2, stop now
266 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierHadronb2);
267 return;
268 } else {
269 const bool accepted = (result->getResult(m_triggerIdentifierHadronb2) == SoftwareTriggerCutResult::c_accept);
270 if (accepted != false) {
271
272 m_h_physicsresults->Fill(2); //hadronb2 events
273
274 //variables for hadronb2 tight
276 std::vector<ROOT::Math::PxPyPzEVector> m_pionHad;
277 double EsumPiHad = 0.;
278 for (unsigned int i = 0; i < hadpiParticles->getListSize(); i++) {
279 const Particle* parPiHad = hadpiParticles->getParticle(i);
280 ROOT::Math::PxPyPzEVector V4PiHad = PCmsLabTransform::labToCms(parPiHad->get4Vector());
281 m_pionHad.push_back(V4PiHad);
282 EsumPiHad += V4PiHad.E();
283 }
284 //EnECLClustersLE
285 double eneclClusters = 0.;
286 StoreArray<ECLCluster> eclClusters;
287 ClusterUtils Cl;
288 double EsumGamma = 0.;
289 if (eclClusters.isValid()) {
290 for (int ncl = 0; ncl < eclClusters.getEntries(); ncl++) {
291 if (eclClusters[ncl]->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
292 && eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1) {
293 eneclClusters += eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
294 if (!eclClusters[ncl]->getRelatedFrom<Track>()) {
295 ROOT::Math::PxPyPzEVector V4Gamma_CMS = PCmsLabTransform::labToCms(Cl.Get4MomentumFromCluster(eclClusters[ncl],
297 EsumGamma += V4Gamma_CMS.E();
298 }
299 }
300 }
301 }
302 double visibleEnergyCMSnorm = (EsumPiHad + EsumGamma) / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
303 double EsumCMSnorm = eneclClusters / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
304 FoxWolfram fw(m_pionHad);
306 double R2 = fw.getR(2);
307 bool hadronb_tag = visibleEnergyCMSnorm > 0.4 && EsumCMSnorm > 0.2 && R2 < 0.2;
308 if (hadronb_tag) {
309 m_h_physicsresults->Fill(3); //hadronb2 tight events
310 }
311
312 }
313 }
314
315
316
317}
Class to provide momentum-related information from ECLClusters.
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
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)
Definition ECLCluster.h:41
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()
Constructor.
Definition HistoModule.h:32
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:76
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition Particle.h:567
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition Particle.h:527
std::string m_ks0PListName
Name of the KS0 particle list.
void initialize() override
Initializer.
StoreObjPtr< TRGSummary > m_l1Trigger
Objects relevant to HLTprefilter monitoring.
void event() override
This method is called for each event.
void endRun() override
This method is called if the current run ends.
std::string m_prefilter_Injection_Strip
HLTPrefilter lines.
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.
bool m_CDCECLCut
Flag for timing cut on injection strip.
TH1F * m_h_nKshortActiveNotCDCECLH
Histogram for Ks events : && active veto && !timing cut.
TH1F * m_h_mUPSe
Ups ee invariant mass.
void beginRun() override
Called when entering a new run.
TH1F * m_h_physicsresults
event physics results
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.
bool m_TimingCut
CDC-ECL occupancy cut for prefilter.
std::string m_prefilter_CDCECL_Cut
Timing cut for prefilter.
std::string m_triggerIdentifierHLT
Trigger identifier string used to select events for HLTprefilter histograms.
std::string m_triggerIdentifierMuMu
Trigger identifier string used to select events for the mumu histograms.
TH1F * m_h_nKshortActiveH
Histogram for Ks events.
std::string m_pi0PListName
Name of the pi0 particle list.
TH1F * m_h_nKshortActiveNotTimeH
Histogram for Ks events : active veto.
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 whether 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.
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
Abstract base class for different kinds of events.