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