25 Stage1Layer2TauAlgorithmImpHW::Stage1Layer2TauAlgorithmImpHW(
CaloParamsHelper* params) : params_(params)
39 const std::vector<l1t::CaloRegion> & regions,
40 std::vector<l1t::Tau> * isoTaus,
41 std::vector<l1t::Tau> * taus) {
43 double towerLsb = params_->towerLsbSum();
45 int tauSeedThreshold= floor( params_->tauSeedThreshold()/towerLsb + 0.5);
46 int tauNeighbourThreshold= floor( params_->tauNeighbourThreshold()/towerLsb + 0.5);
47 int tauMaxPtTauVeto = floor( params_->tauMaxPtTauVeto()/towerLsb + 0.5);
48 int isoTauEtaMin = params_->isoTauEtaMin();
49 int isoTauEtaMax = params_->isoTauEtaMax();
51 std::vector<l1t::CaloRegion> *subRegions =
new std::vector<l1t::CaloRegion>();
61 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>();
76 int regionEt =
region->hwPt();
77 if(regionEt < tauSeedThreshold)
continue;
79 int regionEta =
region->hwEta();
80 int regionPhi =
region->hwPhi();
86 int highestNeighborEt=-1;
87 int highestNeighborEta=-1;
88 int highestNeighborPhi=-1;
89 int highestNeighborTauVeto=-1;
93 neighbor != subRegions->end(); neighbor++) {
95 int neighborPhi = neighbor->hwPhi();
96 int neighborEta = neighbor->hwEta();
97 if(neighborEta < 4 || neighborEta > 17)
100 int deltaPhi = regionPhi - neighborPhi;
102 deltaPhi = -deltaPhi/
std::abs(deltaPhi);
107 if (deltaPhi + deltaEta > 0 && deltaPhi + deltaEta < 2) {
108 if (neighbor->hwPt() > highestNeighborEt) {
109 highestNeighborEt = neighbor->hwPt();
110 highestNeighborEta = neighbor->hwEta();
111 highestNeighborPhi = neighbor->hwPhi();
112 highestNeighborTauVeto = neighbor->hwQual() & 0x1;
117 string NESW = findNESW(regionEta, regionPhi, highestNeighborEta, highestNeighborPhi);
119 if((tauEt > highestNeighborEt && (NESW==
"isEast" || NESW==
"isNorth"))
120 || (tauEt >= highestNeighborEt && (NESW==
"isSouth" || NESW==
"isWest"))
121 || highestNeighborEt == 0 ) {
123 if (highestNeighborEt >= tauNeighbourThreshold) tauEt += highestNeighborEt;
125 int regionTauVeto =
region->hwQual() & 0x1;
128 if (
region->hwEta() >= isoTauEtaMin &&
region->hwEta() <= isoTauEtaMax ){
129 if ((highestNeighborTauVeto == 0 && regionTauVeto == 0) || tauEt > tauMaxPtTauVeto) {
130 int jetEt=AssociatedJetPt(
region->hwEta(),
region->hwPhi(),unCorrJets);
132 unsigned int MAX_LUT_ADDRESS = params_->tauIsolationLUT()->maxSize()-1;
134 unsigned lutAddress = isoTauLut->lutAddress(tauEt,jetEt);
136 if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
137 isoFlag = params_->tauIsolationLUT()->data(lutAddress);
148 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > tauLorentz(0,0,0,0);
152 preGtTaus->push_back(theTau);
154 preGtIsoTaus->push_back(theTau);
164 SortTaus(preSortIsoTaus, sortedIsoTaus);
170 for(std::vector<l1t::Tau>::iterator iTau = isoTaus->begin(); iTau != isoTaus->end(); ++iTau)
179 delete preSortIsoTaus;
180 delete sortedIsoTaus;
186 for(std::vector<l1t::Tau>::const_iterator iTau = taus->begin(); iTau != taus->end(); ++iTau)
188 unsigned int packed =
pack15bits(iTau->hwPt(), iTau->hwEta(), iTau->hwPhi());
189 std::cout << bitset<15>(packed).
to_string() << std::endl;
191 std::cout <<
"Isolated Taus" << std::endl;
192 for(std::vector<l1t::Tau>::const_iterator iTau = isoTaus->begin(); iTau != isoTaus->end(); ++iTau)
194 unsigned int packed =
pack15bits(iTau->hwPt(), iTau->hwEta(), iTau->hwPhi());
195 std::cout << bitset<15>(packed).
to_string() << std::endl;
203 const std::vector<l1t::Jet> &
jets)
const {
206 jet != jets.end();
jet++) {
208 if (ieta==
jet->hwEta() && iphi==
jet->hwPhi()){
225 deltaPhi = -deltaPhi/
std::abs(deltaPhi);
233 else if (deltaEta==0) {
251 const std::vector<l1t::Jet> *
jets)
const {
255 if (Debug)
cout <<
"Number of jets: " << jets->size() << endl;
260 itJet != jets->end(); ++itJet){
262 int jetEta = itJet->hwEta();
263 int jetPhi = itJet->hwPhi();
264 if (Debug)
cout <<
"Matching ETA: " << ieta <<
" " << jetEta << endl;
265 if (Debug)
cout <<
"Matching PHI: " << iphi <<
" " << jetPhi << endl;
266 if ((jetEta == ieta) && (jetPhi == iphi)){
281 const unsigned int nbitsTau=8;
282 const unsigned int nbitsJet=8;
284 const unsigned int maxJet =
pow(2,nbitsJet)-1;
285 const unsigned int maxTau =
pow(2,nbitsTau)-1;
293 else if (nbitsTau == 7)
297 else if (nbitsTau == 8)
309 else if (nbitsJet == 7)
313 else if (nbitsJet == 8)
319 if (jetPt>maxJet) jetPt=maxJet;
320 if (tauPt>maxTau) tauPt=maxTau;
322 unsigned int address= (jetPt << nbitsTau) + tauPt;
double JetIsolation(int et, 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) --------— ...
void TauToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
void TwelveByTwelveFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
void calibrateAndRankTaus(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
void SortTaus(std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
std::string to_string(const T &t)
string findNESW(int ieta, int iphi, int neta, int nphi) const
unsigned isoLutIndex(unsigned int tauPt, unsigned int jetPt) const
Abs< T >::type abs(const T &t)
CaloParamsHelper *const params_
virtual ~Stage1Layer2TauAlgorithmImpHW()
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)
unsigned int pack15bits(int pt, int eta, int phi)
static const unsigned N_PHI
Stage1TauIsolationLUT * isoTauLut
Power< A, B >::type pow(const A &a, const B &b)
std::vector< CaloRegion >::const_iterator const_iterator