Go to the documentation of this file.00001
00003
00004 #ifndef CHAINDATA_H
00005 #define CHAINDATA_H
00006
00007 #include "toolbox/mem/Reference.h"
00008
00009 #include "IOPool/Streamer/interface/HLTInfo.h"
00010 #include "IOPool/Streamer/interface/MsgHeader.h"
00011
00012 #include "EventFilter/Utilities/interface/i2oEvfMsgs.h"
00013
00014 #include "EventFilter/StorageManager/interface/Utils.h"
00015 #include "EventFilter/StorageManager/interface/DQMKey.h"
00016 #include "EventFilter/StorageManager/interface/StreamID.h"
00017 #include "EventFilter/StorageManager/interface/QueueID.h"
00018 #include "EventFilter/StorageManager/interface/Exception.h"
00019
00020
00021 namespace stor
00022 {
00023
00024 namespace detail
00025 {
00026
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00041 class ChainData
00042 {
00043 protected:
00044 enum BitMasksForFaulty { INVALID_INITIAL_REFERENCE = 0x1,
00045 CORRUPT_INITIAL_HEADER = 0x2,
00046 INVALID_SECONDARY_REFERENCE = 0x4,
00047 CORRUPT_SECONDARY_HEADER = 0x8,
00048 TOTAL_COUNT_MISMATCH = 0x10,
00049 FRAGMENTS_OUT_OF_ORDER = 0x20,
00050 DUPLICATE_FRAGMENT = 0x40,
00051 INCOMPLETE_MESSAGE = 0x80,
00052 WRONG_CHECKSUM = 0x100,
00053 EXTERNALLY_REQUESTED = 0x10000 };
00054
00055
00056 public:
00057 explicit ChainData(unsigned short i2oMessageCode = 0x9999,
00058 unsigned int messageCode = Header::INVALID);
00059 virtual ~ChainData();
00060 bool empty() const;
00061 bool complete() const;
00062 bool faulty() const;
00063 unsigned int faultyBits() const;
00064 bool parsable() const;
00065 bool headerOkay() const;
00066 void addFirstFragment(toolbox::mem::Reference*);
00067 void addToChain(ChainData const&);
00068 void markComplete();
00069 void markFaulty();
00070 void markCorrupt();
00071 unsigned long* getBufferData() const;
00072 void swap(ChainData& other);
00073 unsigned int messageCode() const {return messageCode_;}
00074 unsigned short i2oMessageCode() const {return i2oMessageCode_;}
00075 FragKey const& fragmentKey() const {return fragKey_;}
00076 unsigned int fragmentCount() const {return fragmentCount_;}
00077 unsigned int rbBufferId() const {return rbBufferId_;}
00078 unsigned int hltLocalId() const {return hltLocalId_;}
00079 unsigned int hltInstance() const {return hltInstance_;}
00080 unsigned int hltTid() const {return hltTid_;}
00081 unsigned int fuProcessId() const {return fuProcessId_;}
00082 unsigned int fuGuid() const {return fuGuid_;}
00083 utils::TimePoint_t creationTime() const {return creationTime_;}
00084 utils::TimePoint_t lastFragmentTime() const {return lastFragmentTime_;}
00085 utils::TimePoint_t staleWindowStartTime() const {return staleWindowStartTime_;}
00086 void addToStaleWindowStartTime(const utils::Duration_t duration) {
00087 staleWindowStartTime_ += duration;
00088 }
00089 void resetStaleWindowStartTime() {
00090 staleWindowStartTime_ = utils::getCurrentTime();
00091 }
00092 size_t memoryUsed() const;
00093 unsigned long totalDataSize() const;
00094 unsigned long dataSize(int fragmentIndex) const;
00095 unsigned char* dataLocation(int fragmentIndex) const;
00096 unsigned int getFragmentID(int fragmentIndex) const;
00097 unsigned int copyFragmentsIntoBuffer(std::vector<unsigned char>& buff) const;
00098
00099 unsigned long headerSize() const;
00100 unsigned char* headerLocation() const;
00101
00102 std::string hltURL() const;
00103 std::string hltClassName() const;
00104 uint32_t outputModuleId() const;
00105
00106 std::string outputModuleLabel() const;
00107 void hltTriggerNames(Strings& nameList) const;
00108 void hltTriggerSelections(Strings& nameList) const;
00109 void l1TriggerNames(Strings& nameList) const;
00110
00111 void assertRunNumber(uint32_t runNumber);
00112
00113 uint32_t runNumber() const;
00114 uint32_t lumiSection() const;
00115 uint32_t eventNumber() const;
00116 uint32_t adler32Checksum() const;
00117
00118 std::string topFolderName() const;
00119 DQMKey dqmKey() const;
00120
00121 uint32_t hltTriggerCount() const;
00122 void hltTriggerBits(std::vector<unsigned char>& bitList) const;
00123
00124 void tagForStream(StreamID);
00125 void tagForEventConsumer(QueueID);
00126 void tagForDQMEventConsumer(QueueID);
00127 bool isTaggedForAnyStream() const {return !streamTags_.empty();}
00128 bool isTaggedForAnyEventConsumer() const {return !eventConsumerTags_.empty();}
00129 bool isTaggedForAnyDQMEventConsumer() const {return !dqmEventConsumerTags_.empty();}
00130 std::vector<StreamID> const& getStreamTags() const;
00131 QueueIDs const& getEventConsumerTags() const;
00132 QueueIDs const& getDQMEventConsumerTags() const;
00133
00134 bool isEndOfLumiSectionMessage() const;
00135
00136 private:
00137 std::vector<StreamID> streamTags_;
00138 QueueIDs eventConsumerTags_;
00139 QueueIDs dqmEventConsumerTags_;
00140
00141 utils::TimePoint_t creationTime_;
00142 utils::TimePoint_t lastFragmentTime_;
00143 utils::TimePoint_t staleWindowStartTime_;
00144
00145 void checkForCompleteness();
00146 bool validateAdler32Checksum();
00147 uint32_t calculateAdler32() const;
00148
00149 protected:
00150 toolbox::mem::Reference* ref_;
00151
00152 bool complete_;
00153 unsigned int faultyBits_;
00154
00155 unsigned int messageCode_;
00156 unsigned short i2oMessageCode_;
00157 FragKey fragKey_;
00158 unsigned int fragmentCount_;
00159 unsigned int expectedNumberOfFragments_;
00160 unsigned int rbBufferId_;
00161 unsigned int hltLocalId_;
00162 unsigned int hltInstance_;
00163 unsigned int hltTid_;
00164 unsigned int fuProcessId_;
00165 unsigned int fuGuid_;
00166
00167 inline bool validateDataLocation(
00168 toolbox::mem::Reference* ref,
00169 BitMasksForFaulty maskToUse
00170 );
00171 inline bool validateMessageSize(
00172 toolbox::mem::Reference* ref,
00173 BitMasksForFaulty maskToUse
00174 );
00175 inline bool validateFragmentIndexAndCount(
00176 toolbox::mem::Reference* ref,
00177 BitMasksForFaulty maskToUse
00178 );
00179 inline bool validateExpectedFragmentCount(
00180 toolbox::mem::Reference* ref,
00181 BitMasksForFaulty maskToUse
00182 );
00183 inline bool validateFragmentOrder(
00184 toolbox::mem::Reference* ref,
00185 int& indexValue
00186 );
00187 inline bool validateMessageCode(
00188 toolbox::mem::Reference* ref,
00189 unsigned short expectedI2OMessageCode
00190 );
00191
00192 virtual inline size_t do_i2oFrameSize() const { return 0; }
00193 virtual inline unsigned long do_headerSize() const { return 0; }
00194 virtual inline unsigned char* do_headerLocation() const { return 0; }
00195 virtual inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const { return dataLoc; }
00196 virtual inline uint32_t do_adler32Checksum() const { return 0; }
00197
00198 virtual uint32_t do_outputModuleId() const;
00199 virtual std::string do_outputModuleLabel() const;
00200 virtual void do_hltTriggerNames(Strings& nameList) const;
00201 virtual void do_hltTriggerSelections(Strings& nameList) const;
00202 virtual void do_l1TriggerNames(Strings& nameList) const;
00203
00204 virtual std::string do_topFolderName() const;
00205 virtual DQMKey do_dqmKey() const;
00206
00207 virtual uint32_t do_hltTriggerCount() const;
00208 virtual void do_hltTriggerBits(std::vector<unsigned char>& bitList) const;
00209
00210 virtual inline void do_assertRunNumber(uint32_t runNumber) {};
00211
00212 virtual uint32_t do_runNumber() const;
00213 virtual uint32_t do_lumiSection() const;
00214 virtual uint32_t do_eventNumber() const;
00215
00216 };
00217
00218
00222
00223 class InitMsgData : public ChainData
00224 {
00225
00226 public:
00227
00228 explicit InitMsgData(toolbox::mem::Reference* pRef);
00229 ~InitMsgData() {}
00230
00231 protected:
00232
00233 inline size_t do_i2oFrameSize() const;
00234 inline unsigned long do_headerSize() const;
00235 inline unsigned char* do_headerLocation() const;
00236 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00237 inline uint32_t do_adler32Checksum() const;
00238
00239 uint32_t do_outputModuleId() const;
00240 std::string do_outputModuleLabel() const;
00241 void do_hltTriggerNames(Strings& nameList) const;
00242 void do_hltTriggerSelections(Strings& nameList) const;
00243 void do_l1TriggerNames(Strings& nameList) const;
00244
00245 private:
00246
00247 void parseI2OHeader();
00248 void cacheHeaderFields() const;
00249
00250 mutable bool headerFieldsCached_;
00251 mutable std::vector<unsigned char> headerCopy_;
00252 mutable unsigned long headerSize_;
00253 mutable unsigned char* headerLocation_;
00254 mutable uint32_t adler32_;
00255 mutable uint32_t outputModuleId_;
00256 mutable std::string outputModuleLabel_;
00257 mutable Strings hltTriggerNames_;
00258 mutable Strings hltTriggerSelections_;
00259 mutable Strings l1TriggerNames_;
00260
00261 };
00262
00263
00267
00268 class EventMsgData : public ChainData
00269 {
00270
00271 public:
00272
00273 explicit EventMsgData(toolbox::mem::Reference* pRef);
00274 ~EventMsgData() {}
00275
00276 protected:
00277
00278 inline size_t do_i2oFrameSize() const;
00279 inline unsigned long do_headerSize() const;
00280 inline unsigned char* do_headerLocation() const;
00281 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00282 inline uint32_t do_adler32Checksum() const;
00283
00284 uint32_t do_outputModuleId() const;
00285 uint32_t do_hltTriggerCount() const;
00286 void do_hltTriggerBits(std::vector<unsigned char>& bitList) const;
00287 void do_assertRunNumber(uint32_t runNumber);
00288 uint32_t do_runNumber() const;
00289 uint32_t do_lumiSection() const;
00290 uint32_t do_eventNumber() const;
00291
00292 private:
00293
00294 void parseI2OHeader();
00295 void cacheHeaderFields() const;
00296
00297 mutable bool headerFieldsCached_;
00298 mutable std::vector<unsigned char> headerCopy_;
00299 mutable unsigned long headerSize_;
00300 mutable unsigned char* headerLocation_;
00301 mutable uint32_t outputModuleId_;
00302 mutable uint32_t hltTriggerCount_;
00303 mutable std::vector<unsigned char> hltTriggerBits_;
00304 mutable uint32_t runNumber_;
00305 mutable uint32_t lumiSection_;
00306 mutable uint32_t eventNumber_;
00307 mutable uint32_t adler32_;
00308
00309 };
00310
00311
00315
00316 class DQMEventMsgData : public ChainData
00317 {
00318
00319 public:
00320
00321 explicit DQMEventMsgData(toolbox::mem::Reference* pRef);
00322 ~DQMEventMsgData() {}
00323
00324 protected:
00325
00326 inline size_t do_i2oFrameSize() const;
00327 inline unsigned long do_headerSize() const;
00328 inline unsigned char* do_headerLocation() const;
00329 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00330 inline uint32_t do_adler32Checksum() const;
00331
00332 std::string do_topFolderName() const;
00333 DQMKey do_dqmKey() const;
00334 inline void do_assertRunNumber(uint32_t runNumber);
00335 uint32_t do_runNumber() const;
00336 uint32_t do_lumiSection() const;
00337
00338 private:
00339
00340 void parseI2OHeader();
00341 void cacheHeaderFields() const;
00342
00343 mutable bool headerFieldsCached_;
00344 mutable std::vector<unsigned char> headerCopy_;
00345 mutable unsigned long headerSize_;
00346 mutable unsigned char* headerLocation_;
00347 mutable std::string topFolderName_;
00348 mutable DQMKey dqmKey_;
00349 mutable uint32_t adler32_;
00350
00351 };
00352
00353
00357
00358 class ErrorEventMsgData : public ChainData
00359 {
00360
00361 public:
00362
00363 explicit ErrorEventMsgData(toolbox::mem::Reference* pRef);
00364 ~ErrorEventMsgData() {}
00365
00366 protected:
00367
00368 inline size_t do_i2oFrameSize() const;
00369 inline unsigned long do_headerSize() const;
00370 inline unsigned char* do_headerLocation() const;
00371 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00372 inline void do_assertRunNumber(uint32_t runNumber);
00373 uint32_t do_runNumber() const;
00374 uint32_t do_lumiSection() const;
00375 uint32_t do_eventNumber() const;
00376
00377 private:
00378
00379 void parseI2OHeader();
00380 void cacheHeaderFields() const;
00381
00382 mutable bool headerFieldsCached_;
00383 mutable std::vector<unsigned char> headerCopy_;
00384 mutable unsigned long headerSize_;
00385 mutable unsigned char* headerLocation_;
00386 mutable uint32_t runNumber_;
00387 mutable uint32_t lumiSection_;
00388 mutable uint32_t eventNumber_;
00389
00390 };
00391
00392
00396
00397 class EndLumiSectMsgData : public ChainData
00398 {
00399
00400 public:
00401
00402 explicit EndLumiSectMsgData( toolbox::mem::Reference* pRef );
00403 ~EndLumiSectMsgData() {}
00404
00405 protected:
00406
00407 inline uint32_t do_runNumber() const { return runNumber_; }
00408 inline uint32_t do_lumiSection() const { return lumiSection_; }
00409
00410 private:
00411
00412 mutable uint32_t runNumber_;
00413 mutable uint32_t lumiSection_;
00414
00415 };
00416
00417
00418 }
00419
00420 }
00421
00422 #endif
00423