24 Stage1Layer2TauAlgorithmImpPP::Stage1Layer2TauAlgorithmImpPP(
CaloParamsHelper* params) : params_(params)
34 const std::vector<l1t::CaloRegion> & regions,
35 std::vector<l1t::Tau> * isoTaus,
36 std::vector<l1t::Tau> * taus) {
38 double towerLsb = params_->towerLsbSum();
40 int tauSeedThreshold= floor( params_->tauSeedThreshold()/towerLsb + 0.5);
41 int tauNeighbourThreshold= floor( params_->tauNeighbourThreshold()/towerLsb + 0.5);
42 int jetSeedThreshold= floor( params_->jetSeedThreshold()/towerLsb + 0.5);
43 int tauMaxPtTauVeto = floor( params_->tauMaxPtTauVeto()/towerLsb + 0.5);
44 int tauMinPtJetIsolationB = floor( params_->tauMinPtJetIsolationB()/towerLsb + 0.5);
45 int isoTauEtaMin = params_->isoTauEtaMin();
46 int isoTauEtaMax = params_->isoTauEtaMax();
47 double tauMaxJetIsolationB = params_->tauMaxJetIsolationB();
48 double tauMaxJetIsolationA = params_->tauMaxJetIsolationA();
50 std::vector<l1t::CaloRegion> *subRegions =
new std::vector<l1t::CaloRegion>();
60 std::vector<l1t::Jet> *unCorrJets =
new std::vector<l1t::Jet>();
64 std::vector<l1t::Tau> *preGtTaus =
new std::vector<l1t::Tau>();
65 std::vector<l1t::Tau> *preSortTaus =
new std::vector<l1t::Tau>();
66 std::vector<l1t::Tau> *sortedTaus =
new std::vector<l1t::Tau>();
67 std::vector<l1t::Tau> *preGtIsoTaus =
new std::vector<l1t::Tau>();
68 std::vector<l1t::Tau> *preSortIsoTaus =
new std::vector<l1t::Tau>();
69 std::vector<l1t::Tau> *sortedIsoTaus =
new std::vector<l1t::Tau>();
74 int regionEt =
region->hwPt();
75 if(regionEt < tauSeedThreshold)
continue;
77 int regionEta =
region->hwEta();
78 if(regionEta < 4 || regionEta > 17)
80 int regionPhi =
region->hwPhi();
90 int highestNeighborEt=0;
91 int highestNeighborEta=999;
92 int highestNeighborPhi=999;
93 int highestNeighborTauVeto=999;
99 neighbor != subRegions->end(); neighbor++) {
101 int neighborPhi = neighbor->hwPhi();
102 int neighborEta = neighbor->hwEta();
103 if(neighborEta < 4 || neighborEta > 17)
106 int deltaPhi = regionPhi - neighborPhi;
108 deltaPhi = -deltaPhi/
std::abs(deltaPhi);
113 if (deltaPhi + deltaEta > 0 && deltaPhi + deltaEta < 2) {
114 if (neighbor->hwPt() > highestNeighborEt) {
115 highestNeighborEt = neighbor->hwPt();
116 highestNeighborEta = neighbor->hwEta();
117 highestNeighborPhi = neighbor->hwPhi();
118 int neighborTauVeto = neighbor->hwQual() & 0x1;
119 highestNeighborTauVeto = neighborTauVeto;
125 string NESW = findNESW(regionEta, regionPhi, highestNeighborEta, highestNeighborPhi);
128 if((tauEt > highestNeighborEt && (NESW==
"isEast" || NESW==
"isNorth"))
129 || (tauEt >= highestNeighborEt && (NESW==
"isSouth" || NESW==
"isWest"))
130 || highestNeighborEt == 0 ) {
132 if (highestNeighborEt >= tauNeighbourThreshold) tauEt += highestNeighborEt;
134 int regionTauVeto =
region->hwQual() & 0x1;
138 if (
region->hwEta() >= isoTauEtaMin &&
region->hwEta() <= isoTauEtaMax ){
139 if ((highestNeighborTauVeto == 0 && regionTauVeto == 0) || tauEt > tauMaxPtTauVeto) {
140 bool useIsolLut=
true;
142 int jetEt=AssociatedJetPt(
region->hwEta(),
region->hwPhi(),unCorrJets);
144 unsigned int MAX_LUT_ADDRESS = params_->tauIsolationLUT()->maxSize()-1;
145 unsigned int lutAddress = isoLutIndex(tauEt,jetEt);
147 if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
148 isoFlag= params_->tauIsolationLUT()->data(lutAddress);
154 double jetIsolation = JetIsolation(tauEt,
region->hwEta(),
region->hwPhi(), *unCorrJets);
155 if (jetIsolation < tauMaxJetIsolationA || (tauEt >= tauMinPtJetIsolationB && jetIsolation < tauMaxJetIsolationB)
156 || (
std::abs(jetIsolation - 999.) < 0.1) ) isoFlag=1;
162 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > tauLorentz(0,0,0,0);
166 preGtTaus->push_back(theTau);
168 preGtIsoTaus->push_back(theTau);
175 SortTaus(preSortIsoTaus, sortedIsoTaus);
186 delete preSortIsoTaus;
187 delete sortedIsoTaus;
196 const std::vector<l1t::Jet> &
jets)
const {
199 jet != jets.end();
jet++) {
201 if (ieta==
jet->hwEta() && iphi==
jet->hwPhi()){
218 deltaPhi = -deltaPhi/
std::abs(deltaPhi);
226 else if (deltaEta==0) {
244 const std::vector<l1t::Jet> *
jets)
const {
248 if (Debug)
cout <<
"Number of jets: " << jets->size() << endl;
253 itJet != jets->end(); ++itJet){
255 int jetEta = itJet->hwEta();
256 int jetPhi = itJet->hwPhi();
257 if (Debug)
cout <<
"Matching ETA: " << ieta <<
" " << jetEta << endl;
258 if (Debug)
cout <<
"Matching PHI: " << iphi <<
" " << jetPhi << endl;
259 if ((jetEta == ieta) && (jetPhi == iphi)){
274 const unsigned int nbitsTau=8;
275 const unsigned int nbitsJet=8;
277 const unsigned int maxJet =
pow(2,nbitsJet)-1;
278 const unsigned int maxTau =
pow(2,nbitsTau)-1;
286 else if (nbitsTau == 7)
290 else if (nbitsTau == 8)
302 else if (nbitsJet == 7)
306 else if (nbitsJet == 8)
312 if (jetPt>maxJet) jetPt=maxJet;
313 if (tauPt>maxTau) tauPt=maxTau;
315 unsigned int address= (jetPt << nbitsTau) + tauPt;
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) --------— ...
void TauToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
virtual void processEvent(const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::CaloRegion > ®ions, std::vector< l1t::Tau > *isoTaus, std::vector< l1t::Tau > *taus)
void TwelveByTwelveFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
void SortTaus(std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
string findNESW(int ieta, int iphi, int neta, int nphi) const
Abs< T >::type abs(const T &t)
unsigned isoLutIndex(unsigned int tauPt, unsigned int jetPt) const
virtual ~Stage1Layer2TauAlgorithmImpPP()
double JetIsolation(int et, int ieta, int iphi, const std::vector< l1t::Jet > &jets) const
static const unsigned N_PHI
void TauToGtPtScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
Power< A, B >::type pow(const A &a, const B &b)
std::vector< CaloRegion >::const_iterator const_iterator