CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GtInputDump.cc
Go to the documentation of this file.
1 
12 //
13 // This simple module simply retreives the YellowParams object from the event
14 // setup, and sends its payload as an INFO message, for debugging purposes.
15 //
16 
18 
20 //#include "FWCore/ParameterSet/interface/InputTag.h"
21 
22 // system include files
23 #include <iomanip>
24 
25 // user include files
26 // base class
28 
35 
41 
44 
45 using namespace edm;
46 using namespace std;
47 
48 namespace l1t {
49 
50  // class declaration
51  class GtInputDump : public edm::EDAnalyzer {
52  public:
53  explicit GtInputDump(const edm::ParameterSet&);
54  ~GtInputDump() override{};
55  void analyze(const edm::Event&, const edm::EventSetup&) override;
56 
62 
63  int m_minBx;
64  int m_maxBx;
65  };
66 
67  GtInputDump::GtInputDump(const edm::ParameterSet& iConfig) {
68  egToken = consumes<BXVector<l1t::EGamma>>(iConfig.getParameter<InputTag>("egInputTag"));
69  muToken = consumes<BXVector<l1t::Muon>>(iConfig.getParameter<InputTag>("muInputTag"));
70  tauToken = consumes<BXVector<l1t::Tau>>(iConfig.getParameter<InputTag>("tauInputTag"));
71  jetToken = consumes<BXVector<l1t::Jet>>(iConfig.getParameter<InputTag>("jetInputTag"));
72  etsumToken = consumes<BXVector<l1t::EtSum>>(iConfig.getParameter<InputTag>("etsumInputTag"));
73 
74  m_minBx = iConfig.getParameter<int>("minBx");
75  m_maxBx = iConfig.getParameter<int>("maxBx");
76  }
77 
78  // loop over events
79  void GtInputDump::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
80  //inputs
82  iEvent.getByToken(egToken, egammas);
83 
85  iEvent.getByToken(muToken, muons);
86 
88  iEvent.getByToken(tauToken, taus);
89 
91  iEvent.getByToken(jetToken, jets);
92 
94  iEvent.getByToken(etsumToken, etsums);
95 
96  printf("\n -------------------------------------- \n");
97  printf(" *********** New Event ************** \n");
98  printf(" -------------------------------------- \n");
99  //Loop over BX
100  //Loop over BX
101  for (int i = m_minBx; i <= m_maxBx; ++i) {
102  cout << " ========== BX = " << std::dec << i << " =============================" << endl;
103 
104  //Loop over EGamma
105  int nObj = 0;
106  cout << " ------ EGammas -------- " << endl;
107  if (egammas.isValid()) {
108  if (i >= egammas->getFirstBX() && i <= egammas->getLastBX()) {
109  for (std::vector<l1t::EGamma>::const_iterator eg = egammas->begin(i); eg != egammas->end(i); ++eg) {
110  cout << " " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
111  cout << " Pt " << std::dec << std::setw(3) << eg->hwPt() << " (0x" << std::hex << std::setw(3)
112  << std::setfill('0') << eg->hwPt() << ")";
113  cout << " Eta " << std::dec << std::setw(3) << eg->hwEta() << " (0x" << std::hex << std::setw(2)
114  << std::setfill('0') << (eg->hwEta() & 0xff) << ")";
115  cout << " Phi " << std::dec << std::setw(3) << eg->hwPhi() << " (0x" << std::hex << std::setw(2)
116  << std::setfill('0') << eg->hwPhi() << ")";
117  cout << " Iso " << std::dec << std::setw(1) << eg->hwIso();
118  cout << " Qual " << std::dec << std::setw(1) << eg->hwQual();
119  cout << endl;
120  nObj++;
121  }
122  } else {
123  cout << "No EG stored for this bx " << i << endl;
124  }
125  } else {
126  cout << "No EG Data in this event " << endl;
127  }
128 
129  //Loop over Muons
130  nObj = 0;
131  cout << " ------ Muons --------" << endl;
132  if (muons.isValid()) {
133  if (i >= muons->getFirstBX() && i <= muons->getLastBX()) {
134  for (std::vector<l1t::Muon>::const_iterator mu = muons->begin(i); mu != muons->end(i); ++mu) {
135  cout << " " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
136  cout << " Pt " << std::dec << std::setw(3) << mu->hwPt() << " (0x" << std::hex << std::setw(3)
137  << std::setfill('0') << mu->hwPt() << ")";
138  cout << " EtaAtVtx " << std::dec << std::setw(3) << mu->hwEtaAtVtx() << " (0x" << std::hex << std::setw(3)
139  << std::setfill('0') << (mu->hwEtaAtVtx() & 0x1ff) << ")";
140  cout << " Eta " << std::dec << std::setw(3) << mu->hwEta() << " (0x" << std::hex << std::setw(3)
141  << std::setfill('0') << (mu->hwEta() & 0x1ff) << ")";
142  cout << " PhiAtVtx " << std::dec << std::setw(3) << mu->hwPhiAtVtx() << " (0x" << std::hex << std::setw(3)
143  << std::setfill('0') << mu->hwPhiAtVtx() << ")";
144  cout << " Phi " << std::dec << std::setw(3) << mu->hwPhi() << " (0x" << std::hex << std::setw(3)
145  << std::setfill('0') << mu->hwPhi() << ")";
146  cout << " Iso " << std::dec << std::setw(1) << mu->hwIso();
147  cout << " Qual " << std::dec << std::setw(1) << mu->hwQual();
148  cout << endl;
149  nObj++;
150  }
151  } else {
152  cout << "No Muons stored for this bx " << i << endl;
153  }
154  } else {
155  cout << "No Muon Data in this event " << endl;
156  }
157 
158  //Loop over Taus
159  nObj = 0;
160  cout << " ------ Taus ----------" << endl;
161  if (taus.isValid()) {
162  if (i >= taus->getFirstBX() && i <= taus->getLastBX()) {
163  for (std::vector<l1t::Tau>::const_iterator tau = taus->begin(i); tau != taus->end(i); ++tau) {
164  cout << " " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
165  cout << " Pt " << std::dec << std::setw(3) << tau->hwPt() << " (0x" << std::hex << std::setw(3)
166  << std::setfill('0') << tau->hwPt() << ")";
167  cout << " Eta " << std::dec << std::setw(3) << tau->hwEta() << " (0x" << std::hex << std::setw(2)
168  << std::setfill('0') << (tau->hwEta() & 0xff) << ")";
169  cout << " Phi " << std::dec << std::setw(3) << tau->hwPhi() << " (0x" << std::hex << std::setw(2)
170  << std::setfill('0') << tau->hwPhi() << ")";
171  cout << " Iso " << std::dec << std::setw(1) << tau->hwIso();
172  cout << " Qual " << std::dec << std::setw(1) << tau->hwQual();
173  cout << endl;
174  nObj++;
175  }
176  } else {
177  cout << "No Taus stored for this bx " << i << endl;
178  }
179  } else {
180  cout << "No Tau Data in this event " << endl;
181  }
182 
183  //Loop over Jets
184  nObj = 0;
185  cout << " ------ Jets ----------" << endl;
186  if (jets.isValid()) {
187  if (i >= jets->getFirstBX() && i <= jets->getLastBX()) {
188  for (std::vector<l1t::Jet>::const_iterator jet = jets->begin(i); jet != jets->end(i); ++jet) {
189  cout << " " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
190  cout << " Pt " << std::dec << std::setw(3) << jet->hwPt() << " (0x" << std::hex << std::setw(3)
191  << std::setfill('0') << jet->hwPt() << ")";
192  cout << " Eta " << std::dec << std::setw(3) << jet->hwEta() << " (0x" << std::hex << std::setw(2)
193  << std::setfill('0') << (jet->hwEta() & 0xff) << ")";
194  cout << " Phi " << std::dec << std::setw(3) << jet->hwPhi() << " (0x" << std::hex << std::setw(2)
195  << std::setfill('0') << jet->hwPhi() << ")";
196  cout << " Qual " << std::dec << std::setw(1) << jet->hwQual();
197  cout << endl;
198  nObj++;
199  }
200  } else {
201  cout << "No Jets stored for this bx " << i << endl;
202  }
203  } else {
204  cout << "No jet Data in this event " << endl;
205  }
206 
207  //Dump Content
208  cout << " ------ EtSums ----------" << endl;
209  if (etsums.isValid()) {
210  if (i >= etsums->getFirstBX() && i <= etsums->getLastBX()) {
211  for (std::vector<l1t::EtSum>::const_iterator etsum = etsums->begin(i); etsum != etsums->end(i); ++etsum) {
212  switch (etsum->getType()) {
214  cout << " ETM: ";
215  break;
217  cout << " HTM: ";
218  break;
220  cout << " ETT: ";
221  break;
223  cout << " HTT: ";
224  break;
225  default:
226  cout << " Unknown: ";
227  break;
228  }
229  cout << " Et " << std::dec << std::setw(3) << etsum->hwPt() << " (0x" << std::hex << std::setw(3)
230  << std::setfill('0') << etsum->hwPt() << ")";
231  if (etsum->getType() == l1t::EtSum::EtSumType::kMissingEt ||
232  etsum->getType() == l1t::EtSum::EtSumType::kMissingHt)
233  cout << " Phi " << std::dec << std::setw(3) << etsum->hwPhi() << " (0x" << std::hex << std::setw(2)
234  << std::setfill('0') << etsum->hwPhi() << ")";
235  cout << endl;
236  }
237  } else {
238  cout << "No EtSums stored for this bx " << i << endl;
239  }
240  } else {
241  cout << "No EtSum Data in this event " << endl;
242  }
243  }
244  printf("\n");
245  }
246 
247 } // namespace l1t
248 
EDGetToken muToken
Definition: GtInputDump.cc:58
EDGetToken jetToken
Definition: GtInputDump.cc:60
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~GtInputDump() override
Definition: GtInputDump.cc:54
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
vector< PseudoJet > jets
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
const int mu
Definition: Constants.h:22
bool isValid() const
Definition: HandleBase.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EDGetToken egToken
Definition: GtInputDump.cc:57
tuple muons
Definition: patZpeak.py:39
tuple cout
Definition: gather_cfg.py:144
EDGetToken tauToken
Definition: GtInputDump.cc:59
EDGetToken etsumToken
Definition: GtInputDump.cc:61