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