00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "FtfFinder.h"
00019
00020
00021 void FtfPara::read ( char* inputFile ) {
00022
00023 FILE* dataFile = fopen( inputFile, "r");
00024 if (dataFile == NULL) {
00025 printf ( "FtfPara::write: Error opening input file %s \n", inputFile ) ;
00026 return ;
00027 }
00028
00029 char* name = new char[100] ;
00030 while ( 1 ) {
00031 if ( fscanf ( dataFile, "%s", name ) == EOF ) break ;
00032 if ( !strncmp(name,"infoLevel" ,8) ) {
00033 fscanf ( dataFile, "%d", &infoLevel ) ;
00034 continue ;
00035 }
00036 if ( !strncmp(name,"segmentRowSearch",8) ) {
00037 fscanf ( dataFile, "%d", &segmentRowSearchRange ) ;
00038 continue ;
00039 }
00040 if ( !strncmp(name,"trackRowSearch", 8) ) {
00041 fscanf ( dataFile, "%d", &trackRowSearchRange ) ;
00042 continue ;
00043 }
00044 if ( !strncmp(name,"getErrors ", 8) ) {
00045 fscanf ( dataFile, "%d", &getErrors ) ;
00046 continue ;
00047 }
00048 if ( !strncmp(name,"fillTracks ", 8) ) {
00049 fscanf ( dataFile, "%d", &fillTracks ) ;
00050 continue ;
00051 }
00052 if ( !strncmp(name,"ghostFlag ", 8) ) {
00053 fscanf ( dataFile, "%d", &ghostFlag ) ;
00054 continue ;
00055 }
00056 if ( !strncmp(name,"goBackwards ", 8) ) {
00057 fscanf ( dataFile, "%d", &goBackwards ) ;
00058 continue ;
00059 }
00060 if ( !strncmp(name,"mergePrimaries", 8) ) {
00061 fscanf ( dataFile, "%d", &mergePrimaries ) ;
00062 continue ;
00063 }
00064 if ( !strncmp(name,"minHitsPerTrack", 8) ) {
00065 fscanf ( dataFile, "%d", &minHitsPerTrack ) ;
00066 continue ;
00067 }
00068 if ( !strncmp(name,"modRow", 6) ) {
00069 fscanf ( dataFile, "%d", &modRow ) ;
00070 continue ;
00071 }
00072 if ( !strncmp(name,"nHitsForSegment", 8) ) {
00073 fscanf ( dataFile, "%d", &nHitsForSegment ) ;
00074 continue ;
00075 }
00076 if ( !strncmp(name,"minHitsForFit", 8) ) {
00077 fscanf ( dataFile, "%d", &minHitsForFit ) ;
00078 continue ;
00079 }
00080 if ( !strncmp(name,"nEtaTrack", 8) ) {
00081 fscanf ( dataFile, "%i", &nEtaTrack ) ;
00082 continue;
00083 }
00084 if ( !strncmp(name,"nEta", 4) ) {
00085 fscanf ( dataFile, "%d", &nEta ) ;
00086 continue ;
00087 }
00088 if ( !strncmp(name,"nPhiTrack", 8) ) {
00089 fscanf ( dataFile, "%d", &nPhiTrack ) ;
00090 continue ;
00091 }
00092 if ( !strncmp(name,"nPhi", 4) ) {
00093 fscanf ( dataFile, "%d", &nPhi ) ;
00094 continue ;
00095 }
00096 if ( !strncmp(name,"detaMerge ", 8) ) {
00097 fscanf ( dataFile, "%e", &detaMerge ) ;
00098 continue ;
00099 }
00100 if ( !strncmp(name,"deta ", 4) ) {
00101 fscanf ( dataFile, "%e", &deta ) ;
00102 continue ;
00103 }
00104 if ( !strncmp(name,"dphiMerge ", 8) ) {
00105 fscanf ( dataFile, "%e", &dphiMerge ) ;
00106 continue ;
00107 }
00108 if ( !strncmp(name,"dphi ", 4) ) {
00109 fscanf ( dataFile, "%e", &dphi ) ;
00110 continue ;
00111 }
00112 if ( !strncmp(name,"etaMinTrack ", 8) ) {
00113 fscanf ( dataFile, "%e", &etaMinTrack ) ;
00114 continue ;
00115 }
00116 if ( !strncmp(name,"etaMin", 6) ) {
00117 fscanf ( dataFile, "%e", &etaMin ) ;
00118 continue ;
00119 }
00120 if ( !strncmp(name,"etaMaxTrack ", 8) ) {
00121 fscanf ( dataFile, "%e", &etaMaxTrack ) ;
00122 continue ;
00123 }
00124 if ( !strncmp(name,"etaMax ", 6) ) {
00125 fscanf ( dataFile, "%e", &etaMax ) ;
00126 continue ;
00127 }
00128 if ( !strncmp(name,"phiMinTrack ", 8) ) {
00129 fscanf ( dataFile, "%e", &phiMinTrack ) ;
00130 continue ;
00131 }
00132 if ( !strncmp(name,"phiMin ", 6) ) {
00133 fscanf ( dataFile, "%e", &phiMin ) ;
00134 continue ;
00135 }
00136 if ( !strncmp(name,"phiMaxTrack ", 8) ) {
00137 fscanf ( dataFile, "%e", &phiMaxTrack ) ;
00138 continue ;
00139 }
00140 if ( !strncmp(name,"phiMax ", 6) ) {
00141 fscanf ( dataFile, "%e", &phiMax ) ;
00142 continue ;
00143 }
00144 if ( !strncmp(name,"phiShift ", 8) ) {
00145 fscanf ( dataFile, "%e", &phiShift ) ;
00146 continue ;
00147 }
00148 if ( !strncmp(name,"distanceMerge", 8) ) {
00149 fscanf ( dataFile, "%e", &distanceMerge ) ;
00150 continue ;
00151 }
00152 if ( !strncmp(name,"nPrimaryPasses", 8) ) {
00153 fscanf ( dataFile, "%d", &nPrimaryPasses ) ;
00154 continue ;
00155 }
00156 if ( !strncmp(name,"nSecondary", 8) ) {
00157 fscanf ( dataFile, "%d", &nSecondaryPasses ) ;
00158 continue ;
00159 }
00160 if ( !strncmp(name,"vertexConstrainedFit", 8) ) {
00161 fscanf ( dataFile, "%d", &vertexConstrainedFit ) ;
00162 continue ;
00163 }
00164 if ( !strncmp(name,"parameterLocation", 8) ) {
00165 fscanf ( dataFile, "%d", ¶meterLocation ) ;
00166 continue ;
00167 }
00168 if ( !strncmp(name,"rowInnerMost", 8) ) {
00169 fscanf ( dataFile, "%d", &rowInnerMost ) ;
00170 continue ;
00171 }
00172 if ( !strncmp(name,"rowOuterMost", 8) ) {
00173 fscanf ( dataFile, "%d", &rowOuterMost ) ;
00174 continue ;
00175 }
00176 if ( !strncmp(name,"rowStart", 8) ) {
00177 fscanf ( dataFile, "%d", &rowStart ) ;
00178 continue ;
00179 }
00180 if ( !strncmp(name,"rowEnd", 6) ) {
00181 fscanf ( dataFile, "%d", &rowEnd ) ;
00182 continue ;
00183 }
00184 if ( !strncmp(name,"szFitFlag", 8) ) {
00185 fscanf ( dataFile, "%d", &szFitFlag ) ;
00186 continue ;
00187 }
00188 if ( !strncmp(name,"bField", 6) ) {
00189 fscanf ( dataFile, "%e", &bField ) ;
00190 continue ;
00191 }
00192 if ( !strncmp(name,"maxChi2Primary", 12) ) {
00193 fscanf ( dataFile, "%e", &maxChi2Primary ) ;
00194 continue ;
00195 }
00196 if ( !strncmp(name,"hitChi2Cut", 8) ) {
00197 fscanf ( dataFile, "%e", &hitChi2Cut ) ;
00198 continue ;
00199 }
00200 if ( !strncmp(name,"goodHitChi2", 8) ) {
00201 fscanf ( dataFile, "%e", &goodHitChi2 ) ;
00202 continue ;
00203 }
00204 if ( !strncmp(name,"trackChi2Cut", 8) ) {
00205 fscanf ( dataFile, "%e", &trackChi2Cut ) ;
00206 continue ;
00207 }
00208 if ( !strncmp(name,"goodDistance", 8) ) {
00209 fscanf ( dataFile, "%e", &goodDistance ) ;
00210 continue ;
00211 }
00212 if ( !strncmp(name,"ptMinHelixFit", 8) ) {
00213 fscanf ( dataFile, "%e", &ptMinHelixFit ) ;
00214 continue ;
00215 }
00216 if ( !strncmp(name,"maxDistanceSegment", 15) ) {
00217 fscanf ( dataFile, "%e", &maxDistanceSegment ) ;
00218 continue ;
00219 }
00220 if ( !strncmp(name,"xyErrorScale", 10) ) {
00221 fscanf ( dataFile, "%e", &xyErrorScale ) ;
00222 continue ;
00223 }
00224 if ( !strncmp(name,"szErrorScale", 10) ) {
00225 fscanf ( dataFile, "%e", &szErrorScale ) ;
00226 continue ;
00227 }
00228 if ( !strncmp(name,"xVertex", 7) ) {
00229 fscanf ( dataFile, "%e", &xVertex ) ;
00230 continue ;
00231 }
00232 if ( !strncmp(name,"yVertex", 7) ) {
00233 fscanf ( dataFile, "%e", &yVertex ) ;
00234 continue ;
00235 }
00236 if ( !strncmp(name,"zVertex", 7) ) {
00237 fscanf ( dataFile, "%e", &zVertex ) ;
00238 continue ;
00239 }
00240 if ( !strncmp(name,"dxVertex", 8) ) {
00241 fscanf ( dataFile, "%e", &dxVertex ) ;
00242 continue ;
00243 }
00244 if ( !strncmp(name,"dyVertex", 8) ) {
00245 fscanf ( dataFile, "%e", &dyVertex ) ;
00246 continue ;
00247 }
00248 if ( !strncmp(name,"xyWeightVertex", 8) ) {
00249 fscanf ( dataFile, "%e", &xyWeightVertex ) ;
00250 continue ;
00251 }
00252 if ( !strncmp(name,"phiVertex", 8) ) {
00253 fscanf ( dataFile, "%e", &phiVertex ) ;
00254 continue ;
00255 }
00256 if ( !strncmp(name,"rVertex", 7) ) {
00257 fscanf ( dataFile, "%e", &rVertex ) ;
00258 continue ;
00259 }
00260 if ( !strncmp(name,"maxTime", 7) ) {
00261 fscanf ( dataFile, "%e", &maxTime ) ;
00262 continue ;
00263 }
00264 printf ( "FtfPara::read: parameter %s not found \n", name ) ;
00265 float variable ;
00266 fscanf ( dataFile, "%e", &variable ) ;
00267
00268 }
00269
00270 fclose ( dataFile ) ;
00271
00272 }
00273
00274 void FtfPara::write ( char* outputFile ) {
00275 FILE* dataFile = fopen( outputFile, "w");
00276 if (dataFile == NULL) {
00277 printf ( "FtfPara::write: Error opening output file %s \n ", outputFile ) ;
00278 return ;
00279 }
00280 write ( dataFile ) ;
00281 fclose ( dataFile ) ;
00282 }
00283
00284 void FtfPara::write ( FILE* dataFile ) {
00285
00286 fprintf ( dataFile, "infoLevel %10d \n", infoLevel ) ;
00287 fprintf ( dataFile, "segmentRowSearch %10d \n", segmentRowSearchRange ) ;
00288 fprintf ( dataFile, "trackRowSearch %10d \n", trackRowSearchRange ) ;
00289 fprintf ( dataFile, "getErrors %10d \n", getErrors ) ;
00290 fprintf ( dataFile, "fillTracks %10d \n", fillTracks ) ;
00291 fprintf ( dataFile, "ghostFlag %10d \n", ghostFlag ) ;
00292 fprintf ( dataFile, "goBackwards %10d \n", goBackwards ) ;
00293 fprintf ( dataFile, "mergePrimaries %10d \n", mergePrimaries ) ;
00294 fprintf ( dataFile, "minHitsPerTrack %10d \n", minHitsPerTrack ) ;
00295 fprintf ( dataFile, "modRow %10d \n", modRow ) ;
00296 fprintf ( dataFile, "nHitsForSegment %10d \n", nHitsForSegment ) ;
00297
00298 fprintf ( dataFile, "nEta %10d \n", nEta ) ;
00299 fprintf ( dataFile, "nPhi %10d \n", nPhi ) ;
00300 fprintf ( dataFile, "deta %10.2e\n", deta ) ;
00301 fprintf ( dataFile, "dphi %10.2e\n", dphi ) ;
00302 fprintf ( dataFile, "etaMin %10.2e\n", etaMin ) ;
00303 fprintf ( dataFile, "etaMax %10.2e\n", etaMax ) ;
00304 fprintf ( dataFile, "phiMin %10.2e\n", phiMin ) ;
00305 fprintf ( dataFile, "phiMax %10.2e\n", phiMax ) ;
00306 fprintf ( dataFile, "phiShift %10.2e\n", phiShift ) ;
00307 fprintf ( dataFile, "detaMerge %10.2e\n", detaMerge ) ;
00308 fprintf ( dataFile, "distanceMerge %10.2e\n", distanceMerge ) ;
00309 fprintf ( dataFile, "nEtaTrack %10d \n", nEtaTrack ) ;
00310 fprintf ( dataFile, "nPhiTrack %10d \n", nPhiTrack ) ;
00311 fprintf ( dataFile, "etaMinTrack %10.2e\n", etaMinTrack ) ;
00312 fprintf ( dataFile, "etaMaxTrack %10.2e\n", etaMaxTrack ) ;
00313 fprintf ( dataFile, "phiMinTrack %10.2e\n", phiMinTrack ) ;
00314 fprintf ( dataFile, "phiMaxTrack %10.2e\n", phiMaxTrack ) ;
00315 fprintf ( dataFile, "nPrimaryPasses %10d \n", nPrimaryPasses ) ;
00316 fprintf ( dataFile, "nSecondaryPasses %10d \n", nSecondaryPasses ) ;
00317 fprintf ( dataFile, "vertexConstrainedFit %10d \n", vertexConstrainedFit ) ;
00318 fprintf ( dataFile, "parameterLocation %10d \n", parameterLocation ) ;
00319 fprintf ( dataFile, "rowInnerMost %10d \n", rowInnerMost ) ;
00320 fprintf ( dataFile, "rowOuterMost %10d \n", rowOuterMost ) ;
00321 fprintf ( dataFile, "rowStart %10d \n", rowStart ) ;
00322 fprintf ( dataFile, "rowEnd %10d \n", rowEnd ) ;
00323 fprintf ( dataFile, "szFitFlag %10d \n", szFitFlag ) ;
00324 fprintf ( dataFile, "maxChi2Primary %10.2e\n", maxChi2Primary ) ;
00325 fprintf ( dataFile, "bField %10.2e\n", bField ) ;
00326 fprintf ( dataFile, "hitChi2Cut %10.2e\n", hitChi2Cut ) ;
00327 fprintf ( dataFile, "goodHitChi2 %10.2e\n", goodHitChi2 ) ;
00328 fprintf ( dataFile, "trackChi2Cut %10.2e\n", trackChi2Cut ) ;
00329 fprintf ( dataFile, "goodDistance %10.2e\n", goodDistance ) ;
00330 fprintf ( dataFile, "ptMinHelixFit %10.2e\n", ptMinHelixFit ) ;
00331 fprintf ( dataFile, "maxDistanceSegment %10.2e\n", maxDistanceSegment ) ;
00332 fprintf ( dataFile, "xyErrorScale %10.2e\n", xyErrorScale ) ;
00333 fprintf ( dataFile, "szErrorScale %10.2e\n", szErrorScale ) ;
00334 fprintf ( dataFile, "xVertex %10.2e\n", xVertex ) ;
00335 fprintf ( dataFile, "yVertex %10.2e\n", yVertex ) ;
00336 fprintf ( dataFile, "dxVertex %10.2e\n", dxVertex ) ;
00337 fprintf ( dataFile, "dyVertex %10.2e\n", dyVertex ) ;
00338 fprintf ( dataFile, "zVertex %10.2e\n", zVertex ) ;
00339 fprintf ( dataFile, "xyWeightVertex %10.2e\n", xyWeightVertex ) ;
00340 fprintf ( dataFile, "phiVertex %10.2e\n", phiVertex ) ;
00341 fprintf ( dataFile, "rVertex %10.2e\n", rVertex ) ;
00342 fprintf ( dataFile, "maxTime %10.2e\n", maxTime ) ;
00343 }
00344
00345 void FtfPara::setDefaults (void)
00346 {
00347
00348
00349 modRow = 1 ;
00350 infoLevel = 0 ;
00351 hitChi2Cut = 500.F ;
00352 goodHitChi2 = 100.F ;
00353 trackChi2Cut = 250.F ;
00354 maxChi2Primary = 0. ;
00355 segmentRowSearchRange = 1 ;
00356 trackRowSearchRange = 3 ;
00357 dEdx = 0 ;
00358 dEdxNTruncate = 20 ;
00359 minHitsForDedx = 15 ;
00360 dphi = 0.10F * modRow ;
00361 deta = 0.10F * modRow ;
00362 dphiMerge = 0.02F ;
00363 detaMerge = 0.02F ;
00364 distanceMerge = 2. ;
00365 etaMin = -2.5F ;
00366 etaMinTrack = -2.2F ;
00367 etaMax = 2.5F ;
00368 etaMaxTrack = 2.2F ;
00369 eventReset = 1 ;
00370 getErrors = 0 ;
00371 fillTracks = 1 ;
00372 ghostFlag = 0 ;
00373 goBackwards = 0 ;
00374 goodDistance = 1.F * modRow ;
00375 init = 0 ;
00376 mergePrimaries = 1 ;
00377 parameterLocation = 1 ;
00378 phiMin = (float)(-0.000001/toDeg) ;
00379 phiMinTrack = (float)(-0.000001/toDeg) ;
00380 phiMax = (float)(360.2/toDeg) ;
00381 phiMaxTrack = (float)(360.2/toDeg) ;
00382 maxDistanceSegment = 100.F * modRow ;
00383 minHitsPerTrack = 5 ;
00384 nHitsForSegment = 2 ;
00385 nEta = 60 ;
00386 nEtaTrack = 60 ;
00387 nPhi = 20 ;
00388 nPhiTrack = 60 ;
00389 nPrimaryPasses = 1 ;
00390 nSecondaryPasses = 0 ;
00391 vertexConstrainedFit = 0 ;
00392 rowInnerMost = 1 ;
00393 rowOuterMost = 45 ;
00394 rowStart = 45 ;
00395 rowEnd = 1 ;
00396 segmentMaxAngle = 10.F/toDeg ;
00397 szFitFlag = 1 ;
00398 xyErrorScale = 1.0F ;
00399 szErrorScale = 1.0F ;
00400 bField = 0.0F ;
00401 phiShift = 0.0 ;
00402 zMax = 210. ;
00403
00404 ptMinHelixFit = 0.F ;
00405 rVertex = 0.F ;
00406 xVertex = 0.F ;
00407 yVertex = 0.F ;
00408 zVertex = 0.F ;
00409 dxVertex = 0.005F ;
00410 dyVertex = 0.005F ;
00411 phiVertex = 0.F ;
00412 maxTime = 1.e18 ;
00413
00414 return ;
00415 }