5 #include "canvas/Utilities/InputTag.h"
6 #include "gallery/Event.h"
10 #include "art/Framework/Services/Registry/ServiceHandle.h"
19 std::cout <<
"Usage: webevd [-d DET] [-e [[RUN:]SUBRUN:]EVT] events.root [more_events.root...]" << std::endl;
42 std::cerr <<
"Unknown detector enum " << int(det) << std::endl;
69 const std::map<std::string, EDetector> auto_fname_mapping = {
78 for(
auto it: auto_fname_mapping){
79 if(fname.find(it.first) != std::string::npos)
return it.second;
87 std::string fclConfig;
92 "#include \"services_dune.fcl\"\n"
93 "@table::dunefd_services\n"
94 "Geometry.GDML: \"dune10kt_v1_1x2x6.gdml\"\n";
100 "#include \"services_dune.fcl\"\n"
101 "@table::protodunedphase_simulation_services\n";
106 "#include \"services_dune.fcl\"\n"
107 "@table::protodune_services\n";
112 "#include \"services_sbnd.fcl\"\n"
113 "@table::sbnd_services\n";
118 "#include \"services_common_icarus.fcl\"\n"
119 "@table::icarus_common_services\n";
123 std::cout <<
"Don't know how to configure services for " << det << std::endl;
129 "scheduler: @erase \n"
130 "BackTrackerService: @erase \n"
131 "PhotonBackTrackerService: @erase \n"
133 "TFileService: @erase \n";
139 int main(
int argc,
char** argv)
141 if(argc == 1)
usage();
147 int tgt_run = -1, tgt_subrun = -1, tgt_evt = -1;
149 while(argc >= 1 && argv[0][0] ==
'-'){
150 if(std::string(argv[0]) ==
"-d"){
151 if(argc < 2)
usage();
153 const std::string d(argv[1]);
158 std::cout <<
"Unrecognized detector '" << d <<
"'" << std::endl;
167 if(std::string(argv[0]) ==
"-e"){
168 if(argc < 2)
usage();
170 std::vector<int> toks;
172 char* ptok = strtok(argv[1],
":");
174 toks.push_back(atoi(ptok));
175 ptok = strtok(0,
":");
178 if(toks.empty() || toks.size() > 3)
usage();
180 tgt_evt = toks[toks.size()-1];
181 std::cout <<
"Will look for event " << tgt_evt;
183 tgt_subrun = toks[toks.size()-2];
184 std::cout <<
" in subrun " << tgt_subrun;
187 tgt_run = toks[toks.size()-3];
197 if(std::string(argv[0]) ==
"--help" ||
198 std::string(argv[0]) ==
"-h")
usage();
201 std::cout <<
"Unknown argument " << argv[0] << std::endl;
206 std::cout <<
"Must specify at least one input file" << std::endl;
210 const std::vector<std::string> filenames(argv, argv + argc);
216 std::cout <<
"Unable to auto-detect detector from filename. Please specify it explicitly with -d" << std::endl;
220 std::cout <<
"Auto-detected geometry as " << det << std::endl;
236 std::cout <<
"Filling index of event numbers..." << std::endl;
237 std::map<art::EventID, std::pair<long long, long long>> seek_index;
238 for(gallery::Event
evt(filenames); !
evt.atEnd();
evt.next()){
239 seek_index[
evt.eventAuxiliary().eventID()] = std::make_pair(
evt.fileEntry(),
evt.eventEntry());
243 for(gallery::Event
evt(filenames); !
evt.atEnd();){
244 const art::EventAuxiliary& aux =
evt.eventAuxiliary();
246 if(tgt_run >= 0 || tgt_subrun >= 0 || tgt_evt >= 0){
247 if((tgt_run >= 0 &&
int(aux.run()) != tgt_run ) ||
248 (tgt_subrun >= 0 && int(aux.subRun()) != tgt_subrun) ||
249 (tgt_evt >= 0 && int(aux.event()) != tgt_evt )){
256 tgt_run = tgt_subrun = tgt_evt = -1;
259 std::cout <<
"\nDisplaying event " << aux.run() <<
":" << aux.subRun() <<
":" << aux.event() << std::endl << std::endl;
271 std::cout <<
"Previous event" << std::endl;
279 if(seek_index.find(tgt) == seek_index.end()){
280 std::cout << tgt <<
" not found in event index! Abort." << std::endl;
284 while(std::make_pair(
evt.fileEntry(),
evt.eventEntry()) < seek_index[tgt])
evt.next();
285 while(std::make_pair(
evt.fileEntry(),
evt.eventEntry()) > seek_index[tgt])
evt.previous();
298 std::cout <<
"Unrecognized result code " << res.
code <<
"!" << std::endl;
BEGIN_PROLOG could also be cerr
std::string FCLConfigForDetector(EDetector det)
static void load_services(std::string const &config)
std::string GDMLFile() const
Returns the full directory path to the GDML file source.
Description of geometry of one entire detector.
EDetector DetectorFromArgument(const std::string &d)
Result serve(const T &evt, const geo::GeometryCore *geom, const detinfo::DetectorPropertiesData &detprop)
EDetector DetectorFromFilename(const std::string &fname)
int main(int argc, char **argv)
std::ostream & operator<<(std::ostream &out, lar::example::CheatTrack const &track)
art framework interface to geometry description
BEGIN_PROLOG could also be cout