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
35namespace Belle2 {
40
45
46 public:
47
50
53
55 virtual void initialize() override;
56
58 virtual void event() override;
59
60 private:
61
65 struct DEDX {
66 const CDCDedxHit* hit = nullptr;
67 int cWire = -1;
68 int cLayer = -1;
69 double dx = 0;
70 double dE = 0;
71 int nhits = 0;
72 double dxMax = 0;
73
82 void add(const CDCDedxHit& hit_in, int cWire_in, int cLayer_in, double dx_in, double dE_in)
83 {
84 if (not hit) {
85 hit = &hit_in;
86 cWire = cWire_in;
87 cLayer = cLayer_in;
88 dx = dx_in;
89 dE = dE_in;
90 nhits = 1;
91 dxMax = dx;
92 } else if (hit_in.getWireID() == hit->getWireID()) {
93 dx += dx_in;
94 if (hit->getADCCount() != hit_in.getADCCount()) dE += dE_in; // these hits are not piled-up
95 nhits++;
96 if (dx_in > dxMax) dxMax = dx_in;
97 } else {
98 B2ERROR("DEDX helper: measurements on different wires cannot be merged");
99 }
100 }
101
106 void add(const DEDX& dedx)
107 {
108 if (cLayer < 0) {
109 cWire = dedx.cWire;
110 cLayer = dedx.cLayer;
111 dx = dedx.dx;
112 dE = dedx.dE;
113 nhits = dedx.nhits;
114 dxMax = dedx.dxMax;
115 } else if (dedx.cLayer == cLayer) {
116 dx += dedx.dx;
117 dE += dedx.dE;
118 nhits += dedx.nhits;
119 if (dedx.dxMax > dxMax) {
120 dxMax = dedx.dxMax;
121 cWire = dedx.cWire; // wire ID with longest hit
122 }
123 } else {
124 B2ERROR("DEDX helper: measurements in different layers cannot be merged");
125 }
126 }
127 };
128
129 // module steering parameters
135 std::string m_likelihoodsName;
136 std::string m_dedxTracksName;
137
138 // collections
145
146 // parameters: calibration constants
156
157 // parameters to determine the predicted means and resolutions, and hadron correction
161
162 // other
163 int m_nLayerWires[9] = {0};
164 int m_warnCount = 0;
165
166 };
167
169} // Belle2 namespace
170
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
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
Module()
Constructor.
Definition Module.cc:30
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.
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.