CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HFPreRecHit.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
2 #define DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
3 
4 #include <utility>
5 
7 
14 class HFPreRecHit {
15 public:
17 
18  constexpr HFPreRecHit() : hasInfo_{false, false} {}
19 
20  // In the constructor below, either "first" or "second"
21  // pointer can be nullptr
22  constexpr HFPreRecHit(const HcalDetId& id, const HFQIE10Info* first, const HFQIE10Info* second)
23  : id_(id), hasInfo_{false, false} {
24  if (first) {
25  hfQIE10Info_[0] = *first;
26  hasInfo_[0] = true;
27  }
28  if (second) {
29  hfQIE10Info_[1] = *second;
30  hasInfo_[1] = true;
31  }
32  }
33 
34  constexpr HcalDetId id() const { return id_; }
35 
36  // Get a pointer to the QIE10 info. nullptr will be returned
37  // if the info with the given index does not exist or if the
38  // index is out of range.
39  constexpr HFQIE10Info const* getHFQIE10Info(unsigned index) const {
40  if (index < 2 && hasInfo_[index])
41  return &hfQIE10Info_[index];
42  else
43  return nullptr;
44  }
45 
46  // Quantities simply added from both anodes
47  constexpr float charge() const {
48  float q = 0.f;
49  for (unsigned i = 0; i < 2; ++i)
50  if (hasInfo_[i])
51  q += hfQIE10Info_[i].charge();
52  return q;
53  }
54  constexpr float energy() const {
55  float e = 0.f;
56  for (unsigned i = 0; i < 2; ++i)
57  if (hasInfo_[i])
58  e += hfQIE10Info_[i].energy();
59  return e;
60  }
61 
62  // The following function returns a pair.
63  // The first element of the pair is the charge asymmetry,
64  // if calculated. The second element of the pair indicates
65  // whether the asymmetry is actually calculated. "true"
66  // means yes, it is. The asymmetry is calculated if all
67  // of the following conditions are satisfied:
68  //
69  // 1) The data is available for both PMT anodes.
70  // 2) The sum of the charges is positive.
71  // 3) The sum of the charges is at least "chargeThreshold".
72  //
73  // If the asymmetry is not calculated, the first element of
74  // the pair is set to 0 and the second to "false".
75  //
76  std::pair<float, bool> chargeAsymmetry(float chargeThreshold) const;
77 
78  // Similar function for the energy asymmetry
79  std::pair<float, bool> energyAsymmetry(float energyThreshold) const;
80 
81 private:
83 
85  bool hasInfo_[2];
86 };
87 
88 #endif // DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
constexpr HFPreRecHit(const HcalDetId &id, const HFQIE10Info *first, const HFQIE10Info *second)
Definition: HFPreRecHit.h:22
HcalDetId key_type
Definition: HFPreRecHit.h:16
HcalDetId id_
Definition: HFPreRecHit.h:82
U second(std::pair< T, U > const &p)
constexpr HcalDetId id() const
Definition: HFPreRecHit.h:34
constexpr HFPreRecHit()
Definition: HFPreRecHit.h:18
constexpr float charge() const
Definition: HFQIE10Info.h:79
constexpr float energy() const
Definition: HFQIE10Info.h:80
constexpr float charge() const
Definition: HFPreRecHit.h:47
std::pair< float, bool > energyAsymmetry(float energyThreshold) const
Definition: HFPreRecHit.cc:17
constexpr HFQIE10Info const * getHFQIE10Info(unsigned index) const
Definition: HFPreRecHit.h:39
HFQIE10Info hfQIE10Info_[2]
Definition: HFPreRecHit.h:84
std::pair< float, bool > chargeAsymmetry(float chargeThreshold) const
Definition: HFPreRecHit.cc:3
bool hasInfo_[2]
Definition: HFPreRecHit.h:85
constexpr float energy() const
Definition: HFPreRecHit.h:54