CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
readTestVector.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <fstream>
4 #include <memory>
5 #include <map>
6 
12 
13 #include "L1Trigger/L1TGlobal/src/L1TMenuEditor/L1TriggerMenu.hxx"
14 
16 
17 #include <boost/program_options.hpp>
18 
19 #include "TH1.h"
20 #include "TFile.h"
21 
22 const int MAX_ALGO_BITS = 512;
23 
24 #ifndef M_PI
25 #define M_PI 3.14159265358979323846
26 #endif
27 
31 
32 std::vector<int> l1taccepts;
33 std::vector<std::string> l1tnames;
34 std::vector<int> l1taccepts_evt;
35 
36 void parseMuons( std::vector<std::string> muons, bool verbose );
37 void parseEGs( std::vector<std::string> egs, bool verbose );
38 void parseTaus( std::vector<std::string> taus, bool verbose );
39 void parseJets( std::vector<std::string> jets, bool verbose );
40 void parseEtSums(std::vector<std::string> etsums, bool verbose );
41 
42 void parseAlgo( std::string algo );
43 
49 
50 double convertPtFromHW( int hwPt, double max, double step );
51 double convertEtaFromHW( int hwEta, double max, double step, int hwMax );
52 double convertPhiFromHW( int hwPhi, double step );
53 
54 
55 TH1D* h_l1mu_pt_;
62 
67 
68 TH1D* h_l1eg_pt_;
72 
77 
78 TH1D* h_l1ht_;
79 TH1D* h_l1et_;
84 
85 
86 double MaxLepPt_ = 255;
87 double MaxJetPt_ = 1023;
88 double MaxEt_ = 2047;
89 
90 double MaxCaloEta_ = 5.0;
91 double MaxMuonEta_ = 2.45;
92 
93 double PhiStepCalo_ = 144;
94 double PhiStepMuon_ = 576;
95 
96 double EtaStepCalo_ = 230;
97 double EtaStepMuon_ = 450;
98 
99 double PtStep_ = 0.5;
100 
101 
102 // The application.
103 int main( int argc, char** argv ){
104  using namespace boost;
105  namespace po = boost::program_options;
106 
107  std::string vector_file;
108  std::string xml_file;
109  std::string histo_file;
110  bool dumpEvents;
111  int maxEvents;
112 
113  po::options_description desc("Main options");
114  desc.add_options()
115  ("vector_file,i", po::value<std::string>(&vector_file)->default_value(""), "Input file")
116  ("menu_file,m", po::value<std::string>(&xml_file)->default_value(""), "Menu file")
117  ("hist_file,o", po::value<std::string>(&histo_file)->default_value(""), "Output histogram file")
118  ("dumpEvents,d", po::value<bool>(&dumpEvents)->default_value(false), "Dump event-by-event information")
119  ("maxEvents,n", po::value<int>(&maxEvents)->default_value(-1), "Number of events (default is all)")
120  ("help,h", "Produce help message")
121  ;
122 
123  po::variables_map vm, vm0;
124 
125  // parse the first time, using only common options and allow unregistered options
126  try{
127  po::store(po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(), vm0);
128  po::notify(vm0);
129  } catch(std::exception &ex) {
130  std::cout << "Invalid options: " << ex.what() << std::endl;
131  std::cout << "Use readTestVector --help to get a list of all the allowed options" << std::endl;
132  return 999;
133  } catch(...) {
134  std::cout << "Unidentified error parsing options." << std::endl;
135  return 1000;
136  }
137 
138  // if help, print help
139  if(vm0.count("help")) {
140  std::cout << "Usage: readTestVector [options]\n";
141  std::cout << desc;
142  return 0;
143  }
144 
145  if( vector_file=="" ){
146  std::cout << "No input file specified" << std::endl;
147  return 99;
148  }
149 
150  bool readXML = true;
151  if( xml_file=="" ){
152  readXML = false;
153  std::cout << "No menu file specified" << std::endl;
154  }
155 
156  bool output = true;
157  if( histo_file=="" ){
158  output = false;
159  }
160 
161  TFile* histofile = NULL;
162  if( output ){
163  histofile = new TFile(histo_file.c_str(),"RECREATE");
164  histofile->cd();
165  }
166 
167  l1taccepts.resize(MAX_ALGO_BITS);
169  for( unsigned int i=0; i<l1taccepts.size(); i++ ) l1taccepts[i] = 0;
170 
171  if( readXML ){
172  // Load XML.
173  std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(xml_file));
174 
175  l1tnames.resize(MAX_ALGO_BITS);
176  l1t::AlgorithmList algorithms = tm->algorithms();
177  for( l1t::AlgorithmList::algorithm_const_iterator i = algorithms.algorithm().begin();
178  i != algorithms.algorithm().end(); ++i ){
179 
180  l1t::Algorithm algorithm = (*i);
181 
182  int index = algorithm.index();
183  std::string name = algorithm.name();
184 
185  l1tnames[index] = name;
186  }
187  }
188 
190  h_l1mu_pt_ = new TH1D("h_l1mu_pt", ";L1 #mu p_{T}", int((MaxLepPt_+PtStep_)/(PtStep_) + 1.001), 0, MaxLepPt_+PtStep_ );
191  h_l1mu_eta_ = new TH1D("h_l1mu_eta",";L1 #mu #eta", int(EtaStepMuon_/2+0.0001), -MaxMuonEta_, MaxMuonEta_ );
192  h_l1mu_phi_ = new TH1D("h_l1mu_phi",";L1 #mu #phi", PhiStepMuon_+1, 0, 2*M_PI );
193  h_l1mu_charge_ = new TH1D("h_l1mu_charge_",";L1 #mu charge", 2, 0, 2 );
194  h_l1mu_quality_ = new TH1D("h_l1mu_quality_",";L1 #mu quality", 16, 0, 16 );
195  h_l1mu_isolation_ = new TH1D("h_l1mu_isolation_",";L1 #mu isolation", 4, 0, 4 );
196  h_l1mu_num_ = new TH1D("h_l1mu_num",";L1 Number of #mu", 10, 0, 10 );
197 
198  h_l1jet_pt_ = new TH1D("h_l1jet_pt", ";L1 jet p_{T}", int((MaxJetPt_+PtStep_)/(4*PtStep_) + 1.001), 0, MaxJetPt_+PtStep_ );
199  h_l1jet_eta_ = new TH1D("h_l1jet_eta",";L1 jet #eta", int(EtaStepCalo_/2+0.0001), -MaxCaloEta_, MaxCaloEta_ );
200  h_l1jet_phi_ = new TH1D("h_l1jet_phi",";L1 jet #phi", PhiStepCalo_+1, 0, 2*M_PI );
201  h_l1jet_num_ = new TH1D("h_l1jet_num",";L1 Number of jets", 13, 0, 13 );
202 
203  h_l1eg_pt_ = new TH1D("h_l1eg_pt", ";L1 EG p_{T}", int((MaxLepPt_+PtStep_)/(PtStep_) + 1.001), 0, MaxLepPt_+PtStep_ );
204  h_l1eg_eta_ = new TH1D("h_l1eg_eta",";L1 EG #eta", int(EtaStepCalo_/2+0.0001), -MaxCaloEta_, MaxCaloEta_ );
205  h_l1eg_phi_ = new TH1D("h_l1eg_phi",";L1 EG #phi", PhiStepCalo_+1, 0, 2*M_PI );
206  h_l1eg_num_ = new TH1D("h_l1eg_num",";L1 Number of EGs", 13, 0, 13 );
207 
208  h_l1tau_pt_ = new TH1D("h_l1tau_pt", ";L1 #tau p_{T}", int((MaxLepPt_+PtStep_)/(PtStep_) + 1.001), 0, MaxLepPt_+PtStep_ );
209  h_l1tau_eta_ = new TH1D("h_l1tau_eta",";L1 #tau #eta", int(EtaStepCalo_/2+0.0001), -MaxCaloEta_, MaxCaloEta_ );
210  h_l1tau_phi_ = new TH1D("h_l1tau_phi",";L1 #tau #phi", PhiStepCalo_+1, 0, 2*M_PI );
211  h_l1tau_num_ = new TH1D("h_l1tau_num",";L1 Number of #tau", 13, 0, 13 );
212 
213  h_l1ht_ = new TH1D("h_l1ht_", ";L1 #SigmaH_{T}", int((MaxEt_+PtStep_)/(16*PtStep_) + 1.001), 0, MaxEt_+PtStep_ );
214  h_l1et_ = new TH1D("h_l1et_", ";L1 #SigmaE_{T}", int((MaxEt_+PtStep_)/(16*PtStep_) + 1.001), 0, MaxEt_+PtStep_ );
215  h_l1htm_et_ = new TH1D("h_l1htm_et_", ";L1 Missing H_{T}", int((MaxEt_+PtStep_)/(16*PtStep_) + 1.001), 0, MaxEt_+PtStep_ );
216  h_l1etm_et_ = new TH1D("h_l1etm_et_", ";L1 Missing E_{T}", int((MaxEt_+PtStep_)/(16*PtStep_) + 1.001), 0, MaxEt_+PtStep_ );
217  h_l1htm_phi_ = new TH1D("h_l1htm_phi_", ";L1 Missing H_{T} #phi", PhiStepCalo_+1, 0, 2*M_PI );
218  h_l1etm_phi_ = new TH1D("h_l1etm_phi_", ";L1 Missing E_{T} #phi", PhiStepCalo_+1, 0, 2*M_PI );
219 
220 
221  std::ifstream file(vector_file);
223 
224  std::vector<std::string> mu;
225  std::vector<std::string> eg;
226  std::vector<std::string> tau;
227  std::vector<std::string> jet;
228  std::vector<std::string> etsum;
229  mu.resize(8);
230  eg.resize(12);
231  tau.resize(8);
232  jet.resize(12);
233  etsum.resize(4);
234 
235  std::string bx, ex, alg, fin;
236 
237  int evt=0;
238  int l1a=0;
239 
240  if( dumpEvents ) printf(" ==== Objects ===\n");
241 
242  while(std::getline(file, line)){
243  evt++;
244  std::stringstream linestream(line);
245  linestream >> bx
246  >> mu[0] >> mu[1] >> mu[2] >> mu[3] >> mu[4] >> mu[5] >> mu[6] >> mu[7]
247  >> eg[0] >> eg[1] >> eg[2] >> eg[3] >> eg[4] >> eg[5] >> eg[6] >> eg[7] >> eg[8] >> eg[9] >> eg[10] >> eg[11]
248  >> tau[0] >> tau[1] >> tau[2] >> tau[3] >> tau[4] >> tau[5] >> tau[6] >> tau[7]
249  >> jet[0] >> jet[1] >> jet[2] >> jet[3] >> jet[4] >> jet[5] >> jet[6] >> jet[7] >> jet[8] >> jet[9] >> jet[10] >> jet[11]
250  >> etsum[0] >> etsum[1] >> etsum[2] >> etsum[3]
251  >> ex >> alg >> fin;
252 
253  if( dumpEvents ) printf(" <==== BX = %s ====>\n",bx.c_str());
254  parseMuons(mu, dumpEvents);
255  parseEGs(eg, dumpEvents);
256  parseTaus(tau, dumpEvents);
257  parseJets(jet, dumpEvents);
258  parseEtSums(etsum, dumpEvents);
259 
260  parseAlgo(alg);
261 
262  int finOR = atoi( fin.c_str() );
263  l1a += finOR;
264 
265  if( dumpEvents ){
266  printf(" == Algos ==\n");
267  if( finOR ){
268  printf(" Triggers with non-zero accepts\n");
269  if( readXML && l1tnames.size()>0 ) printf("\t bit\t L1A\t Name\n");
270  else printf("\t bit\t L1A\n");
271 
272  for( int i=0; i<MAX_ALGO_BITS; i++ ){
273  if( l1taccepts_evt[i]>0 ){
274  if( readXML && l1tnames.size()>0 ) printf("\t %d \t %d \t %s\n", i, l1taccepts_evt[i], l1tnames[i].c_str());
275  else printf("\t %d \t %d\n", i, l1taccepts_evt[i] );
276  }
277  }
278  }
279  else{
280  printf("\n No triggers passed\n");
281  }
282  // extra spacing between bx
283  printf("\n\n");
284  }
285 
286  if( evt==maxEvents ) break;
287  }
288 
289  printf(" =========== Summary of results ==========\n");
290  printf(" There were %d L1A out of %d events (%.1f%%)\n", l1a, evt, float(l1a)/float(evt)*100);
291  printf("\n Triggers with non-zero accepts\n");
292  if( readXML && l1tnames.size()>0 ) printf("\t bit\t L1A\t Name\n");
293  else printf("\t bit\t L1A\n");
294 
295  for( int i=0; i<MAX_ALGO_BITS; i++ ){
296  if( l1taccepts[i]>0 ){
297  if( readXML && l1tnames.size()>0 ) printf("\t %d \t %d \t %s\n", i, l1taccepts[i], l1tnames[i].c_str());
298  else printf("\t %d \t %d\n", i, l1taccepts[i] );
299  }
300  }
301 
302 
303  if( output ){
304  histofile->Write();
305  histofile->Close();
306  }
307 
308 
309  return 0;
310 }
311 
312 
313 // Parse Objects
314 void parseMuons( std::vector<std::string> muons, bool verbose ){
315 
316  if( verbose) printf(" == Muons ==\n");
317  int nmu=0;
318  for( unsigned int i=0; i<muons.size(); i++ ){
319  std::string imu = muons[i];
320  if( imu==zeroes16 ) continue;
321  nmu++;
322  l1t::Muon mu = unpackMuons( imu );
323 
324  double pt = convertPtFromHW( mu.hwPt(), MaxLepPt_, PtStep_ );
325  double eta = convertEtaFromHW( mu.hwEta(), MaxMuonEta_, EtaStepMuon_, 0x1ff );
326  double phi = convertPhiFromHW( mu.hwPhi(), PhiStepMuon_ );
327 
328  int iso = mu.hwIso();
329  int qual = mu.hwQual();
330  int charge = mu.hwCharge();
331  int chargeValid = mu.hwChargeValid();
332 
333  h_l1mu_pt_->Fill( pt );
334  h_l1mu_eta_->Fill( eta );
335  h_l1mu_phi_->Fill( phi );
336  h_l1mu_charge_->Fill( charge );
337 
338  h_l1mu_quality_->Fill( qual );
339  h_l1mu_isolation_->Fill( iso );
340 
341  if( verbose) printf(" l1t::Muon %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f),\t iso = %d,\t qual = %d,\t charge = %d,\t chargeValid = %d\n", i, mu.hwPt(), pt, mu.hwEta(), eta, mu.hwPhi(), phi, iso, qual, charge, chargeValid);
342  }
343  h_l1mu_num_->Fill(nmu);
344 
345  return;
346 }
347 void parseEGs( std::vector<std::string> egs, bool verbose ){
348 
349  if( verbose) printf(" == EGammas ==\n");
350  int neg=0;
351  for( unsigned int i=0; i<egs.size(); i++ ){
352  std::string ieg = egs[i];
353  if( ieg==zeroes8 ) continue;
354  neg++;
355  l1t::EGamma eg = unpackEGs( ieg );
356 
357  double pt = convertPtFromHW( eg.hwPt(), MaxLepPt_, PtStep_ );
358  double eta = convertEtaFromHW( eg.hwEta(), MaxCaloEta_, EtaStepCalo_, 0xff );
359  double phi = convertPhiFromHW( eg.hwPhi(), PhiStepCalo_ );
360 
361  h_l1eg_pt_->Fill( pt );
362  h_l1eg_eta_->Fill( eta );
363  h_l1eg_phi_->Fill( phi );
364 
365  if( verbose) printf(" l1t::EGamma %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f)\n", i, eg.hwPt(), pt, eg.hwEta(), eta, eg.hwPhi(), phi);
366  }
367  h_l1eg_num_->Fill(neg);
368 
369  return;
370 }
371 void parseTaus( std::vector<std::string> taus, bool verbose ){
372 
373  if( verbose) printf(" == Taus ==\n");
374  int ntau=0;
375  for( unsigned int i=0; i<taus.size(); i++ ){
376  std::string itau = taus[i];
377  if( itau==zeroes8 ) continue;
378  ntau++;
379  l1t::Tau tau = unpackTaus( itau );
380 
381  double pt = convertPtFromHW( tau.hwPt(), MaxLepPt_, PtStep_ );
382  double eta = convertEtaFromHW( tau.hwEta(), MaxCaloEta_, EtaStepCalo_, 0xff );
383  double phi = convertPhiFromHW( tau.hwPhi(), PhiStepCalo_ );
384 
385  h_l1tau_pt_->Fill( pt );
386  h_l1tau_eta_->Fill( eta );
387  h_l1tau_phi_->Fill( phi );
388 
389  if( verbose) printf(" l1t::Tau %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f)\n", i, tau.hwPt(), pt, tau.hwEta(), eta, tau.hwPhi(), phi);
390  }
391  h_l1tau_num_->Fill(ntau);
392 
393  return;
394 }
395 void parseJets( std::vector<std::string> jets, bool verbose ){
396 
397  if( verbose) printf(" == Jets ==\n");
398  int njet=0;
399  for( unsigned int i=0; i<jets.size(); i++ ){
400  std::string ijet = jets[i];
401  if( ijet==zeroes8 ) continue;
402  njet++;
403  l1t::Jet jet = unpackJets( ijet );
404 
405  double pt = convertPtFromHW( jet.hwPt(), MaxJetPt_, PtStep_ );
406  double eta = convertEtaFromHW( jet.hwEta(), MaxCaloEta_, EtaStepCalo_, 0xff );
407  double phi = convertPhiFromHW( jet.hwPhi(), PhiStepCalo_ );
408 
409  h_l1jet_pt_->Fill( pt );
410  h_l1jet_eta_->Fill( eta );
411  h_l1jet_phi_->Fill( phi );
412 
413  if( verbose) printf(" l1t::Jet %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f)\n", i, jet.hwPt(), pt, jet.hwEta(), eta, jet.hwPhi(), phi);
414  }
415  h_l1jet_num_->Fill(njet);
416 
417  return;
418 }
419 void parseEtSums( std::vector<std::string> etsum, bool verbose ){
420 
421  if( verbose) printf(" == EtSums ==\n");
422 
423  //et sum
424  std::string iet = etsum[0];
425  if( iet!=zeroes8 ){
426  l1t::EtSum et = unpackEtSums( iet, l1t::EtSum::EtSumType::kTotalEt );
427  double pt = convertPtFromHW( et.hwPt(), MaxEt_, PtStep_ );
428  h_l1et_->Fill( pt );
429  if( verbose) printf(" l1t::EtSum TotalEt:\t Et = %d\n", et.hwPt());
430  }
431  //ht sum
432  std::string iht = etsum[1];
433  if( iht!=zeroes8 ){
434  l1t::EtSum ht = unpackEtSums( iht, l1t::EtSum::EtSumType::kTotalHt );
435  double pt = convertPtFromHW( ht.hwPt(), MaxEt_, PtStep_ );
436  h_l1ht_->Fill( pt );
437  if( verbose) printf(" l1t::EtSum TotalHt:\t Ht = %d\n", ht.hwPt());
438  }
439  //etm
440  std::string ietm = etsum[2];
441  if( ietm!=zeroes8 ){
442  l1t::EtSum etm = unpackEtSums( ietm, l1t::EtSum::EtSumType::kMissingEt );
443  double pt = convertPtFromHW( etm.hwPt(), MaxEt_, PtStep_ );
444  double phi = convertPhiFromHW( etm.hwPhi(), PhiStepCalo_ );
445  h_l1etm_et_->Fill( pt );
446  h_l1etm_phi_->Fill( phi );
447  if( verbose) printf(" l1t::EtSum MissingEt:\t Et = %d,\t phi = %d\n", etm.hwPt(), etm.hwPhi());
448  }
449  //htm
450  std::string ihtm = etsum[3];
451  if( ihtm!=zeroes8 ){
452  l1t::EtSum htm = unpackEtSums( ihtm, l1t::EtSum::EtSumType::kMissingHt );
453  double pt = convertPtFromHW( htm.hwPt(), MaxEt_, PtStep_ );
454  double phi = convertPhiFromHW( htm.hwPhi(), PhiStepCalo_ );
455  h_l1htm_et_->Fill( pt );
456  h_l1htm_phi_->Fill( phi );
457  if( verbose) printf(" l1t::EtSum MissingHt:\t Et = %d,\t phi = %d\n", htm.hwPt(), htm.hwPhi());
458  }
459 
460  return;
461 }
462 
463 
464 // Parse Algos
466 
467  // clear the algo per event
468  l1taccepts_evt.clear();
470 
471  // Return if no triggers fired
472  if( algo==zeroes128 ) return;
473 
474  std::stringstream ss;
475  std::string s;
476  int pos, algRes, accept;
477 
478  for( int i=0; i<MAX_ALGO_BITS; i++ ){
479  pos = 127 - int( i/4 );
480  std::string in(1,algo[pos]);
481  char* endPtr = (char*) in.c_str();
482  algRes = strtol( in.c_str(), &endPtr, 16 );
483  accept = ( algRes >> (i%4) ) & 1;
484  l1taccepts_evt[i] += accept;
485  l1taccepts[i] += accept;
486  }
487 
488  return;
489 
490 }
491 
492 // Unpack Objects
494 
495  char* endPtr = (char*) imu.c_str();
496  cms_uint64_t packedVal = strtoull( imu.c_str(), &endPtr, 16 );
497 
498  int pt = (packedVal>>10) & 0x1ff;
499  int eta = (packedVal>>23) & 0x1ff;
500  int phi = (packedVal>>0) & 0x3ff;
501  int iso = (packedVal>>32) & 0x3;
502  int qual= (packedVal>>19) & 0xf;
503  int charge = (packedVal>>34) & 0x1;
504  int chargeValid = (packedVal>>35) & 0x1;
505  int mip = 1;
506  int tag = 1;
507 
508  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
509  l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
510 
511  return mu;
512 
513 }
515 
516  char* endPtr = (char*) ieg.c_str();
517  unsigned int packedVal = strtol( ieg.c_str(), &endPtr, 16 );
518 
519  int pt = (packedVal>>0) & 0x1ff;
520  int eta = (packedVal>>9) & 0xff;
521  int phi = (packedVal>>17) & 0xff;
522  int iso = (packedVal>>25) & 0x1;
523  int qual= (packedVal>>26) & 0x1;
524 
525  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
526  l1t::EGamma eg(*p4, pt, eta, phi, qual, iso);
527 
528  return eg;
529 }
531 
532  char* endPtr = (char*) itau.c_str();
533  unsigned int packedVal = strtol( itau.c_str(), &endPtr, 16 );
534 
535  int pt = (packedVal>>0) & 0x1ff;
536  int eta = (packedVal>>9) & 0xff;
537  int phi = (packedVal>>17) & 0xff;
538  int iso = (packedVal>>25) & 0x1;
539  int qual= (packedVal>>26) & 0x1;
540 
541  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
542  l1t::Tau tau(*p4, pt, eta, phi, qual, iso);
543 
544  return tau;
545 }
546 
548 
549  char* endPtr = (char*) ijet.c_str();
550  unsigned int packedVal = strtol( ijet.c_str(), &endPtr, 16 );
551 
552  int pt = (packedVal>>0) & 0x7ff;
553  int eta = (packedVal>>11) & 0xff;
554  int phi = (packedVal>>19) & 0xff;
555  int qual= (packedVal>>27) & 0x1;
556 
557  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
558  l1t::Jet jet(*p4, pt, eta, phi, qual);
559 
560  return jet;
561 }
562 
564 
565  char* endPtr = (char*) ietsum.c_str();
566  unsigned int packedVal = strtol( ietsum.c_str(), &endPtr, 16 );
567 
568  int pt = (packedVal>>0) & 0xfff;
569  int phi = 0;
570  if( type==l1t::EtSum::EtSumType::kMissingEt ||
571  type==l1t::EtSum::EtSumType::kMissingHt ) phi = (packedVal>>12) & 0xff;
572 
573  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
574  l1t::EtSum sum(*p4, type, pt, 0,phi, 0);
575 
576  return sum;
577 }
578 
579 // Conversion into physical coordinates from HW
580 double convertPtFromHW( int hwPt, double max, double step ){
581  double pt = double(hwPt) * step;
582  if( pt>max ) pt = max;
583  return pt;
584 }
585 
586 double convertEtaFromHW( int hwEta, double max, double step, int hwMax ){
587  hwMax++;
588  double binWidth = 2*max/step;
589  double eta = ( hwEta<int(hwMax/2+1.001) ) ? double(hwEta)*binWidth+0.5*binWidth : -(double(hwMax-hwEta)*binWidth -0.5*binWidth);
590  return eta;
591 }
592 double convertPhiFromHW( int hwPhi, double step ){
593  double phi = double(hwPhi)/step * 2 * M_PI;
594  return phi;
595 }
596 
597 
598 // eof
599 
type
Definition: HCALResponse.h:21
double MaxEt_
TH1D * h_l1mu_quality_
int i
Definition: DBlmapReader.cc:9
TH1D * h_l1et_
void parseEGs(std::vector< std::string > egs, bool verbose)
TH1D * h_l1eg_eta_
void parseEtSums(std::vector< std::string > etsums, bool verbose)
TH1D * h_l1mu_num_
TH1D * h_l1mu_charge_
std::string zeroes128
Definition: Tau.h:13
void parseMuons(std::vector< std::string > muons, bool verbose)
#define NULL
Definition: scimark2.h:8
std::vector< int > l1taccepts
int hwPhi() const
Definition: L1Candidate.cc:79
TH1D * h_l1eg_num_
TH1D * h_l1etm_et_
T eta() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:25
int njet
Definition: HydjetWrapper.h:90
void parseTaus(std::vector< std::string > taus, bool verbose)
double MaxMuonEta_
TH1D * h_l1mu_pt_
int main(int argc, char **argv)
TH1D * h_l1tau_num_
int hwIso() const
Definition: L1Candidate.cc:84
Definition: Jet.h:13
TH1D * h_l1eg_pt_
l1t::Muon unpackMuons(std::string imu)
double MaxJetPt_
double PhiStepCalo_
double EtaStepMuon_
TH1D * h_l1etm_phi_
std::string zeroes16
string histofile
Definition: jetmet_cfg.py:4
l1t::EtSum unpackEtSums(std::string ietsum, l1t::EtSum::EtSumType type)
TH1D * h_l1ht_
TH1D * h_l1jet_phi_
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
double convertPhiFromHW(int hwPhi, double step)
void parseJets(std::vector< std::string > jets, bool verbose)
double convertPtFromHW(int hwPt, double max, double step)
TH1D * h_l1mu_isolation_
void parseAlgo(std::string algo)
double PtStep_
double MaxCaloEta_
double PhiStepMuon_
const int mu
Definition: Constants.h:22
int hwEta() const
Definition: L1Candidate.cc:74
TH1D * h_l1tau_eta_
int hwQual() const
Definition: L1Candidate.cc:89
#define M_PI
const int MAX_ALGO_BITS
TH1D * h_l1eg_phi_
Definition: Muon.h:12
TH1D * h_l1jet_pt_
std::vector< int > l1taccepts_evt
TH1D * h_l1tau_pt_
double MaxLepPt_
int hwPt() const
Definition: L1Candidate.cc:69
TH1D * h_l1htm_phi_
tuple argc
Definition: dir2webdir.py:38
TH1D * h_l1jet_eta_
tuple muons
Definition: patZpeak.py:38
double convertEtaFromHW(int hwEta, double max, double step, int hwMax)
std::string zeroes8
tuple cout
Definition: gather_cfg.py:121
l1t::EGamma unpackEGs(std::string ieg)
TH1D * h_l1tau_phi_
unsigned long long cms_uint64_t
Definition: typedefs.h:17
TH1D * h_l1mu_eta_
int hwChargeValid() const
Definition: Muon.cc:54
l1t::Jet unpackJets(std::string ijet)
TH1D * h_l1jet_num_
TH1D * h_l1htm_et_
EtSumType
Definition: EtSum.h:17
TH1D * h_l1mu_phi_
l1t::Tau unpackTaus(std::string itau)
std::vector< std::string > l1tnames
int hwCharge() const
Definition: Muon.cc:49
Definition: DDAxes.h:10
double EtaStepCalo_