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
evf::RecoEventOutputModuleForFU< Consumer > Class Template Reference

#include <RecoEventOutputModuleForFU.h>

Inheritance diagram for evf::RecoEventOutputModuleForFU< Consumer >:
edm::StreamerOutputModuleBase edm::OutputModule edm::EDConsumerBase

Public Member Functions

 RecoEventOutputModuleForFU (edm::ParameterSet const &ps)
 
virtual ~RecoEventOutputModuleForFU ()
 
- Public Member Functions inherited from edm::StreamerOutputModuleBase
 StreamerOutputModuleBase (ParameterSet const &ps)
 
virtual ~StreamerOutputModuleBase ()
 
- 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)
 
bool wantAllEvents () const
 
virtual ~OutputModule ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::StreamerOutputModuleBase
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)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void doOutputEvent (EventMsgBuilder const &msg) const
 
virtual void doOutputHeader (InitMsgBuilder const &init_message) const
 
virtual void endLuminosityBlock (edm::LuminosityBlockPrincipal const &, edm::ModuleCallingContext const *)
 
virtual void start () const
 
virtual void stop () const
 

Private Attributes

IntJ accepted_
 
std::auto_ptr< Consumer > c_
 
IntJ errorEvents_
 
StringJ filelist_
 
IntJ filesize_
 
evf::FastMonitoringServicefms_
 
StringJ inputFiles_
 
boost::shared_ptr< FastMonitorjsonMonitor_
 
boost::filesystem::path openDatFilePath_
 
DataPointDefinition outJsonDef_
 
IntJ processed_
 
IntJ retCodeMask_
 
std::string stream_label_
 

Additional Inherited Members

- Public Types inherited from edm::OutputModule
typedef OutputModule ModuleType
 
- 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<typename Consumer>
class evf::RecoEventOutputModuleForFU< Consumer >

Definition at line 22 of file RecoEventOutputModuleForFU.h.

Constructor & Destructor Documentation

template<typename Consumer >
evf::RecoEventOutputModuleForFU< Consumer >::RecoEventOutputModuleForFU ( edm::ParameterSet const &  ps)
explicit
Consumers are supposed to provide

void doOutputHeader(InitMsgBuilder const& init_message) void doOutputEvent(EventMsgBuilder const& msg) void start() void stop() static void fillDescription(ParameterSetDescription&)

Definition at line 65 of file RecoEventOutputModuleForFU.h.

References evf::RecoEventOutputModuleForFU< Consumer >::accepted_, jsoncollector::DataPointDefinition::addLegendItem(), ws_sso_content_reader::content, evf::RecoEventOutputModuleForFU< Consumer >::errorEvents_, evf::RecoEventOutputModuleForFU< Consumer >::filelist_, evf::RecoEventOutputModuleForFU< Consumer >::filesize_, evf::RecoEventOutputModuleForFU< Consumer >::fms_, evf::RecoEventOutputModuleForFU< Consumer >::inputFiles_, evf::RecoEventOutputModuleForFU< Consumer >::jsonMonitor_, LogDebug, evf::RecoEventOutputModuleForFU< Consumer >::outJsonDef_, evf::RecoEventOutputModuleForFU< Consumer >::processed_, evf::RecoEventOutputModuleForFU< Consumer >::retCodeMask_, cond::serialize(), jsoncollector::DataPointDefinition::setDefaultGroup(), jsoncollector::JsonMonitorable::setName(), AlCaHLTBitMon_QueryRunRegistry::string, and SUM.

65  :
67  c_(new Consumer(ps)),
68  stream_label_(ps.getParameter<std::string>("@module_label")),
69  processed_(0),
70  accepted_(0),
71  errorEvents_(0),
72  retCodeMask_(0),
73  filelist_(),
74  filesize_(0),
75  inputFiles_()
76  {
77  std::string baseRunDir = edm::Service<evf::EvFDaqDirector>()->baseRunDir();
78  LogDebug("RecoEventOutputModuleForFU") << "writing .dat files to -: " << baseRunDir;
79  // create open dir if not already there
80  edm::Service<evf::EvFDaqDirector>()->createRunOpendirMaybe();
81 
83 
84  processed_.setName("Processed");
85  accepted_.setName("Accepted");
86  errorEvents_.setName("ErrorEvents");
87  retCodeMask_.setName("ReturnCodeMask");
88  filelist_.setName("Filelist");
89  filesize_.setName("Filesize");
90  inputFiles_.setName("InputFiles");
91 
93  outJsonDef_.addLegendItem("Processed","integer",DataPointDefinition::SUM);
95  outJsonDef_.addLegendItem("ErrorEvents","integer",DataPointDefinition::SUM);
96  outJsonDef_.addLegendItem("ReturnCodeMask","integer",DataPointDefinition::BINARYOR);
97  outJsonDef_.addLegendItem("Filelist","string",DataPointDefinition::MERGE);
99  outJsonDef_.addLegendItem("InputFiles","string",DataPointDefinition::CAT);
100  std::stringstream tmpss,ss;
101  tmpss << baseRunDir << "/open/" << "output_" << getpid() << ".jsd";
102  ss << baseRunDir << "/" << "output_" << getpid() << ".jsd";
103  std::string outTmpJsonDefName = tmpss.str();
104  std::string outJsonDefName = ss.str();
105 
106  edm::Service<evf::EvFDaqDirector>()->lockInitLock();
107  struct stat fstat;
108  if (stat (outJsonDefName.c_str(), &fstat) != 0) { //file does not exist
109  LogDebug("RecoEventOutputModuleForFU") << "writing output definition file -: " << outJsonDefName;
112  FileIO::writeStringToFile(outTmpJsonDefName, content);
113  boost::filesystem::rename(outTmpJsonDefName,outJsonDefName);
114  }
115  edm::Service<evf::EvFDaqDirector>()->unlockInitLock();
116 
117  jsonMonitor_.reset(new FastMonitor(&outJsonDef_,true));
118  jsonMonitor_->setDefPath(outJsonDefName);
119  jsonMonitor_->registerGlobalMonitorable(&processed_,false);
120  jsonMonitor_->registerGlobalMonitorable(&accepted_,false);
121  jsonMonitor_->registerGlobalMonitorable(&errorEvents_,false);
122  jsonMonitor_->registerGlobalMonitorable(&retCodeMask_,false);
123  jsonMonitor_->registerGlobalMonitorable(&filelist_,false);
124  jsonMonitor_->registerGlobalMonitorable(&filesize_,false);
125  jsonMonitor_->registerGlobalMonitorable(&inputFiles_,false);
126  jsonMonitor_->commit(nullptr);
127  }
#define LogDebug(id)
void addLegendItem(std::string const &name, std::string const &type, std::string const &operation)
boost::shared_ptr< FastMonitor > jsonMonitor_
virtual void setName(std::string name)
#define SUM(A, B)
std::pair< Binary, Binary > serialize(const T &payload, bool packingOnly=false)
Definition: Serialization.h:92
void setDefaultGroup(std::string const &group)
template<typename Consumer >
evf::RecoEventOutputModuleForFU< Consumer >::~RecoEventOutputModuleForFU ( )
virtual

Definition at line 130 of file RecoEventOutputModuleForFU.h.

130 {}

Member Function Documentation

template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::beginLuminosityBlock ( edm::LuminosityBlockPrincipal const &  ls,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 174 of file RecoEventOutputModuleForFU.h.

References edm::LuminosityBlockPrincipal::luminosityBlock().

175  {
176  //edm::LogInfo("RecoEventOutputModuleForFU") << "begin lumi";
177  openDatFilePath_ = edm::Service<evf::EvFDaqDirector>()->getOpenDatFilePath(ls.luminosityBlock(),stream_label_);
178  c_->setOutputFile(openDatFilePath_.string());
179  filelist_ = openDatFilePath_.filename().string();
180  }
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::doOutputEvent ( EventMsgBuilder const &  msg) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 159 of file RecoEventOutputModuleForFU.h.

159  {
160  accepted_.value()++;
161  c_->doOutputEvent(msg); // You can't use msg in RecoEventOutputModuleForFU after this point
162  }
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::doOutputHeader ( InitMsgBuilder const &  init_message) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 152 of file RecoEventOutputModuleForFU.h.

153  {
154  c_->doOutputHeader(init_message);
155  }
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::endLuminosityBlock ( edm::LuminosityBlockPrincipal const &  ls,
edm::ModuleCallingContext const *   
)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 183 of file RecoEventOutputModuleForFU.h.

References b, edm::LuminosityBlockPrincipal::luminosityBlock(), alcazmumu_cfi::src, and AlCaHLTBitMon_QueryRunRegistry::string.

184  {
185  //edm::LogInfo("RecoEventOutputModuleForFU") << "end lumi";
186  long filesize=0;
187  c_->closeOutputFile();
188  processed_.value() = fms_->getEventsProcessedForLumi(ls.luminosityBlock());
189  if(processed_.value()!=0){
190  int b;
191  // move dat file to one level up - this is VERRRRRY inefficient, come up with a smarter idea
192 
193  FILE *des = edm::Service<evf::EvFDaqDirector>()->maybeCreateAndLockFileHeadForStream(ls.luminosityBlock(),stream_label_);
194  FILE *src = fopen(openDatFilePath_.string().c_str(),"r");
195  if(des != 0 && src !=0){
196  while((b=fgetc(src))!= EOF){
197  fputc((unsigned char)b,des);
198  filesize++;
199  }
200  }
201 
202  edm::Service<evf::EvFDaqDirector>()->unlockAndCloseMergeStream();
203  fclose(src);
204  }
205  //remove file
206  remove(openDatFilePath_.string().c_str());
207  filesize_=filesize;
208 
209  // output jsn file
210  if(processed_.value()!=0){
211  jsonMonitor_->snap(ls.luminosityBlock());
212  const std::string outputJsonNameStream =
213  edm::Service<evf::EvFDaqDirector>()->getOutputJsonFilePath(ls.luminosityBlock(),stream_label_);
214  jsonMonitor_->outputFullJSON(outputJsonNameStream,ls.luminosityBlock());
215  }
216 
217  // reset monitoring params
218  accepted_.value() = 0;
219  filelist_ = "";
220  }
unsigned int getEventsProcessedForLumi(unsigned int lumi)
boost::shared_ptr< FastMonitor > jsonMonitor_
double b
Definition: hdecay.h:120
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 166 of file RecoEventOutputModuleForFU.h.

References edm::ConfigurationDescriptions::add(), and edm::StreamerOutputModuleBase::fillDescription().

166  {
169  Consumer::fillDescription(desc);
170  descriptions.add("streamerOutput", desc);
171  }
static void fillDescription(ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::start ( void  ) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 134 of file RecoEventOutputModuleForFU.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by progressbar.ProgressBar::__next__(), Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

135  {
136  const std::string initFileName = edm::Service<evf::EvFDaqDirector>()->getInitFilePath(stream_label_);
137  edm::LogInfo("RecoEventOutputModuleForFU") << "start() method, initializing streams. init stream -: "
138  << initFileName;
139  c_->setInitMessageFile(initFileName);
140  c_->start();
141  }
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::stop ( ) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 145 of file RecoEventOutputModuleForFU.h.

146  {
147  c_->stop();
148  }

Member Data Documentation

template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::accepted_
mutableprivate
template<typename Consumer >
std::auto_ptr<Consumer> evf::RecoEventOutputModuleForFU< Consumer >::c_
private

Definition at line 47 of file RecoEventOutputModuleForFU.h.

template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::errorEvents_
private
template<typename Consumer >
StringJ evf::RecoEventOutputModuleForFU< Consumer >::filelist_
private
template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::filesize_
private
template<typename Consumer >
evf::FastMonitoringService* evf::RecoEventOutputModuleForFU< Consumer >::fms_
private
template<typename Consumer >
StringJ evf::RecoEventOutputModuleForFU< Consumer >::inputFiles_
private
template<typename Consumer >
boost::shared_ptr<FastMonitor> evf::RecoEventOutputModuleForFU< Consumer >::jsonMonitor_
private
template<typename Consumer >
boost::filesystem::path evf::RecoEventOutputModuleForFU< Consumer >::openDatFilePath_
private

Definition at line 49 of file RecoEventOutputModuleForFU.h.

template<typename Consumer >
DataPointDefinition evf::RecoEventOutputModuleForFU< Consumer >::outJsonDef_
private
template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::processed_
private
template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::retCodeMask_
private
template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::stream_label_
private

Definition at line 48 of file RecoEventOutputModuleForFU.h.