CMS 3D CMS Logo

L1TPhysicalEtAdder.cc
Go to the documentation of this file.
3 
8 
12 
15 
18 
20 #include <vector>
21 
22 namespace {
23 
24  int getRegionEta(int gtEta, bool forward) {
25  // backwards conversion is
26  // unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
27  // return (((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));
28  int centralGtEta[] = {11, 12, 13, 14, 15, 16, 17, -100, 10, 9, 8, 7, 6, 5, 4};
29  int forwardGtEta[] = {18, 19, 20, 21, -100, -100, -100, -100, 3, 2, 1, 0};
30 
31  //printf("%i, %i\n",gtEta,forward);
32 
33  int regionEta;
34 
35  if (!forward) {
36  regionEta = centralGtEta[gtEta];
37  } else
38  regionEta = forwardGtEta[gtEta];
39 
40  if (regionEta == -100)
41  edm::LogError("EtaIndexError") << "Bad eta index passed to L1TPhysicalEtAdder::getRegionEta, " << gtEta
42  << std::endl;
43 
44  return regionEta;
45  }
46 
47  // adapted these from the UCT2015 codebase.
48  double getPhysicalEta(int gtEta, bool forward = false) {
49  int etaIndex = getRegionEta(gtEta, forward);
50 
51  const double rgnEtaValues[11] = {0.174, // HB and inner HE bins are 0.348 wide
52  0.522,
53  0.870,
54  1.218,
55  1.566,
56  1.956, // Last two HE bins are 0.432 and 0.828 wide
57  2.586,
58  3.250, // HF bins are 0.5 wide
59  3.750,
60  4.250,
61  4.750};
62  if (etaIndex < 11) {
63  return -rgnEtaValues[-(etaIndex - 10)]; // 0-10 are negative eta values
64  } else if (etaIndex < 22) {
65  return rgnEtaValues[etaIndex - 11]; // 11-21 are positive eta values
66  }
67  return -9;
68  }
69 
70  double getPhysicalPhi(int phiIndex) {
71  if (phiIndex < 10)
72  return 2. * M_PI * phiIndex / 18.;
73  if (phiIndex < 18)
74  return -M_PI + 2. * M_PI * (phiIndex - 9) / 18.;
75  return -9;
76  }
77 
78 } // namespace
79 
80 using namespace l1t;
81 
83  produces<EGammaBxCollection>();
84  produces<TauBxCollection>("rlxTaus");
85  produces<TauBxCollection>("isoTaus");
86  produces<JetBxCollection>();
87  produces<JetBxCollection>("preGtJets");
88  produces<EtSumBxCollection>();
89  produces<CaloSpareBxCollection>("HFRingSums");
90  produces<CaloSpareBxCollection>("HFBitCounts");
91 
92  EGammaToken_ = consumes<EGammaBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
93  RlxTauToken_ = consumes<TauBxCollection>(ps.getParameter<edm::InputTag>("InputRlxTauCollection"));
94  IsoTauToken_ = consumes<TauBxCollection>(ps.getParameter<edm::InputTag>("InputIsoTauCollection"));
95  JetToken_ = consumes<JetBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
96  preGtJetToken_ = consumes<JetBxCollection>(ps.getParameter<edm::InputTag>("InputPreGtJetCollection"));
97  EtSumToken_ = consumes<EtSumBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
98  HfSumsToken_ = consumes<CaloSpareBxCollection>(ps.getParameter<edm::InputTag>("InputHFSumsCollection"));
99  HfCountsToken_ = consumes<CaloSpareBxCollection>(ps.getParameter<edm::InputTag>("InputHFCountsCollection"));
100 }
101 
103 
104 // ------------ method called to produce the data ------------
106  // store new collections which include physical quantities
107  std::unique_ptr<EGammaBxCollection> new_egammas(new EGammaBxCollection);
108  std::unique_ptr<TauBxCollection> new_rlxtaus(new TauBxCollection);
109  std::unique_ptr<TauBxCollection> new_isotaus(new TauBxCollection);
110  std::unique_ptr<JetBxCollection> new_jets(new JetBxCollection);
111  std::unique_ptr<JetBxCollection> new_preGtJets(new JetBxCollection);
112  std::unique_ptr<EtSumBxCollection> new_etsums(new EtSumBxCollection);
113  std::unique_ptr<CaloSpareBxCollection> new_hfsums(new CaloSpareBxCollection);
114  std::unique_ptr<CaloSpareBxCollection> new_hfcounts(new CaloSpareBxCollection);
115 
117  edm::Handle<TauBxCollection> old_rlxtaus;
118  edm::Handle<TauBxCollection> old_isotaus;
120  edm::Handle<JetBxCollection> old_preGtJets;
124 
125  iEvent.getByToken(EGammaToken_, old_egammas);
126  iEvent.getByToken(RlxTauToken_, old_rlxtaus);
127  iEvent.getByToken(IsoTauToken_, old_isotaus);
128  iEvent.getByToken(JetToken_, old_jets);
129  iEvent.getByToken(preGtJetToken_, old_preGtJets);
130  iEvent.getByToken(EtSumToken_, old_etsums);
131  iEvent.getByToken(HfSumsToken_, old_hfsums);
132  iEvent.getByToken(HfCountsToken_, old_hfcounts);
133 
134  //get the proper scales for conversion to physical et
136  iSetup.get<L1EmEtScaleRcd>().get(emScale);
137 
139  iSetup.get<L1JetEtScaleRcd>().get(jetScale);
140 
141  edm::ESHandle<L1CaloEtScale> htMissScale;
142  iSetup.get<L1HtMissScaleRcd>().get(htMissScale);
143 
144  int firstBX = old_egammas->getFirstBX();
145  int lastBX = old_egammas->getLastBX();
146 
147  new_egammas->setBXRange(firstBX, lastBX);
148  new_rlxtaus->setBXRange(firstBX, lastBX);
149  new_isotaus->setBXRange(firstBX, lastBX);
150  new_jets->setBXRange(firstBX, lastBX);
151  new_preGtJets->setBXRange(firstBX, lastBX);
152  new_etsums->setBXRange(firstBX, lastBX);
153  new_hfsums->setBXRange(firstBX, lastBX);
154  new_hfcounts->setBXRange(firstBX, lastBX);
155 
156  for (int bx = firstBX; bx <= lastBX; ++bx) {
157  for (EGammaBxCollection::const_iterator itEGamma = old_egammas->begin(bx); itEGamma != old_egammas->end(bx);
158  ++itEGamma) {
159  //const double pt = itEGamma->hwPt() * emScale->linearLsb();
160  const double et = emScale->et(itEGamma->hwPt());
161  const double eta = getPhysicalEta(itEGamma->hwEta());
162  const double phi = getPhysicalPhi(itEGamma->hwPhi());
164 
165  EGamma eg(*&p4, itEGamma->hwPt(), itEGamma->hwEta(), itEGamma->hwPhi(), itEGamma->hwQual(), itEGamma->hwIso());
166  new_egammas->push_back(bx, *&eg);
167  }
168 
169  for (TauBxCollection::const_iterator itTau = old_rlxtaus->begin(bx); itTau != old_rlxtaus->end(bx); ++itTau) {
170  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
171  //const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt());
172  //const double et = jetScale->et( rankPt ) ;
173 
174  // or use the emScale to get finer-grained et
175  //const double et = itTau->hwPt() * emScale->linearLsb();
176 
177  // we are now already in the rankPt
178  const double et = jetScale->et(itTau->hwPt());
179 
180  const double eta = getPhysicalEta(itTau->hwEta());
181  const double phi = getPhysicalPhi(itTau->hwPhi());
183 
184  Tau tau(*&p4, itTau->hwPt(), itTau->hwEta(), itTau->hwPhi(), itTau->hwQual(), itTau->hwIso());
185  new_rlxtaus->push_back(bx, *&tau);
186  }
187 
188  for (TauBxCollection::const_iterator itTau = old_isotaus->begin(bx); itTau != old_isotaus->end(bx); ++itTau) {
189  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
190  //const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt());
191  //const double et = jetScale->et( rankPt ) ;
192 
193  // or use the emScale to get finer-grained et
194  //const double et = itTau->hwPt() * emScale->linearLsb();
195 
196  // we are now already in the rankPt
197  const double et = jetScale->et(itTau->hwPt());
198 
199  const double eta = getPhysicalEta(itTau->hwEta());
200  const double phi = getPhysicalPhi(itTau->hwPhi());
202 
203  Tau tau(*&p4, itTau->hwPt(), itTau->hwEta(), itTau->hwPhi(), itTau->hwQual(), itTau->hwIso());
204  new_isotaus->push_back(bx, *&tau);
205  }
206 
207  for (JetBxCollection::const_iterator itJet = old_jets->begin(bx); itJet != old_jets->end(bx); ++itJet) {
208  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
209  //const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt());
210  //const double et = jetScale->et( rankPt ) ;
211 
212  // or use the emScale to get finer-grained et
213  //const double et = itJet->hwPt() * emScale->linearLsb();
214 
215  // we are now already in the rankPt
216  const double et = jetScale->et(itJet->hwPt());
217 
218  const bool forward = ((itJet->hwQual() & 0x2) != 0);
219  const double eta = getPhysicalEta(itJet->hwEta(), forward);
220  const double phi = getPhysicalPhi(itJet->hwPhi());
222 
223  Jet jet(*&p4, itJet->hwPt(), itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
224  new_jets->push_back(bx, *&jet);
225  }
226 
227  for (JetBxCollection::const_iterator itJet = old_preGtJets->begin(bx); itJet != old_preGtJets->end(bx); ++itJet) {
228  // use the full-circle conversion to match l1extra, accounts for linearLsb and max value automatically
229  //const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt());
230  //const double et = jetScale->et( rankPt ) ;
231 
232  // or use the emScale to get finer-grained et
233  const double et = itJet->hwPt() * emScale->linearLsb();
234 
235  // we are now already in the rankPt
236  //const double et = jetScale->et( itJet->hwPt() );
237 
238  const bool forward = ((itJet->hwQual() & 0x2) != 0);
239  const double eta = getPhysicalEta(itJet->hwEta(), forward);
240  const double phi = getPhysicalPhi(itJet->hwPhi());
242 
243  Jet jet(*&p4, itJet->hwPt(), itJet->hwEta(), itJet->hwPhi(), itJet->hwQual());
244  new_preGtJets->push_back(bx, *&jet);
245  }
246 
247  for (EtSumBxCollection::const_iterator itEtSum = old_etsums->begin(bx); itEtSum != old_etsums->end(bx); ++itEtSum) {
248  double et = itEtSum->hwPt() * emScale->linearLsb();
249  //hack while we figure out the right scales
250  //double et = emScale->et( itEtSum->hwPt() );
251  const EtSum::EtSumType sumType = itEtSum->getType();
252 
253  const double eta = getPhysicalEta(itEtSum->hwEta());
254  double phi = getPhysicalPhi(itEtSum->hwPhi());
255  if (sumType == EtSum::EtSumType::kMissingHt) {
256  et = htMissScale->et(itEtSum->hwPt());
257  double regionPhiWidth = 2. * 3.1415927 / L1CaloRegionDetId::N_PHI;
258  phi = phi + (regionPhiWidth / 2.); // add the region half-width to match L1Extra MHT phi
259  }
260 
262 
263  EtSum eg(*&p4, sumType, itEtSum->hwPt(), itEtSum->hwEta(), itEtSum->hwPhi(), itEtSum->hwQual());
264  new_etsums->push_back(bx, *&eg);
265  }
266 
267  for (CaloSpareBxCollection::const_iterator itCaloSpare = old_hfsums->begin(bx); itCaloSpare != old_hfsums->end(bx);
268  ++itCaloSpare) {
269  //just pass through for now
270  //a different scale is needed depending on the type
271  new_hfsums->push_back(bx, *itCaloSpare);
272  }
273 
274  for (CaloSpareBxCollection::const_iterator itCaloSpare = old_hfcounts->begin(bx);
275  itCaloSpare != old_hfcounts->end(bx);
276  ++itCaloSpare) {
277  //just pass through for now
278  //a different scale is needed depending on the type
279  new_hfcounts->push_back(bx, *itCaloSpare);
280  }
281  }
282 
283  iEvent.put(std::move(new_egammas));
284  iEvent.put(std::move(new_rlxtaus), "rlxTaus");
285  iEvent.put(std::move(new_isotaus), "isoTaus");
286  iEvent.put(std::move(new_jets));
287  iEvent.put(std::move(new_preGtJets), "preGtJets");
288  iEvent.put(std::move(new_etsums));
289  iEvent.put(std::move(new_hfsums), "HFRingSums");
290  iEvent.put(std::move(new_hfcounts), "HFBitCounts");
291 }
292 
293 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
295  //The following says we do not know what parameters are allowed so do no validation
296  // Please change this to state exactly what you do use, even if it is no parameters
298  desc.setUnknown();
299  descriptions.addDefault(desc);
300 }
301 
302 //define this as a plug-in
L1EmEtScaleRcd.h
edm::StreamID
Definition: StreamID.h:30
L1CaloEmCand.h
MessageLogger.h
BXVector.h
ESHandle.h
metsig::tau
Definition: SignAlgoResolutions.h:49
BXVector::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
L1TPhysicalEtAdder::L1TPhysicalEtAdder
L1TPhysicalEtAdder(const edm::ParameterSet &ps)
Definition: L1TPhysicalEtAdder.cc:82
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Tau
Definition: Tau.py:1
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
edm::Handle
Definition: AssociativeIterator.h:50
L1TPhysicalEtAdder.h
L1TPhysicalEtAdder
Definition: L1TPhysicalEtAdder.h:36
L1HtMissScaleRcd.h
BXVector
Definition: BXVector.h:15
BXVector::getFirstBX
int getFirstBX() const
CaloRegion.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
PVValHelper::eta
Definition: PVValidationHelpers.h:69
L1JetEtScaleRcd
Definition: L1JetEtScaleRcd.h:30
edm::ESHandle
Definition: DTSurvey.h:22
L1CaloEtScale::linearLsb
double linearLsb() const
get LSB of linear input scale
Definition: L1CaloEtScale.h:54
L1TPhysicalEtAdder::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: L1TPhysicalEtAdder.cc:105
BXVector::begin
const_iterator begin(int bx) const
L1TPhysicalEtAdder::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: L1TPhysicalEtAdder.cc:294
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
BXVector::end
const_iterator end(int bx) const
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
l1t
delete x;
Definition: CaloConfig.h:22
l1t::EtSum
Definition: EtSum.h:20
L1CaloCollections.h
iEvent
int iEvent
Definition: GenABIO.cc:224
p4
double p4[4]
Definition: TauolaWrapper.h:92
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
L1TPhysicalEtAdder::~L1TPhysicalEtAdder
~L1TPhysicalEtAdder() override
Definition: L1TPhysicalEtAdder.cc:102
L1Analysis::kMissingHt
Definition: L1AnalysisL1UpgradeDataFormat.h:20
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
l1t::EGamma
Definition: EGamma.h:20
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
L1CaloEtScale.h
l1t::gtEta
const unsigned int gtEta(const unsigned int iEta)
Definition: legacyGtHelper.cc:172
L1CaloRegionDetId::N_PHI
static const unsigned N_PHI
Definition: L1CaloRegionDetId.h:20
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
L1HtMissScaleRcd
Definition: L1HtMissScaleRcd.h:30
eostools.move
def move(src, dest)
Definition: eostools.py:511
CaloEmCand.h
metsig::jet
Definition: SignAlgoResolutions.h:47
L1EmEtScaleRcd
Definition: L1EmEtScaleRcd.h:30
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
wplusjetsAnalysis_cfi.jetScale
jetScale
Definition: wplusjetsAnalysis_cfi.py:88
L1CaloEtScale::et
double et(const uint16_t rank) const
convert from rank to physically meaningful quantity
Definition: L1CaloEtScale.cc:68
l1t::EtSum::EtSumType
EtSumType
Definition: EtSum.h:22
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
EtSum.h
L1JetEtScaleRcd.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
BXVector::getLastBX
int getLastBX() const
edm::InputTag
Definition: InputTag.h:15
L1CaloRegion.h