Belle II Software development
SVDdEdxCollectorModule.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#include <svd/modules/svddEdxCalibrationCollector/SVDdEdxCollectorModule.h>
9
10#include <analysis/dataobjects/ParticleList.h>
11#include <reconstruction/dataobjects/VXDDedxTrack.h>
12#include <mdst/dataobjects/Track.h>
13
14#include <TTree.h>
15
16using namespace std;
17using namespace Belle2;
18
19//-----------------------------------------------------------------
20// Register the Module
21//-----------------------------------------------------------------
22REG_MODULE(SVDdEdxCollector);
23
24//-----------------------------------------------------------------
25// Implementation
26//-----------------------------------------------------------------
27
29{
30 // Set module properties
31
32 setDescription("Collector module used to create the ROOT ntuples used to produce dE/dx calibration payloads");
34
35 addParam("LambdaListName", m_LambdaListName, "Name of the Lambda particle list", std::string("Lambda0:cut"));
36 addParam("DstarListName", m_DstarListName, "Name of the Dstar particle list", std::string("D*+:cut"));
37 addParam("GammaListName", m_GammaListName, "Name of the Gamma particle list", std::string("gamma:cut"));
38}
39
41{
42 B2INFO("Initialisation of the trees");
43 std::string objectNameLambda = "Lambda";
44 std::string objectNameDstar = "Dstar";
45 std::string objectNameGamma = "Gamma";
46 // Data object creation --------------------------------------------------
47 TTree* LambdaTree = new TTree(objectNameLambda.c_str(), "");
48 TTree* DstarTree = new TTree(objectNameDstar.c_str(), "");
49 TTree* GammaTree = new TTree(objectNameGamma.c_str(), "");
50
51 // Event info for all trees
52 LambdaTree->Branch<int>("event", &m_evt);
53 LambdaTree->Branch<int>("exp", &m_exp);
54 LambdaTree->Branch<int>("run", &m_run);
55 LambdaTree->Branch<double>("time", &m_time);
56
57 DstarTree->Branch<int>("event", &m_evt);
58 DstarTree->Branch<int>("exp", &m_exp);
59 DstarTree->Branch<int>("run", &m_run);
60 DstarTree->Branch<double>("time", &m_time);
61
62 GammaTree->Branch<int>("event", &m_evt);
63 GammaTree->Branch<int>("exp", &m_exp);
64 GammaTree->Branch<int>("run", &m_run);
65 GammaTree->Branch<double>("time", &m_time);
66
67 // Specific decay info for all trees
68 LambdaTree->Branch<double>("InvM", &m_InvMLambda);
69 LambdaTree->Branch<double>("ProtonMomentum", &m_protonMomentum);
70 LambdaTree->Branch<double>("ProtonSVDdEdx", &m_protonSVDdEdx);
71 LambdaTree->Branch<double>("PionLambdaMomentum", &m_pionLambdap);
72 LambdaTree->Branch<double>("PionLambdaSVDdEdx", &m_pionLambdaSVDdEdx);
73
74 DstarTree->Branch<double>("InvM", &m_InvMDstar);
75 DstarTree->Branch<double>("D0InvM", &m_InvMD0);
76 DstarTree->Branch<double>("deltaM", &m_DeltaM);
77 DstarTree->Branch<double>("KaonMomentum", &m_kaonMomentum);
78 DstarTree->Branch<double>("KaonSVDdEdx", &m_kaonSVDdEdx);
79 DstarTree->Branch<double>("PionDMomentum", &m_pionDp);
80 DstarTree->Branch<double>("PionDSVDdEdx", &m_pionDSVDdEdx);
81 DstarTree->Branch<double>("SlowPionMomentum", &m_slowPionMomentum);
82 DstarTree->Branch<double>("SlowPionSVDdEdx", &m_slowPionSVDdEdx);
83
84 GammaTree->Branch<double>("InvM", &m_InvMGamma);
85 GammaTree->Branch<double>("FirstElectronMomentum", &m_firstElectronMomentum);
86 GammaTree->Branch<double>("FirstElectronSVDdEdx", &m_firstElectronSVDdEdx);
87 GammaTree->Branch<double>("SecondElectronMomentum", &m_secondElectronMomentum);
88 GammaTree->Branch<double>("SecondElectronSVDdEdx", &m_secondElectronSVDdEdx);
89
90 // We register the objects so that our framework knows about them.
91 // Don't try and hold onto the pointers or fill these objects directly
92 // Use the getObjectPtr functions to access collector objects
93 registerObject<TTree>(objectNameLambda, LambdaTree);
94 registerObject<TTree>(objectNameDstar, DstarTree);
95 registerObject<TTree>(objectNameGamma, GammaTree);
96}
97
98VXDDedxTrack const* getSVDDedxFromParticle(Particle const* particle)
99{
100 const Track* track = particle->getTrack();
101 if (!track) {
102 return nullptr;
103 }
104
105 const VXDDedxTrack* dedxTrack = track->getRelatedTo<VXDDedxTrack>();
106 if (!dedxTrack) {
107 return nullptr;
108 }
109 return dedxTrack;
110}
111
113{
114
115 m_evt = m_emd->getEvent();
116 m_run = m_emd->getRun();
117 m_exp = m_emd->getExperiment();
118 m_time = m_emd->getTime() / 1e9 / 3600.; // from ns to hours
119
123
124
125 if (!LambdaParticles.isValid() && !DstarParticles.isValid() && !GammaParticles.isValid())
126 return;
127
128 if (LambdaParticles->getListSize() > 0) {
129 for (unsigned int iParticle = 0; iParticle < LambdaParticles->getListSize(); ++iParticle) {
130
131 std::vector<int> indicesLambda = LambdaParticles->getParticle(0)->getDaughterIndices();
132 if (indicesLambda.size() != 2)
133 return;
134 const Particle* partLambda = LambdaParticles->getParticle(0);
135 const Particle* partPFromLambda = LambdaParticles->getParticle(0)->getDaughter(0);
136 const Particle* partPiFromLambda = LambdaParticles->getParticle(0)->getDaughter(1);
137
138 const VXDDedxTrack* dedxTrackPFromLambda = getSVDDedxFromParticle(partPFromLambda);
139 const VXDDedxTrack* dedxTrackPiFromLambda = getSVDDedxFromParticle(partPiFromLambda);
140
141 m_InvMLambda = partLambda->getMass();
142
143 m_protonMomentum = partPFromLambda->getMomentumMagnitude();
144 if (!dedxTrackPFromLambda) {
145 m_protonSVDdEdx = -999.0;
146 } else {
147 m_protonSVDdEdx = dedxTrackPFromLambda->getDedx(Const::EDetector::SVD);
148 }
149
150 m_pionLambdap = partPiFromLambda->getMomentumMagnitude();
151 if (!dedxTrackPiFromLambda) {
152 m_pionLambdaSVDdEdx = -999.0;
153 } else {
154 m_pionLambdaSVDdEdx = dedxTrackPiFromLambda->getDedx(Const::EDetector::SVD);
155 }
156 getObjectPtr<TTree>("Lambda")->Fill();
157 }
158 }
159
160 if (DstarParticles->getListSize() > 0) {
161 for (unsigned int iParticle = 0; iParticle < DstarParticles->getListSize(); ++iParticle) {
162
163 std::vector<int> indicesDstar = DstarParticles->getParticle(0)->getDaughterIndices();
164 if (indicesDstar.size() != 2)
165 return;
166
167 const Particle* partDstar = DstarParticles->getParticle(0);
168 const Particle* partD0 = DstarParticles->getParticle(0)->getDaughter(0);
169 const Particle* partPiS = DstarParticles->getParticle(0)->getDaughter(1);
170 const Particle* partKFromD = DstarParticles->getParticle(0)->getDaughter(0)->getDaughter(0);
171 const Particle* partPiFromD = DstarParticles->getParticle(0)->getDaughter(0)->getDaughter(1);
172
173 const VXDDedxTrack* dedxTrackPiS = getSVDDedxFromParticle(partPiS);
174 const VXDDedxTrack* dedxTrackKFromD = getSVDDedxFromParticle(partKFromD);
175 const VXDDedxTrack* dedxTrackPiFromD = getSVDDedxFromParticle(partPiFromD);
176
177
178 m_InvMDstar = partDstar->getMass();
179 m_InvMD0 = partD0->getMass();
181
182 m_kaonMomentum = partKFromD->getMomentumMagnitude();
183 if (!dedxTrackKFromD) {
184 m_kaonSVDdEdx = -999.0;
185 } else {
186 m_kaonSVDdEdx = dedxTrackKFromD->getDedx(Const::EDetector::SVD);
187 }
188
189 m_pionDp = partPiFromD->getMomentumMagnitude();
190 if (!dedxTrackPiFromD) {
191 m_pionDSVDdEdx = -999.0;
192 } else {
193 m_pionDSVDdEdx = dedxTrackPiFromD->getDedx(Const::EDetector::SVD);
194 }
195
197 if (!dedxTrackPiS) {
198 m_slowPionSVDdEdx = -999.0;
199 } else {
200 m_slowPionSVDdEdx = dedxTrackPiS->getDedx(Const::EDetector::SVD);
201 }
202 getObjectPtr<TTree>("Dstar")->Fill();
203 }
204 }
205
206 if (GammaParticles->getListSize() > 0) {
207 for (unsigned int iParticle = 0; iParticle < GammaParticles->getListSize(); ++iParticle) {
208 std::vector<int> indicesGamma = GammaParticles->getParticle(0)->getDaughterIndices();
209 if (indicesGamma.size() != 2)
210 return;
211
212 const Particle* partGamma = GammaParticles->getParticle(0);
213 const Particle* partE1FromGamma = GammaParticles->getParticle(0)->getDaughter(0);
214 const Particle* partE2FromGamma = GammaParticles->getParticle(0)->getDaughter(1);
215
216 const VXDDedxTrack* dedxTrackE1FromGamma = getSVDDedxFromParticle(partE1FromGamma);
217 const VXDDedxTrack* dedxTrackE2FromGamma = getSVDDedxFromParticle(partE2FromGamma);
218
219 m_InvMGamma = partGamma->getMass();
220
222 if (!dedxTrackE1FromGamma) {
223 m_firstElectronSVDdEdx = -999.0;
224 } else {
225 m_firstElectronSVDdEdx = dedxTrackE1FromGamma->getDedx(Const::EDetector::SVD);
226 }
227
229 if (!dedxTrackE2FromGamma) {
231 } else {
232 m_secondElectronSVDdEdx = dedxTrackE2FromGamma->getDedx(Const::EDetector::SVD);
233 }
234
235 getObjectPtr<TTree>("Gamma")->Fill();
236 }
237 }
238}
Calibration collector module base class.
StoreObjPtr< EventMetaData > m_emd
Current EventMetaData.
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
Class to store reconstructed particles.
Definition: Particle.h:75
double getMomentumMagnitude() const
Returns momentum magnitude.
Definition: Particle.h:569
double getMass() const
Returns invariant mass (= nominal for FS particles)
Definition: Particle.h:507
double m_secondElectronSVDdEdx
SVD dE/dx response for the second electron.
void prepare() override final
Initialize the module.
double m_kaonSVDdEdx
SVD dE/dx response for the kaon from the D0.
double m_firstElectronMomentum
momentum for the first electron
double m_protonMomentum
momentum for the proton from the Lambda
double m_pionLambdap
momentum for the pion from the Lambda
std::string m_LambdaListName
Name of the Lambda particle list.
double m_pionDp
momentum for the pion from the D0
double m_protonSVDdEdx
SVD dE/dx response for the proton from the Lambda.
double m_InvMDstar
Invariant mass of Dstar candidates.
double m_InvMD0
Invariant mass of D0 candidates.
double m_slowPionMomentum
momentum for the pion from the Dstar
double m_slowPionSVDdEdx
SVD dE/dx response for the pion from the Dstar.
void collect() override final
Event processor.
double m_DeltaM
deltaM = m(Dstar)-m(D0)
double m_InvMGamma
Invariant mass of converted photon candidates.
double m_firstElectronSVDdEdx
SVD dE/dx response for the first electron.
double m_InvMLambda
Invariant mass of Lambda candidates.
double m_pionLambdaSVDdEdx
SVD dE/dx response for the pion from the Lambda.
std::string m_DstarListName
Name of the Dstar particle list.
double m_pionDSVDdEdx
SVD dE/dx response for the pion from the D0.
std::string m_GammaListName
Name of the Gamma particle list.
double m_secondElectronMomentum
momentum for the second electron
double m_kaonMomentum
momentum for the kaon from the D0
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
Class that bundles various TrackFitResults.
Definition: Track.h:25
Debug output for VXDDedxPID module.
Definition: VXDDedxTrack.h:27
double getDedx(Const::EDetector detector) const
Get dE/dx truncated mean for given detector.
Definition: VXDDedxTrack.h:69
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
VXDDedxTrack const * getSVDDedxFromParticle(Particle const *particle)
SVD dEdx value from particle.
Abstract base class for different kinds of events.
STL namespace.