CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_(iConfig.getParameter<edm::InputTag>("nonIsolatedEmSource")),
94  cenJetSource_(iConfig.getParameter<edm::InputTag>("centralJetSource")),
95  forJetSource_(iConfig.getParameter<edm::InputTag>("forwardJetSource")),
96  tauJetSource_(iConfig.getParameter<edm::InputTag>("tauJetSource")),
97  muonSource_(iConfig.getParameter<edm::InputTag>("muonSource")),
98  etMissSource_(iConfig.getParameter<edm::InputTag>("etMissSource")),
99  htMissSource_(iConfig.getParameter<edm::InputTag>("htMissSource")),
100  hfRingsSource_(iConfig.getParameter<edm::InputTag>("hfRingsSource")),
101  gtReadoutSource_(iConfig.getParameter<edm::InputTag>("gtReadoutSource")),
102  particleMapSource_(iConfig.getParameter<edm::InputTag>("particleMapSource")),
103  file_("l1extra.root", "RECREATE"),
104  hist_("triggers",
105  "Triggers",
106  2 * l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 1,
107  -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  using namespace edm;
127  using namespace l1extra;
128 
129  static int iev = 0;
130  cout << "EVENT " << ++iev << endl;
131 
132  cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
133 
134  // Isolated EM particles
136  iEvent.getByLabel(isoEmSource_, isoEmColl);
137  cout << "Number of isolated EM " << isoEmColl->size() << endl;
138 
139  for (L1EmParticleCollection::const_iterator emItr = isoEmColl->begin(); emItr != isoEmColl->end(); ++emItr) {
140  cout << " p4 (" << emItr->px() << ", " << emItr->py() << ", " << emItr->pz() << ", " << emItr->energy() << ") et "
141  << emItr->et() << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
142  }
143 
144  // Non-isolated EM particles
145  Handle<L1EmParticleCollection> nonIsoEmColl;
146  iEvent.getByLabel(nonIsoEmSource_, nonIsoEmColl);
147  cout << "Number of non-isolated EM " << nonIsoEmColl->size() << endl;
148 
149  for (L1EmParticleCollection::const_iterator emItr = nonIsoEmColl->begin(); emItr != nonIsoEmColl->end(); ++emItr) {
150  cout << " p4 (" << emItr->px() << ", " << emItr->py() << ", " << emItr->pz() << ", " << emItr->energy() << ") et "
151  << emItr->et() << " eta " << emItr->eta() << " phi " << emItr->phi() << endl;
152  }
153 
154  // Jet particles
156  iEvent.getByLabel(cenJetSource_, cenJetColl);
157  cout << "Number of central jets " << cenJetColl->size() << endl;
158 
159  for (L1JetParticleCollection::const_iterator jetItr = cenJetColl->begin(); jetItr != cenJetColl->end(); ++jetItr) {
160  cout << " p4 (" << jetItr->px() << ", " << jetItr->py() << ", " << jetItr->pz() << ", " << jetItr->energy()
161  << ") et " << jetItr->et() << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
162  }
163 
165  iEvent.getByLabel(forJetSource_, forJetColl);
166  cout << "Number of forward jets " << forJetColl->size() << endl;
167 
168  for (L1JetParticleCollection::const_iterator jetItr = forJetColl->begin(); jetItr != forJetColl->end(); ++jetItr) {
169  cout << " p4 (" << jetItr->px() << ", " << jetItr->py() << ", " << jetItr->pz() << ", " << jetItr->energy()
170  << ") et " << jetItr->et() << " eta " << jetItr->eta() << " phi " << jetItr->phi() << endl;
171  }
172 
174  iEvent.getByLabel(tauJetSource_, tauColl);
175  cout << "Number of tau jets " << tauColl->size() << endl;
176 
177  for (L1JetParticleCollection::const_iterator tauItr = tauColl->begin(); tauItr != tauColl->end(); ++tauItr) {
178  cout << " p4 (" << tauItr->px() << ", " << tauItr->py() << ", " << tauItr->pz() << ", " << tauItr->energy()
179  << ") et " << tauItr->et() << " eta " << tauItr->eta() << " phi " << tauItr->phi() << endl;
180  }
181 
182  // Muon particles
184  iEvent.getByLabel(muonSource_, muColl);
185  cout << "Number of muons " << muColl->size() << endl;
186 
187  for (L1MuonParticleCollection::const_iterator muItr = muColl->begin(); muItr != muColl->end(); ++muItr) {
188  cout << " q " << muItr->charge() << " p4 (" << muItr->px() << ", " << muItr->py() << ", " << muItr->pz() << ", "
189  << muItr->energy() << ") et " << muItr->et() << " eta " << muItr->eta() << endl
190  << " phi " << muItr->phi() << " iso " << muItr->isIsolated() << " mip " << muItr->isMip() << " fwd "
191  << muItr->isForward() << " rpc " << muItr->isRPC() << endl;
192  }
193 
194  // MET
196  iEvent.getByLabel(etMissSource_, etMissColl);
197  cout << "MET Coll (" << etMissColl->begin()->px() << ", " << etMissColl->begin()->py() << ", "
198  << etMissColl->begin()->pz() << ", " << etMissColl->begin()->energy() << ") phi " << etMissColl->begin()->phi()
199  << " EtTot " << etMissColl->begin()->etTotal() << endl;
200 
201  // MHT
203  iEvent.getByLabel(htMissSource_, htMissColl);
204  cout << "MHT Coll (" << htMissColl->begin()->px() << ", " << htMissColl->begin()->py() << ", "
205  << htMissColl->begin()->pz() << ", " << htMissColl->begin()->energy() << ") phi " << htMissColl->begin()->phi()
206  << " HtTot " << htMissColl->begin()->etTotal() << endl;
207 
208  // HF Rings
209  Handle<L1HFRingsCollection> hfRingsColl;
210  iEvent.getByLabel(hfRingsSource_, hfRingsColl);
211  cout << "HF Rings:" << endl;
212  for (int i = 0; i < L1HFRings::kNumRings; ++i) {
213  cout << " " << i << ": et sum = " << hfRingsColl->begin()->hfEtSum((L1HFRings::HFRingLabels)i)
214  << ", bit count = " << hfRingsColl->begin()->hfBitCount((L1HFRings::HFRingLabels)i) << endl;
215  }
216  cout << endl;
217 
218  // // L1GlobalTriggerReadoutRecord
219  // Handle< L1GlobalTriggerReadoutRecord > gtRecord ;
220  // iEvent.getByLabel( gtReadoutSource_, gtRecord ) ;
221  // cout << "Global trigger decision " << gtRecord->decision() << endl ;
222 
223  cout << endl;
224 }
225 
226 // define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
edm::InputTag particleMapSource_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
edm::InputTag gtReadoutSource_
L1ExtraTestAnalyzer(const edm::ParameterSet &)
edm::InputTag hfRingsSource_
tuple cout
Definition: gather_cfg.py:144
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int iev