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 Member Functions | Private Attributes | Friends
HBHENegativeEFilter Class Reference

#include <HBHENegativeEFilter.h>

Public Member Functions

bool checkPassFilter (const HcalDetId &id, const double *ts, unsigned lenTS) const
 
const PiecewiseScalingPolynomialgetA1 (const HcalDetId &id) const
 
const PiecewiseScalingPolynomialgetA2 (const HcalDetId &id) const
 
const std::vector< std::pair
< double, double > > & 
getCut () const
 
const std::vector< uint32_t > & getEtaLimits () const
 
unsigned getFirstTimeSlice () const
 
unsigned getLastTimeSlice () const
 
double getMinCharge () const
 
 HBHENegativeEFilter ()
 
 HBHENegativeEFilter (const std::vector< PiecewiseScalingPolynomial > &a1vec, const std::vector< PiecewiseScalingPolynomial > &a2vec, const std::vector< uint32_t > &iEtaLimits, const std::vector< std::pair< double, double > > &cut, double minCharge, unsigned firstTimeSlice, unsigned lastTimeSlice)
 
bool isEnabled () const
 
bool operator!= (const HBHENegativeEFilter &r) const
 
bool operator== (const HBHENegativeEFilter &r) const
 

Private Member Functions

unsigned getEtaIndex (const HcalDetId &id) const
 
template<class Archive >
void load (Archive &ar, const unsigned)
 
template<class Archive >
void save (Archive &ar, const unsigned) const
 
bool validate () const
 

Private Attributes

std::vector
< PiecewiseScalingPolynomial
a1v_
 
std::vector
< PiecewiseScalingPolynomial
a2v_
 
std::vector< std::pair< double,
double > > 
cut_
 
std::vector< uint32_t > iEtaLimits_
 
double minCharge_
 
uint32_t tFirst_
 
uint32_t tLast_
 

Friends

class boost::serialization::access
 

Detailed Description

Definition at line 16 of file HBHENegativeEFilter.h.

Constructor & Destructor Documentation

HBHENegativeEFilter::HBHENegativeEFilter ( )
inline

Definition at line 19 of file HBHENegativeEFilter.h.

HBHENegativeEFilter::HBHENegativeEFilter ( const std::vector< PiecewiseScalingPolynomial > &  a1vec,
const std::vector< PiecewiseScalingPolynomial > &  a2vec,
const std::vector< uint32_t > &  iEtaLimits,
const std::vector< std::pair< double, double > > &  cut,
double  minCharge,
unsigned  firstTimeSlice,
unsigned  lastTimeSlice 
)

Definition at line 6 of file HBHENegativeEFilter.cc.

References Exception, and validate().

14  : a1v_(a1vec),
15  a2v_(a2vec),
16  iEtaLimits_(iEtaLimits),
17  cut_(cut),
18  minCharge_(minCharge),
19  tFirst_(firstTimeSlice),
20  tLast_(lastTimeSlice)
21 {
22  if (!validate()) throw cms::Exception(
23  "Invalid HBHENegativeEFilter constructor arguments");
24 }
std::vector< PiecewiseScalingPolynomial > a1v_
std::vector< PiecewiseScalingPolynomial > a2v_
std::vector< std::pair< double, double > > cut_
std::vector< uint32_t > iEtaLimits_

Member Function Documentation

bool HBHENegativeEFilter::checkPassFilter ( const HcalDetId id,
const double *  ts,
unsigned  lenTS 
) const

Definition at line 87 of file HBHENegativeEFilter.cc.

References a1v_, a2v_, GOODCOLL_filter_cfg::cut, cut_, plotBeamSpotDB::first, getEtaIndex(), i, minCharge_, slope, tFirst_, and tLast_.

Referenced by HBHENegativeFlagSetter::setPulseShapeFlags().

89 {
90  bool passes = true;
91  const unsigned sz = cut_.size();
92  if (sz)
93  {
94  double chargeInWindow = 0.0;
95  for (unsigned i=tFirst_; i<=tLast_ && i<lenTS; ++i)
96  chargeInWindow += ts[i];
97  if (chargeInWindow >= minCharge_)
98  {
99  // Figure out the cut value for this charge
100  const std::pair<double,double>* cut = &cut_[0];
101  double cutValue = cut[0].second;
102  if (sz > 1U)
103  {
104  // First point larger than charge
105  unsigned largerPoint = 0;
106  for (; cut[largerPoint].first <= chargeInWindow; ++largerPoint) {}
107 
108  // Constant extrapolation beyond min and max coords
109  if (largerPoint >= sz)
110  cutValue = cut[sz - 1U].second;
111  else if (largerPoint)
112  {
113  const double slope = (cut[largerPoint].second - cut[largerPoint-1U].second)/
114  (cut[largerPoint].first - cut[largerPoint-1U].first);
115  cutValue = cut[largerPoint-1U].second + slope*
116  (chargeInWindow - cut[largerPoint-1U].first);
117  }
118  }
119 
120  // Compare the modified time slices with the cut
121  const unsigned itaIdx = getEtaIndex(id);
122  const PiecewiseScalingPolynomial& a1(a1v_[itaIdx]);
123  const PiecewiseScalingPolynomial& a2(a2v_[itaIdx]);
124 
125  for (unsigned i=tFirst_; i<=tLast_ && i<lenTS && passes; ++i)
126  {
127  const double ecorr = ts[i] - a1(ts[i-1U]) - a2(ts[i-2U]);
128  passes = ecorr >= cutValue;
129  }
130  }
131  }
132  return passes;
133 }
int i
Definition: DBlmapReader.cc:9
std::vector< PiecewiseScalingPolynomial > a1v_
unsigned getEtaIndex(const HcalDetId &id) const
std::vector< PiecewiseScalingPolynomial > a2v_
static const double slope[3]
std::vector< std::pair< double, double > > cut_
const PiecewiseScalingPolynomial& HBHENegativeEFilter::getA1 ( const HcalDetId id) const
inline

Definition at line 34 of file HBHENegativeEFilter.h.

References a1v_, and getEtaIndex().

35  {return a1v_.at(getEtaIndex(id));}
std::vector< PiecewiseScalingPolynomial > a1v_
unsigned getEtaIndex(const HcalDetId &id) const
const PiecewiseScalingPolynomial& HBHENegativeEFilter::getA2 ( const HcalDetId id) const
inline

Definition at line 36 of file HBHENegativeEFilter.h.

References a2v_, and getEtaIndex().

37  {return a2v_.at(getEtaIndex(id));}
unsigned getEtaIndex(const HcalDetId &id) const
std::vector< PiecewiseScalingPolynomial > a2v_
const std::vector<std::pair<double,double> >& HBHENegativeEFilter::getCut ( ) const
inline

Definition at line 40 of file HBHENegativeEFilter.h.

References cut_.

41  {return cut_;}
std::vector< std::pair< double, double > > cut_
unsigned HBHENegativeEFilter::getEtaIndex ( const HcalDetId id) const
private

Definition at line 72 of file HBHENegativeEFilter.cc.

References funct::abs(), iEtaLimits_, and eostools::which().

Referenced by checkPassFilter(), getA1(), and getA2().

73 {
74  const unsigned nLimits = iEtaLimits_.size();
75  unsigned which(0U);
76  if (nLimits)
77  {
78  const uint32_t uEta = std::abs(id.ieta());
79  const uint32_t* limits(&iEtaLimits_[0]);
80  for (; which<nLimits; ++which)
81  if (uEta < limits[which])
82  break;
83  }
84  return which;
85 }
def which
Definition: eostools.py:335
std::vector< uint32_t > iEtaLimits_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector<uint32_t>& HBHENegativeEFilter::getEtaLimits ( ) const
inline

Definition at line 38 of file HBHENegativeEFilter.h.

References iEtaLimits_.

39  {return iEtaLimits_;}
std::vector< uint32_t > iEtaLimits_
unsigned HBHENegativeEFilter::getFirstTimeSlice ( ) const
inline

Definition at line 43 of file HBHENegativeEFilter.h.

References tFirst_.

43 {return tFirst_;}
unsigned HBHENegativeEFilter::getLastTimeSlice ( ) const
inline

Definition at line 44 of file HBHENegativeEFilter.h.

References tLast_.

44 {return tLast_;}
double HBHENegativeEFilter::getMinCharge ( ) const
inline

Definition at line 42 of file HBHENegativeEFilter.h.

References minCharge_.

42 {return minCharge_;}
bool HBHENegativeEFilter::isEnabled ( ) const
inline

Definition at line 45 of file HBHENegativeEFilter.h.

References cut_.

45 {return !cut_.empty();}
std::vector< std::pair< double, double > > cut_
template<class Archive >
void HBHENegativeEFilter::load ( Archive &  ar,
const unsigned   
)
inlineprivate

Definition at line 75 of file HBHENegativeEFilter.h.

References a1v_, a2v_, cut_, Exception, iEtaLimits_, minCharge_, tFirst_, tLast_, and validate().

Referenced by MatrixToProcess.MatrixToProcess::getProcess(), and MatrixToProcess.MatrixToProcess::listAll().

76  {
78  if (!validate()) throw cms::Exception(
79  "In HBHENegativeEFilter::load: invalid data");
80  }
std::vector< PiecewiseScalingPolynomial > a1v_
std::vector< PiecewiseScalingPolynomial > a2v_
std::vector< std::pair< double, double > > cut_
std::vector< uint32_t > iEtaLimits_
bool HBHENegativeEFilter::operator!= ( const HBHENegativeEFilter r) const
inline

Definition at line 49 of file HBHENegativeEFilter.h.

References alignCSCRings::r.

50  {return !(*this == r);}
bool HBHENegativeEFilter::operator== ( const HBHENegativeEFilter r) const

Definition at line 58 of file HBHENegativeEFilter.cc.

References a1v_, a2v_, cut_, iEtaLimits_, minCharge_, tFirst_, and tLast_.

59 {
60  if (cut_.empty() && r.cut_.empty())
61  return true;
62  else
63  return a1v_ == r.a1v_ &&
64  a2v_ == r.a2v_ &&
65  iEtaLimits_ == r.iEtaLimits_ &&
66  cut_ == r.cut_ &&
67  minCharge_ == r.minCharge_ &&
68  tFirst_ == r.tFirst_ &&
69  tLast_ == r.tLast_;
70 }
std::vector< PiecewiseScalingPolynomial > a1v_
std::vector< PiecewiseScalingPolynomial > a2v_
std::vector< std::pair< double, double > > cut_
std::vector< uint32_t > iEtaLimits_
template<class Archive >
void HBHENegativeEFilter::save ( Archive &  ar,
const unsigned   
) const
inlineprivate

Definition at line 67 of file HBHENegativeEFilter.h.

References a1v_, a2v_, cut_, Exception, iEtaLimits_, minCharge_, tFirst_, tLast_, and validate().

Referenced by Vispa.Main.TabController.TabController::allowClose(), and Vispa.Main.TabController.TabController::checkModificationTimestamp().

68  {
69  if (!validate()) throw cms::Exception(
70  "In HBHENegativeEFilter::save: invalid data");
72  }
std::vector< PiecewiseScalingPolynomial > a1v_
std::vector< PiecewiseScalingPolynomial > a2v_
std::vector< std::pair< double, double > > cut_
std::vector< uint32_t > iEtaLimits_
bool HBHENegativeEFilter::validate ( ) const
private

Definition at line 26 of file HBHENegativeEFilter.cc.

References a1v_, a2v_, cut_, plotBeamSpotDB::first, i, iEtaLimits_, tFirst_, and tLast_.

Referenced by HBHENegativeEFilter(), load(), and save().

27 {
28  if (cut_.empty())
29  return true;
30 
31  const std::size_t nLimits(iEtaLimits_.size());
32  if (nLimits >= static_cast<std::size_t>(UINT_MAX - 1U))
33  return false;
34  for (std::size_t i=1; i<nLimits; ++i)
35  if (!(iEtaLimits_[i-1] < iEtaLimits_[i]))
36  return false;
37 
38  if (a1v_.size() != nLimits + 1)
39  return false;
40  if (a2v_.size() != nLimits + 1)
41  return false;
42 
43  const std::size_t sz = cut_.size();
44  if (sz >= static_cast<std::size_t>(UINT_MAX - 1U))
45  return false;
46  for (std::size_t i=1; i<sz; ++i)
47  if (!(cut_[i-1U].first < cut_[i].first))
48  return false;
49 
50  if (tFirst_ < 2U)
51  return false;
52  if (!(tFirst_ <= tLast_))
53  return false;
54 
55  return true;
56 }
int i
Definition: DBlmapReader.cc:9
std::vector< PiecewiseScalingPolynomial > a1v_
std::vector< PiecewiseScalingPolynomial > a2v_
std::vector< std::pair< double, double > > cut_
std::vector< uint32_t > iEtaLimits_

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 64 of file HBHENegativeEFilter.h.

Member Data Documentation

std::vector<PiecewiseScalingPolynomial> HBHENegativeEFilter::a1v_
private

Definition at line 56 of file HBHENegativeEFilter.h.

Referenced by checkPassFilter(), getA1(), load(), operator==(), save(), and validate().

std::vector<PiecewiseScalingPolynomial> HBHENegativeEFilter::a2v_
private

Definition at line 57 of file HBHENegativeEFilter.h.

Referenced by checkPassFilter(), getA2(), load(), operator==(), save(), and validate().

std::vector<std::pair<double,double> > HBHENegativeEFilter::cut_
private

Definition at line 59 of file HBHENegativeEFilter.h.

Referenced by checkPassFilter(), getCut(), isEnabled(), load(), operator==(), save(), and validate().

std::vector<uint32_t> HBHENegativeEFilter::iEtaLimits_
private

Definition at line 58 of file HBHENegativeEFilter.h.

Referenced by getEtaIndex(), getEtaLimits(), load(), operator==(), save(), and validate().

double HBHENegativeEFilter::minCharge_
private

Definition at line 60 of file HBHENegativeEFilter.h.

Referenced by checkPassFilter(), getMinCharge(), load(), operator==(), and save().

uint32_t HBHENegativeEFilter::tFirst_
private
uint32_t HBHENegativeEFilter::tLast_
private