FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
PndFsmMdtPid Class Reference

#include <PndFsmMdtPid.h>

Inheritance diagram for PndFsmMdtPid:
PndFsmAbsDet

Public Member Functions

 PndFsmMdtPid ()
 
 PndFsmMdtPid (ArgList &par)
 
virtual ~PndFsmMdtPid ()
 
virtual PndFsmResponserespond (PndFsmTrack *t)
 
const std::string & detName ()
 
void setName (std::string &name)
 
Bool_t doesPid () const
 
void setStorePid (Bool_t doespid=kTRUE)
 

Protected Member Functions

virtual bool setParameter (std::string &name, std::string &value)
 
void parseParameterList (ArgList &par)
 

Protected Attributes

std::string _detName
 
double _efficiency
 
TRandom3 * _rand
 
TDatabasePDG * _fdbPDG
 
Bool_t _doesPid
 

Private Member Functions

bool detected (PndFsmTrack *t) const
 
void initParameters ()
 
void print (std::ostream &o)
 
bool setParameter (std::string &name, double value)
 
bool readParameters ()
 

Private Attributes

TH3F * _mdtPidPdf [6]
 
double _thtMin
 
double _thtMax
 
double _pmin
 
double _misId
 
bool _useFlat
 
std::string _parFileName
 

Detailed Description

Definition at line 42 of file PndFsmMdtPid.h.

Constructor & Destructor Documentation

PndFsmMdtPid::PndFsmMdtPid ( )

Default ctor.

Definition at line 60 of file PndFsmMdtPid.cxx.

References _thtMax, _thtMin, initParameters(), and readParameters().

61 {
63 
64  _thtMin=_thtMin*M_PI/180.0;
65  _thtMax=_thtMax*M_PI/180.0;
67  //print(std::cout);
68 }
bool readParameters()
void initParameters()
double _thtMin
Definition: PndFsmMdtPid.h:77
double _thtMax
Definition: PndFsmMdtPid.h:78
PndFsmMdtPid::PndFsmMdtPid ( ArgList par)

Definition at line 70 of file PndFsmMdtPid.cxx.

References _thtMax, _thtMin, initParameters(), PndFsmAbsDet::parseParameterList(), and readParameters().

71 {
73  //set default parameter values and parses a parameter list
74  //i.e. std::list<std::string> of the form
75  //"a=1" "b=2" "c=3"
77 
78  _thtMin=_thtMin*M_PI/180.0;
79  _thtMax=_thtMax*M_PI/180.0;
81  //print(std::cout);
82 }
bool readParameters()
Double_t par[3]
void initParameters()
void parseParameterList(ArgList &par)
double _thtMin
Definition: PndFsmMdtPid.h:77
double _thtMax
Definition: PndFsmMdtPid.h:78
PndFsmMdtPid::~PndFsmMdtPid ( )
virtual

Destructor

Definition at line 88 of file PndFsmMdtPid.cxx.

89 {
90 }

Member Function Documentation

bool PndFsmMdtPid::detected ( PndFsmTrack t) const
private

Definition at line 181 of file PndFsmMdtPid.cxx.

References PndFsmAbsDet::_efficiency, _misId, _pmin, PndFsmAbsDet::_rand, _thtMin, _useFlat, PndFsmTrack::charge(), p, PndFsmTrack::p4(), PndFsmTrack::pdt(), and theta.

Referenced by respond().

182 {
183  double theta = t->p4().Theta();
184  double p=t->p4().Vect().Mag();
185  double charge=t->charge();
186  int type=abs(t->pdt());
187 
188  if (_useFlat) return ( charge!=0.0 && theta>=_thtMin && theta<=_thtMax && p>_pmin && ((type==13 && _rand->Rndm()<=_efficiency) || (type==211 && _rand->Rndm()<=_misId)) );
189 
190  return ( charge!=0.0 && theta>=_thtMin && theta<=_thtMax && p>_pmin );
191 }
Double_t p
Definition: anasim.C:58
double _efficiency
Definition: PndFsmAbsDet.h:93
double charge()
Definition: PndFsmTrack.h:75
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
TLorentzVector p4()
Definition: PndFsmTrack.h:72
double _thtMin
Definition: PndFsmMdtPid.h:77
double _misId
Definition: PndFsmMdtPid.h:80
double _pmin
Definition: PndFsmMdtPid.h:79
const std::string& PndFsmAbsDet::detName ( )
inlineinherited
Bool_t PndFsmAbsDet::doesPid ( ) const
inlineinherited

Definition at line 76 of file PndFsmAbsDet.h.

References PndFsmAbsDet::_doesPid.

Referenced by PndFastSim::Register(), and PndFastSim::smearTrack().

76 {return _doesPid;};
Bool_t _doesPid
Definition: PndFsmAbsDet.h:96
void PndFsmMdtPid::initParameters ( )
privatevirtual

Reimplemented from PndFsmAbsDet.

Definition at line 205 of file PndFsmMdtPid.cxx.

References PndFsmAbsDet::_detName, PndFsmAbsDet::_efficiency, _misId, _parFileName, _pmin, _thtMax, _thtMin, and _useFlat.

Referenced by PndFsmMdtPid().

206 {
207  _detName = "MdtPid";
208  _thtMin = 5.;
209  _thtMax = 160.;
210  _pmin = 1.0;
211  _misId = 0.01;
212  _efficiency = 1.0;
213  _parFileName = "$VMCWORKDIR/fastsim/MdtPidPdf3D.root";
214  _useFlat = false;
215 }
std::string _parFileName
Definition: PndFsmMdtPid.h:84
double _efficiency
Definition: PndFsmAbsDet.h:93
double _thtMin
Definition: PndFsmMdtPid.h:77
double _thtMax
Definition: PndFsmMdtPid.h:78
double _misId
Definition: PndFsmMdtPid.h:80
std::string _detName
Definition: PndFsmAbsDet.h:92
double _pmin
Definition: PndFsmMdtPid.h:79
void PndFsmAbsDet::parseParameterList ( ArgList par)
protectedinherited

Definition at line 119 of file PndFsmAbsDet.cxx.

References CStrTok::GetFirst(), CStrTok::GetNext(), name, and PndFsmAbsDet::setParameter().

Referenced by PndFsmAbsDet::PndFsmAbsDet(), PndFsmCmpDet::PndFsmCmpDet(), PndFsmCombiDet::PndFsmCombiDet(), PndFsmDetTemplate::PndFsmDetTemplate(), PndFsmDrcBarrel::PndFsmDrcBarrel(), PndFsmDrcDisc::PndFsmDrcDisc(), PndFsmEffTracker::PndFsmEffTracker(), PndFsmEmcBarrel::PndFsmEmcBarrel(), PndFsmEmcBwCap::PndFsmEmcBwCap(), PndFsmEmcFS::PndFsmEmcFS(), PndFsmEmcFwCap::PndFsmEmcFwCap(), PndFsmEmcPid::PndFsmEmcPid(), PndFsmIdealPid::PndFsmIdealPid(), PndFsmMdcFS::PndFsmMdcFS(), PndFsmMdcTS::PndFsmMdcTS(), PndFsmMdtPid(), PndFsmMvd::PndFsmMvd(), PndFsmMvd2::PndFsmMvd2(), PndFsmMvdPid::PndFsmMvdPid(), PndFsmRich::PndFsmRich(), PndFsmSimpleTracker::PndFsmSimpleTracker(), PndFsmSimpleVtx::PndFsmSimpleVtx(), PndFsmStt::PndFsmStt(), PndFsmSttPid::PndFsmSttPid(), and PndFsmTof::PndFsmTof().

120 {
121  // ArgList is a std::list<std::string> of the form ("a=1","b=2","c=3","d=4")
122 
123  // Default values for the parameters
124 
125  CStrTok tokenizer;
126  char csrc[200];
127 
128  if (par.size() != 0) {
129 
130  //cout <<"Parameters for detector <"<<_detName<<">"<<endl;
131  for(ArgList::const_iterator argIt=par.begin(); argIt!=par.end();argIt++) {
132 
133  const char *src=argIt->data();
134  strcpy(csrc,src);
135 
136  char* token = tokenizer.GetFirst(csrc,"=");
137  string name(token);
138  //cout <<"variable: -" << name << "- ";
139  token = tokenizer.GetNext("=");
140 
141  double value = atof(token);
142  string strvalue(token);
143 
144  //cout <<"value: -"<<value<<"- "<<endl;
145 
146  if (value!=0 || strvalue=="0" || strvalue=="0.0" || strvalue=="0.")
147  {
148  if (!setParameter(name,value))
149  cout <<" -W- (PndFsmAbsDet::parseParameterList) Unknown Parameter: <"<<name<< endl;
150  }
151  else
152  {
153  if (!setParameter(name,strvalue))
154  cout <<" -W- (PndFsmAbsDet::parseParameterList) Unknown Parameter: <"<<name<< endl;
155  }
156 
157  }
158  }
159 
160  /*
161  if (par.size() != 0) {
162 
163  //cout <<"Parameters for detector <"<<_detName<<">"<<endl;
164  for(ArgList::const_iterator argIt=par.begin(); argIt!=par.end();argIt++) {
165  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
166  boost::char_separator<char> sep("=");
167  tokenizer tokens(*argIt, sep);
168  tokenizer::iterator tok_iter = tokens.begin();
169  string name(*tok_iter);
170  ++tok_iter;
171  double value=atof((*tok_iter).c_str());
172 
173  //cout <<"<"<<name<<"> = "<<value<<endl;
174 
175  string name("efficiency");
176  double value=0.99;
177  if (!setParameter(name,value))
178  cout <<" -W- Unknown Parameter: <"<<name<<"> in PndFsmAbsDet::parseParameterList" << endl;
179  }
180  }
181  */
182  //print(std::cout);
183 
184 }
Double_t par[3]
char * GetFirst(char *lpsz, const char *lpcszDelimiters)
Definition: StrTok.cxx:29
TString name
Definition: StrTok.h:11
virtual bool setParameter(std::string &name, double value)
char * GetNext(const char *lpcszDelimiters)
Definition: StrTok.cxx:37
void PndFsmMdtPid::print ( std::ostream o)
privatevirtual

Reimplemented from PndFsmAbsDet.

Definition at line 194 of file PndFsmMdtPid.cxx.

References PndFsmAbsDet::_efficiency, _misId, _pmin, _thtMax, _thtMin, and PndFsmAbsDet::detName().

195 {
196  o <<"Parameters for detector <"<<detName()<<">"<<endl;
197  o <<" _thtMin = "<<_thtMin<<endl;
198  o <<" _thtMax = "<<_thtMax<<endl;
199  o <<" _pmin = "<<_pmin<<endl;
200  o <<" _misId = "<<_misId<<endl;
201  o <<" _efficiency = "<<_efficiency<<endl;
202 }
double _efficiency
Definition: PndFsmAbsDet.h:93
const std::string & detName()
Definition: PndFsmAbsDet.h:74
double _thtMin
Definition: PndFsmMdtPid.h:77
double _thtMax
Definition: PndFsmMdtPid.h:78
double _misId
Definition: PndFsmMdtPid.h:80
double _pmin
Definition: PndFsmMdtPid.h:79
bool PndFsmMdtPid::readParameters ( )
private

Definition at line 246 of file PndFsmMdtPid.cxx.

References _mdtPidPdf, _parFileName, _useFlat, f, and i.

Referenced by PndFsmMdtPid().

247 {
248 
249  TFile *f=new TFile(_parFileName.c_str());
250 
251  for (int i=0;i<6;i++)
252  {
253  _mdtPidPdf[i]=0;
254  }
255 
256  if (f->IsZombie())
257  {
258  cout <<" -W- (PndFsmMdtPid::readParameters) - file "<<_parFileName.c_str()
259  <<" doesn't exist. Using simple likelihood."<<endl;
260  _useFlat = true;
261  }
262  else
263  {
264  _mdtPidPdf[0]=(TH3F*)f->Get("hpdf_e");
265  _mdtPidPdf[1]=(TH3F*)f->Get("hpdf_mu");
266  _mdtPidPdf[2]=(TH3F*)f->Get("hpdf_pi");
267  _mdtPidPdf[3]=(TH3F*)f->Get("hpdf_k");
268  _mdtPidPdf[4]=(TH3F*)f->Get("hpdf_p");
269  _mdtPidPdf[5]=(TH3F*)f->Get("hpdf_pb");
270 
271  cout << _mdtPidPdf[0]<<endl;
272 
273  for (int i=0;i<6;i++) _mdtPidPdf[i]->SetDirectory(0);
274 
275  f->Close();
276  }
277  delete f;
278 
279  return true;
280 }
std::string _parFileName
Definition: PndFsmMdtPid.h:84
Int_t i
Definition: run_full.C:25
TFile * f
Definition: bump_analys.C:12
TH3F * _mdtPidPdf[6]
Definition: PndFsmMdtPid.h:75
PndFsmResponse * PndFsmMdtPid::respond ( PndFsmTrack t)
virtual

Accessors to contained information

Implements PndFsmAbsDet.

Definition at line 97 of file PndFsmMdtPid.cxx.

References _mdtPidPdf, _misId, _useFlat, PndFsmTrack::charge(), detected(), idx, P, p, PndFsmTrack::p4(), PndFsmTrack::pdt(), PndFsmResponse::setDetected(), PndFsmResponse::setDetector(), PndFsmResponse::setLHElectron(), PndFsmResponse::setLHKaon(), PndFsmResponse::setLHMuon(), PndFsmResponse::setLHPion(), PndFsmResponse::setLHProton(), PndFsmResponse::setMuoIron(), and tht().

98 {
99  PndFsmResponse *result=new PndFsmResponse();
100 
101  result->setDetector(this);
102  bool wasDetected=detected(t);
103  result->setDetected(wasDetected);
104 
105  if (wasDetected)
106  {
107  if (_useFlat) // just use very simple likelihoods for muons and pions
108  {
109  result->setLHElectron(0.);
110  result->setLHMuon( 1-_misId );
111  result->setLHPion( _misId );
112  result->setLHKaon( 0. );
113  result->setLHProton( 0. );
114  }
115  else // use sophisticated methode with histogram lookup likelihoods
116  {
117  int type = t->pdt();
118  double p = t->p4().Vect().Mag();
119  double tht = t->p4().Theta()*57.296;
120  double charge = t->charge();
121 
122  // convert pdg code in type: 0=e+-, 1=mu+-, 2=pi+-, 3=K+-, 4=p, 5=p-bar
123  int idx;
124  if (abs(type)==11) idx=0;
125  else if (abs(type)==13) idx=1;
126  else if (abs(type)==211) idx=2;
127  else if (abs(type)==321) idx=3;
128  else if (type==2212) idx=4;
129  else idx=5;
130 
131  // histogram max p = 8.0
132  if (p>7.99) p=7.99;
133 
134  // get the bin corresponding to p
135  int currbinT = _mdtPidPdf[0]->GetYaxis()->FindBin(tht);
136  int currbinP = _mdtPidPdf[0]->GetZaxis()->FindBin(p);
137 
138  // get the slice containing the pdf emcecal(p) for true particle type
139  TH1D *hpdf = _mdtPidPdf[idx]->ProjectionX("_tmppdf",currbinT, currbinT, currbinP, currbinP);
140 
141  // get a random emcecal value from the true distribution
142  // if distribution is empty, choose 0
143  double xsig = 0.;
144  if (hpdf->Integral()>0) xsig = hpdf->GetRandom();
145 
146  // store the value in the response object
147  result->setMuoIron(xsig);
148 
149  // find the bin corresponding to the value
150  int xsigbin = hpdf->FindBin(xsig);
151 
152  // get the probability values for the different particle types for this emcecal value; sum needed for normalization
153  double P[6], Psum=0.;
154 
155  // sum up e ... K
156  for (int k=0;k<6;++k)
157  {
158  P[k] = _mdtPidPdf[k]->GetBinContent(xsigbin,currbinT,currbinP);
159  if (k<4) Psum += P[k];
160  }
161  // add P_p or P_pbar depending on charge of particle
162  if (charge>0) Psum+=P[4];
163  else Psum+=P[5];
164 
165  if (Psum<=0.) Psum=1.;
166 
167  result->setLHElectron(P[0]/Psum);
168  result->setLHMuon(P[1]/Psum);
169  result->setLHPion(P[2]/Psum);
170  result->setLHKaon(P[3]/Psum);
171  if (charge>0) result->setLHProton(P[4]/Psum);
172  else result->setLHProton(P[5]/Psum);
173 
174  }
175  }
176 
177  return result;
178 }
Double_t p
Definition: anasim.C:58
void setLHElectron(double val)
void setLHProton(double val)
void setLHMuon(double val)
double charge()
Definition: PndFsmTrack.h:75
bool detected(PndFsmTrack *t) const
void setMuoIron(double val)
int idx[MAX]
Definition: autocutx.C:38
TLorentzVector p4()
Definition: PndFsmTrack.h:72
void setDetector(PndFsmAbsDet *detector)
TString tht(TString pts, TString exts="px py pz")
Definition: invexp.C:168
void setLHKaon(double val)
double _misId
Definition: PndFsmMdtPid.h:80
TH3F * _mdtPidPdf[6]
Definition: PndFsmMdtPid.h:75
GeV c P
void setDetected(bool isdet)
void setLHPion(double val)
void PndFsmAbsDet::setName ( std::string &  name)
inlineinherited

Definition at line 75 of file PndFsmAbsDet.h.

References PndFsmAbsDet::_detName, and name.

Referenced by PndFsmDetFactory::create().

75 {_detName = name;};
TString name
std::string _detName
Definition: PndFsmAbsDet.h:92
bool PndFsmMdtPid::setParameter ( std::string &  name,
double  value 
)
privatevirtual

Reimplemented from PndFsmAbsDet.

Definition at line 218 of file PndFsmMdtPid.cxx.

References PndFsmAbsDet::_efficiency, _misId, _pmin, _thtMax, and _thtMin.

219 {
220  // *****************
221  // include here all parameters which should be settable via tcl
222  // *****************
223 
224  bool knownName=true;
225 
226  if (name == "thtMin")
227  _thtMin=value;
228  else
229  if (name == "thtMax")
230  _thtMax=value;
231  else
232  if (name == "pmin")
233  _pmin=value;
234  else
235  if (name == "misId")
236  _misId=value;
237  else
238  if (name == "efficiency")
239  _efficiency=value;
240  else
241  knownName=false;
242 
243  return knownName;
244 }
double _efficiency
Definition: PndFsmAbsDet.h:93
double _thtMin
Definition: PndFsmMdtPid.h:77
double _thtMax
Definition: PndFsmMdtPid.h:78
TString name
double _misId
Definition: PndFsmMdtPid.h:80
double _pmin
Definition: PndFsmMdtPid.h:79
bool PndFsmAbsDet::setParameter ( std::string &  name,
std::string &  value 
)
protectedvirtualinherited

Reimplemented in PndFsmDrcBarrel, PndFsmDrcDisc, PndFsmCombiDet, and PndFsmCmpDet.

Definition at line 99 of file PndFsmAbsDet.cxx.

100 {
101  return false;
102 }
void PndFsmAbsDet::setStorePid ( Bool_t  doespid = kTRUE)
inlineinherited

Definition at line 77 of file PndFsmAbsDet.h.

References PndFsmAbsDet::_doesPid.

Referenced by PndFsmDetFactory::create().

77 {_doesPid=doespid;};
Bool_t _doesPid
Definition: PndFsmAbsDet.h:96

Member Data Documentation

std::string PndFsmAbsDet::_detName
protectedinherited
Bool_t PndFsmAbsDet::_doesPid
protectedinherited
double PndFsmAbsDet::_efficiency
protectedinherited

Definition at line 93 of file PndFsmAbsDet.h.

Referenced by PndFsmDetTemplate::detected(), PndFsmSimpleTracker::detected(), PndFsmMvd2::detected(), PndFsmEmcFwCap::detected(), PndFsmMdcTS::detected(), PndFsmMdcFS::detected(), PndFsmTof::detected(), PndFsmSttPid::detected(), PndFsmMvd::detected(), PndFsmEmcBwCap::detected(), PndFsmEmcFS::detected(), PndFsmStt::detected(), PndFsmSimpleVtx::detected(), PndFsmMvdPid::detected(), PndFsmRich::detected(), PndFsmEmcBarrel::detected(), PndFsmDrcDisc::detected(), detected(), PndFsmDrcBarrel::detected(), PndFsmEmcPid::detected(), PndFsmEffTracker::detected(), PndFsmSimpleTracker::initParameters(), PndFsmSimpleVtx::initParameters(), PndFsmDetTemplate::initParameters(), PndFsmMvdPid::initParameters(), PndFsmTof::initParameters(), initParameters(), PndFsmEmcPid::initParameters(), PndFsmMvd2::initParameters(), PndFsmEmcFwCap::initParameters(), PndFsmRich::initParameters(), PndFsmMdcFS::initParameters(), PndFsmSttPid::initParameters(), PndFsmMdcTS::initParameters(), PndFsmEmcBwCap::initParameters(), PndFsmEmcFS::initParameters(), PndFsmEmcBarrel::initParameters(), PndFsmDrcDisc::initParameters(), PndFsmDrcBarrel::initParameters(), PndFsmStt::initParameters(), PndFsmMvd::initParameters(), PndFsmEffTracker::initParameters(), PndFsmSimpleTracker::print(), PndFsmSimpleVtx::print(), PndFsmDetTemplate::print(), PndFsmMvdPid::print(), PndFsmTof::print(), print(), PndFsmEmcPid::print(), PndFsmSttPid::print(), PndFsmMdcFS::print(), PndFsmMdcTS::print(), PndFsmEmcBwCap::print(), PndFsmMvd2::print(), PndFsmEmcFS::print(), PndFsmEmcFwCap::print(), PndFsmRich::print(), PndFsmDrcDisc::print(), PndFsmEmcBarrel::print(), PndFsmDrcBarrel::print(), PndFsmStt::print(), PndFsmMvd::print(), PndFsmEffTracker::print(), PndFsmSimpleTracker::setParameter(), PndFsmMvdPid::setParameter(), PndFsmDetTemplate::setParameter(), PndFsmSimpleVtx::setParameter(), setParameter(), PndFsmTof::setParameter(), PndFsmEmcPid::setParameter(), PndFsmEmcFS::setParameter(), PndFsmEmcBwCap::setParameter(), PndFsmMdcTS::setParameter(), PndFsmMvd2::setParameter(), PndFsmSttPid::setParameter(), PndFsmEmcFwCap::setParameter(), PndFsmMdcFS::setParameter(), PndFsmRich::setParameter(), PndFsmEmcBarrel::setParameter(), PndFsmDrcDisc::setParameter(), PndFsmDrcBarrel::setParameter(), PndFsmStt::setParameter(), PndFsmMvd::setParameter(), and PndFsmEffTracker::setParameter().

TDatabasePDG* PndFsmAbsDet::_fdbPDG
protectedinherited
TH3F* PndFsmMdtPid::_mdtPidPdf[6]
private

Definition at line 75 of file PndFsmMdtPid.h.

Referenced by readParameters(), and respond().

double PndFsmMdtPid::_misId
private

Definition at line 80 of file PndFsmMdtPid.h.

Referenced by detected(), initParameters(), print(), respond(), and setParameter().

std::string PndFsmMdtPid::_parFileName
private

Definition at line 84 of file PndFsmMdtPid.h.

Referenced by initParameters(), and readParameters().

double PndFsmMdtPid::_pmin
private

Definition at line 79 of file PndFsmMdtPid.h.

Referenced by detected(), initParameters(), print(), and setParameter().

TRandom3* PndFsmAbsDet::_rand
protectedinherited
double PndFsmMdtPid::_thtMax
private

Definition at line 78 of file PndFsmMdtPid.h.

Referenced by initParameters(), PndFsmMdtPid(), print(), and setParameter().

double PndFsmMdtPid::_thtMin
private

Definition at line 77 of file PndFsmMdtPid.h.

Referenced by detected(), initParameters(), PndFsmMdtPid(), print(), and setParameter().

bool PndFsmMdtPid::_useFlat
private

Definition at line 82 of file PndFsmMdtPid.h.

Referenced by detected(), initParameters(), readParameters(), and respond().


The documentation for this class was generated from the following files: