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

bool alwaysCalculatingQAsym () const
 
 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 alwaysCalculateChargeAsymmetry=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

bool alwaysQAsym_
 
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,
bool  alwaysCalculateChargeAsymmetry = true 
)

Definition at line 39 of file HFSimpleTimeCheck.cc.

References HFPhase1Reconstructor_cfi::energyWeights, energyWeights_, and tlimits_.

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

Definition at line 69 of file HFSimpleTimeCheck.h.

69 {}

Member Function Documentation

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

Reimplemented in HFFlexibleTimeCheck.

Definition at line 65 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 alwaysCalculatingQAsym(), and reconstruct().

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

Implements AbsHFPhase1Algo.

Definition at line 71 of file HFSimpleTimeCheck.h.

References reconstruct().

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

Definition at line 83 of file HFSimpleTimeCheck.cc.

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

Referenced by alwaysCalculatingQAsym(), and reconstruct().

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

Definition at line 83 of file HFSimpleTimeCheck.h.

References minChargeForOvershoot_.

Referenced by HFFlexibleTimeCheck::determineAnodeStatus().

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

Implements AbsHFPhase1Algo.

Definition at line 101 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 HGCalRecHit_cfi::weights.

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

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

Definition at line 84 of file HFSimpleTimeCheck.h.

References rejectAllFailures_.

unsigned HFSimpleTimeCheck::soiPhase ( ) const
inline

Definition at line 78 of file HFSimpleTimeCheck.h.

References soiPhase_.

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

Definition at line 81 of file HFSimpleTimeCheck.h.

References tfallIfNoTDC_.

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

Definition at line 79 of file HFSimpleTimeCheck.h.

References timeShift_.

Referenced by HFFlexibleTimeCheck::determineAnodeStatus().

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

Definition at line 80 of file HFSimpleTimeCheck.h.

References triseIfNoTDC_.

80 {return triseIfNoTDC_;}

Member Data Documentation

bool HFSimpleTimeCheck::alwaysQAsym_
private

Definition at line 104 of file HFSimpleTimeCheck.h.

Referenced by alwaysCalculatingQAsym().

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

Definition at line 96 of file HFSimpleTimeCheck.h.

Referenced by HFSimpleTimeCheck(), and reconstruct().

float HFSimpleTimeCheck::minChargeForOvershoot_
private

Definition at line 102 of file HFSimpleTimeCheck.h.

Referenced by minChargeForOvershoot().

float HFSimpleTimeCheck::minChargeForUndershoot_
private

Definition at line 101 of file HFSimpleTimeCheck.h.

Referenced by minChargeForUndershoot().

bool HFSimpleTimeCheck::rejectAllFailures_
private

Definition at line 103 of file HFSimpleTimeCheck.h.

Referenced by mapStatusIntoIndex(), and rejectingAllFailures().

unsigned HFSimpleTimeCheck::soiPhase_
private

Definition at line 97 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and soiPhase().

float HFSimpleTimeCheck::tfallIfNoTDC_
private

Definition at line 100 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and tfallIfNoTDC().

float HFSimpleTimeCheck::timeShift_
private

Definition at line 98 of file HFSimpleTimeCheck.h.

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

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

Definition at line 95 of file HFSimpleTimeCheck.h.

Referenced by determineAnodeStatus(), and HFSimpleTimeCheck().

float HFSimpleTimeCheck::triseIfNoTDC_
private

Definition at line 99 of file HFSimpleTimeCheck.h.

Referenced by reconstruct(), and triseIfNoTDC().