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::Stage1Layer2EGammaAlgorithmImpHW Class Reference

#include <Stage1Layer2EGammaAlgorithmImp.h>

Inheritance diagram for l1t::Stage1Layer2EGammaAlgorithmImpHW:
l1t::Stage1Layer2EGammaAlgorithm

Public Member Functions

virtual void processEvent (const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::CaloRegion > &regions, const std::vector< l1t::Jet > *jets, std::vector< l1t::EGamma > *egammas)
 
 Stage1Layer2EGammaAlgorithmImpHW (CaloParamsHelper *params)
 
virtual ~Stage1Layer2EGammaAlgorithmImpHW ()
 
- Public Member Functions inherited from l1t::Stage1Layer2EGammaAlgorithm
virtual ~Stage1Layer2EGammaAlgorithm ()
 

Private Member Functions

int AssociatedJetPt (int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
 
unsigned isoLutIndex (unsigned int etaPt, unsigned int jetPt) const
 

Private Attributes

CaloParamsHelper *const params_
 

Detailed Description

Definition at line 66 of file Stage1Layer2EGammaAlgorithmImp.h.

Constructor & Destructor Documentation

Stage1Layer2EGammaAlgorithmImpHW::Stage1Layer2EGammaAlgorithmImpHW ( CaloParamsHelper params)

Definition at line 25 of file Stage1Layer2EGammaAlgorithmImpHW.cc.

25 : params_(params) {};
Stage1Layer2EGammaAlgorithmImpHW::~Stage1Layer2EGammaAlgorithmImpHW ( )
virtual

Definition at line 27 of file Stage1Layer2EGammaAlgorithmImpHW.cc.

27 {};

Member Function Documentation

int l1t::Stage1Layer2EGammaAlgorithmImpHW::AssociatedJetPt ( int  ieta,
int  iphi,
const std::vector< l1t::Jet > *  jets 
) const
private

Definition at line 154 of file Stage1Layer2EGammaAlgorithmImpHW.cc.

References gather_cfg::cout, Debug, reco::btau::jetEta, reco::btau::jetPhi, and EnergyCorrector::pt.

155  {
156 
157  bool Debug=false;
158 
159  if (Debug) cout << "Number of jets: " << jets->size() << endl;
160  int pt = 0;
161 
162 
163  for(JetBxCollection::const_iterator itJet = jets->begin();
164  itJet != jets->end(); ++itJet){
165 
166  int jetEta = itJet->hwEta();
167  int jetPhi = itJet->hwPhi();
168  if (Debug) cout << "Matching ETA: " << ieta << " " << jetEta << endl;
169  if (Debug) cout << "Matching PHI: " << iphi << " " << jetPhi << endl;
170  if ((jetEta == ieta) && (jetPhi == iphi)){
171  pt = itJet->hwPt();
172  break;
173  }
174  }
175 
176  // set output
177  return pt;
178 }
vector< PseudoJet > jets
tuple cout
Definition: gather_cfg.py:121
const bool Debug
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:16
unsigned l1t::Stage1Layer2EGammaAlgorithmImpHW::isoLutIndex ( unsigned int  etaPt,
unsigned int  jetPt 
) const
private

Definition at line 142 of file Stage1Layer2EGammaAlgorithmImpHW.cc.

143 {
144  const unsigned int nbitsEG=6; // number of bits used for EG bins in LUT file (needed for left shift operation)
145  // const unsigned int nbitsJet=9; // not used but here for info number of bits used for Jet bins in LUT file
146 
147  //jetPt &= 511; // Take only the LSB 9 bits to match firmware.
148  if(jetPt > 511) jetPt = 511;
149  unsigned int address= (jetPt << nbitsEG) + egPt;
150  // std::cout << address << "\t## " << egPt << " " << jetPt << std::endl;
151  return address;
152 }
void l1t::Stage1Layer2EGammaAlgorithmImpHW::processEvent ( const std::vector< l1t::CaloEmCand > &  EMCands,
const std::vector< l1t::CaloRegion > &  regions,
const std::vector< l1t::Jet > *  jets,
std::vector< l1t::EGamma > *  egammas 
)
virtual

Implements l1t::Stage1Layer2EGammaAlgorithm.

Definition at line 31 of file Stage1Layer2EGammaAlgorithmImpHW.cc.

References l1t::EGammaToGtScales(), cmsHarvester::index, l1t::pack15bits(), l1t::RegionCorrection(), l1t::SortEGammas(), cond::to_string(), and l1t::TwelveByTwelveFinder().

31  {
32 
33 
34  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
35  std::vector<l1t::EGamma> *preSortEGammas = new std::vector<l1t::EGamma>();
36  std::vector<l1t::EGamma> *preGtEGammas = new std::vector<l1t::EGamma>();
37 
38 
39  //Region Correction will return uncorrected subregions if
40  //regionPUSType is set to None in the config
41  RegionCorrection(regions, subRegions, params_);
42 
43  // ----- need to cluster jets in order to compute jet isolation ----
44  std::vector<l1t::Jet> *unCorrJets = new std::vector<l1t::Jet>();
45  TwelveByTwelveFinder(0, subRegions, unCorrJets);
46 
47 
48  //std::cout << "Begin egamma cand debug dump:" << std::endl;
49  //std::cout << "pt eta phi index assocJetPt lutAddress lutResult" << std::endl;
50  for(CaloEmCandBxCollection::const_iterator egCand = EMCands.begin();
51  egCand != EMCands.end(); egCand++) {
52 
53  int eg_et = egCand->hwPt();
54  int eg_eta = egCand->hwEta();
55  int eg_phi = egCand->hwPhi();
56  int index = (egCand->hwIso()*4 + egCand->hwQual()) ;
57 
58  //std::cout << "JetRankMax: " << params_->jetScale().rankScaleMax()<< " EmRankMax: " << params_->emScale().rankScaleMax()<< std::endl;
59  //std::cout << "JetLinMax: " << params_->jetScale().linScaleMax()<< " EmLinMax: " << params_->emScale().linScaleMax()<< std::endl;
60 
61  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > egLorentz(0,0,0,0);
62 
63  int isoFlag = 0;
64  int ijet_pt=AssociatedJetPt(eg_eta,eg_phi,unCorrJets);
65  bool isinBarrel = (eg_eta>=7 && eg_eta<=14);
66  unsigned int lutAddress = isoLutIndex(eg_et,ijet_pt);
67 
68  // Combined Barrel/Endcap LUT uses upper bit to indicate Barrel / Endcap:
69  enum {MAX_LUT_ADDRESS = 0x7fff};
70  enum {LUT_BARREL_OFFSET = 0x0, LUT_ENDCAP_OFFSET = 0x8000};
71  enum {LUT_RCT_OFFSET = 0x10000};
72 
73  unsigned int rct_offset=0;
74  if (egCand->hwIso()) rct_offset=LUT_RCT_OFFSET;
75 
76  if (eg_et >0){
77  if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
78 
79  if (isinBarrel){
80  isoFlag= params_->egIsolationLUT()->data(LUT_BARREL_OFFSET + rct_offset + lutAddress);
81  } else{
82  isoFlag= params_->egIsolationLUT()->data(LUT_ENDCAP_OFFSET + rct_offset + lutAddress);
83  }
84  }
85 
86  // std::cout << eg_et << " " << eg_eta << " " << eg_phi << " " << index << " "
87  // << ijet_pt << " " << lutAddress << " " << isoFlag << std::endl;
88  l1t::EGamma theEG(*&egLorentz, eg_et, eg_eta, eg_phi, index, isoFlag);
89  preSortEGammas->push_back(theEG);
90  }
91 
92  // printf("Pre-Sort\n");
93  // for(std::vector<l1t::EGamma>::const_iterator itEGamma = preSortEGammas->begin();
94  // itEGamma != preSortEGammas->end(); ++itEGamma){
95  // std::cout << itEGamma->hwPt() << " " << itEGamma->hwEta() << " " << itEGamma->hwPhi() << std::endl;
96  // }
97 
98  SortEGammas(preSortEGammas, preGtEGammas);
99 
100  EGammaToGtScales(params_, preGtEGammas, egammas);
101 
102  // printf("Post-Sort\n");
103  // for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
104  // itEGamma != egammas->end(); ++itEGamma){
105  // std::cout << itEGamma->hwPt() << " " << itEGamma->hwEta() << " " << itEGamma->hwPhi() << std::endl;
106  // }
107 
108  const bool verbose = false;
109  if(verbose)
110  {
111  int cEGammas = 0;
112  int fEGammas = 0;
113  printf("EGammas Isolated\n");
114  for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
115  itEGamma != egammas->end(); ++itEGamma){
116  if(itEGamma->hwIso() != 1) continue;
117  cEGammas++;
118  unsigned int packed = pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
119  cout << bitset<15>(packed).to_string() << endl;
120  if(cEGammas == 4) break;
121  }
122 
123  printf("EGammas Non-isolated\n");
124  for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
125  itEGamma != egammas->end(); ++itEGamma){
126  if(itEGamma->hwIso() != 0) continue;
127  fEGammas++;
128  unsigned int packed = pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
129  cout << bitset<15>(packed).to_string() << endl;
130  if(fEGammas == 4) break;
131  }
132  }
133 
134  delete subRegions;
135  delete unCorrJets;
136  delete preSortEGammas;
137  delete preGtEGammas;
138 
139 }
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) --------— ...
void EGammaToGtScales(CaloParamsHelper *params, const std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
void TwelveByTwelveFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
std::string to_string(const T &t)
Definition: Logger.cc:26
unsigned isoLutIndex(unsigned int etaPt, unsigned int jetPt) const
void SortEGammas(std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
unsigned int pack15bits(int pt, int eta, int phi)
int data(unsigned int address) const
Definition: LUT.h:46
std::vector< CaloEmCand >::const_iterator const_iterator
Definition: BXVector.h:16

Member Data Documentation

CaloParamsHelper* const l1t::Stage1Layer2EGammaAlgorithmImpHW::params_
private

Definition at line 75 of file Stage1Layer2EGammaAlgorithmImp.h.