23 #include <boost/algorithm/string.hpp>
24 #include <boost/filesystem.hpp>
30 #include <TGraphAsymmErrors.h>
45 out <<
"Try 'hltDiff --help' for more information" << std::endl;
49 out << message << std::endl;
54 out << message << std::endl;
62 virtual unsigned int size()
const = 0;
63 virtual unsigned int size(
unsigned int trigger)
const = 0;
65 virtual unsigned int triggerIndex(
unsigned int trigger)
const = 0;
68 virtual bool prescaler(
unsigned int trigger,
unsigned int module)
const = 0;
94 virtual unsigned int size()
const override {
98 virtual unsigned int size(
unsigned int trigger)
const override {
110 virtual unsigned int triggerIndex(
unsigned int trigger)
const override {
135 return state ?
"accepted" :
"rejected";
154 virtual unsigned int size()
const override;
155 virtual unsigned int size(
unsigned int trigger)
const override;
157 virtual unsigned int triggerIndex(
unsigned int trigger)
const override;
160 virtual bool prescaler(
unsigned int trigger,
unsigned int module)
const override;
174 for (
unsigned int f = 0;
f < first.
size(); ++
f)
175 for (
unsigned int s = 0;
s < second.
size(); ++
s)
258 return config_.size(index_);
262 return config_.size(index_, trigger);
266 return config_.triggerName(index_, trigger);
270 return config_.triggerIndex(index_, trigger);
274 return config_.moduleLabel(index_, trigger, module);
278 return config_.moduleType(index_, trigger, module);
282 return config_.prescaler(index_, trigger, module);
296 static const char *
message[] = {
"not run",
"accepted",
"rejected",
"exception",
"prescaled",
"invalid" };
298 if (state > 0 and state <
Invalid)
299 return message[state];
308 return (
State) state;
319 if (
std::count(s.begin(), s.end(),
':') == 2) {
321 size_t end = s.find_last_of(
':');
322 if (end > 0 and s.at(end-1) ==
':')
325 return s.substr(0, end);
339 out <<
" by module " << module <<
" '" <<
label <<
"' [" <<
type <<
"]";
341 out <<
" at module " << module <<
" '" <<
label <<
"' [" << type <<
"]";
350 out <<
" not found\n";
360 for (
unsigned int i = 0;
i < summary.
filterKeys(index).size(); ++
i) {
365 <<
"filter id: " <<
id <<
", "
366 <<
"object id: " << candidate.
id() <<
", "
367 <<
"pT: " << candidate.
pt() <<
", "
368 <<
"eta: " << candidate.
eta() <<
", "
369 <<
"phi: " << candidate.
phi() <<
", "
370 <<
"mass: " << candidate.
mass() <<
"\n";
378 out <<
" not found\n";
395 <<
"object id: " << candidate.
id() <<
", "
396 <<
"pT: " << candidate.
pt() <<
", "
397 <<
"eta: " << candidate.
eta() <<
", "
398 <<
"phi: " << candidate.
phi() <<
", "
399 <<
"mass: " << candidate.
mass() <<
"\n";
405 std::vector<boost::iterator_range<std::string::const_iterator>> tokens;
406 boost::split(tokens, branch, boost::is_any_of(
"_."), boost::token_compress_off);
407 return boost::copy_range<std::string>(tokens[3]);
411 auto const & history =
event.processHistory();
412 if (process.empty()) {
419 if (not history.getConfigurationForProcess(process, config)) {
420 std::cerr <<
"error: the process " << process <<
" is not in the Process History" << std::endl;
424 if (pset ==
nullptr) {
425 std::cerr <<
"error: the configuration for the process " << process <<
" is not available in the Provenance" << std::endl;
438 unsigned int internal;
446 memset(buffer, 0, 12);
448 unsigned int digit = 10;
450 buffer[digit] = value % 10 + 48;
454 buffer[digit] =
sign;
461 out << std::setw(12) << diff.
count
478 int nSpaces = tab_spaces;
507 str.append(std::to_string(_int));
514 str.insert(1, _string);
522 for (std::vector<std::string>::const_iterator it = _values.begin(); it != _values.end(); ++it) {
527 if (it != --_values.end()) str.push_back(
',');
547 std::ostringstream
json;
549 json << key_string(
"file_base", file_base) <<
',';
551 json <<
key(
"files") << list_string(
files) <<
',';
553 json << key_string(
"process",
process) <<
',';
555 json <<
key(
"skipped_triggers") << list_string(skipped_triggers);
563 for (
size_t i = 0;
i < file0.length(); ++
i) {
564 bool identicalInAll =
true;
565 char character = file0.at(
i);
567 if (
file.at(
i) == character)
continue;
568 identicalInAll =
false;
571 if (!identicalInAll)
break;
572 file_base.push_back(character);
574 const unsigned int file_base_len = file_base.length();
575 if (file_base_len < 1)
return;
578 file.erase(0, file_base_len);
592 std::ostringstream
json;
593 json <<
indent(_indent) <<
key(
"configuration") <<
'{';
594 json <<
indent(_indent+1) <<
key(
"o") <<
'{';
595 json <<
o.serialise(_indent+2);
596 json <<
indent(_indent+1) <<
"},";
597 json <<
indent(_indent+1) <<
key(
"n") <<
'{';
598 json <<
n.serialise(_indent+2);
599 json <<
indent(_indent+1) <<
"},";
601 json <<
indent(_indent+1) <<
key(
"prescales") << prescales_str <<
',';
603 json <<
indent(_indent) <<
"}";
619 std::ostringstream
json;
620 json <<
indent(_indent) <<
key(
"vars") <<
'{';
621 json <<
indent(_indent+1) <<
key(
"state") << list_string(state) <<
',';
622 json <<
indent(_indent+1) <<
key(
"trigger") << list_string(trigger) <<
',';
623 json <<
indent(_indent+1) <<
key(
"trigger_passed_count") <<
'[';
624 for (std::vector<std::pair<int, int> >::const_iterator it = trigger_passed_count.begin(); it != trigger_passed_count.end(); ++it) {
625 json <<
'{' <<
key(
"o") << (*it).first <<
',' <<
key(
"n") << (*it).second <<
'}';
626 if (it != trigger_passed_count.end()-1)
630 json <<
indent(_indent+1) <<
key(
"label") << list_string(
label) <<
',';
631 json <<
indent(_indent+1) <<
key(
"type") << list_string(
type);
632 json <<
indent(_indent) <<
'}';
646 unsigned int id =
std::find(vars.label.begin(), vars.label.end(), labelName) - vars.label.begin();
647 if (
id < vars.label.size())
649 vars.label.push_back(labelName);
650 return vars.label.size()-1;
654 unsigned int id =
std::find(vars.type.begin(), vars.type.end(), typeName) - vars.type.begin();
655 if (
id < vars.type.size())
657 vars.type.push_back(typeName);
658 return vars.type.size()-1;
669 std::ostringstream
json;
670 json << key_int(
"s",
int(
s));
674 json << key_int(
"m",
m) <<
',';
675 json << key_int(
"l",
l) <<
',';
676 json << key_int(
"t",
t);
691 std::ostringstream
json;
692 json <<
indent(_indent) << key_int(
"t", tr) <<
',';
693 json <<
indent(_indent) <<
key(
"o") <<
'{' <<
o.serialise() <<
"},";
694 json <<
indent(_indent) <<
key(
"n") <<
'{' <<
n.serialise() <<
"}";
710 std::ostringstream
json;
711 json <<
indent(_indent) <<
'{' <<
"\"r\"" <<
':' <<
run <<
",\"l\":" <<
lumi <<
",\"e\":" <<
event <<
",\"t\":[";
712 for (std::vector<JsonTriggerEventState>::const_iterator it = triggerStates.begin(); it != triggerStates.end(); ++it) {
714 json << (*it).serialise(_indent+2);
715 json <<
indent(_indent+1) <<
'}';
716 if (it != --triggerStates.end()) json <<
',';
718 json <<
indent(_indent) <<
']' <<
'}';
724 run(_run),
lumi(_lumi),
event(_event), triggerStates(0) { }
728 if (triggerStates.size() > 0) {
730 if (lastTrigger.
tr == _tr)
734 return triggerStates.back();
744 writeJson(_writeJson),
745 out_filename_base(_file_name) {
746 useSingleOutFile = out_filename_base.length() > 0;
751 if ( (m_run_events.count(_run) == 0 && !useSingleOutFile) || m_run_events.size() == 0 )
752 m_run_events.emplace(_run, std::vector<JsonEvent>());
753 std::vector<JsonEvent>& v_events = useSingleOutFile ? m_run_events.begin()->second : m_run_events.at(_run);
755 if (v_events.size() > 0) {
757 if (lastEvent.
run == _run && lastEvent.
lumi == _lumi && lastEvent.
event == _event)
760 v_events.push_back(
JsonEvent(_run, _lumi, _event));
761 return v_events.back();
765 return JsonEventState(_s, _m, this->labelId(_l), this->typeId(_t));
769 if (useSingleOutFile)
770 return out_filename_base;
779 std::set<std::string> filesCreated;
780 for (
const auto& runEvents : m_run_events) {
781 const int run = runEvents.first;
782 const std::vector<JsonEvent>& v_events = runEvents.second;
784 std::ofstream out_file;
785 std::string output_name = output_filename_base(run)+=
".json";
789 out_file << vars.serialise(1) <<
',';
791 out_file <<
indent(1) <<
key(
"events") <<
'[';
792 for (std::vector<JsonEvent>::const_iterator it = v_events.begin(); it != v_events.end(); ++it) {
793 out_file << (*it).serialise(2);
794 if (it != --v_events.end()) out_file <<
',';
796 out_file <<
indent(1) <<
']';
797 out_file <<
indent(0) <<
"}";
800 filesCreated.insert(output_name);
803 printf(
"Created the following JSON files:\n");
821 Pair(
double _v,
double _e) :
v(_v),
e(_e) {};
847 name = _names.at(
id);
853 int moduleId = state.
o.
l;
855 moduleId = state.
n.
l;
856 v_lost.insert(
event);
859 v_gained.insert(
event);
862 v_changed.insert(
event);
869 return Pair(
double(v_gained.size()),
sqrt(
double(v_gained.size()) ) );
873 return Pair(
double(v_lost.size()),
sqrt(
double(v_lost.size()) ) );
877 return Pair(
double(v_changed.size()),
sqrt(
double(v_changed.size()) ) );
881 return v_changed.size() > 0;
885 return v_gained.size() > 0 || v_lost.size() > 0;
896 accepted_o(_json.vars.trigger_passed_count.at(id).
first),
897 accepted_n(_json.vars.trigger_passed_count.at(id).
second) {}
902 if (m_modules.count(moduleLabelId) == 0)
904 m_modules.at(moduleLabelId).addEntry(_event, _triggerIndex);
908 Pair gained( GenericSummary::gained() );
909 if (
type == 0)
return gained;
910 double all( accepted_n );
914 return Pair( fraction.
v / (fraction.
e + 1
e-10), 0.0 );
918 Pair lost( GenericSummary::lost() );
919 if (
type == 0)
return lost;
920 double all( accepted_o );
924 return Pair( fraction.
v / (fraction.
e + 1
e-10), 0.0 );
928 Pair changed( GenericSummary::changed() );
929 if (
type == 0)
return changed;
930 double all(
json.configuration.events - accepted_o );
934 return Pair( fraction.
v / (fraction.
e + 1
e-10), 0.0 );
942 void prepareSummaries(
const int _run,
const std::vector<JsonOutputProducer::JsonEvent>& _events) {
945 m_triggerSummary.clear();
946 m_moduleSummary.clear();
947 const size_t nTriggers(
json.vars.trigger.size() );
948 const size_t nModules(
json.vars.label.size() );
949 for (
size_t i=0;
i<nTriggers; ++
i)
951 for (
size_t i=0;
i<nModules; ++
i)
956 for (
size_t iTrigger = 0; iTrigger <
event.triggerStates.size(); ++iTrigger) {
958 m_triggerSummary.at(state.
tr).addEntry(
event, iTrigger,
json.vars.label);
960 m_moduleSummary.at(moduleId).addEntry(
event, iTrigger);
966 std::map<std::string, TH1*> m_histo;
969 int nTriggers(0), nTriggers_c(0), nTriggers_gl(0), nModules_c(0), nModules_gl(0);
971 for (
const auto& idSummary : m_triggerSummary) {
972 if (idSummary.second.accepted_o > 0) ++nTriggers;
973 if (idSummary.second.keepForGL()) ++nTriggers_gl;
974 if (idSummary.second.keepForC()) ++nTriggers_c;
976 for (
const auto& idSummary : m_moduleSummary) {
977 if (idSummary.second.keepForGL()) ++nModules_gl;
978 if (idSummary.second.keepForC()) ++nModules_c;
983 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events accepted^{OLD}", nTriggers, 0, nTriggers));
984 name =
"trigger_gained";
985 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events gained", nTriggers_gl, 0, nTriggers_gl));
986 name =
"trigger_lost";
987 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events lost", nTriggers_gl, 0, nTriggers_gl));
988 name =
"trigger_changed";
989 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events changed", nTriggers_c, 0, nTriggers_c));
990 name =
"trigger_gained_frac";
991 m_histo.emplace(name,
new TH1F(name.c_str(),
";;#frac{gained}{accepted}", nTriggers_gl, 0, nTriggers_gl));
992 name =
"trigger_lost_frac";
993 m_histo.emplace(name,
new TH1F(name.c_str(),
";;#frac{lost}{accepted}", nTriggers_gl, 0, nTriggers_gl));
994 name =
"trigger_changed_frac";
995 m_histo.emplace(name,
new TH1F(name.c_str(),
";;#frac{changed}{all - accepted}", nTriggers_c, 0, nTriggers_c));
996 name =
"module_changed";
997 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events changed", nModules_c, 0, nModules_c));
998 name =
"module_gained";
999 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events gained", nModules_gl, 0, nModules_gl));
1000 name =
"module_lost";
1001 m_histo.emplace(name,
new TH1F(name.c_str(),
";;Events lost", nModules_gl, 0, nModules_gl));
1004 size_t bin(0), bin_c(0), bin_gl(0);
1005 for (
const auto& idSummary : m_triggerSummary) {
1010 m_histo.at(
"trigger_accepted")->SetBinContent(
bin, summary.
accepted_o);
1012 m_histo.at(
"trigger_accepted")->GetXaxis()->SetBinLabel(
bin, summary.
name.c_str());
1017 m_histo.at(
"trigger_gained")->SetBinContent(bin_gl, summary.
gained().
v);
1018 m_histo.at(
"trigger_lost")->SetBinContent(bin_gl, -summary.
lost().
v);
1019 m_histo.at(
"trigger_gained_frac")->SetBinContent(bin_gl, summary.
gained(1).
v);
1020 m_histo.at(
"trigger_lost_frac")->SetBinContent(bin_gl, -summary.
lost(1).
v);
1022 m_histo.at(
"trigger_gained_frac")->SetBinError(bin_gl, summary.
gained(1).
e);
1023 m_histo.at(
"trigger_lost_frac")->SetBinError(bin_gl, -summary.
lost(1).
e);
1025 m_histo.at(
"trigger_gained")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1026 m_histo.at(
"trigger_lost")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1027 m_histo.at(
"trigger_gained_frac")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1028 m_histo.at(
"trigger_lost_frac")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1033 m_histo.at(
"trigger_changed")->SetBinContent(bin_c, summary.
changed().
v);
1034 m_histo.at(
"trigger_changed_frac")->SetBinContent(bin_c, summary.
changed(1).
v);
1036 m_histo.at(
"trigger_changed_frac")->SetBinError(bin_c, summary.
changed(1).
e);
1038 m_histo.at(
"trigger_changed")->GetXaxis()->SetBinLabel(bin_c, summary.
name.c_str());
1039 m_histo.at(
"trigger_changed_frac")->GetXaxis()->SetBinLabel(bin_c, summary.
name.c_str());
1047 for (
const auto& idSummary : m_moduleSummary) {
1053 m_histo.at(
"module_gained")->SetBinContent(bin_gl, summary.
gained().
v);
1054 m_histo.at(
"module_lost")->SetBinContent(bin_gl, -summary.
lost().
v);
1056 m_histo.at(
"module_gained")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1057 m_histo.at(
"module_lost")->GetXaxis()->SetBinLabel(bin_gl, summary.
name.c_str());
1062 m_histo.at(
"module_changed")->SetBinContent(bin_c, summary.
changed().
v);
1064 m_histo.at(
"module_changed")->GetXaxis()->SetBinLabel(bin_c, summary.
name.c_str());
1069 for (
const auto& nameHisto : m_histo) {
1071 TH1*
histo = nameHisto.second;
1072 if (name.find(
"gained") != std::string::npos || name.find(
"changed") != std::string::npos) {
1073 if (name.find(
"frac") != std::string::npos)
1074 histo->GetYaxis()->SetRangeUser(0.0, 1.0);
1076 if (name.find(
"lost") != std::string::npos) {
1077 if (name.find(
"frac") != std::string::npos)
1078 histo->GetYaxis()->SetRangeUser(-1.0, 0.0);
1084 TFile* out_file =
new TFile(file_name.c_str(),
"RECREATE");
1086 char savePath[1000];
1087 sprintf(savePath,
"DQMData/Run %d/HLT/Run summary/EventByEvent/", this->
run);
1088 out_file->mkdir(savePath);
1089 gDirectory->cd(savePath);
1090 gDirectory->Write();
1091 for (
const auto& nameHisto : m_histo)
1092 nameHisto.second->Write(nameHisto.first.c_str());
1100 FILE* out_file = fopen((file_name).c_str(),
"w");
1102 fprintf(out_file,
"Total,Accepted OLD,Accepted NEW,Gained,Lost,|G|/A_N + |L|/AO,sigma(AN)+sigma(AO),Changed,C/(T-AO),sigma(T-AO),trigger\n");
1103 for (
const auto& idSummary : m_triggerSummary) {
1105 fprintf(out_file,
"%d,%d,%d,%+.f,%+.f,%.2f%%,%.2f%%,~%.f,~%.2f%%,%.2f%%,%s\n",
1106 this->
json.configuration.events, S.
accepted_o, S.
accepted_n, S.
gained().
v, -1.0*S.
lost().
v, (S.
gained(1).
v+S.
lost(1).
v)*100.0, (S.
gained(1).
e+S.
lost(1).
e)*100.0, S.
changed().
v, S.
changed(1).
v*100.0, S.
changed(1).
e*100.0, S.
name.c_str());
1116 FILE* out_file = fopen((file_name).c_str(),
"w");
1118 fprintf(out_file,
"Total,Gained,Lost,Changed,module\n");
1119 for (
const auto& idSummary : m_moduleSummary) {
1121 fprintf(out_file,
"%d,+%.f,-%.f,~%.f,%s\n",
1137 storeROOT(_storeROOT),
1138 storeCSV(_storeCSV) {}
1141 std::vector<std::string> filesCreated;
1143 for (
const auto& runEvents :
json.m_run_events) {
1144 prepareSummaries(runEvents.first, runEvents.second);
1146 filesCreated.push_back(writeHistograms());
1148 filesCreated.push_back(writeCSV_trigger());
1149 filesCreated.push_back(writeCSV_module());
1153 printf(
"Created the following summary files:\n");
1162 std::unique_ptr<TFile>
f(TFile::Open(file.c_str()));
1163 return (f and not f->IsZombie());
1169 for (
auto const &
file: files)
1172 std::cerr <<
"hltDiff: error: file " <<
file <<
" does not exist, or is not a regular file." << std::endl;
1200 ignore_prescales(
true),
1209 std::shared_ptr<fwlite::ChainEvent> old_events;
1210 std::shared_ptr<fwlite::ChainEvent> new_events;
1213 old_events = std::make_shared<fwlite::ChainEvent>(old_files);
1217 if (new_files.size() == 1 and new_files[0] ==
"-")
1218 new_events = old_events;
1220 new_events = std::make_shared<fwlite::ChainEvent>(new_files);
1238 std::unique_ptr<HLTConfigDataEx> old_config_data;
1239 std::unique_ptr<HLTConfigDataEx> new_config_data;
1240 std::unique_ptr<HLTCommonConfig> common_config;
1245 unsigned int skipped = 0;
1246 unsigned int affected = 0;
1247 bool new_run =
true;
1248 std::vector<TriggerDiff> differences;
1251 const unsigned int nEvents =
std::min((
int)old_events->size(), (int)max_events);
1252 for (old_events->toBegin(); not old_events->atEnd(); ++(*old_events)) {
1254 if (counter%(nEvents/10) == 0) {
1255 printf(
"Processed events: %d out of %d (%d%%)\n", (
int)counter, (
int)nEvents, 10*counter/(nEvents/10));
1260 if (new_events != old_events and not new_events->to(
id)) {
1262 std::cerr <<
"run " <<
id.run() <<
", lumi " <<
id.luminosityBlock() <<
", event " <<
id.event() <<
": not found in the 'new' files, skipping." << std::endl;
1272 old_results = old_results_h.
product();
1275 std::cerr <<
"run " <<
id.run() <<
", lumi " <<
id.luminosityBlock() <<
", event " <<
id.event() <<
": 'old' TriggerResults not found, skipping." << std::endl;
1281 old_summary_h.
getByLabel<
fwlite::Event>(* old_events->event(),
"hltTriggerSummaryAOD",
"", old_process.c_str());
1283 old_summary = old_summary_h.
product();
1289 new_results = new_results_h.
product();
1292 std::cerr <<
"run " <<
id.run() <<
", lumi " <<
id.luminosityBlock() <<
", event " <<
id.event() <<
": 'new' TriggerResults not found, skipping." << std::endl;
1298 new_summary_h.
getByLabel<
fwlite::Event>(* new_events->event(),
"hltTriggerSummaryAOD",
"", new_process.c_str());
1300 new_summary = new_summary_h.
product();
1305 old_events->fillParameterSetRegistry();
1306 new_events->fillParameterSetRegistry();
1310 if (new_config_data->triggerNames() == old_config_data->triggerNames()) {
1311 old_config = old_config_data.get();
1312 new_config = new_config_data.get();
1314 common_config = std::unique_ptr<HLTCommonConfig>(
new HLTCommonConfig(*old_config_data, *new_config_data));
1317 std::cout <<
"Warning: old and new TriggerResults come from different HLT menus. Only the common " << old_config->size() <<
" triggers are compared.\n" << std::endl;
1320 differences.clear();
1321 differences.resize(old_config->
size());
1324 std::vector<std::string> states_str;
1328 for (
size_t triggerId = 0; triggerId < old_config->
size(); ++triggerId) {
1333 for (std::vector<std::string>::const_iterator it = old_config_data->triggerNames().begin(); it != old_config_data->triggerNames().end(); ++it) {
1338 for (std::vector<std::string>::const_iterator it = new_config_data->triggerNames().begin(); it != new_config_data->triggerNames().end(); ++it) {
1345 bool needs_header =
true;
1346 bool event_affected =
false;
1347 for (
unsigned int p = 0;
p < old_config->
size(); ++
p) {
1354 if (old_state ==
Pass) {
1355 ++differences[
p].count;
1357 if (old_state ==
Pass)
1359 if (new_state ==
Pass)
1362 bool trigger_affected =
false;
1364 if (old_state ==
Pass and new_state !=
Pass) {
1365 ++differences[
p].lost;
1366 trigger_affected =
true;
1367 }
else if (old_state !=
Pass and new_state ==
Pass) {
1368 ++differences[
p].gained;
1369 trigger_affected =
true;
1370 }
else if (old_results->
index(old_index) != new_results->
index(new_index)) {
1371 ++differences[
p].internal;
1372 trigger_affected =
true;
1376 if (not trigger_affected)
continue;
1378 event_affected =
true;
1379 const unsigned int old_moduleIndex = old_results->
index(old_index);
1380 const unsigned int new_moduleIndex = new_results->
index(new_index);
1389 needs_header =
false;
1390 std::cout <<
"run " <<
id.run() <<
", lumi " <<
id.luminosityBlock() <<
", event " <<
id.event() <<
": "
1397 <<
" old state is ";
1400 <<
" new state is ";
1404 if (
verbose > 1 and old_summary and new_summary) {
1406 unsigned int module =
std::min(old_moduleIndex, new_moduleIndex);
1408 std::cout <<
" old trigger candidates:\n";
1410 std::cout <<
" new trigger candidates:\n";
1420 if (event_affected and
verbose > 2 and old_summary and new_summary) {
1421 std::map<std::string, std::pair<std::string, std::string>> collections;
1424 for (
auto const & new_collection: new_summary->collectionTags())
1429 std::cout <<
" old trigger candidates:\n";
1431 std::cout <<
" new trigger candidates:\n";
1438 if (nEvents and counter >= nEvents)
1445 std::cout <<
"There are no common events between the old and new files";
1447 std::cout <<
", " << skipped <<
" events were skipped";
1450 std::cout <<
"Found " << counter <<
" matching events, out of which " << affected <<
" have different HLT results";
1452 std::cout <<
", " << skipped <<
" events were skipped";
1453 std::cout <<
"\nSee more in the files listed below...\n" << std::endl;
1464 usage: hltDiff -o|--old-files FILE1.ROOT [FILE2.ROOT ...] [-O|--old-process LABEL[:INSTANCE[:PROCESS]]]\n\
1465 -n|--new-files FILE1.ROOT [FILE2.ROOT ...] [-N|--new-process LABEL[:INSTANCE[:PROCESS]]]\n\
1466 [-m|--max-events MAXEVENTS] [-p|--prescales] [-j|--json-output] OUTPUT_FILE.JSON\n\
1467 [-r|--root-output] OUTPUT_FILE.ROOT [-f|--file-check] [-d|--debug] [-v|--verbose] [-h|--help]\n\
1469 -o|--old-files FILE1.ROOT [FILE2.ROOT ...]\n\
1470 input file(s) with the old (reference) trigger results\n\
1472 -O|--old-process PROCESS\n\
1473 process name of the collection with the old (reference) trigger results\n\
1474 default: take the 'TriggerResults' from the last process\n\
1476 -n|--new-files FILE1.ROOT [FILE2.ROOT ...]\n\
1477 input file(s) with the new trigger results to be compared with the reference\n\
1478 to read these from a different collection in the same files as\n\
1479 the reference, use '-n -' and specify the collection with -N (see below)\n\
1481 -N|--new-process PROCESS\n\
1482 process name of the collection with the new (reference) trigger results\n\
1483 default: take the 'TriggerResults' from the last process\n\
1485 -m|--max-events MAXEVENTS\n\
1486 compare only the first MAXEVENTS events\n\
1487 default: compare all the events in the original (reference) files\n\
1490 do not ignore differences caused by HLTPrescaler modules\n\
1493 produce comparison results in a JSON format\n\
1496 produce comparison results as histograms in a ROOT file\n\
1498 -F|--output-file FILE_NAME\n\
1499 combine all RUNs to files with the specified custom name: FILE_NAME.json, FILE_NAME.root\n\
1500 default: a separate output file will be produced for each RUN with names suitable for the DQM GUI\n\
1503 check existence of every old and new file before running the comparison\n\
1504 safer if files are run for the first time, but can cause a substantial delay\n\
1507 display messages about missing events and collectiions\n\
1509 -v|--verbose LEVEL\n\
1510 set verbosity level:\n\
1511 1: event-by-event comparison results\n\
1512 2: + print the trigger candidates of the affected filters\n\
1513 3: + print all the trigger candidates for the affected events\n\
1517 print this help message, and exit" << std::endl;
1525 const char optstring[] =
"dfo:O:n:N:m:pjrF:v::h";
1526 const option longopts[] = {
1527 option{
"debug", no_argument,
nullptr,
'd' },
1528 option{
"file-check", no_argument,
nullptr,
'f' },
1529 option{
"old-files", required_argument,
nullptr,
'o' },
1530 option{
"old-process", required_argument,
nullptr,
'O' },
1531 option{
"new-files", required_argument,
nullptr,
'n' },
1532 option{
"new-process", required_argument,
nullptr,
'N' },
1533 option{
"max-events", required_argument,
nullptr,
'm' },
1534 option{
"prescales", no_argument,
nullptr,
'p' },
1535 option{
"json-output", optional_argument,
nullptr,
'j' },
1536 option{
"root-output", optional_argument,
nullptr,
'r' },
1537 option{
"output-file", optional_argument,
nullptr,
'F' },
1538 option{
"verbose", optional_argument,
nullptr,
'v' },
1539 option{
"help", no_argument,
nullptr,
'h' },
1547 while ((c = getopt_long(argc, argv, optstring, longopts,
nullptr)) != -1) {
1559 while (optind < argc) {
1560 if (argv[optind][0] ==
'-')
1562 hlt->
old_files.emplace_back(argv[optind]);
1573 while (optind < argc) {
1574 if (argv[optind][0] ==
'-')
1576 hlt->
new_files.emplace_back(argv[optind]);
1609 }
else if (!optarg &&
NULL != argv[optind] &&
'-' != argv[optind][0]) {
1611 const char *tmp_optarg = argv[optind++];
unsigned int typeId(std::string typeName)
JsonEvent & pushEvent(int _run, int _lumi, int _event)
virtual unsigned int triggerIndex(unsigned int trigger) const override
virtual std::string const & triggerName(unsigned int trigger) const override
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const =0
static std::string indent(size_t _nTabs)
std::set< std::string > moduleTypeSet_
virtual bool prescaler(unsigned int trigger, unsigned int module) const override
std::vector< std::pair< unsigned int, unsigned int > > triggerIndices_
virtual bool prescaler(unsigned int trigger, unsigned int module) const override
std::string const & moduleLabel(Index index, unsigned int trigger, unsigned int module) const
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override
virtual unsigned int size(unsigned int trigger) const override
std::map< int, GenericSummary > m_modules
std::map< int, std::vector< JsonEvent > > m_run_events
unsigned int labelId(std::string labelName)
bool check_files(std::vector< std::string > const &files)
const std::vector< std::string > & collectionTags() const
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void print_trigger_candidates(std::ostream &out, trigger::TriggerEvent const &summary, edm::InputTag const &filter)
unsigned int size(Index index, unsigned int trigger) const
trigger::size_type collectionKey(trigger::size_type index) const
std::vector< std::string > skipped_triggers
std::string serialise(size_t _indent=0) const
std::vector< std::vector< std::string const * > > moduleTypes_
Pair gained(int type=0) const
const JsonOutputProducer & json
bool accept() const
Has at least one path accepted the event?
std::string writeCSV_module() const
const Keys & filterKeys(trigger::size_type index) const
View(HLTCommonConfig const &config, HLTCommonConfig::Index index)
const std::vector< std::string > & triggerNames() const
names of trigger paths
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Pair changed(int type=0) const
virtual bool prescaler(unsigned int trigger, unsigned int module) const =0
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override
unsigned int size() const
number of trigger paths in trigger table
JsonOutputProducer(bool _writeJson, std::string _file_name)
TriggerSummary(int _id, const JsonOutputProducer &_json)
void print_detailed_path_state(std::ostream &out, State state, int path, int module, HLTConfigInterface const &config)
virtual std::string const & processName() const override
std::vector< std::pair< int, int > > trigger_passed_count
std::string serialise(size_t _indent=0) const
GenericSummary(int _id, const JsonOutputProducer &_json, const std::vector< std::string > &_names)
const char * event_state(bool state)
void prepareSummaries(const int _run, const std::vector< JsonOutputProducer::JsonEvent > &_events)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual std::string const & triggerName(unsigned int trigger) const override
JsonTriggerEventState & pushTrigger(int _tr)
std::vector< JsonTriggerEventState > triggerStates
std::vector< std::string > label
HLTCommonConfig(HLTConfigDataEx const &first, HLTConfigDataEx const &second)
SummaryOutputProducer(const JsonOutputProducer &_json, bool _storeROOT, bool _storeCSV=true)
virtual std::vector< std::string > const & triggerNames() const
Single trigger physics object (e.g., an isolated muon)
U second(std::pair< T, U > const &p)
static std::string format(unsigned int value, char sign= '+')
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=0, const char *iProcessLabel=0)
std::map< int, GenericSummary > m_moduleSummary
std::vector< std::string > old_files
static std::string string(const std::string &_string, const std::string &_delim="")
virtual std::string const & moduleLabel(unsigned int trigger, unsigned int module) const override
JsonEventState eventState(State _s, int _m, const std::string &_l, const std::string &_t)
State prescaled_state(int state, int path, int module, HLTConfigInterface const &config)
virtual std::string const & triggerName(unsigned int trigger) const =0
const JsonOutputProducer & json
const Vids & filterIds(trigger::size_type index) const
ParameterSetID const & parameterSetID() const
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
std::string output_filename_base(int _run) const
Pair(double _v, double _e)
virtual std::string const & processName() const override
int addEntry(const JsonOutputProducer::JsonEvent &_event, const int _triggerIndex)
HLTConfigDataEx const & second_
std::unique_ptr< HLTConfigDataEx > getHLTConfigData(fwlite::EventBase const &event, std::string process)
const TriggerObjectCollection & getObjects() const
JsonEvent(int _run, int _lumi, int _event)
Event(int _run, int _lumi, int _event)
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
std::vector< std::string > new_files
std::string serialise(size_t _indent=0) const
static std::string key_int(const std::string &_key, int _int, const std::string &_delim="")
std::map< int, TriggerSummary > m_triggerSummary
std::string getProcessNameFromBranch(std::string const &branch)
HLTCommonConfig const & config_
std::set< Event > v_changed
std::vector< std::string > trigger
virtual unsigned int size() const override
bool getMapped(key_type const &k, value_type &result) const
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const =0
const std::string moduleType(const std::string &module) const
C++ class name of module.
std::string out_filename_base
std::string strip_process_name(std::string const &s)
std::string serialise(size_t _indent=0) const
unsigned int size(Index index) const
static std::string list_string(const std::vector< std::string > &_values, const std::string &_delim="")
void addEntry(const JsonOutputProducer::JsonEvent &_event, const int _triggerIndex, const std::vector< std::string > &_moduleNames)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual unsigned int triggerIndex(unsigned int trigger) const =0
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void print_trigger_collection(std::ostream &out, trigger::TriggerEvent const &summary, std::string const &tag)
HLTConfigDataEx(HLTConfigData data)
const std::string & processName() const
Accessors (const methods)
unsigned int triggerIndex(Index index, unsigned int trigger) const
std::vector< std::string > state
std::vector< std::string > files
virtual std::string const & processName() const =0
std::string serialise(size_t _indent=0) const
std::string writeHistograms() const
double S(const TLorentzVector &, const TLorentzVector &)
std::set< Event > v_gained
const char * path_state(State state)
HLTConfigDataEx const & first_
bool check_file(std::string const &file)
virtual unsigned int size() const =0
std::string serialise(size_t _indent=0) const
static std::atomic< unsigned int > counter
std::vector< std::string > type
std::string const & moduleType(Index index, unsigned int trigger, unsigned int module) const
bool prescaler(Index index, unsigned int trigger, unsigned int module) const
std::string const & processName(Index index) const
const std::string & moduleLabel(unsigned int trigger, unsigned int module) const
virtual unsigned int size() const override
T const * product() const
View const & getView(Index index) const
volatile std::atomic< bool > shutdown_flag false
std::vector< std::vector< bool > > prescalers_
std::string const & triggerName(Index index, unsigned int trigger) const
const std::string & triggerName(unsigned int triggerIndex) const
virtual std::string const & moduleType(unsigned int trigger, unsigned int module) const override
Pair lost(int type=0) const
JsonConfiguration configuration
JsonTriggerEventState(int _tr)
virtual unsigned int triggerIndex(unsigned int trigger) const override
JsonEventState(State _s, int _m, int _l, int _t)
static Registry * instance()
hlt::HLTState state(const unsigned int i) const
Get status of ith path.
static std::string key(const std::string &_key, const std::string &_delim="")
std::string writeCSV_trigger() const
static std::string key_string(const std::string &_key, const std::string &_string, const std::string &_delim="")
void usage(std::ostream &out) const