GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimpleHNL.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 /*!
3 
4  Class for the HNL itself
5 
6 \namespace genie::hnl
7 
8 \class genie::hnl::SimpleHNL
9 
10 \brief HNL object
11 
12 \author John Plows <komninos-john.plows@physics.ox.ac.uk>
13 
14 \created December 10th, 2021
15 
16 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
17  For the full text of the license visit http://copyright.genie-mc.org
18 
19 */
20 //----------------------------------------------------------------------------
21 
22 #ifndef _SIMPLEHNL_H_
23 #define _SIMPLEHNL_H_
24 
28 
31 
32 namespace genie {
33 
34  namespace hnl {
35 
36  class SimpleHNL
37  {
38  public:
39  inline SimpleHNL( std::string name, int index ) :
40  fName( name ), fIndex( index ),
43  fIsMajorana( false ),
45  genie::hnl::selector::GetValidChannelWidths( defMass,
47  false ) ),
49  genie::hnl::selector::CalcCoMLifetime( defMass,
51  false ) )
52  { } /// default c'tor
53 
54  inline SimpleHNL(
55  std::string name, int index,
56  const int PDG, const int parPDG, const double mass,
57  const double Ue42, const double Umu42, const double Ut42,
58  const bool IsMajorana
59  ) : fName( name ), fIndex( index ),
60  fPDG( PDG ), fParentPDG( parPDG ), fMass( mass ),
61  fUe42( Ue42 ), fUmu42( Umu42 ), fUt42( Ut42 ),
62  fIsMajorana( IsMajorana ),
64  genie::hnl::selector::GetValidChannelWidths( mass,
65  Ue42, Umu42, Ut42,
66  IsMajorana ) ),
68  genie::hnl::selector::CalcCoMLifetime( mass,
69  Ue42, Umu42, Ut42,
70  IsMajorana ) )
71  { LOG("HNL", pDEBUG) << "SimpleHNL built"; } /// normal constructor
72 
73  inline ~SimpleHNL( ) { }
74 
75  // Getters
76 
77  inline std::string GetName( ) { return fName; }
78 
79  inline int GetIndex( ) { return fIndex; }
80 
81  inline double GetMass( ) { return fMass; }
82 
83  inline std::vector< double > GetCouplings( ) {
84  std::vector< double > coupVec;
85  coupVec.emplace_back( fUe42 );
86  coupVec.emplace_back( fUmu42 );
87  coupVec.emplace_back( fUt42 );
88  return coupVec; }
89 
90  inline bool GetIsMajorana( ) { return fIsMajorana; }
91 
92  inline double GetBeta( ) { return fBeta; }
93 
94  inline double GetGamma( ) { return fGamma; }
95 
96  inline double GetCoMLifetime( ) { return fCoMLifetime; }
97 
98  inline double GetLifetime( ) { /* return fLifetime; */
99  return CalcLifetime( fGamma ); }
100 
101  inline int GetPDG( ) { return fPDG; }
102 
103  inline int GetParentPDG( ) { return fParentPDG; }
104 
105  inline double GetDecayThrow( ) { return fDecayThrow; }
106 
107  inline double GetSelectThrow( ) { return fSelectThrow; }
108 
110 
111  inline std::vector< double > GetDecay4VX( ) {
112  std::vector< double > decVec;
113  decVec.emplace_back(fT);
114  decVec.emplace_back(fX);
115  decVec.emplace_back(fY);
116  decVec.emplace_back(fZ);
117  return decVec; }
118 
119  inline std::vector< double > GetOrigin4VX( ) {
120  std::vector< double > oriVec;
121  oriVec.emplace_back(fT0);
122  oriVec.emplace_back(fX0);
123  oriVec.emplace_back(fY0);
124  oriVec.emplace_back(fZ0);
125  return oriVec; }
126 
127  inline std::vector< double > Get4VP( ) {
128  std::vector< double > momVec;
129  momVec.emplace_back(fE);
130  momVec.emplace_back(fPx);
131  momVec.emplace_back(fPy);
132  momVec.emplace_back(fPz);
133  return momVec; }
134 
135  inline std::vector< double > GetBetaVec( ) {
136  std::vector< double > betaVec;
137  const double mom = GetMomentum( );
138  const int pxMod = ( fPx < 0.0 ) ? -1 : 1;
139  const int pyMod = ( fPy < 0.0 ) ? -1 : 1;
140  const int pzMod = ( fPz < 0.0 ) ? -1 : 1;
141  betaVec.emplace_back( pxMod * fPx / fE * fPx / mom );
142  betaVec.emplace_back( pyMod * fPy / fE * fPy / mom );
143  betaVec.emplace_back( pzMod * fPz / fE * fPz / mom );
144  return betaVec; }
145 
146  inline double GetMomentum( ) {
147  return fPmag;
148  }
149 
150  inline double GetPolarisationMag( ) { return fPol; }
151  inline std::vector< double > * GetPolarisationDir( ) {
152  return fPolDir; }
153 
154  inline std::map< genie::hnl::HNLDecayMode_t, double > GetValidChannels( ) {
155  return fValidChannels; }
156 
157  inline std::map< genie::hnl::HNLDecayMode_t, double > GetInterestingChannels( ) {
158  return fInterestingChannels; }
159 
160  inline std::vector< genie::hnl::HNLDecayMode_t > GetInterestingChannelsVec( ) {
161  return fInterestingChannelsVec; }
162 
163  inline int GetType( ) { return fType; }
164 
165  inline double GetAngularDeviation( ) { return fAngularDeviation; }
166 
167  inline std::vector<double> GetBeam2UserTranslation( ) {
168  std::vector<double> tVec = { fTx, fTy, fTz };
169  return tVec;
170  }
171 
172  inline std::vector<double> GetBeam2UserRotation( ) {
173  std::vector<double> rVec = { fR1, fR2, fR3 };
174  return rVec;
175  }
176 
177  // setters
178 
179  inline void SetName( const std::string name ) { fName = name; }
180 
181  inline void SetIndex( const int idx ) { fIndex = idx; }
182 
183  inline void SetEnergy( const double E ) {
184  // updates beta, gamma, 4P, lifetime. Doesn't change angles.
185  if( E < fMass ) { LOG( "HNL", pERROR ) <<
186  "genie::hnl::SimpleHNL:: Set E too low." <<
187  "\nE = " << E << ", M = " << fMass; exit(3); }
188  double mom3 = std::sqrt( E*E - fMass*fMass );
189  __attribute__((unused)) double oldmom = GetMomentum( );
190  fPmag = mom3;
191  fPx = mom3 / std::sqrt(3.0); fPy = mom3 / std::sqrt(3.0); fPz = mom3 / std::sqrt(3.0);
192  fE = E;
193  fBeta = CalcBeta( E, mom3 );
194  fGamma = CalcGamma( fBeta );
195  fLifetime = fCoMLifetime / ( fGamma * ( 1.0 + fBeta ) );
196  }
197 
198  inline void SetBeta( const double bet ) {
199  fBeta = bet;
200  fGamma = CalcGamma( bet );
201  fE = fGamma * fMass;
202  double oldmom = fPmag;
203  fPmag = std::sqrt( fE*fE - fMass*fMass );
204 
205  fPx *= fPmag / oldmom; fPy *= fPmag / oldmom; fPz *= fPmag / oldmom;
206 
207  fLifetime = fCoMLifetime / ( fGamma * ( 1.0 + bet ) );
208  }
209 
210  inline void SetMomentumAngles( double theta, double phi ) {
211  /// does not change magnitude
212  // bring angles into [0,\pi]*[0,2\pi)
213  if( std::abs( theta ) > genie::constants::kPi ) {
214  const int nabs = std::floor( std::abs( theta ) / genie::constants::kPi );
215  theta += ( theta < 0 ) ? nabs * genie::constants::kPi : -nabs * genie::constants::kPi; }
216  if( std::abs( phi ) > 2.0 * genie::constants::kPi ) {
217  const int nabs = std::floor( std::abs( phi ) / ( 2.0 * genie::constants::kPi ) );
218  phi += ( phi < 0 ) ? nabs * 2.0 * genie::constants::kPi : -nabs * 2.0 * genie::constants::kPi; }
219  phi += ( phi < 0 ) ? 2.0 * genie::constants::kPi : 0.0;
220 
221  if( theta < 0 ){
223  theta *= -1.0; phi += ap;
224  }
225 
226  fPx = fPmag * std::sin( theta ) * std::cos( phi );
227  fPy = fPmag * std::sin( theta ) * std::sin( phi );
228  fPz = fPmag * std::cos( theta );
229  }
230 
231  inline void SetMomentumDirection( double ux, double uy, double uz ) {
232  /// does not change magnitude
233  if( ux == 0.0 && uy == 0.0 && uz == 0.0 ){
234  LOG( "HNL", pERROR ) <<
235  "genie::hnl::SimpleHNL::SetMomentumDirection:: " <<
236  "Zero vector entered. Exiting."; exit(3); }
237  const double umag = std::sqrt( ( ux*ux + uy*uy + uz*uz ) );
238  const double invu = 1.0 / umag;
239  ux *= invu; uy *= invu; uz *= invu;
240  fPx = fPmag * ux; fPy = fPmag * uy; fPz = fPmag * uz;
241  }
242 
243  inline void Set4Momentum( const std::vector< double > fourP ){
244  SetEnergy( fourP.at(0) ); // also takes care of Pmag
245  SetMomentumDirection( fourP.at(1), fourP.at(2), fourP.at(3) ); }
246 
247  inline void SetPolMag( const double pm ){
248  if( pm < -1.0 || pm > 1.0 ){
249  LOG( "HNL", pERROR ) <<
250  "genie::hnl::SimpleHNL::SetPolMag:: " <<
251  "Pol.vec. magnitude must be in [-1,1]. Exiting."; exit(3); }
252  fPol = pm; }
253 
254  inline void SetPolarisationDirection( const double plx,
255  const double ply, const double plz ){
256  if( plx == 0.0 && ply == 0.0 && plz == 0.0 ){
257  LOG( "HNL", pERROR ) <<
258  "genie::hnl::SimpleHNL::SetPolarisationDirection:: " <<
259  "Zero vector entered. Exiting."; exit(1); }
260  const double PM = std::sqrt( plx*plx + ply*ply * plz*plz );
261  fPolUx = plx / PM; fPolUy = ply / PM; fPolUz = plz / PM;
262  if( !fPolDir || fPolDir == 0 ) fPolDir = new std::vector< double >( );
263  else fPolDir->clear();
264  fPolDir->emplace_back( fPolUx ); fPolDir->emplace_back( fPolUy );
265  fPolDir->emplace_back( fPolUz ); }
266 
267  inline void SetProdVtx( const std::vector< double > fourV ){
268  fT0 = fourV.at(0); fX0 = fourV.at(1);
269  fY0 = fourV.at(2); fZ0 = fourV.at(3); }
270 
271  inline void SetDecayVtx( const std::vector< double > fourV ){
272  fT = fourV.at(0); fX = fourV.at(1);
273  fY = fourV.at(2); fZ = fourV.at(3);
274  }
275 
277  const std::map< genie::hnl::HNLDecayMode_t, double > gammaMap ){
278  fInterestingChannels = gammaMap; }
279 
280 
282  const std::vector< genie::hnl::HNLDecayMode_t > decVec ){
283  fInterestingChannelsVec = decVec; }
284 
285  inline void SetDecayMode( const genie::hnl::HNLDecayMode_t decayMode ){
286  fDecayMode = decayMode; }
287 
288  inline void SetParentPDG( const int parPDG ){
289  fParentPDG = parPDG; }
290 
291  inline void SetPDG( const int PDG ){
292  fPDG = PDG; }
293 
294  inline void SetType( const int type ) { fType = type; }
295 
296  inline void SetAngularDeviation( const double adev ) { fAngularDeviation = adev; }
297 
298  inline void SetBeam2UserTranslation( const double tx, const double ty, const double tz ){
299  fTx = tx; fTy = ty; fTz = tz;
300  }
301 
302  inline void SetBeam2UserRotation( const double r1, const double r2, const double r3 ){
303  fR1 = r1; fR2 = r2; fR3 = r3;
304  // and the rotation matrix
305  fRM11 = std::cos( fR2 );
306  fRM12 = -std::cos( fR3 ) * std::sin( fR2 );
307  fRM13 = std::sin( fR2 ) * std::sin( fR3 );
308  fRM21 = std::cos( fR1 ) * std::sin( fR2 );
309  fRM22 = std::cos( fR1 ) * std::cos( fR2 ) * std::cos( fR3 ) - std::sin( fR1 ) * std::sin( fR3 );
310  fRM23 = -std::cos( fR3 ) * std::sin( fR1 ) - std::cos( fR1 ) * std::cos( fR2 ) * std::sin( fR3 );
311  fRM31 = std::sin( fR1 ) * std::sin( fR2 );
312  fRM32 = std::cos( fR1 ) * std::sin( fR3 ) + std::cos( fR2 ) * std::cos( fR3 ) * std::sin( fR1 );
313  fRM33 = std::cos( fR1 ) * std::cos( fR3 ) - std::cos( fR2 ) * std::sin( fR1 ) * std::sin( fR3 );
314  }
315 
316  protected:
317  // default c'tor values
318 
319  int defPDG = 2000020000;
321  double defMass = 0.250 * genie::units::GeV;
322  double defUe42 = 1.0e-4;
323  double defUmu42 = 1.0e-4;
324  double defUt42 = 0.0;
325 
326  // basic calculators
327  inline double CalcBeta( const double E, const double P3 ) {
328  return P3 / E; }
329 
330  inline double CalcGamma( const double bet ) {
331  return std::sqrt( 1.0 / ( 1.0 - bet*bet ) ); }
332 
333  inline double CalcLifetime( const double gam ) {
334  return fCoMLifetime * gam; } // rest-to-lab transf
335 
336  private:
337 
338  mutable std::string fName;
339  mutable int fIndex;
340  mutable int fPDG;
341  mutable int fParentPDG;
342  mutable double fMass;
343  mutable double fUe42, fUmu42, fUt42;
344  mutable bool fIsMajorana;
345  mutable int fType;
346  mutable std::map< genie::hnl::HNLDecayMode_t, double > fValidChannels;
347  mutable double fCoMLifetime; // in GeV^{-1}
348 
349  mutable double fDecayThrow; // determines where decay happens
350  mutable double fSelectThrow; // determines what channel to decay to
352 
353  mutable std::map< genie::hnl::HNLDecayMode_t, double > fInterestingChannels;
354  mutable std::vector< genie::hnl::HNLDecayMode_t > fInterestingChannelsVec;
355 
356  mutable double fBeta, fGamma;
357  mutable double fLifetime;
358  mutable double fT, fX, fY, fZ; // LAB, decay
359  mutable double fT0, fX0, fY0, fZ0; // LAB, origin
360  mutable double fE, fPmag, fPx, fPy, fPz; // LAB, momentum
361  mutable double fPol; // polarisation magnitude
362  mutable double fPolUx, fPolUy, fPolUz;
363  mutable std::vector< double > * fPolDir; // polarisation direction
364 
365  mutable double fAngularDeviation; // ang dev from beam axis, deg
366  mutable double fTx, fTy, fTz; // beam origin in user coordinates [m]
367  mutable double fR1, fR2, fR3; // Euler angles (extrinsic x-z-x) [rad]
368  mutable double fRM11, fRM12, fRM13, fRM21, fRM22, fRM23, fRM31, fRM32, fRM33; // rotation matrix (RM * BEAM = USER)
369 
370  }; // class SimpleHNL
371 
372  } // namespace HNL
373 
374 } // namespace genie
375 
376 #endif // #ifndef _SIMPLEHNL_H_
std::string GetName()
Definition: SimpleHNL.h:77
void SetPolarisationDirection(const double plx, const double ply, const double plz)
Definition: SimpleHNL.h:254
genie::hnl::HNLDecayMode_t fDecayMode
Definition: SimpleHNL.h:351
double GetDecayThrow()
Definition: SimpleHNL.h:105
double GetPolarisationMag()
Definition: SimpleHNL.h:150
#define pERROR
Definition: Messenger.h:59
std::vector< genie::hnl::HNLDecayMode_t > fInterestingChannelsVec
Definition: SimpleHNL.h:354
genie::hnl::HNLDecayMode_t GetDecayMode()
Definition: SimpleHNL.h:109
std::vector< double > GetBeam2UserTranslation()
Definition: SimpleHNL.h:167
void SetPolMag(const double pm)
Definition: SimpleHNL.h:247
HNL object.
Definition: SimpleHNL.h:36
double GetCoMLifetime()
Definition: SimpleHNL.h:96
double GetSelectThrow()
Definition: SimpleHNL.h:107
void SetBeam2UserRotation(const double r1, const double r2, const double r3)
Definition: SimpleHNL.h:302
std::vector< genie::hnl::HNLDecayMode_t > GetInterestingChannelsVec()
Definition: SimpleHNL.h:160
std::map< genie::hnl::HNLDecayMode_t, double > fValidChannels
Definition: SimpleHNL.h:346
void Set4Momentum(const std::vector< double > fourP)
Definition: SimpleHNL.h:243
std::vector< double > * fPolDir
Definition: SimpleHNL.h:363
double CalcBeta(const double E, const double P3)
Definition: SimpleHNL.h:327
std::string fName
Definition: SimpleHNL.h:338
std::vector< double > * GetPolarisationDir()
Definition: SimpleHNL.h:151
void SetDecayVtx(const std::vector< double > fourV)
Definition: SimpleHNL.h:271
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
std::vector< double > GetOrigin4VX()
Definition: SimpleHNL.h:119
void SetMomentumAngles(double theta, double phi)
Definition: SimpleHNL.h:210
SimpleHNL(std::string name, int index)
Definition: SimpleHNL.h:39
void SetMomentumDirection(double ux, double uy, double uz)
Definition: SimpleHNL.h:231
double CalcLifetime(const double gam)
Definition: SimpleHNL.h:333
std::vector< double > GetCouplings()
Definition: SimpleHNL.h:83
static constexpr double GeV
Definition: Units.h:28
void SetInterestingChannelsVec(const std::vector< genie::hnl::HNLDecayMode_t > decVec)
Definition: SimpleHNL.h:281
void SetName(const std::string name)
Definition: SimpleHNL.h:179
const int kPdgKP
Definition: PDGCodes.h:172
void SetBeta(const double bet)
Definition: SimpleHNL.h:198
void SetIndex(const int idx)
Definition: SimpleHNL.h:181
std::map< genie::hnl::HNLDecayMode_t, double > GetValidChannels()
Definition: SimpleHNL.h:154
double GetLifetime()
Definition: SimpleHNL.h:98
enum genie::hnl::EHNLDecayMode HNLDecayMode_t
void SetInterestingChannels(const std::map< genie::hnl::HNLDecayMode_t, double > gammaMap)
Definition: SimpleHNL.h:276
void SetParentPDG(const int parPDG)
Definition: SimpleHNL.h:288
void SetAngularDeviation(const double adev)
Definition: SimpleHNL.h:296
SimpleHNL(std::string name, int index, const int PDG, const int parPDG, const double mass, const double Ue42, const double Umu42, const double Ut42, const bool IsMajorana)
default c&#39;tor
Definition: SimpleHNL.h:54
void SetEnergy(const double E)
Definition: SimpleHNL.h:183
void SetType(const int type)
Definition: SimpleHNL.h:294
double GetAngularDeviation()
Definition: SimpleHNL.h:165
std::vector< double > GetDecay4VX()
Definition: SimpleHNL.h:111
static __attribute__((unused)) double fDecayGammas[]
void SetBeam2UserTranslation(const double tx, const double ty, const double tz)
Definition: SimpleHNL.h:298
std::map< genie::hnl::HNLDecayMode_t, double > fInterestingChannels
Definition: SimpleHNL.h:353
std::vector< double > GetBetaVec()
Definition: SimpleHNL.h:135
void SetDecayMode(const genie::hnl::HNLDecayMode_t decayMode)
Definition: SimpleHNL.h:285
double CalcCoMLifetime(const double M, const double Ue42, const double Umu42, const double Ut42, const bool IsMajorana=false)
~SimpleHNL()
normal constructor
Definition: SimpleHNL.h:73
std::map< genie::hnl::HNLDecayMode_t, double > GetValidChannelWidths(const double M, const double Ue42, const double Umu42, const double Ut42, const bool IsMajorana=false)
double CalcGamma(const double bet)
Definition: SimpleHNL.h:330
std::vector< double > GetBeam2UserRotation()
Definition: SimpleHNL.h:172
void SetProdVtx(const std::vector< double > fourV)
Definition: SimpleHNL.h:267
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
void SetPDG(const int PDG)
Definition: SimpleHNL.h:291
std::vector< double > Get4VP()
Definition: SimpleHNL.h:127
#define pDEBUG
Definition: Messenger.h:63
std::map< genie::hnl::HNLDecayMode_t, double > GetInterestingChannels()
Definition: SimpleHNL.h:157