CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhysicalEtAdder.cc
Go to the documentation of this file.
2 
7 
11 
14 
17 
19 #include <vector>
20 
21 double getPhysicalEta(int etaIndex);
22 double getPhysicalPhi(int phiIndex);
23 
25 
26  produces<l1t::EGammaBxCollection>();
27  produces<l1t::TauBxCollection>();
28  produces<l1t::JetBxCollection>();
29  produces<l1t::EtSumBxCollection>();
30 
31  EGammaToken_ = consumes<l1t::EGammaBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
32  TauToken_ = consumes<l1t::TauBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
33  JetToken_ = consumes<l1t::JetBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
34  EtSumToken_ = consumes<l1t::EtSumBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
35 }
36 
38 
39 }
40 
41 // ------------ method called to produce the data ------------
42 void
44 {
45  // store new collections which include physical quantities
46  std::auto_ptr<l1t::EGammaBxCollection> new_egammas (new l1t::EGammaBxCollection);
47  std::auto_ptr<l1t::TauBxCollection> new_taus (new l1t::TauBxCollection);
48  std::auto_ptr<l1t::JetBxCollection> new_jets (new l1t::JetBxCollection);
49  std::auto_ptr<l1t::EtSumBxCollection> new_etsums (new l1t::EtSumBxCollection);
50 
55 
56  iEvent.getByToken(EGammaToken_, old_egammas);
57  iEvent.getByToken(TauToken_, old_taus);
58  iEvent.getByToken(JetToken_, old_jets);
59  iEvent.getByToken(EtSumToken_, old_etsums);
60 
61 
62  //get the proper scales for conversion to physical et
64  iSetup.get< L1EmEtScaleRcd >().get( emScale ) ;
65 
67  iSetup.get< L1JetEtScaleRcd >().get( jetScale ) ;
68 
69  edm::ESHandle< L1CaloEtScale > hwForJetScale ;
70  iSetup.get< L1JetEtScaleRcd >().get( hwForJetScale ) ;
71 
72  edm::ESHandle< L1CaloEtScale > htMissScale ;
73  std::vector< bool > htMissMatched ;
74  iSetup.get< L1HtMissScaleRcd >().get( htMissScale ) ;
75 
76  int firstBX = old_egammas->getFirstBX();
77  int lastBX = old_egammas->getLastBX();
78 
79  new_egammas->setBXRange(firstBX, lastBX);
80  new_taus->setBXRange(firstBX, lastBX);
81  new_jets->setBXRange(firstBX, lastBX);
82  new_taus->setBXRange(firstBX, lastBX);
83 
84  for(int bx = firstBX; bx <= lastBX; ++bx)
85  {
86  for(l1t::EGammaBxCollection::const_iterator itEGamma = old_egammas->begin(bx);
87  itEGamma != old_egammas->end(bx); ++itEGamma)
88  {
89  const double pt = itEGamma->hwPt() * emScale->linearLsb();
90  const double eta = getPhysicalEta(itEGamma->hwEta());
91  const double phi = getPhysicalPhi(itEGamma->hwPhi());
93 
94  l1t::EGamma *eg = new l1t::EGamma(*p4, itEGamma->hwPt(),
95  itEGamma->hwEta(), itEGamma->hwPhi(),
96  itEGamma->hwQual(), itEGamma->hwIso());
97  new_egammas->push_back(bx, *eg);
98 
99 
100  }
101 
102  for(l1t::TauBxCollection::const_iterator itTau = old_taus->begin(bx);
103  itTau != old_taus->end(bx); ++itTau)
104  {
105  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
106  //const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt());
107  //const double et = jetScale->et( rankPt ) ;
108 
109  // or use the emScale to get finer-grained et
110  const double et = itTau->hwPt() * emScale->linearLsb();
111 
112  const double eta = getPhysicalEta(itTau->hwEta());
113  const double phi = getPhysicalPhi(itTau->hwPhi());
115 
116  l1t::Tau *tau = new l1t::Tau(*p4, itTau->hwPt(),
117  itTau->hwEta(), itTau->hwPhi(),
118  itTau->hwQual());
119  new_taus->push_back(bx, *tau);
120 
121  }
122 
123  for(l1t::JetBxCollection::const_iterator itJet = old_jets->begin(bx);
124  itJet != old_jets->end(bx); ++itJet)
125  {
126  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
127  //const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt());
128  //const double et = jetScale->et( rankPt ) ;
129 
130  // or use the emScale to get finer-grained et
131  const double et = itJet->hwPt() * emScale->linearLsb();
132 
133  const double eta = getPhysicalEta(itJet->hwEta());
134  const double phi = getPhysicalPhi(itJet->hwPhi());
136 
137  l1t::Jet *jet = new l1t::Jet(*p4, itJet->hwPt(),
138  itJet->hwEta(), itJet->hwPhi(),
139  itJet->hwQual());
140  new_jets->push_back(bx, *jet);
141 
142  }
143 
144  for(l1t::EtSumBxCollection::const_iterator itEtSum = old_etsums->begin(bx);
145  itEtSum != old_etsums->end(bx); ++itEtSum)
146  {
147  const double pt = itEtSum->hwPt() * emScale->linearLsb();
148  const double eta = getPhysicalEta(itEtSum->hwEta());
149  const double phi = getPhysicalPhi(itEtSum->hwPhi());
150  const l1t::EtSum::EtSumType sumType = itEtSum->getType();
151  //std::cout << "SumType: " << sumType << std::endl;
153 
154  l1t::EtSum *eg = new l1t::EtSum(*p4, sumType, itEtSum->hwPt(),
155  itEtSum->hwEta(), itEtSum->hwPhi(),
156  itEtSum->hwQual());
157  new_etsums->push_back(bx, *eg);
158 
159  }
160  }
161 
162  iEvent.put(new_egammas);
163  iEvent.put(new_taus);
164  iEvent.put(new_jets);
165  iEvent.put(new_etsums);
166 
167 }
168 
169 // ------------ method called once each job just before starting event loop ------------
170 void
172 {
173 }
174 
175 // ------------ method called once each job just after ending the event loop ------------
176 void
178 }
179 
180 // ------------ method called when starting to processes a run ------------
181 /*
182  void
183  l1t::PhysicalEtAdder::beginRun(edm::Run const&, edm::EventSetup const&)
184  {
185  }
186 */
187 
188 // ------------ method called when ending the processing of a run ------------
189 /*
190  void
191  l1t::PhysicalEtAdder::endRun(edm::Run const&, edm::EventSetup const&)
192  {
193  }
194 */
195 
196 // ------------ method called when starting to processes a luminosity block ------------
197 /*
198  void
199  l1t::PhysicalEtAdder::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup cons
200  t&)
201  {
202  }
203 */
204 
205 // ------------ method called when ending the processing of a luminosity block ------------
206 /*
207  void
208  l1t::PhysicalEtAdder::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&
209  )
210  {
211  }
212 */
213 
214 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
215 void
217  //The following says we do not know what parameters are allowed so do no validation
218  // Please change this to state exactly what you do use, even if it is no parameters
220  desc.setUnknown();
221  descriptions.addDefault(desc);
222 }
223 
224 //define this as a plug-in
226 
227 // grabbed these from the UCT2015 codebase.
228 double getPhysicalEta(int etaIndex)
229 {
230  const double rgnEtaValues[11] = {
231  0.174, // HB and inner HE bins are 0.348 wide
232  0.522,
233  0.870,
234  1.218,
235  1.566,
236  1.956, // Last two HE bins are 0.432 and 0.828 wide
237  2.586,
238  3.250, // HF bins are 0.5 wide
239  3.750,
240  4.250,
241  4.750
242  };
243  if(etaIndex < 11) {
244  return -rgnEtaValues[-(etaIndex - 10)]; // 0-10 are negative eta values
245  }
246  else if (etaIndex < 22) {
247  return rgnEtaValues[etaIndex - 11]; // 11-21 are positive eta values
248  }
249  return -9;
250 }
251 
252 double getPhysicalPhi(int phiIndex)
253 {
254  if (phiIndex < 10)
255  return 2. * M_PI * phiIndex / 18.;
256  if (phiIndex < 18)
257  return -M_PI + 2. * M_PI * (phiIndex - 9) / 18.;
258  return -9;
259 }
T getParameter(std::string const &) const
edm::EDGetToken EtSumToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetToken TauToken_
Definition: Tau.h:13
T eta() const
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
Definition: Jet.h:13
PhysicalEtAdder(const edm::ParameterSet &ps)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double p4[4]
Definition: TauolaWrapper.h:92
virtual void endJob() override
#define M_PI
int hwPt() const
Definition: L1Candidate.cc:69
double getPhysicalPhi(int phiIndex)
const T & get() const
Definition: EventSetup.h:55
virtual void beginJob() override
edm::EDGetToken EGammaToken_
edm::EDGetToken JetToken_
virtual void produce(edm::Event &, const edm::EventSetup &) override
double getPhysicalEta(int etaIndex)
EtSumType
Definition: EtSum.h:17
std::vector< EGamma >::const_iterator const_iterator
Definition: BXVector.h:16
Definition: DDAxes.h:10