FairRoot/PandaRoot
PndFsmDetFactory.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: FsmDetFactory.cc,v 1.12 2007/05/24 08:07:40 klausg Exp $
4 //
5 // Description:
6 // Class FsmDetFactory
7 //
8 // Factory for FsmDetectors
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 // Ralf Kliemt
16 //
17 // Copyright Information:
18 // Copyright (C) 2006 GSI
19 //
20 //------------------------------------------------------------------------
21 
22 //-----------------------
23 // This Class's Header --
24 //-----------------------
25 #include "PndFsmDetFactory.h"
26 
27 //-------------
28 // C Headers --
29 //-------------
30 
31 //---------------
32 // C++ Headers --
33 //---------------
34 #include <iostream>
35 
36 //-------------------------------
37 // Collaborating Class Headers --
38 //-------------------------------
39 //#include "ErrLogger/ErrLog.hh"
40 #include "StrTok.h"
41 #include "TString.h"
42 
43 
44 #include "PndFsmEmcBarrel.h"
45 #include "PndFsmEmcFwCap.h"
46 #include "PndFsmEmcBwCap.h"
47 #include "PndFsmEmcFS.h"
48 #include "PndFsmStt.h"
49 #include "PndFsmMdcFS.h"
50 #include "PndFsmMdcTS.h"
51 #include "PndFsmEffTracker.h"
52 #include "PndFsmDrcBarrel.h"
53 #include "PndFsmDrcDisc.h"
54 #include "PndFsmMvd.h"
55 #include "PndFsmMvd2.h"
56 #include "PndFsmTof.h"
57 #include "PndFsmRich.h"
58 #include "PndFsmSimpleTracker.h"
59 #include "PndFsmCmpDet.h"
60 #include "PndFsmCombiDet.h"
61 #include "PndFsmMvdPid.h"
62 #include "PndFsmSttPid.h"
63 #include "PndFsmMdtPid.h"
64 #include "PndFsmEmcPid.h"
65 #include "PndFsmSimpleVtx.h"
66 #include "PndFsmIdealPid.h"
67 
68 //-----------------------------------------------------------------------
69 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
70 //-----------------------------------------------------------------------
71 
72 //----------------
73 // Constructors --
74 //----------------
75 
77 {
78 }
79 
80 //--------------
81 // Destructor --
82 //--------------
83 
85 {
86 }
87 
88 //--------------
89 // Operations --
90 //--------------
91 
94 {
95  TString tname(name);
96 
97  if (tname.BeginsWith("EmcBarrel")){
98  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEmcBarrel(par));
99  aDet->setName(name);
100  return aDet;
101  } else
102  if (tname=="EmcFwCap"){
103  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEmcFwCap(par));
104  aDet->setName(name);
105  return aDet;
106  } else
107  if (tname=="EmcBwCap"){
108  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEmcBwCap(par));
109  aDet->setName(name);
110  return aDet;
111  } else
112  if (tname=="EmcFS"){
113  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEmcFS(par));
114  aDet->setName(name);
115  return aDet;
116  } else
117  if (tname=="Stt"){
118  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmStt(par));
119  aDet->setName(name);
120  return aDet;
121  } else
122  if (tname=="MdcFS"){
123  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMdcFS(par));
124  aDet->setName(name);
125  return aDet;
126  } else
127  if (tname=="MdcTS"){
128  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMdcTS(par));
129  aDet->setName(name);
130  return aDet;
131  } else
132  if (tname.BeginsWith("EffTracker")){
133  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEffTracker(par));
134  aDet->setName(name);
135  return aDet;
136  } else
137  if (tname=="DrcBarrel"){
138  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmDrcBarrel(par));
139  aDet->setName(name);
140  aDet->setStorePid();
141  return aDet;
142  } else
143  if (tname=="DrcDisc"){
144  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmDrcDisc(par));
145  aDet->setName(name);
146  aDet->setStorePid();
147  return aDet;
148  } else
149  if (tname=="Mvd"){
150  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMvd(par));
151  aDet->setName(name);
152  aDet->setStorePid();
153  return aDet;
154  } else
155  if (tname=="Mvd2"){
156  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMvd2(par));
157  aDet->setName(name);
158  aDet->setStorePid();
159  return aDet;
160  } else
161  if (tname=="Tof"){
162  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmTof(par));
163  aDet->setName(name);
164  aDet->setStorePid();
165  return aDet;
166  } else
167  if (tname=="Rich"){
168  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmRich(par));
169  aDet->setName(name);
170  aDet->setStorePid();
171  return aDet;
172  } else
173  // --- scrutiny process options
174  if (tname.BeginsWith("ScSttAlone") || tname.BeginsWith("ScSttMvd") || tname.BeginsWith("ScSttMvdGem") ||
175  tname.BeginsWith("ScSttGem") || tname.BeginsWith("ScMvdGem") || tname.BeginsWith("ScMvdGemFts") ||
176  tname.BeginsWith("ScMvdFts") || tname.BeginsWith("ScGemFts") || tname=="ScFts" ) {
177  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmSimpleTracker(par));
178  aDet->setName(name);
179  return aDet;
180  } else
181  if (tname=="MvdPid") {
182  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMvdPid(par) );
183  aDet->setStorePid();
184  return aDet;
185  } else
186  if (tname.BeginsWith("ScEmcPidBarrel") || tname=="ScEmcPidFwCap" || tname=="ScEmcPidBwCap" || tname=="ScEmcPidFS"){
187  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmEmcPid(par) );
188  aDet->setName(name);
189  aDet->setStorePid();
190  return aDet;
191  } else
192  if (tname=="SttPid"){
193  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmSttPid(par) );
194  aDet->setStorePid();
195  return aDet;
196  }
197  if (tname=="ScVtxMvd" || tname=="ScVtxNoMvd") {
198  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmSimpleVtx(par));
199  aDet->setName(name);
200  return aDet;
201  } else
202  if (tname=="ScMdtPidBarrel" || tname=="ScMdtPidForward") {
203  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmMdtPid(par));
204  aDet->setName(name);
205  aDet->setStorePid();
206  return aDet;
207  }
208  // general Options
209  else
210  if (tname.BeginsWith("SimpleTracker")) {
211  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmSimpleTracker(par));
212  aDet->setName(name);
213  return aDet;
214  } else
215  if (tname.BeginsWith("SimpleVtx")) {
216  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmSimpleVtx(par));
217  aDet->setName(name);
218  return aDet;
219  } else
220  if (tname=="IdealPid") {
221  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmIdealPid(par));
222  aDet->setName(name);
223  aDet->setStorePid();
224  return aDet;
225  }
226  if (tname=="CmpDet") {
227  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmCmpDet(par));
228  aDet->setName(name);
229  return aDet;
230  } else
231  if (tname=="CombiDet") {
232  PndFsmAbsDet* aDet = (PndFsmAbsDet*)(new PndFsmCombiDet(par));
233  aDet->setName(name);
234  return aDet;
235  } else {
236  std::cout <<" -W- (PndFsmDetFactory::create) Unknown detector: <"<<name<<">"<< std::endl;
237  return 0;
238  }
239 }
240 
242 PndFsmDetFactory::create(std::string &name, std::string par)
243 {
244  // par is a string of the form "a=1 b=2 c=3 d=4"
245  // this function splits the single assignments in the string to an ArgList
246  // i.e. a std::list<std::string> of the form ("a=1","b=2","c=3","d=4")
247 
248  ArgList parList;
249 
250  CStrTok tokenizer;
251  char csrc[200];
252 
253  const char *src=par.data();
254  strcpy(csrc,src);
255 
256  char* token = tokenizer.GetFirst(csrc, " \t");
257 
258  while(token)
259  {
260  parList.push_back(token);
261  token=tokenizer.GetNext(" \t");
262  }
263 
264  /*
265  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
266  boost::char_separator<char> sep_blank(" ");
267  tokenizer tokens_bl(par, sep_blank);
268 
269  for (tokenizer::iterator tok_iter_bl = tokens_bl.begin();tok_iter_bl!=tokens_bl.end();tok_iter_bl++)
270  parList.push_back(*tok_iter_bl);
271  */
272 
273  return (PndFsmAbsDet*)create(name, parList);
274 }
275 
std::list< std::string > ArgList
Definition: ArgList.h:7
void setStorePid(Bool_t doespid=kTRUE)
Definition: PndFsmAbsDet.h:77
Double_t par[3]
void setName(std::string &name)
Definition: PndFsmAbsDet.h:75
char * GetFirst(char *lpsz, const char *lpcszDelimiters)
Definition: StrTok.cxx:29
PndFsmAbsDet * create(std::string &name, ArgList &par)
TString name
Definition: StrTok.h:11
char * GetNext(const char *lpcszDelimiters)
Definition: StrTok.cxx:37