CMS 3D CMS Logo

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