All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
util::FileCatalogMetadataSBN Class Reference

#include <FileCatalogMetadataSBN.h>

Public Member Functions

 FileCatalogMetadataSBN (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
 ~FileCatalogMetadataSBN ()=default
 
const std::string & GetFCLName () const
 
const std::string & GetProjectName () const
 
const std::string & GetProjectStage () const
 
const std::string & GetProjectVersion () const
 
const std::string & GetProjectSoftware () const
 
const std::string & GetProductionName () const
 
const std::string & GetProductionType () const
 
int GetMerge () const
 
const std::vector< std::pair
< std::string, std::string > > & 
GetParameters () const
 

Private Member Functions

void postBeginJob ()
 
void postEndSubRun (art::SubRun const &subrun)
 
void preCloseOutputFile (const std::string &label)
 

Private Attributes

std::string fExperiment
 
std::string fFCLName
 
std::string fProjectName
 
std::string fProjectStage
 
std::string fProjectVersion
 
std::string fProjectSoftware
 
std::string fProductionName
 
std::string fProductionType
 
int fMerge
 
std::vector< std::pair
< std::string, std::string > > 
fParameters
 
std::string fPOTModuleLabel
 
double fTotPOT
 

Detailed Description

Definition at line 44 of file FileCatalogMetadataSBN.h.

Constructor & Destructor Documentation

util::FileCatalogMetadataSBN::FileCatalogMetadataSBN ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry &  reg 
)

Definition at line 24 of file FileCatalogMetadataSBN_service.cc.

24  :
25  fTotPOT(0.)
26 {
27  // Insist on configuring Experiment from the fcl file (ideally) or the
28  // environment.
29  const char* expt = getenv("EXPERIMENT");
30  if(expt) fExperiment = pset.get<std::string>("Experiment", expt); else fExperiment = pset.get<std::string>("Experiment");
31  std::transform(fExperiment.begin(), fExperiment.end(), fExperiment.begin(), [](unsigned char c){return std::tolower(c);});
32 
33  // Get parameters.
34 
35  fFCLName = pset.get<std::string>("FCLName");
36  fProjectName = pset.get<std::string>("ProjectName");
37  fProjectStage = pset.get<std::string>("ProjectStage");
38  fProjectVersion = pset.get<std::string>("ProjectVersion");
39  fProjectSoftware = pset.get<std::string>("ProjectSoftware","");
40  fProductionName = pset.get<std::string>("ProductionName",""); //Leave as default value if not running a production
41  fProductionType = pset.get<std::string>("ProductionType",""); //Leave as default value if not running a production
42  fMerge = pset.get<int>("Merge", -1);
43  fParameters = pset.get<std::vector<std::pair<std::string, std::string>>>("Parameters", std::vector<std::pair<std::string, std::string>>());
44  fPOTModuleLabel = pset.get<std::string>("POTModuleLabel", "generator");
45 
46  // Register for callbacks.
47 
48  reg.sPostBeginJob.watch(this, &FileCatalogMetadataSBN::postBeginJob);
49  reg.sPostEndSubRun.watch(this, &FileCatalogMetadataSBN::postEndSubRun);
50  reg.sPreCloseOutputFile.watch(this, &FileCatalogMetadataSBN::preCloseOutputFile);
51 }
static constexpr Sample_t transform(Sample_t sample)
std::vector< std::pair< std::string, std::string > > fParameters
void preCloseOutputFile(const std::string &label)
void postEndSubRun(art::SubRun const &subrun)
util::FileCatalogMetadataSBN::~FileCatalogMetadataSBN ( )
default

Member Function Documentation

const std::string& util::FileCatalogMetadataSBN::GetFCLName ( ) const
inline

Definition at line 55 of file FileCatalogMetadataSBN.h.

55 {return fFCLName;}
int util::FileCatalogMetadataSBN::GetMerge ( ) const
inline

Definition at line 62 of file FileCatalogMetadataSBN.h.

const std::vector<std::pair<std::string, std::string> >& util::FileCatalogMetadataSBN::GetParameters ( ) const
inline

Definition at line 63 of file FileCatalogMetadataSBN.h.

63 {return fParameters;}
std::vector< std::pair< std::string, std::string > > fParameters
const std::string& util::FileCatalogMetadataSBN::GetProductionName ( ) const
inline

Definition at line 60 of file FileCatalogMetadataSBN.h.

const std::string& util::FileCatalogMetadataSBN::GetProductionType ( ) const
inline

Definition at line 61 of file FileCatalogMetadataSBN.h.

const std::string& util::FileCatalogMetadataSBN::GetProjectName ( ) const
inline

Definition at line 56 of file FileCatalogMetadataSBN.h.

const std::string& util::FileCatalogMetadataSBN::GetProjectSoftware ( ) const
inline

Definition at line 59 of file FileCatalogMetadataSBN.h.

const std::string& util::FileCatalogMetadataSBN::GetProjectStage ( ) const
inline

Definition at line 57 of file FileCatalogMetadataSBN.h.

const std::string& util::FileCatalogMetadataSBN::GetProjectVersion ( ) const
inline

Definition at line 58 of file FileCatalogMetadataSBN.h.

void util::FileCatalogMetadataSBN::postBeginJob ( )
private

Definition at line 56 of file FileCatalogMetadataSBN_service.cc.

57 {
58  // Get art metadata service.
59 
60  art::ServiceHandle<art::FileCatalogMetadata> mds;
61 
62  // Add metadata.
63 
64  mds->addMetadata("fcl.name", fFCLName);
65  mds->addMetadata(fExperiment + "_project.name", fProjectName);
66  mds->addMetadata(fExperiment + "_project.stage", fProjectStage);
67  mds->addMetadata(fExperiment + "_project.version", fProjectVersion);
68  mds->addMetadata(fExperiment + "_project.software", fProjectSoftware);
69  mds->addMetadata("production.name", fProductionName);
70  mds->addMetadata("production.type", fProductionType);
71  std::ostringstream ostr;
72  if(fMerge >= 0) {
73  if(fMerge > 0)
74  mds->addMetadata("merge.merge", "1");
75  else
76  mds->addMetadata("merge.merge", "0");
77  mds->addMetadata("merge.merged", "0");
78  }
79  for(auto const& param : fParameters)
80  mds->addMetadata(param.first, param.second);
81 }
std::vector< std::pair< std::string, std::string > > fParameters
void util::FileCatalogMetadataSBN::postEndSubRun ( art::SubRun const &  subrun)
private

Definition at line 85 of file FileCatalogMetadataSBN_service.cc.

86 {
87 
88  art::ServiceHandle<art::FileCatalogMetadata> mds;
89 
90  art::Handle< sumdata::POTSummary > potListHandle;
91  if(sr.getByLabel(fPOTModuleLabel,potListHandle)){
92  fTotPOT+=potListHandle->totpot;}
93 }
void util::FileCatalogMetadataSBN::preCloseOutputFile ( const std::string &  label)
private

Definition at line 96 of file FileCatalogMetadataSBN_service.cc.

97 {
98 
99  art::ServiceHandle<art::FileCatalogMetadata> mds;
100 
101  if(fTotPOT > 0.) {
102  std::ostringstream streamObj;
103  streamObj << fTotPOT;
104  std::string strPOT = streamObj.str();
105  mds->addMetadata("mc.pot", strPOT);
106  }
107  fTotPOT = 0.;
108 }

Member Data Documentation

std::string util::FileCatalogMetadataSBN::fExperiment
private

Definition at line 75 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fFCLName
private

Definition at line 76 of file FileCatalogMetadataSBN.h.

int util::FileCatalogMetadataSBN::fMerge
private

Definition at line 83 of file FileCatalogMetadataSBN.h.

std::vector<std::pair<std::string, std::string> > util::FileCatalogMetadataSBN::fParameters
private

Definition at line 84 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fPOTModuleLabel
private

Definition at line 85 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProductionName
private

Definition at line 81 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProductionType
private

Definition at line 82 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProjectName
private

Definition at line 77 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProjectSoftware
private

Definition at line 80 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProjectStage
private

Definition at line 78 of file FileCatalogMetadataSBN.h.

std::string util::FileCatalogMetadataSBN::fProjectVersion
private

Definition at line 79 of file FileCatalogMetadataSBN.h.

double util::FileCatalogMetadataSBN::fTotPOT
private

Definition at line 86 of file FileCatalogMetadataSBN.h.


The documentation for this class was generated from the following files: