CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Stage2Layer2EtSumAlgorithmFirmwareImp1.cc
Go to the documentation of this file.
1 
11 #include <math.h>
12 
13 
15  params_(params)
16 {
17 
18  // Add some LogDebug for these settings
19 
22 
25 
28 }
29 
30 
32 
33 void l1t::Stage2Layer2EtSumAlgorithmFirmwareImp1::processEvent(const std::vector<l1t::CaloTower> & towers,
34  std::vector<l1t::EtSum> & etsums) {
35 
36  int etaMax=40, etaMin=1, phiMax=72, phiMin=1;
37 
38  // etaSide=1 is positive eta, etaSide=-1 is negative eta
39  for (int etaSide=1; etaSide>=-1; etaSide-=2) {
40 
41  int32_t ex(0), ey(0), et(0);
42 
43  std::vector<int> rings;
44  for (int i=etaMin; i<=etaMax; i++) rings.push_back(i*etaSide);
45 
46  for (unsigned etaIt=0; etaIt<rings.size(); etaIt++) {
47 
48  int ieta = rings.at(etaIt);
49 
50  // TODO add the eta and Et thresholds
51 
52  int32_t ringEx(0), ringEy(0), ringEt(0);
53 
54  for (int iphi=phiMin; iphi<=phiMax; iphi++) {
55 
56  l1t::CaloTower tower = l1t::CaloTools::getTower(towers, ieta, iphi);
57 
58  ringEx += (int32_t) (tower.hwPt() * std::trunc ( 511. * cos ( 2 * M_PI * (72 - iphi) / 72.0 ) )) >> 9;
59  ringEy += (int32_t) (tower.hwPt() * std::trunc ( 511. * sin ( 2 * M_PI * iphi / 72.0 ) )) >> 9;
60  ringEt += tower.hwPt();
61 
62  }
63 
64  // At some point we will remove the bit shifts and will need to limit to the precision available in the firmware
65 
66  ex += ( ringEx >> 2);
67  ey += ( ringEy >> 2);
68  et += ( ringEt >> 1);
69 
70  }
71 
73 
74  l1t::EtSum etSumTotalEt(p4,l1t::EtSum::EtSumType::kTotalEt,et,0,0,0);
75  l1t::EtSum etSumEx(p4,l1t::EtSum::EtSumType::kTotalEtx,ex,0,0,0);
76  l1t::EtSum etSumEy(p4,l1t::EtSum::EtSumType::kTotalEty,ey,0,0,0);
77 
78  etsums.push_back(etSumTotalEt);
79  etsums.push_back(etSumEx);
80  etsums.push_back(etSumEy);
81 
82  }
83 
84 }
int i
Definition: DBlmapReader.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double etSumEtThreshold(unsigned isum) const
int etSumEtaMax(unsigned isum) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int etSumEtaMin(unsigned isum) const
double p4[4]
Definition: TauolaWrapper.h:92
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
virtual void processEvent(const std::vector< l1t::CaloTower > &towers, std::vector< l1t::EtSum > &sums)
int hwPt() const
Definition: L1Candidate.cc:69
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:11
double towerLsbSum() const