CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
edm::StreamerOutputModuleCommon Class Reference

#include <StreamerOutputModuleCommon.h>

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

Classes

struct  Parameters
 

Public Member Functions

SerializeDataBuffergetSerializerBuffer ()
 
std::unique_ptr< EventMsgBuilderserializeEvent (SerializeDataBuffer &sbuf, EventForOutput const &e, Handle< TriggerResults > const &triggerResults, ParameterSetID const &selectorCfg)
 
std::unique_ptr< InitMsgBuilderserializeRegistry (SerializeDataBuffer &sbuf, BranchIDLists const &branchLists, ThinnedAssociationsHelper const &helper, std::string const &processName, std::string const &moduleLabel, ParameterSetID const &toplevel, SendJobHeader::ParameterSetMap const *psetMap)
 
 StreamerOutputModuleCommon (Parameters const &p, SelectedProducts const *selections, std::string const &moduleLabel)
 
 StreamerOutputModuleCommon (ParameterSet const &ps, SelectedProducts const *selections, std::string const &moduleLabel)
 
 ~StreamerOutputModuleCommon ()
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 
static Parameters parameters (ParameterSet const &ps)
 

Protected Attributes

std::unique_ptr< SerializeDataBufferserializerBuffer_
 

Private Member Functions

void setHltMask (EventForOutput const &e, Handle< TriggerResults > const &triggerResults, std::vector< unsigned char > &hltbits) const
 

Private Attributes

StreamerCompressionAlgo compressionAlgo_
 
std::string compressionAlgoStr_
 
int compressionLevel_
 
unsigned int hltsize_
 
Strings hltTriggerSelections_
 
char host_name_ [255]
 
int lumiSectionInterval_
 
int maxEventSize_
 
uint32 outputModuleId_
 
StreamSerializer serializer_
 
double timeInSecSinceUTC
 
bool useCompression_
 

Detailed Description

Definition at line 21 of file StreamerOutputModuleCommon.h.

Constructor & Destructor Documentation

◆ StreamerOutputModuleCommon() [1/2]

edm::StreamerOutputModuleCommon::StreamerOutputModuleCommon ( Parameters const &  p,
SelectedProducts const *  selections,
std::string const &  moduleLabel 
)
explicit

Definition at line 36 of file StreamerOutputModuleCommon.cc.

References visDQMUpload::buf, compressionAlgo_, compressionAlgoStr_, compressionLevel_, Exception, FDEBUG, edm::getAllTriggerNames(), hltsize_, hltTriggerSelections_, host_name_, dttmaxenums::L, edm::LZMA, HerwigMaxPtPartonFilter_cfi::moduleLabel, submitPVValidationJobs::now, outputModuleId_, AlCaHLTBitMon_ParallelJobs::p, timeInSecSinceUTC, edm::UNCOMPRESSED, useCompression_, edm::ZLIB, and edm::ZSTD.

39  :
40 
42  useCompression_(p.useCompression),
43  compressionAlgoStr_(p.compressionAlgoStr),
44  compressionLevel_(p.compressionLevel),
45  lumiSectionInterval_(p.lumiSectionInterval),
46  hltsize_(0),
47  host_name_(),
49  outputModuleId_(0) {
50  //limits initially set for default ZLIB option
51  int minCompressionLevel = 1;
52  int maxCompressionLevel = 9;
53 
54  // test luminosity sections
55  struct timeval now;
56  struct timezone dummyTZ;
57  gettimeofday(&now, &dummyTZ);
58  timeInSecSinceUTC = static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec) / 1000000.0);
59 
60  if (useCompression_ == true) {
61  if (compressionAlgoStr_ == "ZLIB") {
63  } else if (compressionAlgoStr_ == "LZMA") {
65  minCompressionLevel = 0;
66  } else if (compressionAlgoStr_ == "ZSTD") {
68  maxCompressionLevel = 20;
69  } else if (compressionAlgoStr_ == "UNCOMPRESSED") {
71  useCompression_ = false;
73  } else
74  throw cms::Exception("StreamerOutputModuleCommon", "Compression type unknown")
75  << "Unknown compression algorithm " << compressionAlgoStr_;
76 
77  if (compressionLevel_ < minCompressionLevel) {
78  FDEBUG(9) << "Compression Level = " << compressionLevel_ << " no compression" << std::endl;
80  useCompression_ = false;
82  } else if (compressionLevel_ > maxCompressionLevel) {
83  FDEBUG(9) << "Compression Level = " << compressionLevel_ << " using max compression level "
84  << maxCompressionLevel << std::endl;
85  compressionLevel_ = maxCompressionLevel;
87  }
88  } else
90 
91  int got_host = gethostname(host_name_, 255);
92  if (got_host != 0)
93  strncpy(host_name_, "noHostNameFoundOrTooLong", sizeof(host_name_));
94  //loadExtraClasses();
95 
96  // 25-Jan-2008, KAB - pull out the trigger selection request
97  // which we need for the INIT message
98  hltTriggerSelections_ = p.hltTriggerSelections;
99 
100  Strings const& hltTriggerNames = edm::getAllTriggerNames();
101  hltsize_ = hltTriggerNames.size();
102 
103  //Checksum of the module label
104  uLong crc = crc32(0L, Z_NULL, 0);
105  Bytef const* buf = (Bytef const*)(moduleLabel.data());
106  crc = crc32(crc, buf, moduleLabel.length());
107  outputModuleId_ = static_cast<uint32>(crc);
108  }
std::vector< std::string > const & getAllTriggerNames()
std::vector< std::string > Strings
Definition: MsgTools.h:18
#define FDEBUG(lev)
Definition: DebugMacros.h:19
unsigned int uint32
Definition: MsgTools.h:13

◆ StreamerOutputModuleCommon() [2/2]

edm::StreamerOutputModuleCommon::StreamerOutputModuleCommon ( ParameterSet const &  ps,
SelectedProducts const *  selections,
std::string const &  moduleLabel 
)
inlineexplicit

Definition at line 37 of file StreamerOutputModuleCommon.h.

static Parameters parameters(ParameterSet const &ps)
StreamerOutputModuleCommon(Parameters const &p, SelectedProducts const *selections, std::string const &moduleLabel)

◆ ~StreamerOutputModuleCommon()

edm::StreamerOutputModuleCommon::~StreamerOutputModuleCommon ( )

Definition at line 110 of file StreamerOutputModuleCommon.cc.

110 {}

Member Function Documentation

◆ fillDescription()

void edm::StreamerOutputModuleCommon::fillDescription ( ParameterSetDescription desc)
static

Definition at line 282 of file StreamerOutputModuleCommon.cc.

References submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::StreamerOutputModuleBase::fillDescription(), and evf::GlobalEvFOutputModule::fillDescriptions().

282  {
283  desc.addUntracked<int>("max_event_size", 7000000)->setComment("Obsolete parameter.");
284  desc.addUntracked<bool>("use_compression", true)
285  ->setComment("If True, compression will be used to write streamer file.");
286  desc.addUntracked<std::string>("compression_algorithm", "ZLIB")
287  ->setComment("Compression algorithm to use: UNCOMPRESSED, ZLIB, LZMA or ZSTD");
288  desc.addUntracked<int>("compression_level", 1)->setComment("Compression level to use on serialized ROOT events");
289  desc.addUntracked<int>("lumiSection_interval", 0)
290  ->setComment(
291  "If 0, use lumi section number from event.\n"
292  "If not 0, the interval in seconds between fake lumi sections.");
293  }

◆ getSerializerBuffer()

SerializeDataBuffer * edm::StreamerOutputModuleCommon::getSerializerBuffer ( )

Definition at line 295 of file StreamerOutputModuleCommon.cc.

References serializerBuffer_.

Referenced by edm::StreamerOutputModuleBase::beginRun(), evf::GlobalEvFOutputModule::globalBeginRun(), and edm::StreamerOutputModuleBase::write().

295  {
296  auto* ptr = serializerBuffer_.get();
297  if (!ptr) {
298  serializerBuffer_ = std::make_unique<SerializeDataBuffer>();
299  ptr = serializerBuffer_.get();
300  }
301  return ptr;
302  }
std::unique_ptr< SerializeDataBuffer > serializerBuffer_

◆ parameters()

StreamerOutputModuleCommon::Parameters edm::StreamerOutputModuleCommon::parameters ( ParameterSet const &  ps)
static

Definition at line 26 of file StreamerOutputModuleCommon.cc.

References edm::EventSelector::getEventSelectionVString(), edm::ParameterSet::getUntrackedParameter(), runTheMatrix::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

26  {
28  ret.hltTriggerSelections = EventSelector::getEventSelectionVString(ps);
29  ret.compressionAlgoStr = ps.getUntrackedParameter<std::string>("compression_algorithm");
30  ret.compressionLevel = ps.getUntrackedParameter<int>("compression_level");
31  ret.lumiSectionInterval = ps.getUntrackedParameter<int>("lumiSection_interval");
32  ret.useCompression = ps.getUntrackedParameter<bool>("use_compression");
33  return ret;
34  }
ret
prodAgent to be discontinued
static std::vector< std::string > getEventSelectionVString(edm::ParameterSet const &pset)
std::vector< AlignmentParameters * > Parameters
Definition: Utilities.h:32

◆ serializeEvent()

std::unique_ptr< EventMsgBuilder > edm::StreamerOutputModuleCommon::serializeEvent ( SerializeDataBuffer sbuf,
EventForOutput const &  e,
Handle< TriggerResults > const &  triggerResults,
ParameterSetID const &  selectorCfg 
)

Definition at line 214 of file StreamerOutputModuleCommon.cc.

References funct::abs(), SerializeDataBuffer::adler32_chksum(), SerializeDataBuffer::bufferPointer(), SerializeDataBuffer::comp_buf_, compressionAlgo_, compressionLevel_, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), filterCSVwithJSON::copy, SerializeDataBuffer::currentEventSize(), SerializeDataBuffer::currentSpaceUsed(), MillePedeFileConverter_cfg::e, Exception, SerializeDataBuffer::header_buf_, hltsize_, host_name_, BXlumiParameters_cfi::lumi, lumiSectionInterval_, mps_check::msg, submitPVValidationJobs::now, outputModuleId_, SerializeDataBuffer::reserve_size, edm::StreamSerializer::serializeEvent(), serializer_, setHltMask(), timeInSecSinceUTC, edm::triggerResults(), and useCompression_.

Referenced by edm::StreamerOutputModuleBase::write().

218  {
219  constexpr unsigned int reserve_size = SerializeDataBuffer::reserve_size;
220  //Lets Build the Event Message first
221 
222  //Following is strictly DUMMY Data for L! Trig and will be replaced with actual
223  // once figured out, there is no logic involved here.
224  std::vector<bool> l1bit = {true, true, false};
225  //End of dummy data
226 
227  std::vector<unsigned char> hltbits;
228  setHltMask(e, triggerResults, hltbits);
229 
230  uint32 lumi = e.luminosityBlock();
231  if (lumiSectionInterval_ != 0) {
232  struct timeval now;
233  struct timezone dummyTZ;
234  gettimeofday(&now, &dummyTZ);
235  double timeInSec =
236  static_cast<double>(now.tv_sec) + (static_cast<double>(now.tv_usec) / 1000000.0) - timeInSecSinceUTC;
237  // what about overflows?
238  lumi = static_cast<uint32>(timeInSec / std::abs(lumiSectionInterval_)) + 1;
239  }
240 
241  serializer_.serializeEvent(sbuf, e, selectorCfg, compressionAlgo_, compressionLevel_, reserve_size);
242 
243  // resize header_buf_ to reserved size on first written event
244  if (sbuf.header_buf_.size() < reserve_size)
245  sbuf.header_buf_.resize(reserve_size);
246 
247  auto msg = std::make_unique<EventMsgBuilder>(&sbuf.header_buf_[0],
248  sbuf.comp_buf_.size(),
249  e.id().run(),
250  e.id().event(),
251  lumi,
253  0,
254  l1bit,
255  (uint8*)&hltbits[0],
256  hltsize_,
257  (uint32)sbuf.adler32_chksum(),
258  host_name_);
259 
260  // 50000 bytes is reserved for header as has been the case with previous version which did one extra copy of event data
261  uint32 headerSize = msg->headerSize();
262  if (headerSize > reserve_size)
263  throw cms::Exception("StreamerOutputModuleCommon", "Header Overflow")
264  << " header of size " << headerSize << "bytes is too big to fit into the reserved buffer space";
265 
266  //set addresses to other buffer and copy constructed header there
267  msg->setBufAddr(&sbuf.comp_buf_[reserve_size - headerSize]);
268  msg->setEventAddr(sbuf.bufferPointer());
269  std::copy(&sbuf.header_buf_[0], &sbuf.header_buf_[headerSize], (char*)(&sbuf.comp_buf_[reserve_size - headerSize]));
270 
271  unsigned int src_size = sbuf.currentSpaceUsed();
272  msg->setEventLength(src_size); //compressed size
273  if (useCompression_)
274  msg->setOrigDataSize(
275  sbuf.currentEventSize()); //uncompressed size (or 0 if no compression -> streamer input source requires this)
276  else
277  msg->setOrigDataSize(0);
278 
279  return msg;
280  }
unsigned int currentEventSize() const
void setHltMask(EventForOutput const &e, Handle< TriggerResults > const &triggerResults, std::vector< unsigned char > &hltbits) const
std::vector< unsigned char > comp_buf_
int serializeEvent(SerializeDataBuffer &data_buffer, EventForOutput const &event, ParameterSetID const &selectorConfig, StreamerCompressionAlgo compressionAlgo, int compression_level, unsigned int reserveSize) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned char const * bufferPointer() const
unsigned int uint32
Definition: MsgTools.h:13
unsigned int currentSpaceUsed() const
uint32_t adler32_chksum() const
static std::string const triggerResults("TriggerResults")
tuple msg
Definition: mps_check.py:286
unsigned char uint8
Definition: MsgTools.h:11
static constexpr unsigned int reserve_size

◆ serializeRegistry()

std::unique_ptr< InitMsgBuilder > edm::StreamerOutputModuleCommon::serializeRegistry ( SerializeDataBuffer sbuf,
BranchIDLists const &  branchLists,
ThinnedAssociationsHelper const &  helper,
std::string const &  processName,
std::string const &  moduleLabel,
ParameterSetID const &  toplevel,
SendJobHeader::ParameterSetMap const *  psetMap 
)

Definition at line 112 of file StreamerOutputModuleCommon.cc.

References SerializeDataBuffer::adler32_chksum(), SerializeDataBuffer::bufferPointer(), edm::Hash< I >::compactForm(), filterCSVwithJSON::copy, SerializeDataBuffer::currentSpaceUsed(), edm::getAllTriggerNames(), edm::getReleaseVersion(), SerializeDataBuffer::header_buf_, hltTriggerSelections_, HerwigMaxPtPartonFilter_cfi::moduleLabel, outputModuleId_, SimL1EmulatorRepack_CalouGT_cff::processName, writedatasetfile::run, serializer_, edm::StreamSerializer::serializeRegistry(), and TrackRefitter_38T_cff::src.

Referenced by edm::StreamerOutputModuleBase::beginRun(), and evf::GlobalEvFOutputModule::globalBeginRun().

119  {
120  if (psetMap) {
121  serializer_.serializeRegistry(sbuf, branchLists, helper, *psetMap);
122  } else {
123  serializer_.serializeRegistry(sbuf, branchLists, helper);
124  }
125  // resize header_buf_ to reflect space used in serializer_ + header
126  // I just added an overhead for header of 50000 for now
127  unsigned int src_size = sbuf.currentSpaceUsed();
128  unsigned int new_size = src_size + 50000;
129  if (sbuf.header_buf_.size() < new_size)
130  sbuf.header_buf_.resize(new_size);
131 
132  //Build the INIT Message
133  //Following values are strictly DUMMY and will be replaced
134  // once available with Utility function etc.
135  uint32 run = 1;
136 
137  //Get the Process PSet ID
138 
139  //In case we need to print it
140  // cms::Digest dig(toplevel.compactForm());
141  // cms::MD5Result r1 = dig.digest();
142  // std::string hexy = r1.toString();
143  // std::cout << "HEX Representation of Process PSetID: " << hexy << std::endl;
144 
145  //L1 stays dummy as of today
146  Strings l1_names; //3
147  l1_names.push_back("t1");
148  l1_names.push_back("t10");
149  l1_names.push_back("t2");
150 
151  Strings const& hltTriggerNames = edm::getAllTriggerNames();
152 
153  auto init_message = std::make_unique<InitMsgBuilder>(&sbuf.header_buf_[0],
154  sbuf.header_buf_.size(),
155  run,
156  Version((uint8 const*)toplevel.compactForm().c_str()),
157  getReleaseVersion().c_str(),
158  processName.c_str(),
159  moduleLabel.c_str(),
161  hltTriggerNames,
163  l1_names,
164  (uint32)sbuf.adler32_chksum());
165 
166  // copy data into the destination message
167  unsigned char* src = sbuf.bufferPointer();
168  std::copy(src, src + src_size, init_message->dataAddress());
169  init_message->setDataLength(src_size);
170  return init_message;
171  }
Definition: helper.py:1
std::vector< std::string > const & getAllTriggerNames()
std::vector< std::string > Strings
Definition: MsgTools.h:18
int serializeRegistry(SerializeDataBuffer &data_buffer, const BranchIDLists &branchIDLists, ThinnedAssociationsHelper const &thinnedAssociationsHelper)
unsigned char const * bufferPointer() const
unsigned int uint32
Definition: MsgTools.h:13
unsigned int currentSpaceUsed() const
uint32_t adler32_chksum() const
std::string getReleaseVersion()
unsigned char uint8
Definition: MsgTools.h:11

◆ setHltMask()

void edm::StreamerOutputModuleCommon::setHltMask ( EventForOutput const &  e,
Handle< TriggerResults > const &  triggerResults,
std::vector< unsigned char > &  hltbits 
) const
private

Definition at line 173 of file StreamerOutputModuleCommon.cc.

References ntuplemaker::fill, hltsize_, mps_fire::i, edm::hlt::Pass, and edm::triggerResults().

Referenced by serializeEvent().

175  {
176  hltbits.clear();
177 
178  std::vector<unsigned char> vHltState;
179 
180  if (triggerResults.isValid()) {
182  vHltState.push_back(((triggerResults->at(i)).state()));
183  }
184  } else {
185  // We fill all Trigger bits to valid state.
187  vHltState.push_back(hlt::Pass);
188  }
189  }
190 
191  //Pack into member hltbits
192  if (!vHltState.empty()) {
193  unsigned int packInOneByte = 4;
194  unsigned int sizeOfPackage = 1 + ((vHltState.size() - 1) / packInOneByte); //Two bits per HLT
195 
196  hltbits.resize(sizeOfPackage);
197  std::fill(hltbits.begin(), hltbits.end(), 0);
198 
199  for (std::vector<unsigned char>::size_type i = 0; i != vHltState.size(); ++i) {
200  unsigned int whichByte = i / packInOneByte;
201  unsigned int indxWithinByte = i % packInOneByte;
202  hltbits[whichByte] = hltbits[whichByte] | (vHltState[i] << (indxWithinByte * 2));
203  }
204  }
205 
206  //This is Just a printing code.
207  //std::cout << "Size of hltbits:" << hltbits_.size() << std::endl;
208  //for(unsigned int i=0; i != hltbits_.size() ; ++i) {
209  // printBits(hltbits_[i]);
210  //}
211  //std::cout << "\n";
212  }
uint16_t size_type
accept
Definition: HLTenums.h:18
static std::string const triggerResults("TriggerResults")

Member Data Documentation

◆ compressionAlgo_

StreamerCompressionAlgo edm::StreamerOutputModuleCommon::compressionAlgo_
private

Definition at line 75 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and StreamerOutputModuleCommon().

◆ compressionAlgoStr_

std::string edm::StreamerOutputModuleCommon::compressionAlgoStr_
private

Definition at line 72 of file StreamerOutputModuleCommon.h.

Referenced by StreamerOutputModuleCommon().

◆ compressionLevel_

int edm::StreamerOutputModuleCommon::compressionLevel_
private

Definition at line 73 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and StreamerOutputModuleCommon().

◆ hltsize_

unsigned int edm::StreamerOutputModuleCommon::hltsize_
private

◆ hltTriggerSelections_

Strings edm::StreamerOutputModuleCommon::hltTriggerSelections_
private

Definition at line 84 of file StreamerOutputModuleCommon.h.

Referenced by serializeRegistry(), and StreamerOutputModuleCommon().

◆ host_name_

char edm::StreamerOutputModuleCommon::host_name_[255]
private

Definition at line 82 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and StreamerOutputModuleCommon().

◆ lumiSectionInterval_

int edm::StreamerOutputModuleCommon::lumiSectionInterval_
private

Definition at line 78 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent().

◆ maxEventSize_

int edm::StreamerOutputModuleCommon::maxEventSize_
private

Definition at line 70 of file StreamerOutputModuleCommon.h.

◆ outputModuleId_

uint32 edm::StreamerOutputModuleCommon::outputModuleId_
private

◆ serializer_

StreamSerializer edm::StreamerOutputModuleCommon::serializer_
private

Definition at line 68 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and serializeRegistry().

◆ serializerBuffer_

std::unique_ptr<SerializeDataBuffer> edm::StreamerOutputModuleCommon::serializerBuffer_
protected

◆ timeInSecSinceUTC

double edm::StreamerOutputModuleCommon::timeInSecSinceUTC
private

Definition at line 79 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and StreamerOutputModuleCommon().

◆ useCompression_

bool edm::StreamerOutputModuleCommon::useCompression_
private

Definition at line 71 of file StreamerOutputModuleCommon.h.

Referenced by serializeEvent(), and StreamerOutputModuleCommon().