CMS 3D CMS Logo

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

#include <HBHETimingShapedFlag.h>

Public Member Functions

void Clear ()
 
void dumpInfo ()
 
 HBHETimingShapedFlagSetter ()
 
 HBHETimingShapedFlagSetter (const std::vector< double > &tfilterEnvelope)
 
 HBHETimingShapedFlagSetter (const std::vector< double > &tfilterEnvelope, bool ignorelowest, bool ignorehighest, double win_offset, double win_gain)
 
void SetTimingShapedFlags (HBHERecHit &hbhe)
 
int timingStatus (const HBHERecHit &hbhe)
 
 ~HBHETimingShapedFlagSetter ()
 

Private Types

typedef std::map< int, std::pair< double, double > > TfilterEnvelope_t
 

Private Member Functions

void makeTfilterEnvelope (const std::vector< double > &v_userEnvelope)
 

Private Attributes

bool ignorehighest_
 
bool ignorelowest_
 
TfilterEnvelope_t tfilterEnvelope_
 
double win_gain_
 
double win_offset_
 

Detailed Description

Definition at line 8 of file HBHETimingShapedFlag.h.

Member Typedef Documentation

◆ TfilterEnvelope_t

typedef std::map<int, std::pair<double, double> > HBHETimingShapedFlagSetter::TfilterEnvelope_t
private

Definition at line 36 of file HBHETimingShapedFlag.h.

Constructor & Destructor Documentation

◆ HBHETimingShapedFlagSetter() [1/3]

HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( )

Definition at line 13 of file HBHETimingShapedFlag.cc.

13 {}

◆ HBHETimingShapedFlagSetter() [2/3]

HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope)

Definition at line 17 of file HBHETimingShapedFlag.cc.

References ignorehighest_, ignorelowest_, makeTfilterEnvelope(), win_gain_, and win_offset_.

17  {
18  makeTfilterEnvelope(v_userEnvelope);
19 
20  ignorelowest_ = false;
21  ignorehighest_ = false;
22  win_offset_ = 0.;
23  win_gain_ = 1.;
24 }
void makeTfilterEnvelope(const std::vector< double > &v_userEnvelope)

◆ HBHETimingShapedFlagSetter() [3/3]

HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope,
bool  ignorelowest,
bool  ignorehighest,
double  win_offset,
double  win_gain 
)

Definition at line 26 of file HBHETimingShapedFlag.cc.

References ignorehighest_, ignorelowest_, makeTfilterEnvelope(), win_gain_, and win_offset_.

30  {
31  makeTfilterEnvelope(v_userEnvelope);
32 
33  ignorelowest_ = ignorelowest; // can ignore flagging hits below lowest energy threshold
34  ignorehighest_ = ignorehighest; // can ignore flagging hits above highest energy threshold
35  win_offset_ = win_offset; // timing offset
36  win_gain_ = win_gain; // time gain
37 }
void makeTfilterEnvelope(const std::vector< double > &v_userEnvelope)

◆ ~HBHETimingShapedFlagSetter()

HBHETimingShapedFlagSetter::~HBHETimingShapedFlagSetter ( )

Definition at line 15 of file HBHETimingShapedFlag.cc.

15 {}

Member Function Documentation

◆ Clear()

void HBHETimingShapedFlagSetter::Clear ( )

◆ dumpInfo()

void HBHETimingShapedFlagSetter::dumpInfo ( )

Definition at line 56 of file HBHETimingShapedFlag.cc.

References gather_cfg::cout, ignorehighest_, ignorelowest_, tfilterEnvelope_, win_gain_, and win_offset_.

56  {
57  std::cout << "Timing Energy/Time parameters are:" << std::endl;
58  TfilterEnvelope_t::const_iterator it;
59  for (it = tfilterEnvelope_.begin(); it != tfilterEnvelope_.end(); ++it)
60  std::cout << "\t" << it->first << " GeV\t" << it->second.first << " ns\t" << it->second.second << " ns"
61  << std::endl;
62 
63  std::cout << "ignorelowest = " << ignorelowest_ << std::endl;
64  std::cout << "ignorehighest = " << ignorehighest_ << std::endl;
65  std::cout << "win_offset = " << win_offset_ << std::endl;
66  std::cout << "win_gain = " << win_gain_ << std::endl;
67 }
TfilterEnvelope_t tfilterEnvelope_

◆ makeTfilterEnvelope()

void HBHETimingShapedFlagSetter::makeTfilterEnvelope ( const std::vector< double > &  v_userEnvelope)
private

Definition at line 39 of file HBHETimingShapedFlag.cc.

References Exception, mps_fire::i, createfilelist::int, and tfilterEnvelope_.

Referenced by HBHETimingShapedFlagSetter().

39  {
40  // Transform vector of doubles into a map of <energy,lowtime,hitime> triplets
41  // Add extra protection in case vector of doubles is not a multiple of 3
42  if (v_userEnvelope.size() % 3)
43  throw cms::Exception("Invalid tfilterEnvelope definition") << "Must be one energy and two times per point";
44 
45  for (unsigned int i = 0; i < v_userEnvelope.size(); i += 3) {
46  int intGeV = (int)(v_userEnvelope[i] + 0.5);
47  std::pair<double, double> pairOfTimes = std::make_pair(v_userEnvelope[i + 1], v_userEnvelope[i + 2]);
48  if ((pairOfTimes.first > 0) || (pairOfTimes.second < 0))
49  throw cms::Exception("Invalid tfilterEnvelope definition")
50  << "Min and max time values must straddle t=0; use win_offset to shift";
51 
52  tfilterEnvelope_[intGeV] = pairOfTimes;
53  }
54 }
TfilterEnvelope_t tfilterEnvelope_

◆ SetTimingShapedFlags()

void HBHETimingShapedFlagSetter::SetTimingShapedFlags ( HBHERecHit hbhe)

Definition at line 144 of file HBHETimingShapedFlag.cc.

References photonIsolationHIProducer_cfi::hbhe, HcalCaloFlagLabels::HBHETimingShapedCutsBits, mps_update::status, and timingStatus().

144  {
145  int status = timingStatus(hbhe);
146 
147  // Though we're only using a single bit right now, 3 bits are reserved for these cuts
149 
150  return;
151 }
int timingStatus(const HBHERecHit &hbhe)

◆ timingStatus()

int HBHETimingShapedFlagSetter::timingStatus ( const HBHERecHit hbhe)

Definition at line 69 of file HBHETimingShapedFlag.cc.

References HCALHighEnergyHPDFilter_cfi::energy, photonIsolationHIProducer_cfi::hbhe, ignorehighest_, ignorelowest_, mps_update::status, tfilterEnvelope_, win_gain_, and win_offset_.

Referenced by SetTimingShapedFlags().

69  {
70  int status = 0; // 3 bits reserved;status can range from 0-7
71 
72  // tfilterEnvelope stores triples of energy and high/low time limits;
73  // make sure we're checking over an even number of values
74  // energies are guaranteed by std::map to appear in increasing order
75 
76  // need at least two values to make comparison, and must
77  // always have energy, time pair; otherwise, assume "in time" and don't set bits
78  if (tfilterEnvelope_.empty())
79  return 0;
80 
81  double twinmin, twinmax; // min, max 'good' time; values outside this range have flag set
82  double rhtime = hbhe.time();
83  double energy = hbhe.energy();
84 
85  if (energy < (double)tfilterEnvelope_.begin()->first) // less than lowest energy threshold
86  {
87  // Can skip timing test on cells below lowest threshold if so desired
88  if (ignorelowest_)
89  return 0;
90  else {
91  twinmin = tfilterEnvelope_.begin()->second.first;
92  twinmax = tfilterEnvelope_.begin()->second.second;
93  }
94  } else {
95  // Loop over energies in tfilterEnvelope
96  TfilterEnvelope_t::const_iterator it;
97  for (it = tfilterEnvelope_.begin(); it != tfilterEnvelope_.end(); ++it) {
98  // Identify tfilterEnvelope index for this rechit energy
99  if (energy < (double)it->first)
100  break;
101  }
102 
103  if (it == tfilterEnvelope_.end()) {
104  // Skip timing test on cells above highest threshold if so desired
105  if (ignorehighest_)
106  return 0;
107  else {
108  twinmin = tfilterEnvelope_.rbegin()->second.first;
109  twinmax = tfilterEnvelope_.rbegin()->second.second;
110  }
111  } else {
112  // Perform linear interpolation between energy boundaries
113 
114  std::map<int, std::pair<double, double> >::const_iterator prev = it;
115  prev--;
116 
117  // twinmax interpolation
118  double energy1 = prev->first;
119  double lim1 = prev->second.second;
120  double energy2 = it->first;
121  double lim2 = it->second.second;
122 
123  twinmax = lim1 + ((lim2 - lim1) * (energy - energy1) / (energy2 - energy1));
124 
125  // twinmin interpolation
126  lim1 = prev->second.first;
127  lim2 = it->second.first;
128 
129  twinmin = lim1 + ((lim2 - lim1) * (energy - energy1) / (energy2 - energy1));
130  }
131  }
132 
133  // Apply offset, gain
134  twinmin = win_offset_ + twinmin * win_gain_;
135  twinmax = win_offset_ + twinmax * win_gain_;
136 
137  // Set status high if time outside expected range
138  if (rhtime <= twinmin || rhtime >= twinmax)
139  status = 1; // set status to 1
140 
141  return status;
142 }
TfilterEnvelope_t tfilterEnvelope_

Member Data Documentation

◆ ignorehighest_

bool HBHETimingShapedFlagSetter::ignorehighest_
private

Definition at line 42 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

◆ ignorelowest_

bool HBHETimingShapedFlagSetter::ignorelowest_
private

Definition at line 41 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

◆ tfilterEnvelope_

TfilterEnvelope_t HBHETimingShapedFlagSetter::tfilterEnvelope_
private

Definition at line 37 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), makeTfilterEnvelope(), and timingStatus().

◆ win_gain_

double HBHETimingShapedFlagSetter::win_gain_
private

Definition at line 44 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().

◆ win_offset_

double HBHETimingShapedFlagSetter::win_offset_
private

Definition at line 43 of file HBHETimingShapedFlag.h.

Referenced by dumpInfo(), HBHETimingShapedFlagSetter(), and timingStatus().