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

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

Definition at line 36 of file SimplePlan1RechitCombiner.h.

Constructor & Destructor Documentation

SimplePlan1RechitCombiner::SimplePlan1RechitCombiner ( )

Definition at line 14 of file SimplePlan1RechitCombiner.cc.

15  : topo_(nullptr)
16 {
17 }
SimplePlan1RechitCombiner::~SimplePlan1RechitCombiner ( )
inlineoverride

Member Function Documentation

void SimplePlan1RechitCombiner::add ( const HBHERecHit rh)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 29 of file SimplePlan1RechitCombiner.cc.

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

Referenced by counter.Counter::register(), and ~SimplePlan1RechitCombiner().

30 {
32  rechitMap_.push_back(MapItem(mapRechit(rh.id()), &rh));
33 }
std::vector< MapItem > rechitMap_
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
uint32_t auxPhase1() const
Definition: HBHERecHit.h:57
static const unsigned OFF_DROPPED
std::pair< HcalDetId, const HBHERecHit * > MapItem
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
virtual HcalDetId mapRechit(HcalDetId from) const
void SimplePlan1RechitCombiner::clear ( void  )
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 24 of file SimplePlan1RechitCombiner.cc.

References rechitMap_.

Referenced by ~SimplePlan1RechitCombiner().

25 {
26  rechitMap_.clear();
27 }
std::vector< MapItem > rechitMap_
void SimplePlan1RechitCombiner::combine ( HBHERecHitCollection toFill)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 35 of file SimplePlan1RechitCombiner.cc.

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

Referenced by ~SimplePlan1RechitCombiner().

36 {
37  if (!rechitMap_.empty())
38  {
39  std::sort(rechitMap_.begin(), rechitMap_.end());
40 
41  HcalDetId oldId(rechitMap_[0].first);
42  ptrbuf_.clear();
43  ptrbuf_.push_back(rechitMap_[0].second);
44 
45  const std::size_t nInput = rechitMap_.size();
46  for (std::size_t i = 1; i < nInput; ++i)
47  {
48  if (rechitMap_[i].first != oldId)
49  {
50  const HBHERecHit& rh = makeRechit(oldId, ptrbuf_);
51  if (rh.id().rawId())
52  toFill->push_back(rh);
53  oldId = rechitMap_[i].first;
54  ptrbuf_.clear();
55  }
56  ptrbuf_.push_back(rechitMap_[i].second);
57  }
58 
59  const HBHERecHit& rh = makeRechit(oldId, ptrbuf_);
60  if (rh.id().rawId())
61  toFill->push_back(rh);
62  }
63 }
std::vector< MapItem > rechitMap_
std::vector< const HBHERecHit * > ptrbuf_
virtual HBHERecHit makeRechit(HcalDetId idToMake, const std::vector< const HBHERecHit * > &rechits) const
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
void push_back(T const &t)
U second(std::pair< T, U > const &p)
void SimplePlan1RechitCombiner::combineAuxInfo ( const std::vector< const HBHERecHit * > &  rechits,
HBHERecHit rh 
) const
protectedvirtual

Definition at line 119 of file SimplePlan1RechitCombiner.cc.

References HBHERecHit::auxPhase1(), constexpr, SoftLeptonByDistance_cfi::distance, CaloRecHit::flags(), 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(), and mitigatedMETSequence_cff::U.

Referenced by makeRechit(), and ~SimplePlan1RechitCombiner().

122 {
123  using namespace CaloRecHitAuxSetter;
124  using namespace HcalPhase1FlagLabels;
125 
126  // The number of rechits should be not larger than the
127  // number of half-bytes in a 32-bit word
128  constexpr unsigned MAXLEN = 8U;
129 
130  const unsigned nRecHits = rechits.size();
131  assert(nRecHits);
132  assert(nRecHits <= MAXLEN);
133 
134  uint32_t flags = 0, auxPhase1 = 0;
135  unsigned tripleFitCount = 0;
136  unsigned soiVote[HBHERecHitAuxSetter::MASK_SOI + 1U] = {0};
137  unsigned capidVote[HBHERecHitAuxSetter::MASK_CAPID + 1U] = {0};
138 
139  // Combine various status bits
140  for (unsigned i=0; i<nRecHits; ++i)
141  {
142  const HBHERecHit& rh(*rechits[i]);
143  const uint32_t rhflags = rh.flags();
144  const uint32_t rhAuxPhase1 = rh.auxPhase1();
145 
150 
151  const unsigned soi = getField(rhAuxPhase1, HBHERecHitAuxSetter::MASK_SOI,
153  soiVote[soi]++;
154 
155  const unsigned capid = getField(rhAuxPhase1, HBHERecHitAuxSetter::MASK_CAPID,
157  capidVote[capid]++;
158 
160  ++tripleFitCount;
161 
162  // Status flags are simply ORed for now. Might want
163  // to rethink this in the future.
164  flags |= rhflags;
165  }
166 
167  unsigned* pmaxsoi = std::max_element(soiVote, soiVote+sizeof(soiVote)/sizeof(soiVote[0]));
168  const unsigned soi = std::distance(&soiVote[0], pmaxsoi);
170 
171  unsigned* pmaxcapid = std::max_element(capidVote, capidVote+sizeof(capidVote)/sizeof(capidVote[0]));
172  const unsigned capid = std::distance(&capidVote[0], pmaxcapid);
174 
175  // A number that can be later used to calculate chi-square NDoF
177  HBHERecHitAuxSetter::OFF_ADC, tripleFitCount);
178 
179  // How many rechits were combined?
182 
183  // Should combine QIE11 data only
184  setBit(&auxPhase1, HBHERecHitAuxSetter::OFF_TDC_TIME, true);
185 
186  // Indicate that this rechit is combined
187  setBit(&auxPhase1, HBHERecHitAuxSetter::OFF_COMBINED, true);
188 
189  // Copy the aux words into the rechit
190  rh->setFlags(flags);
191  rh->setAuxPhase1(auxPhase1);
192 
193  // Sort the depth values of the combined rechits
194  // in the increasing order
195  unsigned depthValues[MAXLEN];
196  for (unsigned i=0; i<nRecHits; ++i)
197  depthValues[i] = rechits[i]->id().depth();
198  if (nRecHits > 1U)
199  std::sort(depthValues, depthValues+nRecHits);
200 
201  // Pack the information about the depth of the rechits
202  // that we are combining into the "auxHBHE" word
203  uint32_t auxHBHE = 0;
204  for (unsigned i=0; i<nRecHits; ++i)
205  setField(&auxHBHE, 0xf, i*4, depthValues[i]);
206  rh->setAuxHBHE(auxHBHE);
207 }
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
uint32_t auxPhase1() const
Definition: HBHERecHit.h:57
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
static const unsigned OFF_NSAMPLES
static const unsigned OFF_CAPID
static const unsigned OFF_TDC_TIME
static const unsigned OFF_CAPID_ERR
static const unsigned OFF_LINK_ERR
static const unsigned OFF_ADC
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
static const unsigned MASK_SOI
void setAuxHBHE(const uint32_t aux)
Definition: HBHERecHit.h:53
void setBit(int &_bitArray, unsigned _iBit)
static const unsigned OFF_COMBINED
constexpr void setFlags(uint32_t flags)
Definition: CaloRecHit.h:37
void setAuxPhase1(const uint32_t aux)
Definition: HBHERecHit.h:56
constexpr uint32_t flags() const
Definition: CaloRecHit.h:36
bool getBit(int &_bitArray, unsigned _iBit)
#define constexpr
HBHERecHit SimplePlan1RechitCombiner::makeRechit ( HcalDetId  idToMake,
const std::vector< const HBHERecHit * > &  rechits 
) const
protectedvirtual

Definition at line 71 of file SimplePlan1RechitCombiner.cc.

References HBHERecHit::chi2(), combineAuxInfo(), constexpr, MillePedeFileConverter_cfg::e, HBHERecHit::eaux(), CaloRecHit::energy(), AbsPlan1RechitCombiner::energyWeightedAverage(), HBHERecHit::eraw(), mps_fire::i, HcalSpecialTimes::isSpecial(), HBHERecHit::setAuxEnergy(), HBHERecHit::setChiSquared(), HBHERecHit::setRawEnergy(), CaloRecHit::time(), HBHERecHit::timeFalling(), create_public_lumi_plots::times, mitigatedMETSequence_cff::U, and HcalSpecialTimes::UNKNOWN_T_NOTDC.

Referenced by combine(), and ~SimplePlan1RechitCombiner().

73 {
74  constexpr unsigned MAXLEN = 8U; // Should be >= max # of Phase 1 HCAL depths
75  constexpr float TIME_IF_NO_ENERGY = -999.f;
76 
77  const unsigned nRecHits = rechits.size();
78  assert(nRecHits);
79  assert(nRecHits <= MAXLEN);
80 
81  // Combine energies, times, and fit chi-square
82  double energy = 0.0, eraw = 0.0, eaux = 0.0, chisq = 0.0;
83  FPair times[MAXLEN], adctimes[MAXLEN];
84  unsigned nADCTimes = 0;
85 
86  for (unsigned i=0; i<nRecHits; ++i)
87  {
88  const HBHERecHit& rh(*rechits[i]);
89  const float e = rh.energy();
90  energy += e;
91  eraw += rh.eraw();
92  eaux += rh.eaux();
93  chisq += rh.chi2();
94  times[i].first = rh.time();
95  times[i].second = e;
96 
97  const float tADC = rh.timeFalling();
98  if (!HcalSpecialTimes::isSpecial(tADC))
99  {
100  adctimes[nADCTimes].first = tADC;
101  adctimes[nADCTimes].second = e;
102  ++nADCTimes;
103  }
104  }
105 
106  HBHERecHit rh(idToMake, energy,
107  energyWeightedAverage(times, nRecHits, TIME_IF_NO_ENERGY),
109  rh.setRawEnergy(eraw);
110  rh.setAuxEnergy(eaux);
111  rh.setChiSquared(chisq);
112 
113  // Combine the auxiliary information
114  combineAuxInfo(rechits, &rh);
115 
116  return rh;
117 }
virtual void combineAuxInfo(const std::vector< const HBHERecHit * > &rechits, HBHERecHit *rh) const
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
#define constexpr
HcalDetId SimplePlan1RechitCombiner::mapRechit ( HcalDetId  from) const
protectedvirtual

Definition at line 65 of file SimplePlan1RechitCombiner.cc.

References HcalTopology::mergedDepthDetId(), and topo_.

Referenced by add(), and ~SimplePlan1RechitCombiner().

66 {
67  return topo_->mergedDepthDetId(from);
68 }
HcalDetId mergedDepthDetId(const HcalDetId &id) const
Definition: HcalTopology.h:170
void SimplePlan1RechitCombiner::setTopo ( const HcalTopology topo)
overridevirtual

Implements AbsPlan1RechitCombiner.

Definition at line 19 of file SimplePlan1RechitCombiner.cc.

References topo_.

Referenced by ~SimplePlan1RechitCombiner().

20 {
21  topo_ = topo;
22 }

Member Data Documentation

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

Definition at line 39 of file SimplePlan1RechitCombiner.h.

Referenced by combine().

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

Definition at line 38 of file SimplePlan1RechitCombiner.h.

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

const HcalTopology* SimplePlan1RechitCombiner::topo_
protected

Definition at line 31 of file SimplePlan1RechitCombiner.h.

Referenced by mapRechit(), and setTopo().