-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplain_parser.php
More file actions
64 lines (52 loc) · 2.95 KB
/
Copy pathplain_parser.php
File metadata and controls
64 lines (52 loc) · 2.95 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
<?php
include 'lib/event.php';
include 'lib/plain_table.php';
$simulation_output = file_get_contents(SIM_OUTPUT_FILE_PATH, FALSE); // Load the simulation output
$events = Event::getEvents($simulation_output); // Fetch all the events
// In this script we demonstrate a typical filtering of events
// Here we consider Lambda baryon decay, but the procedure is similar for other particles
// Prepare the txt table
$table = new PlainTable(['Run', 'φ', 'Δφ', 'κ1', 'Δκ1', 'κ2', 'Δκ2', 'x', 'Δx', 'y', 'Δy', 'z', 'Δz']); // Prepare the table
// Note #1: vertex coordinate columns (x,dx,y,dy,z,dz) are usually needed for calculating the mean lifetime
// Note #2: Notice the second argument: 'A10'. It refers to the table position (i.e. the table will start from the cell A10)
$good_events_counter = 0;
// Iterate the events
foreach($events as $event) {
// In most cases Lambda decays into proton and pi-minus (i.e. 2 particles with opposite charges)
// Therefore let's select the events that actually contain spectrometer data (i.e. produced charged particles)
if($event->hasFullSpectrometerData()) {
// We're only interested in events which produced 2 tracks (and also 3, because of a known simulation bug)
if(($event->number_of_tracks == 3 && $event->number_of_vertices > 1) || ($event->number_of_tracks == 2)) {
// Let's find the maximal angle between the tracks (necessary for the case of 3 tracks; trivial when there are 2)
// The class Events has a useful method called maxAngleSpectrometerData() which returns
// all the useful spectrometer data (such as kappa, errors etc.) corresponding to the highest angle (phi)
$max_angle_data = $event->maxAngleSpectrometerData();
// Let's save the kappas to separate variables
$kappa1 = $max_angle_data['tracks'][0]['curvature']['value'];
$kappa2 = $max_angle_data['tracks'][1]['curvature']['value'];
// Since the decay products are supposed to have opposite charges we expect the kappas to differ in sign
// Because that's not always the case, let's select the "correct" events
if(($kappa1 < 0) != ($kappa2 < 0)) {
$good_events_counter++;
// Add the relevant row in the table (notice that the values are in the same order as the columns from $table definition)
$table->addTableRow([
$good_events_counter, // Run
$max_angle_data['angle']['value'], // Phi
$max_angle_data['angle']['error'], // Phi error
$kappa1, // Kappa1
$max_angle_data['tracks'][0]['curvature']['error'], // Kappa1 Error
$kappa2, // Kappa2
$max_angle_data['tracks'][1]['curvature']['error'], // Kappa2 Error
$max_angle_data['vertex_coord']['x']['value'],
$max_angle_data['vertex_coord']['x']['error'],
$max_angle_data['vertex_coord']['y']['value'],
$max_angle_data['vertex_coord']['y']['error'],
$max_angle_data['vertex_coord']['z']['value'],
$max_angle_data['vertex_coord']['z']['error']
]);
}
}
}
}
// Save the table
$table->saveTable();