$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 00002 // Class: EventDump 00003 // Module Type: analyzer 00004 // File: EventDump_module.cc 00005 // Description: Prints out information about each event. 00007 00008 #include "art/Framework/Core/EDAnalyzer.h" 00009 #include "art/Framework/Core/ModuleMacros.h" 00010 #include "art/Framework/Principal/Event.h" 00011 #include "art/Framework/Principal/Handle.h" 00012 #include "canvas/Utilities/Exception.h" 00013 00014 #include "artdaq-core/Data/Fragment.hh" 00015 #include "artdaq-core/Data/ContainerFragment.hh" 00016 00017 #include <algorithm> 00018 #include <cassert> 00019 #include <cmath> 00020 #include <fstream> 00021 #include <iomanip> 00022 #include <vector> 00023 #include <iostream> 00024 00025 namespace artdaq 00026 { 00027 class EventDump; 00028 } 00029 00033 class artdaq::EventDump : public art::EDAnalyzer 00034 { 00035 public: 00046 explicit EventDump(fhicl::ParameterSet const& pset); 00047 00051 virtual ~EventDump() = default; 00052 00060 void analyze(art::Event const& e) override; 00061 00062 private: 00063 std::string raw_data_label_; 00064 int verbosity_; 00065 }; 00066 00067 00068 artdaq::EventDump::EventDump(fhicl::ParameterSet const& pset) 00069 : EDAnalyzer(pset) 00070 , raw_data_label_(pset.get<std::string>("raw_data_label", "daq")) 00071 , verbosity_(pset.get<int>("verbosity",0)) {} 00072 00073 void artdaq::EventDump::analyze(art::Event const& e) 00074 { 00075 if (verbosity_ > 0) { 00076 std::cout << "***** Start of EventDump for event " << e.event() << " *****" << std::endl; 00077 00078 std::vector< art::Handle< std::vector<artdaq::Fragment> > > fragmentHandles; 00079 e.getManyByType(fragmentHandles); 00080 00081 for (auto const& handle : fragmentHandles) 00082 { 00083 if (handle->size() > 0) { 00084 std::string instance_name = handle.provenance()->productInstanceName(); 00085 std::cout << instance_name << " fragments: " << std::endl; 00086 00087 int jdx = 1; 00088 for (auto const& frag : *handle){ 00089 std::cout << " " << jdx << ") fragment ID " << frag.fragmentID() << " has type " 00090 << (int) frag.type() << ", timestamp " << frag.timestamp() 00091 << ", and sizeBytes " << frag.sizeBytes(); 00092 00093 if (instance_name.compare(0,9,"Container")==0) { 00094 artdaq::ContainerFragment cf(frag); 00095 std::cout << " (contents: type = " << (int) cf.fragment_type() << ", count = " 00096 << cf.block_count() << ", missing data = " << cf.missing_data() 00097 << ")" << std::endl;; 00098 if (verbosity_ > 1) { 00099 for (size_t idx = 0; idx < cf.block_count(); ++idx) { 00100 std::cout << " " << (idx+1) << ") fragment type " << (int) (cf.at(idx))->type() 00101 << ", timestamp " << (cf.at(idx))->timestamp() 00102 << ", and sizeBytes " << (cf.at(idx))->sizeBytes() << std::endl; 00103 } 00104 } 00105 } 00106 else { 00107 std::cout << std::endl; 00108 } 00109 ++jdx; 00110 } 00111 } 00112 } 00113 00114 std::cout << "***** End of EventDump for event " << e.event() << " *****" << std::endl; 00115 } 00116 } 00117 00118 DEFINE_ART_MODULE(artdaq::EventDump)