00001 #ifndef PLAYBACKRAWDATAPROVIDER_H 00002 #define PLAYBACKRAWDATAPROVIDER_H 1 00003 00004 #include "FWCore/Framework/interface/EDAnalyzer.h" 00005 #include "FWCore/Framework/interface/Event.h" 00006 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00007 00008 #include <memory> 00009 #include <semaphore.h> 00010 00011 class FEDRawDataCollection; 00012 00013 class PlaybackRawDataProvider : public edm::EDAnalyzer 00014 { 00015 public: 00016 // 00017 // construction/destruction 00018 // 00019 explicit PlaybackRawDataProvider(const edm::ParameterSet&); 00020 virtual ~PlaybackRawDataProvider(); 00021 00022 // EDAnalyzer interface 00023 virtual void beginJob(); 00024 virtual void analyze(const edm::Event&, const edm::EventSetup&); 00025 virtual void endJob(); 00026 virtual void respondToCloseInputFile(edm::FileBlock const& fb); 00027 00028 // provide cached fed collection (and run/evt number, if needed!) 00029 virtual FEDRawDataCollection* getFEDRawData(); 00030 virtual FEDRawDataCollection* getFEDRawData(unsigned int& runNumber, 00031 unsigned int& evtNumber); 00032 void setFreeToEof(); 00033 bool areFilesClosed(); 00034 00035 static PlaybackRawDataProvider* instance(); 00036 00037 00038 private: 00039 00040 static PlaybackRawDataProvider* instance_; 00041 // 00042 // private member functions 00043 // 00044 void lock() { sem_wait(&lock_); } 00045 void unlock() { sem_post(&lock_); } 00046 void waitWriteSem() { sem_wait(&writeSem_); } 00047 void postWriteSem() { sem_post(&writeSem_); } 00048 void waitReadSem() { sem_wait(&readSem_);} 00049 void postReadSem() { sem_post(&readSem_); } 00050 00051 00052 void sem_print(); 00053 00054 00055 private: 00056 // 00057 // member data 00058 // 00059 unsigned int queueSize_; 00060 FEDRawDataCollection **eventQueue_; 00061 unsigned int *runNumber_; 00062 unsigned int *evtNumber_; 00063 unsigned int count_; 00064 00065 sem_t lock_; 00066 sem_t writeSem_; 00067 sem_t readSem_; 00068 unsigned int writeIndex_; 00069 unsigned int readIndex_; 00070 bool freeToEof_; 00071 bool filesClosed_; 00072 bool destroying_; 00073 }; 00074 00075 00076 // 00077 // implementation of inline functions 00078 // 00079 00080 //______________________________________________________________________________ 00081 inline 00082 PlaybackRawDataProvider* PlaybackRawDataProvider::instance() 00083 { 00084 return instance_; 00085 } 00086 00087 00088 #endif