Belle II Software development
CDCDedxHadronCollectorModule.cc
1
2/**************************************************************************
3 * basf2 (Belle II Analysis Software Framework) *
4 * Author: The Belle II Collaboration *
5 * *
6 * See git log for contributors and copyright holders. *
7 * This file is licensed under LGPL-3.0, see LICENSE.md. *
8 **************************************************************************/
9
10#include <cdc/modules/CDCDedxHadronCollector/CDCDedxHadronCollectorModule.h>
11#include <cmath>
12
13using namespace Belle2;
14//-----------------------------------------------------------------
15// Register the Module
16//-----------------------------------------------------------------
17REG_MODULE(CDCDedxHadronCollector);
18
19//-----------------------------------------------------------------
20// Implementation
21//-----------------------------------------------------------------
23{
24 // Set module properties
25 setDescription("A collector module for CDC dE/dx hadron calibrations");
26
27 // Parameter definitions
28 addParam("particleLists", m_strParticleList, "Vector of ParticleLists to save", std::vector<std::string>());
29 addParam("maxcut", m_maxCut, "high cut on dedx curve for proton sample ", double(1.2));
30 addParam("mincut", m_minCut, "low cut on dedx curve for proton sample ", double(0.35));
31}
32
33//-----------------------------------------------------------------
34// Create ROOT objects
35//-----------------------------------------------------------------
36
38{
39
40 std::vector<TTree* > ttree;
41
42 // build a map to relate input strings to the right particle type
43 m_pdgMap = {{"pi+", "pion"}, {"K+", "kaon"}, {"mu+", "muon"}, {"e+", "electron"}, {"p+", "proton"}, {"deuteron", "deutron"}};
44
45 for (auto& x : m_pdgMap) {
46
47 // strip the name of the particle lists to make this work
48 std::string pdg = x.second;
49
50 ttree.push_back(new TTree(Form("%s", pdg.data()), Form("%s dE/dx information", pdg.data())));
51 int tt = ttree.size() - 1;
52
53 ttree[tt]->Branch<double>("dedxnosat", &m_dedxnosat);
54 ttree[tt]->Branch<double>("dedx", &m_dedx);
55 ttree[tt]->Branch<double>("costh", &m_costh);
56 ttree[tt]->Branch<double>("p", &m_p);
57 ttree[tt]->Branch<int>("charge", &m_charge);
58 ttree[tt]->Branch<int>("nhits", &m_nhits);
59 ttree[tt]->Branch<double>("timereso", &m_timeReso);
60 ttree[tt]->Branch<double>("injtime", &m_injTime);
61 ttree[tt]->Branch<double>("injring", &m_injRing);
62
63 // Collector object registration
64 registerObject<TTree>(Form("%s", pdg.data()), ttree[tt]);
65 }
66}
67
68//-----------------------------------------------------------------
69// Fill ROOT objects
70//-----------------------------------------------------------------
72{
73
74 int nParticleList = m_strParticleList.size();
75
76 for (int iList = 0; iList < nParticleList; iList++) {
77
78 //Collector object access
79 std::string pdg = m_pdgMap[m_strParticleList[iList].substr(0, m_strParticleList[iList].find(":"))];
80 auto tree = getObjectPtr<TTree>(Form("%s", pdg.data()));
81
82 // make sure the list exists and is not empty
84
85 if (!particlelist or particlelist->getListSize() == 0) continue;
86
87 // loop over the particles in the list and follow the links to the
88 for (unsigned int iPart = 0; iPart < particlelist->getListSize(true); iPart++) {
89
90 Particle* part = particlelist->getParticle(iPart, true);
91 if (!part) {
92 B2WARNING("No particles...");
93 continue;
94 }
96 if (!pid) {
97 B2WARNING("No related PID likelihood...");
98 continue;
99 }
100 Track* track = pid->getRelatedFrom<Track>();
101 if (!track) {
102 B2WARNING("No related track...");
103 continue;
104 }
105
106 CDCDedxTrack* dedxTrack = track->getRelatedTo<CDCDedxTrack>();
107 if (!dedxTrack) {
108 B2WARNING("No related CDCDedxTrack...");
109 continue;
110 }
111
112 std::string ptype = m_strParticleList[iList].substr(0, m_strParticleList[iList].find(":"));
113
114 const TrackFitResult* fitResult = track->getTrackFitResult(Const::pion);
115 if (ptype != "pi+") {
116 if (ptype == "K+") fitResult = track->getTrackFitResultWithClosestMass(Const::kaon);
117 else if (ptype == "p+") fitResult = track->getTrackFitResultWithClosestMass(Const::proton);
118 else if (ptype == "deuteron") fitResult = track->getTrackFitResultWithClosestMass(Const::deuteron);
119 else if (ptype == "mu+") fitResult = track->getTrackFitResultWithClosestMass(Const::muon);
120 else if (ptype == "e+") fitResult = track->getTrackFitResultWithClosestMass(Const::electron);
121 }
122
123 if (!fitResult) {
124 B2WARNING("No related fit for this track...");
125 continue;
126 }
127
128 if (dedxTrack->size() == 0 || dedxTrack->size() > 200) continue;
129 //if out CDC (dont add as we dont correct via correctionmodules)
130 if (dedxTrack->getCosTheta() < TMath::Cos(150.0 * TMath::DegToRad()))continue; //-0.866
131 if (dedxTrack->getCosTheta() > TMath::Cos(17.0 * TMath::DegToRad())) continue; //0.95
132
133 m_dedxnosat = dedxTrack->getDedxNoSat();
134 m_dedx = dedxTrack->getDedx();
135 m_p = dedxTrack->getMomentum();
136 m_costh = dedxTrack->getCosTheta();
137 m_charge = fitResult->getChargeSign();
138
139 if (m_dedx < 0) continue;
140
141 if (ptype == "mu+")
142 { if (m_p < 0.05) continue;}
143
144 if (ptype == "p+") {
145 if (((m_dedx - 0.45) * std::abs(m_p) * std::abs(m_p) > m_maxCut)
146 || ((m_dedx - 0.45)*std::abs(m_p) * std::abs(m_p) < m_minCut)) continue;
147 if (m_dedx < 1.00) continue;
148 if (std::abs(m_p) > 1.0) continue;
149 }
150
151 if (ptype == "pi+") {
152 if (m_dedx > 20) continue;
153 }
154
155 m_injRing = dedxTrack->getInjectionRing();
156 m_injTime = dedxTrack->getInjectionTime();
157
158 m_timeReso = m_DBInjectTime->getCorrection("reso", m_injRing, m_injTime);
159 m_nhits = dedxTrack->getNLayerHitsUsed();
160
161 // fill the TTree
162 tree->Fill();
163 }
164 }
165}
std::map< std::string, std::string > m_pdgMap
map to relate input strings to the right particle type
double m_maxCut
high cut dedx curve for proton sample
int m_nhits
number of dE/dx hits on the track
virtual void collect() override
Fill ROOT objects.
virtual void prepare() override
Create and book ROOT objects.
double m_dedxnosat
dE/dx truncated mean no-saturation
CDCDedxHadronCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
DBObjPtr< CDCDedxInjectionTime > m_DBInjectTime
Injection time DB object.
std::vector< std::string > m_strParticleList
Hadron collector variables.
Debug output for CDCDedxPID module.
double getDedx() const
Get dE/dx truncated mean for this track.
double getCosTheta() const
Return cos(theta) for this track.
double getInjectionRing() const
Return cos(theta) for this track.
double getInjectionTime() const
Return cos(theta) for this track.
double getDedxNoSat() const
Get dE/dx truncated mean without the saturation correction for this track.
int size() const
Return the number of hits for this track.
double getNLayerHitsUsed() const
Return the number of hits used to determine the truncated mean.
double getMomentum() const
Return the track momentum valid in the CDC.
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
static const ChargedStable muon
muon particle
Definition Const.h:660
static const ChargedStable pion
charged pion particle
Definition Const.h:661
static const ChargedStable proton
proton particle
Definition Const.h:663
static const ChargedStable kaon
charged kaon particle
Definition Const.h:662
static const ChargedStable electron
electron particle
Definition Const.h:659
static const ChargedStable deuteron
deuteron particle
Definition Const.h:664
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Class to store reconstructed particles.
Definition Particle.h:76
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
Class that bundles various TrackFitResults.
Definition Track.h:25
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.