CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
l1t::Stage1Layer2EtSumAlgorithmImpPP Class Reference

#include <Stage1Layer2EtSumAlgorithmImp.h>

Inheritance diagram for l1t::Stage1Layer2EtSumAlgorithmImpPP:
l1t::Stage1Layer2EtSumAlgorithm

Public Member Functions

virtual void processEvent (const std::vector< l1t::CaloRegion > &regions, const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::Jet > *jets, std::vector< l1t::EtSum > *sums)
 
 Stage1Layer2EtSumAlgorithmImpPP (CaloParamsHelper *params)
 
virtual ~Stage1Layer2EtSumAlgorithmImpPP ()
 
- Public Member Functions inherited from l1t::Stage1Layer2EtSumAlgorithm
virtual ~Stage1Layer2EtSumAlgorithm ()
 

Private Member Functions

int DiJetPhi (const std::vector< l1t::Jet > *jets) const
 
uint16_t MHToverHT (uint16_t, uint16_t) const
 

Private Attributes

std::vector< double > cosPhi
 
CaloParamsHelper *const params_
 
std::vector< double > sinPhi
 

Detailed Description

Author
: L. Apanasevich

Description: first iteration of stage 1 jet sums algo

Definition at line 30 of file Stage1Layer2EtSumAlgorithmImp.h.

Constructor & Destructor Documentation

l1t::Stage1Layer2EtSumAlgorithmImpPP::Stage1Layer2EtSumAlgorithmImpPP ( CaloParamsHelper params)

Definition at line 18 of file Stage1Layer2EtSumAlgorithmImpPP.cc.

References funct::cos(), cosPhi, i, L1CaloRegionDetId::N_PHI, funct::sin(), and sinPhi.

18  : params_(params)
19 {
20  //now do what ever initialization is needed
21  for(unsigned int i = 0; i < L1CaloRegionDetId::N_PHI; i++) {
22  sinPhi.push_back(sin(2. * 3.1415927 * i * 1.0 / L1CaloRegionDetId::N_PHI));
23  cosPhi.push_back(cos(2. * 3.1415927 * i * 1.0 / L1CaloRegionDetId::N_PHI));
24  }
25 }
int i
Definition: DBlmapReader.cc:9
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const unsigned N_PHI
l1t::Stage1Layer2EtSumAlgorithmImpPP::~Stage1Layer2EtSumAlgorithmImpPP ( )
virtual

Definition at line 28 of file Stage1Layer2EtSumAlgorithmImpPP.cc.

28  {
29 
30 
31 }

Member Function Documentation

int l1t::Stage1Layer2EtSumAlgorithmImpPP::DiJetPhi ( const std::vector< l1t::Jet > *  jets) const
private

Definition at line 205 of file Stage1Layer2EtSumAlgorithmImpPP.cc.

References funct::abs(), and L1CaloRegionDetId::N_PHI.

205  {
206 
207  // cout << "Number of jets: " << jets->size() << endl;
208 
209  int dphi = 10; // initialize to negative physical dphi value
210  if (jets->size()<2) return dphi; // size() not really reliable as we pad the size to 8 (4cen+4for) in the sorter
211  if ((*jets).at(0).hwPt() == 0) return dphi;
212  if ((*jets).at(1).hwPt() == 0) return dphi;
213 
214 
215  int iphi1 = (*jets).at(0).hwPhi();
216  int iphi2 = (*jets).at(1).hwPhi();
217 
218  int difference=abs(iphi1-iphi2);
219 
220  if ( difference > 9 ) difference= L1CaloRegionDetId::N_PHI - difference ; // make Physical dphi always positive
221  return difference;
222 }
vector< PseudoJet > jets
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const unsigned N_PHI
uint16_t l1t::Stage1Layer2EtSumAlgorithmImpPP::MHToverHT ( uint16_t  num,
uint16_t  den 
) const
private

Definition at line 224 of file Stage1Layer2EtSumAlgorithmImpPP.cc.

References cuy::denominator, cuy::numerator, and query::result.

224  {
225 
226  uint16_t result;
227  uint32_t numerator(num),denominator(den);
228 
229  if(numerator == denominator)
230  result = 0x7f;
231  else
232  {
233  numerator = numerator << 7;
234  result = numerator/denominator;
235  result = result & 0x7f;
236  }
237  // cout << "Result: " << result << endl;
238 
239  return result;
240 }
list numerator
Definition: cuy.py:483
list denominator
Definition: cuy.py:484
tuple result
Definition: query.py:137
void l1t::Stage1Layer2EtSumAlgorithmImpPP::processEvent ( const std::vector< l1t::CaloRegion > &  regions,
const std::vector< l1t::CaloEmCand > &  EMCands,
const std::vector< l1t::Jet > *  jets,
std::vector< l1t::EtSum > *  sums 
)
virtual

Implements l1t::Stage1Layer2EtSumAlgorithm.

Definition at line 38 of file Stage1Layer2EtSumAlgorithmImpPP.cc.

References gather_cfg::cout, l1t::EtSumToGtScales(), l1t::JetCalibration(), L1CaloRegionDetId::N_PHI, HLT_25ns14e33_v3_cff::region, l1t::RegionCorrection(), l1t::slidingWindowJetFinder(), l1t::SortJets(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::to_string().

41  {
42 
43  unsigned int sumET = 0;
44  double sumEx = 0;
45  double sumEy = 0;
46  unsigned int sumHT = 0;
47  double sumHx = 0;
48  double sumHy = 0;
49 
50  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
51 
52 
53  //Region Correction will return uncorrected subregions if
54  //regionPUSType is set to None in the config
55  double jetLsb=params_->jetLsb();
56 
57  int etSumEtaMinEt = params_->etSumEtaMin(0);
58  int etSumEtaMaxEt = params_->etSumEtaMax(0);
59  //double etSumEtThresholdEt = params_->etSumEtThreshold(0);
60  int etSumEtThresholdEt = (int) (params_->etSumEtThreshold(0) / jetLsb);
61 
62  int etSumEtaMinHt = params_->etSumEtaMin(1);
63  int etSumEtaMaxHt = params_->etSumEtaMax(1);
64  //double etSumEtThresholdHt = params_->etSumEtThreshold(1);
65  int etSumEtThresholdHt = (int) (params_->etSumEtThreshold(1) / jetLsb);
66 
67  RegionCorrection(regions, subRegions, params_);
68 
69  double towerLsb = params_->towerLsbSum();
70  int jetSeedThreshold = floor( params_->jetSeedThreshold()/towerLsb + 0.5);
71  // ----- cluster jets for repurposing of MHT phi (use if for angle between leading jet)
72  std::vector<l1t::Jet> *unCorrJets = new std::vector<l1t::Jet>();
73  std::vector<l1t::Jet> * unSortedJets = new std::vector<l1t::Jet>();
74  std::vector<l1t::Jet> * SortedJets = new std::vector<l1t::Jet>();
75  slidingWindowJetFinder(jetSeedThreshold, subRegions, unCorrJets);
76 
77  //if jetCalibrationType is set to None in the config
78  std::string jetCalibrationType = params_->jetCalibrationType();
79  std::vector<double> jetCalibrationParams = params_->jetCalibrationParams();
80  JetCalibration(unCorrJets, jetCalibrationParams, unSortedJets, jetCalibrationType, towerLsb);
81 
82  SortJets(unSortedJets, SortedJets);
83  int dijet_phi=DiJetPhi(SortedJets);
84 
85  for(std::vector<CaloRegion>::const_iterator region = subRegions->begin(); region != subRegions->end(); region++) {
86  if (region->hwEta() < etSumEtaMinEt || region->hwEta() > etSumEtaMaxEt) {
87  continue;
88  }
89 
90  //double regionET= regionPhysicalEt(*region);
91  int regionET = region->hwPt();
92 
93  if(regionET >= etSumEtThresholdEt){
94  sumET += regionET;
95  sumEx += (((double) regionET) * cosPhi[region->hwPhi()]);
96  sumEy += (((double) regionET) * sinPhi[region->hwPhi()]);
97  }
98  }
99 
100  for(std::vector<CaloRegion>::const_iterator region = subRegions->begin(); region != subRegions->end(); region++) {
101  if (region->hwEta() < etSumEtaMinHt || region->hwEta() > etSumEtaMaxHt) {
102  continue;
103  }
104 
105  //double regionET= regionPhysicalEt(*region);
106  int regionET = region->hwPt();
107 
108  if(regionET >= etSumEtThresholdHt) {
109  sumHT += regionET;
110  sumHx += (((double) regionET) * cosPhi[region->hwPhi()]);
111  sumHy += (((double) regionET) * sinPhi[region->hwPhi()]);
112  }
113  }
114 
115  unsigned int MET = ((unsigned int) sqrt(sumEx * sumEx + sumEy * sumEy));
116  unsigned int MHT = ((unsigned int) sqrt(sumHx * sumHx + sumHy * sumHy));
117 
118  double physicalPhi = atan2(sumEy, sumEx) + 3.1415927;
119  // Global Trigger expects MET phi to be 0-71 (e.g. tower granularity)
120  // Although we calculated it with regions, there is some benefit to interpolation.
121  unsigned int iPhiET = 4*L1CaloRegionDetId::N_PHI * physicalPhi / (2 * 3.1415927);
122 
123  double physicalPhiHT = atan2(sumHy, sumHx) + 3.1415927;
124  unsigned int iPhiHT = L1CaloRegionDetId::N_PHI * (physicalPhiHT) / (2 * 3.1415927);
125 
126  //std::cout << "MET:" << MET << "\tHT: " << MHT << std::endl;
127  //std::cout << "sumMET:" << sumET << "\tsumHT: " << sumHT << std::endl;
128 
129  const ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > etLorentz(0,0,0,0);
130 
131  // Set quality (i.e. overflow) bits appropriately
132  int METqual = 0;
133  int MHTqual = 0;
134  int ETTqual = 0;
135  int HTTqual = 0;
136  if(MET >= 0xfff) // MET 12 bits
137  METqual = 1;
138  if(MHT >= 0x7f) // MHT 7 bits
139  MHTqual = 1;
140  if(sumET >= 0xfff)
141  ETTqual = 1;
142  if(sumHT >= 0xfff)
143  HTTqual = 1;
144 
145 
146 
147  // scale MHT by sumHT
148  // int mtmp = floor (((double) MHT / (double) sumHT)*100 + 0.5);
149  // double mtmp = ((double) MHT / (double) sumHT);
150  // int rank=params_->HtMissScale().rank(mtmp);
151  // MHT=rank;
152 
153  uint16_t MHToHT=MHToverHT(MHT,sumHT);
154  iPhiHT=dijet_phi;
155 
156  l1t::EtSum etMiss(*&etLorentz,EtSum::EtSumType::kMissingEt,MET,0,iPhiET,METqual);
157  l1t::EtSum htMiss(*&etLorentz,EtSum::EtSumType::kMissingHt,MHToHT&0x7f,0,iPhiHT,MHTqual);
158  l1t::EtSum etTot (*&etLorentz,EtSum::EtSumType::kTotalEt,sumET&0xfff,0,0,ETTqual);
159  l1t::EtSum htTot (*&etLorentz,EtSum::EtSumType::kTotalHt,sumHT&0xfff,0,0,HTTqual);
160 
161  std::vector<l1t::EtSum> *preGtEtSums = new std::vector<l1t::EtSum>();
162 
163  preGtEtSums->push_back(etMiss);
164  preGtEtSums->push_back(htMiss);
165  preGtEtSums->push_back(etTot);
166  preGtEtSums->push_back(htTot);
167 
168  EtSumToGtScales(params_, preGtEtSums, etsums);
169 
170  delete subRegions;
171  delete unCorrJets;
172  delete unSortedJets;
173  delete SortedJets;
174  delete preGtEtSums;
175 
176  const bool verbose = false;
177  if(verbose)
178  {
179  for(std::vector<l1t::EtSum>::const_iterator itetsum = etsums->begin();
180  itetsum != etsums->end(); ++itetsum){
181  // if(EtSum::EtSumType::kMissingEt == itetsum->getType())
182  // {
183  // cout << "Missing Et" << endl;
184  // cout << bitset<12>(itetsum->hwPt()).to_string() << endl;
185  // }
186  // if(EtSum::EtSumType::kMissingHt == itetsum->getType())
187  // {
188  // cout << "Missing Ht" << endl;
189  // cout << bitset<12>(itetsum->hwPt()).to_string() << endl;
190  // }
191  if(EtSum::EtSumType::kTotalEt == itetsum->getType())
192  {
193  cout << "Total Et" << endl;
194  cout << bitset<12>(itetsum->hwPt()).to_string() << endl;
195  }
196  if(EtSum::EtSumType::kTotalHt == itetsum->getType())
197  {
198  cout << "Total Ht" << endl;
199  cout << bitset<12>(itetsum->hwPt()).to_string() << endl;
200  }
201  }
202  }
203 }
std::vector< double > jetCalibrationParams()
void JetCalibration(std::vector< l1t::Jet > *uncalibjets, std::vector< double > jetCalibrationParams, std::vector< l1t::Jet > *jets, std::string jetCalibrationType, double jetLSB)
void RegionCorrection(const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::CaloRegion > *subRegions, CaloParamsHelper *params)
------— New region correction (PUsub, no response correction at the moment) --------— ...
double etSumEtThreshold(unsigned isum) const
int etSumEtaMax(unsigned isum) const
void EtSumToGtScales(CaloParamsHelper *params, const std::vector< l1t::EtSum > *input, std::vector< l1t::EtSum > *output)
void SortJets(std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
std::string to_string(const T &t)
Definition: Logger.cc:26
std::string jetCalibrationType() const
int etSumEtaMin(unsigned isum) const
T sqrt(T t)
Definition: SSEVec.h:48
double jetLsb() const
uint16_t MHToverHT(uint16_t, uint16_t) const
void slidingWindowJetFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
int DiJetPhi(const std::vector< l1t::Jet > *jets) const
double towerLsbSum() const
tuple cout
Definition: gather_cfg.py:121
static const unsigned N_PHI
double jetSeedThreshold() const

Member Data Documentation

std::vector<double> l1t::Stage1Layer2EtSumAlgorithmImpPP::cosPhi
private

Definition at line 45 of file Stage1Layer2EtSumAlgorithmImp.h.

Referenced by Stage1Layer2EtSumAlgorithmImpPP().

CaloParamsHelper* const l1t::Stage1Layer2EtSumAlgorithmImpPP::params_
private

Definition at line 40 of file Stage1Layer2EtSumAlgorithmImp.h.

std::vector<double> l1t::Stage1Layer2EtSumAlgorithmImpPP::sinPhi
private

Definition at line 44 of file Stage1Layer2EtSumAlgorithmImp.h.

Referenced by Stage1Layer2EtSumAlgorithmImpPP().