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
HBHENegativeFlagSetter Class Reference

#include <HBHENegativeFlag.h>

Public Member Functions

 HBHENegativeFlagSetter ()
 
 HBHENegativeFlagSetter (double minimumChargeThreshold, double tS4TS5ChargeThreshold, int first, int last, std::vector< double > threshold, std::vector< double > cut)
 
void setBXInfo (const BunchXParameter *info, unsigned length)
 
void setHBHEPileupCorrection (boost::shared_ptr< AbsOOTPileupCorrection > corr)
 
void setPulseShapeFlags (HBHERecHit &hbhe, const HBHEDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
 
 ~HBHENegativeFlagSetter ()
 

Private Member Functions

bool checkPassFilter (double charge, double discriminant, std::vector< std::pair< double, double > > &cuts, int side)
 

Private Attributes

boost::shared_ptr
< AbsOOTPileupCorrection
hbhePileupCorr_
 
const BunchXParameter * mBunchCrossingInfo
 
std::vector< std::pair< double,
double > > 
mCut
 
int mFirst
 
int mLast
 
unsigned mLengthBunchCrossingInfo
 
double mMinimumChargeThreshold
 
double mTS4TS5ChargeThreshold
 

Detailed Description

Definition at line 24 of file HBHENegativeFlag.h.

Constructor & Destructor Documentation

HBHENegativeFlagSetter::HBHENegativeFlagSetter ( )

Definition at line 31 of file HBHENegativeFlag.cc.

References mBunchCrossingInfo, mFirst, mLast, mLengthBunchCrossingInfo, mMinimumChargeThreshold, mTS4TS5ChargeThreshold, and NULL.

32 {
33  //
34  // Argumentless constructor; should not be used
35  //
36  // If arguments not properly specified for the constructor, I don't think
37  // we'd trust the flagging algorithm.
38  // Set the minimum charge threshold large enough so that nothing will be flagged.
39  //
40 
41  mMinimumChargeThreshold = 99999999;
42  mTS4TS5ChargeThreshold = 99999999;
43  mFirst = 4;
44  mLast = 6;
47 }
#define NULL
Definition: scimark2.h:8
const BunchXParameter * mBunchCrossingInfo
HBHENegativeFlagSetter::HBHENegativeFlagSetter ( double  minimumChargeThreshold,
double  tS4TS5ChargeThreshold,
int  first,
int  last,
std::vector< double >  threshold,
std::vector< double >  cut 
)

Definition at line 49 of file HBHENegativeFlag.cc.

References edm::hlt::Exception, plotBeamSpotDB::first, i, prof2calltree::last, mBunchCrossingInfo, mCut, mFirst, min(), mLast, mLengthBunchCrossingInfo, mMinimumChargeThreshold, mTS4TS5ChargeThreshold, NULL, and python.multivaluedict::sort().

52 {
53  //
54  // The constructor that should be used
55  //
56  // Copies various thresholds and limits and parameters to the class for future use.
57  //
58 
59  mMinimumChargeThreshold = minimumChargeThreshold;
60  mTS4TS5ChargeThreshold = tS4TS5ChargeThreshold;
61  mFirst = first;
62  mLast = last;
63 
64  if (mFirst < 2 || mLast < mFirst)
65  throw cms::Exception("Invalid mFirst, mLast specification");
66 
69 
70  for(int i = 0; i < (int)std::min(threshold.size(), cut.size()); i++)
71  mCut.push_back(std::pair<double, double>(threshold[i], cut[i]));
72  std::sort(mCut.begin(), mCut.end());
73 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
std::vector< std::pair< double, double > > mCut
T min(T a, T b)
Definition: MathUtil.h:58
const BunchXParameter * mBunchCrossingInfo
HBHENegativeFlagSetter::~HBHENegativeFlagSetter ( )

Definition at line 75 of file HBHENegativeFlag.cc.

76 {
77  // Dummy destructor - there's nothing to destruct by hand here
78 }

Member Function Documentation

bool HBHENegativeFlagSetter::checkPassFilter ( double  charge,
double  discriminant,
std::vector< std::pair< double, double > > &  cuts,
int  side 
)
private

Definition at line 140 of file HBHENegativeFlag.cc.

References Reconstruction_Data_cff::cuts, plotBeamSpotDB::first, i, and MessageLogger_cff::limit.

Referenced by setPulseShapeFlags().

144 {
145  //
146  // Checks whether Discriminant value passes Cuts for the specified Charge. True if pulse is good.
147  //
148  // The "Cuts" pairs are assumed to be sorted in terms of size from small to large,
149  // where each "pair" = (Charge, Discriminant)
150  // "Side" is either positive or negative, which determines whether to discard the pulse if discriminant
151  // is greater or smaller than the cut value
152  //
153 
154  if(cuts.size() == 0) // safety check that there are some cuts defined
155  return true;
156 
157  if(charge <= cuts[0].first) // too small to cut on
158  return true;
159 
160  int indexLargerThanCharge = -1; // find the range it is falling in
161  for(int i = 1; i < (int)cuts.size(); i++)
162  {
163  if(cuts[i].first > charge)
164  {
165  indexLargerThanCharge = i;
166  break;
167  }
168  }
169 
170  double limit = 1000000;
171 
172  if(indexLargerThanCharge == -1) // if charge is greater than the last entry, assume flat line
173  limit = cuts[cuts.size()-1].second;
174  else // otherwise, do a linear interpolation to find the cut position
175  {
176  double C1 = cuts[indexLargerThanCharge].first;
177  double C2 = cuts[indexLargerThanCharge-1].first;
178  double L1 = cuts[indexLargerThanCharge].second;
179  double L2 = cuts[indexLargerThanCharge-1].second;
180 
181  limit = (charge - C1) / (C2 - C1) * (L2 - L1) + L1;
182  }
183 
184  if(side > 0 && discriminant > limit)
185  return false;
186  if(side < 0 && discriminant < limit)
187  return false;
188 
189  return true;
190 }
int i
Definition: DBlmapReader.cc:9
void HBHENegativeFlagSetter::setBXInfo ( const BunchXParameter *  info,
unsigned  length 
)

Definition at line 134 of file HBHENegativeFlag.cc.

References info(), mBunchCrossingInfo, and mLengthBunchCrossingInfo.

135 {
137  mLengthBunchCrossingInfo = length;
138 }
static const TGPicture * info(bool iBackgroundIsBlack)
const BunchXParameter * mBunchCrossingInfo
void HBHENegativeFlagSetter::setHBHEPileupCorrection ( boost::shared_ptr< AbsOOTPileupCorrection corr)

Definition at line 129 of file HBHENegativeFlag.cc.

References corr, and hbhePileupCorr_.

Referenced by HcalHitReconstructor::HcalHitReconstructor().

130 {
132 }
JetCorrectorParameters corr
Definition: classes.h:5
boost::shared_ptr< AbsOOTPileupCorrection > hbhePileupCorr_
void HBHENegativeFlagSetter::setPulseShapeFlags ( HBHERecHit hbhe,
const HBHEDataFrame digi,
const HcalCoder coder,
const HcalCalibrations calib 
)

Definition at line 80 of file HBHENegativeFlag.cc.

References HcalCoder::adc2fC(), checkPassFilter(), fwrapper::cs, fcn(), OOTPileupCorrDataFcn::getA1(), OOTPileupCorrDataFcn::getA2(), OOTPileupCorrData::getCorrectionByID(), HcalCaloFlagLabels::HBHENegativeNoise, hbhePileupCorr_, i, HBHERecHit::id(), CaloSamples::MAXSAMPLES, mCut, mFirst, mLast, mMinimumChargeThreshold, HcalCalibrations::pedestal(), CaloRecHit::setFlagField(), and CaloSamples::size().

Referenced by HcalHitReconstructor::produce().

84 {
85  //
86  // Decide if a digi/pulse is good or bad using negative energy discriminants
87  //
88  // SetPulseShapeFlags determines the total charge in the digi.
89  // If the charge is above the minimum threshold, the code then
90  // runs the flag-setting algorithms to determine whether the
91  // flags should be set.
92  //
93 
94  const OOTPileupCorrData* corrObj = dynamic_cast<OOTPileupCorrData*>(hbhePileupCorr_.get());
95  if (corrObj)
96  {
98  coder.adc2fC(digi,cs);
99  const int nRead = cs.size();
100 
101  double ts[CaloSamples::MAXSAMPLES];
102  for (int i=0; i < nRead; i++)
103  {
104  const int capid = digi[i].capid();
105  ts[i] = cs[i] - calib.pedestal(capid);
106  }
107 
108  double ChargeInWindow = 0.0;
109  for(int i = mFirst; i <= mLast && i < CaloSamples::MAXSAMPLES; i++)
110  ChargeInWindow += ts[i];
111  if(ChargeInWindow < mMinimumChargeThreshold)
112  return;
113 
114  const OOTPileupCorrDataFcn& fcn = corrObj->getCorrectionByID(hbhe.id());
115  const PiecewiseScalingPolynomial& a1 = fcn.getA1();
116  const PiecewiseScalingPolynomial& a2 = fcn.getA2();
117 
118  bool passes = true;
119  for (int i = mFirst; i <= mLast && passes; i++)
120  {
121  const double ecorr = ts[i] - a1(ts[i-1]) - a2(ts[i-2]);
122  passes = checkPassFilter(ChargeInWindow, ecorr, mCut, -1);
123  }
124  if (!passes)
126  }
127 }
int i
Definition: DBlmapReader.cc:9
const PiecewiseScalingPolynomial & getA1() const
auto_ptr< ClusterSequence > cs
static const int MAXSAMPLES
Definition: CaloSamples.h:73
HcalDetId id() const
get the id
Definition: HBHERecHit.h:23
const PiecewiseScalingPolynomial & getA2() const
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
double pedestal(int fCapId) const
get pedestal for capid=0..3
std::vector< std::pair< double, double > > mCut
bool checkPassFilter(double charge, double discriminant, std::vector< std::pair< double, double > > &cuts, int side)
int size() const
get the size
Definition: CaloSamples.h:24
void fcn(int &, double *, double &, double *, int)
boost::shared_ptr< AbsOOTPileupCorrection > hbhePileupCorr_
const OOTPileupCorrDataFcn & getCorrectionByID(const HcalDetId &id) const
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0

Member Data Documentation

boost::shared_ptr<AbsOOTPileupCorrection> HBHENegativeFlagSetter::hbhePileupCorr_
private

Definition at line 41 of file HBHENegativeFlag.h.

Referenced by setHBHEPileupCorrection(), and setPulseShapeFlags().

const BunchXParameter* HBHENegativeFlagSetter::mBunchCrossingInfo
private

Definition at line 44 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setBXInfo().

std::vector<std::pair<double, double> > HBHENegativeFlagSetter::mCut
private

Definition at line 46 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setPulseShapeFlags().

int HBHENegativeFlagSetter::mFirst
private

Definition at line 42 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setPulseShapeFlags().

int HBHENegativeFlagSetter::mLast
private

Definition at line 43 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setPulseShapeFlags().

unsigned HBHENegativeFlagSetter::mLengthBunchCrossingInfo
private

Definition at line 45 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setBXInfo().

double HBHENegativeFlagSetter::mMinimumChargeThreshold
private

Definition at line 39 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter(), and setPulseShapeFlags().

double HBHENegativeFlagSetter::mTS4TS5ChargeThreshold
private

Definition at line 40 of file HBHENegativeFlag.h.

Referenced by HBHENegativeFlagSetter().