FileCatalogMetadataMPD_service.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Name: FileCatalogMetadataMPD_service.cc.
3 //
4 // Purpose: Art service adds MPD-specific per-job sam metadata.
5 //
6 // This service does not have user-callable methods. Simply
7 // add to an art configuration in services.user block of job
8 // file.
9 //
10 // MPD version based on DUNE version, 7 Nov 2019, T. Junk
11 // DUNE version Created: 3-Dec-2014, T. Yang
12 // Copied FileCatalogMetadataMicroBooNE_service.cc by H. Greenlee
13 //
14 ////////////////////////////////////////////////////////////////////////
15 
16 #include "FileCatalogMetadataMPD.h"
17 #include <stdlib.h>
18 
19  //--------------------------------------------------------------------
20  // Constructor.
21 
24  {
25  // Get parameters.
26 
27  fGenerators = pset.get<std::string>("Generators","");
28  fTriggerListVersion = pset.get<std::string>("TriggerListVersion","");
29  fBeamFluxID = pset.get<std::string>("BeamFluxID","");
30  fMCName = pset.get<std::string>("MCName","");
31  fNeutrinoFlavors = pset.get<std::string>("NeutrinoFlavors","");
32  fMiscellaneous = pset.get<std::string>("Miscellaneous","");
33  fGeometryVersion = pset.get<std::string>("GeometryVersion","");
34  fOverlay = pset.get<std::string>("Overlay","");
35  fRunType = pset.get<std::string>("run_type","");
36  fDataTier = pset.get<std::string>("data_tier","");
37  fApplName = pset.get<std::string>("ApplName","garsoft");
38  fEnvVarVer = pset.get<std::string>("EnvVarVer","GARSOFT_VERSION");
39  fHornPolarity = pset.get<std::string>("HornPolarity","");
40 
41  // Register for callbacks.
42 
44  }
45 
46  //--------------------------------------------------------------------
47  // PostBeginJob callback.
48  // Insert per-job metadata via FileCatalogMetadata service.
50  {
51  // Get art metadata service.
52 
54 
55  // Add metadata.
56 
57  if (fGenerators!="") mds->addMetadata("DUNE.Generators", fGenerators);
58  if (fGenerators!="") mds->addMetadata("DUNE_MC.Generators", fGenerators);
59  if (fTriggerListVersion!="") mds->addMetadata("DUNE_MC.trigger-list-version", fTriggerListVersion);
60  if (fBeamFluxID!="") mds->addMetadata("DUNE_MC.beam_flux_ID", fBeamFluxID);
61  if (fMCName!="") mds->addMetadata("DUNE_MC.name", fMCName);
62  if (fNeutrinoFlavors!="") mds->addMetadata("DUNE_MC_neutrino_flavors", fNeutrinoFlavors);
63  if (fMiscellaneous!="") mds->addMetadata("DUNE_MC.miscellaneous", fMiscellaneous);
64  if (fGeometryVersion!="") mds->addMetadata("DUNE_MC.GeometryVersion", fGeometryVersion);
65  if (fOverlay!="") mds->addMetadata("DUNE_MC.Overlay", fOverlay);
66  if (fSystematic!="") mds->addMetadata("DUNE_MC.Systematic", fSystematic);
67  if (fRunType!="") mds->addMetadata("run_type", fRunType);
68  if (fDataTier!="") mds->addMetadata("data_tier", fDataTier); // e.g. "reco"
69  if (fApplName!="") mds->addMetadata("application.family", fApplName); // e.g. "garsoft"
70  if (fDataTier!="") mds->addMetadata("application.name", fDataTier); // e.g. "reco"
71  if (fEnvVarVer!="") mds->addMetadata("application.version", getenv(fEnvVarVer.c_str()));
72  if (fHornPolarity!="") mds->addMetadata("DUNE_MC.HornPolarity", fHornPolarity);
73  }
74 
GlobalSignal< detail::SignalResponseType::FIFO, void()> sPostBeginJob
std::string string
Definition: nybbler.cc:12
std::string getenv(std::string const &name)
Definition: getenv.cc:15
T get(std::string const &key) const
Definition: ParameterSet.h:271
FileCatalogMetadataMPD(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
#define DEFINE_ART_SERVICE(svc)
void addMetadata(std::string const &key, std::string const &value)