eic-smear
1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
|
Go to the documentation of this file.
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++) {
39 for (
unsigned k(0); k <
FalseIdent.size(); k++) {
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++) {
69 Range.at(i).at(j).at(k) = t;
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);
147 while (std::getline(Qfile, line).good()) {
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();
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)) {
231 prtOut.
id = -
Wild(i, pid);
239 std::cout <<
"ParticleID using " <<
PMatPath << std::endl;
Double32_t p
Total momentum of particle.
bool Is(const erhic::VirtualParticle &prt) const
This function determines if the particle provided lies within the acceptance of the detector.
ParticleID()
Default constructor.
void Speak()
Dump the contents of the table to the screen.
std::vector< double > PMin
std::vector< int > TrueIdent
virtual void Print(Option_t *="") const
Print information about this device to standard output.
virtual Double_t GetP() const =0
Returns the magnitude of 3-momentum (GeV).
std::vector< double > PMax
void ReadP(TString filename)
Read in a P matrix and set up the ParticleID to be ready to generate.
std::vector< int > FalseIdent
Int_t id
PDG particle code.
void SetupProbabilityArray()
Setup the range array used by wild.
int InListOfFalse(int ID)
std::vector< std::vector< std::vector< double > > > Range
int Wild(int pbin, int trueID)
Randomly generates a false ID based on the current, a momentum bin and a true particle ID.
Abstract base class for a general particle.
A smeared Monte Carlo particle.
void SetPMatrixSize()
Resize the PMatrix, (# of pbins, # of true, # of false).
virtual void Clear(Option_t *="")
Clears existing table contents.
void Smear(const erhic::VirtualParticle &, ParticleMCS &)
Generates particle ID if the particle is in the list of particles to be identified,...
virtual ~ParticleID()
Destructor.
std::vector< std::vector< std::vector< double > > > PMatrix
virtual Pid Id() const =0
Returns identity information for the Particle species.