Belle II Software development
HitLevelInfoWriter.h
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#pragma once
10
11#include <mdst/dataobjects/Track.h>
12#include <mdst/dataobjects/TrackFitResult.h>
13#include <mdst/dataobjects/ECLCluster.h>
14#include <mdst/dataobjects/KLMCluster.h>
15#include <mdst/dataobjects/HitPatternCDC.h>
16#include <mdst/dataobjects/PIDLikelihood.h>
17#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
18
19#include <genfit/Track.h>
20
21#include <framework/dataobjects/EventMetaData.h>
22#include <framework/datastore/StoreArray.h>
23#include <framework/datastore/StoreObjPtr.h>
24#include <framework/database/DBObjPtr.h>
25#include <framework/core/Module.h>
26#include <framework/gearbox/Const.h>
27
28#include <reconstruction/dataobjects/CDCDedxTrack.h>
29#include <reconstruction/dbobjects/CDCDedxScaleFactor.h>
30#include <reconstruction/dbobjects/CDCDedxWireGain.h>
31#include <reconstruction/dbobjects/CDCDedxRunGain.h>
32#include <reconstruction/dbobjects/CDCDedxCosineCor.h>
33#include <reconstruction/dbobjects/CDCDedxInjectionTime.h>
34#include <reconstruction/dbobjects/CDCDedx2DCell.h>
35#include <reconstruction/dbobjects/CDCDedx1DCell.h>
36#include <reconstruction/dbobjects/CDCDedxInjectionTime.h>
37#include <reconstruction/dbobjects/CDCDedxADCNonLinearity.h> //new in rel5
38#include <reconstruction/dbobjects/CDCDedxCosineEdge.h> //new in rel5
39#include <reconstruction/dbobjects/CDCDedxHadronCor.h>
40#include <reconstruction/dataobjects/DedxConstants.h>
41
42#include <analysis/dataobjects/ParticleList.h>
43#include <analysis/dataobjects/Particle.h>
44#include <analysis/utility/ReferenceFrame.h>
45
46#include <vector>
47
48#include <TFile.h>
49#include <TTree.h>
50#include <TString.h>
51
52class TH2F;
53
54namespace Belle2 {
60 class CDCDedxTrack;
61
65
66 public:
67
70
73
75 virtual void initialize() override;
76
79 virtual void event() override;
80
82 virtual void terminate() override;
83
85 void bookOutput(std::string filename);
86
90 void recalculateDedx(CDCDedxTrack* dedxTrack, std::map<int, std::vector<double>>& l_var,
91 double (&cdcChi)[Const::ChargedStable::c_SetSize]);
92
96 double GetCorrection(int& adc, int layer, int wireID, double doca, double enta, double costheta, double ring, double time) const;
97
101 void HadronCorrection(double costheta, double& dedx) const;
102
106 double D2I(const double cosTheta, const double D) const;
107
111 double I2D(const double cosTheta, const double I) const;
112
120 void calculateMeans(double* mean, double* truncatedMean, double* truncatedMeanErr, const std::vector<double>& dedx) const;
121
125 void saveChiValue(double(&chi)[Const::ChargedStable::c_SetSize], CDCDedxTrack* dedxTrack, double dedx) const;
126
127 private:
128
130 std::vector<std::string> m_strParticleList;
131 std::vector<std::string> m_filename;
132 std::vector<TFile* > m_file;
133 std::vector<TTree* > m_tree;
143 void fillTrack(const TrackFitResult* fitResult);
144
146 void fillDedx(CDCDedxTrack* dedxTrack);
147
149 void clearEntries();
150
151 // event level information (from emd)
152 int m_expID{ -1};
153 int m_runID{ -1};
154 int m_eventID{ -1};
156 double m_injring{ -1.0};
157 double m_injtime{ -1.0};
159 // track level information (from tfr)
160 double m_d0{0.};
161 double m_z0{0.};
162 double m_dz{ -1.};
163 double m_dr{ -1.};
164 double m_dphi{ -1.};
165 double m_vx0{0.};
166 double m_vy0{0.};
167 double m_vz0{0.};
168 double m_tanlambda{ -1.};
169 double m_phi0{ -1.};
170 double m_chi2{ -1.};
172 double m_nCDChits{ -1.};
173 int m_inCDC{ -1};
174 int m_trackID{ -1};
175 double m_length{ -1.};
176 int m_charge{0};
177 double m_cosTheta{ -2.};
178 double m_pCDC{ -1.};
179 double m_p{ -1.};
180 double m_pt{ -1.};
181 double m_phi{ -1.};
182 double m_ioasym{ -1.};
183 double m_theta{ -2.};
185 // track level Mc
186 double m_PDG{ -1.};
187 // double m_motherPDG; /**< MC PID of mother particle */
188 // double m_pTrue; /**< MC true momentum */
189 // double m_trackDist; /**< the total distance traveled by the track */
190
191 // track level dE/dx measurements
192 double m_mean{ -1.};
193 double m_trunc{ -1.};
194 double m_truncNoSat{ -1.};
195 double m_error{ -1.};
197 // other dec specific information
198 double m_eop{ -1.};
199 double m_e{ -1.};
200 double m_e1_9{ -1.};
201 double m_e9_21{ -1.};
202 double m_klmLayers{ -1.};
203 double m_eclsnHits{ -1.};
205 // calibration constants
206 double m_scale{ -1.};
207 double m_cosCor{ -1.};
208 double m_cosEdgeCor{ -1.};
209 double m_runGain{ -1.};
210 double m_timeGain{ -1.};
211 double m_timeReso{ -1.};
213 // hadron cal and PID related variables
214 double m_chieOld{ -1.};
215 double m_chimuOld{ -1.};
216 double m_chipiOld{ -1.};
217 double m_chikOld{ -1.};
218 double m_chipOld{ -1.};
219 double m_chidOld{ -1.};
221 double m_chie{ -1.};
222 double m_chimu{ -1.};
223 double m_chipi{ -1.};
224 double m_chik{ -1.};
225 double m_chip{ -1.};
226 double m_chid{ -1.};
228 double m_prese{ -1.};
229 double m_presmu{ -1.};
230 double m_prespi{ -1.};
231 double m_presk{ -1.};
232 double m_presp{ -1.};
233 double m_presd{ -1.};
235 double m_pmeane{ -1.};
236 double m_pmeanmu{ -1.};
237 double m_pmeanpi{ -1.};
238 double m_pmeank{ -1.};
239 double m_pmeanp{ -1.};
240 double m_pmeand{ -1.};
242 static const int kMaxHits = 200;
243 // layer level information
244 int l_nhits{ -1};
245 int l_nhitsused{ -1};
248 int l_layer[kMaxHits] = {};
249 double l_path[kMaxHits] = {};
250 double l_dedx[kMaxHits] = {};
252 // hit level information (references on nhits)
253 int h_nhits{ -1};
254 int h_lwire[kMaxHits] = {};
255 int h_wire[kMaxHits] = {};
256 int h_layer[kMaxHits] = {};
258 double h_path[kMaxHits] = {};
259 double h_dedx[kMaxHits] = {};
260 double h_adcraw[kMaxHits] = {};
261 double h_adccorr[kMaxHits] = {};
262 double h_doca[kMaxHits] = {};
263 double h_ndoca[kMaxHits] = {};
264 double h_ndocaRS[kMaxHits] = {};
265 double h_enta[kMaxHits] = {};
266 double h_entaRS[kMaxHits] = {};
267 double h_driftT[kMaxHits] = {};
268 double h_driftD[kMaxHits] = {};
269 double h_facnladc[kMaxHits] = {};
270 double h_wireGain[kMaxHits] = {};
271 double h_twodCor[kMaxHits] = {};
272 double h_onedCor[kMaxHits] = {};
274 //Tracking variables for extra hits
280 // parameters: calibration constants
292 std::vector<double> m_hadronpars;
295 //Flag to enable and disable set of variables
300 };
302} // Belle2 namespace
Debug output for CDCDedxPID module.
Definition: CDCDedxTrack.h:25
static const unsigned int c_SetSize
Number of elements (for use in array bounds etc.)
Definition: Const.h:615
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Extracts dE/dx information for calibration testing.
double h_ndoca[kMaxHits]
normalized distance of closest approach
double h_driftD[kMaxHits]
drift distance
double h_onedCor[kMaxHits]
calibration 1D cleanup correction
int l_nhits
the total number of layer hits for this Track
double m_cosEdgeCor
calibration cosine edge correction
double m_presk
pred reso for kaon hypothesis
double m_phi0
Angle of the transverse momentum in the r-phi plane.
double m_d0
Signed distance to the POCA in the r-phi plane.
double m_presp
pred reso for proton hypothesis
double D2I(const double cosTheta, const double D) const
hadron saturation parameterization part 2
int l_wirelongesthit[kMaxHits]
the wire number of longest hit in this layer
double m_ioasym
asymmetry in increasing vs decreasing layer numbers per track
StoreObjPtr< EventLevelTriggerTimeInfo > m_TTDInfo
Store Object Ptr: EventLevelTriggerTimeInfo.
std::vector< double > m_hadronpars
hadron saturation parameters
double m_p
momentum from tracking
double m_e9_21
ratio of energies of the central 3x3 crystal vs 5x5 crystals
int m_trackID
ID number of the Track.
DBObjPtr< CDCDedxRunGain > m_DBRunGain
Run gain DB object.
double m_vx0
X coordinate of track POCA to origin.
virtual ~HitLevelInfoWriterModule()
Destructor.
StoreArray< KLMCluster > m_klmClusters
Required array of input KLMClusters.
double m_pmeand
pred mean for deuteron hypothesis
virtual void initialize() override
Initialize the module.
DBObjPtr< CDCDedxHadronCor > m_DBHadronCor
hadron saturation parameters
double h_enta[kMaxHits]
entrance angle
double m_chipOld
chi value for proton hypothesis
std::string m_strOutputBaseName
Base name for the output ROOT files.
virtual void event() override
This method is called for each event.
double h_WeightKaonHypo[kMaxHits]
weight for kaon hypothesis from KalmanFitterInfo
DBObjPtr< CDCDedxCosineEdge > m_DBCosEdgeCor
cosine edge calibration
HitLevelInfoWriterModule()
Default constructor.
double m_pmeanp
pred mean for proton hypothesis
double I2D(const double cosTheta, const double I) const
hadron saturation parameterization part 1
double h_WeightProtonHypo[kMaxHits]
weight for proton hypothesis from KalmanFitterInfo
double m_chid
modified chi value for deuteron hypothesis
double m_chikOld
chi value for kaon hypothesis
double m_dz
vertex or POCA in case of tracks z in respect to IPs
bool m_isHitLevel
Flag to switch on/off hit level info.
DBObjPtr< CDCDedxADCNonLinearity > m_DBNonlADC
hadron saturation non linearity
double m_pmeank
pred mean for kaon hypothesis
double h_facnladc[kMaxHits]
calibration hit gain
DBObjPtr< CDCDedx1DCell > m_DB1DCell
1D correction DB object
void saveChiValue(double(&chi)[Const::ChargedStable::c_SetSize], CDCDedxTrack *dedxTrack, double dedx) const
for all particles, save chi values into 'chi' chi array of chi values to be modified
StoreArray< TrackFitResult > m_trackFitResults
Required array of input TrackFitResults.
int h_nhits
the number of good hits for this Track
std::vector< std::string > m_filename
full names of the output ROOT files
virtual void terminate() override
End of the event processing.
double h_adccorr[kMaxHits]
charge per hit corr by nonlinear ADC
std::vector< TTree * > m_tree
output ROOT trees
double m_presmu
pred reso for muon hypothesis
double m_cosCor
calibration cosine correction
double m_tanlambda
Slope of the track in the r-z plane.
int h_layer[kMaxHits]
layer number
double h_adcraw[kMaxHits]
charge per hit
int m_expID
experiment in which this Track was found
void fillTrack(const TrackFitResult *fitResult)
Fill the TTree with the information from the track fit.
double h_path[kMaxHits]
path length in cell
double m_chimu
modified chi value for muon hypothesis
double m_vy0
Y coordinate of track POCA to origin.
double m_chik
modified chi value for kaon hypothesis
void recalculateDedx(CDCDedxTrack *dedxTrack, std::map< int, std::vector< double > > &l_var, double(&cdcChi)[Const::ChargedStable::c_SetSize])
Function to recalculate the dedx with latest constants.
double m_chi2
chi^2 from track fit
void HadronCorrection(double costheta, double &dedx) const
Function to apply the hadron correction.
void calculateMeans(double *mean, double *truncatedMean, double *truncatedMeanErr, const std::vector< double > &dedx) const
Save arithmetic and truncated mean for the 'dedx' values.
double h_wireGain[kMaxHits]
calibration hit gain
double m_theta
cos(theta) for the track
double h_twodCor[kMaxHits]
calibration 2D correction
double m_chie
modified chi value for electron hypothesis
DBObjPtr< CDCDedx2DCell > m_DB2DCell
2D correction DB object
double m_runGain
calibration run gain
int m_eventID
event in which this Track was found
double m_timeGain
calibration injection time gain
void bookOutput(std::string filename)
Create the output TFiles and TTrees.
double m_chidOld
chi value for deuteron hypothesis
bool m_isExtraVar
Flag to switch on/off extra level info and some available w/ release/5 only.
void clearEntries()
Clear the arrays before filling an event.
std::vector< TFile * > m_file
output ROOT files
double m_dr
track d0 relative to IP
double m_prese
pred reso for electron hypothesis
DBObjPtr< CDCDedxCosineCor > m_DBCosineCor
Electron saturation correction DB object.
int h_foundByTrackFinder[kMaxHits]
the 'found by track finder' flag for the given hit
double m_timeReso
calibration injection time reso
StoreArray< Track > m_tracks
Required array of input Tracks.
double l_dedx[kMaxHits]
dE/dx for this layer
double l_path[kMaxHits]
distance travelled in this layer
int l_layer[kMaxHits]
layer number
double m_chipiOld
chi value for pion hypothesis
double m_chip
modified chi value for proton hypothesis
bool m_isCorrection
Flag to switch on/off corrections.
double m_pmeane
pred mean for electron hypothesis
double m_cosTheta
cos(theta) for the track
int l_nhitsused
the total number of layer hits used for this Track
StoreArray< ECLCluster > m_eclClusters
Required array of input ECLClusters.
double h_dedx[kMaxHits]
charge per path length
double m_chieOld
chi value for electron hypothesis
double h_driftT[kMaxHits]
drift time
double m_dphi
POCA in degrees in respect to IP.
DBObjPtr< CDCDedxWireGain > m_DBWireGains
Wire gain DB object.
double m_eop
energy over momentum in the calorimeter
bool m_isDeadwire
write only active wires
double m_presd
pred reso for deuteron hypothesis
double m_scale
calibration scale factor
double m_klmLayers
number of klm layers with hits
int l_nhitscombined[kMaxHits]
the number of hits combined this layer
double m_error
standard deviation of the truncated mean
double m_pCDC
momentum valid in CDC
double m_truncNoSat
dE/dx averaged, truncated mean, with corrections (not hadron)
double m_length
total path length of the Track
double m_injring
HER injection status.
double m_nCDChits
Number of CDC hits associated to the track.
static const int kMaxHits
default hit level index
double h_ndocaRS[kMaxHits]
normalized +RS distance of closest approach
double m_vz0
Z coordinate of track POCA to origin.
double m_trunc
dE/dx averaged, truncated mean, with corrections
double GetCorrection(int &adc, int layer, int wireID, double doca, double enta, double costheta, double ring, double time) const
Function to get the correction factor.
int m_inCDC
frack is CDC acceptance or not
double h_doca[kMaxHits]
distance of closest approach
double m_chimuOld
chi value for muon hypothesis
double m_z0
z coordinate of the POCA
int m_charge
the charge for this Track
double h_WeightPionHypo[kMaxHits]
weight for pion hypothesis from KalmanFitterInfo
int m_runID
run in which this Track was found
double m_e
energy in the calorimeter
StoreArray< CDCDedxTrack > m_dedxTracks
Required array of CDCDedxTracks.
double m_injtime
time since last injection in micro seconds
double m_pmeanmu
pred mean for muon hypothesis
double h_entaRS[kMaxHits]
normalized + RS distance of entrance angle
bool m_isRelative
Flag to switch on/off relative constants.
double m_prespi
pred reso for pion hypothesis
DBObjPtr< CDCDedxInjectionTime > m_DBInjectTime
time gain/reso DB object
int h_wire[kMaxHits]
sense wire ID
DBObjPtr< CDCDedxScaleFactor > m_DBScaleFactor
Scale factor to make electrons ~1.
int h_lwire[kMaxHits]
sense wire within layer
double m_chipi
modified chi value for pion hypothesis
std::vector< std::string > m_strParticleList
Vector of ParticleLists to write out.
double m_pt
transverse momentum from tracking
double m_pmeanpi
pred mean for pion hypothesis
void fillDedx(CDCDedxTrack *dedxTrack)
Fill the TTree with the information from a CDCDedxTrack object.
double m_e1_9
ratio of energies of the central 1 crystal vs 3x3 crystals
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
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.
Abstract base class for different kinds of events.