13 #include "L1Trigger/L1TGlobal/src/L1TMenuEditor/L1TriggerMenu.hxx"
17 #include <boost/program_options.hpp>
25 #define M_PI 3.14159265358979323846
104 using namespace boost;
105 namespace po = boost::program_options;
113 po::options_description desc(
"Main 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")
123 po::variables_map vm, vm0;
127 po::store(po::command_line_parser(argc, argv).
options(desc).allow_unregistered().
run(), vm0);
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;
134 std::cout <<
"Unidentified error parsing options." << std::endl;
139 if(vm0.count(
"help")) {
140 std::cout <<
"Usage: readTestVector [options]\n";
145 if( vector_file==
"" ){
146 std::cout <<
"No input file specified" << std::endl;
153 std::cout <<
"No menu file specified" << std::endl;
157 if( histo_file==
"" ){
163 histofile =
new TFile(histo_file.c_str(),
"RECREATE");
173 std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(xml_file));
176 l1t::AlgorithmList algorithms = tm->algorithms();
177 for( l1t::AlgorithmList::algorithm_const_iterator
i = algorithms.algorithm().begin();
178 i != algorithms.algorithm().end(); ++
i ){
182 int index = algorithm.index();
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 );
196 h_l1mu_num_ =
new TH1D(
"h_l1mu_num",
";L1 Number of #mu", 10, 0, 10 );
201 h_l1jet_num_ =
new TH1D(
"h_l1jet_num",
";L1 Number of jets", 13, 0, 13 );
206 h_l1eg_num_ =
new TH1D(
"h_l1eg_num",
";L1 Number of EGs", 13, 0, 13 );
211 h_l1tau_num_ =
new TH1D(
"h_l1tau_num",
";L1 Number of #tau", 13, 0, 13 );
221 std::ifstream
file(vector_file);
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;
240 if( dumpEvents ) printf(
" ==== Objects ===\n");
242 while(std::getline(file,
line)){
244 std::stringstream linestream(
line);
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]
250 >> etsum[0] >> etsum[1] >> etsum[2] >> etsum[3]
253 if( dumpEvents ) printf(
" <==== BX = %s ====>\n",bx.c_str());
262 int finOR = atoi( fin.c_str() );
266 printf(
" == Algos ==\n");
268 printf(
" Triggers with non-zero accepts\n");
270 else printf(
"\t bit\t L1A\n");
280 printf(
"\n No triggers passed\n");
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");
293 else printf(
"\t bit\t L1A\n");
298 else printf(
"\t %d \t %d\n", i,
l1taccepts[i] );
316 if( verbose) printf(
" == Muons ==\n");
318 for(
unsigned int i=0;
i<muons.size();
i++ ){
328 int iso = mu.
hwIso();
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);
349 if( verbose) printf(
" == EGammas ==\n");
351 for(
unsigned int i=0;
i<egs.size();
i++ ){
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);
373 if( verbose) printf(
" == Taus ==\n");
375 for(
unsigned int i=0;
i<taus.size();
i++ ){
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);
397 if( verbose) printf(
" == Jets ==\n");
399 for(
unsigned int i=0;
i<jets.size();
i++ ){
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);
421 if( verbose) printf(
" == EtSums ==\n");
429 if( verbose) printf(
" l1t::EtSum TotalEt:\t Et = %d\n", et.
hwPt());
437 if( verbose) printf(
" l1t::EtSum TotalHt:\t Ht = %d\n", ht.
hwPt());
447 if( verbose) printf(
" l1t::EtSum MissingEt:\t Et = %d,\t phi = %d\n", etm.
hwPt(), etm.
hwPhi());
457 if( verbose) printf(
" l1t::EtSum MissingHt:\t Et = %d,\t phi = %d\n", htm.
hwPt(), htm.
hwPhi());
474 std::stringstream
ss;
479 pos = 127 - int(
i/4 );
481 char* endPtr = (
char*) in.c_str();
482 algRes = strtol( in.c_str(), &endPtr, 16 );
483 accept = ( algRes >> (
i%4) ) & 1;
495 char* endPtr = (
char*) imu.c_str();
496 cms_uint64_t packedVal = strtoull( imu.c_str(), &endPtr, 16 );
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;
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);
516 char* endPtr = (
char*) ieg.c_str();
517 unsigned int packedVal = strtol( ieg.c_str(), &endPtr, 16 );
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;
525 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
532 char* endPtr = (
char*) itau.c_str();
533 unsigned int packedVal = strtol( itau.c_str(), &endPtr, 16 );
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;
541 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
549 char* endPtr = (
char*) ijet.c_str();
550 unsigned int packedVal = strtol( ijet.c_str(), &endPtr, 16 );
552 int pt = (packedVal>>0) & 0x7ff;
553 int eta = (packedVal>>11) & 0xff;
554 int phi = (packedVal>>19) & 0xff;
555 int qual= (packedVal>>27) & 0x1;
557 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
565 char* endPtr = (
char*) ietsum.c_str();
566 unsigned int packedVal = strtol( ietsum.c_str(), &endPtr, 16 );
568 int pt = (packedVal>>0) & 0xfff;
570 if( type==l1t::EtSum::EtSumType::kMissingEt ||
571 type==l1t::EtSum::EtSumType::kMissingHt ) phi = (packedVal>>12) & 0xff;
573 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
581 double pt = double(hwPt) *
step;
582 if( pt>max ) pt =
max;
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);
593 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
int hwChargeValid() const
l1t::Jet unpackJets(std::string ijet)
l1t::Tau unpackTaus(std::string itau)
std::vector< std::string > l1tnames