All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMeVPrtlStage.h
Go to the documentation of this file.
1 /**
2  * @file IMeVPrtlStage.h
3  *
4  * @brief This provides an art tool interface definition for tools which can create
5  * fake particles to overlay onto input daq fragments during decoding
6  *
7  * @author grayputnam@uchicago.edu
8  *
9  */
10 #ifndef IMeVPrtlStage_h
11 #define IMeVPrtlStage_h
12 
13 // Framework Includes
14 #include "fhiclcpp/ParameterSet.h"
15 #include "art/Framework/Principal/Event.h"
16 
17 // Algorithm includes
18 #include "nurandom/RandomUtils/NuRandomService.h"
19 #include "CLHEP/Random/JamesRandom.h"
20 #include "CLHEP/Random/RandFlat.h"
21 
22 #include "TVector3.h"
23 
24 #include <utility>
25 #include <string>
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
29 namespace evgen
30 {
31 namespace ldm {
32 /**
33  * @brief IMeVPrtlStage interface class definiton. General interface behind each
34  * stage. Provides random number generation.
35  */
37 {
38 public:
39  /**
40  * @brief Virtual Destructor
41  */
42  virtual ~IMeVPrtlStage() noexcept {
43  if (fEngine) delete fEngine;
44  }
45 
46  IMeVPrtlStage(const char * name) {
47  // setup the random number engine
48  art::ServiceHandle<rndm::NuRandomService> seedSvc;
49  fEngine = new CLHEP::HepJamesRandom;
50  seedSvc->registerEngine(rndm::NuRandomService::CLHEPengineSeeder(fEngine), name);
51  fName = name;
52  }
53 
54  /**
55  * @brief Interface for configuring the particular algorithm tool
56  *
57  * @param ParameterSet The input set of parameters for configuration
58  */
59  virtual void configure(const fhicl::ParameterSet&) = 0;
60 
61  virtual double MaxWeight() = 0;
62 
63  // useful helper function
64  TVector3 RandomUnitVector() {
65  // In order to pick a random point on a sphere -- pick a random value of _costh_, __not__ theta
66  // b.c. d\Omega = d\phi dcos\theta, i.e. d\Omega != d\phi d\theta
67  double costheta = CLHEP::RandFlat::shoot(fEngine, -1, 1);
68  double sintheta = sqrt(1. - costheta * costheta);
69  double phi = CLHEP::RandFlat::shoot(fEngine, 0, 2*M_PI);
70  return TVector3(sintheta * cos(phi), sintheta * sin(phi), costheta);
71  }
72  double GetRandom() {
73  return CLHEP::RandFlat::shoot(fEngine);
74  }
75 
76  const char *Name() { return fName; }
77 
78 protected:
79  CLHEP::HepRandomEngine* fEngine;
80  const char *fName;
81 };
82 
83 } // namespace ldm
84 } // namespace evgen
85 #endif
86 
CLHEP::HepRandomEngine * fEngine
Definition: IMeVPrtlStage.h:79
virtual double MaxWeight()=0
IMeVPrtlStage interface class definiton. General interface behind each stage. Provides random number ...
Definition: IMeVPrtlStage.h:36
virtual ~IMeVPrtlStage() noexcept
Virtual Destructor.
Definition: IMeVPrtlStage.h:42
virtual void configure(const fhicl::ParameterSet &)=0
Interface for configuring the particular algorithm tool.
then echo fcl name
IMeVPrtlStage(const char *name)
Definition: IMeVPrtlStage.h:46