CMS 3D CMS Logo

Stage2Layer2DemuxTauAlgoFirmwareImp1.cc
Go to the documentation of this file.
1 
10 
12 
13 #include <vector>
14 #include <algorithm>
16 
17 namespace l1t {
18  inline bool operator > ( l1t::Tau& a, l1t::Tau& b )
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::Stage2Layer2DemuxTauAlgoFirmwareImp1::processEvent(const std::vector<l1t::Tau> & inputTaus,
50  std::vector<l1t::Tau> & outputTaus) {
51 
52 
53  vector<pair<int,double> > etaGT;
54  etaGT.reserve(115);
55  for(int i=0;i<115;i++)
56  etaGT.push_back( make_pair(i,i*(0.087/2.)) );
57 
58  vector<pair<int,double> > phiGT;
59  phiGT.reserve(145);
60  for(int i=0;i<145;i++)
61  phiGT.push_back( make_pair(i,i*(M_PI/72.)) );
62  phiGT[144] = make_pair(0,2*M_PI); //2pi = 0
63 
64  outputTaus = inputTaus;
65 
66  for(auto& tau : outputTaus){
67 
68  double eta = tau.eta();
69  double phi = tau.phi();
70  if(phi<0)
71  phi+=2*M_PI;
72 
73  double minDistance = 99999.;
74  pair<int, double> closestPoint = make_pair(0,0.);
75 
76  for(const auto& p : etaGT){
77  double distance = abs(abs(eta) - p.second);
78  if(distance < minDistance){
79  closestPoint = p;
80  minDistance = distance;
81  }
82  }
83 
84  int hwEta_GT = (eta>0) ? closestPoint.first : - closestPoint.first;
85  double eta_GT = (eta>0) ? closestPoint.second : - closestPoint.second;
86 
87  minDistance = 99999.;
88  closestPoint = make_pair(0,0.);
89 
90  for(const auto& p : phiGT){
91  double distance = abs(phi - p.second);
92  if(distance < minDistance){
93  closestPoint = p;
94  minDistance = distance;
95  }
96  }
97 
98  int hwPhi_GT = closestPoint.first;
99  double phi_GT = closestPoint.second;
100 
101  tau.setHwEta(hwEta_GT);
102  tau.setHwPhi(hwPhi_GT);
103 
104  //9 bits threshold
105  if(tau.hwPt()>511)
106  tau.setHwPt(511);
107 
108  math::PtEtaPhiMLorentzVector tauP4(tau.hwPt()*params_->egLsb(), eta_GT, phi_GT, 0.);
109  tau.setP4(tauP4);
110 
111  }
112 
113  //sorting with descending pT
114  std::vector<l1t::Tau>::iterator start_ = outputTaus.begin();
115  std::vector<l1t::Tau>::iterator end_ = outputTaus.end();
116  BitonicSort<l1t::Tau>(down, start_, end_);
117 
118 }
Definition: Tau.h:21
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void processEvent(const std::vector< Tau > &inputTaus, std::vector< Tau > &outputTaus) override
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)