Belle II Software development
KLMEventT0EstimatorModule.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/* KLM geometry & dataobjects */
12#include <klm/bklm/geometry/GeometryPar.h>
13#include <klm/eklm/geometry/GeometryData.h>
14#include <klm/eklm/geometry/TransformData.h>
15#include <klm/dataobjects/KLMHit2d.h>
16#include <klm/dataobjects/KLMDigit.h>
17#include <klm/dataobjects/bklm/BKLMHit1d.h>
18#include <klm/dataobjects/KLMElementNumbers.h>
19#include <klm/dataobjects/KLMMuidLikelihood.h>
20
21/* KLM conditions */
22#include <klm/dbobjects/KLMChannelStatus.h>
23#include <klm/dbobjects/KLMTimeConstants.h>
24#include <klm/dbobjects/KLMTimeCableDelay.h>
25#include <klm/dbobjects/KLMEventT0HitResolution.h>
26
27/* Tracking / analysis */
28#include <mdst/dataobjects/Track.h>
29#include <tracking/dataobjects/ExtHit.h>
30#include <analysis/dataobjects/Particle.h>
31#include <analysis/dataobjects/ParticleList.h>
32
33/* Framework */
34#include <framework/core/HistoModule.h>
35#include <framework/datastore/StoreObjPtr.h>
36#include <framework/datastore/StoreArray.h>
37#include <framework/database/DBObjPtr.h>
38#include <framework/datastore/RelationVector.h>
39#include <framework/dataobjects/EventT0.h>
40#include <framework/dataobjects/EventExtraInfo.h>
41#include <framework/gearbox/Unit.h>
42
43/* ROOT headers. */
44#include <TDirectory.h>
45#include <TH1D.h>
46#include <TH1I.h>
47
48/* C++ headers. */
49#include <cmath>
50#include <vector>
51#include <map>
52#include <string>
53#include <utility>
54
55namespace Belle2 {
60
91 class KLMEventT0EstimatorModule : public HistoModule {
92
93 public:
94 KLMEventT0EstimatorModule();
95 ~KLMEventT0EstimatorModule() override;
96
98 KLMEventT0EstimatorModule(const KLMEventT0EstimatorModule&) = delete;
99
101 KLMEventT0EstimatorModule& operator=(const KLMEventT0EstimatorModule&) = delete;
102
104 void defineHisto() override;
105
107 void initialize() override;
108
110 void beginRun() override;
111
113 void event() override;
114
117 double sumW{0.0};
118 double sumWT{0.0};
119 int nHits{0};
120 int sumSector{0};
121 int sumSection{0};
122 };
123
124 private:
125 /* Local helpers. */
126
128 using ExtMap = std::multimap<unsigned int, Belle2::ExtHit>;
129
131 using ExtPair = std::pair<Belle2::ExtHit*, Belle2::ExtHit*>;
132
137
146 bool passesADCCut(double charge, int subdetector, int layer, bool inRPC) const;
147
149 void collectExtrapolatedHits(const Track* track, ExtMap& scintMap, ExtMap& rpcMap);
150
152 ExtPair matchExt(unsigned int key, ExtMap& v_ExtHits);
153
163 double getHitSigma(int subdetector, int layer, bool inRPC) const;
164
170 CategorySums& sums);
171
176 CategorySums& sums);
177
184 void accumulateBKLMRPC(RelationVector<KLMHit2d>& klmHit2ds, const ExtMap& rpcMap,
185 CategorySums& sums);
186
187 /* ---------- Parameters (set via addParam in constructor) ---------- */
188
190 std::string m_MuonListName;
191
194
196 bool m_ignoreBackward{false};
197
199 std::string m_histDirName;
200
202 std::string m_histSubdirUncorr{"uncorrected"};
203
204 /* Geometry and conditions. */
205
208
211
214
217
220
223
224 /* Inputs. */
225
228
231
234
235 /* Working buffers. */
236
239
242
244 double m_seedT0{0.0};
245
246 /* Monitoring histograms. */
247
249 TH1D* m_hT0Trk_BKLM_Scint{nullptr};
250
252 TH1D* m_hT0Trk_BKLM_RPC{nullptr};
253
255 TH1D* m_hT0Trk_EKLM_Scint{nullptr};
256
259
262
265
267 TH1D* m_hT0Evt_TrkAvg_All{nullptr};
268
271
274
277
280
282 TH1I* m_hFinalSource{nullptr};
283 };
284
286} // namespace Belle2
Class for accessing objects in the database.
Definition DBObjPtr.h:21
EKLM geometry data.
Transformation data.
HistoModule()
Constructor.
Definition HistoModule.h:32
static const KLMElementNumbers & Instance()
Instantiation.
Belle2::EKLM::TransformData * m_transformE
EKLM strip transformation data.
TH1D * m_hT0Evt_TrkAvg_BKLM_RPC_SEM
Per-event T0 track-average for BKLM RPC (SEM) [ns].
TH1D * m_hT0Evt_TrkAvg_EKLM_Scint_SEM
Per-event T0 track-average for EKLM scintillator (SEM) [ns].
TH1D * m_hT0Trk_BKLM_RPC
Per-track T0 for BKLM RPC [ns].
double m_ADCCut_BKLM_Scint_Min
Minimum ADC cut for BKLM scintillator.
TH1D * m_hT0Trk_EKLM_Scint
Per-track T0 for EKLM scintillator [ns].
TH1I * m_hFinalSource
Final EventT0 source selection (7 bins).
std::string m_histDirName
Parent directory inside the ROOT file (HistoManager) for this module.
ExtPair matchExt(unsigned int key, ExtMap &v_ExtHits)
Find earliest (entry) and latest (exit) ExtHits matching a key (channel or module).
const Belle2::EKLM::GeometryData * m_geoParE
EKLM geometry data.
double getHitSigma(int subdetector, int layer, bool inRPC) const
Get per-hit sigma for a digit based on detector category.
TH1D * m_hT0Trk_BKLM_Scint
Per-track T0 for BKLM scintillator [ns].
bool m_useCDCTemporaryT0
Use CDC temporary EventT0 as a diagnostic seed (not applied to averaging).
void initialize() override
Register inputs/params; get geometry; call REG_HISTOGRAM.
void event() override
Per-event algorithm: collect hits, compute residuals, fill outputs.
void accumulateEKLM(const RelationVector< KLMHit2d > &, const ExtMap &, CategorySums &sums)
Accumulate EKLM scintillator per-digit T0 estimates (weighted).
std::string m_histSubdirUncorr
Subdirectory name for uncorrected timing histograms.
DBObjPtr< KLMEventT0HitResolution > m_eventT0HitResolution
Per-hit time resolution for EventT0 estimation.
std::multimap< unsigned int, Belle2::ExtHit > ExtMap
Multimap of ExtHit objects keyed by channel or module number.
ExtMap m_extRPC
Extrapolated hits keyed by module number (RPC).
void accumulateBKLMScint(RelationVector< KLMHit2d > &, const ExtMap &, CategorySums &sums)
Accumulate BKLM scintillator per-digit T0 estimates (weighted).
TH1D * m_hT0Evt_TrkAvg_BKLM_Scint_SEM
Per-event T0 track-average for BKLM scintillator (SEM) [ns].
void collectExtrapolatedHits(const Track *track, ExtMap &scintMap, ExtMap &rpcMap)
Build maps of extrapolated hits for a track (scint: channel key; RPC: module key).
double m_ADCCut_BKLM_Scint_Max
Maximum ADC cut for BKLM scintillator.
DBObjPtr< KLMChannelStatus > m_channelStatus
Channel status (Normal/Dead/etc.).
StoreObjPtr< ParticleList > m_MuonList
Selected muon particle list.
void beginRun() override
Per-run resets if desired (histos remain booked).
StoreArray< Track > m_tracks
Reconstructed tracks.
double m_ADCCut_EKLM_Scint_Max
Maximum ADC cut for EKLM scintillator.
bool passesADCCut(double charge, int subdetector, int layer, bool inRPC) const
Check if a digit passes the ADC charge cut.
double m_ADCCut_EKLM_Scint_Min
Minimum ADC cut for EKLM scintillator.
Belle2::bklm::GeometryPar * m_geoParB
BKLM geometry.
bool m_ignoreBackward
Ignore backward-propagated ExtHits when forming entry/exit pairs.
TH1D * m_hT0Evt_TrkAvg_BKLM_Scint
Per-event T0 track-average for BKLM scintillator (mean) [ns].
std::pair< Belle2::ExtHit *, Belle2::ExtHit * > ExtPair
Pair of entry and exit ExtHit pointers.
KLMEventT0EstimatorModule & operator=(const KLMEventT0EstimatorModule &)=delete
Copying is not allowed: the module manages raw pointers.
double m_seedT0
Optional seed from CDC (for logging only).
std::string m_MuonListName
Input ParticleList (e.g.
StoreObjPtr< EventExtraInfo > m_eventExtraInfo
Event extra info, receives the per-event result of each category.
TH1D * m_hT0Evt_TrkAvg_All
Per-event T0 track-average combined (mean) [ns].
const KLMElementNumbers * m_elementNum
Element numbering helpers.
TH1D * m_hT0Evt_TrkAvg_All_SEM
Per-event T0 track-average combined (SEM) [ns].
TH1D * m_hT0Evt_TrkAvg_BKLM_RPC
Per-event T0 track-average for BKLM RPC (mean) [ns].
KLMEventT0EstimatorModule(const KLMEventT0EstimatorModule &)=delete
Copying is not allowed: the module manages raw pointers.
ExtMap m_extScint
Extrapolated hits keyed by channel number (scintillator).
void accumulateBKLMRPC(RelationVector< KLMHit2d > &klmHit2ds, const ExtMap &rpcMap, CategorySums &sums)
Accumulate BKLM RPC per-digit T0 estimates (weighted, both readout directions).
TH1D * m_hT0Evt_TrkAvg_EKLM_Scint
Per-event T0 track-average for EKLM scintillator (mean) [ns].
void defineHisto() override
Definition of histograms (called once by HistoManager).
Class for type safe access to objects that are referred to in relations.
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
Class that bundles various TrackFitResults.
Definition Track.h:25
Provides BKLM geometry parameters for simulation, reconstruction etc (from Gearbox or DataBase)
Definition GeometryPar.h:37
Abstract base class for different kinds of events.
Running sums of the hits of one category on one track.
int sumSector
Sum of the sector numbers of the hits used.
double sumW
Sum of the hit weights 1/sigma^2 [1/ns^2].
double sumWT
Sum of weight times hit T0 [1/ns].
int sumSection
Sum of the section numbers of the hits used.