Belle II Software development
PhysicsObjectsMiraBelleHadronModule.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/PhysicsObjectsMiraBelleHadronModule.h>
10#include <hlt/softwaretrigger/calculations/utilities.h>
11#include <analysis/dataobjects/ParticleList.h>
12#include <analysis/variables/ContinuumSuppressionVariables.h>
13#include <analysis/ContinuumSuppression/FoxWolfram.h>
14#include <analysis/variables/TrackVariables.h>
15#include <analysis/utility/PCmsLabTransform.h>
16#include <analysis/variables/Variables.h>
17#include <framework/datastore/StoreObjPtr.h>
18#include <framework/datastore/StoreArray.h>
19#include <mdst/dataobjects/Track.h>
20#include <mdst/dataobjects/TrackFitResult.h>
21#include <mdst/dataobjects/KLMCluster.h>
22#include <mdst/dataobjects/HitPatternCDC.h>
23#include <mdst/dataobjects/HitPatternVXD.h>
24#include <mdst/dataobjects/EventLevelTrackingInfo.h>
25#include <mdst/dataobjects/PIDLikelihood.h>
26#include <top/variables/TOPDigitVariables.h>
27#include <arich/modules/arichDQM/ARICHDQMModule.h>
28#include <arich/dataobjects/ARICHLikelihood.h>
29#include <mdst/dataobjects/SoftwareTriggerResult.h>
30#include <analysis/ClusterUtility/ClusterUtils.h>
31#include <TDirectory.h>
32#include <map>
33
34using namespace Belle2;
35
36REG_MODULE(PhysicsObjectsMiraBelleHadron);
37
39{
40 setDescription("Monitor Physics Objects Quality");
42
43 addParam("TriggerIdentifier", m_triggerIdentifier,
44 "Trigger identifier string used to select events for the histograms", std::string("software_trigger_cut&skim&accept_hadronb2"));
45 addParam("hadronb2piPListName", m_hadpiPListName, "Name of the pi+ particle list", std::string("pi+:hadb2physMiraBelle"));
46}
47
49{
50 TDirectory* oldDir = gDirectory;
51 oldDir->mkdir("PhysicsObjectsMiraBelleHadron");
52 oldDir->cd("PhysicsObjectsMiraBelleHadron");
53
54 // Mass distributions
55 m_h_nECLClusters = new TH1F("hist_nECLClusters", "hist_nECLClusters", 100, 0, 60);
56 m_h_nECLClusters->SetXTitle("hist_nECLClusters");
57 m_h_visibleEnergyCMSnorm = new TH1F("hist_visibleEnergyCMSnorm", "hist_visibleEnergyCMSnorm", 100, 0, 2);
58 m_h_visibleEnergyCMSnorm->SetXTitle("hist_visibleEnergyCMSnorm");
59 m_h_EsumCMSnorm = new TH1F("hist_EsumCMSnorm", "hist_EsumCMSnorm", 100, 0, 2);
60 m_h_EsumCMSnorm->SetXTitle("hist_EsumCMSnorm");
61 m_h_R2 = new TH1F("hist_R2", "hist_R2", 100, 0, 1);
62 m_h_R2->SetXTitle("hist_R2");
63 m_h_physicsresultsH = new TH1F("hist_physicsresultsH", "hist_physicsresultsH", 10, 0, 10);
64 m_h_physicsresultsH->SetXTitle("hist_physicsresultsH");
65 m_h_physicsresultsH->GetXaxis()->SetBinLabel(2, "Hadronb2");
66 m_h_physicsresultsH->GetXaxis()->SetBinLabel(3, "Hadronb2_tight");
67
68 oldDir->cd();
69}
70
71
73{
74 REG_HISTOGRAM
75
77 result.isOptional();
78}
79
81{
82
83 m_h_nECLClusters->Reset();
85 m_h_EsumCMSnorm->Reset();
86 m_h_R2->Reset();
87 m_h_physicsresultsH->Reset();
88}
89
91{
92
94 if (!result.isValid()) {
95 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
96 return;
97 }
98
99 const std::map<std::string, int>& results = result->getResults();
100 if (results.find(m_triggerIdentifier) == results.end()) {
101 B2WARNING("PhysicsObjectsMiraBelleHadron: Can't find trigger identifier: " << m_triggerIdentifier);
102 return;
103 }
104
105 // apply software trigger
106 const bool accepted = (result->getResult(m_triggerIdentifier) == SoftwareTriggerCutResult::c_accept);
107 if (accepted == false) return;
108 m_h_physicsresultsH->Fill(1);
109 // get pi list
111 std::vector<ROOT::Math::XYZVector> m_pionHadv3;
112
113 double EsumPiHad = 0.;
114
115 for (unsigned int i = 0; i < hadpiParticles->getListSize(); i++) {
116 const Particle* parPiHad = hadpiParticles->getParticle(i);
117 ROOT::Math::PxPyPzEVector V4PiHad = PCmsLabTransform::labToCms(parPiHad->get4Vector());
118 m_pionHadv3.push_back(parPiHad->getMomentum());
119 EsumPiHad += V4PiHad.E();
120
121 }
122 //nECLClustersLE
123 double neclClusters = -1.;
124 double eneclClusters = 0.;
125 StoreArray<ECLCluster> eclClusters;
126 ClusterUtils Cl;
127 double EsumGamma = 0.;
128
129 if (eclClusters.isValid()) {
130 const unsigned int numberOfECLClusters = std::count_if(eclClusters.begin(), eclClusters.end(),
131 [](const ECLCluster & eclcluster) {
132 return (eclcluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
133 and eclcluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1);
134 });
135 neclClusters = numberOfECLClusters;
136 for (int ncl = 0; ncl < eclClusters.getEntries(); ncl++) {
137 if (eclClusters[ncl]->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)
138 && eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > 0.1) {
139 eneclClusters += eclClusters[ncl]->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
140 if (!eclClusters[ncl]->getRelatedFrom<Track>()) {
141 ROOT::Math::PxPyPzEVector V4Gamma_CMS = PCmsLabTransform::labToCms(Cl.Get4MomentumFromCluster(eclClusters[ncl],
143 EsumGamma += V4Gamma_CMS.E();
144 }
145 }
146 }
147 }
148
149 double visibleEnergyCMSnorm = (EsumPiHad + EsumGamma) / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
150 double EsumCMSnorm = eneclClusters / (Belle2::SoftwareTrigger::BeamEnergyCMS() * 2.0);
151 FoxWolfram fw(m_pionHadv3);
153 double R2 = fw.getR(2);
154
155 m_h_nECLClusters->Fill(neclClusters);
156 m_h_visibleEnergyCMSnorm->Fill(visibleEnergyCMSnorm);
157 m_h_EsumCMSnorm->Fill(EsumCMSnorm);
158 m_h_R2->Fill(R2);
159 bool hadronb_tag = visibleEnergyCMSnorm > 0.4 && EsumCMSnorm > 0.2 && R2 < 0.2;
160 if (hadronb_tag) {
161 m_h_physicsresultsH->Fill(2);
162 }
163
164}
165
166
167
169{
170}
171
173{
174}
175
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
ECL cluster data.
Definition: ECLCluster.h:27
@ 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
void event() override
This method is called for each event.
TH1F * m_h_physicsresultsH
histogram for event results for hadronb2 and hadronb2 tight
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_R2
histogram for R2 of hadron events after the hadronb2 selection
std::string m_hadpiPListName
Name of the pi+ particle list.
void beginRun() override
Called when entering a new run.
TH1F * m_h_visibleEnergyCMSnorm
histogram for visible energy of tracks and gammas
TH1F * m_h_EsumCMSnorm
histogram for sum of energy of clusters with E > 0.1
void defineHisto() override
Definition of the 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
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:96
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.