FairRoot/PandaRoot
PndFsmAbsDet.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: FsmAbsDet.cc,v 1.2 2006/07/13 10:43:45 klausg Exp $
4 //
5 // Description:
6 // Class FsmAbsDet
7 //
8 // Response of FsmDet for a FsmTrack
9 //
10 // This software was developed for the PANDA collaboration. If you
11 // use all or part of it, please give an appropriate acknowledgement.
12 //
13 // Author List:
14 // Klaus Goetzen Original Author
15 //
16 // Copyright Information:
17 // Copyright (C) 2006 GSI
18 //
19 //------------------------------------------------------------------------
20 
21 //-----------------------
22 // This Class's Header --
23 //-----------------------
24 #include "PndFsmRandom.h"
25 #include "PndFsmAbsDet.h"
26 #include "StrTok.h"
27 
28 //-------------
29 // C Headers --
30 //-------------
31 
32 //---------------
33 // C++ Headers --
34 //---------------
35 #include <iostream>
36 #include <algorithm>
37 using std::cout;
38 using std::endl;
39 using std::ostream;
40 using std::string;
41 
42 //-------------------------------
43 // Collaborating Class Headers --
44 //-------------------------------
45 //#include "ErrLogger/ErrLog.hh"
46 //#include "boost/boost/tokenizer.hpp"
47 
48 //-----------------------------------------------------------------------
49 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
50 //-----------------------------------------------------------------------
51 
52 //----------------
53 // Constructors --
54 //----------------
55 
57 {
59 
60  ArgList par;
61  //set default parameter values and parses a parameter list
62  parseParameterList(par);
64  _fdbPDG = TDatabasePDG::Instance();
65  _doesPid=kFALSE;
66 }
67 
69 {
71  //set default parameter values and parses a parameter list
72  //i.e. std::list<std::string> of the form
73  //"a=1" "b=2" "c=3"
74  parseParameterList(par);
75  _rand=new TRandom3();
76  _fdbPDG = TDatabasePDG::Instance();
77  _doesPid=kFALSE;
78 }
79 
80 //--------------
81 // Destructor --
82 //--------------
83 
85 {
86 }
87 
88 //--------------
89 // Operations --
90 //--------------
91 
92 bool
93 PndFsmAbsDet::setParameter(std::string &, double ) // name value //[R.K.03/2017] unused variable(s)
94 {
95  return false;
96 }
97 
98 bool
99 PndFsmAbsDet::setParameter(std::string &, std::string &) // name value //[R.K.03/2017] unused variable(s)
100 {
101  return false;
102 }
103 
104 void
106 {
107  _detName = "default";
108 }
109 
110 
111 void
113 {
114  o<<"Detector:"<<detName()<<endl;
115 }
116 
117 
118 void
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 }
185 
186 
TDatabasePDG * _fdbPDG
Definition: PndFsmAbsDet.h:95
std::list< std::string > ArgList
Definition: ArgList.h:7
virtual void initParameters()
Double_t par[3]
virtual ~PndFsmAbsDet()
void parseParameterList(ArgList &par)
Bool_t _doesPid
Definition: PndFsmAbsDet.h:96
virtual void print(std::ostream &o)
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
basic_ostream< char, char_traits< char > > ostream
const std::string & detName()
Definition: PndFsmAbsDet.h:74
char * GetFirst(char *lpsz, const char *lpcszDelimiters)
Definition: StrTok.cxx:29
TString name
static TRandom3 * Instance()
Definition: PndFsmRandom.cxx:4
std::string _detName
Definition: PndFsmAbsDet.h:92
Definition: StrTok.h:11
virtual bool setParameter(std::string &name, double value)
char * GetNext(const char *lpcszDelimiters)
Definition: StrTok.cxx:37