CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::StreamerOutputModuleBase Class Referenceabstract

#include <StreamerOutputModuleBase.h>

Inheritance diagram for edm::StreamerOutputModuleBase:
edm::OutputModule edm::StreamerOutputModule< Consumer >

Public Member Functions

 StreamerOutputModuleBase (ParameterSet const &ps)
 
virtual ~StreamerOutputModuleBase ()
 
- Public Member Functions inherited from edm::OutputModule
BranchChildren const & branchChildren () const
 
boost::array< bool,
NumBranchTypes > const & 
hasNewlyDroppedBranch () const
 
SelectionsArray const & keptProducts () const
 
int maxEvents () const
 
 OutputModule (ParameterSet const &pset)
 
std::string const & processName () const
 
int remainingEvents () const
 
bool selected (BranchDescription const &desc) const
 
void selectProducts ()
 
bool wantAllEvents () const
 
virtual ~OutputModule ()
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::OutputModule
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob ()
 
virtual void beginRun (RunPrincipal const &)
 
virtual void doOutputEvent (EventMsgBuilder const &msg) const =0
 
virtual void doOutputHeader (InitMsgBuilder const &init_message) const =0
 
virtual void endJob ()
 
virtual void endRun (RunPrincipal const &)
 
std::auto_ptr< EventMsgBuilderserializeEvent (EventPrincipal const &e)
 
std::auto_ptr< InitMsgBuilderserializeRegistry ()
 
void setHltMask (EventPrincipal const &e)
 
void setLumiSection ()
 
virtual void start () const =0
 
virtual void stop () const =0
 
virtual void write (EventPrincipal const &e)
 
virtual void writeLuminosityBlock (LuminosityBlockPrincipal const &)
 
virtual void writeRun (RunPrincipal const &)
 

Private Attributes

int compressionLevel_
 
std::vector< unsigned char > hltbits_
 
unsigned int hltsize_
 
Strings hltTriggerSelections_
 
char host_name_ [255]
 
std::vector< bool > l1bit_
 
uint32 lumi_
 
int lumiSectionInterval_
 
int maxEventSize_
 
uint32 origSize_
 
uint32 outputModuleId_
 
Selections const * selections_
 
StreamSerializer serializer_
 
double timeInSecSinceUTC
 
bool useCompression_
 

Additional Inherited Members

- Public Types inherited from edm::OutputModule
typedef OutputModule ModuleType
 
typedef OutputWorker WorkerType
 
- Protected Member Functions inherited from edm::OutputModule
CurrentProcessingContext const * currentContext () const
 
ModuleDescription const & description () const
 
void doBeginJob ()
 
bool doBeginLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doBeginRun (RunPrincipal const &rp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
void doEndJob ()
 
bool doEndLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doEndRun (RunPrincipal const &rp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doEvent (EventPrincipal const &ep, EventSetup const &c, CurrentProcessingContext const *cpc)
 
Trig getTriggerResults (Event const &ep) const
 
Trig getTriggerResults (EventPrincipal const &ep) const
 
ParameterSetID selectorConfig () const
 

Detailed Description

Definition at line 15 of file StreamerOutputModuleBase.h.

Constructor & Destructor Documentation

edm::StreamerOutputModuleBase::StreamerOutputModuleBase ( ParameterSet const &  ps)
explicit

Definition at line 56 of file StreamerOutputModuleBase.cc.

References SerializeDataBuffer::bufs_, compressionLevel_, edm::RootAutoLibraryLoader::enable(), FDEBUG, edm::EventSelector::getEventSelectionVString(), hltTriggerSelections_, host_name_, maxEventSize_, timeInSecSinceUTC, and useCompression_.

56  :
57  OutputModule(ps),
59  maxEventSize_(ps.getUntrackedParameter<int>("max_event_size")),
60  useCompression_(ps.getUntrackedParameter<bool>("use_compression")),
61  compressionLevel_(ps.getUntrackedParameter<int>("compression_level")),
62  lumiSectionInterval_(ps.getUntrackedParameter<int>("lumiSection_interval")),
64  hltsize_(0),
65  lumi_(0),
66  l1bit_(0),
67  hltbits_(0),
68  origSize_(0) { // no compression as default value - we need this!
69 
70  // test luminosity sections
71  struct timeval now;
72  struct timezone dummyTZ;
73  gettimeofday(&now, &dummyTZ);
74  timeInSecSinceUTC = static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec)/1000000.0);
75 
76  if(useCompression_ == true) {
77  if(compressionLevel_ <= 0) {
78  FDEBUG(9) << "Compression Level = " << compressionLevel_
79  << " no compression" << std::endl;
81  useCompression_ = false;
82  } else if(compressionLevel_ > 9) {
83  FDEBUG(9) << "Compression Level = " << compressionLevel_
84  << " using max compression level 9" << std::endl;
86  }
87  }
89  int got_host = gethostname(host_name_, 255);
90  if(got_host != 0) strcpy(host_name_, "noHostNameFoundOrTooLong");
91  //loadExtraClasses();
92  // do the line below instead of loadExtraClasses() to avoid Root errors
94 
95  // 25-Jan-2008, KAB - pull out the trigger selection request
96  // which we need for the INIT message
98  }
SelectionsArray const & keptProducts() const
Definition: OutputModule.h:56
static SerializeDataBuffer serialize_databuffer
#define FDEBUG(lev)
Definition: DebugMacros.h:18
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
static void enable()
interface for TClass generators
std::vector< unsigned char > hltbits_
OutputModule(ParameterSet const &pset)
edm::StreamerOutputModuleBase::~StreamerOutputModuleBase ( )
virtual

Definition at line 100 of file StreamerOutputModuleBase.cc.

100 {}

Member Function Documentation

void edm::StreamerOutputModuleBase::beginJob ( void  )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 115 of file StreamerOutputModuleBase.cc.

115 {}
void edm::StreamerOutputModuleBase::beginRun ( RunPrincipal const &  )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 103 of file StreamerOutputModuleBase.cc.

References doOutputHeader(), serializeRegistry(), and start().

103  {
104  start();
105  std::auto_ptr<InitMsgBuilder> init_message = serializeRegistry();
106  doOutputHeader(*init_message);
107  }
virtual void doOutputHeader(InitMsgBuilder const &init_message) const =0
std::auto_ptr< InitMsgBuilder > serializeRegistry()
virtual void start() const =0
virtual void edm::StreamerOutputModuleBase::doOutputEvent ( EventMsgBuilder const &  msg) const
privatepure virtual

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by write().

virtual void edm::StreamerOutputModuleBase::doOutputHeader ( InitMsgBuilder const &  init_message) const
privatepure virtual

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by beginRun().

void edm::StreamerOutputModuleBase::endJob ( void  )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 118 of file StreamerOutputModuleBase.cc.

References stop().

118  {
119  stop(); // for closing of files, notify storage manager, etc.
120  }
virtual void stop() const =0
void edm::StreamerOutputModuleBase::endRun ( RunPrincipal const &  )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 110 of file StreamerOutputModuleBase.cc.

References stop().

110  {
111  stop();
112  }
virtual void stop() const =0
void edm::StreamerOutputModuleBase::fillDescription ( ParameterSetDescription desc)
static

Definition at line 289 of file StreamerOutputModuleBase.cc.

References edm::ParameterSetDescription::addUntracked(), and edm::OutputModule::fillDescription().

Referenced by edm::StreamerOutputModule< Consumer >::fillDescriptions().

289  {
290  desc.addUntracked<int>("max_event_size", 7000000)
291  ->setComment("Starting size in bytes of the serialized event buffer.");
292  desc.addUntracked<bool>("use_compression", true)
293  ->setComment("If True, compression will be used to write streamer file.");
294  desc.addUntracked<int>("compression_level", 1)
295  ->setComment("ROOT compression level to use.");
296  desc.addUntracked<int>("lumiSection_interval", 0)
297  ->setComment("If 0, use lumi section number from event.\n"
298  "If not 0, the interval in seconds between fake lumi sections.");
300  }
static void fillDescription(ParameterSetDescription &desc)
std::auto_ptr< EventMsgBuilder > edm::StreamerOutputModuleBase::serializeEvent ( EventPrincipal const &  e)
private

Definition at line 237 of file StreamerOutputModuleBase.cc.

References SerializeDataBuffer::adler32_chksum(), SerializeDataBuffer::bufferPointer(), SerializeDataBuffer::bufs_, compressionLevel_, filterCSVwithJSON::copy, SerializeDataBuffer::currentEventSize(), SerializeDataBuffer::currentSpaceUsed(), edm::EventID::event(), hltbits_, hltsize_, host_name_, edm::EventPrincipal::id(), l1bit_, lumi_, edm::EventPrincipal::luminosityBlock(), lumiSectionInterval_, runTheMatrix::msg, origSize_, outputModuleId_, edm::EventID::run(), edm::OutputModule::selectorConfig(), edm::StreamSerializer::serializeEvent(), serializer_, setHltMask(), setLumiSection(), align_tpl::src, and useCompression_.

Referenced by write().

237  {
238  //Lets Build the Event Message first
239 
240  //Following is strictly DUMMY Data for L! Trig and will be replaced with actual
241  // once figured out, there is no logic involved here.
242  l1bit_.push_back(true);
243  l1bit_.push_back(true);
244  l1bit_.push_back(false);
245  //End of dummy data
246 
247  setHltMask(e);
248 
249  if (lumiSectionInterval_ == 0) {
250  lumi_ = e.luminosityBlock();
251  } else {
252  setLumiSection();
253  }
254 
256 
257  // resize bufs_ to reflect space used in serializer_ + header
258  // I just added an overhead for header of 50000 for now
259  unsigned int src_size = serialize_databuffer.currentSpaceUsed();
260  unsigned int new_size = src_size + 50000;
261  if(serialize_databuffer.bufs_.size() < new_size) serialize_databuffer.bufs_.resize(new_size);
262 
263  std::auto_ptr<EventMsgBuilder>
265  e.id().event(), lumi_, outputModuleId_, 0,
266  l1bit_, (uint8*)&hltbits_[0], hltsize_,
268  msg->setOrigDataSize(origSize_); // we need this set to zero
269 
270  // copy data into the destination message
271  // an alternative is to have serializer only to the serialization
272  // in serializeEvent, and then call a new member "getEventData" that
273  // takes the compression arguments and a place to put the data.
274  // This will require one less copy. The only catch is that the
275  // space provided in bufs_ should be at least the uncompressed
276  // size + overhead for header because we will not know the actual
277  // compressed size.
278 
279  unsigned char* src = serialize_databuffer.bufferPointer();
280  std::copy(src,src + src_size, msg->eventAddr());
281  msg->setEventLength(src_size);
283 
284  l1bit_.clear(); //Clear up for the next event to come.
285  return msg;
286  }
void setHltMask(EventPrincipal const &e)
static SerializeDataBuffer serialize_databuffer
unsigned int currentSpaceUsed() const
int serializeEvent(EventPrincipal const &eventPrincipal, ParameterSetID const &selectorConfig, bool use_compression, int compression_level, SerializeDataBuffer &data_buffer)
unsigned int uint32
Definition: MsgTools.h:13
unsigned char * bufferPointer() const
uint32_t adler32_chksum() const
unsigned char uint8
Definition: MsgTools.h:11
unsigned int currentEventSize() const
std::vector< unsigned char > hltbits_
ParameterSetID selectorConfig() const
Definition: OutputModule.h:83
tuple src
Definition: align_tpl.py:87
std::auto_ptr< InitMsgBuilder > edm::StreamerOutputModuleBase::serializeRegistry ( )
private

Definition at line 135 of file StreamerOutputModuleBase.cc.

References SerializeDataBuffer::adler32_chksum(), SerializeDataBuffer::bufferPointer(), edm::Hash< I >::compactForm(), filterCSVwithJSON::copy, SerializeDataBuffer::currentSpaceUsed(), edm::OutputModule::description(), edm::getAllTriggerNames(), edm::pset::getProcessParameterSetID(), edm::getReleaseVersion(), SerializeDataBuffer::header_buf_, hltsize_, hltTriggerSelections_, host_name_, edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), dttmaxenums::L, moduleLabel(), edm::ModuleDescription::moduleLabel(), outputModuleId_, edm::OutputModule::processName(), DTTTrigCorrFirst::run, serializer_, edm::StreamSerializer::serializeRegistry(), align_tpl::src, and v.

Referenced by beginRun().

135  {
136 
138 
139  // resize bufs_ to reflect space used in serializer_ + header
140  // I just added an overhead for header of 50000 for now
141  unsigned int src_size = serialize_databuffer.currentSpaceUsed();
142  unsigned int new_size = src_size + 50000;
143  if(serialize_databuffer.header_buf_.size() < new_size) serialize_databuffer.header_buf_.resize(new_size);
144 
145  //Build the INIT Message
146  //Following values are strictly DUMMY and will be replaced
147  // once available with Utility function etc.
148  uint32 run = 1;
149 
150  //Get the Process PSet ID
153 
154  //In case we need to print it
155  // cms::Digest dig(toplevel.compactForm());
156  // cms::MD5Result r1 = dig.digest();
157  // std::string hexy = r1.toString();
158  // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl;
159 
160  //Setting protocol version V
161  Version v(8,(uint8*)toplevel.compactForm().c_str());
162 
163  Strings hltTriggerNames = getAllTriggerNames();
164  hltsize_ = hltTriggerNames.size();
165 
166  //L1 stays dummy as of today
167  Strings l1_names; //3
168  l1_names.push_back("t1");
169  l1_names.push_back("t10");
170  l1_names.push_back("t2");
171 
172  //Setting the process name to HLT
173  std::string processName = OutputModule::processName();
174 
175  std::string moduleLabel = description().moduleLabel();
176  uLong crc = crc32(0L, Z_NULL, 0);
177  Bytef* buf = (Bytef*) moduleLabel.data();
178  crc = crc32(crc, buf, moduleLabel.length());
179  outputModuleId_ = static_cast<uint32>(crc);
180 
181  std::auto_ptr<InitMsgBuilder> init_message(
183  run, v, getReleaseVersion().c_str() , processName.c_str(),
184  moduleLabel.c_str(), outputModuleId_,
185  hltTriggerNames, hltTriggerSelections_, l1_names,
187 
188  // copy data into the destination message
189  unsigned char* src = serialize_databuffer.bufferPointer();
190  std::copy(src, src + src_size, init_message->dataAddress());
191  init_message->setDataLength(src_size);
192  return init_message;
193  }
std::vector< std::string > Strings
Definition: MsgTools.h:18
std::string const & processName() const
Definition: OutputModule.h:55
static SerializeDataBuffer serialize_databuffer
detail::ThreadSafeRegistry< ParameterSetID, ParameterSet, ProcessParameterSetIDCache > Registry
Definition: Registry.h:37
std::string const & moduleLabel() const
unsigned int currentSpaceUsed() const
Hash< ParameterSetType > ParameterSetID
unsigned int uint32
Definition: MsgTools.h:13
std::string getReleaseVersion()
unsigned char * bufferPointer() const
uint32_t adler32_chksum() const
unsigned char uint8
Definition: MsgTools.h:11
std::vector< std::string > const & getAllTriggerNames()
Definition: OutputModule.cc:35
int serializeRegistry(SerializeDataBuffer &data_buffer)
ParameterSetID getProcessParameterSetID(Registry const *reg)
Associated free functions.
Definition: Registry.cc:11
static ThreadSafeRegistry * instance()
ModuleDescription const & description() const
mathSSE::Vec4< T > v
tuple src
Definition: align_tpl.py:87
const std::string * moduleLabel() const
Definition: HLTadd.h:40
void edm::StreamerOutputModuleBase::setHltMask ( EventPrincipal const &  e)
private

Definition at line 196 of file StreamerOutputModuleBase.cc.

References edm::OutputModule::getTriggerResults(), hltbits_, hltsize_, i, edm::HandleBase::isValid(), edm::hlt::Pass, parseEventContent::prod, and evf::utils::state.

Referenced by serializeEvent().

196  {
197 
198  hltbits_.clear(); // If there was something left over from last event
199 
201  //Trig const& prod = getTrigMask(e);
202  std::vector<unsigned char> vHltState;
203 
204  if (prod.isValid()) {
206  vHltState.push_back(((prod->at(i)).state()));
207  }
208  } else {
209  // We fill all Trigger bits to valid state.
211  vHltState.push_back(hlt::Pass);
212  }
213  }
214  //Pack into member hltbits_
215  packIntoString(vHltState, hltbits_);
216 
217  //This is Just a printing code.
218  //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl;
219  //for(unsigned int i=0; i != hltbits_.size() ; ++i) {
220  // printBits(hltbits_[i]);
221  //}
222  //std::cout << "\n";
223  }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
accept
Definition: HLTenums.h:22
char state
Definition: procUtils.cc:75
Trig getTriggerResults(Event const &ep) const
std::vector< unsigned char > hltbits_
void edm::StreamerOutputModuleBase::setLumiSection ( )
private

Definition at line 227 of file StreamerOutputModuleBase.cc.

References lumi_, lumiSectionInterval_, and timeInSecSinceUTC.

Referenced by serializeEvent().

227  {
228  struct timeval now;
229  struct timezone dummyTZ;
230  gettimeofday(&now, &dummyTZ);
231  double timeInSec = static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec)/1000000.0) - timeInSecSinceUTC;
232  // what about overflows?
233  if(lumiSectionInterval_ > 0) lumi_ = static_cast<uint32>(timeInSec/lumiSectionInterval_) + 1;
234  }
unsigned int uint32
Definition: MsgTools.h:13
virtual void edm::StreamerOutputModuleBase::start ( ) const
privatepure virtual

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by beginRun().

virtual void edm::StreamerOutputModuleBase::stop ( ) const
privatepure virtual

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by endJob(), and endRun().

void edm::StreamerOutputModuleBase::write ( EventPrincipal const &  e)
privatevirtual

Implements edm::OutputModule.

Definition at line 129 of file StreamerOutputModuleBase.cc.

References doOutputEvent(), runTheMatrix::msg, and serializeEvent().

129  {
130  std::auto_ptr<EventMsgBuilder> msg = serializeEvent(e);
131  doOutputEvent(*msg); // You can't use msg in StreamerOutputModuleBase after this point
132  }
std::auto_ptr< EventMsgBuilder > serializeEvent(EventPrincipal const &e)
virtual void doOutputEvent(EventMsgBuilder const &msg) const =0
void edm::StreamerOutputModuleBase::writeLuminosityBlock ( LuminosityBlockPrincipal const &  )
privatevirtual

Implements edm::OutputModule.

Definition at line 126 of file StreamerOutputModuleBase.cc.

126 {}
void edm::StreamerOutputModuleBase::writeRun ( RunPrincipal const &  )
privatevirtual

Implements edm::OutputModule.

Definition at line 123 of file StreamerOutputModuleBase.cc.

123 {}

Member Data Documentation

int edm::StreamerOutputModuleBase::compressionLevel_
private

Definition at line 45 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and StreamerOutputModuleBase().

std::vector<unsigned char> edm::StreamerOutputModuleBase::hltbits_
private

Definition at line 57 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setHltMask().

unsigned int edm::StreamerOutputModuleBase::hltsize_
private

Definition at line 54 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), serializeRegistry(), and setHltMask().

Strings edm::StreamerOutputModuleBase::hltTriggerSelections_
private

Definition at line 61 of file StreamerOutputModuleBase.h.

Referenced by serializeRegistry(), and StreamerOutputModuleBase().

char edm::StreamerOutputModuleBase::host_name_[255]
private
std::vector<bool> edm::StreamerOutputModuleBase::l1bit_
private

Definition at line 56 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent().

uint32 edm::StreamerOutputModuleBase::lumi_
private

Definition at line 55 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setLumiSection().

int edm::StreamerOutputModuleBase::lumiSectionInterval_
private

Definition at line 48 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setLumiSection().

int edm::StreamerOutputModuleBase::maxEventSize_
private

Definition at line 43 of file StreamerOutputModuleBase.h.

Referenced by StreamerOutputModuleBase().

uint32 edm::StreamerOutputModuleBase::origSize_
private

Definition at line 58 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent().

uint32 edm::StreamerOutputModuleBase::outputModuleId_
private

Definition at line 62 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and serializeRegistry().

Selections const* edm::StreamerOutputModuleBase::selections_
private

Definition at line 41 of file StreamerOutputModuleBase.h.

StreamSerializer edm::StreamerOutputModuleBase::serializer_
private

Definition at line 51 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and serializeRegistry().

double edm::StreamerOutputModuleBase::timeInSecSinceUTC
private

Definition at line 49 of file StreamerOutputModuleBase.h.

Referenced by setLumiSection(), and StreamerOutputModuleBase().

bool edm::StreamerOutputModuleBase::useCompression_
private

Definition at line 44 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and StreamerOutputModuleBase().