HighLAND
ND280AnalysisUtils.hxx
1 #ifndef ND280AnalysisUtils_h
2 #define ND280AnalysisUtils_h
3 
4 #include "AnalysisUtils.hxx"
5 
6 #include "ConstituentsUtils.hxx"
7 #include "PIDUtils.hxx"
8 #include "TruthUtils.hxx"
9 #include "VersioningUtils.hxx"
10 #include "Header.hxx"
11 
12 /// This namespace contains useful functions for analyses. Functions include
13 /// those related to fiducial volumes, accessing tracks with specific
14 /// characteristics, and more.
15 namespace anaUtils{
16 
17  //----- Utility functions -------------
18 
19  /// Get all delayed time bins as Michel Electron candidates
20  int GetFGDMichelElectrons(const AnaEventB& event, const SubDetId::SubDetEnum det, AnaFgdTimeBinB** arr, bool prod5Cut = 0);
21 
22 
23  /// Return a scale factor for the magnet intensity, based on the ND280 run number.
24  /// THIS IS CURRENTLY DISABLED AND WILL ALWAYS RETURN 1!
25  Float_t MagnetIntensityCorrection(Int_t Run);
26 
27  /// Whether the ECal object is "contained" within the ECal volume. This is
28  /// intended for deciding whether to trust the ECal EM energy or not.
29  /// At the moment this is based on the start position of the shower. It will
30  /// be updated to a more rigorous definition when production 5F files have been
31  /// studied more closely.
32  // bool IsEcalContained(AnaEcalTrackEcalPID* EcalSegment);
33 
34  /// Returns the run period (sequentially: 0,1,2,3,4,5 ...)
35  int GetRunPeriod(int run, int subrun = -1);
36 
37  /// Returns the sans muon modes (sequentially: 0,1,2)
38  int GetSandMode(int run);
39 
40  /// Method to load external ipon cross section data into arrays
41  template<int nIntBins, int nMomBins>
42  void LoadPionCrossSections(char* inputFileName, Float_t (&xsec_array)[nIntBins][nMomBins], Float_t (&err_array)[nIntBins][nMomBins]){
43  ifstream inputFile(inputFileName, std::ios::in);
44 
45  if (!inputFile) {
46  std::cerr << "Cannot open input file '" << inputFileName << "'. Exit!" << std::endl;
47  exit(0);
48  }
49 
50  std::string ctype, cintBin, cvalue;
51  char* pEnd;
52  while (inputFile >> ctype >> cintBin) {
53  int intBin = strtod(cintBin.c_str(),&pEnd);
54  int type = strtod(ctype.c_str(),&pEnd);
55 
56  if(intBin >= nIntBins) std::cout << "Error - interaction bin larger than input array size" << std::endl;
57 
58  for (int momBin = 0;momBin<nMomBins;momBin++){
59  inputFile >> cvalue;
60  Float_t value = strtod(cvalue.c_str(),&pEnd);
61  if (type==0){
62  xsec_array[intBin][momBin] = value;
63  }
64  else
65  err_array[intBin][momBin] = value;
66  }
67  }
68 
69  inputFile.close();
70  }
71 
72  double GetNTargets(massComponentEnum massComponent = kFGD1, int target_nucleons = 3);
73  double GetNucleonsPerNucleus(massComponentEnum massComponent = kFGD1, int target_nucleons = 3);
74  double GetAreaFV(massComponentEnum massComponent = kFGD1);
75 
76 
77  void IncrementPOTBySpill(const AnaSpillB& spill, Header& header);
78 
79  /// Compute inverse PT given an AnaDetCrossing
80  Float_t ComputeInversePT(const AnaDetCrossingB &cross, bool entrance = true);
81  Float_t ComputeInversePTFlip(const AnaTrackB& track);
82 
83  /// Compute the total momentum (flip) given the part and the inverse transverse momentum
84  Float_t ComputeMomentumFromInversePTFlip(const AnaParticleB &part, Float_t PTinv);
85 }
86 #endif
87 
88 // LocalWords: ifndef
int GetFGDMichelElectrons(const AnaEventB &event, const SubDetId::SubDetEnum det, AnaFgdTimeBinB **arr, bool prod5Cut=0)
Get all delayed time bins as Michel Electron candidates.
This class handles POT info, SoftwareVersion and IsMC.
Definition: Header.hxx:10
Float_t ComputeInversePT(const AnaDetCrossingB &cross, bool entrance=true)
Compute inverse PT given an AnaDetCrossing.
int GetRunPeriod(int run, int subrun=-1)
Returns the run period (sequentially: 0,1,2,3,4,5 ...)
Float_t ComputeMomentumFromInversePTFlip(const AnaParticleB &part, Float_t PTinv)
Compute the total momentum (flip) given the part and the inverse transverse momentum.
Representation of a detector crossing info for a true particle (G4 trajectory).
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
Representation of a global track.
int GetSandMode(int run)
Returns the sans muon modes (sequentially: 0,1,2)
This namespace contains useful functions for analyses related to kinematics.
Representation of a reconstructed particle (track or shower).
void LoadPionCrossSections(char *inputFileName, Float_t(&xsec_array)[nIntBins][nMomBins], Float_t(&err_array)[nIntBins][nMomBins])
Method to load external ipon cross section data into arrays.
Float_t MagnetIntensityCorrection(Int_t Run)