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 27 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 65 of file RawEventOutputModuleForBU.h.

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

Definition at line 84 of file RawEventOutputModuleForBU.h.

84 {}

Member Function Documentation

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

Definition at line 185 of file RawEventOutputModuleForBU.h.

References gather_cfg::cout, corrVsCorr::filename, RawEventOutputModuleForBU< Consumer >::firstLumi_, edm::LuminosityBlockForOutput::id(), RawEventOutputModuleForBU< Consumer >::index_, edm::LuminosityBlockID::luminosityBlock(), cmsPerfSuiteHarvest::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().

185  {
186  index_ = 0;
187  std::string filename = edm::Service<evf::EvFDaqDirector>()->getOpenRawFilePath( ls.id().luminosityBlock(),index_);
188  std::string destinationDir = edm::Service<evf::EvFDaqDirector>()->buBaseRunDir();
189  std::cout << " writing to destination dir " << destinationDir << " name: " << filename << std::endl;
190  templateConsumer_->initialize(destinationDir,filename,ls.id().luminosityBlock());
191  //edm::Service<evf::EvFDaqDirector>()->updateBuLock(ls.id().luminosityBlock()+1);
192  if(!firstLumi_){
193  timeval now;
194  ::gettimeofday(&now,nullptr);
195  //long long elapsedusec = (now.tv_sec - startOfLastLumi.tv_sec)*1000000+now.tv_usec-startOfLastLumi.tv_usec;
196 /* std::cout << "(now.tv_sec - startOfLastLumi.tv_sec) " << now.tv_sec <<"-" << startOfLastLumi.tv_sec */
197 /* <<" (now.tv_usec-startOfLastLumi.tv_usec) " << now.tv_usec << "-" << startOfLastLumi.tv_usec << std::endl; */
198 /* std::cout << "elapsedusec " << elapsedusec << " totevents " << totevents << " size (GB)" << writtensize */
199 /* << " rate " << (writtensize-writtenSizeLast)/elapsedusec << " MB/s" <<std::endl; */
201  ::gettimeofday(&startOfLastLumi,nullptr);
202  //edm::Service<evf::EvFDaqDirector>()->writeLsStatisticsBU(ls.id().luminosityBlock(), totevents, totsize, elapsedusec);
203  }
204  else
205  ::gettimeofday(&startOfLastLumi,nullptr);
206  totevents = 0;
207  totsize = 0LL;
208  firstLumi_ = false;
209 }
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 172 of file RawEventOutputModuleForBU.h.

References RawEventOutputModuleForBU< Consumer >::templateConsumer_.

173 {
174  // edm::Service<evf::EvFDaqDirector>()->updateBuLock(1);
175  templateConsumer_->start();
176 }
std::unique_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endLuminosityBlock ( edm::LuminosityBlockForOutput const &  ls)
overrideprivate

Definition at line 211 of file RawEventOutputModuleForBU.h.

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

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

211  {
212 
213  // templateConsumer_->touchlock(ls.id().luminosityBlock(),basedir);
214  templateConsumer_->endOfLS(ls.id().luminosityBlock());
215 }
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 179 of file RawEventOutputModuleForBU.h.

References RawEventOutputModuleForBU< Consumer >::templateConsumer_.

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

Implements edm::one::OutputModuleBase.

Definition at line 87 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().

88 {
89  unsigned int ls = e.luminosityBlock();
91  index_++;
92  std::string filename = edm::Service<evf::EvFDaqDirector>()->getOpenRawFilePath( ls,index_);
93  std::string destinationDir = edm::Service<evf::EvFDaqDirector>()->buBaseRunDir();
94  templateConsumer_->initialize(destinationDir,filename,ls);
95  }
96  totevents++;
97  // serialize the FEDRawDataCollection into the format that we expect for
98  // FRDEventMsgView objects (may be better ways to do this)
100  e.getByToken(token_, fedBuffers);
101 
102  // determine the expected size of the FRDEvent IN BYTES !!!!!
103  int headerSize = FRDHeaderVersionSize[frdVersion_];
104  int expectedSize = headerSize;
105  int nFeds = frdVersion_<3? 1024 : FEDNumbering::lastFEDId()+1;
106 
107 
108  for (int idx = 0; idx < nFeds; ++idx) {
109  FEDRawData singleFED = fedBuffers->FEDData(idx);
110  expectedSize += singleFED.size();
111  }
112 
113  totsize += expectedSize;
114  // build the FRDEvent into a temporary buffer
115  boost::shared_array<unsigned char> workBuffer(new unsigned char[expectedSize + 256]);
116  uint32 *bufPtr = (uint32*) workBuffer.get();
117  *bufPtr++ = (uint32) frdVersion_; // version number
118  *bufPtr++ = (uint32) e.id().run();
119  *bufPtr++ = (uint32) e.luminosityBlock();
120  *bufPtr++ = (uint32) e.id().event();
121  if (frdVersion_==4)
122  *bufPtr++ = 0;//64-bit event id high part
123 
124  if (frdVersion_<3) {
125  uint32 fedsize[1024];
126  for (int idx = 0; idx < 1024; ++idx) {
127  FEDRawData singleFED = fedBuffers->FEDData(idx);
128  fedsize[idx] = singleFED.size();
129  //std::cout << "fed size " << singleFED.size()<< std::endl;
130  }
131  memcpy(bufPtr,fedsize,1024 * sizeof(uint32));
132  bufPtr += 1024;
133  }
134  else {
135  *bufPtr++ = expectedSize-headerSize;
136  *bufPtr++ = 0;
137  if (frdVersion_<=4)
138  *bufPtr++ = 0;
139  }
140  uint32 *payloadPtr=bufPtr;
141  for (int idx = 0; idx < nFeds; ++idx) {
142  FEDRawData singleFED = fedBuffers->FEDData(idx);
143  if (singleFED.size() > 0) {
144  memcpy(bufPtr, singleFED.data(), singleFED.size());
145  bufPtr += singleFED.size()/4;
146  }
147  }
148  if (frdVersion_>4) {
149  //crc32c checksum
150  uint32_t crc = 0;
151  *(payloadPtr-1) = crc32c(crc,(const unsigned char*) payloadPtr, expectedSize-headerSize);
152  }
153  else if (frdVersion_>=3) {
154  //adler32 checksum
155  uint32 adlera = 1;
156  uint32 adlerb = 0;
157  cms::Adler32((const char*) payloadPtr, expectedSize-headerSize, adlera, adlerb);
158  *(payloadPtr-1) = (adlerb << 16) | adlera;
159  }
160 
161  // create the FRDEventMsgView and use the template consumer to write it out
162  FRDEventMsgView msg(workBuffer.get());
163  writtensize+=msg.size();
164 
165  if (templateConsumer_->sharedMode())
166  templateConsumer_->doOutputEvent(workBuffer);
167  else
168  templateConsumer_->doOutputEvent(msg);
169 }
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:47
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:279
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
static constexpr int lastFEDId()
Definition: FEDNumbering.h:22
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 43 of file RawEventOutputModuleForBU.h.

43 {}

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 51 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