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
21 #include "fhiclcpp/types/Table.h"
22 #include "cetlib_except/exception.h"
23 namespace fhicl { class ParameterSet; }
24 
25 // art extensions
26 namespace rndm { class NuRandomService; }
27 #include "nurandom/RandomUtils/NuRandomService.h"
28 
29 // LArSoft includes
30 namespace geo { class Geometry; }
31 
32 // ROOT includes
33 #include "TLorentzVector.h"
34 
35 namespace evgen {
36 
38 
39  public:
40 
41  using Name = fhicl::Name;
43 
44  /// Collection of configuration parameters used to
45  /// determine the vertex location for each event
46  struct Config {
48  Name("type"),
49  Comment("Technique used to choose vertex locations"),
50  "sampled" // default value
51  };
52 
54  Name("seed"),
55  Comment("Seed used for sampling vertex locations"),
56  [this]() -> bool { return type_() != "fixed"; }
57  };
58 
60  Name("position"),
61  Comment("Coordinates of the fixed vertex position"),
62  [this]() -> bool { return type_() == "fixed"; }
63  };
64 
66  Name("min_position"),
67  Comment("The minimum allowed values for the x, y, and z coordinates"),
68  [this]() -> bool { return type_() == "box"; }
69  };
70 
72  Name("max_position"),
73  Comment("The maximum allowed values for the x, y, and z coordinates"),
74  [this]() -> bool { return type_() == "box"; }
75  };
76 
77  fhicl::OptionalAtom<bool> check_active_ {
78  Name("check_active"),
79  Comment("Whether to enforce that the sampled vertices are within a TPC"
80  " active volume"),
81  [this]() -> bool { return type_() == "box"; }
82  };
83 
84  }; // struct Config
85 
86  enum class vertex_type_t { kSampled, kFixed, kBox };
87 
88  // Configuration-checking constructors
90  rndm::NuRandomService& rand_service, const geo::Geometry& geom,
91  const std::string& generator_name);
92 
94  rndm::NuRandomService& rand_service, const geo::Geometry& geom,
95  const std::string& generator_name)
96  : ActiveVolumeVertexSampler(fhicl::Table<Config>(pset, {}),
97  rand_service, geom, generator_name) {}
98 
99  void reconfigure(const fhicl::Table<Config>& conf,
100  const geo::Geometry& geom);
101 
102  // Function that selects a primary vertex location for each event.
103  // TODO: add time sampling
104  TLorentzVector sample_vertex_pos(const geo::Geometry& geom);
105 
106  protected:
107 
108  // Currently sampled vertex position (doesn't change value if the vertex
109  // is fixed)
110  TLorentzVector fVertexPosition;
111 
113 
115 
116  // Discrete distribution object used to sample TPCs based on their active
117  // masses
118  std::unique_ptr<std::discrete_distribution<size_t> > fTPCDist;
119 
120  // RNG object used to sample TPCs
121  std::mt19937_64 fTPCEngine;
122 
123  // Helper variables used only for "box" sampling mode
124  double fXmin;
125  double fYmin;
126  double fZmin;
127 
128  double fXmax;
129  double fYmax;
130  double fZmax;
131 
133 
134  }; // class evgen::ActiveVolumeVertexSampler
135 
136 } // namespace evgen
137 
138 #endif
std::string string
Definition: nybbler.cc:12
vertex position fixed manually - no fitting done
Definition: DataStructs.h:95
ChannelGroupService::Name Name
Definition: conf.py:1
virtual void reconfigure(fhicl::ParameterSet const &pset)
The geometry of one entire detector, as served by art.
Definition: Geometry.h:196
#define Comment
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)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
Event Generation using GENIE, cosmics or single particles.