All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MetadataSBN.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Name: MetadataSBN.h
3 //
4 // A struct datatype to hold the metadata information as it is extracted
5 // from various places.
6 //
7 // Created: 21-Feb-2017, D. Brailsford
8 // Based on the DUNE version T. Junk which is based on the MicroBooNE
9 // version by S. Gollapinni
10 //
11 ////////////////////////////////////////////////////////////////////////
12 #ifndef TFILEMETADATASBN_H
13 #define TFILEMETADATASBN_H
14 
15 #include "art/Framework/Services/Registry/ActivityRegistry.h"
16 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
17 #include "art/Framework/Principal/fwd.h"
18 #include "art/Framework/IO/PostCloseFileRenamer.h"
19 #include "art/Framework/IO/FileStatsCollector.h"
20 #include "art/Persistency/Provenance/ScheduleContext.h"
21 #include "canvas/Persistency/Provenance/IDNumber.h"
22 #include "fhiclcpp/ParameterSet.h"
23 
24 #include <fstream>
25 #include <set>
26 #include <string>
27 #include <tuple>
28 #include <vector>
29 
30 namespace util{
31 
33  {
34  public:
35  MetadataSBN(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg);
36 
37  struct metadata {
38  std::tuple<std::string, std::string, std::string> fapplication;
39  //no crc information yet
40  //std::vector<std::string> fcrcs;
41  std::string fdata_tier;
42  time_t fend_time;
43  unsigned int fevent_count=0;
44  std::string ffile_format;
45  std::string ffile_type;
46  art::EventNumber_t ffirst_event=0;
47  std::string fgroup;
48  art::EventNumber_t flast_event=0;
49  std::set<std::string> fParents;
50  std::vector<std::tuple<art::RunNumber_t,art::SubRunNumber_t,std::string>> fruns;
51  time_t fstart_time=0;
52  std::string fFCLName;
53  std::string fProjectName;
54  std::string fProjectStage;
55  std::string fProjectVersion;
56  std::string fProjectSoftware;
57  std::string fProductionName; //Production parameter, do not use if not running a production
58  std::string fProductionType; //Production parameter, do not use if not running a production
59  int merge;
60  double fTotPOT=0.;
61  };
62 
64  std::set<art::SubRunID> fSubRunNumbers;
65 
66  void GetMetadataMaps(std::map<std::string, std::string>& strs,
67  std::map<std::string, int>& ints,
68  std::map<std::string, double>& doubles,
69  std::map<std::string, std::string>& objs);
70 
71  private:
72 
73  // Callbacks.
74  void postBeginJob();
75  void postOpenInputFile(std::string const& fn);
76  void postEvent(art::Event const& ev, art::ScheduleContext);
77  void postBeginSubRun(art::SubRun const& subrun);
78  void postEndSubRun(art::SubRun const& subrun);
79  void postCloseInputFile();
80 
81  std::string GetParentsString() const;
82  std::string GetRunsString() const;
83 
84  std::map<std::string,std::string> mdmapStr;
85  std::map<std::string, int> mdmapInt;
86  std::map<std::string, double> mdmapDouble;
87  std::map<std::string, std::string> mdmapObj;
88 
89  // Fcl parameters.
90  std::string fExperiment;
91  std::string frunType;
92  std::vector<std::string> fJSONFileName;
93  std::vector<std::string> fDataTier;
94  std::vector<std::string> fFileFormat;
95  std::vector<int> fMerge;
96  std::string fPOTModuleLabel;
97  art::FileStatsCollector fFileStats;
98  art::PostCloseFileRenamer fRenamer{fFileStats};
99  }; // class MetadataSBN
100 
101 } //namespace utils
102 
103 DECLARE_ART_SERVICE(util::MetadataSBN, LEGACY)
104 
105 #endif
void GetMetadataMaps(std::map< std::string, std::string > &strs, std::map< std::string, int > &ints, std::map< std::string, double > &doubles, std::map< std::string, std::string > &objs)
art::PostCloseFileRenamer fRenamer
Definition: MetadataSBN.h:98
std::vector< std::string > fFileFormat
Definition: MetadataSBN.h:94
std::string fPOTModuleLabel
Definition: MetadataSBN.h:96
std::set< art::SubRunID > fSubRunNumbers
Definition: MetadataSBN.h:64
void postEndSubRun(art::SubRun const &subrun)
void postEvent(art::Event const &ev, art::ScheduleContext)
std::map< std::string, double > mdmapDouble
Definition: MetadataSBN.h:86
std::vector< int > fMerge
Definition: MetadataSBN.h:95
std::string fExperiment
Definition: MetadataSBN.h:90
art::FileStatsCollector fFileStats
Definition: MetadataSBN.h:97
void postOpenInputFile(std::string const &fn)
std::vector< std::string > fJSONFileName
Definition: MetadataSBN.h:92
MetadataSBN(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
std::tuple< std::string, std::string, std::string > fapplication
Definition: MetadataSBN.h:38
std::vector< std::string > fDataTier
Definition: MetadataSBN.h:93
std::vector< std::tuple< art::RunNumber_t, art::SubRunNumber_t, std::string > > fruns
Definition: MetadataSBN.h:50
std::map< std::string, std::string > mdmapStr
Definition: MetadataSBN.h:84
std::map< std::string, int > mdmapInt
Definition: MetadataSBN.h:85
void postBeginSubRun(art::SubRun const &subrun)
std::string frunType
Definition: MetadataSBN.h:91
std::string GetParentsString() const
art::EventNumber_t ffirst_event
Definition: MetadataSBN.h:46
std::set< std::string > fParents
Definition: MetadataSBN.h:49
std::map< std::string, std::string > mdmapObj
Definition: MetadataSBN.h:87
std::string GetRunsString() const
art::EventNumber_t flast_event
Definition: MetadataSBN.h:48