All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMeVPrtlFlux.h
Go to the documentation of this file.
1 /**
2  * @file IMeVPrtlFlux.h
3  *
4  * @brief This is an interface for an art Tool which turns MCFlux objects (which
5  * is a meson decay to neutrinos) into a "Prtl" flux (a meson decay to a "Prtl"
6  * particle). It maps MCFlux to MeVPrtlFlux.
7  *
8  * @author grayputnam@uchicago.edu
9  *
10  */
11 #ifndef IMeVPrtlFlux_h
12 #define IMeVPrtlFlux_h
13 
14 // Framework Includes
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art/Framework/Principal/Event.h"
17 
18 #include "nusimdata/SimulationBase/MCFlux.h"
20 
21 // LArSoft includes
22 #include "nugen/EventGeneratorBase/GENIE/EvtTimeShiftFactory.h"
23 #include "nugen/EventGeneratorBase/GENIE/EvtTimeShiftI.h"
24 
25 #include "IMeVPrtlStage.h"
26 #include "Constants.h"
27 
28 // Algorithm includes
29 
30 //------------------------------------------------------------------------------------------------------------------------------------------
31 
32 namespace evgen
33 {
34 namespace ldm {
35 
36 /**
37  * @brief IMeVPrtlFlux interface class definiton
38  */
39 class IMeVPrtlFlux: virtual public IMeVPrtlStage
40 {
41 public:
42  /**
43  * @brief Virtual Destructor
44  */
45  virtual ~IMeVPrtlFlux() noexcept = default;
46 
47  virtual bool MakeFlux(const simb::MCFlux &mcflux, MeVPrtlFlux &flux, double &weight) = 0;
48 
49  IMeVPrtlFlux(const fhicl::ParameterSet &pset)
50  {
51  // rotation matrix
52  std::vector<double> rotation = pset.get<std::vector<double>>("Beam2DetectorRotation");
53  assert(rotation.size() == 9);
54  // get the three axes
55  TVector3 beam2DetX(rotation[0], rotation[3], rotation[6]);
56  TVector3 beam2DetY(rotation[1], rotation[4], rotation[7]);
57  TVector3 beam2DetZ(rotation[2], rotation[5], rotation[8]);
58 
59  fBeam2Det.RotateAxes(beam2DetX, beam2DetY, beam2DetZ);
60 
61  // beam origin
62  std::vector<double> origin = pset.get<std::vector<double>>("BeamOrigin");
63  assert(origin.size() == 3 || origin.size() == 6);
64  // beam origin specified in detector rotation-frame
65  if (origin.size() == 3) {
66  fBeamOrigin.SetXYZ(origin[0], origin[1], origin[2]);
67  }
68  // beam origin specified in beam rotation-frame
69  else if (origin.size() == 6) {
70  TVector3 userpos = TVector3(origin[0], origin[1], origin[2]);
71  TVector3 beampos = TVector3(origin[3], origin[4], origin[5]);
72  fBeamOrigin = userpos - fBeam2Det * beampos;
73  }
74 
75  // get random seed for stuff
76  unsigned seed = art::ServiceHandle<rndm::NuRandomService>()->getSeed();
77 
78  // use the time-shifting tools from GENIE
79  fTimeShiftMethod = NULL;
80  if (fSpillTimeConfig != "") {
81  fTimeShiftMethod = evgb::EvtTimeShiftFactory::Instance().GetEvtTimeShift(fSpillTimeConfig);
82  if ( fTimeShiftMethod ) {
83  if ( ! fTimeShiftMethod->IsRandomGeneratorSeeded() ) {
84  fTimeShiftMethod->GetRandomGenerator()->SetSeed(seed);
85  }
86  fTimeShiftMethod->PrintConfig();
87  }
88  else {
89  evgb::EvtTimeShiftFactory::Instance().Print();
90  }
91  }
92  if (fTimeShiftMethod) {
93  std::cout << "Timing Config:\n";
94  fTimeShiftMethod->PrintConfig();
95  std::cout << std::endl;
96  }
97  std::cout << "Neutrino TIF: " << (fBeamOrigin.Mag()/Constants::Instance().c_cm_per_ns) << std::endl;
98  }
99 
100 protected:
101  // derived stuff
102  evgb::EvtTimeShiftI *fTimeShiftMethod;
103  TRotation fBeam2Det;
104  TVector3 fBeamOrigin;
105  std::string fSpillTimeConfig;
106 
107  TLorentzVector BeamOrigin() {
108  double toff = fTimeShiftMethod ? fTimeShiftMethod->TimeOffset() : 0.;
109 
110  // TODO: what to do here? For now -- don't shift time at all
111  //
112  // subtract out the delay of neutrinos reaching the beam
113  // double neutrino_tif = fBeamOrigin.Mag()/Constants::Instance().c_cm_per_ns;
114  // toff -= neutrino_tif;
115  return TLorentzVector(fBeamOrigin, toff);
116  }
117 
118  // Compute the equivalent neutrino energy for a given parent meson position / momentum
119  double EnuLab(double enucm, TLorentzVector meson_mom, TLorentzVector meson_pos) { // all in detector coordinates
120  // Assume neutrino travels to center of detector
121  double costh = meson_mom.Vect().Unit().Dot(-meson_pos.Vect().Unit());
122 
123  // Scale factor
124  double M = 1. / (meson_mom.Gamma() * (1 - meson_mom.Beta() * costh));
125 
126  return M * enucm;
127  }
128 
129 };
130 
131 } // namespace ldm
132 } // namespace evgen
133 #endif
134 
IMeVPrtlFlux(const fhicl::ParameterSet &pset)
Definition: IMeVPrtlFlux.h:49
std::string fSpillTimeConfig
Definition: IMeVPrtlFlux.h:105
virtual bool MakeFlux(const simb::MCFlux &mcflux, MeVPrtlFlux &flux, double &weight)=0
unsigned int seed
IMeVPrtlStage interface class definiton. General interface behind each stage. Provides random number ...
Definition: IMeVPrtlStage.h:36
This provides an art tool interface definition for tools which can create fake particles to overlay o...
static const Constants & Instance()
Definition: Constants.h:68
TLorentzVector BeamOrigin()
Definition: IMeVPrtlFlux.h:107
double EnuLab(double enucm, TLorentzVector meson_mom, TLorentzVector meson_pos)
Definition: IMeVPrtlFlux.h:119
IMeVPrtlFlux interface class definiton.
Definition: IMeVPrtlFlux.h:39
evgb::EvtTimeShiftI * fTimeShiftMethod
Definition: IMeVPrtlFlux.h:102
BEGIN_PROLOG could also be cout
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
virtual ~IMeVPrtlFlux() noexcept=default
Virtual Destructor.