Belle II Software release-09-00-00
CDCDedxPIDCreatorModule.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 <framework/core/Module.h>
12#include <framework/logging/Logger.h>
13#include <framework/datastore/StoreArray.h>
14#include <mdst/dataobjects/Track.h>
15#include <mdst/dataobjects/MCParticle.h>
16#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
17#include <cdc/dataobjects/CDCDedxHit.h>
18#include <cdc/dataobjects/CDCDedxTrack.h>
19#include <cdc/dataobjects/CDCDedxLikelihood.h>
20
21#include <framework/database/DBObjPtr.h>
22#include <cdc/dbobjects/CDCDedxScaleFactor.h>
23#include <cdc/dbobjects/CDCDedxWireGain.h>
24#include <cdc/dbobjects/CDCDedxRunGain.h>
25#include <cdc/dbobjects/CDCDedxCosineCor.h>
26#include <cdc/dbobjects/CDCDedx2DCell.h>
27#include <cdc/dbobjects/CDCDedx1DCell.h>
28#include <cdc/dbobjects/CDCDedxADCNonLinearity.h>
29#include <cdc/dbobjects/CDCDedxCosineEdge.h>
30#include <cdc/dbobjects/CDCDedxMeanPars.h>
31#include <cdc/dbobjects/CDCDedxSigmaPars.h>
32#include <cdc/dbobjects/CDCDedxHadronCor.h>
33#include <cdc/dbobjects/CDCDedxInjectionTime.h>
34
35#include <string.h>
36
37namespace Belle2 {
50
51 public:
52
55
58
60 virtual void initialize() override;
61
63 virtual void event() override;
64
65 private:
66
70 struct DEDX {
71 const CDCDedxHit* hit = nullptr;
72 int cWire = -1;
73 int cLayer = -1;
74 double dx = 0;
75 double dE = 0;
76 int nhits = 0;
77 double dxMax = 0;
87 void add(const CDCDedxHit& hit_in, int cWire_in, int cLayer_in, double dx_in, double dE_in)
88 {
89 if (not hit) {
90 hit = &hit_in;
91 cWire = cWire_in;
92 cLayer = cLayer_in;
93 dx = dx_in;
94 dE = dE_in;
95 nhits = 1;
96 dxMax = dx;
97 } else if (hit_in.getWireID() == hit->getWireID()) {
98 dx += dx_in;
99 if (hit->getADCCount() != hit_in.getADCCount()) dE += dE_in; // these hits are not piled-up
100 nhits++;
101 if (dx_in > dxMax) dxMax = dx_in;
102 } else {
103 B2ERROR("DEDX helper: measurements on different wires cannot be merged");
104 }
105 }
106
111 void add(const DEDX& dedx)
112 {
113 if (cLayer < 0) {
114 cWire = dedx.cWire;
115 cLayer = dedx.cLayer;
116 dx = dedx.dx;
117 dE = dedx.dE;
118 nhits = dedx.nhits;
119 dxMax = dedx.dxMax;
120 } else if (dedx.cLayer == cLayer) {
121 dx += dedx.dx;
122 dE += dedx.dE;
123 nhits += dedx.nhits;
124 if (dedx.dxMax > dxMax) {
125 dxMax = dedx.dxMax;
126 cWire = dedx.cWire; // wire ID with longest hit
127 }
128 } else {
129 B2ERROR("DEDX helper: measurements in different layers cannot be merged");
130 }
131 }
132 };
133
134 // module steering parameters
140 std::string m_likelihoodsName;
141 std::string m_dedxTracksName;
143 // collections
151 // parameters: calibration constants
162 // parameters to determine the predicted means and resolutions, and hadron correction
167 // other
168 int m_nLayerWires[9] = {0};
169 int m_warnCount = 0;
171 };
172
174} // Belle2 namespace
175
Class to store CDC hit information needed for dedx.
Definition: CDCDedxHit.h:26
const WireID & getWireID() const
Returns wire identifier.
Definition: CDCDedxHit.h:66
unsigned short getADCCount() const
Returns ADC count.
Definition: CDCDedxHit.h:78
Module that creates PID likelihoods from CDC hit information stored in CDCDedxHits using parameterize...
bool m_useBackHalfCurlers
whether to use the back half of curlers
StoreObjPtr< EventLevelTriggerTimeInfo > m_TTDInfo
injection time info
DBObjPtr< CDCDedxRunGain > m_DBRunGain
Run gain DB object.
DBObjPtr< CDCDedxMeanPars > m_DBMeanPars
dE/dx mean parameters
DBObjPtr< CDCDedxHadronCor > m_DBHadronCor
hadron saturation parameters
std::string m_dedxTracksName
name of collection of debug output
double m_removeHighest
portion of events with high dE/dx to discard
DBObjPtr< CDCDedxCosineEdge > m_DBCosEdgeCor
non-linearly ACD correction DB object
DBObjPtr< CDCDedxADCNonLinearity > m_DBNonlADC
non-linearly ACD correction DB object
DBObjPtr< CDCDedx1DCell > m_DB1DCell
1D correction DB object
StoreArray< CDCDedxLikelihood > m_likelihoods
collection of PID likelihoods
DBObjPtr< CDCDedx2DCell > m_DB2DCell
2D correction DB object
DBObjPtr< CDCDedxCosineCor > m_DBCosineCor
Electron saturation correction DB object.
StoreArray< Track > m_tracks
collection of tracks
int m_nLayerWires[9]
lookup table for number of wires per superlayer (indexed by superlayer)
DBObjPtr< CDCDedxSigmaPars > m_DBSigmaPars
dE/dx resolution parameters
DBObjPtr< CDCDedxWireGain > m_DBWireGains
Wire gain DB object.
bool m_trackLevel
whether to use track-level or hit-level MC
StoreArray< CDCDedxHit > m_hits
collection of hits
StoreArray< MCParticle > m_mcParticles
collection of MC particles
double m_removeLowest
portion of events with low dE/dx to discard
StoreArray< CDCDedxTrack > m_dedxTracks
collection of debug output
bool m_enableDebugOutput
option to write out debugging information to CDCDedxTracks
std::string m_likelihoodsName
name of collection of PID likelihoods
DBObjPtr< CDCDedxInjectionTime > m_DBInjectTime
time gain/reso DB object
DBObjPtr< CDCDedxScaleFactor > m_DBScaleFactor
Scale factor to make electrons ~1.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
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
virtual void initialize() override
Initialize the module.
CDCDedxPIDCreatorModule()
Default constructor.
virtual void event() override
This method is called for each event.
Abstract base class for different kinds of events.
Helper structure for merging dEdx measurements.
void add(const DEDX &dedx)
Add measurement in the same layer.
void add(const CDCDedxHit &hit_in, int cWire_in, int cLayer_in, double dx_in, double dE_in)
Add measurement on the same wire.