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

#include <Stage1Layer2EGammaAlgorithmImp.h>

Inheritance diagram for l1t::Stage1Layer2EGammaAlgorithmImpPP:
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)
 
 Stage1Layer2EGammaAlgorithmImpPP (CaloParamsHelper *params)
 
virtual ~Stage1Layer2EGammaAlgorithmImpPP ()
 
- 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
 
double HoverE (int et, int ieta, int iphi, const std::vector< l1t::CaloRegion > &regions) const
 --— Compute H/E -----------------— More...
 
double Isolation (int ieta, int iphi, const std::vector< l1t::CaloRegion > &regions) const
 --— Compute isolation sum -----------------— More...
 
unsigned isoLutIndex (unsigned int etaPt, unsigned int jetPt) const
 

Private Attributes

CaloParamsHelper *const params_
 

Detailed Description

Definition at line 26 of file Stage1Layer2EGammaAlgorithmImp.h.

Constructor & Destructor Documentation

Stage1Layer2EGammaAlgorithmImpPP::Stage1Layer2EGammaAlgorithmImpPP ( CaloParamsHelper params)

Definition at line 25 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

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

Definition at line 27 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

27 {};

Member Function Documentation

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

Definition at line 211 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

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

212  {
213 
214  bool Debug=false;
215 
216  if (Debug) cout << "Number of jets: " << jets->size() << endl;
217  int pt = -1;
218 
219 
220  for(JetBxCollection::const_iterator itJet = jets->begin();
221  itJet != jets->end(); ++itJet){
222 
223  int jetEta = itJet->hwEta();
224  int jetPhi = itJet->hwPhi();
225  if (Debug) cout << "Matching ETA: " << ieta << " " << jetEta << endl;
226  if (Debug) cout << "Matching PHI: " << iphi << " " << jetPhi << endl;
227  if ((jetEta == ieta) && (jetPhi == iphi)){
228  pt = itJet->hwPt();
229  break;
230  }
231  }
232 
233  // set output
234  return pt;
235 }
vector< PseudoJet > jets
tuple cout
Definition: gather_cfg.py:121
const bool Debug
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:16
double l1t::Stage1Layer2EGammaAlgorithmImpPP::HoverE ( int  et,
int  ieta,
int  iphi,
const std::vector< l1t::CaloRegion > &  regions 
) const
private

--— Compute H/E -----------------—

Definition at line 240 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

References HLT_25ns14e33_v3_cff::region.

241  {
242  int hadronicET = 0;
243 
244  for(CaloRegionBxCollection::const_iterator region = regions.begin();
245  region != regions.end(); region++) {
246 
247  int regionET = region->hwPt();
248  int regionPhi = region->hwPhi();
249  int regionEta = region->hwEta();
250 
251  if(iphi == regionPhi && ieta == regionEta) {
252  hadronicET = regionET;
253  break;
254  }
255  }
256 
257  hadronicET -= et;
258 
259  double hoe = 0.0;
260 
261  if( hadronicET >0 && et > 0)
262  hoe = (double) hadronicET / (double) et;
263 
264  // set output
265  return hoe;
266 }
std::vector< CaloRegion >::const_iterator const_iterator
Definition: BXVector.h:16
double l1t::Stage1Layer2EGammaAlgorithmImpPP::Isolation ( int  ieta,
int  iphi,
const std::vector< l1t::CaloRegion > &  regions 
) const
private

--— Compute isolation sum -----------------—

Definition at line 175 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

References funct::abs(), HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, L1CaloRegionDetId::N_PHI, and HLT_25ns14e33_v3_cff::region.

176  {
177  double isolation = 0;
178 
179  for(CaloRegionBxCollection::const_iterator region = regions.begin();
180  region != regions.end(); region++) {
181 
182  int regionPhi = region->hwPhi();
183  int regionEta = region->hwEta();
184  unsigned int deltaPhi = iphi - regionPhi;
185  if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1)
186  deltaPhi = -deltaPhi/std::abs(deltaPhi); //18 regions in phi
187 
188  unsigned int deltaEta = std::abs(ieta - regionEta);
189 
190  if ((deltaPhi + deltaEta) > 0 && deltaPhi < 2 && deltaEta < 2)
191  isolation += region->hwPt();
192  }
193 
194  // set output
195  return isolation;
196 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const unsigned N_PHI
std::vector< CaloRegion >::const_iterator const_iterator
Definition: BXVector.h:16
unsigned l1t::Stage1Layer2EGammaAlgorithmImpPP::isoLutIndex ( unsigned int  etaPt,
unsigned int  jetPt 
) const
private

Definition at line 199 of file Stage1Layer2EGammaAlgorithmImpPP.cc.

200 {
201  const unsigned int nbitsEG=6; // number of bits used for EG bins in LUT file (needed for left shift operation)
202  // const unsigned int nbitsJet=9; // not used but here for info number of bits used for Jet bins in LUT file
203 
204  unsigned int address= (jetPt << nbitsEG) + egPt;
205  // std::cout << address << "\t## " << egPt << " " << jetPt << std::endl;
206  return address;
207 }
void l1t::Stage1Layer2EGammaAlgorithmImpPP::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 Stage1Layer2EGammaAlgorithmImpPP.cc.

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

31  {
32 
33 
34  double egLsb=params_->egLsb();
35  double jetLsb=params_->jetLsb();
36  int egSeedThreshold= floor( params_->egSeedThreshold()/egLsb + 0.5);
37  int jetSeedThreshold= floor( params_->jetSeedThreshold()/jetLsb + 0.5);
38  int egMinPtJetIsolation = params_->egMinPtJetIsolation();
39  int egMaxPtJetIsolation = params_->egMaxPtJetIsolation();
40  int egMinPtHOverEIsolation = params_->egMinPtHOverEIsolation();
41  int egMaxPtHOverEIsolation = params_->egMaxPtHOverEIsolation();
42 
43  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
44  std::vector<l1t::EGamma> *preSortEGammas = new std::vector<l1t::EGamma>();
45  std::vector<l1t::EGamma> *preGtEGammas = new std::vector<l1t::EGamma>();
46 
47 
48  //Region Correction will return uncorrected subregions if
49  //regionPUSType is set to None in the config
50  RegionCorrection(regions, subRegions, params_);
51 
52  // ----- need to cluster jets in order to compute jet isolation ----
53  std::vector<l1t::Jet> *unCorrJets = new std::vector<l1t::Jet>();
54  // slidingWindowJetFinder(jetSeedThreshold, subRegions, unCorrJets);
55  TwelveByTwelveFinder(jetSeedThreshold, subRegions, unCorrJets);
56 
57 
58  for(CaloEmCandBxCollection::const_iterator egCand = EMCands.begin();
59  egCand != EMCands.end(); egCand++) {
60 
61  int eg_et = egCand->hwPt();
62  int eg_eta = egCand->hwEta();
63  int eg_phi = egCand->hwPhi();
64  int index = (egCand->hwIso()*4 + egCand->hwQual()) ;
65 
66  //std::cout << "JetRankMax: " << params_->jetScale().rankScaleMax()<< " EmRankMax: " << params_->emScale().rankScaleMax()<< std::endl;
67  //std::cout << "JetLinMax: " << params_->jetScale().linScaleMax()<< " EmLinMax: " << params_->emScale().linScaleMax()<< std::endl;
68  if(eg_et <= egSeedThreshold) continue;
69 
70  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > egLorentz(0,0,0,0);
71 
72  //int quality = 1;
73  int isoFlag = 0;
74  int isoFlagRct = 0;
75 
76  // 3x3 HoE, computed in 3x3
77  if(eg_et>=egMinPtHOverEIsolation && eg_et < egMaxPtHOverEIsolation ) {
78  if(egCand->hwIso()) isoFlagRct =1;
79  }
80  else {isoFlagRct =1;}
81 
82  int ijet_pt=AssociatedJetPt(eg_eta,eg_phi,unCorrJets);
83  // double jet_pt=ijet_pt*jetLsb;
84  bool isinBarrel = (eg_eta>=7 && eg_eta<=14);
85  if (ijet_pt>0 && eg_et>=egMinPtJetIsolation && eg_et<egMaxPtJetIsolation){
86 
87  // Combined Barrel/Endcap LUT uses upper bit to indicate Barrel / Endcap:
88  enum {MAX_LUT_ADDRESS = 0x7fff};
89  enum {LUT_BARREL_OFFSET = 0x0, LUT_ENDCAP_OFFSET = 0x8000};
90 
91  unsigned int lutAddress = isoLutIndex(eg_et,ijet_pt);
92 
93  if (eg_et >0){
94  if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
95  if (isinBarrel){
96  isoFlag= params_->egIsolationLUT()->data(LUT_BARREL_OFFSET + lutAddress);
97  } else{
98  isoFlag= params_->egIsolationLUT()->data(LUT_ENDCAP_OFFSET + lutAddress);
99  }
100  // if (eg_et>20) std::cout << "EG pt: " << eg_et << " Jet pt: " << ijet_pt << ",r: " << ijet_pt*jetLsb << " Address: " << lutAddress << " max: " << params_->egIsolationLUT()->maxSize() << " isol: " << isoFlag << std::endl;
101  }
102 
103 
104  }else{ // no associated jet; assume it's an isolated eg
105  isoFlag=1;
106  }
107 
108  int fullIsoFlag=isoFlag*isoFlagRct;
109 
110  // double hoe = HoverE(eg_et, eg_eta, eg_phi, *subRegions);
111  //if(eg_et>20)
112  //std::cout << "eg/jet/isol/relisol: " << eg_et << " / " << ijet_pt << " /\t " << isoFlag << " "<< isoFlagRct << " "<<fullIsoFlag<<" "<<egCand->hwIso()<<std::endl;
113 
114  // ------- fill the EG candidate vector ---------
115  l1t::EGamma theEG(*&egLorentz, eg_et, eg_eta, eg_phi, index, fullIsoFlag);
116  //?? if( hoe < HoverECut) egammas->push_back(theEG);
117  preSortEGammas->push_back(theEG);
118  }
119 
120  // printf("Pre-Sort\n");
121  // for(std::vector<l1t::EGamma>::const_iterator itEGamma = preSortEGammas->begin();
122  // itEGamma != preSortEGammas->end(); ++itEGamma){
123  // std::cout << itEGamma->hwPt() << " " << itEGamma->hwEta() << " " << itEGamma->hwPhi() << std::endl;
124  // }
125 
126  SortEGammas(preSortEGammas, preGtEGammas);
127 
128  EGammaToGtScales(params_, preGtEGammas, egammas);
129 
130  // printf("Post-Sort\n");
131  // for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
132  // itEGamma != egammas->end(); ++itEGamma){
133  // std::cout << itEGamma->hwPt() << " " << itEGamma->hwEta() << " " << itEGamma->hwPhi() << std::endl;
134  // }
135 
136  const bool verbose = false;
137  if(verbose)
138  {
139  int cEGammas = 0;
140  int fEGammas = 0;
141  printf("EGammas Isolated\n");
142  for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
143  itEGamma != egammas->end(); ++itEGamma){
144  if(itEGamma->hwIso() != 1) continue;
145  cEGammas++;
146  unsigned int packed = pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
147  cout << bitset<15>(packed).to_string() << endl;
148  if(cEGammas == 4) break;
149  }
150 
151  printf("EGammas Non-isolated\n");
152  //printf("pt\teta\tphi\n");
153  for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
154  itEGamma != egammas->end(); ++itEGamma){
155  if(itEGamma->hwIso() != 0) continue;
156  fEGammas++;
157  unsigned int packed = pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
158  cout << bitset<15>(packed).to_string() << endl;
159  if(fEGammas == 4) break;
160  }
161  }
162 
163  delete subRegions;
164  delete unCorrJets;
165  delete preSortEGammas;
166  delete preGtEGammas;
167 
168 }
int egMinPtHOverEIsolation() const
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
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) --------— ...
int egMinPtJetIsolation() const
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)
int egMaxPtHOverEIsolation() const
double egLsb() const
double egSeedThreshold() const
std::string to_string(const T &t)
Definition: Logger.cc:26
double jetLsb() const
void SortEGammas(std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
int egMaxPtJetIsolation() const
unsigned int pack15bits(int pt, int eta, int phi)
unsigned isoLutIndex(unsigned int etaPt, unsigned int jetPt) const
int data(unsigned int address) const
Definition: LUT.h:46
double jetSeedThreshold() const
std::vector< CaloEmCand >::const_iterator const_iterator
Definition: BXVector.h:16

Member Data Documentation

CaloParamsHelper* const l1t::Stage1Layer2EGammaAlgorithmImpPP::params_
private

Definition at line 35 of file Stage1Layer2EGammaAlgorithmImp.h.