Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PIDProbabilities.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PIDProbabilities.cc
1 // Some documentation //
2 
3 #include "PIDProbabilities.h"
4 #include "Poisson.h"
5 
6 #include <TDatabasePDG.h>
7 
8 using namespace std;
9 
10 
12 {
13  _pdg = new TDatabasePDG();
14  _poisson = new Poisson();
15 }
16 
17 bool
18 PIDProbabilities::particle_probs( vector<float> angles, double momentum, double index, long double probs[4] ){
19 
20  bool use_reconstructed_momentum = false;
21  bool use_truth_momentum = false;
22  bool use_emission_momentum = true;
23 
24 
25  /* Initialize particle masses, probably want to use pdg database */
26  int pid[4] = { 11, 211, 321, 2212 };
27  double m[4] = {
28  _pdg->GetParticle(pid[0])->Mass(),
29  _pdg->GetParticle(pid[1])->Mass(),
30  _pdg->GetParticle(pid[2])->Mass(),
31  _pdg->GetParticle(pid[3])->Mass()
32  };
33 
34  /* Set angle window by taking smallest difference, highest momentum in question (70 GeV) */
35  double test_p = 70;
36  double windowx2 = acos( sqrt( m[1]*m[1] + test_p*test_p ) / index / test_p ) - acos( sqrt( m[2]*m[2] + test_p*test_p ) / index / test_p );
37  double window = windowx2/2;
38 
39  /* Determine expectation value for each particle */
40  double beta[4] = {
41  momentum/sqrt( m[0]*m[0] + momentum*momentum ),
42  momentum/sqrt( m[1]*m[1] + momentum*momentum ),
43  momentum/sqrt( m[2]*m[2] + momentum*momentum ),
44  momentum/sqrt( m[3]*m[3] + momentum*momentum )
45  };
46 
47  double theta_expect[4] = {
48  acos( 1/( index * beta[0] ) ),
49  acos( 1/( index * beta[1] ) ),
50  acos( 1/( index * beta[2] ) ),
51  acos( 1/( index * beta[3] ) )
52  };
53 
54 
55  /* Calculate average counts based on sims */
56  double counts_cal[4] = {0,0,0,0};
57  if ( use_reconstructed_momentum )
58  {
59  cout << "Reconstructed momentum function undefined now!" << endl;
60  counts_cal[0] = 0;
61  counts_cal[1] = 0;
62  counts_cal[2] = 0;
63  counts_cal[3] = 0;
64  }
65  if ( use_truth_momentum )
66  {
67  cout << "Truth momentum function undefined now!" << endl;
68  counts_cal[0] = 0;
69  counts_cal[1] = 0;
70  counts_cal[2] = 0;
71  counts_cal[3] = 0;
72  }
73  if ( use_emission_momentum )
74  {
75  // Proton function still needs to be implemented after sims are finished //
76  counts_cal[0] = 29.5;
77  counts_cal[1] = 25.8 * acos( sqrt(178.4 + momentum*momentum) / (2.62*momentum) );
78  counts_cal[2] = 22.08 * acos( sqrt(982600 + momentum*momentum) / (52.93*momentum) );
79  counts_cal[3] = 0;
80  }
81 
82 
83  /* Count hits within window */
84  int counts[4] = {0,0,0,0};
85  for (int i=0; i<300; i++){
86  for (int j=0; j<4; j++){
87  if ( angles[i] > (theta_expect[j] - window) && angles[i] < (theta_expect[j] + window) )
88  counts[j]++;
89  }
90  }
91 
92  /* Determine particle probabilities, Poisson probability mass function */
93  long double probs_norm = 0;
94  for (int k=1; k<3; k++)
95  {
96  probs[k] = _poisson->poisson_prob( counts_cal[k], counts[k] );
97  probs_norm += probs[k];
98  }
99  for (int k=1; k<3; k++)
100  probs[k] /= probs_norm;
101 
102 
103  /* Alert that this may have been a glitched event if very few photons */
104  double allcounts = counts[0] + counts[1] + counts[2] + counts[3];
105  double allcal = counts_cal[0] + counts_cal[1] + counts_cal[2] + counts_cal[3];
106  if ( allcounts / allcal < 0.2 )
107  cout << "WARNING: Very few photons in event. May be an unintended track!" << endl;
108 
109 
110  return true;
111 }