Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-29 07:05:49

0001 /**
0002  \file
0003  Declaration of various Smear namespace functions.
0004  
0005  \author    Michael Savastio
0006  \date      2011-08-19
0007  \copyright 2011 Brookhaven National Lab
0008  */
0009 
0010 #ifndef INCLUDE_EICSMEAR_SMEAR_SMEAR_H_
0011 #define INCLUDE_EICSMEAR_SMEAR_SMEAR_H_
0012 
0013 #include <cmath>
0014 #include <fstream>
0015 #include <iostream>
0016 #include <memory>
0017 #include <sstream>
0018 
0019 #include <TF1.h>
0020 #include <TF2.h>
0021 #include <TLorentzVector.h>
0022 #include <TMath.h>
0023 #include <TRandom3.h>
0024 #include <TROOT.h>
0025 #include <TString.h>
0026 #include <TSystem.h>
0027 #include <TVector2.h>
0028 
0029 #include "eicsmear/erhic/Kinematics.h"
0030 #include "eicsmear/erhic/Particle.h"
0031 #include "eicsmear/erhic/ParticleIdentifier.h"
0032 #include "eicsmear/erhic/VirtualParticle.h"
0033 #include "eicsmear/smear/SmearConstants.h"
0034 #include "eicsmear/smear/ParticleMCS.h"
0035 
0036 namespace Smear {
0037 
0038 /**
0039  Determine particle "genre".
0040  
0041  This refers to whether the particle in the argument is
0042  "electromagnetic" or "hadronic" from the perspective of calorimetry.
0043  
0044  Returns one of the following (see enum EGenre):
0045  kElectromagnetic: photon or electron/positron.
0046  kHadronic:        stable hadron.
0047  kAll:             neither of the above.
0048  */
0049 inline int PGenre(const erhic::VirtualParticle& prt) {
0050   int genre(kAll);
0051   const int id = abs(prt.Id());  // Sign doesn't matter
0052   if (1 == prt.GetStatus()) {  // Only check stable particles.
0053     if (id == 11 || id == 22) {
0054       genre = kElectromagnetic;
0055     } else if (id >110) {
0056       genre = kHadronic;
0057     }  // if
0058   }  // if
0059   return genre;
0060 }
0061 
0062 /**
0063  Fix a polar angle so that it lies within [0,pi].
0064  TODO Nothing Smear-specific here - move to general functions file.
0065  */
0066 inline double FixTheta(double theta) {
0067   // std::cout << theta << std::endl;
0068   while (theta < 0. || theta > TMath::Pi()) {
0069     if (theta < 0.) {
0070       theta = -theta;
0071     }  // if
0072     if (theta > TMath::Pi()) {
0073       theta = TMath::TwoPi() - theta;
0074     }  // if
0075   }
0076   return theta;
0077 }
0078 
0079 /**
0080  Fix an azimuthal angle so that it lies within [0,2*pi).
0081  TODO Nothing Smear-specific here - move to general functions file.
0082  */
0083 inline double FixPhi(double phi) {
0084   return TVector2::Phi_0_2pi(phi);
0085 }
0086 
0087 /**
0088  Returns the kinematic variable associated with kin from the input particle.
0089  */
0090 inline double GetVariable(const erhic::VirtualParticle& prt, KinType kin) {
0091   double z(0.);
0092   switch (kin) {
0093     case kE:
0094       z = prt.GetE(); break;
0095     case kP:
0096       z = prt.GetP(); break;
0097     case kTheta:
0098       z = prt.GetTheta(); break;
0099     case kPhi:
0100       z = prt.GetPhi(); break;
0101     case kPz:
0102       z = prt.GetPz(); break;
0103     case kPt:
0104       z = prt.GetPt(); break;
0105     default:
0106       break;
0107   }  // switch
0108   return z;
0109 }
0110 
0111 inline bool IsCoreType(KinType kin) {
0112   if (kin == kE || kin == kP || kin == kTheta || kin == kPhi) return true;
0113   return false;
0114 }
0115 
0116 int ParseInputFunction(TString &s, KinType &kin1, KinType &kin2);
0117 
0118 }  // namespace Smear
0119 
0120 #endif  // INCLUDE_EICSMEAR_SMEAR_SMEAR_H_