CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHF_PETalgorithm.cc
Go to the documentation of this file.
8 
9 #include <algorithm> // for "max"
10 #include <cmath>
11 #include <iostream>
12 
14 {
15  // no params given; revert to old 'algo 1' fixed settings
16  short_R.clear();
17  short_R.push_back(0.995);
18  short_R_29.clear();
19  short_R_29.push_back(0.995);
20  short_Energy_Thresh.clear();
21  short_Energy_Thresh.push_back(50);
22  short_ET_Thresh.clear();
23  short_ET_Thresh.push_back(0);
24 
25  long_R.clear();
26  long_R.push_back(0.995);
27  long_R_29.clear();
28  long_R_29.push_back(0.995);
29  long_Energy_Thresh.clear();
30  long_Energy_Thresh.push_back(50);
31  long_ET_Thresh.clear();
32  long_ET_Thresh.push_back(0);
34 }
35 
36 HcalHF_PETalgorithm::HcalHF_PETalgorithm(const std::vector<double>& shortR,
37  const std::vector<double>& shortEnergyParams,
38  const std::vector<double>& shortETParams,
39  const std::vector<double>& longR,
40  const std::vector<double>& longEnergyParams,
41  const std::vector<double>& longETParams,
42  int HcalAcceptSeverityLevel,
43  const std::vector<double>& shortR29,
44  const std::vector<double>& longR29)
45 {
46  // R is parameterized depending on the energy of the cells, so just store the parameters here
47  short_R = shortR;
48  long_R = longR;
49  short_R_29 = shortR29;
50  long_R_29 = longR29;
51 
52  // Energy and ET cuts are ieta-dependent, and only need to be calculated once!
53  short_Energy_Thresh.clear();
54  short_ET_Thresh.clear();
55  long_Energy_Thresh.clear();
56  long_ET_Thresh.clear();
57 
58  //separate short, long cuts provided for each ieta
59  short_Energy_Thresh=shortEnergyParams;
60  short_ET_Thresh=shortETParams;
61  long_Energy_Thresh=longEnergyParams;
62  long_ET_Thresh=longETParams;
63 
64  HcalAcceptSeverityLevel_=HcalAcceptSeverityLevel;
65 }
66 
68 
69 
70 
72  HFRecHitCollection& rec,
73  const HcalChannelQuality* myqual,
74  const HcalSeverityLevelComputer* mySeverity)
75 {
76  /* Set the HFLongShort flag by comparing the ratio |L-S|/|L+S|. Channels must first pass energy and ET cuts, and channels whose partners are known to be dead are skipped, since those channels can never satisfy the ratio cut. */
77 
78  int ieta=hf.id().ieta(); // get coordinates of rechit being checked
79  int depth=hf.id().depth();
80  int iphi=hf.id().iphi();
81  double fEta = 0.5*(theHFEtaBounds[abs(ieta)-29] + theHFEtaBounds[abs(ieta)-28]); // calculate eta as average of eta values at ieta boundaries
82  double energy=hf.energy();
83  double ET = energy/fabs(cosh(fEta));
84 
85  // Step 1: Check energy and ET cuts
86  double ETthresh=0, Energythresh=0; // set ET, energy thresholds
87 
88  if (depth==1) // set thresholds for long fibers
89  {
90  Energythresh = long_Energy_Thresh[abs(ieta)-29];
91  ETthresh = long_ET_Thresh[abs(ieta)-29];
92  }
93  else if (depth==2) // short fibers
94  {
95  Energythresh = short_Energy_Thresh[abs(ieta)-29];
96  ETthresh = short_ET_Thresh[abs(ieta)-29];
97  }
98 
99  if (energy<Energythresh || ET < ETthresh)
100  {
101  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
103  return;
104  }
105 
106  // Step 2: Get partner info, check if partner is excluded from rechits already
107  HcalDetId partner(HcalForward, ieta, iphi, 3-depth); // if depth=1, 3-depth=2, and vice versa
108  DetId detpartner=DetId(partner);
109  const HcalChannelStatus* partnerstatus=myqual->getValues(detpartner.rawId());
110 
111  // Don't set the bit if the partner has been dropped from the rechit collection ('dead' or 'off')
112  if (mySeverity->dropChannel(partnerstatus->getValue() ) )
113  {
114  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
116  return;
117  }
118 
119  // Step 3: Compute ratio
120  double Ratio=1;
122  if (part!=rec.end())
123  {
124  HcalDetId neighbor(part->detid().rawId());
125  const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
126  int SeverityLevel=mySeverity->getSeverityLevel(neighbor, part->flags(),
127  chanstat);
128 
129 
130  if (SeverityLevel<=HcalAcceptSeverityLevel_)
131  Ratio=(energy-part->energy())/(energy+part->energy());
132  }
133 
134  double RatioThresh=0;
135  // Allow for the ratio cut to be parameterized in terms of energy
136  if (abs(ieta)==29)
137  {
138  if (depth==1) RatioThresh=CalcThreshold(energy,long_R_29);
139  else if (depth==2) RatioThresh=CalcThreshold(energy,short_R_29);
140  }
141  else
142  {
143  if (depth==1) RatioThresh=CalcThreshold(energy,long_R);
144  else if (depth==2) RatioThresh=CalcThreshold(energy,short_R);
145  }
146  if (Ratio<=RatioThresh)
147  {
148  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
150  return;
151  }
152  // Made it this far -- ratio is > threshold, and cell should be flagged!
153  // 'HFLongShort' is overall topological flag, and 'HFPET' is the flag for this
154  // specific test
157 }//void HcalHF_PETalgorithm::HFSetFlagFromPET
158 
159 
160 
161 double HcalHF_PETalgorithm::CalcThreshold(double abs_x,const std::vector<double>& params)
162 {
163  /* CalcEnergyThreshold calculates the polynomial [0]+[1]*x + [2]*x^2 + ....,
164  where x is an integer provided by the first argument (int double abs_x),
165  and [0],[1],[2] is a vector of doubles provided by the second (std::vector<double> params).
166  The output of the polynomial calculation (threshold) is returned by the function.
167  */
168  double threshold=0;
169  for (std::vector<double>::size_type i=0;i<params.size();++i)
170  {
171  threshold+=params[i]*pow(abs_x, (int)i);
172  }
173  return threshold;
174 } //double HcalHF_PETalgorithm::CalcThreshold(double abs_x,std::vector<double> params)
175 
int i
Definition: DBlmapReader.cc:9
std::vector< double > long_ET_Thresh
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
std::vector< HFRecHit >::const_iterator const_iterator
std::vector< double > long_Energy_Thresh
std::vector< double > short_R
const Item * getValues(DetId fId, bool throwOnFail=true) const
uint16_t size_type
void HFSetFlagFromPET(HFRecHit &hf, HFRecHitCollection &rec, const HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int depth() const
get the tower depth
Definition: HcalDetId.h:40
std::vector< double > long_R
float energy() const
Definition: CaloRecHit.h:17
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool dropChannel(const uint32_t &mystatus) const
double CalcThreshold(double abs_energy, const std::vector< double > &params)
std::vector< double > long_R_29
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
Definition: DetId.h:18
static const double theHFEtaBounds[]
part
Definition: HCALResponse.h:20
std::vector< double > short_ET_Thresh
std::vector< double > short_Energy_Thresh
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
iterator find(key_type k)
SeverityLevel
#define ET
HcalDetId id() const
Definition: HFRecHit.h:23
uint32_t getValue() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< double > short_R_29