CMS 3D CMS Logo

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 edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
bool areFilesClosed ()
 
void beginJob () override
 
void endJob () override
 
virtual FEDRawDataCollectiongetFEDRawData ()
 
virtual FEDRawDataCollectiongetFEDRawData (unsigned int &runNumber, unsigned int &evtNumber)
 
 PlaybackRawDataProvider (const edm::ParameterSet &)
 
void respondToCloseInputFile (edm::FileBlock const &fb) override
 
void setFreeToEof ()
 
 ~PlaybackRawDataProvider () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static PlaybackRawDataProviderinstance ()
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Member Functions

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

Private Attributes

unsigned int count_
 
bool destroying_
 
FEDRawDataCollection ** eventQueue_
 
unsigned int * evtNumber_
 
bool filesClosed_
 
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_ = nullptr
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 13 of file PlaybackRawDataProvider.h.

Constructor & Destructor Documentation

◆ PlaybackRawDataProvider()

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

Definition at line 30 of file PlaybackRawDataProvider.cc.

31  : queueSize_(0),
32  eventQueue_(nullptr),
33  runNumber_(nullptr),
34  evtNumber_(nullptr),
35  count_(0),
36  writeIndex_(0),
37  readIndex_(0),
38  freeToEof_(false),
39  filesClosed_(false),
40  destroying_(false) {
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++)
49  eventQueue_[i] = nullptr;
50  edm::LogInfo("PbImpl") << "Created Concrete RawData Provider 0x" << hex << (unsigned long)this << dec << endl;
51  instance_ = this;
52 }

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

◆ ~PlaybackRawDataProvider()

PlaybackRawDataProvider::~PlaybackRawDataProvider ( )
override

Definition at line 55 of file PlaybackRawDataProvider.cc.

55  {
56  if (nullptr != runNumber_)
57  delete[] runNumber_;
58  if (nullptr != evtNumber_)
59  delete[] evtNumber_;
60  if (nullptr != eventQueue_) {
61  for (unsigned int i = 0; i < queueSize_; i++)
62  if (nullptr != eventQueue_[i])
63  delete eventQueue_[i];
64  delete[] eventQueue_;
65  }
66  edm::LogInfo("PbImpl") << "Destroyed Concrete RawData Provider 0x" << hex << (unsigned long)this << dec << endl;
67  instance_ = nullptr;
68 
69  destroying_ = true;
70  postReadSem();
71  postWriteSem();
72  unlock();
73  sem_destroy(&lock_);
74  sem_destroy(&writeSem_);
75  sem_destroy(&readSem_);
76  usleep(10000);
77 }

References TauDecayModes::dec, destroying_, eventQueue_, evtNumber_, mps_fire::i, instance_, lock_, postReadSem(), postWriteSem(), queueSize_, readSem_, runNumber_, unlock(), and writeSem_.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 84 of file PlaybackRawDataProvider.cc.

84  {
85  if (freeToEof_)
86  return;
87  waitWriteSem();
88  if (freeToEof_)
89  return;
90  runNumber_[writeIndex_] = iEvent.id().run();
91  evtNumber_[writeIndex_] = iEvent.id().event();
92 
94  iEvent.getByLabel("rawDataCollector", pRawData);
95 
96  if (!pRawData.isValid()) {
97  edm::LogError("InvalidHandle") << "no raw data found!" << endl;
98  return;
99  }
100 
101  // copy the raw data collection into rawData_, retrievable via getFEDRawData()
102  assert(nullptr == eventQueue_[writeIndex_]);
104  for (unsigned int i = 0; i < (unsigned int)FEDNumbering::MAXFEDID + 1; i++) {
105  unsigned int fedSize = pRawData->FEDData(i).size();
106  if (fedSize > 0) {
108  fedData.resize(fedSize);
109  memcpy(fedData.data(), pRawData->FEDData(i).data(), fedSize);
110  }
111  }
112 
113  lock();
115  count_++;
116  unlock();
117 
118  postReadSem();
119 
120  return;
121 }

References cms::cuda::assert(), count_, FEDRawData::data(), eventQueue_, evtNumber_, FEDRawDataCollection::FEDData(), EcalFEDMonitor_cfi::FEDRawDataCollection, freeToEof_, mps_fire::i, iEvent, createfilelist::int, edm::HandleBase::isValid(), lock(), FEDNumbering::MAXFEDID, postReadSem(), queueSize_, FEDRawData::resize(), runNumber_, FEDRawData::size(), unlock(), waitWriteSem(), and writeIndex_.

◆ areFilesClosed()

bool PlaybackRawDataProvider::areFilesClosed ( )

Definition at line 188 of file PlaybackRawDataProvider.cc.

188 { return filesClosed_; }

References filesClosed_.

◆ beginJob()

void PlaybackRawDataProvider::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 124 of file PlaybackRawDataProvider.cc.

124 {}

◆ endJob()

void PlaybackRawDataProvider::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 127 of file PlaybackRawDataProvider.cc.

127 { edm::LogInfo("Summary") << count_ << " events read." << endl; }

References count_.

◆ getFEDRawData() [1/2]

FEDRawDataCollection * PlaybackRawDataProvider::getFEDRawData ( )
virtual

Definition at line 133 of file PlaybackRawDataProvider.cc.

133  {
134  FEDRawDataCollection* result = nullptr;
135  waitReadSem();
136  //do not read data if destructor is called
137  if (destroying_)
138  return nullptr;
139  lock();
141  eventQueue_[readIndex_] = nullptr;
142  readIndex_ = (readIndex_ + 1) % queueSize_;
143  unlock();
144 
145  postWriteSem();
146  return result;
147 }

References destroying_, eventQueue_, lock(), postWriteSem(), queueSize_, readIndex_, mps_fire::result, unlock(), and waitReadSem().

◆ getFEDRawData() [2/2]

FEDRawDataCollection * PlaybackRawDataProvider::getFEDRawData ( unsigned int &  runNumber,
unsigned int &  evtNumber 
)
virtual

Definition at line 150 of file PlaybackRawDataProvider.cc.

150  {
151  FEDRawDataCollection* result = nullptr;
152  waitReadSem();
153  //do not read data if destructor is called
154  if (destroying_)
155  return nullptr;
156  lock();
158  evtNumber = evtNumber_[readIndex_];
160  // assert(0!=result);
161  eventQueue_[readIndex_] = nullptr;
162  readIndex_ = (readIndex_ + 1) % queueSize_;
163 
164  unlock();
165 
166  postWriteSem();
167  return result;
168 }

References destroying_, eventQueue_, evtNumber_, lock(), postWriteSem(), queueSize_, readIndex_, mps_fire::result, convertSQLiteXML::runNumber, runNumber_, unlock(), and waitReadSem().

◆ instance()

PlaybackRawDataProvider * PlaybackRawDataProvider::instance ( )
inlinestatic

Definition at line 74 of file PlaybackRawDataProvider.h.

74 { return instance_; }

References instance_.

◆ lock()

void PlaybackRawDataProvider::lock ( )
inlineprivate

Definition at line 40 of file PlaybackRawDataProvider.h.

40 { sem_wait(&lock_); }

References lock_.

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

◆ postReadSem()

void PlaybackRawDataProvider::postReadSem ( )
inlineprivate

Definition at line 45 of file PlaybackRawDataProvider.h.

45 { sem_post(&readSem_); }

References readSem_.

Referenced by analyze(), and ~PlaybackRawDataProvider().

◆ postWriteSem()

void PlaybackRawDataProvider::postWriteSem ( )
inlineprivate

Definition at line 43 of file PlaybackRawDataProvider.h.

43 { sem_post(&writeSem_); }

References writeSem_.

Referenced by getFEDRawData(), setFreeToEof(), and ~PlaybackRawDataProvider().

◆ respondToCloseInputFile()

void PlaybackRawDataProvider::respondToCloseInputFile ( edm::FileBlock const &  fb)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 130 of file PlaybackRawDataProvider.cc.

130 { filesClosed_ = true; }

References filesClosed_.

◆ sem_print()

void PlaybackRawDataProvider::sem_print ( )
private

Definition at line 171 of file PlaybackRawDataProvider.cc.

171  {
172  lock();
173  int wsem, rsem;
174  sem_getvalue(&writeSem_, &wsem);
175  sem_getvalue(&readSem_, &rsem);
176  cout << "sem_print():"
177  << " wsem=" << wsem << " rsem=" << rsem << " writeIndex=" << writeIndex_ << " readIndex=" << readIndex_ << endl;
178  unlock();
179 }

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

◆ setFreeToEof()

void PlaybackRawDataProvider::setFreeToEof ( )

Definition at line 181 of file PlaybackRawDataProvider.cc.

181  {
182  // cout << " PlaybackRawDataProvider::setFreeToEof()" << endl;
183  freeToEof_ = true;
184  // cout << " PlaybackRawDataProvider::setFreeToEof() call postReadSem" << endl;
185  postWriteSem();
186 }

References freeToEof_, and postWriteSem().

◆ unlock()

void PlaybackRawDataProvider::unlock ( )
inlineprivate

Definition at line 41 of file PlaybackRawDataProvider.h.

41 { sem_post(&lock_); }

References lock_.

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

◆ waitReadSem()

void PlaybackRawDataProvider::waitReadSem ( )
inlineprivate

Definition at line 44 of file PlaybackRawDataProvider.h.

44 { sem_wait(&readSem_); }

References readSem_.

Referenced by getFEDRawData().

◆ waitWriteSem()

void PlaybackRawDataProvider::waitWriteSem ( )
inlineprivate

Definition at line 42 of file PlaybackRawDataProvider.h.

42 { sem_wait(&writeSem_); }

References writeSem_.

Referenced by analyze().

Member Data Documentation

◆ count_

unsigned int PlaybackRawDataProvider::count_
private

Definition at line 57 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and endJob().

◆ destroying_

bool PlaybackRawDataProvider::destroying_
private

Definition at line 66 of file PlaybackRawDataProvider.h.

Referenced by getFEDRawData(), and ~PlaybackRawDataProvider().

◆ eventQueue_

FEDRawDataCollection** PlaybackRawDataProvider::eventQueue_
private

◆ evtNumber_

unsigned int* PlaybackRawDataProvider::evtNumber_
private

◆ filesClosed_

bool PlaybackRawDataProvider::filesClosed_
private

Definition at line 65 of file PlaybackRawDataProvider.h.

Referenced by areFilesClosed(), and respondToCloseInputFile().

◆ freeToEof_

bool PlaybackRawDataProvider::freeToEof_
private

Definition at line 64 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and setFreeToEof().

◆ instance_

PlaybackRawDataProvider * PlaybackRawDataProvider::instance_ = nullptr
staticprivate

◆ lock_

sem_t PlaybackRawDataProvider::lock_
private

◆ queueSize_

unsigned int PlaybackRawDataProvider::queueSize_
private

◆ readIndex_

unsigned int PlaybackRawDataProvider::readIndex_
private

Definition at line 63 of file PlaybackRawDataProvider.h.

Referenced by getFEDRawData(), and sem_print().

◆ readSem_

sem_t PlaybackRawDataProvider::readSem_
private

◆ runNumber_

unsigned int* PlaybackRawDataProvider::runNumber_
private

◆ writeIndex_

unsigned int PlaybackRawDataProvider::writeIndex_
private

Definition at line 62 of file PlaybackRawDataProvider.h.

Referenced by analyze(), and sem_print().

◆ writeSem_

sem_t PlaybackRawDataProvider::writeSem_
private
PlaybackRawDataProvider::writeIndex_
unsigned int writeIndex_
Definition: PlaybackRawDataProvider.h:62
mps_fire.i
i
Definition: mps_fire.py:428
PlaybackRawDataProvider::waitReadSem
void waitReadSem()
Definition: PlaybackRawDataProvider.h:44
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
PlaybackRawDataProvider::queueSize_
unsigned int queueSize_
Definition: PlaybackRawDataProvider.h:53
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PlaybackRawDataProvider::count_
unsigned int count_
Definition: PlaybackRawDataProvider.h:57
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
PlaybackRawDataProvider::postReadSem
void postReadSem()
Definition: PlaybackRawDataProvider.h:45
PlaybackRawDataProvider::destroying_
bool destroying_
Definition: PlaybackRawDataProvider.h:66
FEDRawData
Definition: FEDRawData.h:19
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
PlaybackRawDataProvider::lock
void lock()
Definition: PlaybackRawDataProvider.h:40
PlaybackRawDataProvider::readSem_
sem_t readSem_
Definition: PlaybackRawDataProvider.h:61
PlaybackRawDataProvider::lock_
sem_t lock_
Definition: PlaybackRawDataProvider.h:59
PlaybackRawDataProvider::unlock
void unlock()
Definition: PlaybackRawDataProvider.h:41
EcalFEDMonitor_cfi.FEDRawDataCollection
FEDRawDataCollection
Definition: EcalFEDMonitor_cfi.py:6
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
PlaybackRawDataProvider::instance_
static PlaybackRawDataProvider * instance_
Definition: PlaybackRawDataProvider.h:36
PlaybackRawDataProvider::postWriteSem
void postWriteSem()
Definition: PlaybackRawDataProvider.h:43
PlaybackRawDataProvider::freeToEof_
bool freeToEof_
Definition: PlaybackRawDataProvider.h:64
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
PlaybackRawDataProvider::runNumber_
unsigned int * runNumber_
Definition: PlaybackRawDataProvider.h:55
PlaybackRawDataProvider::filesClosed_
bool filesClosed_
Definition: PlaybackRawDataProvider.h:65
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
mps_fire.result
result
Definition: mps_fire.py:311
PlaybackRawDataProvider::readIndex_
unsigned int readIndex_
Definition: PlaybackRawDataProvider.h:63
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
PlaybackRawDataProvider::waitWriteSem
void waitWriteSem()
Definition: PlaybackRawDataProvider.h:42
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
PlaybackRawDataProvider::writeSem_
sem_t writeSem_
Definition: PlaybackRawDataProvider.h:60
PlaybackRawDataProvider::evtNumber_
unsigned int * evtNumber_
Definition: PlaybackRawDataProvider.h:56
PlaybackRawDataProvider::eventQueue_
FEDRawDataCollection ** eventQueue_
Definition: PlaybackRawDataProvider.h:54
FEDNumbering::MAXFEDID
Definition: FEDNumbering.h:26