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