CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
dqm::DQMFileSaverPB Class Reference

#include <DQMFileSaverPB.h>

Inheritance diagram for dqm::DQMFileSaverPB:
dqm::DQMFileSaverBase edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DQMFileSaverPB (const edm::ParameterSet &ps)
 
 ~DQMFileSaverPB () override
 
- Public Member Functions inherited from dqm::DQMFileSaverBase
 DQMFileSaverBase (const edm::ParameterSet &ps)
 
 ~DQMFileSaverBase () override
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static boost::property_tree::ptree fillJson (int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
 
- Static Public Member Functions inherited from dqm::DQMFileSaverBase
static void fillDescription (edm::ParameterSetDescription &d)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void initRun () const override
 
void saveLumi (const FileParameters &fp) const override
 
void saveRun (const FileParameters &fp) const override
 
- Protected Member Functions inherited from dqm::DQMFileSaverBase
void analyze (edm::StreamID, const edm::Event &e, const edm::EventSetup &) const final
 
std::shared_ptr< NoCacheglobalBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const final
 
std::shared_ptr< NoCacheglobalBeginRun (const edm::Run &, const edm::EventSetup &) const final
 
void globalEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const final
 
void globalEndRun (const edm::Run &, const edm::EventSetup &) const final
 
void logFileAction (const std::string &msg, const std::string &fileName) const
 
void saveJobReport (const std::string &filename) const
 
- 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)
 

Protected Attributes

bool fakeFilterUnitMode_
 
std::string mergeType_
 
std::string streamLabel_
 
std::string transferDestination_
 
- Protected Attributes inherited from dqm::DQMFileSaverBase
FileParameters initial_fp_
 
std::mutex initial_fp_lock_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Protected Member Functions inherited from dqm::DQMFileSaverBase
static const std::string filename (const FileParameters &fp, bool useLumi=false)
 

Detailed Description

Definition at line 15 of file DQMFileSaverPB.h.

Constructor & Destructor Documentation

DQMFileSaverPB::DQMFileSaverPB ( const edm::ParameterSet ps)

Definition at line 26 of file DQMFileSaverPB.cc.

References fakeFilterUnitMode_, edm::ParameterSet::getUntrackedParameter(), mergeType_, streamLabel_, AlCaHLTBitMon_QueryRunRegistry::string, transferDestination_, and ~DQMFileSaverPB().

27  : DQMFileSaverBase(ps) {
28 
29  fakeFilterUnitMode_ = ps.getUntrackedParameter<bool>("fakeFilterUnitMode", false);
30  streamLabel_ = ps.getUntrackedParameter<std::string>("streamLabel", "streamDQMHistograms");
31 
33  mergeType_ = "";
34 }
DQMFileSaverBase(const edm::ParameterSet &ps)
std::string streamLabel_
T getUntrackedParameter(std::string const &, T const &) const
std::string transferDestination_
std::string mergeType_
DQMFileSaverPB::~DQMFileSaverPB ( )
overridedefault

Referenced by DQMFileSaverPB().

Member Function Documentation

void DQMFileSaverPB::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 180 of file DQMFileSaverPB.cc.

References edm::ConfigurationDescriptions::addDefault(), edm::ParameterSetDescription::addUntracked(), DEFINE_FWK_MODULE, dqm::DQMFileSaverBase::fillDescription(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

181  {
182 
184  desc.setComment("Saves histograms from DQM store, HLT->pb workflow.");
185 
186  desc.addUntracked<bool>("fakeFilterUnitMode", false)->setComment(
187  "If set, EvFDaqDirector is emulated and not used.");
188 
189  desc.addUntracked<std::string>("streamLabel", "streamDQMHistograms")->setComment(
190  "Label of the stream.");
191 
193 
194  // Changed to use addDefault instead of add here because previously
195  // DQMFileSaverOnline and DQMFileSaverPB both used the module label
196  // "saver" which caused conflicting cfi filenames to be generated.
197  // add could be used if unique module labels were given.
198  descriptions.addDefault(desc);
199 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescription(edm::ParameterSetDescription &d)
boost::property_tree::ptree DQMFileSaverPB::fillJson ( int  run,
int  lumi,
const std::string &  dataFilePathName,
const std::string &  transferDestinationStr,
const std::string &  mergeTypeStr,
evf::FastMonitoringService fms 
)
static

Definition at line 100 of file DQMFileSaverPB.cc.

References data, Exception, evf::FastMonitoringService::getEventsProcessedForLumi(), query::host, merge::inputFiles, callgraph::path, sysUtil::pid, EnergyCorrector::pt, trackingPlots::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by saveLumi().

101 {
102  namespace bpt = boost::property_tree;
103  namespace bfs = boost::filesystem;
104 
105  bpt::ptree pt;
106 
107  int hostnameReturn;
108  char host[32];
109  hostnameReturn = gethostname(host ,sizeof(host));
110  if (hostnameReturn == -1)
111  throw cms::Exception("fillJson")
112  << "Internal error, cannot get host name";
113 
114  int pid = getpid();
115  std::ostringstream oss_pid;
116  oss_pid << pid;
117 
118  int nProcessed = fms ? (fms->getEventsProcessedForLumi(lumi)) : -1;
119 
120  // Stat the data file: if not there, throw
121  std::string dataFileName;
122  struct stat dataFileStat;
123  dataFileStat.st_size=0;
124  if (nProcessed) {
125  if (stat(dataFilePathName.c_str(), &dataFileStat) != 0)
126  throw cms::Exception("fillJson")
127  << "Internal error, cannot get data file: "
128  << dataFilePathName;
129  // Extract only the data file name from the full path
130  dataFileName = bfs::path(dataFilePathName).filename().string();
131  }
132  // The availability test of the FastMonitoringService was done in the ctor.
133  bpt::ptree data;
134  bpt::ptree processedEvents, acceptedEvents, errorEvents, bitmask, fileList, fileSize, inputFiles, fileAdler32, transferDestination, mergeType, hltErrorEvents;
135 
136  processedEvents.put("", nProcessed); // Processed events
137  acceptedEvents.put("", nProcessed); // Accepted events, same as processed for our purposes
138 
139  errorEvents.put("", 0); // Error events
140  bitmask.put("", 0); // Bitmask of abs of CMSSW return code
141  fileList.put("", dataFileName); // Data file the information refers to
142  fileSize.put("", dataFileStat.st_size); // Size in bytes of the data file
143  inputFiles.put("", ""); // We do not care about input files!
144  fileAdler32.put("", -1); // placeholder to match output json definition
145  transferDestination.put("", transferDestinationStr); // SM Transfer destination field
146  mergeType.put("", mergeTypeStr); // SM Transfer destination field
147  hltErrorEvents.put("", 0); // Error events
148 
149  data.push_back(std::make_pair("", processedEvents));
150  data.push_back(std::make_pair("", acceptedEvents));
151  data.push_back(std::make_pair("", errorEvents));
152  data.push_back(std::make_pair("", bitmask));
153  data.push_back(std::make_pair("", fileList));
154  data.push_back(std::make_pair("", fileSize));
155  data.push_back(std::make_pair("", inputFiles));
156  data.push_back(std::make_pair("", fileAdler32));
157  data.push_back(std::make_pair("", transferDestination));
158  data.push_back(std::make_pair("", mergeType));
159  data.push_back(std::make_pair("", hltErrorEvents));
160 
161  pt.add_child("data", data);
162 
163  if (fms == nullptr) {
164  pt.put("definition", "/fakeDefinition.jsn");
165  } else {
166  // The availability test of the EvFDaqDirector Service was done in the ctor.
167  bfs::path outJsonDefName(edm::Service<evf::EvFDaqDirector>()->baseRunDir()); //we assume this file is written bu the EvF Output module
168  outJsonDefName /= (std::string("output_") + oss_pid.str() + std::string(".jsd"));
169  pt.put("definition", outJsonDefName.string());
170  }
171 
172  char sourceInfo[64]; //host and pid information
173  sprintf(sourceInfo, "%s_%d", host, pid);
174  pt.put("source", sourceInfo);
175 
176  return pt;
177 }
host
Definition: query.py:115
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
inputFiles
Definition: merge.py:6
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void DQMFileSaverPB::initRun ( ) const
overrideprotectedvirtual
void DQMFileSaverPB::saveLumi ( const FileParameters fp) const
overrideprotectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 45 of file DQMFileSaverPB.cc.

References fakeFilterUnitMode_, fillJson(), cmsPerfStripChart::format, evf::FastMonitoringService::getEventsProcessedForLumi(), dqm::DQMFileSaverBase::FileParameters::lumi_, mergeType_, dqm::DQMFileSaverBase::FileParameters::path_, EnergyCorrector::pt, dqm::DQMFileSaverBase::FileParameters::run_, str, streamLabel_, AlCaHLTBitMon_QueryRunRegistry::string, and transferDestination_.

45  {
46  // get from DAQ2 services where to store the files according to their format
47  namespace bpt = boost::property_tree;
48 
49  std::string openJsonFilePathName;
50  std::string jsonFilePathName;
51  std::string openHistoFilePathName;
52  std::string histoFilePathName;
53 
54  evf::FastMonitoringService *fms = nullptr;
56 
57  // create the files names
58  if (fakeFilterUnitMode_) {
59  std::string runDir = str(boost::format("%s/run%06d") % fp.path_ % fp.run_);
60  std::string baseName = str(boost::format("%s/run%06d_ls%04d_%s") % runDir % fp.run_ % fp.lumi_ % streamLabel_ );
61 
62  boost::filesystem::create_directories(runDir);
63 
64  jsonFilePathName = baseName + ".jsn";
65  openJsonFilePathName = jsonFilePathName + ".open";
66 
67  histoFilePathName = baseName + ".pb";
68  openHistoFilePathName = histoFilePathName + ".open";
69  } else {
70  openJsonFilePathName = edm::Service<evf::EvFDaqDirector>()->getOpenOutputJsonFilePath(fp.lumi_, streamLabel_);
71  jsonFilePathName = edm::Service<evf::EvFDaqDirector>()->getOutputJsonFilePath(fp.lumi_, streamLabel_);
72 
73  openHistoFilePathName = edm::Service<evf::EvFDaqDirector>()->getOpenProtocolBufferHistogramFilePath(fp.lumi_, streamLabel_);
74  histoFilePathName = edm::Service<evf::EvFDaqDirector>()->getProtocolBufferHistogramFilePath(fp.lumi_, streamLabel_);
75 
77  }
78 
79  if (fms ? fms->getEventsProcessedForLumi(fp.lumi_) : true) {
80  // Save the file in the open directory.
81  store->savePB(openHistoFilePathName, "",
82  store->mtEnabled() ? fp.run_ : 0,
83  fp.lumi_);
84 
85  // Now move the the data and json files into the output directory.
86  ::rename(openHistoFilePathName.c_str(), histoFilePathName.c_str());
87  }
88 
89  // Write the json file in the open directory.
90  bpt::ptree pt = fillJson(fp.run_, fp.lumi_, histoFilePathName, transferDestination_, mergeType_, fms);
91  write_json(openJsonFilePathName, pt);
92  ::rename(openJsonFilePathName.c_str(), jsonFilePathName.c_str());
93 }
std::string streamLabel_
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
std::string transferDestination_
format
Some error handling for the usage.
#define str(s)
static boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
std::string mergeType_
void DQMFileSaverPB::saveRun ( const FileParameters fp) const
overrideprotectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 95 of file DQMFileSaverPB.cc.

95  {
96  // no saving for the run
97 }

Member Data Documentation

bool dqm::DQMFileSaverPB::fakeFilterUnitMode_
protected

Definition at line 31 of file DQMFileSaverPB.h.

Referenced by DQMFileSaverPB(), initRun(), and saveLumi().

std::string dqm::DQMFileSaverPB::mergeType_
mutableprotected

Definition at line 34 of file DQMFileSaverPB.h.

Referenced by DQMFileSaverPB(), initRun(), and saveLumi().

std::string dqm::DQMFileSaverPB::streamLabel_
protected

Definition at line 32 of file DQMFileSaverPB.h.

Referenced by DQMFileSaverPB(), initRun(), and saveLumi().

std::string dqm::DQMFileSaverPB::transferDestination_
mutableprotected

Definition at line 33 of file DQMFileSaverPB.h.

Referenced by DQMFileSaverPB(), initRun(), and saveLumi().