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-demo/Overlays/ToyFragment.hh"
00015 #include "artdaq-core/Data/Fragment.hh"
00016
00017 #include "messagefacility/MessageLogger/MessageLogger.h"
00018
00019 #include <algorithm>
00020 #include <cassert>
00021 #include <cmath>
00022 #include <fstream>
00023 #include <iomanip>
00024 #include <vector>
00025 #include <iostream>
00026
00027 namespace demo
00028 {
00029 class CheckIntegrity;
00030 }
00031
00035 class demo::CheckIntegrity : public art::EDAnalyzer
00036 {
00037 public:
00046 explicit CheckIntegrity(fhicl::ParameterSet const& pset);
00047
00051 virtual ~CheckIntegrity() = default;
00052
00057 virtual void analyze(art::Event const& evt);
00058
00059 private:
00060 std::string raw_data_label_;
00061 std::string frag_type_;
00062 };
00063
00064
00065 demo::CheckIntegrity::CheckIntegrity(fhicl::ParameterSet const& pset)
00066 : EDAnalyzer(pset)
00067 , raw_data_label_(pset.get<std::string>("raw_data_label"))
00068 , frag_type_(pset.get<std::string>("frag_type")) {}
00069
00070 void demo::CheckIntegrity::analyze(art::Event const& evt)
00071 {
00072 art::Handle<artdaq::Fragments> raw;
00073 evt.getByLabel(raw_data_label_, frag_type_, raw);
00074
00075 if (raw.isValid())
00076 {
00077 for (size_t idx = 0; idx < raw->size(); ++idx)
00078 {
00079 const auto& frag((*raw)[idx]);
00080
00081 ToyFragment bb(frag);
00082
00083 {
00084 auto adc_iter = bb.dataBeginADCs();
00085 ToyFragment::adc_t expected_adc = 1;
00086
00087 for (; adc_iter != bb.dataEndADCs(); adc_iter++ , expected_adc++)
00088 {
00089 if (*adc_iter != expected_adc)
00090 {
00091 mf::LogError("CheckIntegrity") << "Error: in run " << evt.run() << ", subrun " << evt.subRun() <<
00092 ", event " << evt.event() << ", seqID " << frag.sequenceID() <<
00093 ", fragID " << frag.fragmentID() << ": expected an ADC value of " << expected_adc <<
00094 ", got " << *adc_iter;
00095 return;
00096 }
00097 }
00098
00099 mf::LogDebug("CheckIntegrity") << "In run " << evt.run() << ", subrun " << evt.subRun() <<
00100 ", event " << evt.event() << ", everything is fine";
00101 }
00102 }
00103 }
00104 else
00105 {
00106 mf::LogError("CheckIntegrity") << "In run " << evt.run() << ", subrun " << evt.subRun() <<
00107 ", event " << evt.event() << ", raw.isValid() returned false";
00108 }
00109 }
00110
00111 DEFINE_ART_MODULE(demo::CheckIntegrity)