CMS 3D CMS Logo

PlaybackRawDataProvider.h
Go to the documentation of this file.
1 #ifndef PLAYBACKRAWDATAPROVIDER_H
2 #define PLAYBACKRAWDATAPROVIDER_H 1
3 
7 
8 #include <memory>
9 #include <semaphore.h>
10 
12 
14 {
15 public:
16  //
17  // construction/destruction
18  //
20  virtual ~PlaybackRawDataProvider();
21 
22  // EDAnalyzer interface
23  virtual void beginJob();
24  virtual void analyze(const edm::Event&, const edm::EventSetup&);
25  virtual void endJob();
26  virtual void respondToCloseInputFile(edm::FileBlock const& fb);
27 
28  // provide cached fed collection (and run/evt number, if needed!)
30  virtual FEDRawDataCollection* getFEDRawData(unsigned int& runNumber,
31  unsigned int& evtNumber);
32  void setFreeToEof();
33  bool areFilesClosed();
34 
36 
37 
38 private:
39 
41  //
42  // private member functions
43  //
44  void lock() { sem_wait(&lock_); }
45  void unlock() { sem_post(&lock_); }
46  void waitWriteSem() { sem_wait(&writeSem_); }
47  void postWriteSem() { sem_post(&writeSem_); }
48  void waitReadSem() { sem_wait(&readSem_);}
49  void postReadSem() { sem_post(&readSem_); }
50 
51 
52  void sem_print();
53 
54 
55 private:
56  //
57  // member data
58  //
59  unsigned int queueSize_;
61  unsigned int *runNumber_;
62  unsigned int *evtNumber_;
63  unsigned int count_;
64 
65  sem_t lock_;
66  sem_t writeSem_;
67  sem_t readSem_;
68  unsigned int writeIndex_;
69  unsigned int readIndex_;
70  bool freeToEof_;
73 };
74 
75 
76 //
77 // implementation of inline functions
78 //
79 
80 //______________________________________________________________________________
81 inline
83 {
84  return instance_;
85 }
86 
87 
88 #endif
FEDRawDataCollection ** eventQueue_
PlaybackRawDataProvider(const edm::ParameterSet &)
virtual FEDRawDataCollection * getFEDRawData()
static PlaybackRawDataProvider * instance()
static PlaybackRawDataProvider * instance_
virtual void respondToCloseInputFile(edm::FileBlock const &fb)
virtual void analyze(const edm::Event &, const edm::EventSetup &)