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  unsigned int lutAddress = (eta<<10)+pt;
23 
24  unsigned int rank = params->jetCalibrationLUT()->data(lutAddress);
25 
26  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
27  l1t::Jet outJet(*&ldummy, rank, itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
28  output->push_back(outJet);
29  }
30  }
31 
33  const std::vector<l1t::Tau> * input,
34  std::vector<l1t::Tau> *output){
35 
36  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
37  itTau != input->end(); ++itTau){
38  unsigned int pt = itTau->hwPt();
39  if(pt > ((1<<10) -1) )
40  pt = ((1<<10) -1);
41  unsigned int eta = itTau->hwEta();
42  unsigned int lutAddress = (eta<<10)+pt;
43 
44  unsigned int rank = params->tauCalibrationLUT()->data(lutAddress);
45 
46  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
47  l1t::Tau outTau(*&ldummy, rank, itTau->hwEta(), itTau->hwPhi(), itTau->hwQual());
48  output->push_back(outTau);
49  }
50  }
51 
52 
54  const std::vector<l1t::Jet> * input,
55  std::vector<l1t::Jet> *output){
56 
57  for(std::vector<l1t::Jet>::const_iterator itJet = input->begin();
58  itJet != input->end(); ++itJet){
59  unsigned newPhi = itJet->hwPhi();
60  unsigned newEta = gtEta(itJet->hwEta());
61 
62  // jets with hwQual & 10 ==10 are "padding" jets from a sort, set their eta and phi
63  // to the max value
64  if((itJet->hwQual() & 0x10) == 0x10)
65  {
66  newEta = 0x0;
67  newPhi = 0x0;
68  }
69 
70  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
71 
72  l1t::Jet gtJet(*&ldummy, itJet->hwPt(), newEta, newPhi, itJet->hwQual());
73  output->push_back(gtJet);
74  }
75  }
76 
78  const std::vector<l1t::Jet> * input,
79  std::vector<l1t::Jet> *output){
80 
81  for(std::vector<l1t::Jet>::const_iterator itJet = input->begin();
82  itJet != input->end(); ++itJet){
83  uint16_t linPt = (uint16_t)itJet->hwPt();
84  if(linPt > params->jetScale().linScaleMax() ) linPt = params->jetScale().linScaleMax();
85  const uint16_t rankPt = params->jetScale().rank(linPt);
86 
87  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
88 
89  l1t::Jet gtJet(*&ldummy, rankPt, itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
90  output->push_back(gtJet);
91  }
92  }
93 
94 
96  const std::vector<l1t::EGamma> * input,
97  std::vector<l1t::EGamma> *output){
98 
99  for(std::vector<l1t::EGamma>::const_iterator itEGamma = input->begin();
100  itEGamma != input->end(); ++itEGamma){
101  unsigned newEta = gtEta(itEGamma->hwEta());
102  unsigned newPhi = itEGamma->hwPhi();
103  const uint16_t rankPt = (uint16_t)itEGamma->hwPt(); //max value?
104 
105  //hwQual &10 == 10 means that the object came from a sort and is padding
106  if((itEGamma->hwQual() & 0x10) == 0x10)
107  {
108  newEta = 0x0;
109  newPhi = 0x0;
110  }
111 
112  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
113 
114  l1t::EGamma gtEGamma(*&ldummy, rankPt, newEta, newPhi,
115  itEGamma->hwQual(), itEGamma->hwIso());
116  output->push_back(gtEGamma);
117  }
118  }
119 
121  const std::vector<l1t::Tau> * input,
122  std::vector<l1t::Tau> *output){
123  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
124  itTau != input->end(); ++itTau){
125  unsigned newPhi = itTau->hwPhi();
126  unsigned newEta = gtEta(itTau->hwEta());
127 
128  // taus with hwQual & 10 ==10 are "padding" jets from a sort, set their eta and phi
129  // to the max value
130  if((itTau->hwQual() & 0x10) == 0x10)
131  {
132  newEta = 0x0;
133  newPhi = 0x0;
134  }
135 
136 
137  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
138 
139  l1t::Tau gtTau(*&ldummy, itTau->hwPt(), newEta, newPhi, itTau->hwQual(), itTau->hwIso());
140  output->push_back(gtTau);
141  }
142  }
143 
145  const std::vector<l1t::Tau> * input,
146  std::vector<l1t::Tau> *output){
147  for(std::vector<l1t::Tau>::const_iterator itTau = input->begin();
148  itTau != input->end(); ++itTau){
149  uint16_t linPt = (uint16_t)itTau->hwPt();
150  if(linPt > params->jetScale().linScaleMax() ) linPt = params->jetScale().linScaleMax();
151  const uint16_t rankPt = params->jetScale().rank(linPt);
152 
153  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
154 
155  l1t::Tau gtTau(*&ldummy, rankPt, itTau->hwEta(), itTau->hwPhi(), itTau->hwQual(), itTau->hwIso());
156  output->push_back(gtTau);
157  }
158  }
159 
160 
162  const std::vector<l1t::EtSum> * input,
163  std::vector<l1t::EtSum> *output){
164  for(std::vector<l1t::EtSum>::const_iterator itEtSum = input->begin();
165  itEtSum != input->end(); ++itEtSum){
166 
167  uint16_t rankPt;
168  // Hack for now to make sure they come out with the right scale
169  //rankPt = params->jetScale().rank((uint16_t)itEtSum->hwPt());
170  rankPt = (uint16_t)itEtSum->hwPt();
171  if (EtSum::EtSumType::kMissingHt == itEtSum->getType())
172  {
173  // if(rankPt > params->HtMissScale().linScaleMax()) rankPt = params->HtMissScale().linScaleMax();
174  // params->HtMissScale().linScaleMax() always returns zero. Hardcode 512 for now
175 
176  // comment out for mht/ht (already in GT scale)
177  //if(rankPt > 512) rankPt = 512;
178  //rankPt = params->HtMissScale().rank(rankPt*params->emScale().linearLsb());
179  }
180 
181  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > ldummy(0,0,0,0);
182 
183  l1t::EtSum gtEtSum(*&ldummy, itEtSum->getType(), rankPt, 0,
184  itEtSum->hwPhi(), itEtSum->hwQual());
185 
186  output->push_back(gtEtSum);
187  }
188  }
189 
190  const unsigned int gtEta(const unsigned int iEta)
191  {
192  unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
193  return (((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));
194  }
195 }
L1CaloEtScale jetScale()
void JetToGtEtaScales(CaloParamsStage1 *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
Definition: Tau.h:13
const unsigned int gtEta(const unsigned int iEta)
void TauToGtEtaScales(CaloParamsStage1 *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
uint16_t rank(const uint16_t linear) const
convert from linear Et scale to rank scale
void JetToGtPtScales(CaloParamsStage1 *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
static std::string const input
Definition: EdmProvDump.cc:43
Definition: Jet.h:13
void TauToGtPtScales(CaloParamsStage1 *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
void calibrateAndRankTaus(CaloParamsStage1 *params, const std::vector< l1t::Tau > *input, std::vector< l1t::Tau > *output)
l1t::LUT * tauCalibrationLUT()
Definition: CaloParams.h:321
l1t::LUT * jetCalibrationLUT()
Definition: CaloParams.h:361
void EGammaToGtScales(CaloParamsStage1 *params, const std::vector< l1t::EGamma > *input, std::vector< l1t::EGamma > *output)
unsigned linScaleMax() const
Definition: L1CaloEtScale.h:47
int data(unsigned int address) const
Definition: LUT.h:46
void calibrateAndRankJets(CaloParamsStage1 *params, const std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
void EtSumToGtScales(CaloParamsStage1 *params, const std::vector< l1t::EtSum > *input, std::vector< l1t::EtSum > *output)