Belle II Software development
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 {
47
48 public:
49
52
55
57 virtual void initialize() override;
58
60 virtual void event() override;
61
62 private:
63
67 struct DEDX {
68 const CDCDedxHit* hit = nullptr;
69 int cWire = -1;
70 int cLayer = -1;
71 double dx = 0;
72 double dE = 0;
73 int nhits = 0;
74 double dxMax = 0;
84 void add(const CDCDedxHit& hit_in, int cWire_in, int cLayer_in, double dx_in, double dE_in)
85 {
86 if (not hit) {
87 hit = &hit_in;
88 cWire = cWire_in;
89 cLayer = cLayer_in;
90 dx = dx_in;
91 dE = dE_in;
92 nhits = 1;
93 dxMax = dx;
94 } else if (hit_in.getWireID() == hit->getWireID()) {
95 dx += dx_in;
96 if (hit->getADCCount() != hit_in.getADCCount()) dE += dE_in; // these hits are not piled-up
97 nhits++;
98 if (dx_in > dxMax) dxMax = dx_in;
99 } else {
100 B2ERROR("DEDX helper: measurements on different wires cannot be merged");
101 }
102 }
103
108 void add(const DEDX& dedx)
109 {
110 if (cLayer < 0) {
111 cWire = dedx.cWire;
112 cLayer = dedx.cLayer;
113 dx = dedx.dx;
114 dE = dedx.dE;
115 nhits = dedx.nhits;
116 dxMax = dedx.dxMax;
117 } else if (dedx.cLayer == cLayer) {
118 dx += dedx.dx;
119 dE += dedx.dE;
120 nhits += dedx.nhits;
121 if (dedx.dxMax > dxMax) {
122 dxMax = dedx.dxMax;
123 cWire = dedx.cWire; // wire ID with longest hit
124 }
125 } else {
126 B2ERROR("DEDX helper: measurements in different layers cannot be merged");
127 }
128 }
129 };
130
131 // module steering parameters
137 std::string m_likelihoodsName;
138 std::string m_dedxTracksName;
140 // collections
148 // parameters: calibration constants
159 // parameters to determine the predicted means and resolutions, and hadron correction
164 // other
165 int m_nLayerWires[9] = {0};
166 int m_warnCount = 0;
168 };
169
171} // Belle2 namespace
172
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:95
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.