CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
dqm::DQMFileSaverBase Class Reference

#include <DQMFileSaverBase.h>

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

Classes

struct  FileParameters
 

Public Member Functions

 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 (const std::string &iProcessName, std::vector< const char * > &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 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 analyze (edm::StreamID, const edm::Event &e, const edm::EventSetup &) const
 
virtual void beginJob (void)
 
virtual void endJob (void)
 
virtual std::shared_ptr< NoCacheglobalBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const
 
virtual std::shared_ptr< NoCacheglobalBeginRun (const edm::Run &, const edm::EventSetup &) const
 
virtual void globalEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const
 
virtual void globalEndRun (const edm::Run &, const edm::EventSetup &) const
 
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
 
virtual void saveLumi (FileParameters fp) const
 
virtual void saveRun (FileParameters fp) 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)
 

Static Protected Member Functions

static const std::string filename (FileParameters fp, bool useLumi=false)
 
static boost::property_tree::ptree fillJson (int run, int lumi, const std::string &dataFilePathName, const std::string transferDestinationStr, evf::FastMonitoringService *fms)
 
static const std::string fillOrigin (const std::string filename, const std::string final_filename)
 

Protected Attributes

FileParameters initial_fp_
 
std::mutex initial_fp_lock_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 

Detailed Description

Definition at line 23 of file DQMFileSaverBase.h.

Constructor & Destructor Documentation

DQMFileSaverBase::DQMFileSaverBase ( const edm::ParameterSet ps)

Definition at line 32 of file DQMFileSaverBase.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, dqm::DQMFileSaverBase::FileParameters::child_, personalPlayback::fp, edm::ParameterSet::getUntrackedParameter(), initial_fp_, initial_fp_lock_, dqm::DQMFileSaverBase::FileParameters::lumi_, dqm::DQMFileSaverBase::FileParameters::path_, dqm::DQMFileSaverBase::FileParameters::producer_, dqm::DQMFileSaverBase::FileParameters::run_, dqm::DQMFileSaverBase::FileParameters::saveReference_, dqm::DQMFileSaverBase::FileParameters::saveReferenceQMin_, DQMStore::SaveWithoutReference, DQMStore::SaveWithReference, DQMStore::SaveWithReferenceForQTest, dqm::qstatus::STATUS_OK, AlCaHLTBitMon_QueryRunRegistry::string, dqm::DQMFileSaverBase::FileParameters::tag_, and dqm::DQMFileSaverBase::FileParameters::version_.

32  {
33  FileParameters fp;
34 
35  fp.path_ = ps.getUntrackedParameter<std::string>("path");
36  fp.producer_ = ps.getUntrackedParameter<std::string>("producer");
37  fp.run_ = 0;
38  fp.tag_ = ps.getUntrackedParameter<std::string>("tag");
39  fp.lumi_ = 0;
40  fp.version_ = 1;
41  fp.child_ = "";
42 
43  fp.saveReference_ = DQMStore::SaveWithReference;
44  // Check how we should save the references.
45  std::string refsave = ps.getUntrackedParameter<std::string>("referenceHandling", "all");
46  if (refsave == "skip")
47  {
48  fp.saveReference_ = DQMStore::SaveWithoutReference;
49  }
50  else if (refsave == "all")
51  {
52  fp.saveReference_ = DQMStore::SaveWithReference;
53  }
54  else if (refsave == "qtests")
55  {
56  fp.saveReference_ = DQMStore::SaveWithReferenceForQTest;
57  }
58  else {
59  //edm::LogInfo("DQMFileSaverBase")
60  std::cerr
61  << "Invalid 'referenceHandling' parameter '" << refsave
62  << "'. Expected 'skip', 'all' or 'qtests'.";
63 
64  }
65 
66  // Check minimum required quality test result for which reference is saved.
67  fp.saveReferenceQMin_ = ps.getUntrackedParameter<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK);
68 
69  std::unique_lock<std::mutex> lck(initial_fp_lock_);
70  initial_fp_ = fp;
71 }
T getUntrackedParameter(std::string const &, T const &) const
FileParameters initial_fp_
static const int STATUS_OK
DQMFileSaverBase::~DQMFileSaverBase ( )

Definition at line 73 of file DQMFileSaverBase.cc.

73 {}

Member Function Documentation

void DQMFileSaverBase::analyze ( edm::StreamID  ,
const edm::Event e,
const edm::EventSetup  
) const
protectedvirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 89 of file DQMFileSaverBase.cc.

90  {
91  // not supported
92 }
void DQMFileSaverBase::beginJob ( void  )
protectedvirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 75 of file DQMFileSaverBase.cc.

75 {}
void DQMFileSaverBase::endJob ( void  )
protectedvirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 126 of file DQMFileSaverBase.cc.

126 {}
const std::string DQMFileSaverBase::filename ( FileParameters  fp,
bool  useLumi = false 
)
staticprotected

Definition at line 148 of file DQMFileSaverBase.cc.

References dqm::DQMFileSaverBase::FileParameters::child_, mergeVDriftHistosByStation::file, dqm::DQMFileSaverBase::FileParameters::lumi_, cmsHarvester::path, dqm::DQMFileSaverBase::FileParameters::path_, dqm::DQMFileSaverBase::FileParameters::producer_, dqm::DQMFileSaverBase::FileParameters::run_, dqm::DQMFileSaverBase::FileParameters::tag_, and dqm::DQMFileSaverBase::FileParameters::version_.

Referenced by cuy.ValElement::__init__(), dqm::DQMFileSaverOnline::makeSnapshot(), and Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::properties().

148  {
149  char buf[256];
150  if (useLumi) {
151  snprintf(buf, 256, "%s_V%04d_%s_R%09ld_L%09ld%s", fp.producer_.c_str(),
152  fp.version_, fp.tag_.c_str(), fp.run_, fp.lumi_,
153  fp.child_.c_str());
154  } else {
155  snprintf(buf, 256, "%s_V%04d_%s_R%09ld%s", fp.producer_.c_str(), fp.version_,
156  fp.tag_.c_str(), fp.run_, fp.child_.c_str());
157  }
158  buf[255] = 0;
159 
160  namespace fs = boost::filesystem;
161  fs::path path(fp.path_);
162  fs::path file(buf);
163 
164  return (path / file).string();
165 }
tuple path
else: Piece not in the list, fine.
void DQMFileSaverBase::fillDescription ( edm::ParameterSetDescription d)
static

Definition at line 280 of file DQMFileSaverBase.cc.

References edm::ParameterSetDescription::addUntracked(), dqm::qstatus::STATUS_OK, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by dqm::DQMFileSaverOnline::fillDescriptions().

280  {
281  desc.addUntracked<std::string>("tag", "UNKNOWN")
282  ->setComment("File tag, DQM_V000_<TAG>*, usually a subsytem name.");
283 
284  desc.addUntracked<std::string>("producer", "DQM")
285  ->setComment("Base prefix for files, <BASE>_V000_**, either 'DQM' or 'Playback'.");
286 
287  desc.addUntracked<std::string>("referenceHandling", "all")
288  ->setComment("saveReference_, passed to the DQMStore");
289 
290  desc.addUntracked<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK)
291  ->setComment("saveReference_, passed to the DQMStore");
292 
293  desc.addUntracked<std::string>("path", "./")->setComment(
294  "Output path prefix.");
295 }
static const int STATUS_OK
boost::property_tree::ptree DQMFileSaverBase::fillJson ( int  run,
int  lumi,
const std::string &  dataFilePathName,
const std::string  transferDestinationStr,
evf::FastMonitoringService fms 
)
staticprotected

Definition at line 169 of file DQMFileSaverBase.cc.

References data, edm::hlt::Exception, evf::FastMonitoringService::getEventsProcessedForLumi(), query::host, merge::inputFiles, cmsHarvester::path, sysUtil::pid, EnergyCorrector::pt, and AlCaHLTBitMon_QueryRunRegistry::string.

170 {
171  namespace bpt = boost::property_tree;
172  namespace bfs = boost::filesystem;
173 
174  bpt::ptree pt;
175 
176  int hostnameReturn;
177  char host[32];
178  hostnameReturn = gethostname(host ,sizeof(host));
179  if (hostnameReturn == -1)
180  throw cms::Exception("fillJson")
181  << "Internal error, cannot get host name";
182 
183  int pid = getpid();
184  std::ostringstream oss_pid;
185  oss_pid << pid;
186 
187  // Stat the data file: if not there, throw
188  struct stat dataFileStat;
189  if (stat(dataFilePathName.c_str(), &dataFileStat) != 0)
190  throw cms::Exception("fillJson")
191  << "Internal error, cannot get data file: "
192  << dataFilePathName;
193  // Extract only the data file name from the full path
194  std::string dataFileName = bfs::path(dataFilePathName).filename().string();
195  // The availability test of the FastMonitoringService was done in the ctor.
196  bpt::ptree data;
197  bpt::ptree processedEvents, acceptedEvents, errorEvents, bitmask, fileList, fileSize, inputFiles, fileAdler32, transferDestination;
198 
199  processedEvents.put("", fms ? (fms->getEventsProcessedForLumi(lumi)) : -1); // Processed events
200  acceptedEvents.put("", fms ? (fms->getEventsProcessedForLumi(lumi)) : -1); // Accepted events, same as processed for our purposes
201 
202  errorEvents.put("", 0); // Error events
203  bitmask.put("", 0); // Bitmask of abs of CMSSW return code
204  fileList.put("", dataFileName); // Data file the information refers to
205  fileSize.put("", dataFileStat.st_size); // Size in bytes of the data file
206  inputFiles.put("", ""); // We do not care about input files!
207  fileAdler32.put("", -1); // placeholder to match output json definition
208  transferDestination.put("", transferDestinationStr); // SM Transfer destination field
209 
210  data.push_back(std::make_pair("", processedEvents));
211  data.push_back(std::make_pair("", acceptedEvents));
212  data.push_back(std::make_pair("", errorEvents));
213  data.push_back(std::make_pair("", bitmask));
214  data.push_back(std::make_pair("", fileList));
215  data.push_back(std::make_pair("", fileSize));
216  data.push_back(std::make_pair("", inputFiles));
217  data.push_back(std::make_pair("", fileAdler32));
218  data.push_back(std::make_pair("", transferDestination));
219 
220  pt.add_child("data", data);
221 
222  if (fms == nullptr) {
223  pt.put("definition", "/fakeDefinition.jsn");
224  } else {
225  // The availability test of the EvFDaqDirector Service was done in the ctor.
226  bfs::path outJsonDefName(edm::Service<evf::EvFDaqDirector>()->baseRunDir()); //we assume this file is written bu the EvF Output module
227  outJsonDefName /= (std::string("output_") + oss_pid.str() + std::string(".jsd"));
228  pt.put("definition", outJsonDefName.string());
229  }
230 
231  char sourceInfo[64]; //host and pid information
232  sprintf(sourceInfo, "%s_%d", host, pid);
233  pt.put("source", sourceInfo);
234 
235  return pt;
236 }
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
tuple lumi
Definition: fjr2json.py:35
tuple path
else: Piece not in the list, fine.
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
const std::string DQMFileSaverBase::fillOrigin ( const std::string  filename,
const std::string  final_filename 
)
staticprotected

Definition at line 238 of file DQMFileSaverBase.cc.

References personalPlayback::fp, cond::hash, i, and dbtoconf::out.

Referenced by dqm::DQMFileSaverOnline::makeSnapshot().

239  {
240 
241  // format.origin (one line):
242  // md5:d566a34b27f48d507150a332b189398b 294835 final_filename.root
243 
244  unsigned char md5[MD5_DIGEST_LENGTH];
245 
246  boost::iostreams::mapped_file_source fp(filename);
247 
248  MD5((unsigned char *)fp.data(), fp.size(), md5);
249 
250  std::ostringstream hash;
251  for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) {
252  hash << std::hex << std::setfill('0') << std::setw(2) << (int)(md5[i]);
253  }
254 
255  std::ostringstream out;
256  out << "md5:" << hash.str() << " " << fp.size() << " " << final_filename;
257  return out.str();
258 }
int i
Definition: DBlmapReader.cc:9
static const std::string filename(FileParameters fp, bool useLumi=false)
tuple out
Definition: dbtoconf.py:99
std::shared_ptr< NoCache > DQMFileSaverBase::globalBeginLuminosityBlock ( const edm::LuminosityBlock l,
const edm::EventSetup  
) const
protectedvirtual

Definition at line 83 of file DQMFileSaverBase.cc.

84  {
85 
86  return nullptr;
87 }
std::shared_ptr< NoCache > DQMFileSaverBase::globalBeginRun ( const edm::Run r,
const edm::EventSetup  
) const
protectedvirtual

Definition at line 77 of file DQMFileSaverBase.cc.

78  {
79 
80  return nullptr;
81 }
void DQMFileSaverBase::globalEndLuminosityBlock ( const edm::LuminosityBlock iLS,
const edm::EventSetup  
) const
protectedvirtual

Definition at line 94 of file DQMFileSaverBase.cc.

References personalPlayback::fp, edm::LuminosityBlockBase::id(), initial_fp_, initial_fp_lock_, dqm::DQMFileSaverBase::FileParameters::lumi_, edm::LuminosityBlockID::luminosityBlock(), edm::LuminosityBlockID::run(), dqm::DQMFileSaverBase::FileParameters::run_, and saveLumi().

95  {
96  int ilumi = iLS.id().luminosityBlock();
97  int irun = iLS.id().run();
98 
99  std::unique_lock<std::mutex> lck(initial_fp_lock_);
100  FileParameters fp = initial_fp_;
101  lck.unlock();
102 
103  fp.lumi_ = ilumi;
104  fp.run_ = irun;
105 
107 
108  this->saveLumi(fp);
109 
110  store->markForDeletion(store->mtEnabled() ? irun : 0, ilumi);
111 }
LuminosityBlockID id() const
RunNumber_t run() const
LuminosityBlockNumber_t luminosityBlock() const
virtual void saveLumi(FileParameters fp) const
FileParameters initial_fp_
void DQMFileSaverBase::globalEndRun ( const edm::Run iRun,
const edm::EventSetup  
) const
protectedvirtual

Definition at line 113 of file DQMFileSaverBase.cc.

References personalPlayback::fp, edm::RunBase::id(), initial_fp_, initial_fp_lock_, edm::RunID::run(), dqm::DQMFileSaverBase::FileParameters::run_, and saveRun().

114  {
115 
116  std::unique_lock<std::mutex> lck(initial_fp_lock_);
117  FileParameters fp = initial_fp_;
118  lck.unlock();
119 
120  fp.run_ = iRun.id().run();
121 
122  // empty
123  this->saveRun(fp);
124 }
RunID const & id() const
Definition: RunBase.h:41
RunNumber_t run() const
Definition: RunID.h:39
FileParameters initial_fp_
virtual void saveRun(FileParameters fp) const
void DQMFileSaverBase::logFileAction ( const std::string &  msg,
const std::string &  fileName 
) const
protected
void DQMFileSaverBase::postForkReacquireResources ( unsigned int  childIndex,
unsigned int  numberOfChildren 
)
protectedvirtual

Reimplemented from edm::global::EDAnalyzerBase.

Definition at line 128 of file DQMFileSaverBase.cc.

References dqm::DQMFileSaverBase::FileParameters::child_, initial_fp_, initial_fp_lock_, and AlCaHLTBitMon_QueryRunRegistry::string.

129  {
130  // this is copied from IOPool/Output/src/PoolOutputModule.cc, for consistency
131  unsigned int digits = 0;
132  while (numberOfChildren != 0) {
133  ++digits;
134  numberOfChildren /= 10;
135  }
136  // protect against zero numberOfChildren
137  if (digits == 0) {
138  digits = 3;
139  }
140 
141  char buffer[digits + 2];
142  snprintf(buffer, digits + 2, "_F%0*d", digits, childIndex);
143 
144  std::unique_lock<std::mutex> lck(initial_fp_lock_);
145  initial_fp_.child_ = std::string(buffer);
146 }
FileParameters initial_fp_
void DQMFileSaverBase::saveJobReport ( const std::string &  filename) const
protected

Definition at line 260 of file DQMFileSaverBase.cc.

References info(), edm::Service< T >::isAvailable(), and edm::JobReport::reportAnalysisFile().

Referenced by dqm::DQMFileSaverOnline::makeSnapshot().

261 {
262  // Report the file to job report service.
264  if (jr.isAvailable())
265  {
266  std::map<std::string, std::string> info;
267  info["Source"] = "DQMStore";
268  info["FileClass"] = "DQM";
269  jr->reportAnalysisFile(filename, info);
270  }
271 
272 }
static const TGPicture * info(bool iBackgroundIsBlack)
static const std::string filename(FileParameters fp, bool useLumi=false)
bool isAvailable() const
Definition: Service.h:46
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:559
virtual void dqm::DQMFileSaverBase::saveLumi ( FileParameters  fp) const
inlineprotectedvirtual

Reimplemented in dqm::DQMFileSaverOnline.

Definition at line 65 of file DQMFileSaverBase.h.

Referenced by globalEndLuminosityBlock().

65 {};
virtual void dqm::DQMFileSaverBase::saveRun ( FileParameters  fp) const
inlineprotectedvirtual

Reimplemented in dqm::DQMFileSaverOnline.

Definition at line 66 of file DQMFileSaverBase.h.

Referenced by globalEndRun().

66 {};

Member Data Documentation

FileParameters dqm::DQMFileSaverBase::initial_fp_
protected
std::mutex dqm::DQMFileSaverBase::initial_fp_lock_
mutableprotected