src/.kate.mpsAnalysis.cc

Go to the documentation of this file.
00001 #include <signal.h>
00002 
00003 #include <iostream>
00004 #include <sstream>
00005 #include <vector>
00006 
00007 #include "UtlArguments.hh"
00008 #include "RcdArena.hh"
00009 #include "RcdCount.hh"
00010 #include "RunReader.hh"
00011 #include "SubAccessor.hh"
00012 
00013 #include "MpsAnalysis.hh"
00014 
00015 using namespace std;
00016 
00017 bool continueJob=true;
00018 
00019 void signalHandler(int signal) {
00020         std::cerr << "Process "<< getpid() << " received signal "<< signal
00021                         << std::endl;
00022         continueJob=false;
00023 }
00024 
00025 int main(int argc, const char **argv) {
00026 
00027         UtlArguments argh(argc, argv);
00028 
00029         const unsigned numberOfBtrs(argh.optionArgument('b', 1000000000,
00030                         "Number of bunch trains"));
00031         const unsigned numberOfCfgs(argh.optionArgument('c', 1000000000,
00032                         "Number of configurations"));
00033         const unsigned numberOfRuns(argh.optionArgument('n', 1, "Number of runs"));
00034         const unsigned printLevel(argh.optionArgument('p', 9, "Print level"));
00035         const unsigned analysisBits(argh.optionArgument('a',
00036                         MpsAnalysis::defaultMpsAnalysisBits, "MpsAnalysis bits"));
00037 
00038         const unsigned lowThreshold(argh.optionArgument('l', 0, "Low threshold"));
00039         const unsigned highThreshold(argh.optionArgument('u', 500,
00040                         "Upper threshold"));
00041         const unsigned bins(argh.optionArgument('i', 0, "Bins"));
00042         // Get run number as last argument
00043         const unsigned runnum(argh.lastArgument(999999, "Run number"));
00044 
00045         if (argh.help())
00046                 return 0;
00047 
00048         // Allow interrupts
00049         signal(SIGINT, signalHandler);
00050         signal(SIGTERM, signalHandler);
00051 
00052         // Define memory space for records
00053         RcdArena arena;
00054 
00055         // Create simple record type counter and configuration counter
00056         RcdCount counter;
00057         unsigned nCfg(0);
00058         unsigned nBtr(0);
00059 
00060         // Create MAPS analysis module
00061         MpsAnalysis analysis(analysisBits, runnum, bins, lowThreshold,
00062                         highThreshold);
00063         analysis.printLevel(printLevel);
00064 
00065         // This can handle both single-file and multi-file runs
00066         RunReader reader;
00067 
00068         for (unsigned run(0); run<numberOfRuns; run++) {
00069 
00070                 // Open run file using reader
00071                 assert(reader.open(runnum+run));
00072 
00073                 // Loop over all records until end-of-file
00074                 while (reader.read(arena) && continueJob && nCfg<numberOfCfgs && nBtr
00075                                 <numberOfBtrs) {
00076 
00077                         // Increment counters
00078                         counter+=arena;
00079                         if (arena.recordType()==RcdHeader::bunchTrain)
00080                                 nBtr++;
00081                         if (arena.recordType()==RcdHeader::configurationEnd)
00082                                 nCfg++;
00083 
00084                         // Run analysis
00085                         analysis.record(arena);
00086                 }
00087 
00088                 // Close run file
00089                 assert(reader.close());
00090         }
00091         analysis.findHitDistribution();
00092         analysis.makeGlobalTimeStampPlot();
00093 
00094         // Print total of counts
00095         cout << endl;
00096         counter.print(cout);
00097 
00098         return 0;
00099 }
00100 

Generated on Wed Mar 19 17:46:07 2008 for MapsTracks by  doxygen 1.5.2