- Timestamp:
- 02/02/05 11:32:56 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/NEWS
r6167 r6193 1 1 -*-*- END -*-*- 2 2 *** Version <cvs> 3 4 - Reference lines in the display can be read from conf. file 5 6 - Interlaced cal. events are now handled correctly by callisto. 7 8 - High-Gain vs. Low-Gain calibration constants can be calculated (but not 9 yet applied) in callisto. 10 11 - class MJCalibTest can be called by callisto 12 13 - interpolated pointing positions are now in Tree "Events" after calibration 14 15 - callisto can now run with three data types: rawdata, rootdata, MC 3 16 4 17 - added two classes mreport/MReportStarguider.cc and -
trunk/MagicSoft/Mars/mjobs/MJCalibTest.cc
r6191 r6193 66 66 67 67 #include "MReadMarsFile.h" 68 #include "MRawFileRead.h" 68 69 #include "MGeomApply.h" 70 #include "MGeomCam.h" 69 71 #include "MExtractTimeAndChargeSlidingWindow.h" 70 72 #include "MExtractor.h" … … 239 241 240 242 243 const char* MJCalibTest::GetInputFile() const 244 { 245 246 if (fSequence.IsValid()) 247 return Form("%s/calib%08d.root", (const char*)fPathOut, fSequence.GetSequence()); 248 249 if (!fRuns) 250 return ""; 251 252 return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName()); 253 254 } 255 256 241 257 const char* MJCalibTest::GetOutputFile() const 242 258 { … … 252 268 } 253 269 254 255 Bool_t MJCalibTest::Process(MPedestalCam &pedcam, 256 MCalibrationChargeCam &calcam, MCalibrationQECam &qecam, 257 MCalibrationRelTimeCam &reltime, 258 Byte_t filetype) 270 Bool_t MJCalibTest::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const 271 { 272 273 const TString fname = GetInputFile(); 274 275 *fLog << inf << "Reading from file: " << fname << endl; 276 277 TFile file(fname, "READ"); 278 if (!file.IsOpen()) 279 { 280 *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl; 281 return kFALSE; 282 } 283 284 TObject *o = file.Get("ExtractSignal"); 285 if (o && !o->InheritsFrom(MExtractor::Class())) 286 { 287 *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl; 288 return kFALSE; 289 } 290 ext1 = o ? (MExtractor*)o->Clone() : NULL; 291 292 o = file.Get("ExtractTime"); 293 if (o && !o->InheritsFrom(MExtractor::Class())) 294 { 295 *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl; 296 return kFALSE; 297 } 298 ext2 = o ? (MExtractor*)o->Clone() : NULL; 299 if (!ext1 && !ext2) 300 { 301 *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl; 302 return kFALSE; 303 } 304 305 o = file.Get("MGeomCam"); 306 if (o && !o->InheritsFrom(MGeomCam::Class())) 307 { 308 *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl; 309 return kFALSE; 310 } 311 geom = o ? o->ClassName() : ""; 312 313 TObjArray cont(l); 314 cont.Add(&cam); 315 return ReadContainer(cont); 316 } 317 318 // -------------------------------------------------------------------------- 319 // 320 // MJCalibration allows to setup several option by a resource file: 321 // MJCalibrateSignal.RawData: yes,no 322 // 323 // For more details see the class description and the corresponding Getters 324 // 325 Bool_t MJCalibTest::CheckEnvLocal() 326 { 327 328 SetUseRootData(); 329 330 if (HasEnv("DataType")) 331 { 332 TString dat = GetEnv("DataType", ""); 333 if (dat.BeginsWith("raw", TString::kIgnoreCase)) 334 { 335 fDataFlag = 0; 336 SetUseRawData(); 337 } 338 if (dat.BeginsWith("root", TString::kIgnoreCase)) 339 { 340 fDataFlag = 0; 341 SetUseRootData(); 342 } 343 if (dat.BeginsWith("mc", TString::kIgnoreCase)) 344 { 345 fDataFlag = 0; 346 SetUseMC(); 347 } 348 } 349 return kTRUE; 350 } 351 352 Bool_t MJCalibTest::Process(MPedestalCam &pedcam) 259 353 { 260 354 // const TString fname = GetOutputFile(); 261 355 262 356 // if (gSystem->AccessPathName(fname, kFileExists)) 263 return ProcessFile(pedcam ,calcam,qecam,reltime,filetype);357 return ProcessFile(pedcam); 264 358 265 359 // return kTRUE; 266 360 } 267 361 268 Bool_t MJCalibTest::ProcessFile(MPedestalCam &pedcam, 269 MCalibrationChargeCam &calcam, MCalibrationQECam &qecam, 270 MCalibrationRelTimeCam &relcam, 271 Byte_t filetype) 272 { 273 if (!fRuns) 274 { 275 *fLog << err << "No Runs choosen... abort." << endl; 276 return kFALSE; 277 } 278 if (fRuns->GetNumRuns() != fRuns->GetNumEntries()) 279 { 280 *fLog << err << "Number of files found doesn't match number of runs... abort." << endl; 281 return kFALSE; 282 } 362 Bool_t MJCalibTest::ProcessFile(MPedestalCam &pedcam) 363 { 364 365 366 if (!fSequence.IsValid()) 367 { 368 if (!fRuns) 369 { 370 *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl; 371 return kFALSE; 372 } 373 374 if (fRuns->GetNumRuns() != fRuns->GetNumEntries()) 375 { 376 *fLog << err << "Number of files found doesn't match number of runs... abort." 377 << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl; 378 return kFALSE; 379 } 380 *fLog << "Calibrate data from "; 381 *fLog << "Runs " << fRuns->GetRunsAsString() << endl; 382 *fLog << endl; 383 } 384 385 CheckEnv(); 283 386 284 387 *fLog << inf; … … 287 390 *fLog << endl; 288 391 289 MBadPixelsCam badcam; 290 392 MDirIter iter; 393 394 if (fSequence.IsValid()) 395 { 396 const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData()); 397 const Int_t n1 = fSequence.GetNumDatRuns(); 398 if (n0==0) 399 { 400 *fLog << err << "ERROR - No input files of sequence found!" << endl; 401 return kFALSE; 402 } 403 if (n0!=n1) 404 { 405 *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl; 406 return kFALSE; 407 } 408 } 409 410 MCalibrationChargeCam calcam; 411 MCalibrationQECam qecam; 412 MCalibrationRelTimeCam tmcam; 413 MBadPixelsCam badpix; 414 415 TObjArray calibcont; 416 calibcont.Add(&calcam); 417 calibcont.Add(&qecam); 418 calibcont.Add(&tmcam); 419 420 MExtractor *extractor1=0; 421 MExtractor *extractor2=0; 422 TString geom; 423 424 if (!ReadCalibration(calibcont, badpix, extractor1, extractor2, geom)) 425 return kFALSE; 426 427 *fLog << all; 428 if (extractor1) 429 { 430 *fLog << underline << "Signal Extractor found in calibration file" << endl; 431 extractor1->Print(); 432 *fLog << endl; 433 } 434 else 435 *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl; 436 437 if (extractor2) 438 { 439 *fLog << underline << "Time Extractor found in calibration file" << endl; 440 extractor2->Print(); 441 *fLog << endl; 442 } 443 else 444 *fLog << inf << "No Time Extractor: ExtractTime in file." << endl; 445 446 if (!geom.IsNull()) 447 *fLog << inf << "Camera geometry found in file: " << geom << endl; 448 else 449 *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl; 450 451 if (fExtractor) 452 extractor1 = fExtractor; 453 if (fTimeExtractor) 454 extractor2 = fTimeExtractor; 455 291 456 // Setup Lists 292 457 MParList plist; … … 294 459 plist.AddToList(&fTestCam); 295 460 plist.AddToList(&fTestTimeCam); 296 plist.AddToList(&bad cam);461 plist.AddToList(&badpix); 297 462 plist.AddToList(&pedcam); 298 463 plist.AddToList(&calcam); 299 464 plist.AddToList(&qecam); 300 plist.AddToList(& relcam);465 plist.AddToList(&tmcam); 301 466 302 467 MCerPhotEvt cerphot; … … 314 479 315 480 // Setup Task-lists 481 MRawFileRead rawread(NULL); 316 482 MReadMarsFile read("Events"); 317 483 read.DisableAutoScheme(); 318 static_cast<MRead&>(read).AddFiles(*fRuns); 319 484 485 if (IsUseRawData()) 486 rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns); 487 else 488 static_cast<MRead&>(read).AddFiles(fSequence.IsValid() ? iter : *fRuns); 489 320 490 // Check for interleaved events 321 491 MTriggerPatternDecode decode; … … 325 495 326 496 MGeomApply apply; // Only necessary to craete geometry 327 apply.SetGeometry(fGeometry); 328 MBadPixelsMerge merge(&fBadPixels); 497 if (!geom.IsNull()) 498 apply.SetGeometry(geom); 499 MBadPixelsMerge merge(&badpix); 329 500 330 501 MExtractTimeAndChargeSlidingWindow extrsw; … … 335 506 MTaskEnv taskenv2("ExtractTime"); 336 507 337 if ( fExtractor)508 if (extractor1) 338 509 { 339 fExtractor->SetPedestals(&pedcam);340 taskenv1.SetDefault( fExtractor);510 extractor1->SetPedestals(&pedcam); 511 taskenv1.SetDefault(extractor1); 341 512 } 342 513 if (fTimeExtractor) … … 356 527 MCalibrateData photcalc; 357 528 MCalibrateRelTimes caltimes; 358 if ( filetype==3) // MC file529 if (IsUseMC()) // MC file 359 530 { 360 531 photcalc.SetCalibrationMode(MCalibrateData::kFfactor); … … 409 580 tlist.AddToList(&conttp); 410 581 tlist.AddToList(&taskenv1); 411 if (! fExtractor->InheritsFrom("MExtractTimeAndCharge"))582 if (!extractor1->InheritsFrom("MExtractTimeAndCharge")) 412 583 tlist.AddToList(&taskenv2); 413 584 tlist.AddToList(&contcos); … … 448 619 } 449 620 450 Bool_t MJCalibTest::ReadPedPhotCam()451 {452 453 const TString fname = GetOutputFile();454 455 if (gSystem->AccessPathName(fname, kFileExists))456 {457 *fLog << err << "Input file " << fname << " doesn't exist." << endl;458 return kFALSE;459 }460 461 *fLog << inf << "Reading from file: " << fname << endl;462 463 TFile file(fname, "READ");464 if (fPedPhotCam.Read()<=0)465 {466 *fLog << "Unable to read MPedPhotCam from " << fname << endl;467 return kFALSE;468 }469 470 if (file.FindKey("MBadPixelsCam"))471 {472 MBadPixelsCam bad;473 if (bad.Read()<=0)474 {475 *fLog << "Unable to read MBadPixelsCam from " << fname << endl;476 return kFALSE;477 }478 fBadPixels.Merge(bad);479 }480 481 if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!482 fDisplay->Read();483 484 return kTRUE;485 }486 487 621 Bool_t MJCalibTest::WriteResult() 488 622 { -
trunk/MagicSoft/Mars/mjobs/MJCalibTest.h
r6191 r6193 52 52 TString fGeometry; 53 53 54 Bool_t ReadPedPhotCam();55 54 Bool_t CheckEnvLocal(); 55 56 56 void DisplayResult(MParList &plist); 57 57 void DisplayResultT(MParList &plist); … … 59 59 Bool_t WriteResult(); 60 60 61 Bool_t ProcessFile(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam, 62 MCalibrationRelTimeCam &rel, Byte_t filetype); 61 Bool_t ReadCalibration(TObjArray &o, MBadPixelsCam &bpix, 62 MExtractor* &ext1, MExtractor* &ext2, TString &geom) const; 63 64 Bool_t ProcessFile(MPedestalCam &pedcam); 63 65 64 66 public: … … 67 69 68 70 const char* GetOutputFile() const; 71 const char* GetInputFile() const; 69 72 70 73 MCalibrationTestCam &GetTestCam() { return fTestCam; } … … 82 85 void SetNormalDisplay() { fDisplayType = kNormalDisplay; } 83 86 84 Bool_t Process(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam, 85 MCalibrationRelTimeCam &relcam,Byte_t filetype=1); 87 Bool_t Process(MPedestalCam &pedcam); 86 88 87 89 ClassDef(MJCalibTest, 0) // Tool to calibrate and test the calibration run itself
Note:
See TracChangeset
for help on using the changeset viewer.