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
12using namespace Belle2;
13//-----------------------------------------------------------------
14// Register the Module
15//-----------------------------------------------------------------
16REG_MODULE(CDCDedxHadronCollector);
17
18//-----------------------------------------------------------------
19// Implementation
20//-----------------------------------------------------------------
22{
23 // Set module properties
24 setDescription("A collector module for CDC dE/dx hadron calibrations");
25
26 // Parameter definitions
27 addParam("particleLists", m_strParticleList, "Vector of ParticleLists to save", std::vector<std::string>());
28 addParam("maxcut", m_maxCut, "high cut on dedx curve for proton sample ", double(1.2));
29 addParam("mincut", m_minCut, "low cut on dedx curve for proton sample ", double(0.35));
30}
31
32//-----------------------------------------------------------------
33// Create ROOT objects
34//-----------------------------------------------------------------
35
37{
38
39 std::vector<TTree* > ttree;
40
41 // build a map to relate input strings to the right particle type
42 m_pdgMap = {{"pi+", "pion"}, {"K+", "kaon"}, {"mu+", "muon"}, {"e+", "electron"}, {"p+", "proton"}, {"deuteron", "deutron"}};
43
44 for (auto& x : m_pdgMap) {
45
46 // strip the name of the particle lists to make this work
47 std::string pdg = x.second;
48
49 ttree.push_back(new TTree(Form("%s", pdg.data()), Form("%s dE/dx information", pdg.data())));
50 int tt = ttree.size() - 1;
51
52 ttree[tt]->Branch<double>("dedxnosat", &m_dedxnosat);
53 ttree[tt]->Branch<double>("dedx", &m_dedx);
54 ttree[tt]->Branch<double>("costh", &m_costh);
55 ttree[tt]->Branch<double>("p", &m_p);
56 ttree[tt]->Branch<int>("charge", &m_charge);
57 ttree[tt]->Branch<int>("nhits", &m_nhits);
58 ttree[tt]->Branch<double>("timereso", &m_timeReso);
59 ttree[tt]->Branch<double>("injtime", &m_injTime);
60 ttree[tt]->Branch<double>("injring", &m_injRing);
61
62 // Collector object registration
63 registerObject<TTree>(Form("%s", pdg.data()), ttree[tt]);
64 }
65}
66
67//-----------------------------------------------------------------
68// Fill ROOT objects
69//-----------------------------------------------------------------
71{
72
73 int nParticleList = m_strParticleList.size();
74
75 for (int iList = 0; iList < nParticleList; iList++) {
76
77 //Collector object access
78 std::string pdg = m_pdgMap[m_strParticleList[iList].substr(0, m_strParticleList[iList].find(":"))];
79 auto tree = getObjectPtr<TTree>(Form("%s", pdg.data()));
80
81 // make sure the list exists and is not empty
83
84 if (!particlelist or particlelist->getListSize() == 0) continue;
85
86 // loop over the particles in the list and follow the links to the
87 for (unsigned int iPart = 0; iPart < particlelist->getListSize(true); iPart++) {
88
89 Particle* part = particlelist->getParticle(iPart, true);
90 if (!part) {
91 B2WARNING("No particles...");
92 continue;
93 }
95 if (!pid) {
96 B2WARNING("No related PID likelihood...");
97 continue;
98 }
99 Track* track = pid->getRelatedFrom<Track>();
100 if (!track) {
101 B2WARNING("No related track...");
102 continue;
103 }
104
105 CDCDedxTrack* dedxTrack = track->getRelatedTo<CDCDedxTrack>();
106 if (!dedxTrack) {
107 B2WARNING("No related CDCDedxTrack...");
108 continue;
109 }
110
111 std::string ptype = m_strParticleList[iList].substr(0, m_strParticleList[iList].find(":"));
112
113 const TrackFitResult* fitResult = track->getTrackFitResult(Const::pion);
114 if (ptype != "pi+") {
115 if (ptype == "K+") fitResult = track->getTrackFitResultWithClosestMass(Const::kaon);
116 else if (ptype == "p+") fitResult = track->getTrackFitResultWithClosestMass(Const::proton);
117 else if (ptype == "deuteron") fitResult = track->getTrackFitResultWithClosestMass(Const::deuteron);
118 else if (ptype == "mu+") fitResult = track->getTrackFitResultWithClosestMass(Const::muon);
119 else if (ptype == "e+") fitResult = track->getTrackFitResultWithClosestMass(Const::electron);
120 }
121
122 if (!fitResult) {
123 B2WARNING("No related fit for this track...");
124 continue;
125 }
126
127 if (dedxTrack->size() == 0 || dedxTrack->size() > 200) continue;
128 //if out CDC (dont add as we dont correct via correctionmodules)
129 if (dedxTrack->getCosTheta() < TMath::Cos(150.0 * TMath::DegToRad()))continue; //-0.866
130 if (dedxTrack->getCosTheta() > TMath::Cos(17.0 * TMath::DegToRad())) continue; //0.95
131
132 m_dedxnosat = dedxTrack->getDedxNoSat();
133 m_dedx = dedxTrack->getDedx();
134 m_p = dedxTrack->getMomentum();
135 m_costh = dedxTrack->getCosTheta();
136 m_charge = fitResult->getChargeSign();
137
138 if (m_dedx < 0) continue;
139
140 if (ptype == "mu+")
141 { if (m_p < 0.05) continue;}
142
143 if (ptype == "p+") {
144 if (((m_dedx - 0.45) * abs(m_p) * abs(m_p) > m_maxCut) || ((m_dedx - 0.45)*abs(m_p) * abs(m_p) < m_minCut)) continue;
145 if (m_dedx < 1.00) continue;
146 if (abs(m_p) > 1.0) continue;
147 }
148
149 if (ptype == "pi+") {
150 if (m_dedx > 20) continue;
151 }
152
153 m_injRing = dedxTrack->getInjectionRing();
154 m_injTime = dedxTrack->getInjectionTime();
155
156 m_timeReso = m_DBInjectTime->getCorrection("reso", m_injRing, m_injTime);
157 m_nhits = dedxTrack->getNLayerHitsUsed();
158
159 // fill the TTree
160 tree->Fill();
161 }
162 }
163}
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.
double m_timeReso
injection time resolution
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.
Definition: CDCDedxTrack.h:25
double getDedx() const
Get dE/dx truncated mean for this track.
Definition: CDCDedxTrack.h:104
double getCosTheta() const
Return cos(theta) for this track.
Definition: CDCDedxTrack.h:122
double getInjectionRing() const
Return cos(theta) for this track.
Definition: CDCDedxTrack.h:131
double getInjectionTime() const
Return cos(theta) for this track.
Definition: CDCDedxTrack.h:128
double getDedxNoSat() const
Get dE/dx truncated mean without the saturation correction for this track.
Definition: CDCDedxTrack.h:107
int size() const
Return the number of hits for this track.
Definition: CDCDedxTrack.h:201
double getNLayerHitsUsed() const
Return the number of hits used to determine the truncated mean.
Definition: CDCDedxTrack.h:178
double getMomentum() const
Return the track momentum valid in the CDC.
Definition: CDCDedxTrack.h:119
Calibration collector module base class.
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...
Definition: PIDLikelihood.h:29
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.