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 unsigned int droppedEventsCount() const;
00093 void setDroppedEventsCount(unsigned int);
00094 size_t memoryUsed() const;
00095 unsigned long totalDataSize() const;
00096 unsigned long dataSize(int fragmentIndex) const;
00097 unsigned char* dataLocation(int fragmentIndex) const;
00098 unsigned int getFragmentID(int fragmentIndex) const;
00099 unsigned int copyFragmentsIntoBuffer(std::vector<unsigned char>& buff) const;
00100
00101 unsigned long headerSize() const;
00102 unsigned char* headerLocation() const;
00103
00104 std::string hltURL() const;
00105 std::string hltClassName() const;
00106 uint32_t outputModuleId() const;
00107
00108 std::string outputModuleLabel() const;
00109 void hltTriggerNames(Strings& nameList) const;
00110 void hltTriggerSelections(Strings& nameList) const;
00111 void l1TriggerNames(Strings& nameList) const;
00112
00113 void assertRunNumber(uint32_t runNumber);
00114
00115 uint32_t runNumber() const;
00116 uint32_t lumiSection() const;
00117 uint32_t eventNumber() const;
00118 uint32_t adler32Checksum() const;
00119
00120 std::string topFolderName() const;
00121 DQMKey dqmKey() const;
00122
00123 uint32_t hltTriggerCount() const;
00124 void hltTriggerBits(std::vector<unsigned char>& bitList) const;
00125
00126 void tagForStream(StreamID);
00127 void tagForEventConsumer(QueueID);
00128 void tagForDQMEventConsumer(QueueID);
00129 bool isTaggedForAnyStream() const {return !streamTags_.empty();}
00130 bool isTaggedForAnyEventConsumer() const {return !eventConsumerTags_.empty();}
00131 bool isTaggedForAnyDQMEventConsumer() const {return !dqmEventConsumerTags_.empty();}
00132 std::vector<StreamID> const& getStreamTags() const;
00133 QueueIDs const& getEventConsumerTags() const;
00134 QueueIDs const& getDQMEventConsumerTags() const;
00135
00136 bool isEndOfLumiSectionMessage() const;
00137
00138 private:
00139 std::vector<StreamID> streamTags_;
00140 QueueIDs eventConsumerTags_;
00141 QueueIDs dqmEventConsumerTags_;
00142
00143 utils::TimePoint_t creationTime_;
00144 utils::TimePoint_t lastFragmentTime_;
00145 utils::TimePoint_t staleWindowStartTime_;
00146
00147 void checkForCompleteness();
00148 bool validateAdler32Checksum();
00149 uint32_t calculateAdler32() const;
00150
00151 protected:
00152 toolbox::mem::Reference* ref_;
00153
00154 bool complete_;
00155 unsigned int faultyBits_;
00156
00157 unsigned int messageCode_;
00158 unsigned short i2oMessageCode_;
00159 FragKey fragKey_;
00160 unsigned int fragmentCount_;
00161 unsigned int expectedNumberOfFragments_;
00162 unsigned int rbBufferId_;
00163 unsigned int hltLocalId_;
00164 unsigned int hltInstance_;
00165 unsigned int hltTid_;
00166 unsigned int fuProcessId_;
00167 unsigned int fuGuid_;
00168
00169 inline bool validateDataLocation(
00170 toolbox::mem::Reference* ref,
00171 BitMasksForFaulty maskToUse
00172 );
00173 inline bool validateMessageSize(
00174 toolbox::mem::Reference* ref,
00175 BitMasksForFaulty maskToUse
00176 );
00177 inline bool validateFragmentIndexAndCount(
00178 toolbox::mem::Reference* ref,
00179 BitMasksForFaulty maskToUse
00180 );
00181 inline bool validateExpectedFragmentCount(
00182 toolbox::mem::Reference* ref,
00183 BitMasksForFaulty maskToUse
00184 );
00185 inline bool validateFragmentOrder(
00186 toolbox::mem::Reference* ref,
00187 int& indexValue
00188 );
00189 inline bool validateMessageCode(
00190 toolbox::mem::Reference* ref,
00191 unsigned short expectedI2OMessageCode
00192 );
00193
00194 virtual inline size_t do_i2oFrameSize() const { return 0; }
00195 virtual inline unsigned long do_headerSize() const { return 0; }
00196 virtual inline unsigned char* do_headerLocation() const { return 0; }
00197 virtual inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const { return dataLoc; }
00198 virtual inline uint32_t do_adler32Checksum() const { return 0; }
00199
00200 virtual uint32_t do_outputModuleId() const;
00201 virtual std::string do_outputModuleLabel() const;
00202 virtual void do_hltTriggerNames(Strings& nameList) const;
00203 virtual void do_hltTriggerSelections(Strings& nameList) const;
00204 virtual void do_l1TriggerNames(Strings& nameList) const;
00205 virtual unsigned int do_droppedEventsCount() const;
00206 virtual void do_setDroppedEventsCount(unsigned int);
00207
00208 virtual std::string do_topFolderName() const;
00209 virtual DQMKey do_dqmKey() const;
00210
00211 virtual uint32_t do_hltTriggerCount() const;
00212 virtual void do_hltTriggerBits(std::vector<unsigned char>& bitList) const;
00213
00214 virtual inline void do_assertRunNumber(uint32_t runNumber) {};
00215
00216 virtual uint32_t do_runNumber() const;
00217 virtual uint32_t do_lumiSection() const;
00218 virtual uint32_t do_eventNumber() const;
00219
00220 };
00221
00222
00226
00227 class InitMsgData : public ChainData
00228 {
00229
00230 public:
00231
00232 explicit InitMsgData(toolbox::mem::Reference* pRef);
00233 ~InitMsgData() {}
00234
00235 protected:
00236
00237 inline size_t do_i2oFrameSize() const;
00238 inline unsigned long do_headerSize() const;
00239 inline unsigned char* do_headerLocation() const;
00240 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00241 inline uint32_t do_adler32Checksum() const;
00242
00243 uint32_t do_outputModuleId() const;
00244 std::string do_outputModuleLabel() const;
00245 void do_hltTriggerNames(Strings& nameList) const;
00246 void do_hltTriggerSelections(Strings& nameList) const;
00247 void do_l1TriggerNames(Strings& nameList) const;
00248
00249 private:
00250
00251 void parseI2OHeader();
00252 void cacheHeaderFields() const;
00253
00254 mutable bool headerFieldsCached_;
00255 mutable std::vector<unsigned char> headerCopy_;
00256 mutable unsigned long headerSize_;
00257 mutable unsigned char* headerLocation_;
00258 mutable uint32_t adler32_;
00259 mutable uint32_t outputModuleId_;
00260 mutable std::string outputModuleLabel_;
00261 mutable Strings hltTriggerNames_;
00262 mutable Strings hltTriggerSelections_;
00263 mutable Strings l1TriggerNames_;
00264
00265 };
00266
00267
00271
00272 class EventMsgData : public ChainData
00273 {
00274
00275 public:
00276
00277 explicit EventMsgData(toolbox::mem::Reference* pRef);
00278 ~EventMsgData() {}
00279
00280 protected:
00281
00282 inline size_t do_i2oFrameSize() const;
00283 inline unsigned long do_headerSize() const;
00284 inline unsigned char* do_headerLocation() const;
00285 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00286 inline uint32_t do_adler32Checksum() const;
00287
00288 uint32_t do_outputModuleId() const;
00289 uint32_t do_hltTriggerCount() const;
00290 void do_hltTriggerBits(std::vector<unsigned char>& bitList) const;
00291 void do_assertRunNumber(uint32_t runNumber);
00292 uint32_t do_runNumber() const;
00293 uint32_t do_lumiSection() const;
00294 uint32_t do_eventNumber() const;
00295
00296 unsigned int do_droppedEventsCount() const;
00297 void do_setDroppedEventsCount(unsigned int);
00298
00299 private:
00300
00301 void parseI2OHeader();
00302 void cacheHeaderFields() const;
00303
00304 mutable bool headerFieldsCached_;
00305 mutable std::vector<unsigned char> headerCopy_;
00306 mutable unsigned long headerSize_;
00307 mutable unsigned char* headerLocation_;
00308 mutable uint32_t outputModuleId_;
00309 mutable uint32_t hltTriggerCount_;
00310 mutable std::vector<unsigned char> hltTriggerBits_;
00311 mutable uint32_t runNumber_;
00312 mutable uint32_t lumiSection_;
00313 mutable uint32_t eventNumber_;
00314 mutable uint32_t adler32_;
00315 mutable unsigned int droppedEventsCount_;
00316
00317 };
00318
00319
00323
00324 class DQMEventMsgData : public ChainData
00325 {
00326
00327 public:
00328
00329 explicit DQMEventMsgData(toolbox::mem::Reference* pRef);
00330 ~DQMEventMsgData() {}
00331
00332 protected:
00333
00334 inline size_t do_i2oFrameSize() const;
00335 inline unsigned long do_headerSize() const;
00336 inline unsigned char* do_headerLocation() const;
00337 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00338 inline uint32_t do_adler32Checksum() const;
00339
00340 std::string do_topFolderName() const;
00341 DQMKey do_dqmKey() const;
00342 inline void do_assertRunNumber(uint32_t runNumber);
00343 uint32_t do_runNumber() const;
00344 uint32_t do_lumiSection() const;
00345
00346 private:
00347
00348 void parseI2OHeader();
00349 void cacheHeaderFields() const;
00350
00351 mutable bool headerFieldsCached_;
00352 mutable std::vector<unsigned char> headerCopy_;
00353 mutable unsigned long headerSize_;
00354 mutable unsigned char* headerLocation_;
00355 mutable std::string topFolderName_;
00356 mutable DQMKey dqmKey_;
00357 mutable uint32_t adler32_;
00358
00359 };
00360
00361
00365
00366 class ErrorEventMsgData : public ChainData
00367 {
00368
00369 public:
00370
00371 explicit ErrorEventMsgData(toolbox::mem::Reference* pRef);
00372 ~ErrorEventMsgData() {}
00373
00374 protected:
00375
00376 inline size_t do_i2oFrameSize() const;
00377 inline unsigned long do_headerSize() const;
00378 inline unsigned char* do_headerLocation() const;
00379 inline unsigned char* do_fragmentLocation(unsigned char* dataLoc) const;
00380 inline void do_assertRunNumber(uint32_t runNumber);
00381 uint32_t do_runNumber() const;
00382 uint32_t do_lumiSection() const;
00383 uint32_t do_eventNumber() const;
00384
00385 private:
00386
00387 void parseI2OHeader();
00388 void cacheHeaderFields() const;
00389
00390 mutable bool headerFieldsCached_;
00391 mutable std::vector<unsigned char> headerCopy_;
00392 mutable unsigned long headerSize_;
00393 mutable unsigned char* headerLocation_;
00394 mutable uint32_t runNumber_;
00395 mutable uint32_t lumiSection_;
00396 mutable uint32_t eventNumber_;
00397
00398 };
00399
00400
00404
00405 class EndLumiSectMsgData : public ChainData
00406 {
00407
00408 public:
00409
00410 explicit EndLumiSectMsgData( toolbox::mem::Reference* pRef );
00411 ~EndLumiSectMsgData() {}
00412
00413 protected:
00414
00415 inline uint32_t do_runNumber() const { return runNumber_; }
00416 inline uint32_t do_lumiSection() const { return lumiSection_; }
00417
00418 private:
00419
00420 mutable uint32_t runNumber_;
00421 mutable uint32_t lumiSection_;
00422
00423 };
00424
00425
00426 }
00427
00428 }
00429
00430 #endif
00431