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
ParticleID.h
Go to the documentation of this file.
1 
10 #ifndef INCLUDE_EICSMEAR_SMEAR_PARTICLEID_H_
11 #define INCLUDE_EICSMEAR_SMEAR_PARTICLEID_H_
12 
13 #include <cmath>
14 #include <fstream>
15 #include <iostream>
16 #include <sstream>
17 #include <vector>
18 
19 #include <TF1.h>
20 #include <TF2.h>
21 #include <TLorentzVector.h>
22 #include <TRandom3.h>
23 #include <TROOT.h>
24 #include <TSystem.h>
25 #include <TString.h>
26 
27 #include "eicsmear/smear/Device.h"
31 #include "eicsmear/smear/Smear.h"
32 #include "eicsmear/smear/Smearer.h"
34 
35 namespace Smear {
36 
67 struct ParticleID : public Smearer {
74  ParticleID();
75 
80  explicit ParticleID(TString filename);
81 
85  virtual ~ParticleID();
86 
91  void SetPMatrixPath(TString);
92 
98  void SetPIDUseMC(bool useMc);
99 
103  TRandom3& GetRandomGenerator();
104 
110  void SetRanSeed(int seed);
111 
117  void GetAcceptanceFromDevice(const Device&);
118 
122  void SetPMatrixSize();
123 
130  void SetupProbabilityArray();
131 
137  virtual ParticleID* Clone(const char* = "") const;
138 
143  int Wild(int pbin, int trueID);
144 
145  int InListOfTrue(int ID);
146 
147  int InListOfFalse(int ID);
148 
153  void ReadP(TString filename);
154 
165 
169  void Speak();
170 
174  virtual void Clear(Option_t* = "");
175 
179  virtual void Print(Option_t* = "") const;
180 
181  TRandom3 Ran;
182  TString PMatPath;
183  std::vector<int> TrueIdent;
184  std::vector<int> FalseIdent;
185  std::vector<double> PMin;
186  std::vector<double> PMax;
187  // Indices are for momentum bin, true ID, and false ID
188  // PMatrix[i][j][k] stores the probability for a particle of type
189  // TrueIdent[j] in the momentum bin (PMin[i], PMax[i]) to be
190  // identified as a particle of type FalseIdent[k].
191  std::vector< std::vector<std::vector<double> > > PMatrix;
192  // Range is the cumulative probability distribution of PMatrix.
193  std::vector< std::vector<std::vector<double> > > Range;
194  bool bUseMC;
195 
196  ClassDef(Smear::ParticleID, 1)
197 };
198 
199 inline void ParticleID::SetPMatrixPath(TString str) {
200  PMatPath = str;
201  ReadP(PMatPath);
202 }
203 
204 inline void ParticleID::SetPIDUseMC(bool d) {
205  bUseMC = d;
206 }
207 
208 inline TRandom3& ParticleID::GetRandomGenerator() {
209  return Ran;
210 }
211 
212 inline void ParticleID::SetRanSeed(int n) {
213  Ran.SetSeed(n);
214 }
215 
217  Accept = dev.Accept;
218 }
219 
220 inline ParticleID* ParticleID::Clone(const char*) const {
221  // const char* argument comes from TObject::Clone(), usused here.
222  return new ParticleID(*this);
223 }
224 
225 } // namespace Smear
226 
227 #endif // INCLUDE_EICSMEAR_SMEAR_PARTICLEID_H_
Smear::ParticleID::PMatPath
TString PMatPath
Definition: ParticleID.h:182
Smear
Definition: Acceptance.cxx:16
Smear::ParticleID::ParticleID
ParticleID()
Default constructor.
Definition: ParticleID.cxx:18
Smear::ParticleID::Clone
virtual ParticleID * Clone(const char *="") const
Returns a copy of this ParticleID.
Definition: ParticleID.h:220
Smear::ParticleID::Speak
void Speak()
Dump the contents of the table to the screen.
Definition: ParticleID.cxx:35
Smear::ParticleID::PMin
std::vector< double > PMin
Definition: ParticleID.h:185
Smear::ParticleID::GetRandomGenerator
TRandom3 & GetRandomGenerator()
Return the TRandom3 instance used by the ParticleID.
Definition: ParticleID.h:208
Smear::ParticleID::SetPIDUseMC
void SetPIDUseMC(bool useMc)
If true, the ParticleID will use the original Monte Carlo values to generate ID's,...
Definition: ParticleID.h:204
Smear::ParticleID::SetPMatrixPath
void SetPMatrixPath(TString)
Set the path to the file containing the particle ID probability matrix, and read it in.
Definition: ParticleID.h:199
Smear::ParticleID::TrueIdent
std::vector< int > TrueIdent
Definition: ParticleID.h:183
Smear::ParticleID::Print
virtual void Print(Option_t *="") const
Print information about this device to standard output.
Definition: ParticleID.cxx:238
Smear::ParticleID::PMax
std::vector< double > PMax
Definition: ParticleID.h:186
Smear::Smearer::Accept
Acceptance Accept
Definition: Smearer.h:50
Smear::ParticleID::GetAcceptanceFromDevice
void GetAcceptanceFromDevice(const Device &)
Set the ParticleID instance to have the same acceptance as the device.
Definition: ParticleID.h:216
Smear::ParticleID::ReadP
void ReadP(TString filename)
Read in a P matrix and set up the ParticleID to be ready to generate.
Definition: ParticleID.cxx:126
Smear::ParticleID::FalseIdent
std::vector< int > FalseIdent
Definition: ParticleID.h:184
Smear::ParticleID::SetupProbabilityArray
void SetupProbabilityArray()
Setup the range array used by wild.
Definition: ParticleID.cxx:60
Smear.h
Smear::ParticleID::InListOfFalse
int InListOfFalse(int ID)
Definition: ParticleID.cxx:104
Smear::ParticleID::Range
std::vector< std::vector< std::vector< double > > > Range
Definition: ParticleID.h:193
Smear::ParticleID::Wild
int Wild(int pbin, int trueID)
Randomly generates a false ID based on the current, a momentum bin and a true particle ID.
Definition: ParticleID.cxx:76
VirtualParticle.h
erhic::VirtualParticle
Abstract base class for a general particle.
Definition: VirtualParticle.h:23
Particle.h
Smear::ParticleID::InListOfTrue
int InListOfTrue(int ID)
Definition: ParticleID.cxx:95
Smear::ParticleID
This structure is used to generate particle ID.
Definition: ParticleID.h:67
Smearer.h
Device.h
Smear::Smearer
Abstract base class for objects performing smearing.
Definition: Smearer.h:33
Smear::ParticleMCS
A smeared Monte Carlo particle.
Definition: ParticleMCS.h:27
Smear::ParticleID::SetPMatrixSize
void SetPMatrixSize()
Resize the PMatrix, (# of pbins, # of true, # of false).
Definition: ParticleID.cxx:50
Smear::Device
Performs smearing of a single kinematic variable according to a simple expression defined via a strin...
Definition: Device.h:44
Smear::ParticleID::Clear
virtual void Clear(Option_t *="")
Clears existing table contents.
Definition: ParticleID.cxx:117
Smear::ParticleID::bUseMC
bool bUseMC
Definition: ParticleID.h:194
Smear::ParticleID::Smear
void Smear(const erhic::VirtualParticle &, ParticleMCS &)
Generates particle ID if the particle is in the list of particles to be identified,...
Definition: ParticleID.cxx:214
Smear::ParticleID::~ParticleID
virtual ~ParticleID()
Destructor.
Definition: ParticleID.cxx:32
Smear::ParticleID::SetRanSeed
void SetRanSeed(int seed)
Set the seed of the random number generator instance used by the ParticleID.
Definition: ParticleID.h:212
Smear::ParticleID::PMatrix
std::vector< std::vector< std::vector< double > > > PMatrix
Definition: ParticleID.h:191
Smear::ParticleID::Ran
TRandom3 Ran
Definition: ParticleID.h:181
ParticleIdentifier.h
Kinematics.h