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

◆ clear()

void SimplePlan1RechitCombiner::clear ( void  )
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 18 of file SimplePlan1RechitCombiner.cc.

18 { rechitMap_.clear(); }

References rechitMap_.

◆ combine()

void SimplePlan1RechitCombiner::combine ( HBHERecHitCollection toFill)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 25 of file SimplePlan1RechitCombiner.cc.

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 }

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

◆ combineAuxInfo()

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

Definition at line 99 of file SimplePlan1RechitCombiner.cc.

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 }

References cms::cuda::assert(), HBHERecHit::auxPhase1(), HLT_FULL_cff::distance, CaloRecHit::flags(), HLT_FULL_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(), HI_PhotonSkim_cff::rechits, HBHERecHit::setAuxHBHE(), HBHERecHit::setAuxPhase1(), setBit(), CaloRecHitAuxSetter::setField(), CaloRecHit::setFlags(), jetUpdater_cfi::sort, and mitigatedMETSequence_cff::U.

Referenced by makeRechit().

◆ makeRechit()

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

Definition at line 53 of file SimplePlan1RechitCombiner.cc.

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 }

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

Referenced by combine().

◆ mapRechit()

HcalDetId SimplePlan1RechitCombiner::mapRechit ( HcalDetId  from) const
protectedvirtual

Definition at line 51 of file SimplePlan1RechitCombiner.cc.

51 { return topo_->mergedDepthDetId(from); }

References HcalTopology::mergedDepthDetId(), and topo_.

Referenced by add().

◆ setTopo()

void SimplePlan1RechitCombiner::setTopo ( const HcalTopology topo)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 16 of file SimplePlan1RechitCombiner.cc.

16 { topo_ = topo; }

References 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().

HBHERecHitAuxSetter::MASK_CAPID
static const unsigned MASK_CAPID
Definition: HBHERecHitAuxSetter.h:31
CaloRecHitAuxSetter::setField
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
Definition: CaloRecHitAuxSetter.h:8
HBHERecHitAuxSetter::OFF_COMBINED
static const unsigned OFF_COMBINED
Definition: HBHERecHitAuxSetter.h:41
mps_fire.i
i
Definition: mps_fire.py:428
HcalSpecialTimes::isSpecial
constexpr bool isSpecial(const float t)
Definition: HcalSpecialTimes.h:53
CaloRecHitAuxSetter::orBit
constexpr void orBit(uint32_t *u, const unsigned bitnum, const bool b)
Definition: CaloRecHitAuxSetter.h:25
HBHERecHit
Definition: HBHERecHit.h:13
cms::cuda::assert
assert(be >=bs)
HBHERecHitAuxSetter::OFF_CAPID_ERR
static const unsigned OFF_CAPID_ERR
Definition: HBHERecHitAuxSetter.h:38
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
HBHERecHitAuxSetter::OFF_TDC_TIME
static const unsigned OFF_TDC_TIME
Definition: HBHERecHitAuxSetter.h:35
AbsPlan1RechitCombiner::FPair
std::pair< float, float > FPair
Definition: AbsPlan1RechitCombiner.h:35
getBit
bool getBit(int &_bitArray, unsigned _iBit)
Definition: EcalCondDBWriter.cc:19
HcalTopology::mergedDepthDetId
HcalDetId mergedDepthDetId(const HcalDetId &id) const
Definition: HcalTopology.h:166
HBHERecHitAuxSetter::OFF_DROPPED
static const unsigned OFF_DROPPED
Definition: HBHERecHitAuxSetter.h:36
SimplePlan1RechitCombiner::makeRechit
virtual HBHERecHit makeRechit(HcalDetId idToMake, const std::vector< const HBHERecHit * > &rechits) const
Definition: SimplePlan1RechitCombiner.cc:53
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
HBHERecHitAuxSetter::OFF_CAPID
static const unsigned OFF_CAPID
Definition: HBHERecHitAuxSetter.h:32
HBHERecHitAuxSetter::MASK_NSAMPLES
static const unsigned MASK_NSAMPLES
Definition: HBHERecHitAuxSetter.h:23
HBHERecHit::setAuxHBHE
constexpr void setAuxHBHE(const uint32_t aux)
Definition: HBHERecHit.h:52
SimplePlan1RechitCombiner::rechitMap_
std::vector< MapItem > rechitMap_
Definition: SimplePlan1RechitCombiner.h:35
SimplePlan1RechitCombiner::ptrbuf_
std::vector< const HBHERecHit * > ptrbuf_
Definition: SimplePlan1RechitCombiner.h:36
setBit
void setBit(int &_bitArray, unsigned _iBit)
Definition: EcalCondDBWriter.cc:17
AbsPlan1RechitCombiner::energyWeightedAverage
static float energyWeightedAverage(const FPair *data, unsigned len, float valueToReturnOnFailure)
Definition: AbsPlan1RechitCombiner.cc:3
HcalSpecialTimes::UNKNOWN_T_NOTDC
constexpr float UNKNOWN_T_NOTDC
Definition: HcalSpecialTimes.h:42
SimplePlan1RechitCombiner::mapRechit
virtual HcalDetId mapRechit(HcalDetId from) const
Definition: SimplePlan1RechitCombiner.cc:51
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
HBHERecHitAuxSetter::MASK_SOI
static const unsigned MASK_SOI
Definition: HBHERecHitAuxSetter.h:27
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
CaloRecHitAuxSetter::getField
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
Definition: CaloRecHitAuxSetter.h:13
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
SimplePlan1RechitCombiner::combineAuxInfo
virtual void combineAuxInfo(const std::vector< const HBHERecHit * > &rechits, HBHERecHit *rh) const
Definition: SimplePlan1RechitCombiner.cc:99
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
CaloRecHit::setFlags
constexpr void setFlags(uint32_t flags)
Definition: CaloRecHit.h:35
HcalDetId
Definition: HcalDetId.h:12
SimplePlan1RechitCombiner::topo_
const HcalTopology * topo_
Definition: SimplePlan1RechitCombiner.h:28
HBHERecHit::auxPhase1
constexpr uint32_t auxPhase1() const
Definition: HBHERecHit.h:56
CaloRecHitAuxSetter::getBit
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
Definition: CaloRecHitAuxSetter.h:37
HBHERecHitAuxSetter::OFF_ADC
static const unsigned OFF_ADC
Definition: HBHERecHitAuxSetter.h:20
HcalCaloFlagLabels::HBHEPulseFitBit
Definition: HcalCaloFlagLabels.h:27
HcalPhase1FlagLabels
Definition: HcalPhase1FlagLabels.h:6
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
SimplePlan1RechitCombiner::MapItem
std::pair< HcalDetId, const HBHERecHit * > MapItem
Definition: SimplePlan1RechitCombiner.h:33
HBHERecHitAuxSetter::OFF_NSAMPLES
static const unsigned OFF_NSAMPLES
Definition: HBHERecHitAuxSetter.h:24
HBHERecHitAuxSetter::OFF_LINK_ERR
static const unsigned OFF_LINK_ERR
Definition: HBHERecHitAuxSetter.h:37
HBHERecHit::id
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
HLT_FULL_cff.flags
flags
Definition: HLT_FULL_cff.py:13150
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
HBHERecHitAuxSetter::OFF_SOI
static const unsigned OFF_SOI
Definition: HBHERecHitAuxSetter.h:28
CaloRecHitAuxSetter
Definition: CaloRecHitAuxSetter.h:7
CaloRecHit::flags
constexpr uint32_t flags() const
Definition: CaloRecHit.h:34
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HBHERecHit::setAuxPhase1
constexpr void setAuxPhase1(const uint32_t aux)
Definition: HBHERecHit.h:55