CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1RCTParameters.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 #include <fstream>
9 #include <cmath>
10 
12 #include <iomanip>
13 
15 using namespace std;
16 
18  double jetMETLSB,
19  double eMinForFGCut,
20  double eMaxForFGCut,
21  double hOeCut,
22  double eMinForHoECut,
23  double eMaxForHoECut,
24  double hMinForHoECut,
25  double eActivityCut,
26  double hActivityCut,
27  unsigned eicIsolationThreshold,
28  unsigned jscQuietThresholdBarrel,
29  unsigned jscQuietThresholdEndcap,
30  bool noiseVetoHB,
31  bool noiseVetoHEplus,
32  bool noiseVetoHEminus,
33  bool useCorrections,
34  const std::vector<double>& eGammaECalScaleFactors,
35  const std::vector<double>& eGammaHCalScaleFactors,
36  const std::vector<double>& jetMETECalScaleFactors,
37  const std::vector<double>& jetMETHCalScaleFactors,
38  const std::vector<double>& ecal_calib,
39  const std::vector<double>& hcal_calib,
40  const std::vector<double>& hcal_high_calib,
41  const std::vector<double>& cross_terms,
42  const std::vector<double>& lowHoverE_smear,
43  const std::vector<double>& highHoverE_smear
44  ) :
45  eGammaLSB_(eGammaLSB),
46  jetMETLSB_(jetMETLSB),
47  eMinForFGCut_(eMinForFGCut),
48  eMaxForFGCut_(eMaxForFGCut),
49  hOeCut_(hOeCut),
50  eMinForHoECut_(eMinForHoECut),
51  eMaxForHoECut_(eMaxForHoECut),
52  hMinForHoECut_(hMinForHoECut),
53  eActivityCut_(eActivityCut),
54  hActivityCut_(hActivityCut),
55  eicIsolationThreshold_(eicIsolationThreshold),
56  jscQuietThresholdBarrel_(jscQuietThresholdBarrel),
57  jscQuietThresholdEndcap_(jscQuietThresholdEndcap),
58  noiseVetoHB_(noiseVetoHB),
59  noiseVetoHEplus_(noiseVetoHEplus),
60  noiseVetoHEminus_(noiseVetoHEminus),
61  useCorrections_(useCorrections),
62  eGammaECalScaleFactors_(eGammaECalScaleFactors),
63  eGammaHCalScaleFactors_(eGammaHCalScaleFactors),
64  jetMETECalScaleFactors_(jetMETECalScaleFactors),
65  jetMETHCalScaleFactors_(jetMETHCalScaleFactors),
66  HoverE_smear_low_(lowHoverE_smear),
67  HoverE_smear_high_(highHoverE_smear)
68 {
69  ecal_calib_.resize(28);
70  hcal_calib_.resize(28);
71  hcal_high_calib_.resize(28);
72  cross_terms_.resize(28);
73 
74  for(unsigned i = 0; i < ecal_calib.size(); ++i)
75  ecal_calib_[i/3].push_back(ecal_calib[i]);
76  for(unsigned i = 0; i < hcal_calib.size(); ++i)
77  hcal_calib_[i/3].push_back(hcal_calib[i]);
78  for(unsigned i = 0; i < hcal_high_calib.size(); ++i)
79  hcal_high_calib_[i/3].push_back(hcal_high_calib[i]);
80  for(unsigned i = 0; i < cross_terms.size(); ++i)
81  cross_terms_[i/6].push_back(cross_terms[i]);
82 }
83 
84 // maps rct iphi, ieta of tower to crate
85 unsigned short L1RCTParameters::calcCrate(unsigned short rct_iphi, short ieta) const
86 {
87  unsigned short crate = rct_iphi/8;
88  if(abs(ieta) > 28) crate = rct_iphi / 2;
89  if (ieta > 0){
90  crate = crate + 9;
91  }
92  return crate;
93 }
94 
95 //map digi rct iphi, ieta to card
96 unsigned short L1RCTParameters::calcCard(unsigned short rct_iphi,
97  unsigned short absIeta) const
98 {
99  unsigned short card = 999;
100  // Note absIeta counts from 1-32 (not 0-31)
101  if (absIeta <= 24){
102  card = ((absIeta-1)/8)*2 + (rct_iphi%8)/4;
103  }
104  // 25 <= absIeta <= 28 (card 6)
105  else if ((absIeta >= 25) && (absIeta <= 28)){
106  card = 6;
107  }
108  else{}
109  return card;
110 }
111 
112 //map digi rct iphi, ieta to tower
113 unsigned short L1RCTParameters::calcTower(unsigned short rct_iphi,
114  unsigned short absIeta) const
115 {
116  unsigned short tower = 999;
117  unsigned short iphi = rct_iphi;
118  unsigned short regionPhi = (iphi % 8)/4;
119 
120  // Note absIeta counts from 1-32 (not 0-31)
121  if (absIeta <= 24){
122  // assume iphi between 0 and 71; makes towers from 0-31, mod. 7Nov07
123  tower = ((absIeta-1)%8)*4 + (iphi%4); // REMOVED +1
124  }
125  // 25 <= absIeta <= 28 (card 6)
126  else if ((absIeta >= 25) && (absIeta <= 28)){
127  if (regionPhi == 0){
128  // towers from 0-31, modified 7Nov07 Jessica Leonard
129  tower = (absIeta-25)*4 + (iphi%4); // REMOVED +1
130  }
131  else {
132  tower = 28 + iphi % 4 + (25 - absIeta) * 4; // mod. 7Nov07 JLL
133  }
134  }
135  // absIeta >= 29 (HF regions)
136  else if ((absIeta >= 29) && (absIeta <= 32)){
137  // SPECIAL DEFINITION OF REGIONPHI FOR HF SINCE HF IPHI IS 0-17
138  // Sept. 19 J. Leonard
139  regionPhi = iphi % 2;
140  // HF MAPPING, just regions now, don't need to worry about towers
141  // just calling it "tower" for convenience
142  tower = (regionPhi) * 4 + absIeta - 29;
143  }
144  return tower;
145 }
146 
147 // iCrate 0-17, iCard 0-6, NEW iTower 0-31
148 short L1RCTParameters::calcIEta(unsigned short iCrate, unsigned short iCard,
149  unsigned short iTower) const
150 {
151  unsigned short absIEta = calcIAbsEta(iCrate, iCard, iTower);
152  short iEta;
153  if(iCrate < 9) iEta = -absIEta;
154  else iEta = absIEta;
155  return iEta;
156 }
157 
158 // iCrate 0-17, iCard 0-6, NEW iTower 0-31
159 unsigned short L1RCTParameters::calcIPhi(unsigned short iCrate,
160  unsigned short iCard,
161  unsigned short iTower) const
162 {
163  short iPhi;
164  if(iCard < 6)
165  iPhi = (iCrate % 9) * 8 + (iCard % 2) * 4 + (iTower % 4); // rm -1 7Nov07
166  else if(iCard == 6){
167  // region 0
168  if(iTower < 16) // 17->16
169  iPhi = (iCrate % 9) * 8 + (iTower % 4); // rm -1
170  // region 1
171  else
172  iPhi = (iCrate % 9) * 8 + ((iTower - 16) % 4) + 4; // 17 -> 16
173  }
174  // HF regions
175  else
176  iPhi = (iCrate % 9) * 2 + iTower / 4;
177  return iPhi;
178 }
179 
180 // iCrate 0-17, iCard 0-6, NEW iTower 0-31
181 unsigned short L1RCTParameters::calcIAbsEta(unsigned short iCrate, unsigned short iCard,
182  unsigned short iTower) const
183 {
184  unsigned short absIEta;
185  if(iCard < 6)
186  absIEta = (iCard / 2) * 8 + (iTower / 4) + 1; // rm -1 JLL 7Nov07
187  else if(iCard == 6) {
188  // card 6, region 0
189  if(iTower < 16) // 17->16
190  absIEta = 25 + iTower / 4; // rm -1
191  // card 6, region 1
192  else
193  absIEta = 28 - ((iTower - 16) / 4); // 17->16
194  }
195  // HF regions
196  else
197  absIEta = 29 + iTower % 4;
198  return absIEta;
199 }
200 
201 float L1RCTParameters::JetMETTPGSum(const float& ecal, const float& hcal, const unsigned& iAbsEta) const
202 {
203  float ecal_c = ecal*jetMETECalScaleFactors_.at(iAbsEta-1);
204  float hcal_c = hcal*jetMETHCalScaleFactors_.at(iAbsEta-1);
205  float result = ecal_c + hcal_c;
206 
207  if(useCorrections_)
208  {
209  if(jetMETHCalScaleFactors_.at(iAbsEta-1) != 0)
210  hcal_c = hcal;
211 
212  if(jetMETECalScaleFactors_.at(iAbsEta-1) != 0)
213  ecal_c = ecal*eGammaECalScaleFactors_.at(iAbsEta-1); // Use eGamma Corrections
214 
215  result = correctedTPGSum(ecal_c,hcal_c,iAbsEta-1);
216  }
217 
218  return result;
219 }
220 
221 float L1RCTParameters::EGammaTPGSum(const float& ecal, const float& hcal, const unsigned& iAbsEta) const
222 {
223  float ecal_c = ecal*eGammaECalScaleFactors_.at(iAbsEta-1);
224  float hcal_c = hcal*eGammaHCalScaleFactors_.at(iAbsEta-1);
225  float result = ecal_c + hcal_c;
226 
227  if(useCorrections_)
228  {
229  if(eGammaHCalScaleFactors_.at(iAbsEta-1) != 0)
230  hcal_c = hcal;
231 
232  result = correctedTPGSum(ecal_c,hcal_c,iAbsEta-1);
233  }
234 
235  return result;
236 }
237 
238 // index = iAbsEta - 1... make sure you call the function like so: "correctedTPGSum(ecal,hcal, iAbsEta - 1)"
239 float L1RCTParameters::correctedTPGSum(const float& ecal, const float& hcal, const unsigned& index) const
240 {
241  if(index >= 28 && ecal > 120 && hcal > 120) return (ecal + hcal); // return plain sum if outside of calibration range or index is too high
242 
243  // let's make sure we're asking for items that are there.
244  if(ecal_calib_.at(index).size() != 3 || hcal_calib_.at(index).size() != 3 ||
245  hcal_high_calib_.at(index).size() != 3 || cross_terms_.at(index).size() != 6 ||
246  HoverE_smear_high_.size() <= index || HoverE_smear_low_.size() <= index)
247  return (ecal+hcal);
248 
249  double e = ecal, h = hcal;
250  double ec = 0.0, hc = 0.0, c = 0.0;
251 
252  ec = (ecal_calib_.at(index).at(0)*std::pow(e,3.) +
253  ecal_calib_.at(index).at(1)*std::pow(e,2.) +
254  ecal_calib_.at(index).at(2)*e);
255 
256  if(e + h < 23)
257  {
258  hc = (hcal_calib_.at(index).at(0)*std::pow(h,3.) +
259  hcal_calib_.at(index).at(1)*std::pow(h,2.) +
260  hcal_calib_.at(index).at(2)*h);
261 
262  c = (cross_terms_.at(index).at(0)*std::pow(e, 2.)*h +
263  cross_terms_.at(index).at(1)*std::pow(h, 2.)*e +
264  cross_terms_.at(index).at(2)*e*h +
265  cross_terms_.at(index).at(3)*std::pow(e, 3.)*h +
266  cross_terms_.at(index).at(4)*std::pow(h, 3.)*e +
267  cross_terms_.at(index).at(5)*std::pow(h, 2.)*std::pow(e, 2.));
268  }
269  else
270  {
271  hc = (hcal_high_calib_.at(index).at(0)*std::pow(h,3.) +
272  hcal_high_calib_.at(index).at(1)*std::pow(h,2.) +
273  hcal_high_calib_.at(index).at(2)*h);
274  }
275 
276  if(h/(e+h) >= 0.05)
277  {
278  ec *= HoverE_smear_high_.at(index);
279  hc *= HoverE_smear_high_.at(index);
280  c *= HoverE_smear_high_.at(index);
281  }
282  else
283  {
284  ec *= HoverE_smear_low_.at(index);
285  }
286  return ec + hc + c;
287 }
288 
289 void
290 L1RCTParameters::print(std::ostream& s) const {
291 
292  s << "\nPrinting record L1RCTParametersRcd" <<endl;
293  s << "\n\"Parameter description\" \n \"Parameter name\" \"Value\" "
294  << endl;
295  s << "\ne/gamma least significant bit energy transmitted from receiver cards to EIC cards. \n "
296  << "eGammaLSB = " << eGammaLSB_ << endl ;
297  s << "\nLSB of region Et scale from RCT to GCT (GeV) \n "
298  << "jetMETLSB = " << jetMETLSB_ << endl ;
299  s << "\nminimum ECAL Et for which fine-grain veto is applied (GeV) \n "
300  << " eMinForFGCut = " << eMinForFGCut_ << endl ;
301  s << "\nmaximum ECAL Et for which fine-grain veto is applied (GeV) \n "
302  << "eMaxForFGCut = " << eMaxForFGCut_ << endl ;
303  s << "\nmaximum value of (HCAL Et / ECAL Et) \n "
304  << "hOeCut = " << hOeCut_ << endl ;
305  s << "\nminimum ECAL Et for which H/E veto is applied (GeV) \n "
306  << "eMinForHoECut = " << eMinForHoECut_ << endl ;
307  s << "\nmaximum ECAL Et for which H/E veto is applied (GeV) \n "
308  << "eMaxForHoECut = " << eMaxForHoECut_ << endl ;
309  s << "\nminimum HCAL Et for which H/E veto is applied (GeV) \n "
310  << "hMinForHoECut = " << hMinForHoECut_ << endl ;
311  s << "\nECAL Et threshold above which tau activity bit is set (GeV) \n "
312  << "eActivityCut = " << eActivityCut_ << endl ;
313  s << "\nHCAL Et threshold above which tau activity bit is set (GeV) \n "
314  << "hActivityCut = " << hActivityCut_ << endl ;
315  s << "\nNeighboring trigger tower energy minimum threshold that marks candidate as non-isolated. (LSB bits) \n "
316  << "eicIsolationThreshold = " << eicIsolationThreshold_ << endl ;
317  s << "\nIf jetMet energy in RCT Barrel Region is below this value, a quiet bit is set. (LSB bits)\n "
318  << "jscQuietThreshBarrel = " << jscQuietThresholdBarrel_ << endl ;
319  s << "\nIf jetMet energy in RCT Endcap Region is below this value, a quiet bit is set. (LSB bits) \n "
320  << "jscQuietThreshEndcap = " << jscQuietThresholdEndcap_ << endl ;
321  s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT Barrel \n "
322  << "noiseVetoHB = " << noiseVetoHB_ << endl ;
323  s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT Encap+ \n "
324  << "noiseVetoHEplus = " << noiseVetoHEplus_ << endl ;
325  s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT Endcap- \n "
326  << "noiseVetoHEminus = " << noiseVetoHEminus_ << endl ;
327 
328  s << "\n\neta-dependent multiplicative factors for ECAL Et before summation \n "
329  << "eGammaECal Scale Factors " << endl;
330  s << "ieta ScaleFactor" <<endl;
331  for(int i = 0 ; i<28; i++)
332  s << setw(4) << i+1 << " " << eGammaECalScaleFactors_.at(i) <<endl;
333 
334  s << "\n\neta-dependent multiplicative factors for HCAL Et before summation \n "
335  <<"eGammaHCal Scale Factors "<<endl;
336  s << "ieta ScaleFactor" <<endl;
337  for(int i = 0 ; i<28; i++)
338  s << setw(4) << i+1 << " " << eGammaHCalScaleFactors_.at(i) <<endl;
339 
340  s << "\n\neta-dependent multiplicative factors for ECAL Et before summation \n "
341  <<"jetMETECal Scale Factors "<<endl;
342  s << "ieta ScaleFactor" <<endl;
343  for(int i = 0 ; i<28; i++)
344  s<< setw(4) << i+1 << " " << jetMETECalScaleFactors_.at(i) <<endl;
345 
346  s << "\n\neta-dependent multiplicative factors for HCAL Et before summation \n"
347  <<"jetMETHCal Scale Factors "<<endl;
348  s << "ieta ScaleFactor" <<endl;
349  for(int i = 0 ; i<28; i++)
350  s << setw(4) <<i+1 << " " << jetMETHCalScaleFactors_.at(i) <<endl;
351 
352 
353  if(useCorrections_) {
354  s<< "\n\nUSING calibration variables " <<endl;
355 
356 
357  s << "\n\nH over E smear low Correction Factors "<<endl;
358  s << "ieta Correction Factor" <<endl;
359  for(int i = 0 ; i<28; i++)
360  s << setw(4) <<i+1 << " " << HoverE_smear_low_.at(i) <<endl;
361 
362 
363  s << "\n\nH over E smear high Correction Factors "<<endl;
364  s <<"ieta Correction Factor" <<endl;
365  for(int i = 0 ; i<28; i++)
366  s << setw(4) <<i+1 << " " << HoverE_smear_high_.at(i) <<endl;
367 
368  s << "\n\necal calibrations "<<endl;
369  s << "ieta CorrFactor1 CorrFactor2 CorrFactor3" <<endl;
370  int end = ecal_calib_[0].size();
371  for(int i = 0 ; i<28; i++) {
372  s << setw(4) << i;
373  for(int j = 0; j< end ; j++)
374  s << setw(11) << setprecision(8) << ecal_calib_[i][j] ;
375 
376  s << endl;
377 
378  }
379 
380  s <<"\n\nhcal calibrations "<<endl;
381  s <<"ieta CorrFactor1 CorrFactor2 CorrFactor3" <<endl;
382  end = hcal_calib_[0].size();
383  for(int i = 0 ; i<28; i++) {
384  s << setw(4) << i;
385  for(int j = 0; j< end ; j++)
386  s << setw(11) << setprecision(8) << hcal_calib_[i][j] ;
387 
388  s << endl;
389 
390  }
391  s <<"\n\nhcal_high calibrations "<<endl;
392  s <<"ieta CorrFactor1 CorrFactor2 CorrFactor3" <<endl;
393  end = hcal_high_calib_[0].size();
394  for(int i = 0 ; i<28; i++) {
395  s << setw(4) << i;
396  for(int j = 0; j< end ; j++)
397  s << setw(11) << setprecision(8) << hcal_high_calib_[i][j] ;
398 
399  s << endl;
400 
401  }
402  end = cross_terms_[0].size();
403  s <<"\n\ncross terms calibrations "<<endl;
404  s <<"ieta CorrFactor1 CorrFactor2 CorrFactor3 CorrFactor4 CorrFactor5 CorrFactor6" <<endl;
405  for(int i = 0 ; i<28; i++) {
406  s << setw(4) << i;
407  for(int j = 0; j< end ; j++)
408  s << setw(11) << setprecision(8) << cross_terms_[i][j] ;
409 
410  s << endl;
411 
412  }
413 
414  } else
415  s<< "\n\nNOT USING calibration variables " <<endl;
416 
417  s << "\n\n" <<endl;
418 
419 }
int i
Definition: DBlmapReader.cc:9
void print(std::ostream &s) const
std::vector< double > jetMETECalScaleFactors_
short calcIEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
unsigned jscQuietThresholdBarrel_
std::vector< double > eGammaECalScaleFactors_
#define abs(x)
Definition: mlp_lapack.h:159
std::vector< std::vector< double > > cross_terms_
std::vector< std::vector< double > > hcal_high_calib_
std::vector< double > HoverE_smear_low_
float correctedTPGSum(const float &ecal, const float &hcal, const unsigned &index) const
unsigned short calcTower(unsigned short rct_iphi, unsigned short absIeta) const
float EGammaTPGSum(const float &ecal, const float &hcal, const unsigned &iAbsEta) const
unsigned jscQuietThresholdEndcap_
std::vector< double > jetMETHCalScaleFactors_
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
unsigned short calcIAbsEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
std::vector< std::vector< double > > hcal_calib_
#define end
Definition: vmac.h:38
unsigned short calcIPhi(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const
std::vector< double > HoverE_smear_high_
unsigned short calcCard(unsigned short rct_iphi, unsigned short absIeta) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< double > eGammaHCalScaleFactors_
std::vector< std::vector< double > > ecal_calib_
unsigned eicIsolationThreshold_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
unsigned short calcCrate(unsigned short rct_iphi, short ieta) const
float JetMETTPGSum(const float &ecal, const float &hcal, const unsigned &iAbsEta) const