CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1ExtraTestAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1ExtraTestAnalyzer
4 // Class: L1ExtraTestAnalyzer
5 //
10 //
11 // Original Author: Werner Sun
12 // Created: Fri Jul 28 14:22:31 EDT 2006
13 //
14 //
15 
16 
17 // system include files
18 #include <memory>
19 #include <string>
20 
21 // user include files
24 
27 
30 
41 
43 
44 #include "TH1.h"
45 #include "TFile.h"
46 
47 using namespace std ;
48 
49 //
50 // class decleration
51 //
52 
54  public:
55  explicit L1ExtraTestAnalyzer(const edm::ParameterSet&);
57 
58 
59  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
60  private:
61  // ----------member data ---------------------------
62 
74 
75  TFile file_ ;
76  TH1F hist_ ;
77 };
78 
79 //
80 // constants, enums and typedefs
81 //
82 
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
91  : isoEmSource_( iConfig.getParameter< edm::InputTag >(
92  "isolatedEmSource" ) ),
93  nonIsoEmSource_( iConfig.getParameter< edm::InputTag >(
94  "nonIsolatedEmSource" ) ),
95  cenJetSource_( iConfig.getParameter< edm::InputTag >(
96  "centralJetSource" ) ),
97  forJetSource_( iConfig.getParameter< edm::InputTag >(
98  "forwardJetSource" ) ),
99  tauJetSource_( iConfig.getParameter< edm::InputTag >(
100  "tauJetSource" ) ),
101  muonSource_( iConfig.getParameter< edm::InputTag >(
102  "muonSource" ) ),
103  etMissSource_( iConfig.getParameter< edm::InputTag >(
104  "etMissSource" ) ),
105  htMissSource_( iConfig.getParameter< edm::InputTag >(
106  "htMissSource" ) ),
107  hfRingsSource_( iConfig.getParameter< edm::InputTag >(
108  "hfRingsSource" ) ),
109  gtReadoutSource_( iConfig.getParameter< edm::InputTag >(
110  "gtReadoutSource" ) ),
111  particleMapSource_( iConfig.getParameter< edm::InputTag >(
112  "particleMapSource" ) ),
113  file_( "l1extra.root", "RECREATE" ),
114  hist_( "triggers", "Triggers",
115  2*l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 1,
116  -0.75,
117  l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 0.5 - 0.75 )
118 {
119  //now do what ever initialization is needed
120 
121 }
122 
123 
125 {
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 
129  file_.cd() ;
130  hist_.Write() ;
131 }
132 
133 
134 //
135 // member functions
136 //
137 
138 // ------------ method called to produce the data ------------
139 void
141  const edm::EventSetup& iSetup)
142 {
143  using namespace edm ;
144  using namespace l1extra ;
145 
146  static int iev = 0 ;
147  cout << "EVENT " << ++iev << endl ;
148 
149  cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl ;
150 
151  // Isolated EM particles
153  iEvent.getByLabel( isoEmSource_, isoEmColl ) ;
154  cout << "Number of isolated EM " << isoEmColl->size() << endl ;
155 
156  for( L1EmParticleCollection::const_iterator emItr = isoEmColl->begin() ;
157  emItr != isoEmColl->end() ;
158  ++emItr )
159  {
160  cout << " p4 (" << emItr->px()
161  << ", " << emItr->py()
162  << ", " << emItr->pz()
163  << ", " << emItr->energy()
164  << ") et " << emItr->et()
165  << " eta " << emItr->eta()
166  << " phi " << emItr->phi()
167  << endl ;
168  }
169 
170  // Non-isolated EM particles
171  Handle< L1EmParticleCollection > nonIsoEmColl ;
172  iEvent.getByLabel( nonIsoEmSource_, nonIsoEmColl ) ;
173  cout << "Number of non-isolated EM " << nonIsoEmColl->size() << endl ;
174 
175  for( L1EmParticleCollection::const_iterator emItr = nonIsoEmColl->begin() ;
176  emItr != nonIsoEmColl->end() ;
177  ++emItr )
178  {
179  cout << " p4 (" << emItr->px()
180  << ", " << emItr->py()
181  << ", " << emItr->pz()
182  << ", " << emItr->energy()
183  << ") et " << emItr->et()
184  << " eta " << emItr->eta()
185  << " phi " << emItr->phi()
186  << endl ;
187  }
188 
189  // Jet particles
191  iEvent.getByLabel( cenJetSource_, cenJetColl ) ;
192  cout << "Number of central jets " << cenJetColl->size() << endl ;
193 
194  for( L1JetParticleCollection::const_iterator jetItr = cenJetColl->begin() ;
195  jetItr != cenJetColl->end() ;
196  ++jetItr )
197  {
198  cout << " p4 (" << jetItr->px()
199  << ", " << jetItr->py()
200  << ", " << jetItr->pz()
201  << ", " << jetItr->energy()
202  << ") et " << jetItr->et()
203  << " eta " << jetItr->eta()
204  << " phi " << jetItr->phi()
205  << endl ;
206  }
207 
209  iEvent.getByLabel( forJetSource_, forJetColl ) ;
210  cout << "Number of forward jets " << forJetColl->size() << endl ;
211 
212  for( L1JetParticleCollection::const_iterator jetItr = forJetColl->begin() ;
213  jetItr != forJetColl->end() ;
214  ++jetItr )
215  {
216  cout << " p4 (" << jetItr->px()
217  << ", " << jetItr->py()
218  << ", " << jetItr->pz()
219  << ", " << jetItr->energy()
220  << ") et " << jetItr->et()
221  << " eta " << jetItr->eta()
222  << " phi " << jetItr->phi()
223  << endl ;
224  }
225 
227  iEvent.getByLabel( tauJetSource_, tauColl ) ;
228  cout << "Number of tau jets " << tauColl->size() << endl ;
229 
230  for( L1JetParticleCollection::const_iterator tauItr = tauColl->begin() ;
231  tauItr != tauColl->end() ;
232  ++tauItr )
233  {
234  cout << " p4 (" << tauItr->px()
235  << ", " << tauItr->py()
236  << ", " << tauItr->pz()
237  << ", " << tauItr->energy()
238  << ") et " << tauItr->et()
239  << " eta " << tauItr->eta()
240  << " phi " << tauItr->phi()
241  << endl ;
242  }
243 
244  // Muon particles
246  iEvent.getByLabel( muonSource_, muColl ) ;
247  cout << "Number of muons " << muColl->size() << endl ;
248 
249  for( L1MuonParticleCollection::const_iterator muItr = muColl->begin() ;
250  muItr != muColl->end() ;
251  ++muItr )
252  {
253  cout << " q " << muItr->charge()
254  << " p4 (" << muItr->px()
255  << ", " << muItr->py()
256  << ", " << muItr->pz()
257  << ", " << muItr->energy()
258  << ") et " << muItr->et()
259  << " eta " << muItr->eta() << endl
260  << " phi " << muItr->phi()
261  << " iso " << muItr->isIsolated()
262  << " mip " << muItr->isMip()
263  << " fwd " << muItr->isForward()
264  << " rpc " << muItr->isRPC()
265  << endl ;
266  }
267 
268  // MET
270  iEvent.getByLabel( etMissSource_, etMissColl ) ;
271  cout << "MET Coll (" << etMissColl->begin()->px()
272  << ", " << etMissColl->begin()->py()
273  << ", " << etMissColl->begin()->pz()
274  << ", " << etMissColl->begin()->energy()
275  << ") phi " << etMissColl->begin()->phi()
276  << " EtTot " << etMissColl->begin()->etTotal()
277  << endl ;
278 
279  // MHT
281  iEvent.getByLabel( htMissSource_, htMissColl ) ;
282  cout << "MHT Coll (" << htMissColl->begin()->px()
283  << ", " << htMissColl->begin()->py()
284  << ", " << htMissColl->begin()->pz()
285  << ", " << htMissColl->begin()->energy()
286  << ") phi " << htMissColl->begin()->phi()
287  << " HtTot " << htMissColl->begin()->etTotal()
288  << endl ;
289 
290  // HF Rings
291  Handle< L1HFRingsCollection > hfRingsColl ;
292  iEvent.getByLabel( hfRingsSource_, hfRingsColl ) ;
293  cout << "HF Rings:" << endl ;
294  for( int i = 0 ; i < L1HFRings::kNumRings ; ++i )
295  {
296  cout << " " << i << ": et sum = "
297  << hfRingsColl->begin()->hfEtSum( (L1HFRings::HFRingLabels) i )
298  << ", bit count = "
299  << hfRingsColl->begin()->hfBitCount( (L1HFRings::HFRingLabels) i )
300  << endl ;
301  }
302  cout << endl ;
303 
304 // // L1GlobalTriggerReadoutRecord
305 // Handle< L1GlobalTriggerReadoutRecord > gtRecord ;
306 // iEvent.getByLabel( gtReadoutSource_, gtRecord ) ;
307 // cout << "Global trigger decision " << gtRecord->decision() << endl ;
308 
309  cout << endl ;
310 }
311 
312 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::InputTag nonIsoEmSource_
int iEvent
Definition: GenABIO.cc:230
edm::InputTag particleMapSource_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag gtReadoutSource_
L1ExtraTestAnalyzer(const edm::ParameterSet &)
edm::InputTag hfRingsSource_
tuple cout
Definition: gather_cfg.py:121