13 #include "L1Trigger/L1TGlobal/src/L1TMenuEditor/L1TriggerMenu.hxx"
17 #include <boost/program_options.hpp>
25 #define M_PI 3.14159265358979323846
101 using namespace boost;
102 namespace po = boost::program_options;
110 po::options_description desc(
"Main options");
112 (
"vector_file,i", po::value<std::string>(&vector_file)->default_value(
""),
"Input file")
113 (
"menu_file,m", po::value<std::string>(&xml_file)->default_value(
""),
"Menu file")
114 (
"hist_file,o", po::value<std::string>(&histo_file)->default_value(
""),
"Output histogram file")
115 (
"dumpEvents,d", po::value<bool>(&dumpEvents)->default_value(
false),
"Dump event-by-event information")
116 (
"maxEvents,n", po::value<int>(&
maxEvents)->default_value(-1),
"Number of events (default is all)")
117 (
"help,h",
"Produce help message")
120 po::variables_map vm, vm0;
124 po::store(po::command_line_parser(argc, argv).
options(desc).allow_unregistered().
run(), vm0);
127 std::cout <<
"Invalid options: " << ex.what() << std::endl;
128 std::cout <<
"Use readTestVector --help to get a list of all the allowed options" << std::endl;
131 std::cout <<
"Unidentified error parsing options." << std::endl;
136 if(vm0.count(
"help")) {
137 std::cout <<
"Usage: readTestVector [options]\n";
142 if( vector_file==
"" ){
143 std::cout <<
"No input file specified" << std::endl;
150 std::cout <<
"No menu file specified" << std::endl;
154 if( histo_file==
"" ){
160 histofile =
new TFile(histo_file.c_str(),
"RECREATE");
170 std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(xml_file));
173 l1t::AlgorithmList algorithms = tm->algorithms();
174 for( l1t::AlgorithmList::algorithm_const_iterator
i = algorithms.algorithm().begin();
175 i != algorithms.algorithm().end(); ++
i ){
179 int index = algorithm.index();
190 h_l1mu_num_ =
new TH1D(
"h_l1mu_num",
";L1 Number of #mu", 10, 0, 10 );
195 h_l1jet_num_ =
new TH1D(
"h_l1jet_num",
";L1 Number of jets", 13, 0, 13 );
200 h_l1eg_num_ =
new TH1D(
"h_l1eg_num",
";L1 Number of EGs", 13, 0, 13 );
205 h_l1tau_num_ =
new TH1D(
"h_l1tau_num",
";L1 Number of #tau", 13, 0, 13 );
215 std::ifstream
file(vector_file);
218 std::vector<std::string>
mu;
219 std::vector<std::string> eg;
220 std::vector<std::string>
tau;
221 std::vector<std::string>
jet;
222 std::vector<std::string> etsum;
234 if( dumpEvents ) printf(
" ==== Objects ===\n");
236 while(std::getline(file,
line)){
238 std::stringstream linestream(
line);
241 >> eg[0] >> eg[1] >> eg[2] >> eg[3] >> eg[4] >> eg[5] >> eg[6] >> eg[7] >> eg[8] >> eg[9] >> eg[10] >> eg[11]
244 >> etsum[0] >> etsum[1] >> etsum[2] >> etsum[3]
247 if( dumpEvents ) printf(
" <==== BX = %s ====>\n",bx.c_str());
256 int finOR = atoi( fin.c_str() );
260 printf(
" == Algos ==\n");
262 printf(
" Triggers with nono-zero accepts\n");
264 else printf(
"\t bit\t L1A\n");
274 printf(
"\n No triggers passed\n");
283 printf(
" =========== Summary of results ==========\n");
284 printf(
" There were %d L1A out of %d events (%.1f%%)\n", l1a, evt,
float(l1a)/
float(evt)*100);
285 printf(
"\n Triggers with nono-zero accepts\n");
287 else printf(
"\t bit\t L1A\n");
292 else printf(
"\t %d \t %d\n", i,
l1taccepts[i] );
310 if( verbose) printf(
" == Muons ==\n");
312 for(
unsigned int i=0;
i<muons.size();
i++ ){
326 if( verbose) printf(
" l1t::Muon %d:\t pt = %d (%.1f),\t eta = %d (%+.2f),\t phi = %d (%.2f)\n",
i, mu.
hwPt(),
pt, mu.
hwEta(),
eta, mu.
hwPhi(),
phi);
334 if( verbose) printf(
" == EGammas ==\n");
336 for(
unsigned int i=0;
i<egs.size();
i++ ){
350 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);
358 if( verbose) printf(
" == Taus ==\n");
360 for(
unsigned int i=0;
i<taus.size();
i++ ){
374 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);
382 if( verbose) printf(
" == Jets ==\n");
384 for(
unsigned int i=0;
i<jets.size();
i++ ){
398 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);
406 if( verbose) printf(
" == EtSums ==\n");
414 if( verbose) printf(
" l1t::EtSum TotalEt:\t Et = %d\n", et.
hwPt());
422 if( verbose) printf(
" l1t::EtSum TotalHt:\t Ht = %d\n", ht.
hwPt());
432 if( verbose) printf(
" l1t::EtSum MissingEt:\t Et = %d,\t phi = %d\n", etm.
hwPt(), etm.
hwPhi());
442 if( verbose) printf(
" l1t::EtSum MissingHt:\t Et = %d,\t phi = %d\n", htm.
hwPt(), htm.
hwPhi());
459 std::stringstream
ss;
464 pos = 127 - int(
i/4 );
466 char* endPtr = (
char*) in.c_str();
467 algRes = strtol( in.c_str(), &endPtr, 16 );
468 accept = ( algRes >> (
i%4) ) & 1;
480 char* endPtr = (
char*) imu.c_str();
481 cms_uint64_t packedVal = strtoull( imu.c_str(), &endPtr, 16 );
483 int pt = (packedVal>>10) & 0x1ff;
484 int eta = (packedVal>>23) & 0x1ff;
485 int phi = (packedVal>>0) & 0x3ff;
486 int iso = (packedVal>>32) & 0x1;
487 int qual= (packedVal>>19) & 0x1;
488 int charge = (packedVal>>34) & 0x1;
489 int chargeValid = (packedVal>>35) & 0x1;
493 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
494 l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
501 char* endPtr = (
char*) ieg.c_str();
502 unsigned int packedVal = strtol( ieg.c_str(), &endPtr, 16 );
504 int pt = (packedVal>>0) & 0x1ff;
505 int eta = (packedVal>>9) & 0xff;
506 int phi = (packedVal>>17) & 0xff;
507 int iso = (packedVal>>25) & 0x1;
508 int qual= (packedVal>>26) & 0x1;
510 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
517 char* endPtr = (
char*) itau.c_str();
518 unsigned int packedVal = strtol( itau.c_str(), &endPtr, 16 );
520 int pt = (packedVal>>0) & 0x1ff;
521 int eta = (packedVal>>9) & 0xff;
522 int phi = (packedVal>>17) & 0xff;
523 int iso = (packedVal>>25) & 0x1;
524 int qual= (packedVal>>26) & 0x1;
526 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
534 char* endPtr = (
char*) ijet.c_str();
535 unsigned int packedVal = strtol( ijet.c_str(), &endPtr, 16 );
537 int pt = (packedVal>>0) & 0x7ff;
538 int eta = (packedVal>>11) & 0xff;
539 int phi = (packedVal>>19) & 0xff;
540 int qual= (packedVal>>27) & 0x1;
542 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
550 char* endPtr = (
char*) ietsum.c_str();
551 unsigned int packedVal = strtol( ietsum.c_str(), &endPtr, 16 );
553 int pt = (packedVal>>0) & 0xfff;
555 if( type==l1t::EtSum::EtSumType::kMissingEt ||
556 type==l1t::EtSum::EtSumType::kMissingHt ) phi = (packedVal>>12) & 0xff;
558 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
566 double pt = double(hwPt)/
step;
567 if( pt>max ) pt =
max;
573 double binWidth = 2*max/
step;
574 double eta = ( hwEta<int(hwMax/2+1.001) ) ?
double(hwEta)*binWidth+0.5*binWidth : -(double(hwMax-hwEta)*binWidth -0.5*binWidth);
578 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)
int main(int argc, char **argv)
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
double convertEtaFromHW(int hwEta, double max, double step, int hwMax)
l1t::EGamma unpackEGs(std::string ieg)
unsigned long long cms_uint64_t
l1t::Jet unpackJets(std::string ijet)
l1t::Tau unpackTaus(std::string itau)
std::vector< std::string > l1tnames