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
 
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 *)
 
void initializeStreams ()
 
virtual void start () const
 
virtual void stop () const
 

Private Attributes

IntJ accepted_
 
std::string baseDir_
 
std::auto_ptr< Consumer > c_
 
std::string events_base_filename_
 
StringJ filelist_
 
evf::FastMonitoringServicefms_
 
std::string jsonDefPath_
 
boost::shared_ptr< FastMonitorjsonMonitor_
 
boost::filesystem::path openDatFilePath_
 
IntJ processed_
 
std::string smpath_
 
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, 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 21 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 84 of file RecoEventOutputModuleForFU.h.

References evf::RecoEventOutputModuleForFU< Consumer >::accepted_, evf::RecoEventOutputModuleForFU< Consumer >::filelist_, evf::RecoEventOutputModuleForFU< Consumer >::fms_, evf::FastMonitoringService::getOutputDefPath(), evf::RecoEventOutputModuleForFU< Consumer >::initializeStreams(), evf::RecoEventOutputModuleForFU< Consumer >::jsonDefPath_, evf::RecoEventOutputModuleForFU< Consumer >::jsonMonitor_, evf::RecoEventOutputModuleForFU< Consumer >::processed_, and jsoncollector::JsonMonitorable::setName().

84  :
86  c_(new Consumer(ps)),
87  stream_label_(ps.getParameter<std::string>("@module_label")),
88  baseDir_(ps.getUntrackedParameter<std::string>("baseDir","")),
89  processed_(0),
90  accepted_(0),
91  filelist_("")
92  {
94 
97 
98  processed_.setName("Processed");
99  accepted_.setName("Accepted");
100  filelist_.setName("Filelist");
101  vector<JsonMonitorable*> monParams;
102  monParams.push_back(&processed_);
103  monParams.push_back(&accepted_);
104  monParams.push_back(&filelist_);
105 
106  jsonMonitor_.reset(new FastMonitor(monParams, jsonDefPath_));
107  }
std::string getOutputDefPath() const
boost::shared_ptr< FastMonitor > jsonMonitor_
template<typename Consumer >
evf::RecoEventOutputModuleForFU< Consumer >::~RecoEventOutputModuleForFU ( )
virtual

Definition at line 110 of file RecoEventOutputModuleForFU.h.

110 {}

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 165 of file RecoEventOutputModuleForFU.h.

References gather_cfg::cout, and edm::LuminosityBlockPrincipal::luminosityBlock().

165  {
166  std::cout << "RecoEventOutputModuleForFU : begin lumi " << std::endl;
167  openDatFilePath_ = edm::Service<evf::EvFDaqDirector>()->getOpenDatFilePath(ls.luminosityBlock(),stream_label_);
168  c_->setOutputFile(openDatFilePath_.string());
169  filelist_ = openDatFilePath_.filename().string();
170  }
tuple cout
Definition: gather_cfg.py:121
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::doOutputEvent ( EventMsgBuilder const &  msg) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 142 of file RecoEventOutputModuleForFU.h.

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

Implements edm::StreamerOutputModuleBase.

Definition at line 135 of file RecoEventOutputModuleForFU.h.

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

Reimplemented from edm::OutputModule.

Definition at line 173 of file RecoEventOutputModuleForFU.h.

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

173  {
174  std::cout << "RecoEventOutputModuleForFU : end lumi " << std::endl;
175  c_->closeOutputFile();
176  processed_.value() = fms_->getEventsProcessedForLumi(ls.luminosityBlock());
177  if(processed_.value()!=0){
178  int b;
179  // move dat file to one level up - this is VERRRRRY inefficient, come up with a smarter idea
180 
181  FILE *des = edm::Service<evf::EvFDaqDirector>()->maybeCreateAndLockFileHeadForStream(ls.luminosityBlock(),stream_label_);
182  FILE *src = fopen(openDatFilePath_.string().c_str(),"r");
183  if(des != 0 && src !=0){
184  while((b=fgetc(src))!= EOF){
185  fputc((unsigned char)b,des);
186  }
187  }
188 
189  edm::Service<evf::EvFDaqDirector>()->unlockAndCloseMergeStream();
190  fclose(src);
191  }
192  //remove file
193  remove(openDatFilePath_.string().c_str());
194 
195  // output jsn file
196  if(processed_.value()!=0){
197  jsonMonitor_->snap(false, "");
198  const std::string outputJsonNameStream =
199  edm::Service<evf::EvFDaqDirector>()->getOutputJsonFilePath(ls.luminosityBlock(),stream_label_);
200  jsonMonitor_->outputFullHistoDataPoint(outputJsonNameStream);
201  }
202 
203  // reset monitoring params
204  accepted_.value() = 0;
205  filelist_ = "";
206  }
unsigned int getEventsProcessedForLumi(unsigned int lumi)
boost::shared_ptr< FastMonitor > jsonMonitor_
double b
Definition: hdecay.h:120
tuple cout
Definition: gather_cfg.py:121
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 149 of file RecoEventOutputModuleForFU.h.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::StreamerOutputModuleBase::fillDescription(), and AlCaHLTBitMon_QueryRunRegistry::string.

149  {
152  Consumer::fillDescription(desc);
153  desc.addUntracked<std::string>("baseDir", "")
154  ->setComment("Top level output directory");
155  descriptions.add("streamerOutput", desc);
156  }
static void fillDescription(ParameterSetDescription &desc)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::initializeStreams ( )
inlineprivate

Definition at line 45 of file RecoEventOutputModuleForFU.h.

References gather_cfg::cout, getHLTPrescaleColumns::path, and evf::RecoEventOutputModuleForFU< Consumer >::smpath_.

Referenced by evf::RecoEventOutputModuleForFU< Consumer >::RecoEventOutputModuleForFU().

45  {
46  // find run dir
47  boost::filesystem::path runDirectory(
48  edm::Service<evf::EvFDaqDirector>()->findCurrentRunDir());
49  smpath_ = runDirectory.string();
50  edm::LogInfo("RecoEventOutputModuleForFU") << "Writing .dat files to "
51  << smpath_;
52  // create open dir if not already there
53  boost::filesystem::path openPath = runDirectory;
54  openPath /= "open";
55  // do these dirs need to be created?
56  bool foundOpenDir = false;
57  if (boost::filesystem::is_directory(openPath))
58  foundOpenDir = true;
59  if (!foundOpenDir) {
60  std::cout << "<open> FU dir not found. Creating..."
61  << std::endl;
62  boost::filesystem::create_directories(openPath);
63  }
64  }
tuple cout
Definition: gather_cfg.py:121
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::start ( void  ) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 114 of file RecoEventOutputModuleForFU.h.

References gather_cfg::cout, and AlCaHLTBitMon_QueryRunRegistry::string.

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

115  {
116  std::cout << "RecoEventOutputModuleForFU: start() method " << std::endl;
117 
118  const std::string initFileName = edm::Service<evf::EvFDaqDirector>()->getInitFilePath(stream_label_);
119 
120  std::cout << "RecoEventOutputModuleForFU, initializing streams. init stream: "
121  << initFileName << std::endl;
122 
123  c_->setInitMessageFile(initFileName);
124  c_->start();
125  }
tuple cout
Definition: gather_cfg.py:121
template<typename Consumer >
void evf::RecoEventOutputModuleForFU< Consumer >::stop ( ) const
privatevirtual

Implements edm::StreamerOutputModuleBase.

Definition at line 129 of file RecoEventOutputModuleForFU.h.

129  {
130  c_->stop();
131  }

Member Data Documentation

template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::accepted_
mutableprivate
template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::baseDir_
private

Definition at line 70 of file RecoEventOutputModuleForFU.h.

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

Definition at line 67 of file RecoEventOutputModuleForFU.h.

template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::events_base_filename_
private

Definition at line 69 of file RecoEventOutputModuleForFU.h.

template<typename Consumer >
StringJ evf::RecoEventOutputModuleForFU< Consumer >::filelist_
private
template<typename Consumer >
evf::FastMonitoringService* evf::RecoEventOutputModuleForFU< Consumer >::fms_
private
template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::jsonDefPath_
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 73 of file RecoEventOutputModuleForFU.h.

template<typename Consumer >
IntJ evf::RecoEventOutputModuleForFU< Consumer >::processed_
private
template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::smpath_
private
template<typename Consumer >
std::string evf::RecoEventOutputModuleForFU< Consumer >::stream_label_
private

Definition at line 68 of file RecoEventOutputModuleForFU.h.