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

#include <Stage1Layer2TauAlgorithmImp.h>

Inheritance diagram for l1t::Stage1Layer2TauAlgorithmImpHW:
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)
 
 Stage1Layer2TauAlgorithmImpHW (CaloParamsHelper *params)
 
virtual ~Stage1Layer2TauAlgorithmImpHW ()
 
- 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

Stage1TauIsolationLUTisoTauLut
 
CaloParamsHelper *const params_
 

Additional Inherited Members

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

Detailed Description

Definition at line 54 of file Stage1Layer2TauAlgorithmImp.h.

Constructor & Destructor Documentation

Stage1Layer2TauAlgorithmImpHW::Stage1Layer2TauAlgorithmImpHW ( CaloParamsHelper params)

Definition at line 25 of file Stage1Layer2TauAlgorithmImpHW.cc.

References isoTauLut, and params_.

Stage1Layer2TauAlgorithmImpHW::~Stage1Layer2TauAlgorithmImpHW ( )
virtual

Definition at line 31 of file Stage1Layer2TauAlgorithmImpHW.cc.

References isoTauLut.

31  {
32  delete isoTauLut;
33 };

Member Function Documentation

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

Definition at line 250 of file Stage1Layer2TauAlgorithmImpHW.cc.

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

251  {
252 
253  bool Debug=false;
254 
255  if (Debug) cout << "Number of jets: " << jets->size() << endl;
256  int pt = -1;
257 
258 
259  for(JetBxCollection::const_iterator itJet = jets->begin();
260  itJet != jets->end(); ++itJet){
261 
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)){
267  pt = itJet->hwPt();
268  break;
269  }
270  }
271 
272  // set output
273  return pt;
274 }
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::Stage1Layer2TauAlgorithmImpHW::findNESW ( int  ieta,
int  iphi,
int  neta,
int  nphi 
) const
private

Definition at line 221 of file Stage1Layer2TauAlgorithmImpHW.cc.

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

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

Definition at line 276 of file Stage1Layer2TauAlgorithmImpHW.cc.

References funct::pow().

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

Definition at line 202 of file Stage1Layer2TauAlgorithmImpHW.cc.

References metsig::jet.

203  {
204 
206  jet != jets.end(); jet++) {
207 
208  if (ieta==jet->hwEta() && iphi==jet->hwPhi()){
209 
210  double isolation = (double) (jet->hwPt() - et);
211  return isolation/et;
212  }
213  }
214 
215  // set output
216  return 999.;
217 }
vector< PseudoJet > jets
std::vector< Jet >::const_iterator const_iterator
Definition: BXVector.h:16
void l1t::Stage1Layer2TauAlgorithmImpHW::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 38 of file Stage1Layer2TauAlgorithmImpHW.cc.

References funct::abs(), l1t::calibrateAndRankTaus(), gather_cfg::cout, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, L1CaloRegionDetId::N_PHI, l1t::pack15bits(), HLT_25ns14e33_v1_cff::quality, HLT_25ns14e33_v3_cff::region, l1t::RegionCorrection(), l1t::SortTaus(), l1t::TauToGtEtaScales(), cond::to_string(), and l1t::TwelveByTwelveFinder().

41  {
42 
43  double towerLsb = params_->towerLsbSum();
44 
45  int tauSeedThreshold= floor( params_->tauSeedThreshold()/towerLsb + 0.5); // convert GeV to HW units
46  int tauNeighbourThreshold= floor( params_->tauNeighbourThreshold()/towerLsb + 0.5); // convert GeV to HW units
47  int tauMaxPtTauVeto = floor( params_->tauMaxPtTauVeto()/towerLsb + 0.5);
48  int isoTauEtaMin = params_->isoTauEtaMin();
49  int isoTauEtaMax = params_->isoTauEtaMax();
50 
51  std::vector<l1t::CaloRegion> *subRegions = new std::vector<l1t::CaloRegion>();
52 
53 
54  //Region Correction will return uncorrected subregions if
55  //regionPUSType is set to None in the config
56  RegionCorrection(regions, subRegions, params_);
57 
58 
59 
60  // ----- need to cluster jets in order to compute jet isolation ----
61  std::vector<l1t::Jet> *unCorrJets = new std::vector<l1t::Jet>();
62  TwelveByTwelveFinder(0, 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  if(region->hwEta() < 4 || region->hwEta() > 17)
74  continue;
75 
76  int regionEt = region->hwPt();
77  if(regionEt < tauSeedThreshold) continue;
78 
79  int regionEta = region->hwEta();
80  int regionPhi = region->hwPhi();
81 
82  int tauEt = regionEt;
83  int isoFlag = 0; // is 1 if it passes the relative jet iso requirement
84  int quality = 0; //doesn't really mean anything and isn't used
85 
86  int highestNeighborEt=-1;
87  int highestNeighborEta=-1;
88  int highestNeighborPhi=-1;
89  int highestNeighborTauVeto=-1;
90 
91  //Find neighbor with highest Et
92  for(CaloRegionBxCollection::const_iterator neighbor = subRegions->begin();
93  neighbor != subRegions->end(); neighbor++) {
94 
95  int neighborPhi = neighbor->hwPhi();
96  int neighborEta = neighbor->hwEta();
97  if(neighborEta < 4 || neighborEta > 17)
98  continue;
99 
100  int deltaPhi = regionPhi - neighborPhi;
101  if (std::abs(deltaPhi) == L1CaloRegionDetId::N_PHI-1)
102  deltaPhi = -deltaPhi/std::abs(deltaPhi); //18 regions in phi
103 
104  deltaPhi = std::abs(deltaPhi);
105  int deltaEta = std::abs(regionEta - neighborEta);
106 
107  if (deltaPhi + deltaEta > 0 && deltaPhi + deltaEta < 2) { //nondiagonal neighbors
108  if (neighbor->hwPt() > highestNeighborEt) {
109  highestNeighborEt = neighbor->hwPt();
110  highestNeighborEta = neighbor->hwEta();
111  highestNeighborPhi = neighbor->hwPhi();
112  highestNeighborTauVeto = neighbor->hwQual() & 0x1; // tauVeto should be the first bit of quality integer
113  }
114  }
115  }
116 
117  string NESW = findNESW(regionEta, regionPhi, highestNeighborEta, highestNeighborPhi);
118 
119  if((tauEt > highestNeighborEt && (NESW=="isEast" || NESW=="isNorth"))
120  || (tauEt >= highestNeighborEt && (NESW=="isSouth" || NESW=="isWest"))
121  || highestNeighborEt == 0 ) {
122 
123  if (highestNeighborEt >= tauNeighbourThreshold) tauEt += highestNeighborEt;
124 
125  int regionTauVeto = region->hwQual() & 0x1; // tauVeto should be the first bit of quality integer
126 
127  // compute relative jet isolation
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);
131  if (jetEt>0){
132  unsigned int MAX_LUT_ADDRESS = params_->tauIsolationLUT()->maxSize()-1;
133  // unsigned int lutAddress = isoLutIndex(tauEt,jetEt);
134  unsigned lutAddress = isoTauLut->lutAddress(tauEt,jetEt);
135  if (tauEt >0){
136  if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
137  isoFlag = params_->tauIsolationLUT()->data(lutAddress);
138  // isoFlag= isoTauLut->lutPayload(lutAddress);
139  // if (isoFlag != params_->tauIsolationLUT()->data(lutAddress)) std::cout << "XXX -- isoFlag: " << isoFlag << "\tisoFlag2: " << params_->tauIsolationLUT()->data(lutAddress) << std::endl;
140  }
141 
142  }else{ // no associated jet
143  isoFlag=1;
144  }
145  }
146  }
147 
148  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > tauLorentz(0,0,0,0);
149 
150  l1t::Tau theTau(*&tauLorentz, tauEt, region->hwEta(), region->hwPhi(), quality, isoFlag);
151 
152  preGtTaus->push_back(theTau);
153  if(isoFlag)
154  preGtIsoTaus->push_back(theTau);
155  }
156  }
157 
158  // TauToGtPtScales(params_, preGtTaus, preRankTaus);
159  // TauToGtPtScales(params_, preGtIsoTaus, preRankIsoTaus);
160  calibrateAndRankTaus(params_,preGtTaus,preSortTaus);
161  calibrateAndRankTaus(params_,preGtIsoTaus, preSortIsoTaus);
162 
163  SortTaus(preSortTaus, sortedTaus);
164  SortTaus(preSortIsoTaus, sortedIsoTaus);
165 
166  TauToGtEtaScales(params_, sortedTaus, taus);
167  TauToGtEtaScales(params_, sortedIsoTaus, isoTaus);
168 
169  // set all filler taus to have isolation bit set
170  for(std::vector<l1t::Tau>::iterator iTau = isoTaus->begin(); iTau != isoTaus->end(); ++iTau)
171  iTau->setHwIso(1);
172 
173  delete subRegions;
174  delete unCorrJets;
175  delete preGtTaus;
176  delete preSortTaus;
177  delete sortedTaus;
178  delete preGtIsoTaus;
179  delete preSortIsoTaus;
180  delete sortedIsoTaus;
181 
182  const bool verbose = false;
183  if(verbose)
184  {
185  std::cout << "Taus" << std::endl;
186  for(std::vector<l1t::Tau>::const_iterator iTau = taus->begin(); iTau != taus->end(); ++iTau)
187  {
188  unsigned int packed = pack15bits(iTau->hwPt(), iTau->hwEta(), iTau->hwPhi());
189  std::cout << bitset<15>(packed).to_string() << std::endl;
190  }
191  std::cout << "Isolated Taus" << std::endl;
192  for(std::vector<l1t::Tau>::const_iterator iTau = isoTaus->begin(); iTau != isoTaus->end(); ++iTau)
193  {
194  unsigned int packed = pack15bits(iTau->hwPt(), iTau->hwEta(), iTau->hwPhi());
195  std::cout << bitset<15>(packed).to_string() << std::endl;
196  }
197  }
198 }
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)
unsigned int maxSize() const
Definition: LUT.h:53
double tauMaxPtTauVeto() const
Definition: Tau.h:13
double tauNeighbourThreshold() const
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)
Definition: Logger.cc:26
string findNESW(int ieta, int iphi, int neta, int nphi) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int AssociatedJetPt(int ieta, int iphi, const std::vector< l1t::Jet > *jets) const
unsigned int pack15bits(int pt, int eta, int phi)
unsigned lutAddress(unsigned int, unsigned int) const
double tauSeedThreshold() const
double towerLsbSum() const
tuple cout
Definition: gather_cfg.py:121
int data(unsigned int address) const
Definition: LUT.h:46
static const unsigned N_PHI
l1t::LUT * tauIsolationLUT()
std::vector< CaloRegion >::const_iterator const_iterator
Definition: BXVector.h:16

Member Data Documentation

Stage1TauIsolationLUT* l1t::Stage1Layer2TauAlgorithmImpHW::isoTauLut
private
CaloParamsHelper* const l1t::Stage1Layer2TauAlgorithmImpHW::params_
private

Definition at line 65 of file Stage1Layer2TauAlgorithmImp.h.

Referenced by Stage1Layer2TauAlgorithmImpHW().