CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
evf::EvFOutputModule Class Reference

#include <EvFOutputModule.h>

Inheritance diagram for evf::EvFOutputModule:
edm::one::OutputModule< T > edm::one::OutputModuleBase edm::EDConsumerBase

Public Member Functions

 EvFOutputModule (edm::ParameterSet const &ps)
 
 ~EvFOutputModule () override
 
- Public Member Functions inherited from edm::one::OutputModule< T >
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 (ParameterSet const &pset)
 
 OutputModuleBase (OutputModuleBase const &)=delete
 
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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)
 

Static Public Member Functions

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

Private Member Functions

void beginRun (edm::RunForOutput const &run) override
 
void endRun (edm::RunForOutput const &) override
 
Trig getTriggerResults (edm::EDGetTokenT< edm::TriggerResults > const &token, edm::EventForOutput const &e) const
 
std::shared_ptr< EvFOutputEventWriterglobalBeginLuminosityBlock (edm::LuminosityBlockForOutput const &iLB) const override
 
void globalEndLuminosityBlock (edm::LuminosityBlockForOutput const &iLB) override
 
void write (edm::EventForOutput const &e) override
 
void writeLuminosityBlock (edm::LuminosityBlockForOutput const &) override
 
void writeRun (edm::RunForOutput const &) override
 

Private Attributes

evf::FastMonitoringServicefms_
 
std::unique_ptr< evf::EvFOutputJSONWriterjsonWriter_
 
edm::ParameterSet const & ps_
 
std::string streamLabel_
 
edm::EDGetTokenT< edm::TriggerResultstrToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::OutputModuleBase
typedef OutputModuleBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 83 of file EvFOutputModule.h.

Constructor & Destructor Documentation

evf::EvFOutputModule::EvFOutputModule ( edm::ParameterSet const &  ps)
explicit

Definition at line 105 of file EvFOutputModule.cc.

References Exception, fms_, streamLabel_, and AlCaHLTBitMon_QueryRunRegistry::string.

105  :
108  ps_(ps),
109  streamLabel_(ps.getParameter<std::string>("@module_label")),
110  trToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults")))
111  {
112  //replace hltOutoputA with stream if the HLT menu uses this convention
113  std::string testPrefix="hltOutput";
114  if (streamLabel_.find(testPrefix)==0)
115  streamLabel_=std::string("stream")+streamLabel_.substr(testPrefix.size());
116 
117  if (streamLabel_.find("_")!=std::string::npos) {
118  throw cms::Exception("EvFOutputModule")
119  << "Underscore character is reserved can not be used for stream names in FFF, but was detected in stream name -: " << streamLabel_;
120  }
121 
122  std::string streamLabelLow = streamLabel_;
123  boost::algorithm::to_lower(streamLabelLow);
124  auto streampos = streamLabelLow.rfind("stream");
125  if (streampos !=0 && streampos!=std::string::npos)
126  throw cms::Exception("EvFOutputModule")
127  << "stream (case-insensitive) sequence was found in stream suffix. This is reserved and can not be used for names in FFF based HLT, but was detected in stream name";
128 
130  }
edm::ParameterSet const & ps_
edm::EDGetTokenT< edm::TriggerResults > trToken_
edm::one::OutputModule< edm::one::WatchRuns, edm::LuminosityBlockCache< evf::EvFOutputEventWriter > > EvFOutputModuleType
evf::FastMonitoringService * fms_
evf::EvFOutputModule::~EvFOutputModule ( )
override

Definition at line 133 of file EvFOutputModule.cc.

133 {}

Member Function Documentation

void evf::EvFOutputModule::beginRun ( edm::RunForOutput const &  run)
overrideprivate

Definition at line 145 of file EvFOutputModule.cc.

References cms::Adler32(), StreamerOutputFile::adler32(), edm::one::OutputModuleBase::branchIDLists(), StreamerOutputFile::close(), edm::one::OutputModuleBase::description(), Exception, edm::InEvent, jsonWriter_, edm::one::OutputModuleBase::keptProducts(), LogDebug, edm::one::OutputModuleBase::moduleDescription(), modifiedElectrons_cfi::processName, ps_, TrackRefitter_38T_cff::src, trackingPlots::stat, streamLabel_, AlCaHLTBitMon_QueryRunRegistry::string, edm::one::OutputModuleBase::thinnedAssociationsHelper(), and StreamerOutputFile::write().

146  {
147  //create run Cache holding JSON file writer and variables
148  jsonWriter_ = std::make_unique<EvFOutputJSONWriter>(ps_,&keptProducts()[edm::InEvent],streamLabel_);
149 
150  //output INI file (non-const). This doesn't require globalBeginRun to be finished
151  const std::string openIniFileName = edm::Service<evf::EvFDaqDirector>()->getOpenInitFilePath(streamLabel_);
152  edm::LogInfo("EvFOutputModule") << "beginRun init stream -: " << openIniFileName;
153 
154  StreamerOutputFile stream_writer_preamble(openIniFileName);
155  uint32 preamble_adler32 = 1;
156  edm::BranchIDLists const* bidlPtr = branchIDLists();
157 
158  std::unique_ptr<InitMsgBuilder> init_message =
159  jsonWriter_->streamerCommon_.serializeRegistry(*bidlPtr, *thinnedAssociationsHelper(),
160  OutputModule::processName(), description().moduleLabel(), moduleDescription().mainParameterSetID());
161 
162  //Let us turn it into a View
163  InitMsgView view(init_message->startAddress());
164 
165  //output header
166  stream_writer_preamble.write(view);
167  preamble_adler32 = stream_writer_preamble.adler32();
168  stream_writer_preamble.close();
169 
170  struct stat istat;
171  stat(openIniFileName.c_str(), &istat);
172  //read back file to check integrity of what was written
173  off_t readInput=0;
174  uint32_t adlera=1,adlerb=0;
175  FILE *src = fopen(openIniFileName.c_str(),"r");
176 
177  //allocate buffer to write INI file
178  unsigned char * outBuf = new unsigned char[1024*1024];
179  while (readInput<istat.st_size)
180  {
181  size_t toRead= readInput+1024*1024 < istat.st_size ? 1024*1024 : istat.st_size-readInput;
182  fread(outBuf,toRead,1,src);
183  cms::Adler32((const char*)outBuf,toRead,adlera,adlerb);
184  readInput+=toRead;
185  }
186  fclose(src);
187 
188  //clear serialization buffers
189  jsonWriter_->streamerCommon_.clearSerializeDataBuffer();
190 
191  //free output buffer needed only for the file write
192  delete [] outBuf;
193  outBuf=nullptr;
194 
195  uint32_t adler32c = (adlerb << 16) | adlera;
196  if (adler32c != preamble_adler32) {
197  throw cms::Exception("EvFOutputModule") << "Checksum mismatch of ini file -: " << openIniFileName
198  << " expected:" << preamble_adler32 << " obtained:" << adler32c;
199  }
200  else {
201  LogDebug("EvFOutputModule") << "Ini file checksum -: "<< streamLabel_ << " " << adler32c;
202  boost::filesystem::rename(openIniFileName,edm::Service<evf::EvFDaqDirector>()->getInitFilePath(streamLabel_));
203  }
204 
205  }
#define LogDebug(id)
std::unique_ptr< evf::EvFOutputJSONWriter > jsonWriter_
ModuleDescription const & description() const
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
edm::ParameterSet const & ps_
ThinnedAssociationsHelper const * thinnedAssociationsHelper() const
SelectedProductsForBranchType const & keptProducts() const
unsigned int uint32
Definition: MsgTools.h:13
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
const ModuleDescription & moduleDescription() const
BranchIDLists const * branchIDLists()
void evf::EvFOutputModule::endRun ( edm::RunForOutput const &  )
inlineoverrideprivate

Definition at line 98 of file EvFOutputModule.h.

References dqmoffline::l1t::getTriggerResults().

98 {}
void evf::EvFOutputModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static
Trig evf::EvFOutputModule::getTriggerResults ( edm::EDGetTokenT< edm::TriggerResults > const &  token,
edm::EventForOutput const &  e 
) const
private
std::shared_ptr< EvFOutputEventWriter > evf::EvFOutputModule::globalBeginLuminosityBlock ( edm::LuminosityBlockForOutput const &  iLB) const
overrideprivate

Definition at line 217 of file EvFOutputModule.cc.

References edm::LuminosityBlockForOutput::luminosityBlock(), and streamLabel_.

218  {
219  auto openDatFilePath = edm::Service<evf::EvFDaqDirector>()->getOpenDatFilePath(iLB.luminosityBlock(),streamLabel_);
220 
221  return std::make_shared<EvFOutputEventWriter>(openDatFilePath);
222  }
void evf::EvFOutputModule::globalEndLuminosityBlock ( edm::LuminosityBlockForOutput const &  iLB)
overrideprivate

Definition at line 240 of file EvFOutputModule.cc.

References fms_, evf::FastMonitoringService::getEventsProcessedForLumi(), edm::LuminosityBlockForOutput::index(), jsonWriter_, edm::LuminosityBlockForOutput::luminosityBlock(), callgraph::path, trackingPlots::stat, streamLabel_, and AlCaHLTBitMon_QueryRunRegistry::string.

241  {
242  auto lumiWriter = luminosityBlockCache(iLB.index());
243  //close dat file
244  lumiWriter->close();
245 
246  jsonWriter_->fileAdler32_.value() = lumiWriter->get_adler32();
247  jsonWriter_->accepted_.value() = lumiWriter->getAccepted();
248 
249  bool abortFlag = false;
250  jsonWriter_->processed_.value() = fms_->getEventsProcessedForLumi(iLB.luminosityBlock(),&abortFlag);
251  if (abortFlag) {
252  edm::LogInfo("EvFOutputModule") << "Abort flag has been set. Output is suppressed";
253  return;
254  }
255 
256  if (jsonWriter_->processed_.value()!=0) {
257  struct stat istat;
258  boost::filesystem::path openDatFilePath = lumiWriter->getFilePath();
259  stat(openDatFilePath.string().c_str(), &istat);
260  jsonWriter_->filesize_ = istat.st_size;
261  boost::filesystem::rename(openDatFilePath.string().c_str(), edm::Service<evf::EvFDaqDirector>()->getDatFilePath(iLB.luminosityBlock(),streamLabel_));
262  jsonWriter_->filelist_ = openDatFilePath.filename().string();
263  } else {
264  //remove empty file when no event processing has occurred
265  remove(lumiWriter->getFilePath().c_str());
266  jsonWriter_->filesize_ = 0;
267  jsonWriter_->filelist_ = "";
268  jsonWriter_->fileAdler32_.value()=-1; //no files in signed long
269  }
270 
271  //produce JSON file
272  jsonWriter_->jsonMonitor_->snap(iLB.luminosityBlock());
273  const std::string outputJsonNameStream =
274  edm::Service<evf::EvFDaqDirector>()->getOutputJsonFilePath(iLB.luminosityBlock(),streamLabel_);
275  jsonWriter_->jsonMonitor_->outputFullJSON(outputJsonNameStream,iLB.luminosityBlock());
276 
277  }
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
std::unique_ptr< evf::EvFOutputJSONWriter > jsonWriter_
evf::FastMonitoringService * fms_
void evf::EvFOutputModule::write ( edm::EventForOutput const &  e)
overrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 226 of file EvFOutputModule.cc.

References edm::EventForOutput::getLuminosityBlock(), getTriggerResults(), edm::LuminosityBlockForOutput::index(), jsonWriter_, mps_check::msg, edm::one::OutputModuleBase::selectorConfig(), triggerResults, and trToken_.

Referenced by pkg.AbstractPkg::generate().

226  {
227 
229 
230  //auto lumiWriter = const_cast<EvFOutputEventWriter*>(luminosityBlockCache(e.getLuminosityBlock().index() ));
231  auto lumiWriter = luminosityBlockCache(e.getLuminosityBlock().index() );
232 
233  std::unique_ptr<EventMsgBuilder> msg = jsonWriter_->streamerCommon_.serializeEvent(e, triggerResults, selectorConfig());
234  lumiWriter->incAccepted();
235  lumiWriter->doOutputEvent(*msg); //msg is written and discarded at this point
236  }
std::unique_ptr< evf::EvFOutputJSONWriter > jsonWriter_
ParameterSetID selectorConfig() const
static std::string const triggerResults
Definition: EdmProvDump.cc:45
edm::EDGetTokenT< edm::TriggerResults > trToken_
tuple msg
Definition: mps_check.py:285
Trig getTriggerResults(edm::EDGetTokenT< edm::TriggerResults > const &token, edm::EventForOutput const &e) const
void evf::EvFOutputModule::writeLuminosityBlock ( edm::LuminosityBlockForOutput const &  )
inlineoverrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 96 of file EvFOutputModule.h.

96 {}
void evf::EvFOutputModule::writeRun ( edm::RunForOutput const &  )
inlineoverrideprivatevirtual

Implements edm::one::OutputModuleBase.

Definition at line 97 of file EvFOutputModule.h.

97 {}

Member Data Documentation

evf::FastMonitoringService* evf::EvFOutputModule::fms_
private

Definition at line 109 of file EvFOutputModule.h.

Referenced by EvFOutputModule(), and globalEndLuminosityBlock().

std::unique_ptr<evf::EvFOutputJSONWriter> evf::EvFOutputModule::jsonWriter_
private

Definition at line 111 of file EvFOutputModule.h.

Referenced by beginRun(), globalEndLuminosityBlock(), and write().

edm::ParameterSet const& evf::EvFOutputModule::ps_
private

Definition at line 105 of file EvFOutputModule.h.

Referenced by beginRun().

std::string evf::EvFOutputModule::streamLabel_
private
edm::EDGetTokenT<edm::TriggerResults> evf::EvFOutputModule::trToken_
private

Definition at line 107 of file EvFOutputModule.h.

Referenced by write().