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 9 of file HBHETimingShapedFlag.h.

Member Typedef Documentation

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

Definition at line 37 of file HBHETimingShapedFlag.h.

Constructor & Destructor Documentation

HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( )

Definition at line 13 of file HBHETimingShapedFlag.cc.

14 {
15 }
HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope)

Definition at line 21 of file HBHETimingShapedFlag.cc.

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

22 {
23  makeTfilterEnvelope(v_userEnvelope);
24 
25  ignorelowest_=false;
26  ignorehighest_=false;
27  win_offset_=0.;
28  win_gain_=1.;
29 }
void makeTfilterEnvelope(const std::vector< double > &v_userEnvelope)
HBHETimingShapedFlagSetter::HBHETimingShapedFlagSetter ( const std::vector< double > &  tfilterEnvelope,
bool  ignorelowest,
bool  ignorehighest,
double  win_offset,
double  win_gain 
)

Definition at line 31 of file HBHETimingShapedFlag.cc.

References HcalHitReconstructor_hbhe_cfi::ignorehighest, ignorehighest_, HcalHitReconstructor_hbhe_cfi::ignorelowest, ignorelowest_, makeTfilterEnvelope(), HcalHitReconstructor_hbhe_cfi::win_gain, win_gain_, HcalHitReconstructor_hbhe_cfi::win_offset, and win_offset_.

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

Definition at line 17 of file HBHETimingShapedFlag.cc.

18 {
19 }

Member Function Documentation

void HBHETimingShapedFlagSetter::Clear ( )
void HBHETimingShapedFlagSetter::dumpInfo ( )

Definition at line 66 of file HBHETimingShapedFlag.cc.

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

67 {
68  std::cout <<"Timing Energy/Time parameters are:"<<std::endl;
69  TfilterEnvelope_t::const_iterator it;
70  for (it=tfilterEnvelope_.begin();it!=tfilterEnvelope_.end();++it)
71  std::cout <<"\t"<<it->first<<" GeV\t"<<it->second.first<<" ns\t"<<it->second.second<<" ns"<<std::endl;
72 
73  std::cout <<"ignorelowest = "<<ignorelowest_<<std::endl;
74  std::cout <<"ignorehighest = "<<ignorehighest_<<std::endl;
75  std::cout <<"win_offset = "<<win_offset_<<std::endl;
76  std::cout <<"win_gain = "<<win_gain_<<std::endl;
77 }
TfilterEnvelope_t tfilterEnvelope_
void HBHETimingShapedFlagSetter::makeTfilterEnvelope ( const std::vector< double > &  v_userEnvelope)
private

Definition at line 44 of file HBHETimingShapedFlag.cc.

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

Referenced by HBHETimingShapedFlagSetter().

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

Definition at line 161 of file HBHETimingShapedFlag.cc.

References HcalCaloFlagLabels::HBHETimingShapedCutsBits, CaloRecHit::setFlagField(), mps_update::status, and timingStatus().

Referenced by HcalHitReconstructor::produce().

162 {
163  int status = timingStatus(hbhe);
164 
165  // Though we're only using a single bit right now, 3 bits are reserved for these cuts
167 
168  return;
169 }
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
int timingStatus(const HBHERecHit &hbhe)
int HBHETimingShapedFlagSetter::timingStatus ( const HBHERecHit hbhe)

Definition at line 80 of file HBHETimingShapedFlag.cc.

References CaloRecHit::energy(), ignorehighest_, ignorelowest_, mps_update::status, tfilterEnvelope_, CaloRecHit::time(), win_gain_, and win_offset_.

Referenced by SetTimingShapedFlags().

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

Member Data Documentation

bool HBHETimingShapedFlagSetter::ignorehighest_
private

Definition at line 43 of file HBHETimingShapedFlag.h.

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

bool HBHETimingShapedFlagSetter::ignorelowest_
private

Definition at line 42 of file HBHETimingShapedFlag.h.

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

TfilterEnvelope_t HBHETimingShapedFlagSetter::tfilterEnvelope_
private

Definition at line 38 of file HBHETimingShapedFlag.h.

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

double HBHETimingShapedFlagSetter::win_gain_
private

Definition at line 45 of file HBHETimingShapedFlag.h.

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

double HBHETimingShapedFlagSetter::win_offset_
private

Definition at line 44 of file HBHETimingShapedFlag.h.

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