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