CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastL1Region.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FastL1CaloSim
4 // Class: FastL1Region
5 //
13 //
14 // Original Author: Chi Nhan Nguyen
15 // Created: Mon Feb 19 13:25:24 CST 2007
16 // $Id: FastL1Region.cc,v 1.23 2009/03/23 11:41:28 chinhan Exp $
17 //
18 
19 
21 
23 {
25 
26  jetE = 0.;
27  jetEt = 0.;
28 
29  id = 999;
30  ieta = 999;
31  iphi = 999;
32 
33  tauBit = false;
34  quietBit = false;
35  mipBit = false;
36  for(int i=0;i<16;i++) {
37  hcfgBit[i] = false;
38  fgBit[i] = false;
39  hOeBit[i] = false;
40  for (int j=0;j<25;j++) {
41  EMCrystalEnergy[i][j] = 0. ; // 16x25 Crystals
42  }
43  }
44 
45  // default values
47  Config.EMActiveLevel = 3.;
49  Config.noTauVetoLevel = 10000.;
50  Config.hOeThreshold = 0.05;
51  Config.FGEBThreshold = 0.8;
52  Config.noFGThreshold = 50.;
53  Config.FGEEThreshold = 0.8;
55  Config.EMNoiseLevel = 2.;
56  Config.HadNoiseLevel = 2.;
61 
62  Config.TowerEMLSB = 1.;
63  Config.TowerHadLSB = 1.;
64  Config.EMLSB = 1.;
65  Config.JetLSB = 1.;
66 
68  Config.TowerEEThreshold = 0.45;
71 
72  Config.TowerEBScale = 1.0;
73  Config.TowerEEScale = 1.0;
74  Config.TowerHBScale = 1.0;
75  Config.TowerHEScale = 1.0;
76 
77 
78  //Config.EmInputs;
79  //Config.xTowerInput;
80 
81 }
82 
83 
85 {
86 }
87 
88 
89 void
91 {
92  Config = iconfig;
93 }
94 
95 void
97 {
98  sumE = CalcSumE();
99  sumEt = CalcSumEt();
100 }
101 
102 void
104 {
105  SetTauBit(e);
106  SetQuietBit();
107  SetMIPBit();
108 }
109 
110 void
112 {
113  SetFGBit();
114  SetHOEBit();
115  SetHCFGBit();
116 }
117 
118 //
119 void
121  const CaloTopology* calotopo,
122  const CaloGeometry* cGeom,
123  const EcalRecHitCollection* ec0,
124  const EcalRecHitCollection* ec1,
125  FastL1RegionMap* m_RMap)
126 {
127  //std::vector< std::pair <std::string,std::string> > la;
128  //la.resize(2);
130  //la[0].first = "ecalRecHit";
131  //la[0].second = "EcalRecHitsEB";
133  //la[1].first = "ecalRecHit";
134  //la[1].second = "EcalRecHitsEE";
135 
136 
137  double ethres = Config.CrystalEBThreshold;
138 
139  // EB
140  //e.getByLabel(la[0].first,la[0].second,ec);
141  //e.getByLabel(Config.EmInputs.at(0),ec);
142 
143  ethres = Config.CrystalEBThreshold;
144  for(EcalRecHitCollection::const_iterator ecItr = ec0->begin();
145  ecItr != ec0->end(); ++ecItr) {
146  //CaloRecHit recHit = (CaloRecHit)(*ecItr);
147  if (ecItr->energy()<ethres) continue;
148 
149  EBDetId detId = ecItr->detid();
150 
151  //int hiphi = detId.tower_iphi();
152  int hieta = detId.tower_ieta();
153  int eieta = detId.ieta();
154  int eiphi = detId.iphi();
155  int crIeta = 999;
156  if (hieta>0)
157  crIeta = (eieta-1)%5;
158  else
159  crIeta = 4 + (eieta+1)%5;
160  int crIphi = (eiphi - 1)%5;
161 
162  //const GlobalPoint gP = cGeom->getPosition(detId);
163 
164  //CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
165  // loop over towers
166  for(int i=0;i<16;i++) {
167  //int hiphi = m_RMap->convertFromECal_to_HCal_iphi(detId.tower_iphi());
168  //int hiphi = m_RMap->convertFromHCal_to_ECal_iphi(detId.tower_iphi());
169  int hiphi = detId.tower_iphi();
170  if ( !Towers[i].id().iphi()==hiphi || !Towers[i].id().ieta()==hieta ) continue;
171  EMCrystalEnergy[i][crIeta + 5*crIphi] = ecItr->energy();
172  }
173  }
174 
175  // After having filled crsystal info set all veto bits
176  SetTowerBits();
177 
178  // EE FG bits are filled here!!!
179  //e.getByLabel(la[1].first,la[1].second,ec);
180 
181  if (GetiEta()==4 || GetiEta()==5 || GetiEta()==6 ||
182  GetiEta()==15 || GetiEta()==16 || GetiEta()==17 ) {
183 
184  //e.getByLabel(Config.EmInputs.at(1),ec);
185  ethres = Config.CrystalEEThreshold;
186  double towerEnergy[16];
187  // loop over towers
188  for(int i=0;i<16;i++) {
189  fgBit[i] = false; // re-iniate
190 
191  //if (Towers[i].hadEt()>Config.HadNoiseLevel && Towers[i].emEt()>Config.EMNoiseLevel ) {
192  if (Towers[i].emEt()>=Config.EMNoiseLevel ) {
193  //if (Towers[i].emEnergy()>Config.EMNoiseLevel ) {
194  //towerEnergy[i] = Towers[i].hadEt() + Towers[i].emEt();
195  towerEnergy[i] = Towers[i].hadEnergy() + Towers[i].emEnergy();
196  } else {
197  fgBit[i] = false;
198  continue;
199  }
200 
201  // EB/EE transition area: unset fg bits
202  // if (std::abs(Towers[i].id().ieta())==16 || std::abs(Towers[i].id().ieta())==17) {
203  // fgBit[i] = false;
204  // continue;
205  // }
206  if (Towers[i].emEt()>Config.noFGThreshold) {
207  fgBit[i] = false;
208  continue;
209  }
210 
211  //CaloRecHit maxRecHit;
212  //CaloRecHit maxRecHit2;
213  double maxRecHit=-1.;
214  double maxRecHit2=-1.;
215  DetId maxDetId;
216 
217  double max2En = 0.;
218 
219  for(EcalRecHitCollection::const_iterator ecItr = ec1->begin();
220  ecItr != ec1->end(); ++ecItr) {
221  //CaloRecHit recHit = (CaloRecHit)(*ecItr);
222  if (ecItr->energy()<ethres) continue;
223 
224  EEDetId detId = ecItr->detid();
225 
226  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
227  //int hiphi = m_RMap->convertFromECal_to_HCal_iphi(towerDetId.iphi());
228  int hiphi = towerDetId.iphi();
229  if (Towers[i].id().iphi()==hiphi &&
230  Towers[i].id().ieta()==towerDetId.ieta() ) {
231  if (maxRecHit<ecItr->energy()) {
232  maxRecHit = ecItr->energy();
233  maxDetId = detId;
234  }
235  }
236  }
237 
238  std::vector<DetId> westV = calotopo->west(maxDetId);
239  std::vector<DetId> eastV = calotopo->east(maxDetId);
240  std::vector<DetId> southV = calotopo->south(maxDetId);
241  std::vector<DetId> northV = calotopo->north(maxDetId);
242  for(EcalRecHitCollection::const_iterator ecItr = ec1->begin();
243  ecItr != ec1->end(); ++ecItr) {
244  //CaloRecHit recHit = (CaloRecHit)(*ecItr);
245  if (ecItr->energy()<ethres) continue;
246 
247  EEDetId detId = ecItr->detid();
248 
249  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
250  //int hiphi = m_RMap->convertFromECal_to_HCal_iphi(towerDetId.iphi());
251  int hiphi = towerDetId.iphi();
252  if (Towers[i].id().iphi()==hiphi &&
253  Towers[i].id().ieta()==towerDetId.ieta() ) {
254  if (
255  (!westV.empty() && detId==westV[0]) ||
256  (!eastV.empty() && detId==eastV[0]) ||
257  (!northV.empty() && detId==northV[0]) ||
258  (!southV.empty() && detId==southV[0])
259  ) {
260  if (maxRecHit2<ecItr->energy()) {
261  maxRecHit2 = ecItr->energy();
262  }
263  max2En += ecItr->energy();
264  }
265  }
266  }
267 
268  double eeThres = Config.FGEEThreshold;
269  //double totE = maxRecHit.energy() + max2En;
270  double totE = maxRecHit + maxRecHit2;
271  if (towerEnergy[i]>(Config.TowerEEThreshold)) {
272  //double totE = maxRecHit.energy() + maxRecHit2.energy();
273  //if (totE/towerEnergy[i]<Config.FGEBThreshold) fgBit[i] = true;
274  if (totE/towerEnergy[i]<eeThres) fgBit[i] = true;
275  }
276 
277  }
278  }
279 
280 
281 }
282 
283 //
284 void
286 {
287  Towers[tid] = CaloTower(t);
288  //std::cout<<"--- "<<Towers[tid].emEt()<<" "<<Towers[tid].hadEt()<<std::endl;
289 }
290 
291 void
293 {
294  double EThres = 0.;
295  double HThres = 0.;
296  double EBthres = Config.TowerEBThreshold;
297  double HBthres = Config.TowerHBThreshold;
298  double EEthres = Config.TowerEEThreshold;
299  double HEthres = Config.TowerHEThreshold;
300 
301  if(std::abs(t.eta())<2.322) {
302  EThres = EBthres;
303  } else {
304  EThres = EEthres;
305  }
306  if(std::abs(t.eta())<2.322) {
307  HThres = HBthres;
308  } else {
309  HThres = HEthres;
310  }
311 
312  double upperThres = 1024.;
313  double emet = RCTEnergyTrunc(t.emEt(),Config.TowerEMLSB,upperThres);
314  double hadet = RCTEnergyTrunc(t.hadEt(),Config.TowerHadLSB,upperThres);
315  //double eme = RCTEnergyTrunc(t.emEnergy(),Config.TowerEMLSB,upperThres);
316  //double hade = RCTEnergyTrunc(t.hadEnergy(),Config.TowerHadLSB,upperThres);
317 
318  if ( emet<EThres) emet = 0.;
319  if ( hadet<HThres) hadet = 0.;
320  //if ( eme<EThres) emet = 0.;
321  //if ( hade<HThres) hadet = 0.;
322 
323  GlobalPoint gP = cGeom->getPosition(t.id());
324  math::XYZTLorentzVector lvec(t.px(),t.py(),t.px(),t.energy());
325  //Towers[tid] = CaloTower(t);
326  //Towers[tid] = CaloTower(t.id(),t.momentum(),emet,hadet,t.outerEt(),0,0);
327  Towers[tid] = CaloTower(t.id(),emet,hadet,t.outerEt(),0,0,lvec,gP,gP);
328 }
329 
330 
331 //
332 void
333 FastL1Region::FillTower_Scaled(const CaloTower& t, int& tid, bool doRCTTrunc,edm::ESHandle<CaloGeometry> &cGeom)
334 {
335 
336  double EThres = 0.;
337  double HThres = 0.;
338  double EBthres = Config.TowerEBThreshold;
339  double HBthres = Config.TowerHBThreshold;
340  double EEthres = Config.TowerEEThreshold;
341  double HEthres = Config.TowerHEThreshold;
342 
343  if(std::abs(t.eta())<2.322) {
344  EThres = EBthres;
345  } else {
346  EThres = EEthres;
347  }
348  if(std::abs(t.eta())<2.322) {
349  HThres = HBthres;
350  } else {
351  HThres = HEthres;
352  }
353 
354  double emScale = 1.0;
355  double hadScale = 1.0;
356  //double outerScale = 1.0;
357 
358  if (std::abs(t.eta()>1.3050) && std::abs(t.eta())<3.0) {
359  hadScale = Config.TowerHEScale;
360  emScale = Config.TowerEEScale;
361  }
362  if (std::abs(t.eta()<1.3050)) {
363  hadScale = Config.TowerHBScale;
364  emScale = Config.TowerEBScale;
365  }
366 
367  double emet = emScale * t.emEt();
368  double hadet = hadScale * t.hadEt();
369  double eme = emScale * t.emEnergy();
370  double hade = hadScale * t.hadEnergy();
371 
372  if (doRCTTrunc) {
373  double upperThres = 1024.;
374  emet = RCTEnergyTrunc(emet,Config.TowerEMLSB,upperThres);
375  hadet = RCTEnergyTrunc(hadet,Config.TowerHadLSB,upperThres);
376  eme = RCTEnergyTrunc(eme,Config.TowerEMLSB,upperThres);
377  hade = RCTEnergyTrunc(hade,Config.TowerHadLSB,upperThres);
378  }
379  if ( emet<EThres) emet = 0.;
380  if ( hadet<HThres) hadet = 0.;
381  //if ( eme<EThres) emet = 0.;
382  //if ( hade<HThres) hadet = 0.;
383 
384  /*
385  if (t.emEt()>0. || t.hadEt()>0.) {
386  std::cout<<"+++ "
387  <<t.emEt()<<" "<<t.hadEt()<<" "
388  <<t.eta()<<" "<<t.phi()<<" "
389  <<std::endl;
390  }
391  */
392 
393  //Towers[tid] = CaloTower(t);
394  //Towers[tid] = CaloTower(t.id(),t.momentum(),emet,hadet,0.,0,0);
395  //edm::ESHandle<CaloGeometry> cGeom;
396  //c.get<CaloGeometryRecord>().get(cGeom);
397  GlobalPoint gP = cGeom->getPosition(t.id());
398  math::XYZTLorentzVector lvec(t.px(),t.py(),t.px(),t.energy());
399  //Towers[tid] = CaloTower(t);
400  //Towers[tid] = CaloTower(t.id(),t.momentum(),emet,hadet,t.outerEt(),0,0);
401  Towers[tid] = CaloTower(t.id(),emet,hadet,t.outerEt(),0,0,lvec,gP,gP);
402 
403  //std::cout<<tid<<" "<<Towers[tid].emEt()<< " " <<Towers[tid].hadEt()<< std::endl;
404 
405 }
406 
407 void
409 {
410  double fracThres = Config.hOeThreshold;
411 
412  for (int i=0; i<16; i++) {
413  //if (Towers[i].hadEt()>Config.HadNoiseLevel && Towers[i].emEt()>Config.EMNoiseLevel ) {
414  if (Towers[i].hadEnergy()>Config.HadNoiseLevel && Towers[i].emEnergy()>Config.EMNoiseLevel ) {
415  if((Towers[i].hadEt()/Towers[i].emEt()) > fracThres) {
416  hOeBit[i] = true;
417  }
418  }
419  }
420 }
421 
422 void
424 {
426  quietBit = true;
427 }
428 
429 void
431 {
432  // temporary: check definition
433  // if (Tower->hadEt>100GeV) hcfgBit = true; ????
434  //for (int i=0; i<16; i++) {
435  //}
436 }
437 
438 void
440 {
441  if (quietBit)
442  for (int i=0; i<16; i++) {
443  if (hcfgBit) {
444  mipBit = true;
445  return;
446  }
447  }
448 }
449 
450 void
451 FastL1Region::SetFGBit(int twrid,bool FGBIT)
452 {
453  fgBit[twrid] = FGBIT;
454 }
455 void
456 FastL1Region::SetHCFGBit(int twrid,bool FGBIT)
457 {
458  ;
459 }
460 void
461 FastL1Region::SetHOEBit(int twrid,bool FGBIT)
462 {
463  hOeBit[twrid] = FGBIT;
464 }
465 
466 void
468 {
469  double ratioCut = Config.FGEBThreshold;
470 
471  double stripEnergy[16][5];
472  double duostripEnergy[16][4];
473  double towerEnergy[16];
474 
475  if (GetiEta()>=7 && GetiEta()<=14) {
476  //Barrel
477  for (int i=0; i<16; i++) {
478  //if (Towers[i].hadEt()>Config.HadNoiseLevel && Towers[i].emEt()>Config.EMNoiseLevel ) {
479  if (Towers[i].emEt()>Config.EMNoiseLevel ) {
480  //towerEnergy[i] = Towers[i].hadEt() + Towers[i].emEt();
481  towerEnergy[i] = Towers[i].hadEnergy() + Towers[i].emEnergy();
482  } else {
483  fgBit[i] = false;
484  continue;
485  }
486 
487  // EB/EE transition area: unset fg bits
488  //if (std::abs(Towers[i].id().ieta())==16 || std::abs(Towers[i].id().ieta())==17) {
489  //fgBit[i] = false;
490  //continue;
491  //}
492  if (Towers[i].emEt()>Config.noFGThreshold) {
493  fgBit[i] = false;
494  continue;
495  }
496 
497  bool fgflag = false;
498  for (int j=0; j<5; j++) {
499  stripEnergy[i][j] = EMCrystalEnergy[i][j] + EMCrystalEnergy[i][j+5] + EMCrystalEnergy[i][j+10] +
500  EMCrystalEnergy[i][j+15] + EMCrystalEnergy[i][j+20];
501  }
502  for (int j=0; j<4; j++) {
503  duostripEnergy[i][j] = stripEnergy[i][j] + stripEnergy[i][j+1];
504  if (towerEnergy[i]>(Config.TowerEBThreshold)) {
505  //std::cout<<duostripEnergy[i][j]<<" |"<<towerEnergy[i]<<" |"<<duostripEnergy[i][j]/towerEnergy[i]<<std::endl;
506  if ( (duostripEnergy[i][j] / towerEnergy[i]) > ratioCut) {
507  fgflag = true;
508  }
509  //std::cout<<duostripEnergy[i][j]<<" | "<<towerEnergy[i]<<": "<<duostripEnergy[i][j]/towerEnergy[i]<<std::endl;
510  }
511  }
512 
513  if (fgflag) {
514  fgBit[i] = false;
515  } else {
516  fgBit[i] = true;
517  }
518  //std::cout<<GetiEta()<<" | "<<i<<": "<<fgBit[i]<<std::endl;
519  //std::cout<<"********************************************"<<std::endl;
520  }
521  } else {
522  // Endcap FG bit is already filled in fillEMCrystals()!!!
523  }
524 
525 }
526 
527 
528 void
530 {
531  float emThres = Config.EMActiveLevel;
532  float hadThres = Config.HadActiveLevel;
533 
534  if (doBitInfo) BitInfo.setIsolationVeto(false);
535  if (doBitInfo) BitInfo.setTauVeto(false);
536  if (doBitInfo) BitInfo.setEmTauVeto(false);
537  if (doBitInfo) BitInfo.setHadTauVeto(false);
538 
539  // init pattern containers
540  unsigned emEtaPat = 0;
541  unsigned emPhiPat = 0;
542  unsigned hadEtaPat = 0;
543  unsigned hadPhiPat = 0;
544  unsigned one = 1;
545 
546 
547  // fill hits as bit pattern
548  for (int i=0; i<16; i++) {
549  if(Towers[i].emEt() > emThres) {
550  emEtaPat |= (one << (unsigned)(i%4));
551  emPhiPat |= (one << (unsigned)(i/4));
552  }
553 
554  if( Towers[i].hadEt() > hadThres) {
555  hadEtaPat |= (one << (unsigned)(i%4));
556  hadPhiPat |= (one << (unsigned)(i/4));
557  }
558 
559  }
560 
561  // Patterns with two or less contiguous bits set are passed
562  // rest are vetoed; 5=0101;7=0111;9=1001;10=1010;11=1011;13=1101;14=1110;15=1111
563  // --- Alternate patterns
564  // --- 9=1001;15=1111
565  static std::vector<unsigned> vetoPatterns;
566  if(vetoPatterns.size() == 0) {
567  vetoPatterns.push_back(5);
568  vetoPatterns.push_back(7);
569  vetoPatterns.push_back(9);
570  vetoPatterns.push_back(10);
571  vetoPatterns.push_back(11);
572  vetoPatterns.push_back(13);
573  vetoPatterns.push_back(14);
574  vetoPatterns.push_back(15);
575  }
576 
577 
578  for(std::vector<unsigned>::iterator i = vetoPatterns.begin();
579  i != vetoPatterns.end(); i++) {
580  unsigned etaPattern = emEtaPat | hadEtaPat;
581  unsigned phiPattern = emPhiPat | hadPhiPat;
582 
583  // em pattern
584  if(emEtaPat == *i || emPhiPat == *i) {
585  if (doBitInfo) BitInfo.setEmTauVeto(true);
586  }
587  // had pattern
588  if(hadEtaPat == *i || hadPhiPat == *i) {
589  if (doBitInfo) BitInfo.setHadTauVeto(true);
590  }
591 
592  if(etaPattern == *i || phiPattern == *i) // combined pattern
593  //if(emEtaPat == *i || emPhiPat == *i || hadEtaPat == *i || hadPhiPat == *i)
594  {
595  tauBit = true;
596  if (doBitInfo) BitInfo.setTauVeto(true);
597  return;
598  }
599  }
600 
601  tauBit = false;
602 
603 }
604 
605 
606 int
608 {
609  int hid = -1;
610  double tmpet=0.;
611  for (int i=0; i<16; i++) {
612  if ( (Towers[i].emEt()+Towers[i].hadEt()) > tmpet) {
613  tmpet = (Towers[i].emEt()+Towers[i].hadEt());
614  hid = i;
615  }
616  }
617 
619 
620  return hid;
621 }
622 
623 int
625 {
626  int hid = -1;
627  double tmpet=0.;
628  for (int i=0; i<16; i++) {
629  if ( (Towers[i].emEt()) > tmpet) {
630  tmpet = (Towers[i].emEt());
631  hid = i;
632  }
633  }
634 
636  return hid;
637 }
638 
639 int
641 {
642  int hid = -1;
643  double tmpet=0.;
644  for (int i=0; i<16; i++) {
645  if ( (Towers[i].hadEt()) > tmpet) {
646  tmpet = (Towers[i].hadEt());
647  hid = i;
648  }
649  }
650 
652  return hid;
653 }
654 
655 double
657 {
658  double sumet=0;
659  for (int i=0; i<16; i++) {
660  sumet += Towers[i].emEt();
661  sumet += Towers[i].hadEt();
662  }
663 
664  return sumet;
665 }
666 
667 double
669 {
670  double sumet=0;
671  for (int i=0; i<16; i++) {
672  sumet += Towers[i].emEt();
673  }
674 
675  return sumet;
676 }
677 
678 double
680 {
681  double sumet=0;
682  for (int i=0; i<16; i++) {
683  sumet += Towers[i].hadEt();
684  }
685 
686  return sumet;
687 }
688 
689 double
691 {
692  double sume=0;
693  for (int i=0; i<16; i++) {
694  sume += Towers[i].emEnergy();
695  sume += Towers[i].hadEnergy();
696 
697  }
698  return sume;
699 }
700 
701 double
703 {
704  double sume=0;
705  for (int i=0; i<16; i++) {
706  sume += Towers[i].emEnergy();
707  }
708  return sume;
709 }
710 
711 double
713 {
714  double sume=0;
715  for (int i=0; i<16; i++) {
716  sume += Towers[i].hadEnergy();
717  }
718  return sume;
719 }
720 
721 
722 std::pair<double, double>
724 {
726  //c.get<IdealGeometryRecord>().get(cGeom);
727  c.get<CaloGeometryRecord>().get(cGeom);
728 
729  const GlobalPoint gP1 = cGeom->getPosition(Towers[5].id());
730  //const GlobalPoint gP2 = cGeom->getPosition(Towers[6].id());
731  //const GlobalPoint gP3 = cGeom->getPosition(Towers[10].id());
732 
733  double eta = gP1.eta();
734  double phi = gP1.phi();
735 
736  return std::pair<double, double>(eta, phi);
737 }
738 
739 
740 // test filling of FastL1Region
741 void
743 {
744 
745  // test tower filling:
746  /*
747  CaloTowerCollection::const_iterator t;
748  int count = 0;
749  for (t=Towers.begin(); t!=Towers.end(); t++) {
750  std::cout << count << ") " << t->energy() << " | " << t->eta() << " | " << t->phi() << std::endl;
751  count++;
752  }
753  std::cout << std::endl;
754  */
755 
756  // test region neighbours:
757  std::cout << this->GetNWId() << " " << this->GetNorthId() << " " << this->GetNEId() << std::endl;
758  std::cout << this->GetWestId() << " " << this->GetId() << " " << this->GetEastId() << std::endl;
759  std::cout << this->GetSWId() << " " << this->GetSouthId() << " " << this->GetSEId() << std::endl;
760  std::cout << std::endl;
761 
762 }
763 
764 int
766 { if (iphi != 17) return ((iphi+1)*22 + ieta); else return ieta; }
767 
768 
769 int
771 { if (iphi != 0) return ((iphi-1)*22 + ieta); else return (17*22 + ieta); }
772 
773 int
775 { if (ieta != 0) return (iphi*22 + ieta-1); else return 999; }
776 
777 int
779 { if (ieta != 21) return (iphi*22 + ieta+1); else return 999; }
780 
781 int
783 {
784  if (ieta != 0) {
785  if (iphi != 17)
786  return ((iphi+1)*22 + ieta-1);
787  else
788  return (ieta-1);
789  } else {
790  return 999;
791  }
792 }
793 
794 int
796 {
797  if (ieta != 0) {
798  if (iphi != 0)
799  return ((iphi-1)*22 + ieta-1);
800  else
801  return (17*22 + ieta-1);
802  } else {
803  return 999;
804  }
805 }
806 
808 {
809  if (ieta != 21) {
810  if (iphi != 17)
811  return ((iphi+1)*22 + ieta+1);
812  else
813  return (ieta+1);
814  } else {
815  return 999;
816  }
817 }
818 
819 int
821 {
822  if (ieta != 21) {
823  if (iphi != 0)
824  return ((iphi-1)*22 + ieta+1);
825  else
826  return (17*22 + ieta+1);
827  } else {
828  return 999;
829  }
830 }
831 
832 double
833 corrJetEt(double et, double eta)
834 {
835  return corrJetEt1(et,eta);
836  //return corrJetEt2(et,eta);
837 }
838 
839 
840 // Jet Calibration from CMSSW_1_3_0
841 double
842 corrJetEt2(double et, double eta)
843 {
844  const int NUMBER_ETA_VALUES = 11;
845  std::vector< std::vector<float> > m_calibFunc;
846 
847  m_calibFunc.resize(NUMBER_ETA_VALUES);
848 
849  // still fill manually
850  m_calibFunc.at(0).push_back(1);
851  m_calibFunc.at(0).push_back(1);
852  m_calibFunc.at(0).push_back(2);
853 
854  m_calibFunc.at(1).push_back(1);
855  m_calibFunc.at(1).push_back(2);
856  m_calibFunc.at(1).push_back(2);
857 
858  m_calibFunc.at(2).push_back(2);
859  m_calibFunc.at(2).push_back(2);
860  m_calibFunc.at(2).push_back(2);
861  m_calibFunc.at(2).push_back(2);
862  m_calibFunc.at(2).push_back(3);
863  m_calibFunc.at(2).push_back(3);
864 
865  m_calibFunc.at(3).push_back(1);
866  m_calibFunc.at(3).push_back(1);
867  m_calibFunc.at(3).push_back(3);
868 
869  m_calibFunc.at(4).push_back(1);
870  m_calibFunc.at(4).push_back(3);
871  m_calibFunc.at(4).push_back(3);
872  m_calibFunc.at(4).push_back(6);
873  m_calibFunc.at(4).push_back(6);
874  m_calibFunc.at(4).push_back(6);
875  m_calibFunc.at(4).push_back(6);
876  m_calibFunc.at(4).push_back(6);
877 
878  m_calibFunc.at(5).push_back(3);
879  m_calibFunc.at(5).push_back(3);
880  m_calibFunc.at(5).push_back(3);
881 
882  m_calibFunc.at(6).push_back(1);
883  m_calibFunc.at(6).push_back(1);
884  m_calibFunc.at(6).push_back(4);
885 
886  m_calibFunc.at(7).push_back(1);
887  m_calibFunc.at(7).push_back(4);
888  m_calibFunc.at(7).push_back(4);
889 
890  m_calibFunc.at(8).push_back(4);
891  m_calibFunc.at(8).push_back(4);
892  m_calibFunc.at(8).push_back(4);
893  m_calibFunc.at(8).push_back(1);
894  m_calibFunc.at(8).push_back(1);
895  m_calibFunc.at(8).push_back(1);
896 
897  m_calibFunc.at(9).push_back(1);
898  m_calibFunc.at(9).push_back(1);
899  m_calibFunc.at(9).push_back(5);
900 
901  m_calibFunc.at(10).push_back(1);
902  m_calibFunc.at(10).push_back(5);
903  m_calibFunc.at(10).push_back(5);
904 
905 
906  double etabin[12] = { 0.0, 0.348, 0.696, 1.044, 1.392, 1.74, 2.172, 3.0,
907  3.33, 3.839, 4.439, 5.115};
908  int BinID = 0;
909  for(int i = 0; i < 11; i++){
910  if(std::abs(eta) >= etabin[i] && eta < etabin[i+1])
911  BinID = i;
912  }
913 
914  double corrEt = 0;
915  for (unsigned i=0; i<m_calibFunc.at(BinID).size();i++){
916  corrEt += m_calibFunc.at(BinID).at(i)*pow(et,(int)i);
917  }
918 
919  uint16_t jetEtOut = (uint16_t)corrEt;
920 
921  if(jetEtOut < 1024) {
922  return (double)jetEtOut;
923  }
924  return (double)1023;
925 
926 }
927 
928 // Jet Calibration from Frederick(Helsinki), Monika/Creighton (Wisconsin)
929 double
930 corrJetEt1(double et, double eta)
931 {
932  double etabin[23] = {-5.115, -4.439, -3.839, -3.33,
933  -3.0, -2.172, -1.74, -1.392, -1.044, -0.696, -0.348,
934  0.0, 0.348, 0.696, 1.044, 1.392, 1.74, 2.172, 3.0,
935  3.33, 3.839, 4.439, 5.115};
936 
937  int BinID = 0;
938 
939  double domainbin_L[22] = {6.52223337753073373e+00,6.64347505748981959e+00,6.78054870174118296e+00,6.75191887554567405e+00,
940  6.60891660595437802e+00,6.57813476381055473e+00,6.96764764481347232e+00,6.77192746888150943e+00,
941  7.16209661824076260e+00,7.09640803784948027e+00,7.29886808171882517e+00,7.29883431473330546e+00,
942  7.24561741344293875e+00,7.05381822724987995e+00,6.52340799679028827e+00,6.96091042775473401e+00,
943  6.69803071767842262e+00,7.79138848427964259e+00,6.78565437835616603e+00,6.71201461174192904e+00,
944  6.60832257380386334e+00,6.54875448717649267e+00};
945 
946  double domainbin_U[22] = {8.90225568813317558e+00,1.24483653543590922e+01,1.32037091554958987e+01,1.70036104608977681e+01,
947  3.54325008263432011e+01,4.28758696753095450e+01,4.73079850563588025e+01,4.74182802251108981e+01,
948  4.62509826468679748e+01,5.02198002212212913e+01,4.69817029938948352e+01,4.77263481299233732e+01,
949  4.86083837976362076e+01,4.80105593452927337e+01,5.11550616006504200e+01,4.90703092811585861e+01,
950  4.11879629179572788e+01,3.21820720507165845e+01,1.71844078553560529e+01,1.33158534849654764e+01,
951  1.43586396719878149e+01,1.08629843894704248e+01};
952 
953  double A[22] = {2.03682,-4.36824,-4.45258,-6.76524,-22.5984,-24.5289,-24.0313,-22.1896,-21.7818,-22.9882,-20.3321,
954  -21.0595,-22.1007,-22.658,-23.6898,-24.8888,-23.3246,-21.5343,-6.41221,-4.58952,-3.17222,0.637666};
955 
956  double B[22] = {0.226303,0.683099,0.704578,0.704623,0.825928,0.80086,0.766475,0.726059,0.760964,0.792227,0.789188,0.795219,
957  0.781097,0.768022,0.740101,0.774782,0.788106,0.814502,0.686877,0.709556,0.628581,0.317453};
958 
959  double C[22] = {0.00409083,0.000235995,8.22958e-05,2.47567e-05,0.000127995,0.000132914,0.000133342,0.000133035,0.000125993,
960  8.25968e-05,9.94442e-05,9.11652e-05,0.000109351,0.000115883,0.00011112,0.000122559,0.00015868,0.000152601,
961  0.000112927,6.29999e-05,0.000741798,0.00274605};
962 
963  double D[22] = {8.24022,7.55916,7.16448,6.31577,5.96339,5.31203,5.35456,4.95243,5.34809,4.93339,5.05723,5.08575,5.18643,5.15202,
964  4.48249,5.2734,5.51785,8.00182,6.21742,6.96692,7.22975,8.12257};
965 
966  double E[22] = {-0.343598,-0.294067,-0.22529,-0.0718625,0.004164,0.081987,0.124964,0.15006,0.145201,0.182151,0.187525,0.184763,
967  0.170689,0.155268,0.174603,0.133432,0.0719798,-0.0921457,-0.0525274,-0.208415,-0.253542,-0.318476};
968 
969  double F[22] = {0.0171799,0.0202499,0.0186897,0.0115477,0.00603883,0.00446235,0.00363449,0.00318894,0.00361997,0.00341508,
970  0.00366392,0.0036545,0.00352303,0.00349116,0.00294891,0.00353187,0.00460384,0.00711028,0.0109351,0.0182924,
971  0.01914,0.0161094};
972 
973  for(int i = 0; i < 22; i++){
974  if(eta > etabin[i] && eta <= etabin[i+1])
975  BinID = i;
976  }
977 
978  if(et >= domainbin_U[BinID]){
979  return 2*(et-A[BinID])/(B[BinID]+sqrt(B[BinID]*B[BinID]-4*A[BinID]*C[BinID]+4*et*C[BinID]));
980  }
981  else if(et > domainbin_L[BinID]){
982  return 2*(et-D[BinID])/(E[BinID]+sqrt(E[BinID]*E[BinID]-4*D[BinID]*F[BinID]+4*et*F[BinID]));
983  }
984  else return et;
985 }
986 
987 
988 // EM correction from ORCA for cmsim 133
989 double
990 //corrEmEt(double et, double eta) {
991 corrEmEt(double et, int eta) {
992 
993 
994  const int nscales = 32;
995  /*
996  const int nscales = 27;
997  double etalimit[nscales] = { 0.0,0.087,0.174,0.261,0.348,0.435,0.522,0.609,0.696,0.783,0.870,0.957,
998  1.044,1.131,1.218,1.305,1.392,1.479,1.566,1.653,1.740,1.830,1.930,
999  2.043,2.172,2.322,2.500};
1000  */
1001 
1002  double scfactor[nscales] = {
1003  1.00,1.01,1.02,1.02,1.02,1.06,1.04,1.04,1.05,1.09,1.10,1.10,1.15,
1004  1.20,1.27,1.29,1.32,1.52,1.52,1.48,1.40,1.32,1.26,1.21,1.17,1.15,
1005  1.15,1.15,1.15,1.15,1.15,1.15};
1006 
1007  /*
1008  double scale=1.;
1009  for (int i=0;i<nscales;i++) {
1010  if (std::abs(eta)<etalimit[i]) {
1011  scale = scfactor[i];
1012  }
1013  }
1014  return (scale*et);
1015  */
1016 
1017  if (eta>=0 && eta <=28)
1018  return (scfactor[eta]*et);
1019  else
1020  return et;
1021 }
1022 
1023 
1024 // Rounding the Et info for simulating the regional Et resolution
1025 double
1026 RCTEnergyTrunc(double et, double LSB, double thres) {
1027 
1028  //return et;
1029  if (et>=thres) return thres;
1030 
1031  //et += LSB/2.;
1032  //double ret = (int)(et / LSB) * LSB + LSB;
1033  int iEt = (int)(et / LSB);
1034  double ret = (double)iEt * LSB;
1035 
1036  return ret;
1037 }
1038 
1039 
1040 double
1041 GCTEnergyTrunc(double et, double LSB, bool doEM) {
1042 
1043  //return et;
1044 
1045  //double L1CaloEmEtScaleLSB = LSB;
1046  //double L1CaloRegionEtScaleLSB = LSB;
1047 
1048  //if (et>0.) et += LSB/2.; // round up
1049 
1050  double L1CaloEmThresholds[64] = {
1051  0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,
1052  10., 11., 12., 13., 14., 15., 16., 17., 18., 19.,
1053  20., 21., 22., 23., 24., 25., 26., 27., 28., 29.,
1054  30., 31., 32., 33., 34., 35., 36., 37., 38., 39.,
1055  40., 41., 42., 43., 44., 45., 46., 47., 48., 49.,
1056  50., 51., 52., 53., 54., 55., 56., 57., 58., 59.,
1057  60., 61., 62., 63.
1058  };
1059 
1060  double L1CaloJetThresholds[64] = {
1061  0., 10., 12., 14., 15., 18., 20., 22., 24., 25.,
1062  28., 30., 32., 35., 37., 40., 45., 50., 55., 60.,
1063  65., 70., 75., 80., 85., 90., 100., 110., 120., 125.,
1064  130., 140., 150., 160., 170., 175., 180., 190., 200., 215.,
1065  225., 235., 250., 275., 300., 325., 350., 375., 400., 425.,
1066  450., 475., 500., 525., 550., 575., 600., 625., 650., 675.,
1067  700., 725., 750., 775.
1068  };
1069 
1070 
1071 
1072  double L1CaloThresholds[64];
1073  if (doEM) {
1074  for (int i=0;i<64;i++)
1075  L1CaloThresholds[i] = L1CaloEmThresholds[i];
1076  } else {
1077  for (int i=0;i<64;i++)
1078  L1CaloThresholds[i] = L1CaloJetThresholds[i];
1079  }
1080 
1081 
1082  double ret = 0.;
1083  for (int i=63;i>0;i--) {
1084  if (et>=(L1CaloThresholds[i])) {
1085  if (i==63) {
1086  ret = L1CaloThresholds[63];
1087  } else {
1088  /*
1089  double minL = std::abs(et - L1CaloThresholds[i]);
1090  double minU = std::abs(et - L1CaloThresholds[i+1]);
1091  if (minL<minU)
1092  ret = L1CaloThresholds[i];
1093  else
1094  ret = L1CaloThresholds[i+1];
1095  */
1096  /*
1097  if (doEM) {
1098  ret = L1CaloThresholds[i];
1099  } else {
1100  ret = L1CaloThresholds[i+1];
1101  }
1102  */
1103  ret = L1CaloThresholds[i];
1104  }
1105  break;
1106  }
1107  }
1108  return ret;
1109 }
1110 
1111 
1112 
virtual double energy() const GCC11_FINAL
energy
double FGEBThreshold
Definition: FastL1Region.h:67
double FGEEThreshold
Definition: FastL1Region.h:68
int i
Definition: DBlmapReader.cc:9
double corrJetEt(double et, double eta)
void SetRegionBits(edm::Event const &e)
double TowerEEScale
Definition: FastL1Region.h:86
std::pair< double, double > getRegionCenterEtaPhi(const edm::EventSetup &c)
void setTauVeto(bool tauVeto)
Definition: FastL1BitInfo.h:24
double HadActiveLevel
Definition: FastL1Region.h:61
double SumEt()
Definition: FastL1Region.h:161
double corrJetEt2(double et, double eta)
double noTauVetoLevel
Definition: FastL1Region.h:65
double QuietRegionThreshold
Definition: FastL1Region.h:70
double hOeThreshold
Definition: FastL1Region.h:66
double hadEt() const
Definition: CaloTower.h:85
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:56
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:114
double CalcSumHadE()
double outerEt() const
Definition: CaloTower.h:86
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void SetHCFGBit()
void SetTowerBits()
std::vector< EcalRecHit >::const_iterator const_iterator
void setHighestEtTowerID(int id)
Definition: FastL1BitInfo.h:35
double CalcSumEmE()
#define abs(x)
Definition: mlp_lapack.h:159
double EMActiveLevel
Definition: FastL1Region.h:60
bool hOeBit[16]
Definition: FastL1Region.h:236
double TowerEBScale
Definition: FastL1Region.h:85
double TowerHEThreshold
Definition: FastL1Region.h:83
T eta() const
bool fgBit[16]
Definition: FastL1Region.h:235
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
double HadNoiseLevel
Definition: FastL1Region.h:63
int HighestEmEtTowerID()
void FillEMCrystals(const CaloTowerConstituentsMap *theTowerConstituentsMap, const CaloTopology *calotopo, const CaloGeometry *cGeom, const EcalRecHitCollection *ec0, const EcalRecHitCollection *ec1, FastL1RegionMap *m_RMap)
void SetQuietBit()
int iphi() const
get the crystal iphi
Definition: EBDetId.h:54
double TowerHEScale
Definition: FastL1Region.h:88
double CalcSumHadEt()
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
double TowerHBScale
Definition: FastL1Region.h:87
double TowerEMLSB
Definition: FastL1Region.h:75
int iEvent
Definition: GenABIO.cc:243
void setHadTauVeto(bool hadTauVeto)
Definition: FastL1BitInfo.h:26
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
double emEnergy() const
Definition: CaloTower.h:79
double TowerHBThreshold
Definition: FastL1Region.h:82
double CalcSumEt()
double CrystalEBThreshold
Definition: FastL1Region.h:72
T sqrt(T t)
Definition: SSEVec.h:48
double JetSeedEtThreshold
Definition: FastL1Region.h:57
double CalcSumEmEt()
int iphi() const
get the tower iphi
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
double noFGThreshold
Definition: FastL1Region.h:69
int j
Definition: DBlmapReader.cc:9
std::vector< DetId > east(const DetId &id) const
Get the neighbors of the given cell in east direction.
Definition: CaloTopology.cc:38
double GCTEnergyTrunc(double et, double LSB=1., bool doEM=false)
void SetHOEBit()
int ieta() const
get the crystal ieta
Definition: EBDetId.h:52
void FillTowerZero(const CaloTower &t, int &tid)
std::vector< DetId > north(const DetId &id) const
Get the neighbors of the given cell in north direction.
Definition: CaloTopology.cc:48
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double TowerEEThreshold
Definition: FastL1Region.h:81
double hadEnergy() const
Definition: CaloTower.h:80
const_iterator end() const
double EMNoiseLevel
Definition: FastL1Region.h:62
double corrEmEt(double et, int eta)
Definition: DetId.h:20
CaloTowerDetId id() const
Definition: CaloTower.h:72
void SetParameters(L1Config)
Definition: FastL1Region.cc:90
void setIsolationVeto(bool isolationVeto)
Definition: FastL1BitInfo.h:27
CaloTowerCollection Towers
Definition: FastL1Region.h:216
std::vector< DetId > west(const DetId &id) const
Get the neighbors of the given cell in west direction.
Definition: CaloTopology.cc:43
int HighestEtTowerID()
void setEmTauVeto(bool emTauVeto)
Definition: FastL1BitInfo.h:25
const T & get() const
Definition: EventSetup.h:55
double EMCrystalEnergy[16][25]
Definition: FastL1Region.h:218
void setHighestHadEtTowerID(int id)
Definition: FastL1BitInfo.h:37
double TowerHadLSB
Definition: FastL1Region.h:76
T eta() const
Definition: PV3DBase.h:76
double corrJetEt1(double et, double eta)
double EMLSB
Definition: FastL1Region.h:77
edm::SortedCollection< CaloTower > CaloTowerCollection
Definition: CaloTowerFwd.h:15
double JetLSB
Definition: FastL1Region.h:78
double CrystalEEThreshold
Definition: FastL1Region.h:73
void SetRegionEnergy()
Definition: FastL1Region.cc:96
double MuonNoiseLevel
Definition: FastL1Region.h:71
tuple cout
Definition: gather_cfg.py:121
void SetTauBit(edm::Event const &e)
double RCTEnergyTrunc(double et, double Resol=1., double thres=1024.)
FastL1BitInfo BitInfo
Definition: FastL1Region.h:196
L1Config Config
Definition: FastL1Region.h:242
void FillTower(const CaloTower &t, int &tid, edm::ESHandle< CaloGeometry > &cGeom)
double EMSeedEnThreshold
Definition: FastL1Region.h:58
int ieta() const
get the tower ieta
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
void SetMIPBit()
bool hcfgBit[16]
Definition: FastL1Region.h:237
void FillTower_Scaled(const CaloTower &t, int &tid, bool doRCTTrunc, edm::ESHandle< CaloGeometry > &cGeom)
double TowerEBThreshold
Definition: FastL1Region.h:80
int HighestHadEtTowerID()
double emEt() const
Definition: CaloTower.h:84
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< DetId > south(const DetId &id) const
Get the neighbors of the given cell in south direction.
Definition: CaloTopology.cc:53
void setHighestEmEtTowerID(int id)
Definition: FastL1BitInfo.h:36
const_iterator begin() const
double CalcSumE()
Definition: DDAxes.h:10