Belle II Software  release-08-01-10
BKLMHit1d.cc
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 /* Own header. */
10 #include <klm/dataobjects/bklm/BKLMHit1d.h>
11 
12 /* KLM headers. */
13 #include <klm/dataobjects/bklm/BKLMStatus.h>
14 
15 /* Basf2 headers. */
16 #include <framework/logging/Logger.h>
17 
18 /* C++ headers. */
19 #include <algorithm>
20 #include <climits>
21 
22 using namespace Belle2;
23 
24 // empty constructor for ROOT - do not use this
27  m_ModuleID(0),
28  m_Time(0.0),
29  m_EnergyDeposit(0.0)
30 {
31 }
32 
33 BKLMHit1d::BKLMHit1d(const std::vector<std::pair<const KLMDigit*, double>>& digitsWithTime) :
35  m_ModuleID(0),
36  m_Time(0.0),
37  m_EnergyDeposit(0.0)
38 {
39  if (digitsWithTime.size() == 0) {
40  B2WARNING("Attempt to create a BKLMHit1d with no KLMDigits");
41  return;
42  }
43  int stripMin = INT_MAX;
44  int stripMax = INT_MIN;
45  const KLMDigit* bklmDigit = digitsWithTime.front().first;
46  if (bklmDigit->getSubdetector() != KLMElementNumbers::c_BKLM)
47  B2FATAL("Trying to construct a BKLMHit1d using KLMDigits from EKLM.");
53  for (const std::pair<const KLMDigit*, double>& digitWithTime : digitsWithTime) {
54  const KLMDigit* digit = digitWithTime.first;
55  double correctedTime = digitWithTime.second;
56  if (!(bklmDigit->getSection() == digit->getSection() &&
57  bklmDigit->getSector() == digit->getSector() &&
58  bklmDigit->getLayer() == digit->getLayer() &&
59  bklmDigit->getPlane() == digit->getPlane())) {
60  B2WARNING("Attempt to combine non-parallel or distinct-module KLMDigits");
61  continue;
62  }
63  m_Time += correctedTime;
65  int strip = digit->getStrip();
66  stripMin = std::min(stripMin, strip);
67  stripMax = std::max(stripMax, strip);
68  if (digit->isMultiStrip()) {
69  m_Time += correctedTime * (digit->getLastStrip() - strip);
70  stripMax = std::max(stripMax, digit->getLastStrip());
71  }
72  addRelationTo(digit);
73  }
74 
75  if (stripMax >= stripMin) {
76  m_Time /= ((stripMax - stripMin) + 1.0);
79  }
80 }
81 
82 // Copy constructor
84  RelationsObject(h),
85  m_ModuleID(h.m_ModuleID),
86  m_Time(h.m_Time),
87  m_EnergyDeposit(h.m_EnergyDeposit)
88 {
89 }
90 
91 // Assignment operator
93 {
94  m_ModuleID = h.m_ModuleID;
95  m_Time = h.m_Time;
96  m_EnergyDeposit = h.m_EnergyDeposit;
97  return *this;
98 }
static void setStripInModule(int &module, int strip)
Set strip number in module identifier.
static void setLayerInModule(int &module, int layer)
Set layer number in module identifier.
static void setSectionInModule(int &module, int section)
Set section number in module identifier.
static void setSectorInModule(int &module, int sector)
Set sector number in module identifier.
static void setPlaneInModule(int &module, int plane)
Set plane number in module identifier.
Store one reconstructed BKLM 1D hit as a ROOT object.
Definition: BKLMHit1d.h:30
BKLMHit1d()
Empty constructor for ROOT IO (needed to make the class storable)
Definition: BKLMHit1d.cc:25
float m_Time
reconstructed hit time (ns)
Definition: BKLMHit1d.h:152
float m_EnergyDeposit
reconstructed pulse height (MeV)
Definition: BKLMHit1d.h:155
int m_ModuleID
detector-module identifier
Definition: BKLMHit1d.h:149
BKLMHit1d & operator=(const BKLMHit1d &)
Assignment operator.
Definition: BKLMHit1d.cc:92
static void setMaximalStrip(int &module, int strip)
Set maximal strip number.
Definition: BKLMStatus.h:49
KLM digit (class representing a digitized hit in RPCs or scintillators).
Definition: KLMDigit.h:29
int getSubdetector() const
Get subdetector number.
Definition: KLMDigit.h:72
int getLayer() const
Get layer number.
Definition: KLMDigit.h:126
int getSection() const
Get section number.
Definition: KLMDigit.h:90
int getPlane() const
Get plane number.
Definition: KLMDigit.h:144
int getStrip() const
Get strip number.
Definition: KLMDigit.h:162
bool isMultiStrip() const
Determine whether this digit is a multi-strip one or not.
Definition: KLMDigit.h:197
int getSector() const
Get sector number.
Definition: KLMDigit.h:108
int getLastStrip() const
Get last strip number (for multi-strip digits).
Definition: KLMDigit.h:180
float getEnergyDeposit() const
Get energy deposit.
Definition: KLMDigit.h:294
Defines interface for accessing relations of objects in StoreArray.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Abstract base class for different kinds of events.