Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:12

0001 #ifndef PLAYBACKRAWDATAPROVIDER_H
0002 #define PLAYBACKRAWDATAPROVIDER_H 1
0003 
0004 #include "FWCore/Framework/interface/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 
0008 #include <memory>
0009 #include <semaphore.h>
0010 
0011 class FEDRawDataCollection;
0012 
0013 class PlaybackRawDataProvider : public edm::EDAnalyzer {
0014 public:
0015   //
0016   // construction/destruction
0017   //
0018   explicit PlaybackRawDataProvider(const edm::ParameterSet&);
0019   ~PlaybackRawDataProvider() override;
0020 
0021   // EDAnalyzer interface
0022   void beginJob() override;
0023   void analyze(const edm::Event&, const edm::EventSetup&) override;
0024   void endJob() override;
0025   void respondToCloseInputFile(edm::FileBlock const& fb) override;
0026 
0027   // provide cached fed collection (and run/evt number, if needed!)
0028   virtual FEDRawDataCollection* getFEDRawData();
0029   virtual FEDRawDataCollection* getFEDRawData(unsigned int& runNumber, unsigned int& evtNumber);
0030   void setFreeToEof();
0031   bool areFilesClosed();
0032 
0033   static PlaybackRawDataProvider* instance();
0034 
0035 private:
0036   static PlaybackRawDataProvider* instance_;
0037   //
0038   // private member functions
0039   //
0040   void lock() { sem_wait(&lock_); }
0041   void unlock() { sem_post(&lock_); }
0042   void waitWriteSem() { sem_wait(&writeSem_); }
0043   void postWriteSem() { sem_post(&writeSem_); }
0044   void waitReadSem() { sem_wait(&readSem_); }
0045   void postReadSem() { sem_post(&readSem_); }
0046 
0047   void sem_print();
0048 
0049 private:
0050   //
0051   // member data
0052   //
0053   unsigned int queueSize_;
0054   FEDRawDataCollection** eventQueue_;
0055   unsigned int* runNumber_;
0056   unsigned int* evtNumber_;
0057   unsigned int count_;
0058 
0059   sem_t lock_;
0060   sem_t writeSem_;
0061   sem_t readSem_;
0062   unsigned int writeIndex_;
0063   unsigned int readIndex_;
0064   bool freeToEof_;
0065   bool filesClosed_;
0066   bool destroying_;
0067 };
0068 
0069 //
0070 // implementation of inline functions
0071 //
0072 
0073 //______________________________________________________________________________
0074 inline PlaybackRawDataProvider* PlaybackRawDataProvider::instance() { return instance_; }
0075 
0076 #endif