CMS 3D CMS Logo

edm::StreamerOutputModuleBase Class Reference

#include <IOPool/Streamer/interface/StreamerOutputModuleBase.h>

Inheritance diagram for edm::StreamerOutputModuleBase:

edm::OutputModule edm::StreamerOutputModule< Consumer >

List of all members.

Public Member Functions

 StreamerOutputModuleBase (ParameterSet const &ps)
virtual ~StreamerOutputModuleBase ()

Private Member Functions

virtual void beginJob (EventSetup const &)
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_
std::vector< booll1bit_
uint32 lumi_
int lumiSectionInterval_
int maxEventSize_
uint32 origSize_
uint32 outputModuleId_
Selections const * selections_
StreamSerializer serializer_
double timeInSecSinceUTC
bool useCompression_


Detailed Description

Definition at line 14 of file StreamerOutputModuleBase.h.


Constructor & Destructor Documentation

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

Definition at line 53 of file StreamerOutputModuleBase.cc.

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

00053                                                                            :
00054     OutputModule(ps),
00055     selections_(&keptProducts()[InEvent]),
00056     maxEventSize_(ps.getUntrackedParameter<int>("max_event_size", 7000000)),
00057     useCompression_(ps.getUntrackedParameter<bool>("use_compression", true)),
00058     compressionLevel_(ps.getUntrackedParameter<int>("compression_level", 1)),
00059     lumiSectionInterval_(ps.getUntrackedParameter<int>("lumiSection_interval", 0)), 
00060     serializer_(selections_),
00061     hltsize_(0),
00062     lumi_(0), 
00063     l1bit_(0),
00064     hltbits_(0),
00065     origSize_(0) // no compression as default value - we need this!
00066   {
00067 
00068     // test luminosity sections
00069     struct timeval now;
00070     struct timezone dummyTZ;
00071     gettimeofday(&now, &dummyTZ);
00072     timeInSecSinceUTC = static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec)/1000000.0);
00073 
00074     if(useCompression_ == true) {
00075       if(compressionLevel_ <= 0) {
00076         FDEBUG(9) << "Compression Level = " << compressionLevel_ 
00077                   << " no compression" << std::endl;
00078         compressionLevel_ = 0;
00079         useCompression_ = false;
00080       } else if(compressionLevel_ > 9) {
00081         FDEBUG(9) << "Compression Level = " << compressionLevel_ 
00082                   << " using max compression level 9" << std::endl;
00083         compressionLevel_ = 9;
00084       }
00085     }
00086     serialize_databuffer.bufs_.resize(maxEventSize_);
00087     //loadExtraClasses();
00088     // do the line below instead of loadExtraClasses() to avoid Root errors
00089     RootAutoLibraryLoader::enable();
00090 
00091     // 25-Jan-2008, KAB - pull out the trigger selection request
00092     // which we need for the INIT message
00093     hltTriggerSelections_ = EventSelector::getEventSelectionVString(ps);
00094   }

edm::StreamerOutputModuleBase::~StreamerOutputModuleBase (  )  [virtual]

Definition at line 96 of file StreamerOutputModuleBase.cc.

00096 {}


Member Function Documentation

void edm::StreamerOutputModuleBase::beginJob ( EventSetup const &   )  [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 111 of file StreamerOutputModuleBase.cc.

00111 {}

void edm::StreamerOutputModuleBase::beginRun ( RunPrincipal const &   )  [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 99 of file StreamerOutputModuleBase.cc.

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

00099                                                         {
00100     start();
00101     std::auto_ptr<InitMsgBuilder>  init_message = serializeRegistry();
00102     doOutputHeader(*init_message);
00103   }

virtual void edm::StreamerOutputModuleBase::doOutputEvent ( EventMsgBuilder const &  msg  )  const [private, pure virtual]

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by write().

virtual void edm::StreamerOutputModuleBase::doOutputHeader ( InitMsgBuilder const &  init_message  )  const [private, pure virtual]

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by beginRun().

void edm::StreamerOutputModuleBase::endJob ( void   )  [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 114 of file StreamerOutputModuleBase.cc.

References stop().

00114                                    {
00115     stop();  // for closing of files, notify storage manager, etc.
00116   }

void edm::StreamerOutputModuleBase::endRun ( RunPrincipal const &   )  [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 106 of file StreamerOutputModuleBase.cc.

References stop().

00106                                                       {
00107     stop();
00108   }

std::auto_ptr< EventMsgBuilder > edm::StreamerOutputModuleBase::serializeEvent ( EventPrincipal const &  e  )  [private]

Definition at line 238 of file StreamerOutputModuleBase.cc.

References SerializeDataBuffer::bufferPointer(), SerializeDataBuffer::bufs_, compressionLevel_, edmNew::copy(), SerializeDataBuffer::currentEventSize(), SerializeDataBuffer::currentSpaceUsed(), edm::EventID::event(), hltbits_, hltsize_, edm::EventPrincipal::id(), l1bit_, lumi_, edm::EventPrincipal::luminosityBlock(), lumiSectionInterval_, alivecheck_mergeAndRegister::msg, origSize_, outputModuleId_, edm::EventID::run(), edm::StreamSerializer::serializeEvent(), serializer_, setHltMask(), setLumiSection(), HLT_VtxMuL3::src, and useCompression_.

Referenced by write().

00238                                                                   {
00239     //Lets Build the Event Message first 
00240 
00241     //Following is strictly DUMMY Data for L! Trig and will be replaced with actual
00242     // once figured out, there is no logic involved here.
00243     l1bit_.push_back(true);
00244     l1bit_.push_back(true);
00245     l1bit_.push_back(false);
00246     //End of dummy data
00247 
00248     setHltMask(e);
00249 
00250     if (lumiSectionInterval_ == 0) {
00251       lumi_ = e.luminosityBlock();
00252     } else {
00253       setLumiSection();
00254     }
00255 
00256     serializer_.serializeEvent(e, useCompression_, compressionLevel_, serialize_databuffer);
00257 
00258     // resize bufs_ to reflect space used in serializer_ + header
00259     // I just added an overhead for header of 50000 for now
00260     unsigned int src_size = serialize_databuffer.currentSpaceUsed();
00261     unsigned int new_size = src_size + 50000;
00262     if(serialize_databuffer.bufs_.size() < new_size) serialize_databuffer.bufs_.resize(new_size);
00263 
00264     std::auto_ptr<EventMsgBuilder> 
00265       msg(new EventMsgBuilder(&serialize_databuffer.bufs_[0], serialize_databuffer.bufs_.size(), e.id().run(),
00266                               e.id().event(), lumi_, outputModuleId_,
00267                               l1bit_, (uint8*)&hltbits_[0], hltsize_) );
00268     msg->setOrigDataSize(origSize_); // we need this set to zero
00269 
00270     // copy data into the destination message
00271     // an alternative is to have serializer only to the serialization
00272     // in serializeEvent, and then call a new member "getEventData" that
00273     // takes the compression arguments and a place to put the data.
00274     // This will require one less copy.  The only catch is that the
00275     // space provided in bufs_ should be at least the uncompressed 
00276     // size + overhead for header because we will not know the actual
00277     // compressed size.
00278 
00279     unsigned char* src = serialize_databuffer.bufferPointer();
00280     std::copy(src,src + src_size, msg->eventAddr());
00281     msg->setEventLength(src_size);
00282     if(useCompression_) msg->setOrigDataSize(serialize_databuffer.currentEventSize());
00283 
00284     l1bit_.clear();  //Clear up for the next event to come.
00285     return msg;
00286   }

std::auto_ptr< InitMsgBuilder > edm::StreamerOutputModuleBase::serializeRegistry (  )  [private]

Definition at line 131 of file StreamerOutputModuleBase.cc.

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

Referenced by beginRun().

00131                                               {
00132 
00133     serializer_.serializeRegistry(serialize_databuffer);
00134 
00135     // resize bufs_ to reflect space used in serializer_ + header
00136     // I just added an overhead for header of 50000 for now
00137     unsigned int src_size = serialize_databuffer.currentSpaceUsed();
00138     unsigned int new_size = src_size + 50000;
00139     if(serialize_databuffer.header_buf_.size() < new_size) serialize_databuffer.header_buf_.resize(new_size);
00140 
00141     //Build the INIT Message
00142     //Following values are strictly DUMMY and will be replaced
00143     // once available with Utility function etc.
00144     uint32 run = 1;
00145     
00146     //Get the Process PSet ID  
00147     pset::Registry* reg = pset::Registry::instance();
00148     ParameterSetID toplevel = pset::getProcessParameterSetID(reg);
00149 
00150     //In case we need to print it 
00151     //  cms::Digest dig(toplevel.compactForm());
00152     //  cms::MD5Result r1 = dig.digest();
00153     //  std::string hexy = r1.toString();
00154     //  std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl;  
00155 
00156     //Setting protocol version V
00157     Version v(7,(uint8*)toplevel.compactForm().c_str());
00158 
00159     Strings hltTriggerNames = getAllTriggerNames();
00160     hltsize_ = hltTriggerNames.size();
00161 
00162     //L1 stays dummy as of today
00163     Strings l1_names;  //3
00164     l1_names.push_back("t1");
00165     l1_names.push_back("t10");
00166     l1_names.push_back("t2");  
00167 
00168     //Setting the process name to HLT
00169     std::string processName = OutputModule::processName();
00170 
00171     std::string moduleLabel = description().moduleLabel();
00172     uLong crc = crc32(0L, Z_NULL, 0);
00173     Bytef* buf = (Bytef*) moduleLabel.data();
00174     crc = crc32(crc, buf, moduleLabel.length());
00175     outputModuleId_ = static_cast<uint32>(crc);
00176 
00177     std::auto_ptr<InitMsgBuilder> init_message(
00178         new InitMsgBuilder(&serialize_databuffer.header_buf_[0], serialize_databuffer.header_buf_.size(),
00179                            run, v, getReleaseVersion().c_str() , processName.c_str(),
00180                            moduleLabel.c_str(), outputModuleId_,
00181                            hltTriggerNames, hltTriggerSelections_, l1_names));
00182 
00183 
00184     // copy data into the destination message
00185 
00186     unsigned char* src = serialize_databuffer.bufferPointer();
00187     std::copy(src, src + src_size, init_message->dataAddress());
00188     init_message->setDataLength(src_size);
00189 
00190     return init_message;
00191   }

void edm::StreamerOutputModuleBase::setHltMask ( EventPrincipal const &  e  )  [private]

Definition at line 195 of file StreamerOutputModuleBase.cc.

References edm::OutputModule::getTriggerResults(), hltbits_, hltsize_, i, edm::Handle< T >::isValid(), packIntoString(), edm::hlt::Pass, and state.

Referenced by serializeEvent().

00195                                                               {
00196 
00197     hltbits_.clear();  // If there was something left over from last event
00198 
00199     Handle<TriggerResults> const& prod = getTriggerResults(e);
00200     //Trig const& prod = getTrigMask(e);
00201     std::vector<unsigned char> vHltState; 
00202     
00203     if (prod.isValid()) {
00204       for(std::vector<unsigned char>::size_type i=0; i != hltsize_ ; ++i) {
00205         vHltState.push_back(((prod->at(i)).state()));
00206       }
00207     } else {
00208      // We fill all Trigger bits to valid state.
00209      for(std::vector<unsigned char>::size_type i=0; i != hltsize_ ; ++i) {
00210            vHltState.push_back(hlt::Pass);
00211       }
00212     }
00213     
00214     //Pack into member hltbits_
00215     packIntoString(vHltState, hltbits_);
00216 
00217     //This is Just a printing code.
00218     //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl;
00219     //for(unsigned int i=0; i != hltbits_.size() ; ++i) {
00220     //  printBits(hltbits_[i]);
00221     //}
00222     //std::cout << "\n";
00223   }

void edm::StreamerOutputModuleBase::setLumiSection (  )  [private]

Definition at line 228 of file StreamerOutputModuleBase.cc.

References lumi_, lumiSectionInterval_, and timeInSecSinceUTC.

Referenced by serializeEvent().

00228                                            {
00229     struct timeval now;
00230     struct timezone dummyTZ;
00231     gettimeofday(&now, &dummyTZ);
00232     double timeInSec = static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec)/1000000.0) - timeInSecSinceUTC;
00233     // what about overflows?
00234     if(lumiSectionInterval_ > 0) lumi_ = static_cast<uint32>(timeInSec/lumiSectionInterval_) + 1;
00235   }

virtual void edm::StreamerOutputModuleBase::start (  )  const [private, pure virtual]

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by beginRun().

virtual void edm::StreamerOutputModuleBase::stop (  )  const [private, pure virtual]

Implemented in edm::StreamerOutputModule< Consumer >.

Referenced by endJob(), and endRun().

void edm::StreamerOutputModuleBase::write ( EventPrincipal const &  e  )  [private, virtual]

Implements edm::OutputModule.

Definition at line 125 of file StreamerOutputModuleBase.cc.

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

00125                                                          {
00126     std::auto_ptr<EventMsgBuilder> msg = serializeEvent(e);
00127     doOutputEvent(*msg); // You can't use msg in StreamerOutputModuleBase after this point
00128   }

void edm::StreamerOutputModuleBase::writeLuminosityBlock ( LuminosityBlockPrincipal const &   )  [private, virtual]

Implements edm::OutputModule.

Definition at line 122 of file StreamerOutputModuleBase.cc.

00122 {}

void edm::StreamerOutputModuleBase::writeRun ( RunPrincipal const &   )  [private, virtual]

Implements edm::OutputModule.

Definition at line 119 of file StreamerOutputModuleBase.cc.

00119 {}


Member Data Documentation

int edm::StreamerOutputModuleBase::compressionLevel_ [private]

Definition at line 43 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and StreamerOutputModuleBase().

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

Definition at line 55 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setHltMask().

unsigned int edm::StreamerOutputModuleBase::hltsize_ [private]

Definition at line 52 of file StreamerOutputModuleBase.h.

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

Strings edm::StreamerOutputModuleBase::hltTriggerSelections_ [private]

Definition at line 58 of file StreamerOutputModuleBase.h.

Referenced by serializeRegistry(), and StreamerOutputModuleBase().

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

Definition at line 54 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent().

uint32 edm::StreamerOutputModuleBase::lumi_ [private]

Definition at line 53 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setLumiSection().

int edm::StreamerOutputModuleBase::lumiSectionInterval_ [private]

Definition at line 46 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and setLumiSection().

int edm::StreamerOutputModuleBase::maxEventSize_ [private]

Definition at line 41 of file StreamerOutputModuleBase.h.

Referenced by StreamerOutputModuleBase().

uint32 edm::StreamerOutputModuleBase::origSize_ [private]

Definition at line 56 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent().

uint32 edm::StreamerOutputModuleBase::outputModuleId_ [private]

Definition at line 59 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and serializeRegistry().

Selections const* edm::StreamerOutputModuleBase::selections_ [private]

Definition at line 39 of file StreamerOutputModuleBase.h.

StreamSerializer edm::StreamerOutputModuleBase::serializer_ [private]

Definition at line 49 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and serializeRegistry().

double edm::StreamerOutputModuleBase::timeInSecSinceUTC [private]

Definition at line 47 of file StreamerOutputModuleBase.h.

Referenced by setLumiSection(), and StreamerOutputModuleBase().

bool edm::StreamerOutputModuleBase::useCompression_ [private]

Definition at line 42 of file StreamerOutputModuleBase.h.

Referenced by serializeEvent(), and StreamerOutputModuleBase().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:44:24 2009 for CMSSW by  doxygen 1.5.4