| 1 | #include <TROOT.h>
|
|---|
| 2 | #include <TClass.h>
|
|---|
| 3 | #include <TSystem.h>
|
|---|
| 4 | #include <TGClient.h>
|
|---|
| 5 | #include <TApplication.h>
|
|---|
| 6 | #include <TObjectTable.h>
|
|---|
| 7 |
|
|---|
| 8 | #include "MLog.h"
|
|---|
| 9 | #include "MLogManip.h"
|
|---|
| 10 |
|
|---|
| 11 | #include "MEnv.h"
|
|---|
| 12 | #include "MArgs.h"
|
|---|
| 13 | #include "MArray.h"
|
|---|
| 14 | #include "MDirIter.h"
|
|---|
| 15 |
|
|---|
| 16 | #include "MStatusDisplay.h"
|
|---|
| 17 |
|
|---|
| 18 | #include "MSequence.h"
|
|---|
| 19 | #include "MJPedestal.h"
|
|---|
| 20 | #include "MJCalibration.h"
|
|---|
| 21 | #include "MJCalibrateSignal.h"
|
|---|
| 22 | #include "MJCalibTest.h"
|
|---|
| 23 |
|
|---|
| 24 | using namespace std;
|
|---|
| 25 |
|
|---|
| 26 | static void StartUpMessage()
|
|---|
| 27 | {
|
|---|
| 28 | gLog << all << endl;
|
|---|
| 29 |
|
|---|
| 30 | // 1 2 3 4 5
|
|---|
| 31 | // 12345678901234567890123456789012345678901234567890
|
|---|
| 32 | gLog << "========================================================" << endl;
|
|---|
| 33 | gLog << " Callisto - MARS V" << MARSVER << endl;
|
|---|
| 34 | gLog << " MARS -- CALibrate LIght Signals and Time Offsets" << endl;
|
|---|
| 35 | gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl;
|
|---|
| 36 | gLog << "========================================================" << endl;
|
|---|
| 37 | gLog << endl;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | static void Usage()
|
|---|
| 41 | {
|
|---|
| 42 | // 1 2 3 4 5 6 7 8
|
|---|
| 43 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
|---|
| 44 | gLog << all << endl;
|
|---|
| 45 | gLog << "Sorry the usage is:" << endl;
|
|---|
| 46 | gLog << " callisto [-c] [-y] [options] sequence.txt|number" << endl << endl;
|
|---|
| 47 | gLog << " Arguments:" << endl;
|
|---|
| 48 | gLog << " sequence.txt: ASCII file defining a sequence of runs" << endl;
|
|---|
| 49 | gLog << " number: The sequence number (using file in the datacenter)" << endl;
|
|---|
| 50 | gLog << " For more details see MSequence" << endl;
|
|---|
| 51 | gLog << " Root Options:" << endl;
|
|---|
| 52 | gLog << " -b Batch mode (no graphical output to screen)" << endl<<endl;
|
|---|
| 53 | gLog << " Operation Modes:" << endl;
|
|---|
| 54 | gLog << " -c Calculate the calibration constants" << endl;
|
|---|
| 55 | gLog << " -y Extract and calibrate signal" << endl << endl;
|
|---|
| 56 | gLog << " Data Type (exclusive):" << endl;
|
|---|
| 57 | gLog << " -mc Input root-files are monte carlo files" << endl;
|
|---|
| 58 | gLog << " Options:" << endl;
|
|---|
| 59 | gLog.Usage();
|
|---|
| 60 | gLog << " --debug-env=0 Disable debugging setting resources <default>" << endl;
|
|---|
| 61 | gLog << " --debug-env[=1] Display untouched resources after program execution" << endl;
|
|---|
| 62 | gLog << " --debug-env=2 Display untouched resources after eventloop setup" << endl;
|
|---|
| 63 | gLog << " --debug-env=3 Debug setting resources from resource file" << endl;
|
|---|
| 64 | gLog << " --debug-mem Debug memory usage" << endl << endl;
|
|---|
| 65 | gLog << endl;
|
|---|
| 66 | gLog << " -q Quit when job is finished" << endl;
|
|---|
| 67 | gLog << " -f Force overwrite of existing files" << endl;
|
|---|
| 68 | gLog << " --ind=path Path where to search for the data files" << endl;
|
|---|
| 69 | gLog << " [default=standard path in datacenter]" << endl;
|
|---|
| 70 | gLog << " --iny=path Path where to search for the calibration files" << endl;
|
|---|
| 71 | gLog << " [default=local path or output path of Mode-C]" << endl;
|
|---|
| 72 | gLog << " --outc=path Path to write Mode-C result to [def=local path]" << endl;
|
|---|
| 73 | gLog << " --outy=path Path to write Mode-Y result to [def=local path]" << endl;
|
|---|
| 74 | gLog << " --out=path Path to write the all results to [def=local path]" << endl;
|
|---|
| 75 | gLog << " (overwrites --outc and --outy)" << endl;
|
|---|
| 76 | gLog << " --path=path Path to write the all results to [def=local path]" << endl;
|
|---|
| 77 | gLog << " (overwrites --iny, --outc and --outy)" << endl;
|
|---|
| 78 | gLog << " --print-seq Print Sequence information" << endl;
|
|---|
| 79 | gLog << " --print-files Print Files taken from Sequence" << endl;
|
|---|
| 80 | gLog << " --print-found Print Files found from Sequence" << endl;
|
|---|
| 81 | gLog << " --use-test Apply calibration constants to same calibration" << endl;
|
|---|
| 82 | gLog << " file (for testing, calibration mode only)" << endl;
|
|---|
| 83 | gLog << " --movie Write a movie in addition to Mode-Y (this might " << endl;
|
|---|
| 84 | gLog << " stop the eventloop before all evts are processed)" << endl;
|
|---|
| 85 | gLog << " --moon Force using pedestal fits instead of calculated RMS" << endl;
|
|---|
| 86 | gLog << " --config=callisto.rc Resource file [default=callisto.rc]" << endl;
|
|---|
| 87 | gLog << endl;
|
|---|
| 88 | gLog << " --version, -V Show startup message with version number" << endl;
|
|---|
| 89 | gLog << " -?, -h, --help This help" << endl << endl;
|
|---|
| 90 | gLog << " Setup of the two jobs run by callisto (MJPedestal and MJCalibration)" << endl;
|
|---|
| 91 | gLog << " can be done with the resource file. See MJPedestal and MJCalibration" << endl;
|
|---|
| 92 | gLog << " especially CheckEnv() for more details. Command line options might" << endl;
|
|---|
| 93 | gLog << " be overwritten by the resource file." << endl << endl;
|
|---|
| 94 | gLog << " If running in Mode-C and Mode-Y --iny= is obsolete, instead --outc=" << endl;
|
|---|
| 95 | gLog << " is used." << endl << endl;
|
|---|
| 96 | gLog << " Using --iny=, --outc=, --outy=, --out= or --path= automatically" << endl;
|
|---|
| 97 | gLog << " enables the corresponding modes. In this case -c/-y are obsolete." << endl << endl;
|
|---|
| 98 | gLog << "Description:" << endl;
|
|---|
| 99 | gLog << " callisto will calculate pedestals from pedestal-files defined in a" << endl;
|
|---|
| 100 | gLog << " sequence-file. This pedestals are used to calculate the calibration" << endl;
|
|---|
| 101 | gLog << " constants. These constants are stored in a so called calibration-file" << endl;
|
|---|
| 102 | gLog << " together with some datacheck plots which can be viewed using either" << endl;
|
|---|
| 103 | gLog << " showplot or MStatusDisplay in the interpreter. A description of a" << endl;
|
|---|
| 104 | gLog << " sequence-file can be found in the class reference of MSequence." << endl << endl;
|
|---|
| 105 | gLog << "Background:" << endl;
|
|---|
| 106 | gLog << " Callisto is a large, icy, dark-colored, low-density outer moon of" << endl;
|
|---|
| 107 | gLog << " Jupiter that is scarred with impact craters and ejecta. It has a" << endl;
|
|---|
| 108 | gLog << " diameter of about 4800km, the second-largest moon of Jupiter; it is" << endl;
|
|---|
| 109 | gLog << " roughly the size of Mercury. Callisto has the largest-known impact" << endl;
|
|---|
| 110 | gLog << " crater in the Solar System, Valhalla, which has a bright patch 600km" << endl;
|
|---|
| 111 | gLog << " across and rings that go out to almost 3000km. Callisto orbits" << endl;
|
|---|
| 112 | gLog << " Jupiter at a mean distance of 1,883,000km. Its mass is 1.1e23 kg. It" << endl;
|
|---|
| 113 | gLog << " takes Callisto 16.7 days to orbit Jupiter in a synchronous orbit." << endl;
|
|---|
| 114 | gLog << " Jupiter's moon Callisto was discovered independently by Galileo and" << endl;
|
|---|
| 115 | gLog << " S.Marius in 1610." << endl << endl;
|
|---|
| 116 | gLog << "Example:" << endl;
|
|---|
| 117 | gLog << " callisto -f --outc=mycal/ --outy=mysignal/ --log sequence02345.txt" << endl;
|
|---|
| 118 | gLog << endl;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | static void PrintFiles(const MSequence &seq, const TString &kInpathD, Bool_t raw, Bool_t showall)
|
|---|
| 122 | {
|
|---|
| 123 | const char *prep = showall ? "Found" : "Scheduled";
|
|---|
| 124 |
|
|---|
| 125 | MDirIter Next1, Next2, Next3;
|
|---|
| 126 | seq.SetupPedRuns(Next1, kInpathD, raw);
|
|---|
| 127 | seq.SetupCalRuns(Next2, kInpathD, raw);
|
|---|
| 128 | seq.SetupDatRuns(Next3, kInpathD, raw);
|
|---|
| 129 |
|
|---|
| 130 | gLog << all;
|
|---|
| 131 | gLog.Separator(Form("%s Pedestal Files", prep));
|
|---|
| 132 | Next1.Print(showall?"all":"");
|
|---|
| 133 | gLog << endl;
|
|---|
| 134 | gLog.Separator(Form("%s Calibration Files", prep));
|
|---|
| 135 | Next2.Print(showall?"all":"");
|
|---|
| 136 | gLog << endl;
|
|---|
| 137 | gLog.Separator(Form("%s Data Files", prep));
|
|---|
| 138 | Next3.Print(showall?"all":"");
|
|---|
| 139 | gLog << endl;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | int main(int argc, char **argv)
|
|---|
| 143 | {
|
|---|
| 144 | if (!MARS::CheckRootVer())
|
|---|
| 145 | return 0xff;
|
|---|
| 146 |
|
|---|
| 147 | MLog::RedirectErrorHandler(MLog::kColor);
|
|---|
| 148 |
|
|---|
| 149 | //
|
|---|
| 150 | // Evaluate arguments
|
|---|
| 151 | //
|
|---|
| 152 | MArgs arg(argc, argv, kTRUE);
|
|---|
| 153 | gLog.Setup(arg);
|
|---|
| 154 |
|
|---|
| 155 | StartUpMessage();
|
|---|
| 156 |
|
|---|
| 157 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
|---|
| 158 | return 0;
|
|---|
| 159 |
|
|---|
| 160 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
|---|
| 161 | {
|
|---|
| 162 | Usage();
|
|---|
| 163 | return 2;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
|---|
| 167 |
|
|---|
| 168 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
|---|
| 169 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
|---|
| 170 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
|---|
| 171 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
|---|
| 172 | const Bool_t kMovie = arg.HasOnlyAndRemove("--movie");
|
|---|
| 173 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
|---|
| 174 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
|---|
| 175 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
|---|
| 176 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
|---|
| 177 |
|
|---|
| 178 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
|---|
| 179 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
|---|
| 180 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
|---|
| 181 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
|---|
| 182 |
|
|---|
| 183 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
|---|
| 184 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
|---|
| 185 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
|---|
| 186 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
|---|
| 187 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
|---|
| 188 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
|---|
| 189 |
|
|---|
| 190 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
|---|
| 191 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
|---|
| 192 | const Bool_t kIsMC = arg.HasOnlyAndRemove("-mc");
|
|---|
| 193 |
|
|---|
| 194 | if (!kInpathY.IsNull() || !kOutpathY.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
|---|
| 195 | kModeY = kTRUE;
|
|---|
| 196 | if (!kOutpathC.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
|---|
| 197 | kModeC = kTRUE;
|
|---|
| 198 |
|
|---|
| 199 | //
|
|---|
| 200 | // check for the right usage of the program
|
|---|
| 201 | //
|
|---|
| 202 | if (arg.GetNumArguments()!=1)
|
|---|
| 203 | {
|
|---|
| 204 | gLog << warn << "WARNING - Wrong number of arguments..." << endl;
|
|---|
| 205 | Usage();
|
|---|
| 206 | return 2;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | if (arg.GetNumOptions()>0)
|
|---|
| 210 | {
|
|---|
| 211 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
|---|
| 212 | arg.Print("options");
|
|---|
| 213 | gLog << endl;
|
|---|
| 214 | return 2;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
|---|
| 218 | {
|
|---|
| 219 | gLog << err << "Neither calibration (-c), signal extraction (-y) or test-mode (--use-test)" << endl;
|
|---|
| 220 | gLog << "specified! You can also give the operation mode by the options defining the" << endl;
|
|---|
| 221 | gLog << "output path --outc, --outy or --out." << endl;
|
|---|
| 222 | Usage();
|
|---|
| 223 | return 2;
|
|---|
| 224 | }
|
|---|
| 225 | if (!kModeY && kMovie)
|
|---|
| 226 | {
|
|---|
| 227 | gLog << err << "Signal extraction mode (-y) not switched on but movie requested." << endl;
|
|---|
| 228 | Usage();
|
|---|
| 229 | return 2;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
|---|
| 233 | kOutpathC = ".";
|
|---|
| 234 | if (kModeY)
|
|---|
| 235 | {
|
|---|
| 236 | if (kInpathY.IsNull())
|
|---|
| 237 | kInpathY = ".";
|
|---|
| 238 | if (kOutpathY.IsNull())
|
|---|
| 239 | kOutpathY = ".";
|
|---|
| 240 | }
|
|---|
| 241 | if (!kOutpath.IsNull())
|
|---|
| 242 | {
|
|---|
| 243 | kOutpathC = kOutpath;
|
|---|
| 244 | kOutpathY = kOutpath;
|
|---|
| 245 | }
|
|---|
| 246 | if (!kPath.IsNull())
|
|---|
| 247 | {
|
|---|
| 248 | kOutpathC = kOutpath;
|
|---|
| 249 | kOutpathY = kOutpath;
|
|---|
| 250 | kInpathY = kOutpath;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | if (kModeC && kModeY)
|
|---|
| 254 | kInpathY = kOutpathC;
|
|---|
| 255 |
|
|---|
| 256 | //
|
|---|
| 257 | // Setup sequence file and check for its existance
|
|---|
| 258 | //
|
|---|
| 259 | TString kSequence = arg.GetArgumentStr(0);
|
|---|
| 260 |
|
|---|
| 261 | if (!MSequence::InflatePath(kSequence, kIsMC))
|
|---|
| 262 | return 3;
|
|---|
| 263 |
|
|---|
| 264 | if (kDebugMem)
|
|---|
| 265 | TObject::SetObjectStat(kTRUE);
|
|---|
| 266 |
|
|---|
| 267 | //
|
|---|
| 268 | // Setup sequence and check its validity
|
|---|
| 269 | //
|
|---|
| 270 | MSequence seq(kSequence, kInpathD);
|
|---|
| 271 | if (!seq.IsMonteCarlo())
|
|---|
| 272 | seq.SetMonteCarlo(kIsMC);
|
|---|
| 273 | if (kPrintSeq)
|
|---|
| 274 | {
|
|---|
| 275 | gLog << all;
|
|---|
| 276 | gLog.Separator(kSequence);
|
|---|
| 277 | seq.Print();
|
|---|
| 278 | gLog << endl;
|
|---|
| 279 | }
|
|---|
| 280 | if (!seq.IsValid())
|
|---|
| 281 | {
|
|---|
| 282 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
|---|
| 283 | return 5;
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | //
|
|---|
| 287 | // Process print options
|
|---|
| 288 | //
|
|---|
| 289 | if (kPrintFiles)
|
|---|
| 290 | PrintFiles(seq, kInpathD, !seq.IsMonteCarlo(), kFALSE);
|
|---|
| 291 | if (kPrintFound)
|
|---|
| 292 | PrintFiles(seq, kInpathD, !seq.IsMonteCarlo(), kTRUE);
|
|---|
| 293 |
|
|---|
| 294 | if (seq.HasMoon())
|
|---|
| 295 | kMoon = kTRUE;
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 | /*
|
|---|
| 299 | //
|
|---|
| 300 | // Check for existance of all files
|
|---|
| 301 | //
|
|---|
| 302 | MDirIter iter;
|
|---|
| 303 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
|---|
| 304 | const Int_t n1 = seq.GetNumAllRuns();
|
|---|
| 305 | if (n0 != n1)
|
|---|
| 306 | {
|
|---|
| 307 | if (kForceExec)
|
|---|
| 308 | gLog << warn << "WARNING";
|
|---|
| 309 | else
|
|---|
| 310 | gLog << err << "ERROR";
|
|---|
| 311 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
|---|
| 312 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
|---|
| 313 | if (!kForceExec)
|
|---|
| 314 | return 2;
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | if (kPrintOnly)
|
|---|
| 318 | return 0;
|
|---|
| 319 | */
|
|---|
| 320 | //
|
|---|
| 321 | // Initialize root
|
|---|
| 322 | //
|
|---|
| 323 | MArray::Class()->IgnoreTObjectStreamer();
|
|---|
| 324 | MParContainer::Class()->IgnoreTObjectStreamer();
|
|---|
| 325 |
|
|---|
| 326 | TApplication app("callisto", &argc, argv);
|
|---|
| 327 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
|---|
| 328 | {
|
|---|
| 329 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
|---|
| 330 | return 1;
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | //
|
|---|
| 334 | // Update frequency by default = 1Hz
|
|---|
| 335 | //
|
|---|
| 336 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 337 |
|
|---|
| 338 | // From now on each 'Exit' means: Terminate the application
|
|---|
| 339 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
|---|
| 340 | d->SetTitle(kSequence);
|
|---|
| 341 |
|
|---|
| 342 | MEnv env(kConfig);
|
|---|
| 343 | if (!env.IsValid())
|
|---|
| 344 | {
|
|---|
| 345 | gLog << err << "Configuration file " << kConfig << " not found." << endl;
|
|---|
| 346 | return 0xfe;
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 | if (kModeC/* || kUseTest*/)
|
|---|
| 350 | {
|
|---|
| 351 | //
|
|---|
| 352 | // Calculate pedestal for pedestal-calculation and calibration
|
|---|
| 353 | //
|
|---|
| 354 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
|---|
| 355 | job1.SetNoStorage();
|
|---|
| 356 | job1.SetSequence(seq);
|
|---|
| 357 | job1.SetEnv(&env);
|
|---|
| 358 | job1.SetEnvDebug(kDebugEnv);
|
|---|
| 359 | job1.SetDisplay(d);
|
|---|
| 360 | job1.SetOverwrite(kOverwrite);
|
|---|
| 361 | job1.SetUseHists(kMoon);
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 | job1.SetExtractionFundamental();
|
|---|
| 365 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 366 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
|---|
| 367 |
|
|---|
| 368 | if (!job1.Process())
|
|---|
| 369 | {
|
|---|
| 370 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
|---|
| 371 | return 6;
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | if (!job1.GetDisplay())
|
|---|
| 375 | {
|
|---|
| 376 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 377 | return 1;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | //
|
|---|
| 381 | // Calculate pedestal and pedestal resolution
|
|---|
| 382 | //
|
|---|
| 383 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
|---|
| 384 | job2.SetNoStorage();
|
|---|
| 385 | job2.SetSequence(seq);
|
|---|
| 386 | job2.SetEnv(&env);
|
|---|
| 387 | job2.SetEnvDebug(kDebugEnv);
|
|---|
| 388 | job2.SetDisplay(d);;
|
|---|
| 389 | job2.SetOverwrite(kOverwrite);
|
|---|
| 390 | job2.SetUseHists(kMoon);
|
|---|
| 391 | job2.SetDeadPixelCheck();
|
|---|
| 392 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 393 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
|---|
| 394 |
|
|---|
| 395 | //job2.SetExtractorResolution();
|
|---|
| 396 | job2.SetExtractionWithExtractorRndm();
|
|---|
| 397 | job2.SetExtractor(job1.GetExtractor());
|
|---|
| 398 | job2.SetPedestals(job1.GetPedestalCam());
|
|---|
| 399 | job2.SetBadPixels(job1.GetBadPixels());
|
|---|
| 400 |
|
|---|
| 401 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
|---|
| 402 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 403 | if (!job2.Process())
|
|---|
| 404 | {
|
|---|
| 405 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
|---|
| 406 | return 7;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | if (!job2.GetDisplay())
|
|---|
| 410 | {
|
|---|
| 411 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 412 | return 1;
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | //
|
|---|
| 416 | // Do calibration
|
|---|
| 417 | //
|
|---|
| 418 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
|---|
| 419 | job3.SetSequence(seq);
|
|---|
| 420 | job3.SetEnv(&env);
|
|---|
| 421 | job3.SetEnvDebug(kDebugEnv);
|
|---|
| 422 | job3.SetDisplay(d);
|
|---|
| 423 | job3.SetOverwrite(kOverwrite);
|
|---|
| 424 | job3.SetPathOut(kOutpathC);
|
|---|
| 425 | // job2.SetPathIn(kInpathC); // not yet needed
|
|---|
| 426 |
|
|---|
| 427 | job3.SetBadPixels(job2.GetBadPixels());
|
|---|
| 428 | job3.SetExtractor(job2.GetExtractor());
|
|---|
| 429 | job3.SetExtractorCam(job2.GetPedestalCam());
|
|---|
| 430 |
|
|---|
| 431 | if (!job3.Process(job1.GetPedestalCam()))
|
|---|
| 432 | {
|
|---|
| 433 | gLog << err << "Calculation of calibration failed." << endl << endl;
|
|---|
| 434 | return 8;
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | if (kDebugEnv>0)
|
|---|
| 438 | env.PrintUntouched();
|
|---|
| 439 |
|
|---|
| 440 | if (!job3.GetDisplay())
|
|---|
| 441 | {
|
|---|
| 442 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 443 | return 1;
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | if (kUseTest)
|
|---|
| 447 | {
|
|---|
| 448 | MJCalibTest job4(Form("MJCalibTest #%d", seq.GetSequence()));
|
|---|
| 449 | job4.SetBadPixels(job2.GetBadPixels());
|
|---|
| 450 | job4.SetSequence(seq);
|
|---|
| 451 | job4.SetEnv(&env);
|
|---|
| 452 | job4.SetEnvDebug(kDebugEnv);
|
|---|
| 453 | job4.SetDisplay(d);;
|
|---|
| 454 | job4.SetOverwrite(kOverwrite);
|
|---|
| 455 | job4.SetPathOut(kOutpathC);
|
|---|
| 456 |
|
|---|
| 457 | if (!job4.Process(job1.GetPedestalCam()))
|
|---|
| 458 | {
|
|---|
| 459 | gLog << err << "Calibration of calibration failed." << endl << endl;
|
|---|
| 460 | return 9;
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 | if (kDebugEnv>0)
|
|---|
| 464 | env.PrintUntouched();
|
|---|
| 465 |
|
|---|
| 466 | if (!job4.GetDisplay())
|
|---|
| 467 | {
|
|---|
| 468 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 469 | return 1;
|
|---|
| 470 | }
|
|---|
| 471 | }
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | if (kModeY)
|
|---|
| 475 | {
|
|---|
| 476 | d->Reset();
|
|---|
| 477 |
|
|---|
| 478 | //
|
|---|
| 479 | // Calculate starting pedestal for data extraction
|
|---|
| 480 | //
|
|---|
| 481 | MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence()));
|
|---|
| 482 | job1.SetNoStorage();
|
|---|
| 483 | job1.SetSequence(seq);
|
|---|
| 484 | job1.SetEnv(&env);
|
|---|
| 485 | job1.SetEnvDebug(kDebugEnv);
|
|---|
| 486 | job1.SetDisplay(d);
|
|---|
| 487 | job1.SetNoDisplay();
|
|---|
| 488 | job1.SetOverwrite(kOverwrite);
|
|---|
| 489 | job1.SetPathIn(kInpathY); // --> READ Extractor from calib-file
|
|---|
| 490 | //job1.SetPathOut(kOutpathY); // not yet needed
|
|---|
| 491 | job1.SetUseData();
|
|---|
| 492 | job1.SetExtractionFundamental();
|
|---|
| 493 | job1.SetUseHists(kMoon);
|
|---|
| 494 |
|
|---|
| 495 | if (!job1.Process())
|
|---|
| 496 | {
|
|---|
| 497 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
|---|
| 498 | return 10;
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | if (!job1.GetDisplay())
|
|---|
| 502 | {
|
|---|
| 503 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 504 | return 1;
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|
| 507 | //
|
|---|
| 508 | // Calculate pedestal and pedestal resolution
|
|---|
| 509 | //
|
|---|
| 510 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
|---|
| 511 | job2.SetNoStorage(kMovie);
|
|---|
| 512 | job2.SetSequence(seq);
|
|---|
| 513 | job2.SetEnv(&env);
|
|---|
| 514 | job2.SetEnvDebug(kDebugEnv);
|
|---|
| 515 | job2.SetDisplay(d);
|
|---|
| 516 | job2.SetNoDisplay();
|
|---|
| 517 | job2.SetOverwrite(kOverwrite);
|
|---|
| 518 | job2.SetPathIn(kInpathY);
|
|---|
| 519 | job2.SetPulsePosCheck(!seq.IsMonteCarlo());
|
|---|
| 520 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
|---|
| 521 |
|
|---|
| 522 | job2.SetUseData();
|
|---|
| 523 | job2.SetExtractionWithExtractorRndm();
|
|---|
| 524 | job2.SetExtractor(job1.GetExtractor());
|
|---|
| 525 | job2.SetPedestals(job1.GetPedestalCam());
|
|---|
| 526 | job2.SetBadPixels(job1.GetBadPixels());
|
|---|
| 527 | job2.SetUseHists(kMoon);
|
|---|
| 528 |
|
|---|
| 529 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
|---|
| 530 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 531 | const Int_t rc = job2.Process();
|
|---|
| 532 | if (rc<=0)
|
|---|
| 533 | {
|
|---|
| 534 | // rc==0: Error
|
|---|
| 535 | // rc==-1: too much to the left
|
|---|
| 536 | // rc==-2: too much to the right
|
|---|
| 537 | // rc==-3: too much to the right (beyond limits)
|
|---|
| 538 |
|
|---|
| 539 | gLog << err << "Calculation of pedestal from extractor (random) failed." << endl << endl;
|
|---|
| 540 |
|
|---|
| 541 | //error coding for the automatic analysis (to be filled into the database)
|
|---|
| 542 | switch (rc)
|
|---|
| 543 | {
|
|---|
| 544 | case 0:
|
|---|
| 545 | return 11;
|
|---|
| 546 | case -1:
|
|---|
| 547 | return 12;
|
|---|
| 548 | case -2:
|
|---|
| 549 | return 13;
|
|---|
| 550 | case -3:
|
|---|
| 551 | return 14;
|
|---|
| 552 | }
|
|---|
| 553 | return 2;
|
|---|
| 554 | }
|
|---|
| 555 |
|
|---|
| 556 | if (!job2.GetDisplay())
|
|---|
| 557 | {
|
|---|
| 558 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 559 | return 1;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | //
|
|---|
| 563 | // Calculate pedestal and pedestal resolution
|
|---|
| 564 | //
|
|---|
| 565 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
|---|
| 566 | job3.SetNoStorage();
|
|---|
| 567 | job3.SetSequence(seq);
|
|---|
| 568 | job3.SetEnv(&env);
|
|---|
| 569 | job3.SetEnvDebug(kDebugEnv);
|
|---|
| 570 | job3.SetDisplay(d);
|
|---|
| 571 | job3.SetNoDisplay();
|
|---|
| 572 | job3.SetOverwrite(kOverwrite);
|
|---|
| 573 | job3.SetPathIn(kInpathY);
|
|---|
| 574 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 575 | // job1.SetPathIn(kInpathC); // not yet needed
|
|---|
| 576 |
|
|---|
| 577 | job3.SetUseData();
|
|---|
| 578 | job3.SetExtractionWithExtractor();
|
|---|
| 579 | job3.SetExtractor(job2.GetExtractor());
|
|---|
| 580 | job3.SetPedestals(job1.GetPedestalCam());
|
|---|
| 581 | job3.SetBadPixels(job1.GetBadPixels());
|
|---|
| 582 | job3.SetUseHists(kMoon);
|
|---|
| 583 |
|
|---|
| 584 | if (!job3.Process())
|
|---|
| 585 | {
|
|---|
| 586 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
|---|
| 587 | return 15;
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | if (!job3.GetDisplay())
|
|---|
| 591 | {
|
|---|
| 592 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 593 | return 1;
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | //
|
|---|
| 597 | // Extract signal and calibrate it
|
|---|
| 598 | //
|
|---|
| 599 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
|---|
| 600 | job4.SetSequence(seq);
|
|---|
| 601 | job4.SetDisplay(d);;
|
|---|
| 602 | job4.SetEnv(&env);
|
|---|
| 603 | job4.SetEnvDebug(kDebugEnv);
|
|---|
| 604 | job4.SetOverwrite(kOverwrite);
|
|---|
| 605 | job4.SetPathIn(kInpathY);
|
|---|
| 606 | job4.SetPathOut(kOutpathY);
|
|---|
| 607 | job4.SetMovieMode(kMovie);
|
|---|
| 608 | if (!seq.IsMonteCarlo())
|
|---|
| 609 | job4.SetExtractor(job2.GetExtractor());
|
|---|
| 610 |
|
|---|
| 611 | // Where to search for calibration files
|
|---|
| 612 | if (!job4.Process(job1.GetPedestalCam(), job3.GetPedestalCam(), job2.GetPedestalCam()))
|
|---|
| 613 | return 16;
|
|---|
| 614 |
|
|---|
| 615 | if (kDebugEnv>0)
|
|---|
| 616 | env.PrintUntouched();
|
|---|
| 617 |
|
|---|
| 618 | if (!job4.GetDisplay())
|
|---|
| 619 | {
|
|---|
| 620 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 621 | return 1;
|
|---|
| 622 | }
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | if (kBatch || kQuit)
|
|---|
| 626 | delete d;
|
|---|
| 627 | else
|
|---|
| 628 | {
|
|---|
| 629 | // From now on each 'Close' means: Terminate the application
|
|---|
| 630 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
|---|
| 631 |
|
|---|
| 632 | // Wait until the user decides to exit the application
|
|---|
| 633 | app.Run(kFALSE);
|
|---|
| 634 | }
|
|---|
| 635 |
|
|---|
| 636 | if (TObject::GetObjectStat())
|
|---|
| 637 | {
|
|---|
| 638 | TObject::SetObjectStat(kFALSE);
|
|---|
| 639 | gObjectTable->Print();
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | return 0;
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|