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 | 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 ()
 
- Public Member Functions inherited from dqm::DQMFileSaverBase
 DQMFileSaverBase (const edm::ParameterSet &ps)
 
 ~DQMFileSaverBase ()
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 boost::property_tree::ptree fillJson (int run, int lumi, const std::string &dataFilePathName, const std::string transferDestinationStr, 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

virtual void initRun () const override
 
virtual void saveLumi (const FileParameters &fp) const override
 
virtual void saveRun (const FileParameters &fp) const override
 
- Protected Member Functions inherited from dqm::DQMFileSaverBase
virtual void analyze (edm::StreamID, const edm::Event &e, const edm::EventSetup &) const overridefinal
 
virtual std::shared_ptr< NoCacheglobalBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const overridefinal
 
virtual std::shared_ptr< NoCacheglobalBeginRun (const edm::Run &, const edm::EventSetup &) const overridefinal
 
virtual void globalEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const overridefinal
 
virtual void globalEndRun (const edm::Run &, const edm::EventSetup &) const overridefinal
 
void logFileAction (const std::string &msg, const std::string &fileName) const
 
virtual void postForkReacquireResources (unsigned int childIndex, unsigned int numberOfChildren)
 
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 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(), streamLabel_, AlCaHLTBitMon_QueryRunRegistry::string, and transferDestination_.

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

Definition at line 35 of file DQMFileSaverPB.cc.

35 {}

Member Function Documentation

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

Definition at line 175 of file DQMFileSaverPB.cc.

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

176  {
177 
179  desc.setComment("Saves histograms from DQM store, HLT->pb workflow.");
180 
181  desc.addUntracked<bool>("fakeFilterUnitMode", false)->setComment(
182  "If set, EvFDaqDirector is emulated and not used.");
183 
184  desc.addUntracked<std::string>("streamLabel", "streamDQMHistograms")->setComment(
185  "Label of the stream.");
186 
188  descriptions.add("saver", desc);
189 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, 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,
evf::FastMonitoringService fms 
)
static

Definition at line 99 of file DQMFileSaverPB.cc.

References data, Exception, evf::FastMonitoringService::getEventsProcessedForLumi(), query::host, merge::inputFiles, fed_dqm_sourceclient-live_cfg::path, sysUtil::pid, EnergyCorrector::pt, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by saveLumi().

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

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 37 of file DQMFileSaverPB.cc.

References fakeFilterUnitMode_, streamLabel_, and transferDestination_.

37  {
38  if (!fakeFilterUnitMode_) {
40  }
41 }
std::string streamLabel_
std::string transferDestination_
void DQMFileSaverPB::saveLumi ( const FileParameters fp) const
overrideprotectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 43 of file DQMFileSaverPB.cc.

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

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

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 94 of file DQMFileSaverPB.cc.

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

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::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().