int EvalExpAndCounts(PilParams ¶ms, double tmin, double tmax, int &countscalc, double &expcalc) { int timestep = 1; Intervals intervals; if (!eval::LoadTimeList(params["timelist"], intervals, tmin, tmax)) { cerr << "Error loading timelist file '" << params["timelist"].GetStr() << "'" << endl; return EXIT_FAILURE; } cout << endl << "INPUT PARAMETERS:" << endl; params.Print(); double radius = params["radius"]; //mres double mdim = radius*sqrt(2); cout << "radius for evt: " << radius << " - mdim for exp: " << mdim << endl; double binstep = 1.0; const char *projection = "ARC"; cout << "Binstep: " << binstep << endl; cout << "Projection: " << projection << endl; cout << "INTERVALS N=" << intervals.Count() << ":" << endl; for (int i=0; i<intervals.Count(); i++) cout << " " << intervals[i].String() << endl; cout << "Selecting the events.." << endl; char selectionLogFilename[FLEN_FILENAME]; char templateLogFilename[FLEN_FILENAME]; tmpnam(selectionLogFilename); tmpnam(templateLogFilename); char *logfile = (char*) params["logfile"].GetStr(); if (logfile && logfile[0]=='@') logfile++; string logExpr = selection::LogExprString(intervals, params["phasecode"], timestep); cout << logExpr << endl; int status = selection::MakeSelection(logfile, intervals, logExpr, selectionLogFilename, templateLogFilename); if (status==-118) { cout << endl << "AG_lm5......................no matching events found" << endl; cout << endString << endl; return 0; } else if (status != 0) { cout << endl << "AG_lm5......................selection failed" << endl; cout << endString << endl; return 0; } cout << "Selecting the events.." << endl; char selectionEvtFilename[FLEN_FILENAME]; char templateEvtFilename[FLEN_FILENAME]; tmpnam(selectionEvtFilename); tmpnam(templateEvtFilename); char *evtfile = (char*) params["evtfile"].GetStr(); if (evtfile && evtfile[0]=='@') evtfile++; string evtExpr = selection::EvtExprString(intervals, params["emin"], params["emax"], params["albrad"], params["fovradmax"], params["fovradmin"], params["phasecode"], params["filtercode"]); status = selection::MakeSelection(evtfile, intervals, evtExpr, selectionEvtFilename, templateEvtFilename); if (status==-118) { cout << endl << "AG_lm5......................no matching events found" << endl; cout << endString << endl; return 0; } else if (status != 0) { cout << endl << "AG_lm5......................selection failed" << endl; cout << endString << endl; return 0; } double beginTime = tmin; double endTime = tmax; cout.setf(ios::fixed); cout << std::setprecision(2); cout << "***** " << beginTime << " " << endTime << " " << endl << endl; Interval timeSlot; timeSlot.Set(beginTime, endTime); #ifdef DEBUG cout << "Time slot beginTime: " << beginTime << " endTime: " << endTime << endl; #endif Intervals intervalSlots = Intersection(intervals, timeSlot); if (intervalSlots.Count()) { cout << "Selected slots:" << endl; for (int i=0; i<intervalSlots.Count(); i++) cout << " " << intervalSlots[i].Start() << " " << intervalSlots[i].Stop() << endl; vector< vector<double> > exposures; status = eval::EvalExposure("None", params["sarFileName"], params["edpFileName"], "None", projection, mdim, mdim, params["la"], params["ba"], params["lonpole"], params["albrad"], params["y_tol"], params["roll_tol"], params["earth_tol"], params["phasecode"], binstep, params["timestep"], params["index"], tmin, tmax, params["emin"], params["emax"], params["fovradmin"], params["fovradmax"], selectionLogFilename, templateLogFilename, intervalSlots, exposures, false); vector<int> counts; status = eval::EvalCountsInRadius("None", tmin, tmax, radius, params["la"], params["ba"], params["lonpole"], params["emin"], params["emax"], params["fovradmax"], params["fovradmin"], params["albrad"], params["phasecode"], params["filtercode"], selectionEvtFilename, templateEvtFilename, intervalSlots, counts); expcalc = 0; countscalc = 0; for (int slot=0; slot<intervalSlots.Count(); slot++) { expcalc += exposures[slot][0]; // the map is 1x1 countscalc += counts[slot]; } } else cout << "No intervals selected" << endl; FitsFile slogfile(selectionLogFilename); slogfile.Delete(); FitsFile tlogfile(templateLogFilename); tlogfile.Delete(); FitsFile sevtfile(selectionEvtFilename); sevtfile.Delete(); FitsFile tevtfile(templateEvtFilename); tevtfile.Delete(); if (status == -118) { cout << endl << "AG_lm5......................no matching events found" << endl; } else if (status != 0) { cout << endl << "AG_lm5...................... exiting with ERROR:"<< endl; fits_report_error(stdout, status); } cout << endString << endl; return status; }