test
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, 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

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 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, and transferDestination_.

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

Definition at line 36 of file DQMFileSaverPB.cc.

36 {}

Member Function Documentation

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

Definition at line 181 of file DQMFileSaverPB.cc.

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

182  {
183 
185  desc.setComment("Saves histograms from DQM store, HLT->pb workflow.");
186 
187  desc.addUntracked<bool>("fakeFilterUnitMode", false)->setComment(
188  "If set, EvFDaqDirector is emulated and not used.");
189 
190  desc.addUntracked<std::string>("streamLabel", "streamDQMHistograms")->setComment(
191  "Label of the stream.");
192 
194  descriptions.add("saver", desc);
195 }
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,
const std::string  mergeTypeStr,
evf::FastMonitoringService fms 
)
static

Definition at line 101 of file DQMFileSaverPB.cc.

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

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

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 96 of file DQMFileSaverPB.cc.

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

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