13 #include "L1Trigger/L1TGlobal/src/L1TMenuEditor/L1TriggerMenu.hxx"
17 #include <boost/program_options.hpp>
25 #define M_PI 3.14159265358979323846
106 using namespace boost;
107 namespace po = boost::program_options;
115 po::options_description desc(
"Main options");
117 (
"vector_file,i", po::value<std::string>(&vector_file)->default_value(
""),
"Input file")
118 (
"menu_file,m", po::value<std::string>(&xml_file)->default_value(
""),
"Menu file")
119 (
"hist_file,o", po::value<std::string>(&histo_file)->default_value(
""),
"Output histogram file")
120 (
"dumpEvents,d", po::value<bool>(&dumpEvents)->default_value(
false),
"Dump event-by-event information")
121 (
"maxEvents,n", po::value<int>(&
maxEvents)->default_value(-1),
"Number of events (default is all)")
122 (
"help,h",
"Produce help message")
125 po::variables_map vm, vm0;
129 po::store(po::command_line_parser(argc, argv).
options(desc).allow_unregistered().
run(), vm0);
132 std::cout <<
"Invalid options: " << ex.what() << std::endl;
133 std::cout <<
"Use readTestVector --help to get a list of all the allowed options" << std::endl;
136 std::cout <<
"Unidentified error parsing options." << std::endl;
141 if(vm0.count(
"help")) {
142 std::cout <<
"Usage: readTestVector [options]\n";
147 if( vector_file==
"" ){
148 std::cout <<
"No input file specified" << std::endl;
155 std::cout <<
"No menu file specified" << std::endl;
159 if( histo_file==
"" ){
165 histofile =
new TFile(histo_file.c_str(),
"RECREATE");
175 std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(xml_file));
178 l1t::AlgorithmList algorithms = tm->algorithms();
179 for( l1t::AlgorithmList::algorithm_const_iterator
i = algorithms.algorithm().begin();
180 i != algorithms.algorithm().end(); ++
i ){
184 int index = algorithm.index();
195 h_l1mu_charge_ =
new TH1D(
"h_l1mu_charge_",
";L1 #mu charge", 2, 0, 2 );
196 h_l1mu_quality_ =
new TH1D(
"h_l1mu_quality_",
";L1 #mu quality", 16, 0, 16 );
198 h_l1mu_num_ =
new TH1D(
"h_l1mu_num",
";L1 Number of #mu", 10, 0, 10 );
203 h_l1jet_num_ =
new TH1D(
"h_l1jet_num",
";L1 Number of jets", 13, 0, 13 );
209 h_l1eg_num_ =
new TH1D(
"h_l1eg_num",
";L1 Number of EGs", 13, 0, 13 );
215 h_l1tau_num_ =
new TH1D(
"h_l1tau_num",
";L1 Number of #tau", 13, 0, 13 );
225 std::ifstream
file(vector_file);
228 std::vector<std::string>
mu;
229 std::vector<std::string> eg;
230 std::vector<std::string>
tau;
231 std::vector<std::string>
jet;
232 std::vector<std::string> etsum;
244 if( dumpEvents ) printf(
" ==== Objects ===\n");
246 while(std::getline(file,
line)){
248 std::stringstream linestream(
line);
251 >> eg[0] >> eg[1] >> eg[2] >> eg[3] >> eg[4] >> eg[5] >> eg[6] >> eg[7] >> eg[8] >> eg[9] >> eg[10] >> eg[11]
254 >> etsum[0] >> etsum[1] >> etsum[2] >> etsum[3]
257 if( dumpEvents ) printf(
" <==== BX = %s ====>\n",bx.c_str());
266 int finOR = atoi( fin.c_str() );
270 printf(
" == Algos ==\n");
272 printf(
" Triggers with non-zero accepts\n");
274 else printf(
"\t bit\t L1A\n");
284 printf(
"\n No triggers passed\n");
293 printf(
" =========== Summary of results ==========\n");
294 printf(
" There were %d L1A out of %d events (%.1f%%)\n", l1a, evt,
float(l1a)/
float(evt)*100);
295 printf(
"\n Triggers with non-zero accepts\n");
297 else printf(
"\t bit\t L1A\n");
302 else printf(
"\t %d \t %d\n", i,
l1taccepts[i] );
320 if( verbose) printf(
" == Muons ==\n");
322 for(
unsigned int i=0;
i<muons.size();
i++ ){
332 int iso = mu.
hwIso();
345 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);
353 if( verbose) printf(
" == EGammas ==\n");
355 for(
unsigned int i=0;
i<egs.size();
i++ ){
370 if( verbose) printf(
" l1t::EGamma %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f),\t iso = %d\n",
i, eg.
hwPt(),
pt, eg.
hwEta(),
eta, eg.
hwPhi(),
phi, eg.
hwIso());
378 if( verbose) printf(
" == Taus ==\n");
380 for(
unsigned int i=0;
i<taus.size();
i++ ){
395 if( verbose) printf(
" l1t::Tau %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f),\t iso = %d\n",
i, tau.
hwPt(),
pt, tau.
hwEta(),
eta, tau.
hwPhi(),
phi, tau.
hwIso());
403 if( verbose) printf(
" == Jets ==\n");
405 for(
unsigned int i=0;
i<jets.size();
i++ ){
419 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);
427 if( verbose) printf(
" == EtSums ==\n");
435 if( verbose) printf(
" l1t::EtSum TotalEt:\t Et = %d\n", et.
hwPt());
443 if( verbose) printf(
" l1t::EtSum TotalHt:\t Ht = %d\n", ht.
hwPt());
453 if( verbose) printf(
" l1t::EtSum MissingEt:\t Et = %d,\t phi = %d\n", etm.
hwPt(), etm.
hwPhi());
463 if( verbose) printf(
" l1t::EtSum MissingHt:\t Et = %d,\t phi = %d\n", htm.
hwPt(), htm.
hwPhi());
480 std::stringstream
ss;
485 pos = 127 - int(
i/4 );
487 char* endPtr = (
char*) in.c_str();
488 algRes = strtol( in.c_str(), &endPtr, 16 );
489 accept = ( algRes >> (
i%4) ) & 1;
501 char* endPtr = (
char*) imu.c_str();
502 cms_uint64_t packedVal = strtoull( imu.c_str(), &endPtr, 16 );
504 int pt = (packedVal>>10) & 0x1ff;
505 int eta = (packedVal>>23) & 0x1ff;
506 int phi = (packedVal>>0) & 0x3ff;
507 int iso = (packedVal>>32) & 0x3;
508 int qual= (packedVal>>19) & 0xf;
509 int charge = (packedVal>>34) & 0x1;
510 int chargeValid = (packedVal>>35) & 0x1;
514 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
515 l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
522 char* endPtr = (
char*) ieg.c_str();
523 unsigned int packedVal = strtol( ieg.c_str(), &endPtr, 16 );
525 int pt = (packedVal>>0) & 0x1ff;
526 int eta = (packedVal>>9) & 0xff;
527 int phi = (packedVal>>17) & 0xff;
528 int iso = (packedVal>>25) & 0x3;
529 int qual= (packedVal>>27) & 0x31;
531 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
538 char* endPtr = (
char*) itau.c_str();
539 unsigned int packedVal = strtol( itau.c_str(), &endPtr, 16 );
541 int pt = (packedVal>>0) & 0x1ff;
542 int eta = (packedVal>>9) & 0xff;
543 int phi = (packedVal>>17) & 0xff;
544 int iso = (packedVal>>25) & 0x3;
545 int qual= (packedVal>>27) & 0x31;
547 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
555 char* endPtr = (
char*) ijet.c_str();
556 unsigned int packedVal = strtol( ijet.c_str(), &endPtr, 16 );
558 int pt = (packedVal>>0) & 0x7ff;
559 int eta = (packedVal>>11) & 0xff;
560 int phi = (packedVal>>19) & 0xff;
561 int qual= (packedVal>>27) & 0x1;
563 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
571 char* endPtr = (
char*) ietsum.c_str();
572 unsigned int packedVal = strtol( ietsum.c_str(), &endPtr, 16 );
574 int pt = (packedVal>>0) & 0xfff;
576 if( type==l1t::EtSum::EtSumType::kMissingEt ||
577 type==l1t::EtSum::EtSumType::kMissingHt ) phi = (packedVal>>12) & 0xff;
579 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
587 double pt = double(hwPt) *
step;
588 if( pt>max ) pt =
max;
594 double binWidth = 2*max/
step;
595 double eta = ( hwEta<int(hwMax/2+1.001) ) ?
double(hwEta)*binWidth+0.5*binWidth : -(double(hwMax-hwEta)*binWidth -0.5*binWidth);
599 double phi = double(hwPhi)/step * 2 *
M_PI;
void parseEGs(std::vector< std::string > egs, bool verbose)
void parseEtSums(std::vector< std::string > etsums, bool verbose)
void parseMuons(std::vector< std::string > muons, bool verbose)
std::vector< int > l1taccepts
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
void parseTaus(std::vector< std::string > taus, bool verbose)
l1t::Muon unpackMuons(std::string imu)
l1t::EtSum unpackEtSums(std::string ietsum, l1t::EtSum::EtSumType type)
double convertPhiFromHW(int hwPhi, double step)
void parseJets(std::vector< std::string > jets, bool verbose)
double convertPtFromHW(int hwPt, double max, double step)
void parseAlgo(std::string algo)
std::vector< int > l1taccepts_evt
Geom::Phi< T > phi() const
double convertEtaFromHW(int hwEta, double max, double step, int hwMax)
l1t::EGamma unpackEGs(std::string ieg)
unsigned long long cms_uint64_t
int hwChargeValid() const
l1t::Jet unpackJets(std::string ijet)
l1t::Tau unpackTaus(std::string itau)
std::vector< std::string > l1tnames
TH1D * h_l1tau_isolation_