Belle II Software  release-06-00-14
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 <framework/datastore/StoreObjPtr.h>
17 #include <framework/gearbox/Const.h>
18 #include <mdst/dataobjects/SoftwareTriggerResult.h>
19 #include <TDirectory.h>
20 #include <map>
21 
22 using namespace Belle2;
23 
24 //-----------------------------------------------------------------
25 // Register the Module
26 //-----------------------------------------------------------------
27 REG_MODULE(PhysicsObjectsDQM)
28 
29 //-----------------------------------------------------------------
30 // Implementation
31 //-----------------------------------------------------------------
32 
33 PhysicsObjectsDQMModule::PhysicsObjectsDQMModule() : HistoModule()
34 {
35  //Set module properties
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_hadron"));
42  addParam("TriggerIdentifierMuMu", m_triggerIdentifierMuMu,
43  "Trigger identifier string used to select events for the mumu histograms",
44  std::string("software_trigger_cut&skim&accept_mumutight"));
45  addParam("PI0PListName", m_pi0PListName, "Name of the pi0 particle list", std::string("pi0:physDQM"));
46  addParam("KS0PListName", m_ks0PListName, "Name of the KS0 particle list", std::string("K_S0:physDQM"));
47  addParam("UpsPListName", m_upsPListName, "Name of the Ups particle list", std::string("Upsilon:physDQM"));
48 }
49 
50 void PhysicsObjectsDQMModule::defineHisto()
51 {
52  TDirectory* oldDir = gDirectory;
53  oldDir->mkdir("PhysicsObjects")->cd();
54 
55  m_h_mKS0 = new TH1F("mKS0", "KS0 Invariant Mass", 20, 0.48, 0.52);
56  m_h_mKS0->SetXTitle("M(K_{S}^{0}) [GeV]");
57 
58  m_h_mPI0 = new TH1F("mPI0", "pi0 Invariant Mass", 25, 0.10, 0.15);
59  m_h_mPI0->SetXTitle("M(#pi^{0}) [GeV]");
60 
61  m_h_mUPS = new TH1F("mUPS", "Ups Invariant Mass", 500, 9, 12);
62  m_h_mUPS->SetXTitle("M(#mu#mu) [GeV]");
63 
64  m_h_R2 = new TH1F("R2", "Event Level R2", 36, 0, 1.2);
65  m_h_R2->SetXTitle("R2");
66 
67  oldDir->cd();
68 }
69 
70 
72 {
73  REG_HISTOGRAM
74 
76  result.isOptional();
77 }
78 
79 
81 {
82  m_h_mKS0->Reset();
83  m_h_mPI0->Reset();
84  m_h_mUPS->Reset();
85  m_h_R2->Reset();
86 }
87 
88 
90 {
91 }
92 
93 
95 {
96 }
97 
98 
100 {
102  if (!result.isValid()) {
103  B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
104  return;
105  }
106 
107  const std::map<std::string, int>& results = result->getResults();
108 
109  if (results.find(m_triggerIdentifier) == results.end()) {
110  //Cannot find the m_triggerIdentifier, move on to mumu
111  B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifier);
112  } else {
113  const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
114  if (accepted != false) {
115 
118 
119  double R2 = Belle2::Variable::foxWolframR2(nullptr);
120  m_h_R2->Fill(R2);
121 
122  if (pi0Particles.isValid() && abs(pi0Particles->getPDGCode()) == Const::pi0.getPDGCode()) {
123  for (unsigned int i = 0; i < pi0Particles->getListSize(); i++) {
124  Particle* pi0 = pi0Particles->getParticle(i);
125  m_h_mPI0->Fill(pi0->getMass());
126  }
127  }
128  if (ks0Particles.isValid() && abs(ks0Particles->getPDGCode()) == Const::Kshort.getPDGCode()) {
129  for (unsigned int i = 0; i < ks0Particles->getListSize(); i++) {
130  Particle* ks0 = ks0Particles->getParticle(i);
131  m_h_mKS0->Fill(ks0->getMass());
132  }
133  }
134  }
135  }
136  if (results.find(m_triggerIdentifierMuMu) == results.end()) {
137  //Cannot find the m_triggerIdentifierMuMu, stop now
138  B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierMuMu);
139  return;
140  } else {
141  const bool accepted = (result->getResult(m_triggerIdentifierMuMu) == SoftwareTriggerCutResult::c_accept);
142  if (accepted != false) {
144  if (UpsParticles.isValid()) {
145  for (unsigned int i = 0; i < UpsParticles->getListSize(); i++) {
146  Particle* Ups = UpsParticles->getParticle(i);
147  m_h_mUPS->Fill(Ups->getMass());
148  }
149  }
150  }
151  }
152 
153 
154 
155 }
int getPDGCode() const
PDG code.
Definition: Const.h:354
static const ParticleType pi0
neutral pion particle
Definition: Const.h:555
static const ParticleType Kshort
K^0_S particle.
Definition: Const.h:557
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Class to store reconstructed particles.
Definition: Particle.h:74
float getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:445
TH1F * m_h_mUPS
Ups invariant mass.
std::string m_ks0PListName
Name of the KS0 particle list.
void initialize() override
Function for dynamic initialization of module.
void event() override
Function to process event record.
void endRun() override
Function to process end_run record.
void terminate() override
Function to terminate module.
std::string m_triggerIdentifier
Trigger identifier string used to select events for the histograms.
TH1F * m_h_mPI0
PI0 invariant mass.
void beginRun() override
Function to process begin_run record.
TH1F * m_h_mKS0
KS0 invariant mass.
std::string m_upsPListName
Name of the Ups particle list.
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.
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
#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.