CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
RawEventOutputModuleForBU< Consumer > Class Template Reference

#include <RawEventOutputModuleForBU.h>

Inheritance diagram for RawEventOutputModuleForBU< Consumer >:
edm::one::OutputModule< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::OutputModuleBase edm::EDConsumerBase

Public Member Functions

 RawEventOutputModuleForBU (edm::ParameterSet const &ps)
 
 ~RawEventOutputModuleForBU () override
 
- Public Member Functions inherited from edm::one::OutputModule< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
 OutputModule (edm::ParameterSet const &iPSet)
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::OutputModuleBase
BranchIDLists const * branchIDLists ()
 
std::array< bool, NumBranchTypes > const & hasNewlyDroppedBranch () const
 
SelectedProductsForBranchType const & keptProducts () const
 
int maxEvents () const
 
const ModuleDescriptionmoduleDescription () const
 
OutputModuleBaseoperator= (OutputModuleBase const &)=delete
 
 OutputModuleBase (ParameterSet const &pset)
 
 OutputModuleBase (OutputModuleBase const &)=delete
 
std::string const & processName () const
 
int remainingEvents () const
 
bool selected (BranchDescription const &desc) const
 
void selectProducts (ProductRegistry const &preg, ThinnedAssociationsHelper const &)
 
SharedResourcesAcquirersharedResourcesAcquirer ()
 
SubProcessParentageHelper const * subProcessParentageHelper () const
 
ThinnedAssociationsHelper const * thinnedAssociationsHelper () const
 
bool wantAllEvents () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~OutputModuleBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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)
 

Private Types

typedef unsigned int uint32
 

Private Member Functions

void beginLuminosityBlock (edm::LuminosityBlockForOutput const &) override
 
void beginRun (edm::RunForOutput const &) override
 
void endLuminosityBlock (edm::LuminosityBlockForOutput const &) override
 
void endRun (edm::RunForOutput const &) override
 
void write (edm::EventForOutput const &e) override
 
void writeLuminosityBlock (const edm::LuminosityBlockForOutput &) override
 
void writeRun (const edm::RunForOutput &) override
 

Private Attributes

bool firstLumi_
 
unsigned int frdVersion_
 
unsigned int index_
 
std::string instance_
 
std::string label_
 
unsigned int numEventsPerFile_
 
timeval startOfLastLumi
 
std::unique_ptr< Consumer > templateConsumer_
 
edm::EDGetTokenT< FEDRawDataCollectiontoken_
 
unsigned int totevents
 
unsigned long long totsize
 
unsigned long long writtensize
 
unsigned long long writtenSizeLast
 

Additional Inherited Members

- Public Types inherited from edm::one::OutputModuleBase
typedef OutputModuleBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::OutputModuleBase
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::one::OutputModuleBase
void configure (OutputModuleDescription const &desc)
 
ModuleDescription const & description () const
 
void doBeginJob ()
 
bool doBeginLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetupImpl const &c, ModuleCallingContext const *)
 
bool doBeginRun (RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *)
 
void doEndJob ()
 
bool doEndLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetupImpl const &c, ModuleCallingContext const *)
 
bool doEndRun (RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *)
 
bool doEvent (EventPrincipal const &ep, EventSetupImpl const &c, ActivityRegistry *, ModuleCallingContext const *)
 
void doPreallocate (PreallocationConfiguration const &)
 
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID ()
 
virtual void preallocLumis (unsigned int)
 
ParameterSetID selectorConfig () const
 
void setEventSelectionInfo (std::map< std::string, std::vector< std::pair< std::string, int >>> const &outputModulePathPositions, bool anyProductProduced)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<class Consumer>
class RawEventOutputModuleForBU< Consumer >

Definition at line 25 of file RawEventOutputModuleForBU.h.

Member Typedef Documentation

template<class Consumer >
typedef unsigned int RawEventOutputModuleForBU< Consumer >::uint32
private

Definition at line 26 of file RawEventOutputModuleForBU.h.

Constructor & Destructor Documentation

template<class Consumer >
RawEventOutputModuleForBU< Consumer >::RawEventOutputModuleForBU ( edm::ParameterSet const &  ps)
explicit

Consumers are suppose to provide: void doOutputEvent(const FRDEventMsgView& msg) void start() void stop()

Definition at line 64 of file RawEventOutputModuleForBU.h.

67  templateConsumer_(new Consumer(ps)),
68  label_(ps.getUntrackedParameter<std::string>("ProductLabel", "source")),
69  instance_(ps.getUntrackedParameter<std::string>("ProductInstance", "")),
70  token_(consumes<FEDRawDataCollection>(edm::InputTag(label_, instance_))),
71  numEventsPerFile_(ps.getUntrackedParameter<unsigned int>("numEventsPerFile", 100)),
72  frdVersion_(ps.getUntrackedParameter<unsigned int>("frdVersion", 3)),
73  totsize(0LL),
74  writtensize(0LL),
76  totevents(0),
77  index_(0),
78  firstLumi_(true) {}
std::unique_ptr< Consumer > templateConsumer_
edm::EDGetTokenT< FEDRawDataCollection > token_
OutputModuleBase(ParameterSet const &pset)
template<class Consumer >
RawEventOutputModuleForBU< Consumer >::~RawEventOutputModuleForBU ( )
override

Definition at line 81 of file RawEventOutputModuleForBU.h.

81 {}

Member Function Documentation

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::beginLuminosityBlock ( edm::LuminosityBlockForOutput const &  ls)
overrideprivate

Definition at line 176 of file RawEventOutputModuleForBU.h.

References gather_cfg::cout, corrVsCorr::filename, RawEventOutputModuleForBU< Consumer >::firstLumi_, edm::LuminosityBlockForOutput::id(), RawEventOutputModuleForBU< Consumer >::index_, L1DTConfigBti_cff::LL, edm::LuminosityBlockID::luminosityBlock(), fileCollector::now, RawEventOutputModuleForBU< Consumer >::startOfLastLumi, AlCaHLTBitMon_QueryRunRegistry::string, RawEventOutputModuleForBU< Consumer >::templateConsumer_, RawEventOutputModuleForBU< Consumer >::totevents, RawEventOutputModuleForBU< Consumer >::totsize, RawEventOutputModuleForBU< Consumer >::writtensize, and RawEventOutputModuleForBU< Consumer >::writtenSizeLast.

Referenced by RawEventOutputModuleForBU< Consumer >::writeLuminosityBlock().

176  {
177  index_ = 0;
178  std::string filename = edm::Service<evf::EvFDaqDirector>()->getOpenRawFilePath(ls.id().luminosityBlock(), index_);
179  std::string destinationDir = edm::Service<evf::EvFDaqDirector>()->buBaseRunDir();
180  std::cout << " writing to destination dir " << destinationDir << " name: " << filename << std::endl;
181  templateConsumer_->initialize(destinationDir, filename, ls.id().luminosityBlock());
182  //edm::Service<evf::EvFDaqDirector>()->updateBuLock(ls.id().luminosityBlock()+1);
183  if (!firstLumi_) {
184  timeval now;
185  ::gettimeofday(&now, nullptr);
186  //long long elapsedusec = (now.tv_sec - startOfLastLumi.tv_sec)*1000000+now.tv_usec-startOfLastLumi.tv_usec;
187  /* std::cout << "(now.tv_sec - startOfLastLumi.tv_sec) " << now.tv_sec <<"-" << startOfLastLumi.tv_sec */
188  /* <<" (now.tv_usec-startOfLastLumi.tv_usec) " << now.tv_usec << "-" << startOfLastLumi.tv_usec << std::endl; */
189  /* std::cout << "elapsedusec " << elapsedusec << " totevents " << totevents << " size (GB)" << writtensize */
190  /* << " rate " << (writtensize-writtenSizeLast)/elapsedusec << " MB/s" <<std::endl; */
192  ::gettimeofday(&startOfLastLumi, nullptr);
193  //edm::Service<evf::EvFDaqDirector>()->writeLsStatisticsBU(ls.id().luminosityBlock(), totevents, totsize, elapsedusec);
194  } else
195  ::gettimeofday(&startOfLastLumi, nullptr);
196  totevents = 0;
197  totsize = 0LL;
198  firstLumi_ = false;
199 }
std::unique_ptr< Consumer > templateConsumer_
def ls(path, rec=False)
Definition: eostools.py:349
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::beginRun ( edm::RunForOutput const &  )
overrideprivate

Definition at line 165 of file RawEventOutputModuleForBU.h.

References RawEventOutputModuleForBU< Consumer >::templateConsumer_.

165  {
166  // edm::Service<evf::EvFDaqDirector>()->updateBuLock(1);
167  templateConsumer_->start();
168 }
std::unique_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endLuminosityBlock ( edm::LuminosityBlockForOutput const &  ls)
overrideprivate

Definition at line 201 of file RawEventOutputModuleForBU.h.

References edm::LuminosityBlockForOutput::id(), edm::LuminosityBlockID::luminosityBlock(), and RawEventOutputModuleForBU< Consumer >::templateConsumer_.

Referenced by RawEventOutputModuleForBU< Consumer >::writeLuminosityBlock().

201  {
202  // templateConsumer_->touchlock(ls.id().luminosityBlock(),basedir);
203  templateConsumer_->endOfLS(ls.id().luminosityBlock());
204 }
std::unique_ptr< Consumer > templateConsumer_
def ls(path, rec=False)
Definition: eostools.py:349
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endRun ( edm::RunForOutput const &  )
overrideprivate

Definition at line 171 of file RawEventOutputModuleForBU.h.

References RawEventOutputModuleForBU< Consumer >::templateConsumer_.

171  {
172  templateConsumer_->stop();
173 }
std::unique_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::write ( edm::EventForOutput const &  e)
overrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 84 of file RawEventOutputModuleForBU.h.

References cms::Adler32(), crc32c(), FEDRawData::data(), edm::EventID::event(), FEDRawDataCollection::FEDData(), corrVsCorr::filename, FRDHeaderVersionSize, RawEventOutputModuleForBU< Consumer >::frdVersion_, edm::OccurrenceForOutput::getByToken(), edm::EventForOutput::id(), training_settings::idx, RawEventOutputModuleForBU< Consumer >::index_, FEDNumbering::lastFEDId(), eostools::ls(), edm::EventForOutput::luminosityBlock(), mps_check::msg, RawEventOutputModuleForBU< Consumer >::numEventsPerFile_, edm::EventID::run(), FEDRawData::size(), AlCaHLTBitMon_QueryRunRegistry::string, RawEventOutputModuleForBU< Consumer >::templateConsumer_, RawEventOutputModuleForBU< Consumer >::token_, RawEventOutputModuleForBU< Consumer >::totevents, RawEventOutputModuleForBU< Consumer >::totsize, and RawEventOutputModuleForBU< Consumer >::writtensize.

Referenced by pkg.AbstractPkg::generate().

84  {
85  unsigned int ls = e.luminosityBlock();
86  if (totevents > 0 && totevents % numEventsPerFile_ == 0) {
87  index_++;
88  std::string filename = edm::Service<evf::EvFDaqDirector>()->getOpenRawFilePath(ls, index_);
89  std::string destinationDir = edm::Service<evf::EvFDaqDirector>()->buBaseRunDir();
90  templateConsumer_->initialize(destinationDir, filename, ls);
91  }
92  totevents++;
93  // serialize the FEDRawDataCollection into the format that we expect for
94  // FRDEventMsgView objects (may be better ways to do this)
96  e.getByToken(token_, fedBuffers);
97 
98  // determine the expected size of the FRDEvent IN BYTES !!!!!
99  int headerSize = FRDHeaderVersionSize[frdVersion_];
100  int expectedSize = headerSize;
101  int nFeds = frdVersion_ < 3 ? 1024 : FEDNumbering::lastFEDId() + 1;
102 
103  for (int idx = 0; idx < nFeds; ++idx) {
104  FEDRawData singleFED = fedBuffers->FEDData(idx);
105  expectedSize += singleFED.size();
106  }
107 
108  totsize += expectedSize;
109  // build the FRDEvent into a temporary buffer
110  boost::shared_array<unsigned char> workBuffer(new unsigned char[expectedSize + 256]);
111  uint32* bufPtr = (uint32*)workBuffer.get();
112  *bufPtr++ = (uint32)frdVersion_; // version number
113  *bufPtr++ = (uint32)e.id().run();
114  *bufPtr++ = (uint32)e.luminosityBlock();
115  *bufPtr++ = (uint32)e.id().event();
116  if (frdVersion_ == 4)
117  *bufPtr++ = 0; //64-bit event id high part
118 
119  if (frdVersion_ < 3) {
120  uint32 fedsize[1024];
121  for (int idx = 0; idx < 1024; ++idx) {
122  FEDRawData singleFED = fedBuffers->FEDData(idx);
123  fedsize[idx] = singleFED.size();
124  //std::cout << "fed size " << singleFED.size()<< std::endl;
125  }
126  memcpy(bufPtr, fedsize, 1024 * sizeof(uint32));
127  bufPtr += 1024;
128  } else {
129  *bufPtr++ = expectedSize - headerSize;
130  *bufPtr++ = 0;
131  if (frdVersion_ <= 4)
132  *bufPtr++ = 0;
133  }
134  uint32* payloadPtr = bufPtr;
135  for (int idx = 0; idx < nFeds; ++idx) {
136  FEDRawData singleFED = fedBuffers->FEDData(idx);
137  if (singleFED.size() > 0) {
138  memcpy(bufPtr, singleFED.data(), singleFED.size());
139  bufPtr += singleFED.size() / 4;
140  }
141  }
142  if (frdVersion_ > 4) {
143  //crc32c checksum
144  uint32_t crc = 0;
145  *(payloadPtr - 1) = crc32c(crc, (const unsigned char*)payloadPtr, expectedSize - headerSize);
146  } else if (frdVersion_ >= 3) {
147  //adler32 checksum
148  uint32 adlera = 1;
149  uint32 adlerb = 0;
150  cms::Adler32((const char*)payloadPtr, expectedSize - headerSize, adlera, adlerb);
151  *(payloadPtr - 1) = (adlerb << 16) | adlera;
152  }
153 
154  // create the FRDEventMsgView and use the template consumer to write it out
155  FRDEventMsgView msg(workBuffer.get());
156  writtensize += msg.size();
157 
158  if (templateConsumer_->sharedMode())
159  templateConsumer_->doOutputEvent(workBuffer);
160  else
161  templateConsumer_->doOutputEvent(msg);
162 }
std::unique_ptr< Consumer > templateConsumer_
const uint32 FRDHeaderVersionSize[6]
edm::EDGetTokenT< FEDRawDataCollection > token_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
unsigned int uint32
Definition: MsgTools.h:13
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
Definition: crc32c.cc:340
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
def ls(path, rec=False)
Definition: eostools.py:349
tuple msg
Definition: mps_check.py:285
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::writeLuminosityBlock ( const edm::LuminosityBlockForOutput )
inlineoverrideprivate
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::writeRun ( const edm::RunForOutput )
inlineoverrideprivate

Definition at line 42 of file RawEventOutputModuleForBU.h.

42 {}

Member Data Documentation

template<class Consumer >
bool RawEventOutputModuleForBU< Consumer >::firstLumi_
private
template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::frdVersion_
private
template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::index_
private
template<class Consumer >
std::string RawEventOutputModuleForBU< Consumer >::instance_
private

Definition at line 50 of file RawEventOutputModuleForBU.h.

template<class Consumer >
std::string RawEventOutputModuleForBU< Consumer >::label_
private
template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::numEventsPerFile_
private
template<class Consumer >
timeval RawEventOutputModuleForBU< Consumer >::startOfLastLumi
private
template<class Consumer >
std::unique_ptr<Consumer> RawEventOutputModuleForBU< Consumer >::templateConsumer_
private
template<class Consumer >
edm::EDGetTokenT<FEDRawDataCollection> RawEventOutputModuleForBU< Consumer >::token_
private
template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::totevents
private
template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::totsize
private
template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::writtensize
private
template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::writtenSizeLast
private