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