File indexing completed on 2024-04-06 12:10:31
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015
0016 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0017 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0018
0019 #include "DataFormats/CTPPSDigi/interface/TotemFEDInfo.h"
0020
0021 #include "EventFilter/CTPPSRawToDigi/interface/SimpleVFATFrameCollection.h"
0022 #include "EventFilter/CTPPSRawToDigi/interface/RawDataUnpacker.h"
0023
0024 #include <string>
0025
0026 class TotemVFATFrameAnalyzer : public edm::global::EDAnalyzer<> {
0027 public:
0028 explicit TotemVFATFrameAnalyzer(const edm::ParameterSet &);
0029 ~TotemVFATFrameAnalyzer();
0030
0031 virtual void analyze(edm::StreamID, const edm::Event &, const edm::EventSetup &) const override;
0032
0033 private:
0034 std::vector<unsigned int> fedIds;
0035
0036 edm::EDGetTokenT<FEDRawDataCollection> fedDataToken;
0037
0038 pps::RawDataUnpacker rawDataUnpacker;
0039
0040 template <typename DigiType>
0041 void run(edm::Event &, const edm::EventSetup &);
0042 };
0043
0044 using namespace edm;
0045 using namespace std;
0046
0047 TotemVFATFrameAnalyzer::TotemVFATFrameAnalyzer(const edm::ParameterSet &conf)
0048 : fedIds(conf.getParameter<vector<unsigned int> >("fedIds")),
0049 rawDataUnpacker(conf.getParameterSet("RawUnpacking")) {
0050 fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
0051 }
0052
0053 TotemVFATFrameAnalyzer::~TotemVFATFrameAnalyzer() {}
0054
0055 void TotemVFATFrameAnalyzer::analyze(edm::StreamID, const edm::Event &event, const edm::EventSetup &) const {
0056
0057 edm::Handle<FEDRawDataCollection> rawData;
0058 event.getByToken(fedDataToken, rawData);
0059
0060
0061 vector<TotemFEDInfo> fedInfo;
0062 SimpleVFATFrameCollection vfatCollection;
0063 for (const auto &fedId : fedIds) {
0064 const FEDRawData &data = rawData->FEDData(fedId);
0065 if (data.size() > 0)
0066 rawDataUnpacker.run(fedId, data, fedInfo, vfatCollection);
0067 }
0068
0069
0070 edm::LogInfo("TotemVFATFrameAnalyzer")
0071 << "\n----------------------------------------------------------------------------------------------------\n"
0072 << event.id() << "\n";
0073
0074 for (VFATFrameCollection::Iterator fr(&vfatCollection); !fr.IsEnd(); fr.Next()) {
0075 edm::LogInfo("TotemVFATFrameAnalyzer") << fr.Position() << " > ";
0076 fr.Data()->Print();
0077 }
0078 }
0079
0080 DEFINE_FWK_MODULE(TotemVFATFrameAnalyzer);