| 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 << " -raw Read input from raw-data <default>" << endl;
|
|---|
| 58 | gLog << " -mc Input root-files are monte carlo files" << endl;
|
|---|
| 59 | gLog << " -root Read input from root-files (merpped)" << endl << endl;
|
|---|
| 60 | gLog << " Options:" << endl;
|
|---|
| 61 | gLog.Usage();
|
|---|
| 62 | gLog << " --debug-env=0 Disable debugging setting resources <default>" << endl;
|
|---|
| 63 | gLog << " --debug-env[=1] Display untouched resources after program execution" << endl;
|
|---|
| 64 | gLog << " --debug-env=2 Display untouched resources after eventloop setup" << endl;
|
|---|
| 65 | gLog << " --debug-env=3 Debug setting resources from resource file" << endl;
|
|---|
| 66 | gLog << " --debug-mem Debug memory usage" << endl << endl;
|
|---|
| 67 | gLog << endl;
|
|---|
| 68 | gLog << " -q Quit when job is finished" << endl;
|
|---|
| 69 | gLog << " -f Force overwrite of existing files" << endl;
|
|---|
| 70 | gLog << " --ind=path Path where to search for the data files" << endl;
|
|---|
| 71 | gLog << " [default=standard path in datacenter]" << endl;
|
|---|
| 72 | gLog << " --iny=path Path where to search for the calibration files" << endl;
|
|---|
| 73 | gLog << " [default=local path or output path of Mode-C]" << endl;
|
|---|
| 74 | gLog << " --outc=path Path to write Mode-C result to [def=local path]" << endl;
|
|---|
| 75 | gLog << " --outy=path Path to write Mode-Y result to [def=local path]" << endl;
|
|---|
| 76 | gLog << " --out=path Path to write the all results to [def=local path]" << endl;
|
|---|
| 77 | gLog << " (overwrites --outc and --outy)" << endl;
|
|---|
| 78 | gLog << " --path=path Path to write the all results to [def=local path]" << endl;
|
|---|
| 79 | gLog << " (overwrites --iny, --outc and --outy)" << endl;
|
|---|
| 80 | gLog << " --print-seq Print Sequence information" << endl;
|
|---|
| 81 | gLog << " --print-files Print Files taken from Sequence" << endl;
|
|---|
| 82 | gLog << " --print-found Print Files found from Sequence" << endl;
|
|---|
| 83 | gLog << " --use-test Apply calibration constants to same calibration" << endl;
|
|---|
| 84 | gLog << " file (for testing, calibration mode only)" << 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 | //
|
|---|
| 148 | // Evaluate arguments
|
|---|
| 149 | //
|
|---|
| 150 | MArgs arg(argc, argv, kTRUE);
|
|---|
| 151 | gLog.Setup(arg);
|
|---|
| 152 |
|
|---|
| 153 | StartUpMessage();
|
|---|
| 154 |
|
|---|
| 155 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
|---|
| 156 | return 0;
|
|---|
| 157 |
|
|---|
| 158 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
|---|
| 159 | {
|
|---|
| 160 | Usage();
|
|---|
| 161 | return 2;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
|---|
| 165 |
|
|---|
| 166 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
|---|
| 167 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
|---|
| 168 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
|---|
| 169 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
|---|
| 170 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
|---|
| 171 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
|---|
| 172 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
|---|
| 173 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
|---|
| 174 |
|
|---|
| 175 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
|---|
| 176 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
|---|
| 177 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
|---|
| 178 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
|---|
| 179 |
|
|---|
| 180 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
|---|
| 181 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
|---|
| 182 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
|---|
| 183 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
|---|
| 184 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
|---|
| 185 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
|---|
| 186 |
|
|---|
| 187 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
|---|
| 188 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
|---|
| 189 |
|
|---|
| 190 | MJCalib::DataType_t kDataType = MJCalib::kIsUseRawData; // root
|
|---|
| 191 | if (arg.HasOnlyAndRemove("-root"))
|
|---|
| 192 | kDataType = MJCalib::kIsUseRootData; // root
|
|---|
| 193 | if (arg.HasOnlyAndRemove("-raw"))
|
|---|
| 194 | kDataType = MJCalib::kIsUseRawData; // raw
|
|---|
| 195 | if (arg.HasOnlyAndRemove("-mc"))
|
|---|
| 196 | kDataType = MJCalib::kIsUseMC; // monte carlo
|
|---|
| 197 |
|
|---|
| 198 | if (!kInpathY.IsNull() || !kOutpathY.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
|---|
| 199 | kModeY = kTRUE;
|
|---|
| 200 | if (!kOutpathC.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
|---|
| 201 | kModeC = kTRUE;
|
|---|
| 202 |
|
|---|
| 203 | //
|
|---|
| 204 | // check for the right usage of the program
|
|---|
| 205 | //
|
|---|
| 206 | if (arg.GetNumArguments()!=1)
|
|---|
| 207 | {
|
|---|
| 208 | Usage();
|
|---|
| 209 | return 2;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | if (arg.GetNumOptions()>0)
|
|---|
| 213 | {
|
|---|
| 214 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
|---|
| 215 | arg.Print("options");
|
|---|
| 216 | gLog << endl;
|
|---|
| 217 | return 2;
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
|---|
| 221 | {
|
|---|
| 222 | gLog << err << "Neither calibration (-c), signal extraction (-y) or test-mode (--use-test)" << endl;
|
|---|
| 223 | gLog << "specified! You can also give the operation mode by the options defining the" << endl;
|
|---|
| 224 | gLog << "output path --outc, --outy or --out." << endl;
|
|---|
| 225 | Usage();
|
|---|
| 226 | return 2;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
|---|
| 230 | kOutpathC = ".";
|
|---|
| 231 | if (kModeY)
|
|---|
| 232 | {
|
|---|
| 233 | if (kInpathY.IsNull())
|
|---|
| 234 | kInpathY = ".";
|
|---|
| 235 | if (kOutpathY.IsNull())
|
|---|
| 236 | kOutpathY = ".";
|
|---|
| 237 | }
|
|---|
| 238 | if (!kOutpath.IsNull())
|
|---|
| 239 | {
|
|---|
| 240 | kOutpathC = kOutpath;
|
|---|
| 241 | kOutpathY = kOutpath;
|
|---|
| 242 | }
|
|---|
| 243 | if (!kPath.IsNull())
|
|---|
| 244 | {
|
|---|
| 245 | kOutpathC = kOutpath;
|
|---|
| 246 | kOutpathY = kOutpath;
|
|---|
| 247 | kInpathY = kOutpath;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | if (kModeC && kModeY)
|
|---|
| 251 | kInpathY = kOutpathC;
|
|---|
| 252 |
|
|---|
| 253 | //
|
|---|
| 254 | // Setup sequence file and check for its existance
|
|---|
| 255 | //
|
|---|
| 256 | TString kSequence = arg.GetArgumentStr(0);
|
|---|
| 257 |
|
|---|
| 258 | if (kSequence.IsDigit())
|
|---|
| 259 | {
|
|---|
| 260 | const Int_t numseq = kSequence.Atoi();
|
|---|
| 261 | kSequence = Form("/magic/sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
|
|---|
| 262 | gLog << inf << "Inflated sequence file: " << kSequence << endl;
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | if (gSystem->AccessPathName(kSequence, kFileExists))
|
|---|
| 266 | {
|
|---|
| 267 | gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl;
|
|---|
| 268 | return 3;
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | if (gSystem->AccessPathName(kConfig, kFileExists))
|
|---|
| 272 | {
|
|---|
| 273 | gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
|
|---|
| 274 | return 4;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | if (kDebugMem)
|
|---|
| 278 | TObject::SetObjectStat(kTRUE);
|
|---|
| 279 |
|
|---|
| 280 | //
|
|---|
| 281 | // Setup sequence and check its validity
|
|---|
| 282 | //
|
|---|
| 283 | MSequence seq(kSequence);
|
|---|
| 284 | if (kPrintSeq)
|
|---|
| 285 | {
|
|---|
| 286 | gLog << all;
|
|---|
| 287 | gLog.Separator(kSequence);
|
|---|
| 288 | seq.Print();
|
|---|
| 289 | gLog << endl;
|
|---|
| 290 | }
|
|---|
| 291 | if (!seq.IsValid())
|
|---|
| 292 | {
|
|---|
| 293 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
|---|
| 294 | return 5;
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | //
|
|---|
| 298 | // Process print options
|
|---|
| 299 | //
|
|---|
| 300 | if (kPrintFiles)
|
|---|
| 301 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kFALSE);
|
|---|
| 302 | if (kPrintFound)
|
|---|
| 303 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kTRUE);
|
|---|
| 304 |
|
|---|
| 305 | if (seq.HasMoon())
|
|---|
| 306 | kMoon = kTRUE;
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 | /*
|
|---|
| 310 | //
|
|---|
| 311 | // Check for existance of all files
|
|---|
| 312 | //
|
|---|
| 313 | MDirIter iter;
|
|---|
| 314 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
|---|
| 315 | const Int_t n1 = seq.GetNumAllRuns();
|
|---|
| 316 | if (n0 != n1)
|
|---|
| 317 | {
|
|---|
| 318 | if (kForceExec)
|
|---|
| 319 | gLog << warn << "WARNING";
|
|---|
| 320 | else
|
|---|
| 321 | gLog << err << "ERROR";
|
|---|
| 322 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
|---|
| 323 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
|---|
| 324 | if (!kForceExec)
|
|---|
| 325 | return 2;
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | if (kPrintOnly)
|
|---|
| 329 | return 0;
|
|---|
| 330 | */
|
|---|
| 331 | //
|
|---|
| 332 | // Initialize root
|
|---|
| 333 | //
|
|---|
| 334 | MArray::Class()->IgnoreTObjectStreamer();
|
|---|
| 335 | MParContainer::Class()->IgnoreTObjectStreamer();
|
|---|
| 336 |
|
|---|
| 337 | TApplication app("callisto", &argc, argv);
|
|---|
| 338 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
|---|
| 339 | {
|
|---|
| 340 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
|---|
| 341 | return 1;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | //
|
|---|
| 345 | // Update frequency by default = 1Hz
|
|---|
| 346 | //
|
|---|
| 347 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 348 |
|
|---|
| 349 | // From now on each 'Exit' means: Terminate the application
|
|---|
| 350 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
|---|
| 351 | d->SetTitle(kSequence);
|
|---|
| 352 |
|
|---|
| 353 | MEnv env(kConfig);
|
|---|
| 354 | if (kModeC/* || kUseTest*/)
|
|---|
| 355 | {
|
|---|
| 356 | //
|
|---|
| 357 | // Calculate pedestal for pedestal-calculation and calibration
|
|---|
| 358 | //
|
|---|
| 359 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
|---|
| 360 | job1.SetNoStorage();
|
|---|
| 361 | job1.SetSequence(seq);
|
|---|
| 362 | job1.SetEnv(&env);
|
|---|
| 363 | job1.SetEnvDebug(kDebugEnv);
|
|---|
| 364 | job1.SetDisplay(d);
|
|---|
| 365 | job1.SetOverwrite(kOverwrite);
|
|---|
| 366 | job1.SetPathData(kInpathD);
|
|---|
| 367 | job1.SetDataType(kDataType);
|
|---|
| 368 | job1.SetUseHists(kMoon);
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 | job1.SetExtractionFundamental();
|
|---|
| 372 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 373 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
|---|
| 374 |
|
|---|
| 375 | if (!job1.Process())
|
|---|
| 376 | {
|
|---|
| 377 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
|---|
| 378 | return 6;
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | if (!job1.GetDisplay())
|
|---|
| 382 | {
|
|---|
| 383 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 384 | return 1;
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | //
|
|---|
| 388 | // Calculate pedestal and pedestal resolution
|
|---|
| 389 | //
|
|---|
| 390 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
|---|
| 391 | job2.SetNoStorage();
|
|---|
| 392 | job2.SetSequence(seq);
|
|---|
| 393 | job2.SetEnv(&env);
|
|---|
| 394 | job2.SetEnvDebug(kDebugEnv);
|
|---|
| 395 | job2.SetDisplay(d);;
|
|---|
| 396 | job2.SetOverwrite(kOverwrite);
|
|---|
| 397 | job2.SetPathData(kInpathD);
|
|---|
| 398 | job2.SetDataType(kDataType);
|
|---|
| 399 | job2.SetUseHists(kMoon);
|
|---|
| 400 | job2.SetDeadPixelCheck();
|
|---|
| 401 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 402 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
|---|
| 403 |
|
|---|
| 404 | //job2.SetExtractorResolution();
|
|---|
| 405 | job2.SetExtractionWithExtractorRndm();
|
|---|
| 406 | job2.SetExtractor(job1.GetExtractor());
|
|---|
| 407 | job2.SetPedestals(job1.GetPedestalCam());
|
|---|
| 408 | job2.SetBadPixels(job1.GetBadPixels());
|
|---|
| 409 |
|
|---|
| 410 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
|---|
| 411 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 412 | if (!job2.Process())
|
|---|
| 413 | {
|
|---|
| 414 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
|---|
| 415 | return 7;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | if (!job2.GetDisplay())
|
|---|
| 419 | {
|
|---|
| 420 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 421 | return 1;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | //
|
|---|
| 425 | // Do calibration
|
|---|
| 426 | //
|
|---|
| 427 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
|---|
| 428 | job3.SetSequence(seq);
|
|---|
| 429 | job3.SetEnv(&env);
|
|---|
| 430 | job3.SetEnvDebug(kDebugEnv);
|
|---|
| 431 | job3.SetDisplay(d);
|
|---|
| 432 | job3.SetOverwrite(kOverwrite);
|
|---|
| 433 | job3.SetPathOut(kOutpathC);
|
|---|
| 434 | job3.SetPathData(kInpathD);
|
|---|
| 435 | job3.SetDataType(kDataType);
|
|---|
| 436 | // job2.SetPathIn(kInpathC); // not yet needed
|
|---|
| 437 |
|
|---|
| 438 | job3.SetBadPixels(job2.GetBadPixels());
|
|---|
| 439 | job3.SetExtractor(job2.GetExtractor());
|
|---|
| 440 | job3.SetExtractorCam(job2.GetPedestalCam());
|
|---|
| 441 |
|
|---|
| 442 | if (!job3.Process(job1.GetPedestalCam()))
|
|---|
| 443 | {
|
|---|
| 444 | gLog << err << "Calculation of calibration failed." << endl << endl;
|
|---|
| 445 | return 8;
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | if (kDebugEnv>0)
|
|---|
| 449 | env.PrintUntouched();
|
|---|
| 450 |
|
|---|
| 451 | if (!job3.GetDisplay())
|
|---|
| 452 | {
|
|---|
| 453 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 454 | return 1;
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | if (kUseTest)
|
|---|
| 458 | {
|
|---|
| 459 | MJCalibTest job4(Form("MJCalibTest #%d", seq.GetSequence()));
|
|---|
| 460 | job4.SetBadPixels(job2.GetBadPixels());
|
|---|
| 461 | job4.SetSequence(seq);
|
|---|
| 462 | job4.SetEnv(&env);
|
|---|
| 463 | job4.SetEnvDebug(kDebugEnv);
|
|---|
| 464 | job4.SetDisplay(d);;
|
|---|
| 465 | job4.SetOverwrite(kOverwrite);
|
|---|
| 466 | job4.SetPathOut(kOutpathC);
|
|---|
| 467 | job4.SetPathData(kInpathD);
|
|---|
| 468 | job4.SetDataType(kDataType);
|
|---|
| 469 |
|
|---|
| 470 | if (!job4.Process(job1.GetPedestalCam()))
|
|---|
| 471 | {
|
|---|
| 472 | gLog << err << "Calibration of calibration failed." << endl << endl;
|
|---|
| 473 | return 9;
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | if (kDebugEnv>0)
|
|---|
| 477 | env.PrintUntouched();
|
|---|
| 478 |
|
|---|
| 479 | if (!job4.GetDisplay())
|
|---|
| 480 | {
|
|---|
| 481 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 482 | return 1;
|
|---|
| 483 | }
|
|---|
| 484 | }
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | if (kModeY)
|
|---|
| 488 | {
|
|---|
| 489 | d->Reset();
|
|---|
| 490 |
|
|---|
| 491 | //
|
|---|
| 492 | // Calculate starting pedestal for data extraction
|
|---|
| 493 | //
|
|---|
| 494 | MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence()));
|
|---|
| 495 | job1.SetNoStorage();
|
|---|
| 496 | job1.SetSequence(seq);
|
|---|
| 497 | job1.SetEnv(&env);
|
|---|
| 498 | job1.SetEnvDebug(kDebugEnv);
|
|---|
| 499 | job1.SetDisplay(d);
|
|---|
| 500 | job1.SetNoDisplay();
|
|---|
| 501 | job1.SetOverwrite(kOverwrite);
|
|---|
| 502 | job1.SetPathData(kInpathD);
|
|---|
| 503 | job1.SetPathIn(kInpathY); // --> READ Extractor from calib-file
|
|---|
| 504 | job1.SetDataType(kDataType);
|
|---|
| 505 | //job1.SetPathOut(kOutpathY); // not yet needed
|
|---|
| 506 | job1.SetUseData();
|
|---|
| 507 | job1.SetExtractionFundamental();
|
|---|
| 508 | job1.SetUseHists(kMoon);
|
|---|
| 509 |
|
|---|
| 510 | if (!job1.Process())
|
|---|
| 511 | {
|
|---|
| 512 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
|---|
| 513 | return 10;
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | if (!job1.GetDisplay())
|
|---|
| 517 | {
|
|---|
| 518 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 519 | return 1;
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | //
|
|---|
| 523 | // Calculate pedestal and pedestal resolution
|
|---|
| 524 | //
|
|---|
| 525 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
|---|
| 526 | job2.SetNoStorage();
|
|---|
| 527 | job2.SetSequence(seq);
|
|---|
| 528 | job2.SetEnv(&env);
|
|---|
| 529 | job2.SetEnvDebug(kDebugEnv);
|
|---|
| 530 | job2.SetDisplay(d);
|
|---|
| 531 | job2.SetNoDisplay();
|
|---|
| 532 | job2.SetOverwrite(kOverwrite);
|
|---|
| 533 | job2.SetPathData(kInpathD);
|
|---|
| 534 | job2.SetPathIn(kInpathY);
|
|---|
| 535 | job2.SetDataType(kDataType);
|
|---|
| 536 | job2.SetPulsePosCheck(kDataType!=MJCalib::kIsUseMC);
|
|---|
| 537 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
|---|
| 538 |
|
|---|
| 539 | job2.SetUseData();
|
|---|
| 540 | job2.SetExtractionWithExtractorRndm();
|
|---|
| 541 | job2.SetExtractor(job1.GetExtractor());
|
|---|
| 542 | job2.SetPedestals(job1.GetPedestalCam());
|
|---|
| 543 | job2.SetBadPixels(job1.GetBadPixels());
|
|---|
| 544 | job2.SetUseHists(kMoon);
|
|---|
| 545 |
|
|---|
| 546 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
|---|
| 547 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
|---|
| 548 | const Int_t rc = job2.Process();
|
|---|
| 549 | if (rc<=0)
|
|---|
| 550 | {
|
|---|
| 551 | // rc==0: Error
|
|---|
| 552 | // rc==-1: too much to the left
|
|---|
| 553 | // rc==-2: too much to the right
|
|---|
| 554 | // rc==-3: too much to the right (beyond limits)
|
|---|
| 555 |
|
|---|
| 556 | gLog << err << "Calculation of pedestal from extractor (random) failed." << endl << endl;
|
|---|
| 557 |
|
|---|
| 558 | //error coding for the automatic analysis (to be filled into the database)
|
|---|
| 559 | switch (rc)
|
|---|
| 560 | {
|
|---|
| 561 | case 0:
|
|---|
| 562 | return 11;
|
|---|
| 563 | case -1:
|
|---|
| 564 | return 12;
|
|---|
| 565 | case -2:
|
|---|
| 566 | return 13;
|
|---|
| 567 | case -3:
|
|---|
| 568 | return 14;
|
|---|
| 569 | }
|
|---|
| 570 | return 2;
|
|---|
| 571 | }
|
|---|
| 572 |
|
|---|
| 573 | if (!job2.GetDisplay())
|
|---|
| 574 | {
|
|---|
| 575 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 576 | return 1;
|
|---|
| 577 | }
|
|---|
| 578 |
|
|---|
| 579 | //
|
|---|
| 580 | // Calculate pedestal and pedestal resolution
|
|---|
| 581 | //
|
|---|
| 582 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
|---|
| 583 | job3.SetNoStorage();
|
|---|
| 584 | job3.SetSequence(seq);
|
|---|
| 585 | job3.SetEnv(&env);
|
|---|
| 586 | job3.SetEnvDebug(kDebugEnv);
|
|---|
| 587 | job3.SetDisplay(d);
|
|---|
| 588 | job3.SetNoDisplay();
|
|---|
| 589 | job3.SetOverwrite(kOverwrite);
|
|---|
| 590 | job3.SetPathData(kInpathD);
|
|---|
| 591 | job3.SetPathIn(kInpathY);
|
|---|
| 592 | job3.SetDataType(kDataType);
|
|---|
| 593 | // job1.SetPathOut(kOutpathC); // not yet needed
|
|---|
| 594 | // job1.SetPathIn(kInpathC); // not yet needed
|
|---|
| 595 |
|
|---|
| 596 | job3.SetUseData();
|
|---|
| 597 | job3.SetExtractionWithExtractor();
|
|---|
| 598 | job3.SetExtractor(job2.GetExtractor());
|
|---|
| 599 | job3.SetPedestals(job1.GetPedestalCam());
|
|---|
| 600 | job3.SetBadPixels(job1.GetBadPixels());
|
|---|
| 601 | job3.SetUseHists(kMoon);
|
|---|
| 602 |
|
|---|
| 603 | if (!job3.Process())
|
|---|
| 604 | {
|
|---|
| 605 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
|---|
| 606 | return 15;
|
|---|
| 607 | }
|
|---|
| 608 |
|
|---|
| 609 | if (!job3.GetDisplay())
|
|---|
| 610 | {
|
|---|
| 611 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 612 | return 1;
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | //
|
|---|
| 616 | // Extract signal and calibrate it
|
|---|
| 617 | //
|
|---|
| 618 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
|---|
| 619 | job4.SetSequence(seq);
|
|---|
| 620 | job4.SetDisplay(d);;
|
|---|
| 621 | job4.SetEnv(&env);
|
|---|
| 622 | job4.SetEnvDebug(kDebugEnv);
|
|---|
| 623 | job4.SetOverwrite(kOverwrite);
|
|---|
| 624 | job4.SetPathIn(kInpathY);
|
|---|
| 625 | job4.SetPathOut(kOutpathY);
|
|---|
| 626 | job4.SetPathData(kInpathD);
|
|---|
| 627 | job4.SetDataType(kDataType);
|
|---|
| 628 | if (kDataType!=MJCalib::kIsUseMC)
|
|---|
| 629 | job4.SetExtractor(job2.GetExtractor());
|
|---|
| 630 |
|
|---|
| 631 | // Where to search for calibration files
|
|---|
| 632 | if (!job4.Process(job1.GetPedestalCam(), job3.GetPedestalCam(), job2.GetPedestalCam()))
|
|---|
| 633 | return 16;
|
|---|
| 634 |
|
|---|
| 635 | if (kDebugEnv>0)
|
|---|
| 636 | env.PrintUntouched();
|
|---|
| 637 |
|
|---|
| 638 | if (!job4.GetDisplay())
|
|---|
| 639 | {
|
|---|
| 640 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
|---|
| 641 | return 1;
|
|---|
| 642 | }
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | if (kBatch || kQuit)
|
|---|
| 646 | delete d;
|
|---|
| 647 | else
|
|---|
| 648 | {
|
|---|
| 649 | // From now on each 'Close' means: Terminate the application
|
|---|
| 650 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
|---|
| 651 |
|
|---|
| 652 | // Wait until the user decides to exit the application
|
|---|
| 653 | app.Run(kFALSE);
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | if (TObject::GetObjectStat())
|
|---|
| 657 | {
|
|---|
| 658 | TObject::SetObjectStat(kFALSE);
|
|---|
| 659 | gObjectTable->Print();
|
|---|
| 660 | }
|
|---|
| 661 |
|
|---|
| 662 | return 0;
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|