CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
PlaybackRawDataProvider Class Reference

#include <PlaybackRawDataProvider.h>

Inheritance diagram for PlaybackRawDataProvider:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
virtual FEDRawDataCollectiongetFEDRawData ()
 
virtual FEDRawDataCollectiongetFEDRawData (unsigned int &runNumber, unsigned int &evtNumber)
 
 PlaybackRawDataProvider (const edm::ParameterSet &)
 
void setFreeToEof ()
 
virtual ~PlaybackRawDataProvider ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Static Public Member Functions

static PlaybackRawDataProviderinstance ()
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void lock ()
 
void postReadSem ()
 
void postWriteSem ()
 
void sem_print ()
 
void unlock ()
 
void waitReadSem ()
 
void waitWriteSem ()
 

Private Attributes

unsigned int count_
 
FEDRawDataCollection ** eventQueue_
 
unsigned int * evtNumber_
 
bool freeToEof_
 
sem_t lock_
 
unsigned int queueSize_
 
unsigned int readIndex_
 
sem_t readSem_
 
unsigned int * runNumber_
 
unsigned int writeIndex_
 
sem_t writeSem_
 

Static Private Attributes

static PlaybackRawDataProviderinstance_ =0
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 13 of file PlaybackRawDataProvider.h.

Constructor & Destructor Documentation

PlaybackRawDataProvider::PlaybackRawDataProvider ( const edm::ParameterSet iConfig)
explicit

Definition at line 31 of file PlaybackRawDataProvider.cc.

References eventQueue_, evtNumber_, edm::ParameterSet::getUntrackedParameter(), i, instance_, lock_, queueSize_, readSem_, runNumber_, and writeSem_.

32  : queueSize_(0)
33  , eventQueue_(0)
34  , runNumber_(0)
35  , evtNumber_(0)
36  , count_(0)
37  , writeIndex_(0)
38  , readIndex_(0)
39  , freeToEof_(false)
40 {
41  queueSize_=iConfig.getUntrackedParameter<unsigned int>("queueSize",32);
42  sem_init(&lock_,0,1);
43  sem_init(&writeSem_,0,queueSize_);
44  sem_init(&readSem_,0,0);
45  runNumber_ =new unsigned int[queueSize_];
46  evtNumber_ =new unsigned int[queueSize_];
48  for (unsigned int i=0;i<queueSize_;i++) eventQueue_[i]=0;
49  edm::LogInfo("PbImpl") << "Created Concrete RawData Provider 0x"<< hex << (unsigned long) this << dec << endl;
50  instance_=this;
51 }
FEDRawDataCollection ** eventQueue_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static PlaybackRawDataProvider * instance_
PlaybackRawDataProvider::~PlaybackRawDataProvider ( )
virtual

Definition at line 55 of file PlaybackRawDataProvider.cc.

References eventQueue_, evtNumber_, i, instance_, queueSize_, and runNumber_.

56 {
57  if (0!=runNumber_) delete [] runNumber_;
58  if (0!=evtNumber_) delete [] evtNumber_;
59  if (0!=eventQueue_) {
60  for (unsigned int i=0;i<queueSize_;i++)
61  if (0!=eventQueue_[i]) delete eventQueue_[i];
62  delete [] eventQueue_;
63  }
64  edm::LogInfo("PbImpl") << "Destroyed Concrete RawData Provider 0x"<< hex << (unsigned long) this << dec << endl;
65  instance_=0;
66 }
FEDRawDataCollection ** eventQueue_
int i
Definition: DBlmapReader.cc:9
static PlaybackRawDataProvider * instance_

Member Function Documentation

void PlaybackRawDataProvider::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 74 of file PlaybackRawDataProvider.cc.

References count_, FEDRawData::data(), edm::EventID::event(), eventQueue_, evtNumber_, FEDRawDataCollection::FEDData(), freeToEof_, edm::Event::getByType(), i, edm::EventBase::id(), edm::HandleBase::isValid(), lock(), FEDNumbering::MAXFEDID, postReadSem(), queueSize_, FEDRawData::resize(), edm::EventID::run(), runNumber_, unlock(), waitWriteSem(), and writeIndex_.

76 {
77  if(freeToEof_) return;
78  waitWriteSem();
79  if(freeToEof_) return;
80  runNumber_[writeIndex_]=iEvent.id().run();
81  evtNumber_[writeIndex_]=iEvent.id().event();
82 
84  iEvent.getByType(pRawData);
85 
86  if (!pRawData.isValid()) {
87  edm::LogError("InvalidHandle")<<"no raw data found!"<<endl;
88  return;
89  }
90 
91 
92  // copy the raw data collection into rawData_, retrievable via getFEDRawData()
93  assert(0==eventQueue_[writeIndex_]);
95  for (unsigned int i=0;i<(unsigned int)FEDNumbering::MAXFEDID+1;i++) {
96  unsigned int fedSize=pRawData->FEDData(i).size();
97  if (fedSize>0) {
99  fedData.resize(fedSize);
100  memcpy(fedData.data(),pRawData->FEDData(i).data(),fedSize);
101  }
102  }
103 
104  lock();
106  count_++;
107  unlock();
108 
109  postReadSem();
110 
111  return;
112 }
RunNumber_t run() const
Definition: EventID.h:42
FEDRawDataCollection ** eventQueue_
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
bool getByType(Handle< PROD > &result) const
Definition: Event.h:397
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:33
bool isValid() const
Definition: HandleBase.h:76
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void PlaybackRawDataProvider::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 116 of file PlaybackRawDataProvider.cc.

117 {
118 
119 }
void PlaybackRawDataProvider::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 123 of file PlaybackRawDataProvider.cc.

References count_.

124 {
125  edm::LogInfo("Summary")<<count_<<" events read."<<endl;
126 }
FEDRawDataCollection * PlaybackRawDataProvider::getFEDRawData ( )
virtual
FEDRawDataCollection * PlaybackRawDataProvider::getFEDRawData ( unsigned int &  runNumber,
unsigned int &  evtNumber 
)
virtual

Definition at line 146 of file PlaybackRawDataProvider.cc.

References eventQueue_, evtNumber_, lock(), postWriteSem(), queueSize_, readIndex_, query::result, runNumber_, unlock(), and waitReadSem().

PlaybackRawDataProvider * PlaybackRawDataProvider::instance ( )
inlinestatic

Definition at line 78 of file PlaybackRawDataProvider.h.

References instance_.

Referenced by evf::BU::actionPerformed(), evf::BU::enabling(), evf::BU::generateEvent(), and evf::BU::stopping().

79 {
80  return instance_;
81 }
static PlaybackRawDataProvider * instance_
void PlaybackRawDataProvider::lock ( void  )
inlineprivate

Definition at line 42 of file PlaybackRawDataProvider.h.

References lock_.

Referenced by analyze(), getFEDRawData(), and sem_print().

42 { sem_wait(&lock_); }
void PlaybackRawDataProvider::postReadSem ( )
inlineprivate

Definition at line 47 of file PlaybackRawDataProvider.h.

References readSem_.

Referenced by analyze().

47 { sem_post(&readSem_); }
void PlaybackRawDataProvider::postWriteSem ( )
inlineprivate

Definition at line 45 of file PlaybackRawDataProvider.h.

References writeSem_.

Referenced by getFEDRawData(), and setFreeToEof().

45 { sem_post(&writeSem_); }
void PlaybackRawDataProvider::sem_print ( )
private

Definition at line 168 of file PlaybackRawDataProvider.cc.

References gather_cfg::cout, lock(), readIndex_, readSem_, unlock(), writeIndex_, and writeSem_.

169 {
170  lock();
171  int wsem,rsem;
172  sem_getvalue(&writeSem_,&wsem);
173  sem_getvalue(&readSem_,&rsem);
174  cout<<"sem_print():"
175  <<" wsem="<<wsem
176  <<" rsem="<<rsem
177  <<" writeIndex="<<writeIndex_
178  <<" readIndex="<<readIndex_
179  <<endl;
180  unlock();
181 }
tuple cout
Definition: gather_cfg.py:41
void PlaybackRawDataProvider::setFreeToEof ( )

Definition at line 183 of file PlaybackRawDataProvider.cc.

References freeToEof_, and postWriteSem().

Referenced by evf::BU::generateEvent(), and evf::BU::stopping().

184 {
185  // cout << " PlaybackRawDataProvider::setFreeToEof()" << endl;
186  freeToEof_ = true;
187  // cout << " PlaybackRawDataProvider::setFreeToEof() call postReadSem" << endl;
188  postWriteSem();
189 }
void PlaybackRawDataProvider::unlock ( void  )
inlineprivate

Definition at line 43 of file PlaybackRawDataProvider.h.

References lock_.

Referenced by analyze(), getFEDRawData(), and sem_print().

43 { sem_post(&lock_); }
void PlaybackRawDataProvider::waitReadSem ( )
inlineprivate

Definition at line 46 of file PlaybackRawDataProvider.h.

References readSem_.

Referenced by getFEDRawData().

46 { sem_wait(&readSem_);}
void PlaybackRawDataProvider::waitWriteSem ( )
inlineprivate

Definition at line 44 of file PlaybackRawDataProvider.h.

References writeSem_.

Referenced by analyze().

44 { sem_wait(&writeSem_); }

Member Data Documentation

unsigned int PlaybackRawDataProvider::count_
private

Definition at line 61 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and endJob().

FEDRawDataCollection** PlaybackRawDataProvider::eventQueue_
private
unsigned int* PlaybackRawDataProvider::evtNumber_
private
bool PlaybackRawDataProvider::freeToEof_
private

Definition at line 68 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and setFreeToEof().

PlaybackRawDataProvider * PlaybackRawDataProvider::instance_ =0
staticprivate
sem_t PlaybackRawDataProvider::lock_
private

Definition at line 63 of file PlaybackRawDataProvider.h.

Referenced by lock(), PlaybackRawDataProvider(), and unlock().

unsigned int PlaybackRawDataProvider::queueSize_
private
unsigned int PlaybackRawDataProvider::readIndex_
private

Definition at line 67 of file PlaybackRawDataProvider.h.

Referenced by getFEDRawData(), and sem_print().

sem_t PlaybackRawDataProvider::readSem_
private
unsigned int* PlaybackRawDataProvider::runNumber_
private
unsigned int PlaybackRawDataProvider::writeIndex_
private

Definition at line 66 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and sem_print().

sem_t PlaybackRawDataProvider::writeSem_
private