File indexing completed on 2024-04-06 11:57:58
0001 #ifndef SourceModule_H
0002 #define SourceModule_H
0003
0004 #include <vector>
0005 #include <string>
0006 #include <cinttypes>
0007 #include <fstream>
0008
0009 #include "FWCore/Sources/interface/ProducerSourceBase.h"
0010 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0011 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0012 #include "DataFormats/Provenance/interface/Timestamp.h"
0013
0014 class LmfSource : public edm::ProducerSourceBase {
0015 private:
0016 struct IndexRecord {
0017 uint32_t orbit;
0018 uint32_t filePos;
0019
0020 };
0021
0022 public:
0023 LmfSource(const edm::ParameterSet& pset, const edm::InputSourceDescription& isd);
0024 ~LmfSource() override {}
0025
0026 private:
0027
0028
0029 void produce(edm::Event& e) override;
0030
0031
0032
0033
0034
0035 bool setRunAndEventInfo(edm::EventID& id,
0036 edm::TimeValue_t& time,
0037 edm::EventAuxiliary::ExperimentType& eType) override;
0038
0039 bool openFile(int iFile);
0040
0041 bool readFileHeader();
0042
0043
0044
0045
0046
0047
0048
0049 bool readEventWithinFile(bool doSkip);
0050
0051
0052
0053
0054
0055 std::string toString(edm::TimeValue_t& t) const;
0056
0057 private:
0058
0059
0060 std::vector<std::string> fileNames_;
0061
0062
0063
0064 int iFile_;
0065
0066
0067
0068 FEDRawDataCollection fedColl_;
0069
0070
0071
0072 FEDRawData emptyFedBlock_;
0073
0074
0075
0076
0077 int fedId_;
0078
0079
0080
0081 std::vector<uint32_t> header_;
0082
0083 static const unsigned fileHeaderSize;
0084
0085
0086
0087 std::vector<uint32_t> fileHeader_;
0088
0089
0090
0091 static const unsigned char minDataFormatVersion_;
0092
0093
0094
0095 static const unsigned char maxDataFormatVersion_;
0096
0097
0098
0099
0100 bool filter() const;
0101
0102
0103
0104
0105
0106 bool readEvent(bool doSkip = false);
0107
0108
0109
0110
0111
0112 bool nextEventWithinFile();
0113
0114
0115
0116
0117
0118 void checkFileNames();
0119
0120
0121
0122
0123 void readIndexTable();
0124
0125 uint64_t timeStamp_;
0126 uint32_t lumiBlock_;
0127 uint32_t runNum_;
0128 uint32_t bx_;
0129 uint32_t eventNum_;
0130 uint32_t orbitNum_;
0131
0132 unsigned char dataFormatVers_;
0133
0134 std::ifstream in_;
0135
0136
0137
0138 bool rcRead_;
0139
0140 unsigned preScale_;
0141
0142
0143
0144 uint32_t iEvent_;
0145
0146
0147
0148 uint32_t iEventInFile_;
0149
0150 uint32_t indexTablePos_;
0151
0152 int calibTrig_;
0153
0154 int nFeds_;
0155
0156
0157
0158
0159 std::vector<IndexRecord> indexTable_;
0160
0161
0162
0163
0164 static const unsigned maxEvents_ = 1 << 20;
0165
0166
0167
0168
0169 static const unsigned maxEventSize_ = 1 << 20;
0170
0171
0172
0173
0174 bool orderedRead_;
0175
0176
0177
0178
0179 bool watchFileList_;
0180
0181
0182
0183 std::string fileListName_;
0184
0185
0186
0187 std::string inputDir_;
0188
0189
0190
0191 std::string currentFileName_;
0192
0193 std::ifstream fileList_;
0194
0195
0196
0197 int nSecondsToSleep_;
0198
0199
0200
0201 int verbosity_;
0202 };
0203 #endif