CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCaloUpgradeToGCTConverter.cc
Go to the documentation of this file.
1 // L1TCaloUpgradeToGCTConverter.cc
2 // Authors: Ivan Cali
3 // R. Alex Barbieri
4 
5 // Stage 1 upgrade to old GT format converter
6 // Assumes input collections are sorted, but not truncated.
7 
8 // In the 'gct' eta coordinates the HF is 0-3 and 18-21. Jets which
9 // include any energy at all from the HF should be considered
10 // 'forward' jets, however, so jets with centers in 0-4 and 17-21 are
11 // considered 'forward'.
12 
13 
15 #include <boost/shared_ptr.hpp>
16 
21 
22 using namespace l1t;
23 
25 {
26  produces<L1GctEmCandCollection>("isoEm");
27  produces<L1GctEmCandCollection>("nonIsoEm");
28  produces<L1GctJetCandCollection>("cenJets");
29  produces<L1GctJetCandCollection>("forJets");
30  produces<L1GctJetCandCollection>("tauJets");
31  produces<L1GctJetCandCollection>("isoTauJets");
32  produces<L1GctInternJetDataCollection>();
33  produces<L1GctEtTotalCollection>();
34  produces<L1GctEtHadCollection>();
35  produces<L1GctEtMissCollection>();
36  produces<L1GctHtMissCollection>();
37  produces<L1GctInternEtSumCollection>();
38  produces<L1GctInternHtMissCollection>();
39  produces<L1GctHFBitCountsCollection>();
40  produces<L1GctHFRingEtSumsCollection>();
41 
42  // register what you consume and keep token for later access:
43  EGammaToken_ = consumes<EGammaBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
44  RlxTauToken_ = consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputRlxTauCollection"));
45  IsoTauToken_ = consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputIsoTauCollection"));
46  JetToken_ = consumes<JetBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
47  EtSumToken_ = consumes<EtSumBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
48  HfSumsToken_ = consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFSumsCollection"));
49  HfCountsToken_ = consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFCountsCollection"));
50 }
51 
52 
54 {
55 }
56 
57 
58 
59 
60 // ------------ method called to produce the data ------------
61 void
63 {
64  LogDebug("l1t|stage 1 Converter") << "L1TCaloUpgradeToGCTConverter::produce function called...\n";
65 
66  //inputs
68  e.getByToken(EGammaToken_,EGamma);
69 
71  e.getByToken(RlxTauToken_,RlxTau);
72 
74  e.getByToken(IsoTauToken_,IsoTau);
75 
77  e.getByToken(JetToken_,Jet);
78 
80  e.getByToken(EtSumToken_,EtSum);
81 
83  e.getByToken(HfSumsToken_, HfSums);
84 
86  e.getByToken(HfCountsToken_, HfCounts);
87 
88  // create the em and jet collections
89  std::auto_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection( ) );
90  std::auto_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection( ) );
91  std::auto_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection( ) );
92  std::auto_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection( ) );
93  std::auto_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection( ) );
94  std::auto_ptr<L1GctJetCandCollection> isoTauJetResult(new L1GctJetCandCollection( ) );
95 
96  // create the energy sum digis
97  std::auto_ptr<L1GctEtTotalCollection> etTotResult (new L1GctEtTotalCollection( ) );
98  std::auto_ptr<L1GctEtHadCollection> etHadResult (new L1GctEtHadCollection ( ) );
99  std::auto_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection ( ) );
100  std::auto_ptr<L1GctHtMissCollection> htMissResult(new L1GctHtMissCollection ( ) );
101 
102  // create the Hf sums digis
103  std::auto_ptr<L1GctHFBitCountsCollection> hfBitCountResult (new L1GctHFBitCountsCollection ( ) );
104  std::auto_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection( ) );
105 
106  // create internal data collections
107  std::auto_ptr<L1GctInternJetDataCollection> internalJetResult (new L1GctInternJetDataCollection( ));
108  std::auto_ptr<L1GctInternEtSumCollection> internalEtSumResult (new L1GctInternEtSumCollection ( ));
109  std::auto_ptr<L1GctInternHtMissCollection> internalHtMissResult(new L1GctInternHtMissCollection ( ));
110 
111 
112  // Assume BX is the same for all collections
113  int firstBX = EGamma->getFirstBX();
114  int lastBX = EGamma->getLastBX();
115 
116  for(int itBX=firstBX; itBX!=lastBX+1; ++itBX){
117 
118  //looping over EGamma elments with a specific BX
119  int nonIsoCount = 0;
120  int isoCount = 0;
121  for(EGammaBxCollection::const_iterator itEGamma = EGamma->begin(itBX);
122  itEGamma != EGamma->end(itBX); ++itEGamma){
123  bool iso = itEGamma->hwIso();
124 
125  L1GctEmCand EmCand(itEGamma->hwPt(), itEGamma->hwPhi(), itEGamma->hwEta(),
126  iso, 0, 0, itBX);
127  //L1GctEmCand(unsigned rank, unsigned phi, unsigned eta,
128  // bool iso, uint16_t block, uint16_t index, int16_t bx);
129 
130  if(iso){
131  if(isoCount != 4)
132  {
133  isoEmResult->push_back(EmCand);
134  isoCount++;
135  }
136  }
137  else{
138  if(nonIsoCount != 4)
139  {
140  nonIsoEmResult->push_back(EmCand);
141  nonIsoCount++;
142  }
143  }
144  }
145  isoEmResult->resize(4);
146  nonIsoEmResult->resize(4);
147 
148  //looping over Tau elments with a specific BX
149  int tauCount = 0; //max 4
150  for(TauBxCollection::const_iterator itTau = RlxTau->begin(itBX);
151  itTau != RlxTau->end(itBX); ++itTau){
152  // taus are not allowed to be forward
153  const bool forward= false;
154 
155  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(),
156  true, forward,0, 0, itBX);
157  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
158  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
159  if(tauCount != 4){
160  tauJetResult->push_back(TauCand);
161  tauCount++;
162  }
163  }
164  tauJetResult->resize(4);
165 
166 
167  //looping over Iso Tau elments with a specific BX
168  int isoTauCount = 0; //max 4
169  for(TauBxCollection::const_iterator itTau = IsoTau->begin(itBX);
170  itTau != IsoTau->end(itBX); ++itTau){
171  // taus are not allowed to be forward
172  const bool forward= false;
173 
174  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(),
175  true, forward,0, 0, itBX);
176  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
177  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
178  if(isoTauCount != 4){
179  isoTauJetResult->push_back(TauCand);
180  isoTauCount++;
181  }
182  }
183  isoTauJetResult->resize(4);
184 
185 
186  //looping over Jet elments with a specific BX
187  int forCount = 0; //max 4
188  int cenCount = 0; //max 4
189  for(JetBxCollection::const_iterator itJet = Jet->begin(itBX);
190  itJet != Jet->end(itBX); ++itJet){
191  // use 2nd quality bit to define forward
192  const bool forward = ((itJet->hwQual() & 0x2) != 0);
193  L1GctJetCand JetCand(itJet->hwPt(), itJet->hwPhi(), itJet->hwEta(),
194  false, forward,0, 0, itBX);
195  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
196  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
197  if(forward) {
198  if(forCount !=4 ){
199  forJetResult->push_back(JetCand);
200  forCount++;
201  }
202  }
203  else {
204  if(cenCount != 4){
205  cenJetResult->push_back(JetCand);
206  cenCount++;
207  }
208  }
209  }
210  forJetResult->resize(4);
211  cenJetResult->resize(4);
212 
213  //looping over EtSum elments with a specific BX
214  for (EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX);
215  itEtSum != EtSum->end(itBX); ++itEtSum){
216 
217  if (EtSum::EtSumType::kMissingEt == itEtSum->getType()){
218  L1GctEtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual()&0x1, itBX);
219  etMissResult->push_back(Cand);
220  }else if (EtSum::EtSumType::kMissingHt == itEtSum->getType()){
221  L1GctHtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual()&0x1, itBX);
222  htMissResult->push_back(Cand);
223  }else if (EtSum::EtSumType::kTotalEt == itEtSum->getType()){
224  L1GctEtTotal Cand(itEtSum->hwPt(), itEtSum->hwQual()&0x1, itBX);
225  etTotResult->push_back(Cand);
226  }else if (EtSum::EtSumType::kTotalHt == itEtSum->getType()){
227  L1GctEtHad Cand(itEtSum->hwPt(), itEtSum->hwQual()&0x1, itBX);
228  etHadResult->push_back(Cand);
229  }else {
230  LogError("l1t|stage 1 Converter") <<" Unknown EtSumType --- EtSum collection will not be saved...\n ";
231  }
232  }
233  etMissResult->resize(1);
234  htMissResult->resize(1);
235  etTotResult->resize(1);
236  etHadResult->resize(1);
237 
239  0,
240  0,
241  0,
242  0);
243  for (CaloSpareBxCollection::const_iterator itCaloSpare = HfSums->begin(itBX);
244  itCaloSpare != HfSums->end(itBX); ++itCaloSpare){
245  // if (CaloSpare::CaloSpareType::V2 == itCaloSpare->getType())
246  // {
247  // sum.setEtSum(3, itCaloSpare->hwPt());
248  // } else if (CaloSpare::CaloSpareType::Centrality == itCaloSpare->getType())
249  // {
250  // sum.setEtSum(0, itCaloSpare->hwPt());
251  // } else if (CaloSpare::CaloSpareType::Tau == itCaloSpare->getType())
252  // {
253  // sum.setEtSum(0, itCaloSpare->hwPt() & 0x7);
254  // sum.setEtSum(1, (itCaloSpare->hwPt() >> 3) & 0x7);
255  // sum.setEtSum(2, (itCaloSpare->hwPt() >> 6) & 0x7);
256  // sum.setEtSum(3, (itCaloSpare->hwPt() >> 9) & 0x7);
257  // }
258  for(int i = 0; i < 4; i++)
259  {
260  sum.setEtSum(i, itCaloSpare->GetRing(i));
261  }
262  }
263  hfRingEtSumResult->push_back(sum);
264 
265  hfRingEtSumResult->resize(1);
266  //no hfBitCounts yet
267  hfBitCountResult->resize(1);
268  }
269 
270  e.put(isoEmResult,"isoEm");
271  e.put(nonIsoEmResult,"nonIsoEm");
272  e.put(cenJetResult,"cenJets");
273  e.put(forJetResult,"forJets");
274  e.put(tauJetResult,"tauJets");
275  e.put(isoTauJetResult,"isoTauJets");
276  e.put(etTotResult);
277  e.put(etHadResult);
278  e.put(etMissResult);
279  e.put(htMissResult);
280  e.put(hfBitCountResult);
281  e.put(hfRingEtSumResult);
282 
283  e.put(internalJetResult);
284  e.put(internalEtSumResult);
285  e.put(internalHtMissResult);
286 }
287 
288 // ------------ method called once each job just before starting event loop ------------
289 void
291 {
292 }
293 
294 // ------------ method called once each job just after ending the event loop ------------
295 void
297 }
298 
299 // ------------ method called when starting to processes a run ------------
300 
301 void
303 
304 }
305 
306 // ------------ method called when ending the processing of a run ------------
307 void
309 
310 }
311 
312 
313 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
314 void
316  //The following says we do not know what parameters are allowed so do no validation
317  // Please change this to state exactly what you do use, even if it is no parameters
319  desc.setUnknown();
320  descriptions.addDefault(desc);
321 }
322 
323 //define this as a plug-in
static L1GctHFRingEtSums fromGctEmulator(const int16_t bx, const uint16_t etSumPosEtaRing1, const uint16_t etSumNegEtaRing1, const uint16_t etSumPosEtaRing2, const uint16_t etSumNegEtaRing2)
named ctor for GCT emulator
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< L1GctEtMiss > L1GctEtMissCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< L1GctEtHad > L1GctEtHadCollection
Level-1 Trigger jet candidate.
Definition: L1GctJetCand.h:18
std::vector< L1GctInternHtMiss > L1GctInternHtMissCollection
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:18
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:22
std::vector< L1GctEtTotal > L1GctEtTotalCollection
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:18
virtual void beginRun(Run const &iR, EventSetup const &iE)
void setEtSum(unsigned i, uint16_t et)
set a sum
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:18
L1 GCT HF ring Et sums.
virtual void produce(Event &, EventSetup const &) override
std::vector< L1GctHtMiss > L1GctHtMissCollection
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
static void fillDescriptions(ConfigurationDescriptions &descriptions)
std::vector< L1GctInternEtSum > L1GctInternEtSumCollection
virtual void endRun(Run const &iR, EventSetup const &iE)
L1TCaloUpgradeToGCTConverter(const ParameterSet &)
Definition: Run.h:41
std::vector< EGamma >::const_iterator const_iterator
Definition: BXVector.h:16
std::vector< L1GctEmCand > L1GctEmCandCollection