File indexing completed on 2024-04-06 12:04:19
0001 #ifndef DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
0002 #define DATAFORMATS_HCALRECHIT_HFPRERECHIT_H
0003
0004 #include <utility>
0005
0006 #include "DataFormats/HcalRecHit/interface/HFQIE10Info.h"
0007
0008
0009
0010
0011
0012
0013
0014 class HFPreRecHit {
0015 public:
0016 typedef HcalDetId key_type;
0017
0018 constexpr HFPreRecHit() : hasInfo_{false, false} {}
0019
0020
0021
0022 constexpr HFPreRecHit(const HcalDetId& id, const HFQIE10Info* first, const HFQIE10Info* second)
0023 : id_(id), hasInfo_{false, false} {
0024 if (first) {
0025 hfQIE10Info_[0] = *first;
0026 hasInfo_[0] = true;
0027 }
0028 if (second) {
0029 hfQIE10Info_[1] = *second;
0030 hasInfo_[1] = true;
0031 }
0032 }
0033
0034 constexpr HcalDetId id() const { return id_; }
0035
0036
0037
0038
0039 constexpr HFQIE10Info const* getHFQIE10Info(unsigned index) const {
0040 if (index < 2 && hasInfo_[index])
0041 return &hfQIE10Info_[index];
0042 else
0043 return nullptr;
0044 }
0045
0046
0047 constexpr float charge() const {
0048 float q = 0.f;
0049 for (unsigned i = 0; i < 2; ++i)
0050 if (hasInfo_[i])
0051 q += hfQIE10Info_[i].charge();
0052 return q;
0053 }
0054 constexpr float energy() const {
0055 float e = 0.f;
0056 for (unsigned i = 0; i < 2; ++i)
0057 if (hasInfo_[i])
0058 e += hfQIE10Info_[i].energy();
0059 return e;
0060 }
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 std::pair<float, bool> chargeAsymmetry(float chargeThreshold) const;
0077
0078
0079 std::pair<float, bool> energyAsymmetry(float energyThreshold) const;
0080
0081 private:
0082 HcalDetId id_;
0083
0084 HFQIE10Info hfQIE10Info_[2];
0085 bool hasInfo_[2];
0086 };
0087
0088 #endif