CMS 3D CMS Logo

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