CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 17 of file HBHETimingShapedFlag.cc.

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

18 {
19  makeTfilterEnvelope(v_userEnvelope);
20 
21  ignorelowest_=false;
22  ignorehighest_=false;
23  win_offset_=0.;
24  win_gain_=1.;
25 }
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 27 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 ( )

Member Function Documentation

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

Definition at line 62 of file HBHETimingShapedFlag.cc.

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

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

Definition at line 40 of file HBHETimingShapedFlag.cc.

References edm::hlt::Exception, i, and tfilterEnvelope_.

Referenced by HBHETimingShapedFlagSetter().

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

Definition at line 157 of file HBHETimingShapedFlag.cc.

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

Referenced by HcalHitReconstructor::produce().

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

Definition at line 76 of file HBHETimingShapedFlag.cc.

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

Referenced by SetTimingShapedFlags().

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

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().