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

#include <Stage1Layer2TauAlgorithmImp.h>

Inheritance diagram for l1t::Stage1Layer2TauAlgorithmImpPP:
l1t::Stage1Layer2TauAlgorithm

Public Member Functions

virtual void processEvent (const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::CaloRegion > &regions, std::vector< l1t::Tau > *isoTaus, std::vector< l1t::Tau > *taus)
 
 Stage1Layer2TauAlgorithmImpPP (CaloParamsHelper *params)
 
virtual ~Stage1Layer2TauAlgorithmImpPP ()
 
- Public Member Functions inherited from l1t::Stage1Layer2TauAlgorithm
virtual ~Stage1Layer2TauAlgorithm ()
 

Private Member Functions

int AssociatedJetPt (int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
 
string findNESW (int ieta, int iphi, int neta, int nphi) const
 
unsigned isoLutIndex (unsigned int tauPt, unsigned int jetPt) const
 
double JetIsolation (int et, int ieta, int iphi, const std::vector< l1t::Jet > &jets) const
 

Private Attributes

CaloParamsHelper *const params_
 

Additional Inherited Members

- Public Attributes inherited from l1t::Stage1Layer2TauAlgorithm
std::vector< double > regionPUSParams
 
std::string regionPUSType
 

Detailed Description

Definition at line 29 of file Stage1Layer2TauAlgorithmImp.h.

Constructor & Destructor Documentation

Stage1Layer2TauAlgorithmImpPP::Stage1Layer2TauAlgorithmImpPP ( CaloParamsHelper params)

Definition at line 24 of file Stage1Layer2TauAlgorithmImpPP.cc.

24  : params_(params)
25 {
26 }
Stage1Layer2TauAlgorithmImpPP::~Stage1Layer2TauAlgorithmImpPP ( )
virtual

Definition at line 28 of file Stage1Layer2TauAlgorithmImpPP.cc.

28 {};

Member Function Documentation

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

Definition at line 243 of file Stage1Layer2TauAlgorithmImpPP.cc.

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

244  {
245 
246  bool Debug=false;
247 
248  if (Debug) cout << "Number of jets: " << jets->size() << endl;
249  int pt = -1;
250 
251 
252  for(JetBxCollection::const_iterator itJet = jets->begin();
253  itJet != jets->end(); ++itJet){
254 
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)){
260  pt = itJet->hwPt();
261  break;
262  }
263  }
264 
265  // set output
266  return pt;
267 }
vector< PseudoJet > jets
tuple cout
Definition: gather_cfg.py:121
const bool Debug
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:16
string l1t::Stage1Layer2TauAlgorithmImpPP::findNESW ( int  ieta,
int  iphi,
int  neta,
int  nphi 
) const
private

Definition at line 214 of file Stage1Layer2TauAlgorithmImpPP.cc.

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

214  {
215 
216  int deltaPhi = iphi - nphi;
217  if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1)
218  deltaPhi = -deltaPhi/std::abs(deltaPhi); //18 regions in phi
219 
220  int deltaEta = ieta - neta;
221 
222  if ((std::abs(deltaPhi) + std::abs(deltaEta)) < 2) {
223  if (deltaEta==-1) {
224  return "isEast";
225  }
226  else if (deltaEta==0) {
227  if (deltaPhi==-1) {
228  return "isNorth";
229  }
230  if (deltaPhi==1) {
231  return "isSouth";
232  }
233  }
234  else {
235  return "isWest";
236  }
237  }
238 
239  return "999";
240 
241 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const unsigned N_PHI
unsigned l1t::Stage1Layer2TauAlgorithmImpPP::isoLutIndex ( unsigned int  tauPt,
unsigned int  jetPt 
) const
private

Definition at line 269 of file Stage1Layer2TauAlgorithmImpPP.cc.

References funct::pow().

270 {
271  //const unsigned int nbitsTau=9; // number of bits used for et in LUT file (needed for left shift operation)
272  //const unsigned int nbitsJet=9;
273 
274  const unsigned int nbitsTau=8; // number of bits used for et in LUT file (needed for left shift operation)
275  const unsigned int nbitsJet=8;
276 
277  const unsigned int maxJet = pow(2,nbitsJet)-1;
278  const unsigned int maxTau = pow(2,nbitsTau)-1;
279 
280  if (nbitsTau < 9)
281  {
282  if (nbitsTau == 6)
283  {
284  tauPt=tauPt>>3;
285  }
286  else if (nbitsTau == 7)
287  {
288  tauPt=tauPt>>2;
289  }
290  else if (nbitsTau == 8)
291  {
292  tauPt=tauPt>>1;
293  }
294  }
295 
296  if (nbitsJet < 9)// no need to do shift if nbits>=9
297  {
298  if (nbitsJet == 6)
299  {
300  jetPt=jetPt>>3;
301  }
302  else if (nbitsJet == 7)
303  {
304  jetPt=jetPt>>2;
305  }
306  else if (nbitsJet == 8)
307  {
308  jetPt=jetPt>>1;
309  }
310  }
311 
312  if (jetPt>maxJet) jetPt=maxJet;
313  if (tauPt>maxTau) tauPt=maxTau;
314 
315  unsigned int address= (jetPt << nbitsTau) + tauPt;
316  // std::cout << address << "\t## " << tauPt << " " << jetPt << std::endl;
317  return address;
318 }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double l1t::Stage1Layer2TauAlgorithmImpPP::JetIsolation ( int  et,
int  ieta,
int  iphi,
const std::vector< l1t::Jet > &  jets 
) const
private

Definition at line 195 of file Stage1Layer2TauAlgorithmImpPP.cc.

References metsig::jet.

196  {
197 
199  jet != jets.end(); jet++) {
200 
201  if (ieta==jet->hwEta() && iphi==jet->hwPhi()){
202 
203  double isolation = (double) (jet->hwPt() - et);
204  return isolation/et;
205  }
206  }
207 
208  // set output
209  return 999.;
210 }
vector< PseudoJet > jets
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:16
void l1t::Stage1Layer2TauAlgorithmImpPP::processEvent ( const std::vector< l1t::CaloEmCand > &  EMCands,
const std::vector< l1t::CaloRegion > &  regions,
std::vector< l1t::Tau > *  isoTaus,
std::vector< l1t::Tau > *  taus 
)
virtual

Implements l1t::Stage1Layer2TauAlgorithm.

Definition at line 33 of file Stage1Layer2TauAlgorithmImpPP.cc.

References funct::abs(), HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, L1CaloRegionDetId::N_PHI, HLT_25ns14e33_v1_cff::quality, HLT_25ns14e33_v3_cff::region, l1t::RegionCorrection(), l1t::SortTaus(), l1t::TauToGtEtaScales(), l1t::TauToGtPtScales(), and l1t::TwelveByTwelveFinder().

36  {
37 
38  double towerLsb = params_->towerLsbSum();
39 
40  int tauSeedThreshold= floor( params_->tauSeedThreshold()/towerLsb + 0.5); // convert GeV to HW units
41  int tauNeighbourThreshold= floor( params_->tauNeighbourThreshold()/towerLsb + 0.5); // convert GeV to HW units
42  int jetSeedThreshold= floor( params_->jetSeedThreshold()/towerLsb + 0.5); // convert GeV to HW units
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();
49 
50  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
51 
52 
53  //Region Correction will return uncorrected subregions if
54  //regionPUSType is set to None in the config
55  RegionCorrection(regions, subRegions, params_);
56 
57 
58 
59  // ----- need to cluster jets in order to compute jet isolation ----
60  std::vector<l1t::Jet> *unCorrJets = new std::vector<l1t::Jet>();
61  //slidingWindowJetFinder(jetSeedThreshold, subRegions, unCorrJets);
62  TwelveByTwelveFinder(jetSeedThreshold, subRegions, unCorrJets);
63 
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>();
70 
71  for(CaloRegionBxCollection::const_iterator region = subRegions->begin();
72  region != subRegions->end(); region++) {
73 
74  int regionEt = region->hwPt();
75  if(regionEt < tauSeedThreshold) continue;
76 
77  int regionEta = region->hwEta();
78  if(regionEta < 4 || regionEta > 17)
79  continue; // Taus cannot come from HF
80  int regionPhi = region->hwPhi();
81 
82  //int associatedSecondRegionEt =
83  // AssociatedSecondRegionEt(region->hwEta(), region->hwPhi(),
84  // *subRegions);
85 
86  int tauEt=regionEt;
87  int isoFlag=0; // is 1 if it passes the relative jet iso requirement
88  int quality = 1; //doesn't really mean anything and isn't used
89 
90  int highestNeighborEt=0;
91  int highestNeighborEta=999;
92  int highestNeighborPhi=999;
93  int highestNeighborTauVeto=999;
94 
95  // if (regionEt>0) std::cout << "CCLA Prod: TauVeto: " << region->hwQual() << "\tET: " << regionEt << "\tETA: " << regionEta << "\tPhi: " << regionPhi << std::endl;
96 
97  //Find neighbor with highest Et
98  for(CaloRegionBxCollection::const_iterator neighbor = subRegions->begin();
99  neighbor != subRegions->end(); neighbor++) {
100 
101  int neighborPhi = neighbor->hwPhi();
102  int neighborEta = neighbor->hwEta();
103  if(neighborEta < 4 || neighborEta > 17)
104  continue; // Taus cannot come from HF
105 
106  int deltaPhi = regionPhi - neighborPhi;
107  if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1)
108  deltaPhi = -deltaPhi/std::abs(deltaPhi); //18 regions in phi
109 
110  deltaPhi = std::abs(deltaPhi);
111  int deltaEta = std::abs(regionEta - neighborEta);
112 
113  if (deltaPhi + deltaEta > 0 && deltaPhi + deltaEta < 2) { //nondiagonal neighbors
114  if (neighbor->hwPt() > highestNeighborEt) {
115  highestNeighborEt = neighbor->hwPt();
116  highestNeighborEta = neighbor->hwEta();
117  highestNeighborPhi = neighbor->hwPhi();
118  int neighborTauVeto = neighbor->hwQual() & 0x1; // tauVeto should be the first bit of quality integer
119  highestNeighborTauVeto = neighborTauVeto;
120  }
121  }
122  }
123 
124 
125  string NESW = findNESW(regionEta, regionPhi, highestNeighborEta, highestNeighborPhi);
126 
127  //std::cout << "tau et, neighbor et " << tauEt << " " << highestNeighborEt << std::endl;
128  if((tauEt > highestNeighborEt && (NESW=="isEast" || NESW=="isNorth"))
129  || (tauEt >= highestNeighborEt && (NESW=="isSouth" || NESW=="isWest"))
130  || highestNeighborEt == 0 ) {
131 
132  if (highestNeighborEt >= tauNeighbourThreshold) tauEt += highestNeighborEt;
133 
134  int regionTauVeto = region->hwQual() & 0x1; // tauVeto should be the first bit of quality integer
135  //std::cout<< "regiontauveto, neighbor " << regionTauVeto << " " << highestNeighborTauVeto << std::endl;
136 
137  // compute relative jet isolation
138  if (region->hwEta() >= isoTauEtaMin && region->hwEta() <= isoTauEtaMax ){
139  if ((highestNeighborTauVeto == 0 && regionTauVeto == 0) || tauEt > tauMaxPtTauVeto) {
140  bool useIsolLut=true;
141  if (useIsolLut){
142  int jetEt=AssociatedJetPt(region->hwEta(), region->hwPhi(),unCorrJets);
143  if (jetEt>0){
144  unsigned int MAX_LUT_ADDRESS = params_->tauIsolationLUT()->maxSize()-1;
145  unsigned int lutAddress = isoLutIndex(tauEt,jetEt);
146  if (tauEt >0){
147  if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
148  isoFlag= params_->tauIsolationLUT()->data(lutAddress);
149  }
150  }else{ // no associated jet
151  isoFlag=1;
152  }
153  }else{
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;
157  }
158  }
159  }
160 
161 
162  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > tauLorentz(0,0,0,0);
163 
164  l1t::Tau theTau(*&tauLorentz, tauEt, region->hwEta(), region->hwPhi(), quality, isoFlag);
165 
166  preGtTaus->push_back(theTau);
167  if(isoFlag)
168  preGtIsoTaus->push_back(theTau);
169  }
170  }
171  TauToGtPtScales(params_, preGtTaus, preSortTaus);
172  TauToGtPtScales(params_, preGtIsoTaus, preSortIsoTaus);
173 
174  SortTaus(preSortTaus, sortedTaus);
175  SortTaus(preSortIsoTaus, sortedIsoTaus);
176 
177  TauToGtEtaScales(params_, sortedTaus, taus);
178  TauToGtEtaScales(params_, sortedIsoTaus, isoTaus);
179 
180  delete subRegions;
181  delete unCorrJets;
182  delete preGtTaus;
183  delete preSortTaus;
184  delete sortedTaus;
185  delete preGtIsoTaus;
186  delete preSortIsoTaus;
187  delete sortedIsoTaus;
188 }
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 TauToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
double tauMaxJetIsolationB() const
unsigned int maxSize() const
Definition: LUT.h:53
double tauMaxPtTauVeto() const
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
double tauMinPtJetIsolationB() const
Definition: Tau.h:13
double tauNeighbourThreshold() const
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)
Definition: Abs.h:22
unsigned isoLutIndex(unsigned int tauPt, unsigned int jetPt) const
double tauSeedThreshold() const
double towerLsbSum() const
double JetIsolation(int et, int ieta, int iphi, const std::vector< l1t::Jet > &jets) const
int data(unsigned int address) const
Definition: LUT.h:46
static const unsigned N_PHI
double jetSeedThreshold() const
l1t::LUT * tauIsolationLUT()
void TauToGtPtScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
std::vector< CaloRegion >::const_iterator const_iterator
Definition: BXVector.h:16
double tauMaxJetIsolationA() const

Member Data Documentation

CaloParamsHelper* const l1t::Stage1Layer2TauAlgorithmImpPP::params_
private

Definition at line 40 of file Stage1Layer2TauAlgorithmImp.h.