CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes
SimplePlan1RechitCombiner Class Reference

#include <SimplePlan1RechitCombiner.h>

Inheritance diagram for SimplePlan1RechitCombiner:
AbsPlan1RechitCombiner

Public Member Functions

void add (const HBHERecHit &rh) override
 
void clear () override
 
void combine (HBHERecHitCollection *toFill) override
 
void setTopo (const HcalTopology *topo) override
 
 SimplePlan1RechitCombiner ()
 
 ~SimplePlan1RechitCombiner () override
 
- Public Member Functions inherited from AbsPlan1RechitCombiner
virtual ~AbsPlan1RechitCombiner ()
 

Protected Member Functions

virtual void combineAuxInfo (const std::vector< const HBHERecHit *> &rechits, HBHERecHit *rh) const
 
virtual HBHERecHit makeRechit (HcalDetId idToMake, const std::vector< const HBHERecHit *> &rechits) const
 
virtual HcalDetId mapRechit (HcalDetId from) const
 

Protected Attributes

const HcalTopologytopo_
 

Private Types

typedef std::pair< HcalDetId, const HBHERecHit * > MapItem
 

Private Attributes

std::vector< const HBHERecHit * > ptrbuf_
 
std::vector< MapItemrechitMap_
 

Additional Inherited Members

- Protected Types inherited from AbsPlan1RechitCombiner
typedef std::pair< float, float > FPair
 
- Static Protected Member Functions inherited from AbsPlan1RechitCombiner
static float energyWeightedAverage (const FPair *data, unsigned len, float valueToReturnOnFailure)
 

Detailed Description

Definition at line 7 of file SimplePlan1RechitCombiner.h.

Member Typedef Documentation

◆ MapItem

typedef std::pair<HcalDetId, const HBHERecHit*> SimplePlan1RechitCombiner::MapItem
private

Definition at line 33 of file SimplePlan1RechitCombiner.h.

Constructor & Destructor Documentation

◆ SimplePlan1RechitCombiner()

SimplePlan1RechitCombiner::SimplePlan1RechitCombiner ( )

Definition at line 14 of file SimplePlan1RechitCombiner.cc.

14 : topo_(nullptr) {}

◆ ~SimplePlan1RechitCombiner()

SimplePlan1RechitCombiner::~SimplePlan1RechitCombiner ( )
inlineoverride

Definition at line 11 of file SimplePlan1RechitCombiner.h.

11 {}

Member Function Documentation

◆ add()

void SimplePlan1RechitCombiner::add ( const HBHERecHit rh)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 20 of file SimplePlan1RechitCombiner.cc.

References HBHERecHit::auxPhase1(), CaloRecHitAuxSetter::getBit(), HBHERecHit::id(), mapRechit(), HBHERecHitAuxSetter::OFF_DROPPED, and rechitMap_.

Referenced by counter.Counter::register().

20  {
22  rechitMap_.push_back(MapItem(mapRechit(rh.id()), &rh));
23 }
std::vector< MapItem > rechitMap_
static const unsigned OFF_DROPPED
virtual HcalDetId mapRechit(HcalDetId from) const
constexpr uint32_t auxPhase1() const
Definition: HBHERecHit.h:56
std::pair< HcalDetId, const HBHERecHit * > MapItem
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41

◆ clear()

void SimplePlan1RechitCombiner::clear ( void  )
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 18 of file SimplePlan1RechitCombiner.cc.

References rechitMap_.

18 { rechitMap_.clear(); }
std::vector< MapItem > rechitMap_

◆ combine()

void SimplePlan1RechitCombiner::combine ( HBHERecHitCollection toFill)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 25 of file SimplePlan1RechitCombiner.cc.

References dqmdumpme::first, mps_fire::i, HBHERecHit::id(), makeRechit(), ptrbuf_, edm::SortedCollection< T, SORT >::push_back(), DetId::rawId(), rechitMap_, edm::second(), and jetUpdater_cfi::sort.

25  {
26  if (!rechitMap_.empty()) {
27  std::sort(rechitMap_.begin(), rechitMap_.end());
28 
29  HcalDetId oldId(rechitMap_[0].first);
30  ptrbuf_.clear();
31  ptrbuf_.push_back(rechitMap_[0].second);
32 
33  const std::size_t nInput = rechitMap_.size();
34  for (std::size_t i = 1; i < nInput; ++i) {
35  if (rechitMap_[i].first != oldId) {
36  const HBHERecHit& rh = makeRechit(oldId, ptrbuf_);
37  if (rh.id().rawId())
38  toFill->push_back(rh);
39  oldId = rechitMap_[i].first;
40  ptrbuf_.clear();
41  }
42  ptrbuf_.push_back(rechitMap_[i].second);
43  }
44 
45  const HBHERecHit& rh = makeRechit(oldId, ptrbuf_);
46  if (rh.id().rawId())
47  toFill->push_back(rh);
48  }
49 }
std::vector< MapItem > rechitMap_
std::vector< const HBHERecHit * > ptrbuf_
void push_back(T const &t)
U second(std::pair< T, U > const &p)
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual HBHERecHit makeRechit(HcalDetId idToMake, const std::vector< const HBHERecHit *> &rechits) const

◆ combineAuxInfo()

void SimplePlan1RechitCombiner::combineAuxInfo ( const std::vector< const HBHERecHit *> &  rechits,
HBHERecHit rh 
) const
protectedvirtual

Definition at line 99 of file SimplePlan1RechitCombiner.cc.

References cms::cuda::assert(), HBHERecHit::auxPhase1(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), HLT_2024v14_cff::distance, CaloRecHit::flags(), HLT_2024v14_cff::flags, getBit(), CaloRecHitAuxSetter::getField(), HcalCaloFlagLabels::HBHEPulseFitBit, mps_fire::i, HBHERecHitAuxSetter::MASK_CAPID, HBHERecHitAuxSetter::MASK_NSAMPLES, HBHERecHitAuxSetter::MASK_SOI, HBHERecHitAuxSetter::OFF_ADC, HBHERecHitAuxSetter::OFF_CAPID, HBHERecHitAuxSetter::OFF_CAPID_ERR, HBHERecHitAuxSetter::OFF_COMBINED, HBHERecHitAuxSetter::OFF_LINK_ERR, HBHERecHitAuxSetter::OFF_NSAMPLES, HBHERecHitAuxSetter::OFF_SOI, HBHERecHitAuxSetter::OFF_TDC_TIME, CaloRecHitAuxSetter::orBit(), HBHERecHit::setAuxHBHE(), HBHERecHit::setAuxPhase1(), setBit(), CaloRecHitAuxSetter::setField(), CaloRecHit::setFlags(), jetUpdater_cfi::sort, and mitigatedMETSequence_cff::U.

Referenced by makeRechit().

99  {
100  using namespace CaloRecHitAuxSetter;
101  using namespace HcalPhase1FlagLabels;
102 
103  // The number of rechits should be not larger than the
104  // number of half-bytes in a 32-bit word
105  constexpr unsigned MAXLEN = 8U;
106 
107  const unsigned nRecHits = rechits.size();
108  assert(nRecHits);
109  assert(nRecHits <= MAXLEN);
110 
111  uint32_t flags = 0, auxPhase1 = 0;
112  unsigned tripleFitCount = 0;
113  unsigned soiVote[HBHERecHitAuxSetter::MASK_SOI + 1U] = {0};
114  unsigned capidVote[HBHERecHitAuxSetter::MASK_CAPID + 1U] = {0};
115 
116  // Combine various status bits
117  for (unsigned i = 0; i < nRecHits; ++i) {
118  const HBHERecHit& rh(*rechits[i]);
119  const uint32_t rhflags = rh.flags();
120  const uint32_t rhAuxPhase1 = rh.auxPhase1();
121 
124 
125  const unsigned soi = getField(rhAuxPhase1, HBHERecHitAuxSetter::MASK_SOI, HBHERecHitAuxSetter::OFF_SOI);
126  soiVote[soi]++;
127 
128  const unsigned capid = getField(rhAuxPhase1, HBHERecHitAuxSetter::MASK_CAPID, HBHERecHitAuxSetter::OFF_CAPID);
129  capidVote[capid]++;
130 
132  ++tripleFitCount;
133 
134  // Status flags are simply ORed for now. Might want
135  // to rethink this in the future.
136  flags |= rhflags;
137  }
138 
139  unsigned* pmaxsoi = std::max_element(soiVote, soiVote + sizeof(soiVote) / sizeof(soiVote[0]));
140  const unsigned soi = std::distance(&soiVote[0], pmaxsoi);
142 
143  unsigned* pmaxcapid = std::max_element(capidVote, capidVote + sizeof(capidVote) / sizeof(capidVote[0]));
144  const unsigned capid = std::distance(&capidVote[0], pmaxcapid);
146 
147  // A number that can be later used to calculate chi-square NDoF
149 
150  // How many rechits were combined?
152 
153  // Should combine QIE11 data only
154  setBit(&auxPhase1, HBHERecHitAuxSetter::OFF_TDC_TIME, true);
155 
156  // Indicate that this rechit is combined
157  setBit(&auxPhase1, HBHERecHitAuxSetter::OFF_COMBINED, true);
158 
159  // Copy the aux words into the rechit
160  rh->setFlags(flags);
161  rh->setAuxPhase1(auxPhase1);
162 
163  // Sort the depth values of the combined rechits
164  // in the increasing order
165  unsigned depthValues[MAXLEN];
166  for (unsigned i = 0; i < nRecHits; ++i)
167  depthValues[i] = rechits[i]->id().depth();
168  if (nRecHits > 1U)
169  std::sort(depthValues, depthValues + nRecHits);
170 
171  // Pack the information about the depth of the rechits
172  // that we are combining into the "auxHBHE" word
173  uint32_t auxHBHE = 0;
174  for (unsigned i = 0; i < nRecHits; ++i)
175  setField(&auxHBHE, 0xf, i * 4, depthValues[i]);
176  rh->setAuxHBHE(auxHBHE);
177 }
static const unsigned MASK_NSAMPLES
constexpr void orBit(uint32_t *u, const unsigned bitnum, const bool b)
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
static const unsigned OFF_SOI
static const unsigned MASK_CAPID
assert(be >=bs)
static const unsigned OFF_NSAMPLES
static const unsigned OFF_CAPID
constexpr void setAuxPhase1(const uint32_t aux)
Definition: HBHERecHit.h:55
static const unsigned OFF_TDC_TIME
static const unsigned OFF_CAPID_ERR
constexpr uint32_t flags() const
Definition: CaloRecHit.h:34
static const unsigned OFF_LINK_ERR
static const unsigned OFF_ADC
constexpr uint32_t auxPhase1() const
Definition: HBHERecHit.h:56
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
constexpr void setAuxHBHE(const uint32_t aux)
Definition: HBHERecHit.h:52
static const unsigned MASK_SOI
void setBit(int &_bitArray, unsigned _iBit)
static const unsigned OFF_COMBINED
constexpr void setFlags(uint32_t flags)
Definition: CaloRecHit.h:35
bool getBit(int &_bitArray, unsigned _iBit)

◆ makeRechit()

HBHERecHit SimplePlan1RechitCombiner::makeRechit ( HcalDetId  idToMake,
const std::vector< const HBHERecHit *> &  rechits 
) const
protectedvirtual

Definition at line 53 of file SimplePlan1RechitCombiner.cc.

References cms::cuda::assert(), HBHERecHit::chi2(), combineAuxInfo(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), MillePedeFileConverter_cfg::e, HBHERecHit::eaux(), hcalRecHitTable_cff::energy, CaloRecHit::energy(), AbsPlan1RechitCombiner::energyWeightedAverage(), HBHERecHit::eraw(), mps_fire::i, HcalSpecialTimes::isSpecial(), HBHERecHit::setAuxEnergy(), HBHERecHit::setChiSquared(), HBHERecHit::setRawEnergy(), CaloRecHit::time(), HBHERecHit::timeFalling(), mitigatedMETSequence_cff::U, and HcalSpecialTimes::UNKNOWN_T_NOTDC.

Referenced by combine().

54  {
55  constexpr unsigned MAXLEN = 8U; // Should be >= max # of Phase 1 HCAL depths
56  constexpr float TIME_IF_NO_ENERGY = -999.f;
57 
58  const unsigned nRecHits = rechits.size();
59  assert(nRecHits);
60  assert(nRecHits <= MAXLEN);
61 
62  // Combine energies, times, and fit chi-square
63  double energy = 0.0, eraw = 0.0, eaux = 0.0, chisq = 0.0;
64  FPair times[MAXLEN], adctimes[MAXLEN];
65  unsigned nADCTimes = 0;
66 
67  for (unsigned i = 0; i < nRecHits; ++i) {
68  const HBHERecHit& rh(*rechits[i]);
69  const float e = rh.energy();
70  energy += e;
71  eraw += rh.eraw();
72  eaux += rh.eaux();
73  chisq += rh.chi2();
74  times[i].first = rh.time();
75  times[i].second = e;
76 
77  const float tADC = rh.timeFalling();
78  if (!HcalSpecialTimes::isSpecial(tADC)) {
79  adctimes[nADCTimes].first = tADC;
80  adctimes[nADCTimes].second = e;
81  ++nADCTimes;
82  }
83  }
84 
85  HBHERecHit rh(idToMake,
86  energy,
87  energyWeightedAverage(times, nRecHits, TIME_IF_NO_ENERGY),
89  rh.setRawEnergy(eraw);
90  rh.setAuxEnergy(eaux);
91  rh.setChiSquared(chisq);
92 
93  // Combine the auxiliary information
94  combineAuxInfo(rechits, &rh);
95 
96  return rh;
97 }
assert(be >=bs)
static float energyWeightedAverage(const FPair *data, unsigned len, float valueToReturnOnFailure)
std::pair< float, float > FPair
constexpr bool isSpecial(const float t)
constexpr float UNKNOWN_T_NOTDC
virtual void combineAuxInfo(const std::vector< const HBHERecHit *> &rechits, HBHERecHit *rh) const

◆ mapRechit()

HcalDetId SimplePlan1RechitCombiner::mapRechit ( HcalDetId  from) const
protectedvirtual

Definition at line 51 of file SimplePlan1RechitCombiner.cc.

References HcalTopology::mergedDepthDetId(), and topo_.

Referenced by add().

51 { return topo_->mergedDepthDetId(from); }
HcalDetId mergedDepthDetId(const HcalDetId &id) const
Definition: HcalTopology.h:166

◆ setTopo()

void SimplePlan1RechitCombiner::setTopo ( const HcalTopology topo)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 16 of file SimplePlan1RechitCombiner.cc.

References topo_.

16 { topo_ = topo; }

Member Data Documentation

◆ ptrbuf_

std::vector<const HBHERecHit*> SimplePlan1RechitCombiner::ptrbuf_
private

Definition at line 36 of file SimplePlan1RechitCombiner.h.

Referenced by combine().

◆ rechitMap_

std::vector<MapItem> SimplePlan1RechitCombiner::rechitMap_
private

Definition at line 35 of file SimplePlan1RechitCombiner.h.

Referenced by add(), clear(), and combine().

◆ topo_

const HcalTopology* SimplePlan1RechitCombiner::topo_
protected

Definition at line 28 of file SimplePlan1RechitCombiner.h.

Referenced by mapRechit(), and setTopo().