#include #include #include #include #include #include #include "MLog.h" #include "MLogManip.h" #include "MArgs.h" #include "MArray.h" #include "MDirIter.h" #include "MStatusDisplay.h" #include "MSequence.h" #include "MJPedestal.h" #include "MJCalibration.h" #include "MJCalibrateSignal.h" using namespace std; static void StartUpMessage() { gLog << all << endl; // 1 2 3 4 5 // 12345678901234567890123456789012345678901234567890 gLog << "========================================================" << endl; gLog << " Callisto - MARS V" << MARSVER << endl; gLog << " MARS -- CALibrate LIght Signals and Time Offsets" << endl; gLog << " Compiled on <" << __DATE__ << ">" << endl; gLog << " Using ROOT v" << ROOTVER << endl; gLog << "========================================================" << endl; gLog << endl; } static void Usage() { // 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 gLog << all << endl; gLog << "Sorry the usage is:" << endl; gLog << " callisto [-c] [-y] [options] sequence.txt" << endl << endl; gLog << " Arguments:" << endl; gLog << " sequence.txt: An ascii file defining a sequence of runs" << endl; gLog << " Root Options:" << endl; gLog << " -b Batch mode (no graphical output to screen)" << endl<0) { gLog << warn << "WARNING - Unknown commandline options..." << endl; arg.Print("options"); gLog << endl; } // // check for the right usage of the program // if (arg.GetNumArguments()!=1) { Usage(); return -1; } // // Setup sequence file and check for its existance // const TString kSequence = arg.GetArgumentStr(0); if (gSystem->AccessPathName(kSequence, kFileExists)) { gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl; return -1; } if (kDebugMem) TObject::SetObjectStat(kTRUE); // // Setup sequence and check its validity // MSequence seq(kSequence); if (kPrintSeq) { gLog << all; gLog.Separator(kSequence); seq.Print(); gLog << endl; } if (!seq.IsValid()) { gLog << err << "Sequence read but not valid!" << endl << endl; return -1; } /* // // Process print options // if (kPrintFiles) { MDirIter Next1, Next2, Next3; seq.SetupPedRuns(Next1, kInpathD); seq.SetupCalRuns(Next2, kInpathD); seq.SetupDatRuns(Next3, kInpathD); gLog << all; gLog.Separator("Pedestal Files"); Next1.Print("all"); gLog << endl; gLog.Separator("Calibration Files"); Next2.Print("all"); gLog << endl; gLog.Separator("Data Files"); Next3.Print("all"); gLog << endl; } // // Check for existance of all files // MDirIter iter; const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]"); const Int_t n1 = seq.GetNumAllRuns(); if (n0 != n1) { if (kForceExec) gLog << warn << "WARNING"; else gLog << err << "ERROR"; gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in "; gLog << (kInpathD.IsNull() ? "" : kInpathD.Data()) << endl; if (!kForceExec) return -1; } if (kPrintOnly) return 0; */ // // Initialize root // MArray::Class()->IgnoreTObjectStreamer(); MParContainer::Class()->IgnoreTObjectStreamer(); TApplication app("Callisto", &argc, argv); if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch) { gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl; return 1; } // // Update frequency by default = 1Hz // MStatusDisplay *d = new MStatusDisplay; // From now on each 'Exit' means: Terminate the application d->SetBit(MStatusDisplay::kExitLoopOnExit); d->SetTitle(kSequence); if (kModeC) { // // Calculate pedestal for pedestal-calculation and calibration // MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence())); job1.SetNoStorage(); job1.SetSequence(seq); job1.SetEnv(kConfig); job1.SetEnvDebug(kDebugEnv); job1.SetDisplay(d);; job1.SetOverwrite(kOverwrite); job1.SetPathData(kInpathD); job1.SetExtractionFundamental(); // job1.SetPathOut(kOutpathC); // not yet needed // job1.SetPathIn(kInpathC); // not yet needed if (!job1.ProcessFile()) { gLog << err << "Calculation of pedestal failed." << endl << endl; return -1; } if (!job1.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } // // Calculate pedestal and pedestal resolution // MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence())); job2.SetNoStorage(); job2.SetSequence(seq); job2.SetEnv(kConfig); job2.SetEnvDebug(kDebugEnv); job2.SetDisplay(d);; job2.SetOverwrite(kOverwrite); job2.SetPathData(kInpathD); // job1.SetPathOut(kOutpathC); // not yet needed // job1.SetPathIn(kInpathC); // not yet needed //job2.SetExtractorResolution(); job2.SetExtractionWithExtractorRndm(); job2.SetExtractor(job1.GetExtractor()); job2.SetPedestals(job1.GetPedestalCam()); job2.SetBadPixels(job1.GetBadPixels()); if (!job2.ProcessFile()) { gLog << err << "Calculation of pedestal resolution failed." << endl << endl; return -1; } if (!job2.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } // // Do calibration // MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence())); job3.SetSequence(seq); job3.SetEnv(kConfig); job3.SetEnvDebug(kDebugEnv); job3.SetDisplay(d);; job3.SetOverwrite(kOverwrite); job3.SetPathOut(kOutpathC); job3.SetPathData(kInpathD); // job2.SetPathIn(kInpathC); // not yet needed job3.SetBadPixels(job2.GetBadPixels()); job3.SetExtractor(job2.GetExtractor()); job3.SetExtractorCam(job2.GetPedestalCam()); if (!job3.ProcessFile(job1.GetPedestalCam())) { gLog << err << "Calculation of calibration failed." << endl << endl; return -1; } if (!job3.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } } if (kModeY) { d->Reset(); // // Calculate starting pedestal for data extraction // MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence())); job1.SetNoStorage(); job1.SetSequence(seq); job1.SetEnv(kConfig); job1.SetEnvDebug(kDebugEnv); job1.SetDisplay(d);; job1.SetOverwrite(kOverwrite); job1.SetPathData(kInpathD); job1.SetPathIn(kInpathY); //job1.SetPathOut(kOutpathY); // not yet needed job1.SetUseData(); job1.SetExtractionFundamental(); if (!job1.ProcessFile()) { gLog << err << "Calculation of fundamental pedestal failed." << endl << endl; return -1; } if (!job1.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } // // Calculate pedestal and pedestal resolution // MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence())); job2.SetNoStorage(); job2.SetSequence(seq); job2.SetEnv(kConfig); job2.SetEnvDebug(kDebugEnv); job2.SetDisplay(d);; job2.SetOverwrite(kOverwrite); job2.SetPathData(kInpathD); job2.SetPathIn(kInpathY); // job1.SetPathOut(kOutpathC); // not yet needed // job1.SetPathIn(kInpathC); // not yet needed job2.SetUseData(); job2.SetExtractionWithExtractor(); job2.SetExtractor(job1.GetExtractor()); job2.SetPedestals(job1.GetPedestalCam()); job2.SetBadPixels(job1.GetBadPixels()); if (!job2.ProcessFile()) { gLog << err << "Calculation of pedestal from extrtactor (random) failed." << endl << endl; return -1; } if (!job2.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } // // Calculate pedestal and pedestal resolution // MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence())); job3.SetNoStorage(); job3.SetSequence(seq); job3.SetEnv(kConfig); job3.SetEnvDebug(kDebugEnv); job3.SetDisplay(d);; job3.SetOverwrite(kOverwrite); job3.SetPathData(kInpathD); job3.SetPathIn(kInpathY); // job1.SetPathOut(kOutpathC); // not yet needed // job1.SetPathIn(kInpathC); // not yet needed job3.SetUseData(); job3.SetExtractionWithExtractorRndm(); job3.SetExtractor(job1.GetExtractor()); job3.SetPedestals(job1.GetPedestalCam()); job3.SetBadPixels(job1.GetBadPixels()); if (!job3.ProcessFile()) { gLog << err << "Calculation of pedestal from extractor failed." << endl << endl; return -1; } if (!job3.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } // // Extract signal and calibrate it // MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence())); job4.SetSequence(seq); job4.SetDisplay(d);; job4.SetEnv(kConfig); job4.SetEnvDebug(kDebugEnv); job4.SetOverwrite(kOverwrite); job4.SetPathIn(kInpathY); job4.SetPathOut(kOutpathY); job4.SetPathData(kInpathD); // Where to search for calibration files if (!job4.ProcessFile(job1.GetPedestalCam(), job2.GetPedestalCam(), job3.GetPedestalCam())) return -1; if (!job4.GetDisplay()) { gLog << warn << "Display closed by user... execution aborted." << endl << endl; return 1; } } if (kBatch || kQuit) delete d; else { // From now on each 'Close' means: Terminate the application d->SetBit(MStatusDisplay::kExitLoopOnClose); // Wait until the user decides to exit the application app.Run(kFALSE); } if (TObject::GetObjectStat()) { TObject::SetObjectStat(kFALSE); gObjectTable->Print(); } return 0; }