CMS 3D CMS Logo

Stage2Layer2DemuxEGAlgoFirmwareImp1.cc
Go to the documentation of this file.
1 
10 
12 
13 #include <vector>
14 #include <algorithm>
16 
17 namespace l1t {
19  {
20  if ( a.pt() == b.pt() ){
21  if( a.hwPhi() == b.hwPhi() ){
22  return a.hwEta() > b.hwEta();
23  }
24  else{
25  return a.hwPhi() > b.hwPhi();
26  }
27 
28  }
29  else{
30  return a.pt() > b.pt();
31  }
32  }
33 }
34 
36  params_(params)
37 {
38 
39 
40 }
41 
42 
44 
45 
46 }
47 
48 
49 void l1t::Stage2Layer2DemuxEGAlgoFirmwareImp1::processEvent(const std::vector<l1t::EGamma> & inputEGammas,
50  std::vector<l1t::EGamma> & outputEGammas) {
51 
52  vector<pair<int,double> > etaGT;
53  etaGT.reserve(115);
54  for(int i=0;i<115;i++)
55  etaGT.push_back( make_pair(i,i*(0.087/2.)) );
56 
57  vector<pair<int,double> > phiGT;
58  phiGT.reserve(145);
59  for(int i=0;i<145;i++)
60  phiGT.push_back( make_pair(i,i*(M_PI/72.)) );
61  phiGT[144] = make_pair(0,2*M_PI); //2pi = 0
62 
63  outputEGammas = inputEGammas;
64 
65  for(auto& egamma : outputEGammas){
66 
67  double eta = egamma.eta();
68  double phi = egamma.phi();
69  if(phi<0)
70  phi+=2*M_PI;
71 
72  double minDistance = 99999.;
73  pair<int, double> closestPoint = make_pair(0,0.);
74 
75  for(const auto& p : etaGT){
76  double distance = abs(abs(eta) - p.second);
77  if(distance < minDistance){
78  closestPoint = p;
79  minDistance = distance;
80  }
81  }
82 
83  int hwEta_GT = (eta>0) ? closestPoint.first : - closestPoint.first;
84  double eta_GT = (eta>0) ? closestPoint.second : - closestPoint.second;
85 
86  minDistance = 99999.;
87  closestPoint = make_pair(0,0.);
88 
89  for(const auto& p : phiGT){
90  double distance = abs(phi - p.second);
91  if(distance < minDistance){
92  closestPoint = p;
93  minDistance = distance;
94  }
95  }
96 
97  int hwPhi_GT = closestPoint.first;
98  double phi_GT = closestPoint.second;
99 
100  egamma.setHwEta(hwEta_GT);
101  egamma.setHwPhi(hwPhi_GT);
102 
103  //9 bits threshold
104  if(egamma.hwPt()>511)
105  egamma.setHwPt(511);
106 
107  math::PtEtaPhiMLorentzVector egammaP4(egamma.hwPt()*params_->egLsb(), eta_GT, phi_GT, 0.);
108  egamma.setP4(egammaP4);
109 
110 
111  }
112 
113  //sorting with descending pT
114  std::vector<l1t::EGamma>::iterator start_ = outputEGammas.begin();
115  std::vector<l1t::EGamma>::iterator end_ = outputEGammas.end();
116  BitonicSort<l1t::EGamma>(down, start_, end_);
117 
118 
119 }
double pt() const final
transverse momentum
int hwPhi() const
Definition: L1Candidate.h:50
delete x;
Definition: CaloConfig.h:22
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
void processEvent(const std::vector< EGamma > &inputEgammas, std::vector< EGamma > &outputEgammas) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int hwEta() const
Definition: L1Candidate.h:49
#define M_PI
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool operator>(const l1t::Jet &a, l1t::Jet &b)
Stage2Layer2DemuxEGAlgoFirmwareImp1(CaloParamsHelper const *params)