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 28 of file HBHENegativeFlag.cc.

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

29 {
30  //
31  // Argumentless constructor; should not be used
32  //
33  // If arguments not properly specified for the constructor, I don't think
34  // we'd trust the flagging algorithm.
35  // Set the minimum charge threshold large enough so that nothing will be flagged.
36  //
37 
38  mMinimumChargeThreshold = 99999999;
39  mTS4TS5ChargeThreshold = 99999999;
40  mFirst = 4;
41  mLast = 6;
44 }
#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 46 of file HBHENegativeFlag.cc.

References first, i, prof2calltree::last, mBunchCrossingInfo, mCut, mFirst, min(), mLast, mLengthBunchCrossingInfo, mMinimumChargeThreshold, mTS4TS5ChargeThreshold, NULL, python.multivaluedict::sort(), and std::swap().

49 {
50  //
51  // The constructor that should be used
52  //
53  // Copies various thresholds and limits and parameters to the class for future use.
54  //
55 
56  mMinimumChargeThreshold = minimumChargeThreshold;
57  mTS4TS5ChargeThreshold = tS4TS5ChargeThreshold;
58  mFirst = first;
59  mLast = last;
60 
61  if(mLast < mFirst) // sanity protection
63 
66 
67  for(int i = 0; i < (int)std::min(threshold.size(), cut.size()); i++)
68  mCut.push_back(std::pair<double, double>(threshold[i], cut[i]));
69  std::sort(mCut.begin(), mCut.end());
70 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
std::vector< std::pair< double, double > > mCut
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T min(T a, T b)
Definition: MathUtil.h:58
bool first
Definition: L1TdeRCT.cc:75
const BunchXParameter * mBunchCrossingInfo
HBHENegativeFlagSetter::~HBHENegativeFlagSetter ( )

Definition at line 72 of file HBHENegativeFlag.cc.

73 {
74  // Dummy destructor - there's nothing to destruct by hand here
75 }

Member Function Documentation

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

Definition at line 151 of file HBHENegativeFlag.cc.

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

Referenced by setPulseShapeFlags().

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

Definition at line 145 of file HBHENegativeFlag.cc.

References info(), mBunchCrossingInfo, and mLengthBunchCrossingInfo.

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

Definition at line 140 of file HBHENegativeFlag.cc.

References corr, and hbhePileupCorr_.

Referenced by HcalHitReconstructor::HcalHitReconstructor().

141 {
143 }
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 77 of file HBHENegativeFlag.cc.

References HcalCoder::adc2fC(), checkPassFilter(), fwrapper::cs, HcalCaloFlagLabels::HBHENegativeNoise, hbhePileupCorr_, i, HBHEDataFrame::id(), CaloSamples::MAXSAMPLES, mBunchCrossingInfo, mCut, mFirst, min(), mLast, mLengthBunchCrossingInfo, mMinimumChargeThreshold, n, HcalCalibrations::pedestal(), HcalCalibrations::respcorrgain(), CaloRecHit::setFlagField(), and CaloSamples::size().

Referenced by HcalHitReconstructor::produce().

81 {
82  //
83  // Decide if a digi/pulse is good or bad using negative energy discriminants
84  //
85  // SetPulseShapeFlags determines the total charge in the digi.
86  // If the charge is above the minimum threshold, the code then
87  // runs the flag-setting algorithms to determine whether the
88  // flags should be set.
89  //
90 
91  if(hbhePileupCorr_)
92  {
94  coder.adc2fC(digi,cs);
95  const int nRead = cs.size();
96 
97  double inputCharge[CaloSamples::MAXSAMPLES];
98  double gains[CaloSamples::MAXSAMPLES];
99  double CorrectedEnergy[CaloSamples::MAXSAMPLES];
100 
101  for(int i = 0; i < nRead; i++)
102  {
103  const int capid = digi[i].capid();
104  inputCharge[i] = cs[i] - calib.pedestal(capid);
105  gains[i] = calib.respcorrgain(capid);
106  }
107 
108  double ChargeInWindow = 0;
109  for(int i = mFirst; i <= mLast && i < CaloSamples::MAXSAMPLES; i++)
110  ChargeInWindow = ChargeInWindow + inputCharge[i];
111  if(ChargeInWindow < mMinimumChargeThreshold)
112  return;
113 
114  const bool UseGain = hbhePileupCorr_->inputIsEnergy();
115  if(UseGain == true)
116  for(int i = 0; i < nRead; i++)
117  inputCharge[i] = inputCharge[i] * gains[i];
118 
119  bool pulseShapeCorrApplied = false;
120  bool leakCorrApplied = false;
121  bool readjustTiming = false;
122 
123  int n = std::min(mLast + 1, CaloSamples::MAXSAMPLES) - mFirst;
124 
125  hbhePileupCorr_->apply(digi.id(), inputCharge, nRead,
127  CorrectedEnergy, CaloSamples::MAXSAMPLES,
128  &pulseShapeCorrApplied, &leakCorrApplied,
129  &readjustTiming);
130 
131  for(int i = mFirst; i <= mLast; i++)
132  {
133  bool decision = checkPassFilter(ChargeInWindow, CorrectedEnergy[i], mCut, -1);
134  if(decision == false)
136  }
137  }
138 }
int i
Definition: DBlmapReader.cc:9
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
static const int MAXSAMPLES
Definition: CaloSamples.h:73
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
T min(T a, T b)
Definition: MathUtil.h:58
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
boost::shared_ptr< AbsOOTPileupCorrection > hbhePileupCorr_
const BunchXParameter * mBunchCrossingInfo
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22

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(), setBXInfo(), and setPulseShapeFlags().

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(), setBXInfo(), and setPulseShapeFlags().

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