All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ActiveVolumeVertexSampler.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 /// \file ActiveVolumeVertexSampler.h
3 /// \brief Algorithm that samples vertex locations uniformly within the
4 /// active volume of a detector. It is fully experiment-agnostic and multi-TPC
5 /// aware.
6 ///
7 /// \author Steven Gardiner <sjgardiner@ucdavis.edu>
8 //////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef LARSIM_ALGORITHMS_ACTIVEVOLUMEVERTEXSAMPLER_H
11 #define LARSIM_ALGORITHMS_ACTIVEVOLUMEVERTEXSAMPLER_H
12 
13 // standard library includes
14 #include <memory>
15 #include <random>
16 #include <string>
17 
18 // framework includes
19 #include "fhiclcpp/types/Atom.h"
20 #include "fhiclcpp/types/Comment.h"
21 #include "fhiclcpp/types/Name.h"
22 #include "fhiclcpp/types/OptionalAtom.h"
23 #include "fhiclcpp/types/Sequence.h"
24 #include "fhiclcpp/types/Table.h"
25 namespace fhicl { class ParameterSet; }
26 
27 // art extensions
28 namespace rndm { class NuRandomService; }
29 
30 // LArSoft includes
31 namespace geo { class Geometry; }
32 
33 // ROOT includes
34 #include "TLorentzVector.h"
35 
36 namespace evgen {
37 
39 
40  public:
41 
42  using Name = fhicl::Name;
43  using Comment = fhicl::Comment;
44 
45  /// Collection of configuration parameters used to
46  /// determine the vertex location for each event
47  struct Config {
48  fhicl::Atom<std::string> type_ {
49  Name("type"),
50  Comment("Technique used to choose vertex locations"),
51  "sampled" // default value
52  };
53 
54  fhicl::OptionalAtom<std::string> seed_ {
55  Name("seed"),
56  Comment("Seed used for sampling vertex locations"),
57  [this]() -> bool { return type_() != "fixed"; }
58  };
59 
60  fhicl::Sequence<double, 3> position_ {
61  Name("position"),
62  Comment("Coordinates of the fixed vertex position"),
63  [this]() -> bool { return type_() == "fixed"; }
64  };
65 
66  fhicl::Sequence<double, 3> min_position_ {
67  Name("min_position"),
68  Comment("The minimum allowed values for the x, y, and z coordinates"),
69  [this]() -> bool { return type_() == "box"; }
70  };
71 
72  fhicl::Sequence<double, 3> max_position_ {
73  Name("max_position"),
74  Comment("The maximum allowed values for the x, y, and z coordinates"),
75  [this]() -> bool { return type_() == "box"; }
76  };
77 
78  fhicl::OptionalAtom<bool> check_active_ {
79  Name("check_active"),
80  Comment("Whether to enforce that the sampled vertices are within a TPC"
81  " active volume"),
82  [this]() -> bool { return type_() == "box"; }
83  };
84 
85  }; // struct Config
86 
87  enum class vertex_type_t { kSampled, kFixed, kBox };
88 
89  // Configuration-checking constructors
90  ActiveVolumeVertexSampler(const fhicl::Table<Config>& conf,
91  rndm::NuRandomService& rand_service, const geo::Geometry& geom,
92  const std::string& generator_name);
93 
94  ActiveVolumeVertexSampler(const fhicl::ParameterSet& pset,
95  rndm::NuRandomService& rand_service, const geo::Geometry& geom,
96  const std::string& generator_name)
97  : ActiveVolumeVertexSampler(fhicl::Table<Config>(pset, {}),
99 
100  void reconfigure(const fhicl::Table<Config>& conf,
101  const geo::Geometry& geom);
102 
103  // Function that selects a primary vertex location for each event.
104  // TODO: add time sampling
105  TLorentzVector sample_vertex_pos(const geo::Geometry& geom);
106 
107  protected:
108 
109  // Currently sampled vertex position (doesn't change value if the vertex
110  // is fixed)
111  TLorentzVector fVertexPosition;
112 
114 
115  std::string fGeneratorName;
116 
117  // Discrete distribution object used to sample TPCs based on their active
118  // masses
119  std::unique_ptr<std::discrete_distribution<size_t> > fTPCDist;
120 
121  // RNG object used to sample TPCs
122  std::mt19937_64 fTPCEngine;
123 
124  // Helper variables used only for "box" sampling mode
125  double fXmin;
126  double fYmin;
127  double fZmin;
128 
129  double fXmax;
130  double fYmax;
131  double fZmax;
132 
134 
135  }; // class evgen::ActiveVolumeVertexSampler
136 
137 } // namespace evgen
138 
139 #endif
TLorentzVector sample_vertex_pos(const geo::Geometry &geom)
for pfile in ack l reconfigure(.*) override"` do echo "checking $
ActiveVolumeVertexSampler(const fhicl::Table< Config > &conf, rndm::NuRandomService &rand_service, const geo::Geometry &geom, const std::string &generator_name)
BEGIN_PROLOG vertical distance to the surface Name
The geometry of one entire detector, as served by art.
Definition: Geometry.h:181
fhicl::OptionalAtom< std::string > seed_
std::unique_ptr< std::discrete_distribution< size_t > > fTPCDist
ActiveVolumeVertexSampler(const fhicl::ParameterSet &pset, rndm::NuRandomService &rand_service, const geo::Geometry &geom, const std::string &generator_name)