CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::OutputModule edm::EDConsumerBase

Public Member Functions

 RawEventOutputModuleForBU (edm::ParameterSet const &ps)
 
 ~RawEventOutputModuleForBU ()
 
- Public Member Functions inherited from edm::OutputModule
BranchChildren const & branchChildren () const
 
BranchIDLists const * branchIDLists () const
 
std::array< bool,
NumBranchTypes > const & 
hasNewlyDroppedBranch () const
 
SelectedProductsForBranchType
const & 
keptProducts () const
 
int maxEvents () const
 
OutputModuleoperator= (OutputModule const &)=delete
 
 OutputModule (ParameterSet const &pset)
 
 OutputModule (OutputModule const &)=delete
 
std::string const & processName () const
 
int remainingEvents () const
 
bool selected (BranchDescription const &desc) const
 
void selectProducts (ProductRegistry const &preg, ThinnedAssociationsHelper const &)
 
ThinnedAssociationsHelper const * thinnedAssociationsHelper () const
 
bool wantAllEvents () const
 
virtual ~OutputModule ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef unsigned int uint32
 

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void beginRun (edm::RunPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void endLuminosityBlock (edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void endRun (edm::RunPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void write (edm::EventPrincipal const &e, edm::ModuleCallingContext const *)
 
virtual void writeLuminosityBlock (const edm::LuminosityBlockPrincipal &, edm::ModuleCallingContext const *)
 
virtual void writeRun (const edm::RunPrincipal &, edm::ModuleCallingContext const *)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::OutputModule
typedef OutputModule ModuleType
 
- Static Public Member Functions inherited from edm::OutputModule
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::OutputModule
void configure (OutputModuleDescription const &desc)
 
ModuleDescription const & description () const
 
void doBeginJob ()
 
bool doBeginLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc)
 
bool doBeginRun (RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
 
void doEndJob ()
 
bool doEndLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, ModuleCallingContext const *mcc)
 
bool doEndRun (RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
 
bool doEvent (EventPrincipal const &ep, EventSetup const &c, ActivityRegistry *act, ModuleCallingContext const *mcc)
 
void doPreallocate (PreallocationConfiguration const &)
 
std::map< BranchID::value_type,
BranchID::value_type > const & 
droppedBranchIDToKeptBranchID ()
 
Trig getTriggerResults (EventPrincipal const &ep, ModuleCallingContext const *) const
 
ModuleDescription const & moduleDescription () const
 
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 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 24 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 63 of file RawEventOutputModuleForBU.h.

63  :
65  templateConsumer_(new Consumer(ps)),
66  label_(ps.getUntrackedParameter<std::string>("ProductLabel","source")),
67  instance_(ps.getUntrackedParameter<std::string>("ProductInstance","")),
68  numEventsPerFile_(ps.getUntrackedParameter<unsigned int>("numEventsPerFile",100)),
69  frdVersion_(ps.getUntrackedParameter<unsigned int>("frdVersion",3)),
70  totsize(0LL),
71  writtensize(0LL),
72  writtenSizeLast(0LL),
73  totevents(0),
74  index_(0),
75  firstLumi_(true)
76 {
77 }
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
RawEventOutputModuleForBU< Consumer >::~RawEventOutputModuleForBU ( )

Definition at line 80 of file RawEventOutputModuleForBU.h.

80 {}

Member Function Documentation

template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::beginLuminosityBlock ( edm::LuminosityBlockPrincipal const &  ls,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 182 of file RawEventOutputModuleForBU.h.

References gather_cfg::cout, lut2db_cfg::filename, edm::LuminosityBlockPrincipal::id(), edm::LuminosityBlockID::luminosityBlock(), fileCollector::now, and AlCaHLTBitMon_QueryRunRegistry::string.

182  {
183  index_ = 0;
184  std::string filename = edm::Service<evf::EvFDaqDirector>()->getOpenRawFilePath( ls.id().luminosityBlock(),index_);
185  std::string destinationDir = edm::Service<evf::EvFDaqDirector>()->buBaseRunDir();
186  std::cout << " writing to destination dir " << destinationDir << " name: " << filename << std::endl;
187  templateConsumer_->initialize(destinationDir,filename,ls.id().luminosityBlock());
188  //edm::Service<evf::EvFDaqDirector>()->updateBuLock(ls.id().luminosityBlock()+1);
189  if(!firstLumi_){
190  timeval now;
191  ::gettimeofday(&now,0);
192  //long long elapsedusec = (now.tv_sec - startOfLastLumi.tv_sec)*1000000+now.tv_usec-startOfLastLumi.tv_usec;
193 /* std::cout << "(now.tv_sec - startOfLastLumi.tv_sec) " << now.tv_sec <<"-" << startOfLastLumi.tv_sec */
194 /* <<" (now.tv_usec-startOfLastLumi.tv_usec) " << now.tv_usec << "-" << startOfLastLumi.tv_usec << std::endl; */
195 /* std::cout << "elapsedusec " << elapsedusec << " totevents " << totevents << " size (GB)" << writtensize */
196 /* << " rate " << (writtensize-writtenSizeLast)/elapsedusec << " MB/s" <<std::endl; */
198  ::gettimeofday(&startOfLastLumi,0);
199  //edm::Service<evf::EvFDaqDirector>()->writeLsStatisticsBU(ls.id().luminosityBlock(), totevents, totsize, elapsedusec);
200  }
201  else
202  ::gettimeofday(&startOfLastLumi,0);
203  totevents = 0;
204  totsize = 0LL;
205  firstLumi_ = false;
206 }
def ls
Definition: eostools.py:346
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::beginRun ( edm::RunPrincipal const &  ,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 169 of file RawEventOutputModuleForBU.h.

170 {
171  // edm::Service<evf::EvFDaqDirector>()->updateBuLock(1);
172  templateConsumer_->start();
173 }
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endLuminosityBlock ( edm::LuminosityBlockPrincipal const &  ls,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 208 of file RawEventOutputModuleForBU.h.

References edm::LuminosityBlockPrincipal::id(), and edm::LuminosityBlockID::luminosityBlock().

208  {
209 
210  // templateConsumer_->touchlock(ls.id().luminosityBlock(),basedir);
211  templateConsumer_->endOfLS(ls.id().luminosityBlock());
212 }
def ls
Definition: eostools.py:346
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::endRun ( edm::RunPrincipal const &  ,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 176 of file RawEventOutputModuleForBU.h.

177 {
178  templateConsumer_->stop();
179 }
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
void RawEventOutputModuleForBU< Consumer >::write ( edm::EventPrincipal const &  e,
edm::ModuleCallingContext const *  mcc 
)
privatevirtual

Implements edm::OutputModule.

Definition at line 83 of file RawEventOutputModuleForBU.h.

References cms::Adler32(), crc32c(), FEDRawData::data(), idDealer::description, edm::EventID::event(), event(), lut2db_cfg::filename, FRDHeaderVersionSize, edm::EventBase::id(), customizeTrackingMonitorSeedNumber::idx, FEDNumbering::lastFEDId(), eostools::ls(), edm::EventBase::luminosityBlock(), edm::EventPrincipal::luminosityBlock(), producerFileCleanner::msg, edm::EventID::run(), FEDRawData::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pkg.AbstractPkg::generate().

84 {
85  unsigned int ls = e.luminosityBlock();
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)
95  edm::Event event(const_cast<edm::EventPrincipal&>(e), description(),mcc);
97  event.getByLabel(label_, instance_, fedBuffers);
98 
99  // determine the expected size of the FRDEvent IN BYTES !!!!!
100  int headerSize = FRDHeaderVersionSize[frdVersion_];
101  int expectedSize = headerSize;
102  int nFeds = frdVersion_<3? 1024 : FEDNumbering::lastFEDId()+1;
103 
104 
105  for (int idx = 0; idx < nFeds; ++idx) {
106  FEDRawData singleFED = fedBuffers->FEDData(idx);
107  expectedSize += singleFED.size();
108  }
109 
110  totsize += expectedSize;
111  // build the FRDEvent into a temporary buffer
112  boost::shared_array<unsigned char> workBuffer(new unsigned char[expectedSize + 256]);
113  uint32 *bufPtr = (uint32*) workBuffer.get();
114  *bufPtr++ = (uint32) frdVersion_; // version number
115  *bufPtr++ = (uint32) event.id().run();
116  *bufPtr++ = (uint32) event.luminosityBlock();
117  *bufPtr++ = (uint32) event.id().event();
118  if (frdVersion_==4)
119  *bufPtr++ = 0;//64-bit event id high part
120 
121  if (frdVersion_<3) {
122  uint32 fedsize[1024];
123  for (int idx = 0; idx < 1024; ++idx) {
124  FEDRawData singleFED = fedBuffers->FEDData(idx);
125  fedsize[idx] = singleFED.size();
126  //std::cout << "fed size " << singleFED.size()<< std::endl;
127  }
128  memcpy(bufPtr,fedsize,1024 * sizeof(uint32));
129  bufPtr += 1024;
130  }
131  else {
132  *bufPtr++ = expectedSize-headerSize;
133  *bufPtr++ = 0;
134  if (frdVersion_<=4)
135  *bufPtr++ = 0;
136  }
137  uint32 *payloadPtr=bufPtr;
138  for (int idx = 0; idx < nFeds; ++idx) {
139  FEDRawData singleFED = fedBuffers->FEDData(idx);
140  if (singleFED.size() > 0) {
141  memcpy(bufPtr, singleFED.data(), singleFED.size());
142  bufPtr += singleFED.size()/4;
143  }
144  }
145  if (frdVersion_>4) {
146  //crc32c checksum
147  uint32_t crc = 0;
148  *(payloadPtr-1) = crc32c(crc,(const unsigned char*) payloadPtr, expectedSize-headerSize);
149  }
150  else if (frdVersion_>=3) {
151  //adler32 checksum
152  uint32 adlera = 1;
153  uint32 adlerb = 0;
154  cms::Adler32((const char*) payloadPtr, expectedSize-headerSize, adlera, adlerb);
155  *(payloadPtr-1) = (adlerb << 16) | adlera;
156  }
157 
158  // create the FRDEventMsgView and use the template consumer to write it out
159  FRDEventMsgView msg(workBuffer.get());
160  writtensize+=msg.size();
161 
162  if (templateConsumer_->sharedMode())
163  templateConsumer_->doOutputEvent(workBuffer);
164  else
165  templateConsumer_->doOutputEvent(msg);
166 }
const uint32 FRDHeaderVersionSize[6]
def ls
Definition: eostools.py:346
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned int uint32
Definition: MsgTools.h:13
static int lastFEDId()
Definition: FEDNumbering.cc:17
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)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
tuple filename
Definition: lut2db_cfg.py:20
ModuleDescription const & description() const
std::auto_ptr< Consumer > templateConsumer_
template<class Consumer >
virtual void RawEventOutputModuleForBU< Consumer >::writeLuminosityBlock ( const edm::LuminosityBlockPrincipal ,
edm::ModuleCallingContext const *   
)
inlineprivatevirtual

Implements edm::OutputModule.

Definition at line 43 of file RawEventOutputModuleForBU.h.

43 {}
template<class Consumer >
virtual void RawEventOutputModuleForBU< Consumer >::writeRun ( const edm::RunPrincipal ,
edm::ModuleCallingContext const *   
)
inlineprivatevirtual

Implements edm::OutputModule.

Definition at line 42 of file RawEventOutputModuleForBU.h.

42 {}

Member Data Documentation

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

Definition at line 59 of file RawEventOutputModuleForBU.h.

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

Definition at line 52 of file RawEventOutputModuleForBU.h.

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

Definition at line 57 of file RawEventOutputModuleForBU.h.

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

Definition at line 51 of file RawEventOutputModuleForBU.h.

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

Definition at line 58 of file RawEventOutputModuleForBU.h.

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

Definition at line 48 of file RawEventOutputModuleForBU.h.

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

Definition at line 56 of file RawEventOutputModuleForBU.h.

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

Definition at line 53 of file RawEventOutputModuleForBU.h.

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

Definition at line 54 of file RawEventOutputModuleForBU.h.

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

Definition at line 55 of file RawEventOutputModuleForBU.h.