CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
legacyGtHelper.cc
Go to the documentation of this file.
1 // legacyGtHelper.cc
2 // Authors: Alex Barbieri
3 //
4 // This is a collection of helper methods to make sure that
5 // the objects passed to the legacy GT are using the proper
6 // Et scales and eta coordinates.
7 
9 
10 namespace l1t {
11 
13  const std::vector<l1t::Jet> * input,
14  std::vector<l1t::Jet> *output){
15 
16  for(std::vector<l1t::Jet>::const_iterator itJet = input->begin();
17  itJet != input->end(); ++itJet){
18  unsigned int pt = itJet->hwPt();
19  if(pt > ((1<<10) -1) )
20  pt = ((1<<10) -1);
21  unsigned int eta = itJet->hwEta();
22  if (eta>10){ // LUT is symmetric in eta. For eta>10 map to corresponding eta<10 bin
23  int offset=2*(eta-10)-1;
24  eta=eta-offset;
25  }
26  unsigned int lutAddress = (eta<<10)+pt;
27 
28  unsigned int rank = params->jetCalibrationLUT()->data(lutAddress);
29 
30  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
31  l1t::Jet outJet(*&ldummy, rank, itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
32  output->push_back(outJet);
33  }
34  }
35 
37  const std::vector<l1t::Tau> * input,
38  std::vector<l1t::Tau> *output){
39 
40  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
41  itTau != input->end(); ++itTau){
42  unsigned int pt = itTau->hwPt();
43  if(pt > ((1<<10) -1) )
44  pt = ((1<<10) -1);
45  unsigned int eta = itTau->hwEta();
46  unsigned int lutAddress = (eta<<10)+pt;
47 
48  unsigned int rank = params->tauCalibrationLUT()->data(lutAddress);
49 
50  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
51  l1t::Tau outTau(*&ldummy, rank, itTau->hwEta(), itTau->hwPhi(), itTau->hwQual());
52  output->push_back(outTau);
53  }
54  }
55 
56 
58  const std::vector<l1t::Jet> * input,
59  std::vector<l1t::Jet> *output){
60 
61  for(std::vector<l1t::Jet>::const_iterator itJet = input->begin();
62  itJet != input->end(); ++itJet){
63  unsigned newPhi = itJet->hwPhi();
64  unsigned newEta = gtEta(itJet->hwEta());
65 
66  // jets with hwQual & 10 ==10 are "padding" jets from a sort, set their eta and phi
67  // to the max value
68  if((itJet->hwQual() & 0x10) == 0x10)
69  {
70  newEta = 0x0;
71  newPhi = 0x0;
72  }
73 
74  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
75 
76  l1t::Jet gtJet(*&ldummy, itJet->hwPt(), newEta, newPhi, itJet->hwQual());
77  output->push_back(gtJet);
78  }
79  }
80 
82  const std::vector<l1t::Jet> * input,
83  std::vector<l1t::Jet> *output){
84 
85  for(std::vector<l1t::Jet>::const_iterator itJet = input->begin();
86  itJet != input->end(); ++itJet){
87  uint16_t linPt = (uint16_t)itJet->hwPt();
88  if(linPt > params->jetScale().linScaleMax() ) linPt = params->jetScale().linScaleMax();
89  const uint16_t rankPt = params->jetScale().rank(linPt);
90 
91  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
92 
93  l1t::Jet gtJet(*&ldummy, rankPt, itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
94  output->push_back(gtJet);
95  }
96  }
97 
98 
100  const std::vector<l1t::EGamma> * input,
101  std::vector<l1t::EGamma> *output){
102 
103  for(std::vector<l1t::EGamma>::const_iterator itEGamma = input->begin();
104  itEGamma != input->end(); ++itEGamma){
105  unsigned newEta = gtEta(itEGamma->hwEta());
106  unsigned newPhi = itEGamma->hwPhi();
107  const uint16_t rankPt = (uint16_t)itEGamma->hwPt(); //max value?
108 
109  //hwQual &10 == 10 means that the object came from a sort and is padding
110  if((itEGamma->hwQual() & 0x10) == 0x10)
111  {
112  newEta = 0x0;
113  newPhi = 0x0;
114  }
115 
116  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
117 
118  l1t::EGamma gtEGamma(*&ldummy, rankPt, newEta, newPhi,
119  itEGamma->hwQual(), itEGamma->hwIso());
120  output->push_back(gtEGamma);
121  }
122  }
123 
125  const std::vector<l1t::Tau> * input,
126  std::vector<l1t::Tau> *output){
127  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
128  itTau != input->end(); ++itTau){
129  unsigned newPhi = itTau->hwPhi();
130  unsigned newEta = gtEta(itTau->hwEta());
131 
132  // taus with hwQual & 10 ==10 are "padding" jets from a sort, set their eta and phi
133  // to the max value
134  if((itTau->hwQual() & 0x10) == 0x10)
135  {
136  newEta = 0x0;
137  newPhi = 0x0;
138  }
139 
140 
141  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
142 
143  l1t::Tau gtTau(*&ldummy, itTau->hwPt(), newEta, newPhi, itTau->hwQual(), itTau->hwIso());
144  output->push_back(gtTau);
145  }
146  }
147 
149  const std::vector<l1t::Tau> * input,
150  std::vector<l1t::Tau> *output){
151  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
152  itTau != input->end(); ++itTau){
153  uint16_t linPt = (uint16_t)itTau->hwPt();
154  if(linPt > params->jetScale().linScaleMax() ) linPt = params->jetScale().linScaleMax();
155  const uint16_t rankPt = params->jetScale().rank(linPt);
156 
157  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
158 
159  l1t::Tau gtTau(*&ldummy, rankPt, itTau->hwEta(), itTau->hwPhi(), itTau->hwQual(), itTau->hwIso());
160  output->push_back(gtTau);
161  }
162  }
163 
164 
166  const std::vector<l1t::EtSum> * input,
167  std::vector<l1t::EtSum> *output){
168  for(std::vector<l1t::EtSum>::const_iterator itEtSum = input->begin();
169  itEtSum != input->end(); ++itEtSum){
170 
171  uint16_t rankPt;
172  // Hack for now to make sure they come out with the right scale
173  //rankPt = params->jetScale().rank((uint16_t)itEtSum->hwPt());
174  rankPt = (uint16_t)itEtSum->hwPt();
175  if (EtSum::EtSumType::kMissingHt == itEtSum->getType())
176  {
177  // if(rankPt > params->HtMissScale().linScaleMax()) rankPt = params->HtMissScale().linScaleMax();
178  // params->HtMissScale().linScaleMax() always returns zero. Hardcode 512 for now
179 
180  // comment out for mht/ht (already in GT scale)
181  //if(rankPt > 512) rankPt = 512;
182  //rankPt = params->HtMissScale().rank(rankPt*params->emScale().linearLsb());
183  }
184 
185  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
186 
187  l1t::EtSum gtEtSum(*&ldummy, itEtSum->getType(), rankPt, 0,
188  itEtSum->hwPhi(), itEtSum->hwQual());
189 
190  output->push_back(gtEtSum);
191  }
192  }
193 
194  const unsigned int gtEta(const unsigned int iEta)
195  {
196  unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
197  return (((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));
198  }
199 }
L1CaloEtScale jetScale()
void TauToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
l1t::LUT * jetCalibrationLUT()
Definition: Tau.h:13
const unsigned int gtEta(const unsigned int iEta)
void EGammaToGtScales(CaloParamsHelper *params, const std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
void calibrateAndRankTaus(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
void EtSumToGtScales(CaloParamsHelper *params, const std::vector< l1t::EtSum > *input, std::vector< l1t::EtSum > *output)
uint16_t rank(const uint16_t linear) const
convert from linear Et scale to rank scale
static std::string const input
Definition: EdmProvDump.cc:43
void calibrateAndRankJets(CaloParamsHelper *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
Definition: Jet.h:13
void JetToGtEtaScales(CaloParamsHelper *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
void JetToGtPtScales(CaloParamsHelper *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
l1t::LUT * tauCalibrationLUT()
unsigned linScaleMax() const
Definition: L1CaloEtScale.h:47
int data(unsigned int address) const
Definition: LUT.h:46
void TauToGtPtScales(CaloParamsHelper *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)