StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FtfPara.cxx
1 //:>------------------------------------------------------------------
2 //: FILE: FtfPara.cxx
3 //: HISTORY:
4 //: 28oct1996 version 1.00
5 //: 7dec1998 ppy variable names changed to C++ style
6 //: 3jun1999 ppy add fillTracks flag
7 //: 11aug1999 ppy add vertexContrainedFit variable
8 //: 23aug1999 ppy add Root option
9 //: 11feb2000 ppy add maxTime
10 //: 13mar2000 ppy add default value for rowEnd
11 //:
12 //:<------------------------------------------------------------------
13 //:>------------------------------------------------------------------
14 //: CLASS: FtfPara
15 //: DESCRIPTION: Functions associated with this class
16 //: AUTHOR: ppy - Pablo Yepes, yepes@physics.rice.edu
17 //:>------------------------------------------------------------------
18 #include "FtfFinder.h"
19 
20 
21 void FtfPara::read ( char* inputFile ) {
22 
23  FILE* dataFile = fopen( inputFile, "r");
24  if (dataFile == NULL) {
25  printf ( "FtfPara::write: Error opening input file %s \n", inputFile ) ;
26  return ;
27  }
28 
29  char* name = new char[100] ;
30  while ( 1 ) {
31  if ( fscanf ( dataFile, "%s", name ) == EOF ) break ;
32  if ( !strncmp(name,"infoLevel" ,8) ) {
33  fscanf ( dataFile, "%d", &infoLevel ) ;
34  continue ;
35  }
36  if ( !strncmp(name,"segmentRowSearch",8) ) {
37  fscanf ( dataFile, "%d", &segmentRowSearchRange ) ;
38  continue ;
39  }
40  if ( !strncmp(name,"trackRowSearch", 8) ) {
41  fscanf ( dataFile, "%d", &trackRowSearchRange ) ;
42  continue ;
43  }
44  if ( !strncmp(name,"getErrors ", 8) ) {
45  fscanf ( dataFile, "%d", &getErrors ) ;
46  continue ;
47  }
48  if ( !strncmp(name,"fillTracks ", 8) ) {
49  fscanf ( dataFile, "%d", &fillTracks ) ;
50  continue ;
51  }
52  if ( !strncmp(name,"ghostFlag ", 8) ) {
53  fscanf ( dataFile, "%d", &ghostFlag ) ;
54  continue ;
55  }
56  if ( !strncmp(name,"goBackwards ", 8) ) {
57  fscanf ( dataFile, "%d", &goBackwards ) ;
58  continue ;
59  }
60  if ( !strncmp(name,"mergePrimaries", 8) ) {
61  fscanf ( dataFile, "%d", &mergePrimaries ) ;
62  continue ;
63  }
64  if ( !strncmp(name,"minHitsPerTrack", 8) ) {
65  fscanf ( dataFile, "%d", &minHitsPerTrack ) ;
66  continue ;
67  }
68  if ( !strncmp(name,"modRow", 6) ) {
69  fscanf ( dataFile, "%d", &modRow ) ;
70  continue ;
71  }
72  if ( !strncmp(name,"nHitsForSegment", 8) ) {
73  fscanf ( dataFile, "%d", &nHitsForSegment ) ;
74  continue ;
75  }
76  if ( !strncmp(name,"minHitsForFit", 8) ) {
77  fscanf ( dataFile, "%d", &minHitsForFit ) ;
78  continue ;
79  }
80  if ( !strncmp(name,"nEtaTrack", 8) ) {
81  fscanf ( dataFile, "%i", &nEtaTrack ) ;
82  continue;
83  }
84  if ( !strncmp(name,"nEta", 4) ) {
85  fscanf ( dataFile, "%d", &nEta ) ;
86  continue ;
87  }
88  if ( !strncmp(name,"nPhiTrack", 8) ) {
89  fscanf ( dataFile, "%d", &nPhiTrack ) ;
90  continue ;
91  }
92  if ( !strncmp(name,"nPhi", 4) ) {
93  fscanf ( dataFile, "%d", &nPhi ) ;
94  continue ;
95  }
96  if ( !strncmp(name,"detaMerge ", 8) ) {
97  fscanf ( dataFile, "%e", &detaMerge ) ;
98  continue ;
99  }
100  if ( !strncmp(name,"deta ", 4) ) {
101  fscanf ( dataFile, "%e", &deta ) ;
102  continue ;
103  }
104  if ( !strncmp(name,"dphiMerge ", 8) ) {
105  fscanf ( dataFile, "%e", &dphiMerge ) ;
106  continue ;
107  }
108  if ( !strncmp(name,"dphi ", 4) ) {
109  fscanf ( dataFile, "%e", &dphi ) ;
110  continue ;
111  }
112  if ( !strncmp(name,"etaMinTrack ", 8) ) {
113  fscanf ( dataFile, "%e", &etaMinTrack ) ;
114  continue ;
115  }
116  if ( !strncmp(name,"etaMin", 6) ) {
117  fscanf ( dataFile, "%e", &etaMin ) ;
118  continue ;
119  }
120  if ( !strncmp(name,"etaMaxTrack ", 8) ) {
121  fscanf ( dataFile, "%e", &etaMaxTrack ) ;
122  continue ;
123  }
124  if ( !strncmp(name,"etaMax ", 6) ) {
125  fscanf ( dataFile, "%e", &etaMax ) ;
126  continue ;
127  }
128  if ( !strncmp(name,"phiMinTrack ", 8) ) {
129  fscanf ( dataFile, "%e", &phiMinTrack ) ;
130  continue ;
131  }
132  if ( !strncmp(name,"phiMin ", 6) ) {
133  fscanf ( dataFile, "%e", &phiMin ) ;
134  continue ;
135  }
136  if ( !strncmp(name,"phiMaxTrack ", 8) ) {
137  fscanf ( dataFile, "%e", &phiMaxTrack ) ;
138  continue ;
139  }
140  if ( !strncmp(name,"phiMax ", 6) ) {
141  fscanf ( dataFile, "%e", &phiMax ) ;
142  continue ;
143  }
144  if ( !strncmp(name,"phiShift ", 8) ) {
145  fscanf ( dataFile, "%e", &phiShift ) ;
146  continue ;
147  }
148  if ( !strncmp(name,"distanceMerge", 8) ) {
149  fscanf ( dataFile, "%e", &distanceMerge ) ;
150  continue ;
151  }
152  if ( !strncmp(name,"nPrimaryPasses", 8) ) {
153  fscanf ( dataFile, "%d", &nPrimaryPasses ) ;
154  continue ;
155  }
156  if ( !strncmp(name,"nSecondary", 8) ) {
157  fscanf ( dataFile, "%d", &nSecondaryPasses ) ;
158  continue ;
159  }
160  if ( !strncmp(name,"vertexConstrainedFit", 8) ) {
161  fscanf ( dataFile, "%d", &vertexConstrainedFit ) ;
162  continue ;
163  }
164  if ( !strncmp(name,"parameterLocation", 8) ) {
165  fscanf ( dataFile, "%d", &parameterLocation ) ;
166  continue ;
167  }
168  if ( !strncmp(name,"rowInnerMost", 8) ) {
169  fscanf ( dataFile, "%d", &rowInnerMost ) ;
170  continue ;
171  }
172  if ( !strncmp(name,"rowOuterMost", 8) ) {
173  fscanf ( dataFile, "%d", &rowOuterMost ) ;
174  continue ;
175  }
176  if ( !strncmp(name,"rowStart", 8) ) {
177  fscanf ( dataFile, "%d", &rowStart ) ;
178  continue ;
179  }
180  if ( !strncmp(name,"rowEnd", 6) ) {
181  fscanf ( dataFile, "%d", &rowEnd ) ;
182  continue ;
183  }
184  if ( !strncmp(name,"szFitFlag", 8) ) {
185  fscanf ( dataFile, "%d", &szFitFlag ) ;
186  continue ;
187  }
188  if ( !strncmp(name,"bField", 6) ) {
189  fscanf ( dataFile, "%e", &bField ) ;
190  continue ;
191  }
192  if ( !strncmp(name,"maxChi2Primary", 12) ) {
193  fscanf ( dataFile, "%e", &maxChi2Primary ) ;
194  continue ;
195  }
196  if ( !strncmp(name,"hitChi2Cut", 8) ) {
197  fscanf ( dataFile, "%e", &hitChi2Cut ) ;
198  continue ;
199  }
200  if ( !strncmp(name,"goodHitChi2", 8) ) {
201  fscanf ( dataFile, "%e", &goodHitChi2 ) ;
202  continue ;
203  }
204  if ( !strncmp(name,"trackChi2Cut", 8) ) {
205  fscanf ( dataFile, "%e", &trackChi2Cut ) ;
206  continue ;
207  }
208  if ( !strncmp(name,"goodDistance", 8) ) {
209  fscanf ( dataFile, "%e", &goodDistance ) ;
210  continue ;
211  }
212  if ( !strncmp(name,"ptMinHelixFit", 8) ) {
213  fscanf ( dataFile, "%e", &ptMinHelixFit ) ;
214  continue ;
215  }
216  if ( !strncmp(name,"maxDistanceSegment", 15) ) {
217  fscanf ( dataFile, "%e", &maxDistanceSegment ) ;
218  continue ;
219  }
220  if ( !strncmp(name,"xyErrorScale", 10) ) {
221  fscanf ( dataFile, "%e", &xyErrorScale ) ;
222  continue ;
223  }
224  if ( !strncmp(name,"szErrorScale", 10) ) {
225  fscanf ( dataFile, "%e", &szErrorScale ) ;
226  continue ;
227  }
228  if ( !strncmp(name,"xVertex", 7) ) {
229  fscanf ( dataFile, "%e", &xVertex ) ;
230  continue ;
231  }
232  if ( !strncmp(name,"yVertex", 7) ) {
233  fscanf ( dataFile, "%e", &yVertex ) ;
234  continue ;
235  }
236  if ( !strncmp(name,"zVertex", 7) ) {
237  fscanf ( dataFile, "%e", &zVertex ) ;
238  continue ;
239  }
240  if ( !strncmp(name,"dxVertex", 8) ) {
241  fscanf ( dataFile, "%e", &dxVertex ) ;
242  continue ;
243  }
244  if ( !strncmp(name,"dyVertex", 8) ) {
245  fscanf ( dataFile, "%e", &dyVertex ) ;
246  continue ;
247  }
248  if ( !strncmp(name,"xyWeightVertex", 8) ) {
249  fscanf ( dataFile, "%e", &xyWeightVertex ) ;
250  continue ;
251  }
252  if ( !strncmp(name,"phiVertex", 8) ) {
253  fscanf ( dataFile, "%e", &phiVertex ) ;
254  continue ;
255  }
256  if ( !strncmp(name,"rVertex", 7) ) {
257  fscanf ( dataFile, "%e", &rVertex ) ;
258  continue ;
259  }
260  if ( !strncmp(name,"maxTime", 7) ) {
261  fscanf ( dataFile, "%e", &maxTime ) ;
262  continue ;
263  }
264  printf ( "FtfPara::read: parameter %s not found \n", name ) ;
265  float variable ;
266  fscanf ( dataFile, "%e", &variable ) ;
267 
268  }
269 
270  fclose ( dataFile ) ;
271 
272 }
273 
274 void FtfPara::write ( char* outputFile ) {
275  FILE* dataFile = fopen( outputFile, "w");
276  if (dataFile == NULL) {
277  printf ( "FtfPara::write: Error opening output file %s \n ", outputFile ) ;
278  return ;
279  }
280  write ( dataFile ) ;
281  fclose ( dataFile ) ;
282 }
283 
284 void FtfPara::write ( FILE* dataFile ) {
285 
286  fprintf ( dataFile, "infoLevel %10d \n", infoLevel ) ;
287  fprintf ( dataFile, "segmentRowSearch %10d \n", segmentRowSearchRange ) ;
288  fprintf ( dataFile, "trackRowSearch %10d \n", trackRowSearchRange ) ;
289  fprintf ( dataFile, "getErrors %10d \n", getErrors ) ;
290  fprintf ( dataFile, "fillTracks %10d \n", fillTracks ) ;
291  fprintf ( dataFile, "ghostFlag %10d \n", ghostFlag ) ;
292  fprintf ( dataFile, "goBackwards %10d \n", goBackwards ) ;
293  fprintf ( dataFile, "mergePrimaries %10d \n", mergePrimaries ) ;
294  fprintf ( dataFile, "minHitsPerTrack %10d \n", minHitsPerTrack ) ;
295  fprintf ( dataFile, "modRow %10d \n", modRow ) ;
296  fprintf ( dataFile, "nHitsForSegment %10d \n", nHitsForSegment ) ;
297 // fprintf ( dataFile, "minHitsForFit %10d \n", minHitsForFit ) ;
298  fprintf ( dataFile, "nEta %10d \n", nEta ) ;
299  fprintf ( dataFile, "nPhi %10d \n", nPhi ) ;
300  fprintf ( dataFile, "deta %10.2e\n", deta ) ;
301  fprintf ( dataFile, "dphi %10.2e\n", dphi ) ;
302  fprintf ( dataFile, "etaMin %10.2e\n", etaMin ) ;
303  fprintf ( dataFile, "etaMax %10.2e\n", etaMax ) ;
304  fprintf ( dataFile, "phiMin %10.2e\n", phiMin ) ;
305  fprintf ( dataFile, "phiMax %10.2e\n", phiMax ) ;
306  fprintf ( dataFile, "phiShift %10.2e\n", phiShift ) ;
307  fprintf ( dataFile, "detaMerge %10.2e\n", detaMerge ) ;
308  fprintf ( dataFile, "distanceMerge %10.2e\n", distanceMerge ) ;
309  fprintf ( dataFile, "nEtaTrack %10d \n", nEtaTrack ) ;
310  fprintf ( dataFile, "nPhiTrack %10d \n", nPhiTrack ) ;
311  fprintf ( dataFile, "etaMinTrack %10.2e\n", etaMinTrack ) ;
312  fprintf ( dataFile, "etaMaxTrack %10.2e\n", etaMaxTrack ) ;
313  fprintf ( dataFile, "phiMinTrack %10.2e\n", phiMinTrack ) ;
314  fprintf ( dataFile, "phiMaxTrack %10.2e\n", phiMaxTrack ) ;
315  fprintf ( dataFile, "nPrimaryPasses %10d \n", nPrimaryPasses ) ;
316  fprintf ( dataFile, "nSecondaryPasses %10d \n", nSecondaryPasses ) ;
317  fprintf ( dataFile, "vertexConstrainedFit %10d \n", vertexConstrainedFit ) ;
318  fprintf ( dataFile, "parameterLocation %10d \n", parameterLocation ) ;
319  fprintf ( dataFile, "rowInnerMost %10d \n", rowInnerMost ) ;
320  fprintf ( dataFile, "rowOuterMost %10d \n", rowOuterMost ) ;
321  fprintf ( dataFile, "rowStart %10d \n", rowStart ) ;
322  fprintf ( dataFile, "rowEnd %10d \n", rowEnd ) ;
323  fprintf ( dataFile, "szFitFlag %10d \n", szFitFlag ) ;
324  fprintf ( dataFile, "maxChi2Primary %10.2e\n", maxChi2Primary ) ;
325  fprintf ( dataFile, "bField %10.2e\n", bField ) ;
326  fprintf ( dataFile, "hitChi2Cut %10.2e\n", hitChi2Cut ) ;
327  fprintf ( dataFile, "goodHitChi2 %10.2e\n", goodHitChi2 ) ;
328  fprintf ( dataFile, "trackChi2Cut %10.2e\n", trackChi2Cut ) ;
329  fprintf ( dataFile, "goodDistance %10.2e\n", goodDistance ) ;
330  fprintf ( dataFile, "ptMinHelixFit %10.2e\n", ptMinHelixFit ) ;
331  fprintf ( dataFile, "maxDistanceSegment %10.2e\n", maxDistanceSegment ) ;
332  fprintf ( dataFile, "xyErrorScale %10.2e\n", xyErrorScale ) ;
333  fprintf ( dataFile, "szErrorScale %10.2e\n", szErrorScale ) ;
334  fprintf ( dataFile, "xVertex %10.2e\n", xVertex ) ;
335  fprintf ( dataFile, "yVertex %10.2e\n", yVertex ) ;
336  fprintf ( dataFile, "dxVertex %10.2e\n", dxVertex ) ;
337  fprintf ( dataFile, "dyVertex %10.2e\n", dyVertex ) ;
338  fprintf ( dataFile, "zVertex %10.2e\n", zVertex ) ;
339  fprintf ( dataFile, "xyWeightVertex %10.2e\n", xyWeightVertex ) ;
340  fprintf ( dataFile, "phiVertex %10.2e\n", phiVertex ) ;
341  fprintf ( dataFile, "rVertex %10.2e\n", rVertex ) ;
342  fprintf ( dataFile, "maxTime %10.2e\n", maxTime ) ;
343 }
344 
345 void FtfPara::setDefaults (void)
346 {
347 /* Define cuts - this should be obsolete */
348 
349  modRow = 1 ;
350  infoLevel = 0 ;
351  hitChi2Cut = 500.F ;
352  goodHitChi2 = 100.F ;
353  trackChi2Cut = 250.F ;
354  maxChi2Primary = 0. ;
355  segmentRowSearchRange = 1 ;
356  trackRowSearchRange = 3 ;
357  dEdx = 0 ;
358  dEdxNTruncate = 20 ;
359  minHitsForDedx = 15 ;
360  dphi = 0.10F * modRow ;
361  deta = 0.10F * modRow ;
362  dphiMerge = 0.02F ;
363  detaMerge = 0.02F ;
364  distanceMerge = 2. ;
365  etaMin = -2.5F ;
366  etaMinTrack = -2.2F ;
367  etaMax = 2.5F ;
368  etaMaxTrack = 2.2F ;
369  eventReset = 1 ;
370  getErrors = 0 ;
371  fillTracks = 1 ;
372  ghostFlag = 0 ;
373  goBackwards = 0 ;
374  goodDistance = 1.F * modRow ;
375  init = 0 ;
376  mergePrimaries = 1 ;
377  parameterLocation = 1 ;
378  phiMin = (float)(-0.000001/toDeg) ;
379  phiMinTrack = (float)(-0.000001/toDeg) ;
380  phiMax = (float)(360.2/toDeg) ;
381  phiMaxTrack = (float)(360.2/toDeg) ;
382  maxDistanceSegment = 100.F * modRow ;
383  minHitsPerTrack = 5 ;
384  nHitsForSegment = 2 ;
385  nEta = 60 ;
386  nEtaTrack = 60 ;
387  nPhi = 20 ;
388  nPhiTrack = 60 ;
389  nPrimaryPasses = 1 ;
390  nSecondaryPasses = 0 ;
391  vertexConstrainedFit = 0 ;
392  rowInnerMost = 1 ;
393  rowOuterMost = 45 ;
394  rowStart = 45 ;
395  rowEnd = 1 ;
396  segmentMaxAngle = 10.F/toDeg ;
397  szFitFlag = 1 ;
398  xyErrorScale = 1.0F ;
399  szErrorScale = 1.0F ;
400  bField = 0.0F ;
401  phiShift = 0.0 ;
402  zMax = 210. ;
403 
404  ptMinHelixFit = 0.F ;
405  rVertex = 0.F ;
406  xVertex = 0.F ;
407  yVertex = 0.F ;
408  zVertex = 0.F ;
409  dxVertex = 0.005F ;
410  dyVertex = 0.005F ;
411  phiVertex = 0.F ;
412  maxTime = 1.e18 ; // by default tracker can run as long as the age of the Universe
413 
414  return ;
415 }