CMS 3D CMS Logo

L1ExtraTestAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1ExtraTestAnalyzer
4 // Class: L1ExtraTestAnalyzer
5 //
12 //
13 // Original Author: Werner Sun
14 // Created: Fri Jul 28 14:22:31 EDT 2006
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 "TFile.h"
46 #include "TH1.h"
47 
48 using namespace std;
49 
50 //
51 // class decleration
52 //
53 
55 public:
56  explicit L1ExtraTestAnalyzer(const edm::ParameterSet &);
57  ~L1ExtraTestAnalyzer() override;
58 
59  void analyze(const edm::Event &, const edm::EventSetup &) override;
60 
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>("isolatedEmSource")),
93  nonIsoEmSource_(
94  iConfig.getParameter<edm::InputTag>("nonIsolatedEmSource")),
95  cenJetSource_(iConfig.getParameter<edm::InputTag>("centralJetSource")),
96  forJetSource_(iConfig.getParameter<edm::InputTag>("forwardJetSource")),
97  tauJetSource_(iConfig.getParameter<edm::InputTag>("tauJetSource")),
98  muonSource_(iConfig.getParameter<edm::InputTag>("muonSource")),
99  etMissSource_(iConfig.getParameter<edm::InputTag>("etMissSource")),
100  htMissSource_(iConfig.getParameter<edm::InputTag>("htMissSource")),
101  hfRingsSource_(iConfig.getParameter<edm::InputTag>("hfRingsSource")),
102  gtReadoutSource_(iConfig.getParameter<edm::InputTag>("gtReadoutSource")),
103  particleMapSource_(
104  iConfig.getParameter<edm::InputTag>("particleMapSource")),
105  file_("l1extra.root", "RECREATE"),
106  hist_("triggers", "Triggers",
107  2 * l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 1, -0.75,
108  l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 0.5 - 0.75) {
109  // now do what ever initialization is needed
110 }
111 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 
116  file_.cd();
117  hist_.Write();
118 }
119 
120 //
121 // member functions
122 //
123 
124 // ------------ method called to produce the data ------------
126  const edm::EventSetup &iSetup) {
127  using namespace edm;
128  using namespace l1extra;
129 
130  static int iev = 0;
131  cout << "EVENT " << ++iev << endl;
132 
133  cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
134 
135  // Isolated EM particles
137  iEvent.getByLabel(isoEmSource_, isoEmColl);
138  cout << "Number of isolated EM " << isoEmColl->size() << endl;
139 
140  for (L1EmParticleCollection::const_iterator emItr = isoEmColl->begin();
141  emItr != isoEmColl->end(); ++emItr) {
142  cout << " p4 (" << emItr->px() << ", " << emItr->py() << ", "
143  << emItr->pz() << ", " << emItr->energy() << ") et " << emItr->et()
144  << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
145  }
146 
147  // Non-isolated EM particles
148  Handle<L1EmParticleCollection> nonIsoEmColl;
149  iEvent.getByLabel(nonIsoEmSource_, nonIsoEmColl);
150  cout << "Number of non-isolated EM " << nonIsoEmColl->size() << endl;
151 
152  for (L1EmParticleCollection::const_iterator emItr = nonIsoEmColl->begin();
153  emItr != nonIsoEmColl->end(); ++emItr) {
154  cout << " p4 (" << emItr->px() << ", " << emItr->py() << ", "
155  << emItr->pz() << ", " << emItr->energy() << ") et " << emItr->et()
156  << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
157  }
158 
159  // Jet particles
161  iEvent.getByLabel(cenJetSource_, cenJetColl);
162  cout << "Number of central jets " << cenJetColl->size() << endl;
163 
164  for (L1JetParticleCollection::const_iterator jetItr = cenJetColl->begin();
165  jetItr != cenJetColl->end(); ++jetItr) {
166  cout << " p4 (" << jetItr->px() << ", " << jetItr->py() << ", "
167  << jetItr->pz() << ", " << jetItr->energy() << ") et " << jetItr->et()
168  << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
169  }
170 
172  iEvent.getByLabel(forJetSource_, forJetColl);
173  cout << "Number of forward jets " << forJetColl->size() << endl;
174 
175  for (L1JetParticleCollection::const_iterator jetItr = forJetColl->begin();
176  jetItr != forJetColl->end(); ++jetItr) {
177  cout << " p4 (" << jetItr->px() << ", " << jetItr->py() << ", "
178  << jetItr->pz() << ", " << jetItr->energy() << ") et " << jetItr->et()
179  << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
180  }
181 
183  iEvent.getByLabel(tauJetSource_, tauColl);
184  cout << "Number of tau jets " << tauColl->size() << endl;
185 
186  for (L1JetParticleCollection::const_iterator tauItr = tauColl->begin();
187  tauItr != tauColl->end(); ++tauItr) {
188  cout << " p4 (" << tauItr->px() << ", " << tauItr->py() << ", "
189  << tauItr->pz() << ", " << tauItr->energy() << ") et " << tauItr->et()
190  << " eta " << tauItr->eta() << " phi " << tauItr->phi() << endl;
191  }
192 
193  // Muon particles
195  iEvent.getByLabel(muonSource_, muColl);
196  cout << "Number of muons " << muColl->size() << endl;
197 
198  for (L1MuonParticleCollection::const_iterator muItr = muColl->begin();
199  muItr != muColl->end(); ++muItr) {
200  cout << " q " << muItr->charge() << " p4 (" << muItr->px() << ", "
201  << muItr->py() << ", " << muItr->pz() << ", " << muItr->energy()
202  << ") et " << muItr->et() << " eta " << muItr->eta() << endl
203  << " phi " << muItr->phi() << " iso " << muItr->isIsolated()
204  << " mip " << muItr->isMip() << " fwd " << muItr->isForward()
205  << " rpc " << muItr->isRPC() << endl;
206  }
207 
208  // MET
210  iEvent.getByLabel(etMissSource_, etMissColl);
211  cout << "MET Coll (" << etMissColl->begin()->px() << ", "
212  << etMissColl->begin()->py() << ", " << etMissColl->begin()->pz() << ", "
213  << etMissColl->begin()->energy() << ") phi "
214  << etMissColl->begin()->phi() << " EtTot "
215  << etMissColl->begin()->etTotal() << endl;
216 
217  // MHT
219  iEvent.getByLabel(htMissSource_, htMissColl);
220  cout << "MHT Coll (" << htMissColl->begin()->px() << ", "
221  << htMissColl->begin()->py() << ", " << htMissColl->begin()->pz() << ", "
222  << htMissColl->begin()->energy() << ") phi "
223  << htMissColl->begin()->phi() << " HtTot "
224  << htMissColl->begin()->etTotal() << endl;
225 
226  // HF Rings
227  Handle<L1HFRingsCollection> hfRingsColl;
228  iEvent.getByLabel(hfRingsSource_, hfRingsColl);
229  cout << "HF Rings:" << endl;
230  for (int i = 0; i < L1HFRings::kNumRings; ++i) {
231  cout << " " << i << ": et sum = "
232  << hfRingsColl->begin()->hfEtSum((L1HFRings::HFRingLabels)i)
233  << ", bit count = "
234  << hfRingsColl->begin()->hfBitCount((L1HFRings::HFRingLabels)i)
235  << endl;
236  }
237  cout << endl;
238 
239  // // L1GlobalTriggerReadoutRecord
240  // Handle< L1GlobalTriggerReadoutRecord > gtRecord ;
241  // iEvent.getByLabel( gtReadoutSource_, gtRecord ) ;
242  // cout << "Global trigger decision " << gtRecord->decision() << endl ;
243 
244  cout << endl;
245 }
246 
247 // define this as a plug-in
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::InputTag nonIsoEmSource_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::InputTag particleMapSource_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
edm::InputTag gtReadoutSource_
L1ExtraTestAnalyzer(const edm::ParameterSet &)
edm::InputTag hfRingsSource_
HLT enums.