CMS 3D CMS Logo

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

#include <HFSimpleTimeCheck.h>

Inheritance diagram for HFSimpleTimeCheck:
AbsHFPhase1Algo HFFlexibleTimeCheck

Public Member Functions

 HFSimpleTimeCheck (const std::pair< float, float > tlimits[2], const float energyWeights[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2], unsigned soiPhase, float timeShift, float triseIfNoTDC, float tfallIfNoTDC, float minChargeForUndershoot, float minChargeForOvershoot, bool rejectAllFailures=true)
 
bool isConfigurable () const override
 
float minChargeForOvershoot () const
 
float minChargeForUndershoot () const
 
HFRecHit reconstruct (const HFPreRecHit &prehit, const HcalCalibrations &calibs, const bool flaggedBadInDB[2], bool expectSingleAnodePMT) override
 
bool rejectingAllFailures () const
 
unsigned soiPhase () const
 
float tfallIfNoTDC () const
 
float timeShift () const
 
float triseIfNoTDC () const
 
 ~HFSimpleTimeCheck () override
 
- Public Member Functions inherited from AbsHFPhase1Algo
virtual bool configure (const AbsHcalAlgoData *)
 
virtual ~AbsHFPhase1Algo ()
 

Protected Member Functions

virtual unsigned determineAnodeStatus (unsigned anodeNumber, const HFQIE10Info &anode, bool *isTimingReliable) const
 

Private Member Functions

unsigned mapStatusIntoIndex (const unsigned states[2]) const
 

Private Attributes

float energyWeights_ [2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
 
float minChargeForOvershoot_
 
float minChargeForUndershoot_
 
bool rejectAllFailures_
 
unsigned soiPhase_
 
float tfallIfNoTDC_
 
float timeShift_
 
std::pair< float, float > tlimits_ [2]
 
float triseIfNoTDC_
 

Detailed Description

Definition at line 9 of file HFSimpleTimeCheck.h.

Constructor & Destructor Documentation

HFSimpleTimeCheck::HFSimpleTimeCheck ( const std::pair< float, float >  tlimits[2],
const float  energyWeights[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2],
unsigned  soiPhase,
float  timeShift,
float  triseIfNoTDC,
float  tfallIfNoTDC,
float  minChargeForUndershoot,
float  minChargeForOvershoot,
bool  rejectAllFailures = true 
)

Definition at line 39 of file HFSimpleTimeCheck.cc.

References HFPhase1Reconstructor_cfi::energyWeights, energyWeights_, and tlimits_.

48  : soiPhase_(i_soiPhase),
49  timeShift_(i_timeShift),
50  triseIfNoTDC_(i_triseIfNoTDC),
51  tfallIfNoTDC_(i_tfallIfNoTDC),
52  minChargeForUndershoot_(i_minChargeForUndershoot),
53  minChargeForOvershoot_(i_minChargeForOvershoot),
55 {
56  tlimits_[0] = tlimits[0];
57  tlimits_[1] = tlimits[1];
58  float* to = &energyWeights_[0][0];
59  const float* from = &energyWeights[0][0];
60  memcpy(to, from, sizeof(energyWeights_));
61 }
std::pair< float, float > tlimits_[2]
float energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
HFSimpleTimeCheck::~HFSimpleTimeCheck ( )
inlineoverride

Definition at line 62 of file HFSimpleTimeCheck.h.

62 {}

Member Function Documentation

unsigned HFSimpleTimeCheck::determineAnodeStatus ( unsigned  anodeNumber,
const HFQIE10Info anode,
bool *  isTimingReliable 
) const
protectedvirtual

Reimplemented in HFFlexibleTimeCheck.

Definition at line 63 of file HFSimpleTimeCheck.cc.

References HFAnodeStatus::FAILED_TIMING, plotBeamSpotDB::first, HFAnodeStatus::HARDWARE_ERROR, HFQIE10Info::isDataframeOK(), HcalSpecialTimes::isSpecial(), HFAnodeStatus::OK, edm::second(), HFQIE10Info::timeRising(), timeShift_, and tlimits_.

Referenced by reconstruct(), and rejectingAllFailures().

65 {
66  // Check if this anode has a dataframe error
67  if (!anode.isDataframeOK())
69 
70  // Check the time limits
71  float trise = anode.timeRising();
72  const bool timeIsKnown = !HcalSpecialTimes::isSpecial(trise);
73  trise += timeShift_;
74  if (timeIsKnown &&
75  tlimits_[ianode].first <= trise && trise <= tlimits_[ianode].second)
76  return HFAnodeStatus::OK;
77  else
79 }
std::pair< float, float > tlimits_[2]
float timeRising() const
Definition: HFQIE10Info.h:36
bool isDataframeOK(bool checkAllTimeSlices=false) const
Definition: HFQIE10Info.cc:66
U second(std::pair< T, U > const &p)
bool isSpecial(const float t)
bool HFSimpleTimeCheck::isConfigurable ( ) const
inlineoverridevirtual

Implements AbsHFPhase1Algo.

Definition at line 64 of file HFSimpleTimeCheck.h.

References reconstruct().

64 {return false;}
unsigned HFSimpleTimeCheck::mapStatusIntoIndex ( const unsigned  states[2]) const
private

Definition at line 81 of file HFSimpleTimeCheck.cc.

References HFAnodeStatus::FAILED_OTHER, HFAnodeStatus::FAILED_TIMING, mps_fire::i, HFAnodeStatus::N_POSSIBLE_STATES, HFAnodeStatus::OK, and rejectAllFailures_.

Referenced by reconstruct(), and rejectingAllFailures().

82 {
83  unsigned eStates[2];
84  eStates[0] = states[0];
85  eStates[1] = states[1];
86  if (!rejectAllFailures_)
87  for (unsigned i=0; i<2; ++i)
88  if (eStates[i] == HFAnodeStatus::FAILED_TIMING ||
89  eStates[i] == HFAnodeStatus::FAILED_OTHER)
90  eStates[i] = HFAnodeStatus::OK;
91  if (eStates[0] == HFAnodeStatus::OK)
92  return eStates[1];
93  else if (eStates[1] == HFAnodeStatus::OK)
94  return HFAnodeStatus::N_POSSIBLE_STATES + eStates[0] - 1;
95  else
96  return UINT_MAX;
97 }
float HFSimpleTimeCheck::minChargeForOvershoot ( ) const
inline

Definition at line 76 of file HFSimpleTimeCheck.h.

References minChargeForOvershoot_.

Referenced by HFFlexibleTimeCheck::determineAnodeStatus().

float HFSimpleTimeCheck::minChargeForUndershoot ( ) const
inline

Definition at line 75 of file HFSimpleTimeCheck.h.

References minChargeForUndershoot_.

Referenced by HFFlexibleTimeCheck::determineAnodeStatus().

HFRecHit HFSimpleTimeCheck::reconstruct ( const HFPreRecHit prehit,
const HcalCalibrations calibs,
const bool  flaggedBadInDB[2],
bool  expectSingleAnodePMT 
)
overridevirtual

Implements AbsHFPhase1Algo.

Definition at line 99 of file HFSimpleTimeCheck.cc.

References determineAnodeStatus(), HFQIE10Info::energy(), energyWeights_, f, HFAnodeStatus::FAILED_TIMING, RemoveAddSevLevel::flag, HFAnodeStatus::FLAGGED_BAD, HFPreRecHit::getHFQIE10Info(), HFPreRecHit::id(), HcalSpecialTimes::isSpecial(), mapStatusIntoIndex(), HFAnodeStatus::NOT_DUAL, HFAnodeStatus::NOT_READ_OUT, HFRecHitAuxSetter::setAux(), CaloRecHit::setFlagField(), soiPhase_, tfallIfNoTDC_, HFQIE10Info::timeFalling(), HFQIE10Info::timeRising(), timeShift_, HcalPhase1FlagLabels::TimingFromTDC, triseIfNoTDC_, mitigatedMETSequence_cff::U, and create_public_lumi_plots::weights.

Referenced by isConfigurable(), and HFFlexibleTimeCheck::reconstruct().

103 {
104  HFRecHit rh;
105 
106  // Determine the status of each anode
108  if (expectSingleAnodePMT)
109  states[1] = HFAnodeStatus::NOT_DUAL;
110 
111  bool isTimingReliable[2] = {true, true};
112  for (unsigned ianode=0; ianode<2; ++ianode)
113  {
114  if (flaggedBadInDB[ianode])
115  states[ianode] = HFAnodeStatus::FLAGGED_BAD;
116  else
117  {
118  const HFQIE10Info* anodeInfo = prehit.getHFQIE10Info(ianode);
119  if (anodeInfo)
120  states[ianode] = determineAnodeStatus(ianode, *anodeInfo,
121  &isTimingReliable[ianode]);
122  }
123  }
124 
125  // Reconstruct energy and time
126  const unsigned lookupInd = mapStatusIntoIndex(states);
127  if (lookupInd != UINT_MAX)
128  {
129  // In this scope, at least one of states[i] is HFAnodeStatus::OK
130  // or was mapped into that status by "mapStatusIntoIndex" method
131  //
132  const float* weights = &energyWeights_[lookupInd][0];
133  float energy = 0.f, tfallWeightedEnergySum = 0.f, triseWeightedEnergySum = 0.f;
134  float tfallWeightedSum = 0.f, triseWeightedSum = 0.f;
135  float tfallSum = 0.f, triseSum = 0.f;
136  unsigned tfallCount = 0, triseCount = 0;
137 
138  for (unsigned ianode=0; ianode<2; ++ianode)
139  {
140  const HFQIE10Info* anodeInfo = prehit.getHFQIE10Info(ianode);
141  if (anodeInfo && weights[ianode] > 0.f)
142  {
143  const float weightedEnergy = weights[ianode]*anodeInfo->energy();
144  energy += weightedEnergy;
145 
146  if (isTimingReliable[ianode] &&
147  states[ianode] != HFAnodeStatus::FAILED_TIMING)
148  {
149  float trise = anodeInfo->timeRising();
150  if (!HcalSpecialTimes::isSpecial(trise))
151  {
152  trise += timeShift_;
153  triseSum += trise;
154  ++triseCount;
155  if (weightedEnergy > 0.f)
156  {
157  triseWeightedSum += trise*weightedEnergy;
158  triseWeightedEnergySum += weightedEnergy;
159  }
160  }
161 
162  float tfall = anodeInfo->timeFalling();
163  if (!HcalSpecialTimes::isSpecial(tfall))
164  {
165  tfall += timeShift_;
166  tfallSum += tfall;
167  ++tfallCount;
168  if (weightedEnergy > 0.f)
169  {
170  tfallWeightedSum += tfall*weightedEnergy;
171  tfallWeightedEnergySum += weightedEnergy;
172  }
173  }
174  }
175  }
176  }
177 
178  bool triseFromTDC = false;
179  const float trise = build_rechit_time(
180  triseWeightedEnergySum, triseWeightedSum, triseSum,
181  triseCount, triseIfNoTDC_, &triseFromTDC);
182 
183  bool tfallFromTDC = false;
184  const float tfall = build_rechit_time(
185  tfallWeightedEnergySum, tfallWeightedSum, tfallSum,
186  tfallCount, tfallIfNoTDC_, &tfallFromTDC);
187 
188  rh = HFRecHit(prehit.id(), energy, trise, tfall);
189  HFRecHitAuxSetter::setAux(prehit, states, soiPhase_, &rh);
190 
191  // Set the "timing from TDC" flag
192  const uint32_t flag = triseFromTDC ? 1U : 0U;
194  }
195 
196  return rh;
197 }
float timeRising() const
Definition: HFQIE10Info.h:36
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
virtual unsigned determineAnodeStatus(unsigned anodeNumber, const HFQIE10Info &anode, bool *isTimingReliable) const
const HFQIE10Info * getHFQIE10Info(unsigned index) const
Definition: HFPreRecHit.cc:42
HcalDetId id() const
Definition: HFPreRecHit.h:26
bool isSpecial(const float t)
unsigned mapStatusIntoIndex(const unsigned states[2]) const
double f[11][100]
float energy() const
Definition: HFQIE10Info.h:35
float energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
static void setAux(const HFPreRecHit &prehit, const unsigned anodeStates[2], unsigned soiPhase, HFRecHit *rechit)
float timeFalling() const
Definition: HFQIE10Info.h:37
bool HFSimpleTimeCheck::rejectingAllFailures ( ) const
inline
unsigned HFSimpleTimeCheck::soiPhase ( ) const
inline

Definition at line 71 of file HFSimpleTimeCheck.h.

References soiPhase_.

71 {return soiPhase_;}
float HFSimpleTimeCheck::tfallIfNoTDC ( ) const
inline

Definition at line 74 of file HFSimpleTimeCheck.h.

References tfallIfNoTDC_.

74 {return tfallIfNoTDC_;}
float HFSimpleTimeCheck::timeShift ( ) const
inline

Definition at line 72 of file HFSimpleTimeCheck.h.

References timeShift_.

Referenced by HFFlexibleTimeCheck::determineAnodeStatus().

72 {return timeShift_;}
float HFSimpleTimeCheck::triseIfNoTDC ( ) const
inline

Definition at line 73 of file HFSimpleTimeCheck.h.

References triseIfNoTDC_.

73 {return triseIfNoTDC_;}

Member Data Documentation

float HFSimpleTimeCheck::energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
private

Definition at line 88 of file HFSimpleTimeCheck.h.

Referenced by HFSimpleTimeCheck(), and reconstruct().

float HFSimpleTimeCheck::minChargeForOvershoot_
private

Definition at line 94 of file HFSimpleTimeCheck.h.

Referenced by minChargeForOvershoot().

float HFSimpleTimeCheck::minChargeForUndershoot_
private

Definition at line 93 of file HFSimpleTimeCheck.h.

Referenced by minChargeForUndershoot().

bool HFSimpleTimeCheck::rejectAllFailures_
private

Definition at line 95 of file HFSimpleTimeCheck.h.

Referenced by mapStatusIntoIndex(), and rejectingAllFailures().

unsigned HFSimpleTimeCheck::soiPhase_
private

Definition at line 89 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and soiPhase().

float HFSimpleTimeCheck::tfallIfNoTDC_
private

Definition at line 92 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and tfallIfNoTDC().

float HFSimpleTimeCheck::timeShift_
private

Definition at line 90 of file HFSimpleTimeCheck.h.

Referenced by determineAnodeStatus(), reconstruct(), and timeShift().

std::pair<float,float> HFSimpleTimeCheck::tlimits_[2]
private

Definition at line 87 of file HFSimpleTimeCheck.h.

Referenced by determineAnodeStatus(), and HFSimpleTimeCheck().

float HFSimpleTimeCheck::triseIfNoTDC_
private

Definition at line 91 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and triseIfNoTDC().