-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent_analyzer.cpp
More file actions
155 lines (123 loc) · 3.55 KB
/
Copy pathevent_analyzer.cpp
File metadata and controls
155 lines (123 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "event_analyzer.h"
using namespace std;
int main(int argc, char * argv[])
{
Event_Parser parser(num_events);
auto events = parser.get_events(filepath, filename);
float avg_pionpion_distance = 0.;
float avg_kaonkaon_distance = 0.;
/**
* Calculate the average distances between pion-pion pairs and kaon-kaon pairs
*/
calculate_distances(events,
avg_pionpion_distance,
avg_kaonkaon_distance);
/**
* Print out the averages for easy reading
*/
std::cout<<std::setprecision(4)<<"Charged pions are, on average, separated by "
<<avg_pionpion_distance<<" in azimuthal-pseudorapidity space"
<<std::endl;
std::cout<<std::setprecision(4)<<"Charged Kaons are, on average, separated by "
<<avg_kaonkaon_distance<<" in azimuthal-pseudorapidity space"
<<std::endl;
return 1;
}
/**
* Calculate the distances between pion-pion pairs and kaon-kaon pairs
*/
void calculate_distances(std::vector<Event> events,
float &pipi,
float &kk)
{
int total_pions_analyzed = 0;
int total_kaons_analyzed = 0;
/**
* Loop over all the events to analyze
*/
for(int i = 0; i < events.size(); ++i )
{
auto numparts_in_event = events.at(i).num_particles_in_event();
std::vector <Pion> pions;
std::vector <Kaon> kaons;
/**
* Collect the pions and kaons in a given event i
*/
for(int j = 0; j < numparts_in_event; ++j )
{
auto particle = events.at(i).get_particles().at(j);
/**
* Just analyze pions in a given pseudorapidity range defined by the cut
*/
if(fabs( particle.get_pseudorapidity() ) > pseudorapidity_cut )
continue;
/**
* Check that the masses are within 5% of the measured pion or kaon mass.
* This accounts for the particles being slightly off mass shell.
*/
if( fabs( 1. - particle.get_mass() / PION_MASS ) < 0.05 )
{
pions.push_back( Pion( particle.get_px(),
particle.get_py(),
particle.get_pz() ) );
}
if( fabs( 1. - particle.get_mass() / KAON_MASS ) <0.05 )
{
kaons.push_back( Kaon( particle.get_px(),
particle.get_py(),
particle.get_pz() ) );
}
} ///collected pions and kaons in an event
/**
* Now compare the particles to one another to determine
* distance in pseudorapidity-phi space
*/
for(int j = 0; j < pions.size(); ++j)
{
Pion pion1 = pions.at(j);
/**
* Start at j to avoid double counting
*/
for(int k = j; k < pions.size(); ++k)
{
/**
* Don't want to compare the particle to itself
*/
if( j == k )
continue;
Pion pion2 = pions.at(k);
pipi += pion1.deltaR(pion2);
total_pions_analyzed++;
}
}
for(int j = 0; j < kaons.size(); ++j)
{
Kaon kaon1 = kaons.at(j);
/**
* Start at j to avoid double counting
*/
for(int k = j; k < kaons.size(); ++k)
{
/**
* Don't want to compare the particle to itself
*/
if( j == k )
continue;
Kaon kaon2 = kaons.at(k);
kk += kaon1.deltaR(kaon2);
total_kaons_analyzed++;
}
}
/**
* Make sure to resize the vectors, just to be sure we don't have events mixing with each other
*/
pions.resize(0);
kaons.resize(0);
} ///Event loop
/**
* Now take the average by dividing by the total number of particles analyzed
* These are pointers so they get "returned"
*/
pipi /= total_pions_analyzed;
kk /= total_kaons_analyzed;
}