00001
00002
00003
00004
00005
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() << " and timestamp " << frag.timestamp();
00091
00092 if (instance_name.compare(0,9,"Container")==0) {
00093 artdaq::ContainerFragment cf(frag);
00094 std::cout << " (contents: type = " << (int) cf.fragment_type() << ", count = "
00095 << cf.block_count() << ", missing data = " << cf.missing_data()
00096 << ")" << std::endl;;
00097 if (verbosity_ > 1) {
00098 for (size_t idx = 0; idx < cf.block_count(); ++idx) {
00099 std::cout << " " << (idx+1) << ") fragment type " << (int) (cf.at(idx))->type()
00100 << " fragment timestamp " << (cf.at(idx))->timestamp() << std::endl;
00101 }
00102 }
00103 }
00104 else {
00105 std::cout << std::endl;
00106 }
00107 ++jdx;
00108 }
00109 }
00110 }
00111
00112 std::cout << "***** End of EventDump for event " << e.event() << " *****" << std::endl;
00113 }
00114 }
00115
00116 DEFINE_ART_MODULE(artdaq::EventDump)