CMS 3D CMS Logo

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