CMS 3D CMS Logo

HcalHFStatusBitFromDigis.cc
Go to the documentation of this file.
3 
4 #include <algorithm> // for "max"
5 #include <cmath>
6 #include <iostream>
7 
9  // use simple values in default constructor
10  minthreshold_ = 40; // minimum energy threshold (in GeV)
11 
12  firstSample_ =
13  1; // these are the firstSample, samplesToAdd value of Igor's algorithm -- not necessarily the same as the reco first, toadd values (which are supplied individually for each hit)
14  samplesToAdd_ = 3;
15  expectedPeak_ = 2;
16 
17  // Based on Igor V's algorithm:
18  //TS4/(TS3+TS4+TS5+TS6) > 0.93 - exp(-0.38275-0.012667*E)
19  coef_.push_back(0.93);
20  coef_.push_back(-0.38275);
21  coef_.push_back(-0.012667);
22  // Minimum energy of 10 GeV required
24  HFlongwindowMinTime_.clear();
25  HFlongwindowMinTime_.push_back(-10);
26  HFlongwindowMaxTime_.clear();
27  HFlongwindowMaxTime_.push_back(8);
29  HFshortwindowMinTime_.clear();
30  HFshortwindowMinTime_.push_back(-10);
31  HFshortwindowMaxTime_.clear();
32  HFshortwindowMaxTime_.push_back(8);
33 }
34 
36  const edm::ParameterSet& HFTimeInWindowParams) {
37  // Specify parameters used in forming the HFDigiTime flag
38  firstSample_ = HFDigiTimeParams.getParameter<int>("HFdigiflagFirstSample");
39  samplesToAdd_ = HFDigiTimeParams.getParameter<int>("HFdigiflagSamplesToAdd");
40  expectedPeak_ = HFDigiTimeParams.getParameter<int>("HFdigiflagExpectedPeak");
41  minthreshold_ = HFDigiTimeParams.getParameter<double>("HFdigiflagMinEthreshold");
42  coef_ = HFDigiTimeParams.getParameter<std::vector<double> >("HFdigiflagCoef");
43 
44  // Specify parameters used in forming HFInTimeWindow flag
45  HFlongwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMinWindowTime");
46  HFlongwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMaxWindowTime");
47  HFlongwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hflongEthresh");
48  HFshortwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMinWindowTime");
49  HFshortwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMaxWindowTime");
50  HFshortwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hfshortEthresh");
51 }
52 
54 
56  int firstSample, int samplesToAdd, int expectedPeak, double minthreshold, const std::vector<double>& coef) {
57  // Resets values based on values in database.
60  expectedPeak_ = expectedPeak;
61  minthreshold_ = minthreshold;
62  coef_ = coef;
63 }
64 
66  // This resets the time samples used in the HF flag. These samples are not necessarily the same
67  // as the flags used by the energy reconstruction
70  expectedPeak_ = expectedPeak;
71 } // void HcalHFStatusBitFromDigis
72 
74  const HFDataFrame& digi,
75  const HcalCoder& coder,
76  const HcalCalibrations& calib) {
77  // The following 3 values are computed by Igor's algorithm
78  //only in the window [firstSample_, firstSample_ + samplesToAdd_),
79  //which may not be the same as the default reco window.
80 
81  double totalCharge = 0;
82  double peakCharge = 0;
83  double RecomputedEnergy = 0;
84 
85  CaloSamples tool;
86  coder.adc2fC(digi, tool);
87 
88  // Compute quantities needed for HFDigiTime, Fraction2TS FLAGS
89  for (int i = 0; i < digi.size(); ++i) {
90  int capid = digi.sample(i).capid();
91  double value = tool[i] - calib.pedestal(capid);
92 
93  // Sum all charge within flagging window, find charge in expected peak time slice
94  if (i >= firstSample_ && i < firstSample_ + samplesToAdd_) {
95  totalCharge += value;
96  RecomputedEnergy += value * calib.respcorrgain(capid);
97  if (i == expectedPeak_)
98  peakCharge = value;
99  }
100  } // for (int i=0;i<digi.size();++i)
101 
102  // FLAG: HcalCaloLabels::HFDigiTime
103  // Igor's algorithm: compare charge in peak to total charge in window
104  if (RecomputedEnergy >= minthreshold_) // don't set noise flags for cells below a given threshold
105  {
106  // Calculate allowed minimum value of (TS4/TS3+4+5+6):
107  double cutoff = 0; // no arguments specified; no cutoff applied
108  if (!coef_.empty())
109  cutoff = coef_[0];
110  // default cutoff takes the form:
111  // cutoff = coef_[0] - exp(coef_[1]+coef_[2]*E+coef_[3]*E^2+...)
112  double powRE = 1;
113  double expo_arg = 0;
114  for (unsigned int zz = 1; zz < coef_.size(); ++zz) {
115  expo_arg += coef_[zz] * powRE;
116  powRE *= RecomputedEnergy;
117  }
118  cutoff -= exp(expo_arg);
119 
120  if (peakCharge / totalCharge < cutoff)
121  hf.setFlagField(1, HcalCaloFlagLabels::HFDigiTime);
122  }
123 
124  // FLAG: HcalCaloLabels:: HFInTimeWindow
125  // Timing algorithm
126  if (hf.id().depth() == 1) {
127  if (hf.energy() >= HFlongwindowEthresh_) {
128  float mult = 1. / hf.energy();
129  float enPow = 1.;
130  float mintime = 0;
131  float maxtime = 0;
132  for (unsigned int i = 0; i < HFlongwindowMinTime_.size(); ++i) {
133  mintime += HFlongwindowMinTime_[i] * enPow;
134  maxtime += HFlongwindowMaxTime_[i] * enPow;
135  enPow *= mult;
136  }
137  if (hf.time() < mintime || hf.time() > maxtime)
138  hf.setFlagField(1, HcalCaloFlagLabels::HFInTimeWindow);
139  }
140  } else if (hf.id().depth() == 2) {
141  if (hf.energy() >= HFshortwindowEthresh_) {
142  float mult = 1. / hf.energy();
143  float enPow = 1.;
144  float mintime = 0;
145  float maxtime = 0;
146  for (unsigned int i = 0; i < HFshortwindowMinTime_.size(); ++i) {
147  mintime += HFshortwindowMinTime_[i] * enPow;
148  maxtime += HFshortwindowMaxTime_[i] * enPow;
149  enPow *= mult;
150  }
151  if (hf.time() < mintime || hf.time() > maxtime)
152  hf.setFlagField(1, HcalCaloFlagLabels::HFInTimeWindow);
153  }
154  }
155 
156  return;
157 }
HcalHFStatusBitFromDigis::HFshortwindowMaxTime_
std::vector< double > HFshortwindowMaxTime_
Definition: HcalHFStatusBitFromDigis.h:55
mps_fire.i
i
Definition: mps_fire.py:428
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
MessageLogger.h
CastorTowerReco_cfi.mintime
mintime
Definition: CastorTowerReco_cfi.py:7
HcalHFStatusBitFromDigis::HFshortwindowMinTime_
std::vector< double > HFshortwindowMinTime_
Definition: HcalHFStatusBitFromDigis.h:54
HcalCoder::adc2fC
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
castor_dqm_sourceclient-live_cfg.samplesToAdd
samplesToAdd
Definition: castor_dqm_sourceclient-live_cfg.py:62
HcalHFStatusBitFromDigis::HcalHFStatusBitFromDigis
HcalHFStatusBitFromDigis()
Definition: HcalHFStatusBitFromDigis.cc:8
HFDataFrame::sample
constexpr HcalQIESample const & sample(int i) const
access a sample
Definition: HFDataFrame.h:40
CastorTowerReco_cfi.maxtime
maxtime
Definition: CastorTowerReco_cfi.py:8
HcalHFStatusBitFromDigis::hfSetFlagFromDigi
void hfSetFlagFromDigi(HFRecHit &hf, const HFDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
Definition: HcalHFStatusBitFromDigis.cc:73
HcalHFStatusBitFromDigis::samplesToAdd_
int samplesToAdd_
Definition: HcalHFStatusBitFromDigis.h:42
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
HFRecHit
Definition: HFRecHit.h:11
HcalCaloFlagLabels::HFDigiTime
Definition: HcalCaloFlagLabels.h:38
HcalHFStatusBitFromDigis::minthreshold_
double minthreshold_
Definition: HcalHFStatusBitFromDigis.h:36
HcalCalibrations
Definition: HcalCalibrations.h:9
HcalHFStatusBitFromDigis::expectedPeak_
int expectedPeak_
Definition: HcalHFStatusBitFromDigis.h:43
HcalHFStatusBitFromDigis::coef_
std::vector< double > coef_
Definition: HcalHFStatusBitFromDigis.h:47
calib
Definition: CalibElectron.h:12
HFDataFrame::size
constexpr int size() const
total number of samples in the digi
Definition: HFDataFrame.h:27
edm::ParameterSet
Definition: ParameterSet.h:47
castor_dqm_sourceclient-live_cfg.firstSample
firstSample
Definition: castor_dqm_sourceclient-live_cfg.py:64
HcalHFStatusBitFromDigis::resetParamsFromDB
void resetParamsFromDB(int firstSample, int samplesToAdd, int expectedPeak, double minthreshold, const std::vector< double > &coef)
Definition: HcalHFStatusBitFromDigis.cc:55
HcalHFStatusBitFromDigis::HFlongwindowEthresh_
double HFlongwindowEthresh_
Definition: HcalHFStatusBitFromDigis.h:50
HcalHFStatusBitFromDigis::HFlongwindowMaxTime_
std::vector< double > HFlongwindowMaxTime_
Definition: HcalHFStatusBitFromDigis.h:52
HFDataFrame
Definition: HFDataFrame.h:14
value
Definition: value.py:1
HcalQIESample::capid
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
CaloSamples
Definition: CaloSamples.h:14
HcalHFStatusBitFromDigis::firstSample_
int firstSample_
Definition: HcalHFStatusBitFromDigis.h:41
HcalCaloFlagLabels::HFInTimeWindow
Definition: HcalCaloFlagLabels.h:39
HcalHFStatusBitFromDigis.h
EcalSCDynamicDPhiParametersESProducer_cfi.cutoff
cutoff
Definition: EcalSCDynamicDPhiParametersESProducer_cfi.py:15
relativeConstraints.value
value
Definition: relativeConstraints.py:53
HcalCoder
Definition: HcalCoder.h:19
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
VarParsing.mult
mult
Definition: VarParsing.py:658
HcalHFStatusBitFromDigis::HFlongwindowMinTime_
std::vector< double > HFlongwindowMinTime_
Definition: HcalHFStatusBitFromDigis.h:51
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
HcalHFStatusBitFromDigis::resetFlagTimeSamples
void resetFlagTimeSamples(int firstSample, int samplesToAdd, int expectedPeak)
Definition: HcalHFStatusBitFromDigis.cc:65
HcalHFStatusBitFromDigis::HFshortwindowEthresh_
double HFshortwindowEthresh_
Definition: HcalHFStatusBitFromDigis.h:53
HcalHFStatusBitFromDigis::~HcalHFStatusBitFromDigis
~HcalHFStatusBitFromDigis()
Definition: HcalHFStatusBitFromDigis.cc:53