#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ctk.h" /*---------*/ /* globals */ /*---------*/ long __sysconf (int); volatile extern TRACKINGPAR Pars; #ifdef SOLARIS #include #include #define CLK_TCK ((clock_t)_sysconf(3)) #endif #ifdef LINUX #include #define CLK_TCK ((__clock_t) __sysconf (2)) #endif int ctkStats (struct tms *timesThen, STAT * ctkStat) { /* declarations */ FILE *fp; int i, j, k, i1; float r1, r2; double d1, d2, d3, d4, totalTime, FM; struct rusage r_usage; struct tms timesNow; long long int il1; /* figure out what cputime we used (first) */ times ((struct tms *) ×Now); printf ("\n"); printf ("-------------------\n"); printf ("done processing data\n"); printf ("-------------------\n"); printf ("\n"); /* close output file */ close (Pars.trackDataStream); printf ("\n"); printf ("trackDataStream output file closed\n"); printf ("\n"); printf ("permutation selection statistics\n"); printf ("--> \"permutation_selection.log\"\n"); fp = fopen ("permutation_selection.log", "w"); for (i = 1; i < MAXNOSEG; i++) { fprintf (fp, "-------ndet=%i--------, jump strategy: ", i); /* print jump nomenclature */ for (j = 0; j < i; j++) if (j < Pars.jmpGrpLen[i]) fprintf (fp, "g"); else fprintf (fp, "t"); for (j = i; j < MAXNOSEG; j++) fprintf (fp, " "); fprintf (fp, "\n"); #if(0) r1 = 0; for (j = 0; j < Pars.nperm[i]; j++) r1 += ctkStat->permHit[i][j]; r1 /= 100; if (r1 > 0) for (j = 0; j < Pars.nperm[i]; j++) if (ctkStat->permHit[i][j] > 0) { fprintf (fp, "perm# %3i: { ", j); for (k = 0; k < i; k++) fprintf (fp, "%i ", Pars.permlkup[i][j][k]); fprintf (fp, "} "); fprintf (fp, " selected "); fprintf (fp, "%5.1f%% (%10i)\n", (float) ctkStat->permHit[i][j] / r1, ctkStat->permHit[i][j]); }; #endif }; /* track selected, statistics */ d1 = 100.0; printf ("ctkStat->trackGetCalls = %12li (%6.2f%%)\n", ctkStat->trackGetCalls, (float) d1); d1 = 100.0 * (double) ctkStat->trackPassCount / (double) ctkStat->trackGetCalls; printf ("ctkStat->trackPassCount = %12li (%6.2f%%) [basic conditions]\n", ctkStat->trackPassCount, (float) d1); d1 = 100.0 * (double) ctkStat->trackFMok / (double) ctkStat->trackGetCalls; printf ("ctkStat->trackFMok = %12li (%6.2f%%) \n", ctkStat->trackFMok, (float) d1); printf ("average permutations/track: %9.3f\n", d1); /* tracking stategies */ printf ("\n"); printf ("tracking stategies:\n"); printf ("\n"); d1 = (double) ctkStat->nperm / (double) ctkStat->trackFMok; for (i = 0; i < MAXNOSEG; i++) { printf ("tracking option for ndet=%i, %i == ", i, Pars.trackOps[i]); ctkTrackOpt (Pars.trackOps[i]); }; printf ("\n"); printf ("\n"); /* list tracking options */ printf ("\n"); printf ("tracking options available\n"); printf ("\n"); k = 0; for (i = 0; i < 20 && k == 0; i++) { printf ("%2i: ", i); k = ctkTrackOpt (i); }; getrusage (RUSAGE_SELF, &r_usage); printf ("\n"); printf ("maximum resident set size, ru_maxrss.............. %li\n", r_usage.ru_maxrss); printf ("integral resident set size, ru_idrss.............. %li\n", r_usage.ru_idrss); printf ("page faults not requiring physical I/O, ru_minflt. %li\n", r_usage.ru_minflt); printf ("page faults requiring physical I/O, ru_majflt .... %li\n", r_usage.ru_majflt); printf ("swaps ru_nswap.................................... %li\n", r_usage.ru_nswap); printf ("block input operations, ru_inblock................ %li\n", r_usage.ru_inblock); printf ("block output operations, ru_oublock............... %li\n", r_usage.ru_oublock); printf ("messages sent, ru_msgsnd.......................... %li\n", r_usage.ru_msgsnd); printf ("messages received, ru_msgrcv...................... %li\n", r_usage.ru_msgrcv); printf ("signals receivedru_nvcsw, ru_nsignals, ru_nsignals %li\n", r_usage.ru_nsignals); printf ("voluntary context switches, ru_nvcsw.............. %li\n", r_usage.ru_nvcsw); printf ("involuntary context switches, ru_nivcsw........... %li\n", r_usage.ru_nivcsw); /* write out various things */ printf ("\n"); printf ("\nCPU usage:\n\n"); r1 = timesNow.tms_utime - timesThen->tms_utime; totalTime = r1; printf ("user CPU time: %9.3f sec\n", r1 / CLK_TCK); r1 = timesNow.tms_stime - timesThen->tms_stime; totalTime += r1; printf ("system CPU time: %9.3f sec\n", r1 / CLK_TCK); totalTime /= CLK_TCK; printf ("Total CPU time: %9.3f sec\n", totalTime); /* statistics */ printf ("\n"); printf ("read %li tracks\n", ctkStat->trackGetCalls); printf ("\n"); printf ("sectors hit statistics\n"); printf ("\n"); i1 = 0; for (i = 0; i < 64; i++) i1 += ctkStat->nhit[i]; d1 = 0; for (i = 0; i < 64; i++) if (ctkStat->nhit[i] > 0) { r1 = 100.0 * (float) ctkStat->nhit[i] / (float) i1; printf ("%2i > %10i (%5.1f%%) ", i, ctkStat->nhit[i], r1); d1 += i * (float) ctkStat->nhit[i] / (float) i1; switch (i) { case 1: printf ("single absorption\n"); break; case 2: printf ("1 comption interaction\n"); break; default: printf ("%i comption interactions\n", i - 1); break; }; }; printf ("__ mean number of sectors that fired: %6.2f\n", d1); system ("ulimit -a"); /* reminder to myself:: */ /* pthread_attr_setstacksize */ /* setrlimit(RLIMIT_STACK,.... */ printf ("\n"); ctk_pr_trackPar (); printf ("\n"); printf ("size of struct TRACKINGPAR Pars, %f MB\n", (float) sizeof (struct TRACKINGPAR) / 1e6); printf ("MAXNOSEG= %i; ", MAXNOSEG); printf ("MAXPERM= %i\n", MAXPERM); printf ("\n"); /* ctkStat->nEvents :: triggers in GRETINA */ /* ctkStat->nClusters :: resolved gamma ray hits */ /* (with multiple hits per gamma ray) */ /* ctkStat->nHits :: total # interactions in GRETA */ /* The goal is 20,000 gamma rays/sec */ printf ("-------------------\n"); printf ("read %10i events (== triggered events in GRETA) [ctkStat->nEvents]\n", ctkStat->nEvents); printf ("saw %10i gamma-rays( aka, clusters) [ctkStat->nClusters]\n", ctkStat->nClusters); printf ("had %10i individual shell interactions [ctkStat->nHits]\n", ctkStat->nHits); printf ("mean number of interactions : %5.2f in shell\n", (float) ctkStat->nHits / (float) ctkStat->nEvents); printf ("mean event multiplicity : %5.2f \n", (float) ctkStat->nClusters / (float) ctkStat->nEvents); printf ("mean interactions per gamma-ray: %5.2f \n", (float) ctkStat->nHits / (float) ctkStat->nClusters); printf ("-------------------\n"); printf ("clustering angle [alpha] %5.2f degrees\n", Pars.alpha / RAD2DEG); printf ("-------------------\n"); r1 = ctkStat->nEvents / totalTime; printf ("processed %8.1f triggered events/sec\n", r1); r1 = ctkStat->nClusters / totalTime; printf ("processed %8.1f gamma rays/sec (aka clusters)(goal==20,000)\n", r1); r1 = 20000 / r1; printf ("I.e., we need %i threads, or %i (8 core) nodes, to keep up\n", (int) r1 + 1, (int) (r1 / 8) + 1); r1 = ctkStat->nHits / totalTime; printf ("processed %8.1f interactions/sec\n", r1); printf ("-------------------\n"); printf ("\n"); printf ("\n"); printf ("tracking return errors\n"); printf ("\n"); printf ("ctktk0_errors\n"); printf ("\n"); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->ctktk0_errors[i] > 0) printf ("%2i: %10i\n", i, ctkStat->ctktk0_errors[i]); printf ("\n"); printf ("ctktk1_errors\n"); printf ("\n"); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->ctktk1_errors[i] > 0) printf ("%2i: %10i\n", i, ctkStat->ctktk1_errors[i]); printf ("\n"); printf ("ctktk3_errors\n"); printf ("\n"); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->ctktk3_errors[i] > 0) printf ("%2i: %10i\n", i, ctkStat->ctktk3_errors[i]); printf ("\n"); printf ("ctktk4_errors\n"); printf ("\n"); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->ctktk4_errors[i] > 0) printf ("%2i: %10i\n", i, ctkStat->ctktk4_errors[i]); printf ("\n"); printf ("ctktk5_errors\n"); printf ("\n"); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->ctktk5_errors[i] > 0) printf ("%2i: %10i\n", i, ctkStat->ctktk5_errors[i]); printf ("\n"); printf ("*first trackings after initial clustering........:"); printf (" %10i %6.1f%%\n", ctkStat->firstClusterTrackCalls, 100.0 * ctkStat->firstClusterTrackCalls / ctkStat->TrackingCalls); if (Pars.recluster1) { printf ("\n"); printf ("*reCluster return codes for UNTRACKED (monster) clusters::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->reClusterReturns1[i]; printf ("total calls.....................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->reClusterReturns1[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("successful kickout reclustering.............: "); break; case 1: printf ("at least one non trivial is better..........: "); break; case 8: printf ("failed reclustering.........................: "); break; default: printf ("unknown error code..........................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->reClusterReturns1[i], 100 * ctkStat->reClusterReturns1[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->reClusterTrackCalls1[i], 100.0 * ctkStat->reClusterTrackCalls1[i] / ctkStat->TrackingCalls); }; } else printf ("\ndid not attempt to recluster for UNTRACKED (monster) clusters\n"); if (Pars.splitclusters1) { printf ("\n"); printf ("*splitClusters return codes for UNTRACKED (monster) clusters::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->splitClusterReturns1[i]; printf ("total calls......................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->splitClusterReturns1[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("successful cluster splits...................: "); break; case 1: printf ("success/best-we-have-return after max tries.: "); break; case 2: printf ("success, hard fom limit kickout. ..........: "); break; case 3: printf ("success, fraction fom limit kickout.........: "); break; case 5: printf ("cluster too big to handle...................: "); break; case 6: printf ("failed/nosplit after max tries..............: "); break; case 8: printf ("no best split was found.....................: "); break; default: printf ("unknown error code..........................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->splitClusterReturns1[i], 100 * ctkStat->splitClusterReturns1[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->splitClusterTrackCalls1[i], 100.0 * ctkStat->splitClusterTrackCalls1[i] / ctkStat->TrackingCalls); }; } else printf ("\ndid not attempt to split any clusters for UNTRACKED (monster) clusters\n"); if (Pars.recluster2) { printf ("\n"); printf ("*reCluster return codes for TRACKED clusters::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->reClusterReturns2[i]; printf ("total calls......................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->reClusterReturns2[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("successful kickout reclustering.............: "); break; case 1: printf ("at least one non trivial is better..........: "); break; case 8: printf ("failed reclustering.........................: "); break; default: printf ("unknown error code..........................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->reClusterReturns2[i], 100 * ctkStat->reClusterReturns2[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->reClusterTrackCalls2[i], 100.0 * ctkStat->reClusterTrackCalls2[i] / ctkStat->TrackingCalls); }; } else printf ("\ndid not attempt to split recluster for TRACKED clusters\n"); if (Pars.splitclusters2) { printf ("\n"); printf ("*splitClusters return codes for TRACKED clusters::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->splitClusterReturns2[i]; printf ("total calls......................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->splitClusterReturns2[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("successful untracked cluster splits.........: "); break; case 1: printf ("success/best-we-have-return after max tries.: "); break; case 2: printf ("success, hard fom limit kickout. ..........: "); break; case 3: printf ("success, fraction fom limit kickout.........: "); break; case 5: printf ("cluster too big to handle...................: "); break; case 6: printf ("failed/nosplit after max tries..............: "); break; case 8: printf ("no best split was found.....................: "); break; default: printf ("unknown error code..........................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->splitClusterReturns2[i], 100 * ctkStat->splitClusterReturns2[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->splitClusterTrackCalls2[i], 100.0 * ctkStat->splitClusterTrackCalls2[i] / ctkStat->TrackingCalls); }; } else printf ("\ndid not attempt to split any clusters for TRACKED clusters\n"); if (Pars.combineclusters) { printf ("\n"); printf ("*CombineClusters return code breakdown::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->combineClusterReturns[i]; printf ("total calls......................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->combineClusterReturns[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("success combinations........................: "); break; case 1: printf ("unsuccessful/no improve.....................: "); break; case 2: printf ("no nearby candidates........................: "); break; default: printf ("unknown error code..........................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->combineClusterReturns[i], 100 * ctkStat->combineClusterReturns[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->combineClusterTrackCalls[i], 100.0 * ctkStat->combineClusterTrackCalls[i] / ctkStat->TrackingCalls); }; printf ("\n"); printf ("*matchMaker return code breakdown::\n"); r2 = 0; for (i = 0; i < NRETURNCODES; i++) r2 += ctkStat->matchMakerReturns[i]; printf ("total calls......................................: "); printf ("%10i %6.1f%%\n", (int) r2, 100 * r2 / r2); for (i = 0; i < NRETURNCODES; i++) if (ctkStat->matchMakerReturns[i] > 0) { printf ("[%2i] ", i); switch (i) { case 0: printf ("success combinations........................: "); break; case 1: printf ("not close enough............................: "); break; case 2: printf ("FOM over threshold..........................: "); break; default: printf ("unknown error code....................................: "); break; }; printf ("%10i %6.1f%%; ", ctkStat->matchMakerReturns[i], 100 * ctkStat->matchMakerReturns[i] / r2); printf ("trackings: %10i %6.1f%%\n", ctkStat->matchMakerTrackCalls[i], 100.0 * ctkStat->matchMakerTrackCalls[i] / ctkStat->TrackingCalls); }; } else printf ("\ndid not attempt to combine any clusters\n"); printf ("-------------------\n"); #if(0) d1 = ctkStat->simpleTrackCalls + ctkStat->splitTrackCalls + ctkStat->combineTrackCalls + ctkStat->matchMakerTrackCalls; r1 = 100 * (double) ctkStat->simpleTrackCalls / d1; printf ("simpleTrackCalls....: %12i %6.1f%%\n", ctkStat->simpleTrackCalls, r1); r1 = 100 * (double) ctkStat->splitTrackCalls / d1; printf ("splitTrackCalls.....: %12i %6.1f%%\n", ctkStat->splitTrackCalls, r1); r1 = 100 * (double) ctkStat->combineTrackCalls / d1; printf ("combineTrackCalls...: %12i %6.1f%%\n", ctkStat->combineTrackCalls, r1); r1 = 100 * (double) ctkStat->matchMakerTrackCalls / d1; printf ("matchMakerTrackCalls: %12i %6.1f%%\n", ctkStat->matchMakerTrackCalls, r1); #endif /* success rate */ printf ("\n"); d2 = (double) ctkStat->nClusters / (double) ctkStat->nEvents; printf ("mean multiplicity of tracked data....: %6.2f\n", (float) d2); #if(SIMULATED) d1 = (double) ctkStat->noTrueClusters / (double) ctkStat->nEvents; printf ("mean multiplicity of input data..: %6.2f (for simulated data)\n", (float) d1); FM = (d1 - d2) / d1; if (FM < 0) FM *= -1; FM += 1; printf ("deduced FM on multiplicity.......: %6.2f\n", (float) FM); d3 = ctkStat->goodtrak + ctkStat->badtrack; d3 = 100. * (double) ctkStat->goodtrak / d3; printf ("** good tracks vs total..........: %5.1f%%\n", d3); d4 = 100. * (double) ctkStat->goodtrak / (double) ctkStat->noTrueClusters; printf ("** first interaction points......: %5.1f%% (FOM for simulated data)\n", d4); printf ("\n"); d1 = ctkStat->goodtrak + ctkStat->badtrack; FM = 100.0 * ctkStat->goodtrak / d1; printf ("*** overall FM %6.1f ***\n", FM); printf ("\n"); printf ("full energy vs compton loss for input data: "); il1 = ctkStat->fullEnergyEv + ctkStat->comptonLossEnergyEv; r1 = (float) ctkStat->fullEnergyEv / (float) il1; printf ("%5.1f%%\n", r1 * 100); #endif d1 = 100.0 * (double) ctkStat->notTracked / (double) ctkStat->trackGetCalls; printf ("number of Clusters we could not track: %10li, %6.1f%%\n", ctkStat->notTracked, d1); d1 = 100.0 * ((double) ctkStat->nEvents - (double) ctkStat->notTracked) / (double) ctkStat->nEvents; printf ("number of Clusters we did track......: %10li, %6.1f%%\n", ctkStat->nEvents - ctkStat->notTracked, d1); d1 = 100.0 * ((double) ctkStat->badpad) / (double) ctkStat->nEvents; printf ("badpad...............................: %10li, %6.1f%%\n", ctkStat->badpad, d1); printf ("SegHits..............................: %10li\n", ctkStat->SegHits); d1 = 100.0 * ((double) ctkStat->doubleSegHits) / (double) ctkStat->SegHits; printf ("doubleSegHits........................: %10li, %6.1f%%\n", ctkStat->doubleSegHits, d1); #if(0) printf ("ctkStat->nEvents= %10li\n", ctkStat->nEvents); printf ("ctkStat->nClusters=%10i\n", ctkStat->nClusters); printf ("tkStat.notTracked=%10li\n", ctkStat->notTracked); printf ("tkStat.goodtrak= %10li\n", ctkStat->goodtrak); printf ("tkStat.badtrack= %10li\n", ctkStat->badtrack); #endif printf ("ctkStat->singlehitoutofrange= %lli\n", ctkStat->singlehitoutofrange); printf ("ctkStat->badndetElim........= %lli\n", ctkStat->badndetElim); /* mean figure of merit */ d1 = ctkStat->sfom / ctkStat->nClusters; printf ("mean figure of merit per event.......: %9.3f\n", (float) (d1)); d1 = ctkStat->sfom_nt / ctkStat->nsfom_nt; printf ("mean FOM/event non-trivial (ndet>1)..: %9.3f\n", (float) (d1)); /* done */ printf ("Total CPU time: %9.3f sec\n", totalTime); printf ("ctkStats... done\n"); /* done */ return (0); }