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 (OutputModuleBase const &)=delete
 
 OutputModuleBase (ParameterSet const &pset)
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
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)
 

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, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
 
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
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>
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)
 
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

template<class Consumer>
class RawEventOutputModuleForBU< Consumer >

Definition at line 25 of file RawEventOutputModuleForBU.h.

Member Typedef Documentation

◆ uint32

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

Definition at line 26 of file RawEventOutputModuleForBU.h.

Constructor & Destructor Documentation

◆ RawEventOutputModuleForBU()

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) {}

◆ ~RawEventOutputModuleForBU()

template<class Consumer >
RawEventOutputModuleForBU< Consumer >::~RawEventOutputModuleForBU ( )
override

Definition at line 81 of file RawEventOutputModuleForBU.h.

81 {}

Member Function Documentation

◆ beginLuminosityBlock()

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

Definition at line 176 of file RawEventOutputModuleForBU.h.

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 }

References gather_cfg::cout, corrVsCorr::filename, L1DTConfigBti_cff::LL, eostools::ls(), fileCollector::now, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ beginRun()

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::beginRun ( edm::RunForOutput const &  )
overrideprivate

Definition at line 165 of file RawEventOutputModuleForBU.h.

165  {
166  // edm::Service<evf::EvFDaqDirector>()->updateBuLock(1);
167  templateConsumer_->start();
168 }

◆ endLuminosityBlock()

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

Definition at line 201 of file RawEventOutputModuleForBU.h.

201  {
202  // templateConsumer_->touchlock(ls.id().luminosityBlock(),basedir);
203  templateConsumer_->endOfLS(ls.id().luminosityBlock());
204 }

References eostools::ls().

◆ endRun()

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endRun ( edm::RunForOutput const &  )
overrideprivate

Definition at line 171 of file RawEventOutputModuleForBU.h.

171  {
172  templateConsumer_->stop();
173 }

◆ write()

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::write ( edm::EventForOutput const &  e)
overrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 84 of file RawEventOutputModuleForBU.h.

84  {
85  unsigned int ls = e.luminosityBlock();
86  if (totevents > 0 && totevents % numEventsPerFile_ == 0) {
87  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 }

References cms::Adler32(), crc32c(), FEDRawData::data(), MillePedeFileConverter_cfg::e, FEDRawDataCollection::FEDData(), corrVsCorr::filename, FRDHeaderVersionSize, training_settings::idx, FEDNumbering::lastFEDId(), eostools::ls(), mps_check::msg, FEDRawData::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pkg.AbstractPkg::generate().

◆ writeLuminosityBlock()

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::writeLuminosityBlock ( const edm::LuminosityBlockForOutput )
inlineoverrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 43 of file RawEventOutputModuleForBU.h.

43 {}

◆ writeRun()

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::writeRun ( const edm::RunForOutput )
inlineoverrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 42 of file RawEventOutputModuleForBU.h.

42 {}

Member Data Documentation

◆ firstLumi_

template<class Consumer >
bool RawEventOutputModuleForBU< Consumer >::firstLumi_
private

Definition at line 60 of file RawEventOutputModuleForBU.h.

◆ frdVersion_

template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::frdVersion_
private

Definition at line 53 of file RawEventOutputModuleForBU.h.

◆ index_

template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::index_
private

Definition at line 58 of file RawEventOutputModuleForBU.h.

◆ instance_

template<class Consumer >
std::string RawEventOutputModuleForBU< Consumer >::instance_
private

Definition at line 50 of file RawEventOutputModuleForBU.h.

◆ label_

template<class Consumer >
std::string RawEventOutputModuleForBU< Consumer >::label_
private

◆ numEventsPerFile_

template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::numEventsPerFile_
private

Definition at line 52 of file RawEventOutputModuleForBU.h.

◆ startOfLastLumi

template<class Consumer >
timeval RawEventOutputModuleForBU< Consumer >::startOfLastLumi
private

Definition at line 59 of file RawEventOutputModuleForBU.h.

◆ templateConsumer_

template<class Consumer >
std::unique_ptr<Consumer> RawEventOutputModuleForBU< Consumer >::templateConsumer_
private

Definition at line 48 of file RawEventOutputModuleForBU.h.

◆ token_

template<class Consumer >
edm::EDGetTokenT<FEDRawDataCollection> RawEventOutputModuleForBU< Consumer >::token_
private

Definition at line 51 of file RawEventOutputModuleForBU.h.

◆ totevents

template<class Consumer >
unsigned int RawEventOutputModuleForBU< Consumer >::totevents
private

Definition at line 57 of file RawEventOutputModuleForBU.h.

◆ totsize

template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::totsize
private

Definition at line 54 of file RawEventOutputModuleForBU.h.

◆ writtensize

template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::writtensize
private

Definition at line 55 of file RawEventOutputModuleForBU.h.

◆ writtenSizeLast

template<class Consumer >
unsigned long long RawEventOutputModuleForBU< Consumer >::writtenSizeLast
private

Definition at line 56 of file RawEventOutputModuleForBU.h.

edm::one::OutputModule< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
FRDEventMsgView
Definition: FRDEventMessage.h:107
FEDNumbering::lastFEDId
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RawEventOutputModuleForBU::totsize
unsigned long long totsize
Definition: RawEventOutputModuleForBU.h:54
RawEventOutputModuleForBU::writtensize
unsigned long long writtensize
Definition: RawEventOutputModuleForBU.h:55
RawEventOutputModuleForBU::instance_
std::string instance_
Definition: RawEventOutputModuleForBU.h:50
FRDHeaderVersionSize
const uint32 FRDHeaderVersionSize[6]
Definition: FRDEventMessage.h:104
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
edm::one::OutputModuleBase::OutputModuleBase
OutputModuleBase(ParameterSet const &pset)
Definition: OutputModuleBase.cc:45
uint32
unsigned int uint32
Definition: MsgTools.h:13
FEDRawData
Definition: FEDRawData.h:19
fileCollector.now
now
Definition: fileCollector.py:207
cms::Adler32
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
Definition: Adler32Calculator.cc:10
RawEventOutputModuleForBU::uint32
unsigned int uint32
Definition: RawEventOutputModuleForBU.h:26
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
RawEventOutputModuleForBU::token_
edm::EDGetTokenT< FEDRawDataCollection > token_
Definition: RawEventOutputModuleForBU.h:51
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
crc32c
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
Definition: crc32c.cc:340
RawEventOutputModuleForBU::numEventsPerFile_
unsigned int numEventsPerFile_
Definition: RawEventOutputModuleForBU.h:52
RawEventOutputModuleForBU::firstLumi_
bool firstLumi_
Definition: RawEventOutputModuleForBU.h:60
RawEventOutputModuleForBU::totevents
unsigned int totevents
Definition: RawEventOutputModuleForBU.h:57
edm::Service
Definition: Service.h:30
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
RawEventOutputModuleForBU::writtenSizeLast
unsigned long long writtenSizeLast
Definition: RawEventOutputModuleForBU.h:56
RawEventOutputModuleForBU::templateConsumer_
std::unique_ptr< Consumer > templateConsumer_
Definition: RawEventOutputModuleForBU.h:48
RawEventOutputModuleForBU::label_
std::string label_
Definition: RawEventOutputModuleForBU.h:49
edm::InputTag
Definition: InputTag.h:15
RawEventOutputModuleForBU::index_
unsigned int index_
Definition: RawEventOutputModuleForBU.h:58
RawEventOutputModuleForBU::startOfLastLumi
timeval startOfLastLumi
Definition: RawEventOutputModuleForBU.h:59
RawEventOutputModuleForBU::frdVersion_
unsigned int frdVersion_
Definition: RawEventOutputModuleForBU.h:53
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37