20 , PMatPath(
"PIDMatrix.dat")
36 std::cout.setf(std::ios::fixed);
37 std::cout.precision(6);
38 for (
unsigned i(0); i <
PMax.size(); i++) {
40 std::cout << 1 <<
'\t' << i + 1 <<
'\t' <<
PMin.at(i) <<
'\t' <<
41 PMax.at(i) <<
'\t' <<
k + 1;
42 for (
unsigned j(0); j <
TrueIdent.size(); j++) {
43 std::cout <<
'\t' <<
PMatrix.at(i).at(j).at(
k);
45 std::cout << std::endl;
52 for (
unsigned i(0); i <
PMatrix.size(); i++) {
54 for (
unsigned j(0); j <
PMatrix.at(i).size(); j++) {
63 for (
unsigned i(0); i <
Range.size(); i++) {
65 for (
unsigned j(0); j <
Range.at(i).size(); j++) {
67 for (
unsigned k = 0;
k <
Range.at(i).at(j).size();
k++) {
77 const double r =
Ran.Rndm();
79 int falseid(-999999999);
82 const std::vector<double>&
values =
Range.at(pbin).at(k);
83 for (
unsigned i(0); i < values.size(); i++) {
85 if (r < values.at(i)) {
88 }
else if (r > values.at(i-1) && r < values.at(i)) {
96 for (
unsigned i(0); i <
TrueIdent.size(); i++) {
105 for (
unsigned i(0); i <
FalseIdent.size(); i++) {
111 if (ID < 5 && ID > 0) {
130 Qfile.open(filename);
132 std::cerr <<
"Error in ParticleID: unable to open file "
133 << filename << std::endl;
138 bool operator()(
const std::string&
s,
139 const std::string& pattern)
const {
140 return s.find(pattern, 0) == 0;
144 std::stringstream ss;
145 std::string line, dummy;
146 bool gotTrue(
false), gotFalse(
false), gotBins(
false);
149 line.erase(0, line.find_first_not_of(
" \t"));
156 if (starts(line,
"!T")) {
158 while ((ss >> tmpint).good()) {
162 }
else if (starts(line,
"!F")) {
165 while ((ss >> tmpint).good()) {
169 }
else if (starts(line,
"!P")) {
175 gotBins = !
PMin.empty();
176 }
else if (starts(line,
"1") || starts(line,
"2") || starts(line,
"3")) {
178 if (!(gotTrue && gotFalse && gotBins)) {
179 std::cerr <<
"Error in ParticleID: " <<
180 "P matrix input file has bad or missing format lines.\n";
183 int table, pbin,
pid;
184 double pmin, pmax, p1, p2, p3;
185 ss >> table >> pbin >> pmin >> pmax >> pid >> p1 >> p2 >> p3;
186 if ((
unsigned)pbin >
PMin.size()) {
187 std::cerr <<
"Error in ParticleID: " <<
188 "Out of bounds momentum bin listing.\n";
192 PMin.at(pbin) = pmin;
193 PMax.at(pbin) = pmax;
196 std::cerr <<
"Error in ParticleID: " <<
197 "P matrix has bad particle listing.\n";
205 PMatrix.at(pbin).at(0).at(pid) = p1;
206 PMatrix.at(pbin).at(1).at(pid) = p2;
207 PMatrix.at(pbin).at(2).at(pid) = p3;
218 momentum = prt.
GetP();
220 momentum = prtOut.
GetP();
222 const int pid = prt.
Id();
224 for (
unsigned i(0); i <
PMin.size(); i++) {
225 if (momentum >
PMin.at(i) && momentum <
PMax.at(i)) {
239 std::cout <<
"ParticleID using " <<
PMatPath << std::endl;