25 Stage1Layer2EGammaAlgorithmImpPP::Stage1Layer2EGammaAlgorithmImpPP(
CaloParamsHelper* params) : params_(params) {};
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();
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>();
53 std::vector<l1t::Jet> *unCorrJets =
new std::vector<l1t::Jet>();
59 egCand != EMCands.end(); egCand++) {
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()) ;
68 if(eg_et <= egSeedThreshold)
continue;
70 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > egLorentz(0,0,0,0);
77 if(eg_et>=egMinPtHOverEIsolation && eg_et < egMaxPtHOverEIsolation ) {
78 if(egCand->hwIso()) isoFlagRct =1;
82 int ijet_pt=AssociatedJetPt(eg_eta,eg_phi,unCorrJets);
84 bool isinBarrel = (eg_eta>=7 && eg_eta<=14);
85 if (ijet_pt>0 && eg_et>=egMinPtJetIsolation && eg_et<egMaxPtJetIsolation){
88 enum {MAX_LUT_ADDRESS = 0x7fff};
89 enum {LUT_BARREL_OFFSET = 0x0, LUT_ENDCAP_OFFSET = 0x8000};
91 unsigned int lutAddress = isoLutIndex(eg_et,ijet_pt);
94 if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
96 isoFlag= params_->egIsolationLUT()->data(LUT_BARREL_OFFSET + lutAddress);
98 isoFlag= params_->egIsolationLUT()->data(LUT_ENDCAP_OFFSET + lutAddress);
108 int fullIsoFlag=isoFlag*isoFlagRct;
115 l1t::EGamma theEG(*&egLorentz, eg_et, eg_eta, eg_phi, index, fullIsoFlag);
117 preSortEGammas->push_back(theEG);
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;
146 unsigned int packed =
pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
147 cout << bitset<15>(packed).
to_string() << endl;
148 if(cEGammas == 4)
break;
151 printf(
"EGammas Non-isolated\n");
153 for(std::vector<l1t::EGamma>::const_iterator itEGamma = egammas->begin();
154 itEGamma != egammas->end(); ++itEGamma){
155 if(itEGamma->hwIso() != 0)
continue;
157 unsigned int packed =
pack15bits(itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi());
158 cout << bitset<15>(packed).
to_string() << endl;
159 if(fEGammas == 4)
break;
165 delete preSortEGammas;
176 const std::vector<l1t::CaloRegion> & regions)
const {
182 int regionPhi =
region->hwPhi();
183 int regionEta =
region->hwEta();
184 unsigned int deltaPhi = iphi - regionPhi;
186 deltaPhi = -deltaPhi/
std::abs(deltaPhi);
190 if ((deltaPhi + deltaEta) > 0 && deltaPhi < 2 && deltaEta < 2)
191 isolation +=
region->hwPt();
201 const unsigned int nbitsEG=6;
204 unsigned int address= (jetPt << nbitsEG) + egPt;
212 const std::vector<l1t::Jet> *
jets)
const {
216 if (Debug)
cout <<
"Number of jets: " << jets->size() << endl;
221 itJet != jets->end(); ++itJet){
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)){
241 const std::vector<l1t::CaloRegion> & regions)
const {
247 int regionET =
region->hwPt();
248 int regionPhi =
region->hwPhi();
249 int regionEta =
region->hwEta();
251 if(iphi == regionPhi && ieta == regionEta) {
252 hadronicET = regionET;
261 if( hadronicET >0 && et > 0)
262 hoe = (double) hadronicET / (
double) et;
double HoverE(int et, int ieta, int iphi, const std::vector< l1t::CaloRegion > ®ions) const
--— Compute H/E -----------------—
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
void RegionCorrection(const std::vector< l1t::CaloRegion > ®ions, std::vector< l1t::CaloRegion > *subRegions, CaloParamsHelper *params)
------— New region correction (PUsub, no response correction at the moment) --------— ...
virtual ~Stage1Layer2EGammaAlgorithmImpPP()
double Isolation(int ieta, int iphi, const std::vector< l1t::CaloRegion > ®ions) const
--— Compute isolation sum -----------------—
virtual void processEvent(const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::CaloRegion > ®ions, const std::vector< l1t::Jet > *jets, std::vector< l1t::EGamma > *egammas)
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)
void SortEGammas(std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
Abs< T >::type abs(const T &t)
unsigned int pack15bits(int pt, int eta, int phi)
unsigned isoLutIndex(unsigned int etaPt, unsigned int jetPt) const
static const unsigned N_PHI
std::vector< CaloEmCand >::const_iterator const_iterator