forked from tomasate/Event-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
states_constructor.h
101 lines (78 loc) · 2.71 KB
/
states_constructor.h
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
#include <iostream>
#include <vector>
#include <typeinfo>
std::string state1;
std::string state2;
std::vector<std::string> state_out; //Vector with the names of particles in the final state
std::vector<std::string> state_in; //Vector with the names of particles in the initial state
int counter{0}; //Counter for the number of particles
int Nparticles; //Number of particles in the final state
void states(){
std::cout << "***** Event generator *****\n";
std::cout << "Particles are defined as:\n";
std::cout << "Charged leptons and antileptons are: e- e+, mu- mu+, tau- tau+\n";
std::cout << "Quarks and antiquarks are: u u~, d d~, c c~, s s~, t t~, b b~\n";
std::cout << "Electronic, muonic and tauonic neutrinos are respectively: ve, vu, vt\n";
std::cout << "Spin 1 bosons are: a, g, w+, w-, z\n";
std::cout << "Higgs bosson is: h\n";
std::cout << "The states are written as: particle1 particle2 particle3 ...\n";
//Enter the states
std::cout << "Initial state\n";
std::getline(std::cin, state1);
std::cout << "Final state\n";
std::getline(std::cin, state2);
int len1 = state1.size(); //Number of characteres in the initial state
int len2 = state2.size(); //Number of characteres in the final state
//Counter for the particles in the final state
for(int i = 0; i < len2; i++){
if(state2[i] == ' '){
counter += 1;
}
}
if(state2[len2-1] == ' '){
Nparticles = counter;
}
else{
Nparticles = counter + 1;
}
//Resize the state vectors
state_out.resize(Nparticles);
state_in.resize(2);
//Contruct the vector with the labels of particles in the initial state
int count{0};
for(int i = 0; i < 2; i++){
for(int ii = count; ii < len1; ii++){
if(state1[ii] == ' '){
count += 1;
break;
}
state_in[i] += state1[ii];
count += 1;
}
}
//Contruct the vector with the labels of particles in the final state
count = 0;
for(int i = 0; i < Nparticles; i++){
for(int ii = count; ii < len2; ii++){
if(state2[ii] == ' '){
count += 1;
break;
}
state_out[i] += state2[ii];
count += 1;
}
}
//Prevents for type errors in the states
for(int i = 0; i < 2; i++){
if(map(state_in[i]).mass == 0 && map(state_in[i]).spin == 0 && map(state_in[i]).charge == 0){
std::cout << "One or more particles in the initial state is not well defined" << std::endl;
exit(0);
}
}
for(int i = 0; i < Nparticles; i++){
if(map(state_out[i]).mass == 0 && map(state_out[i]).spin == 0 && map(state_out[i]).charge == 0){
std::cout << "One or more particles in the final state is not well defined" << std::endl;
exit(0);
}
}
}