Changeset 8292
- Timestamp:
- 02/03/07 14:10:52 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
r8245 r8292 104 104 #include "MLogManip.h" 105 105 106 #include "MEnv.h" 106 107 #include "MRunIter.h" 107 108 #include "MSequence.h" … … 110 111 #include "MEvtLoop.h" 111 112 113 #include "MHCamEvent.h" 112 114 #include "MHCamera.h" 113 115 #include "MGeomCam.h" … … 124 126 #include "MCalibrationPatternDecode.h" 125 127 #include "MCalibrationCam.h" 126 #include "MCalibrationHiLoCam.h"127 #include "MCalibrationHiLoPix.h"128 128 #include "MCalibrationQECam.h" 129 129 #include "MCalibrationQEPix.h" … … 186 186 const Int_t MJCalibration::gkThirdBlindPixelInstallation = 43308; 187 187 const TString MJCalibration::fgReferenceFile = "mjobs/calibrationref.rc"; 188 const TString MJCalibration::fgHiLoCalibFile = " mjobs/hilocalib_df46.root";188 const TString MJCalibration::fgHiLoCalibFile = "resources/hilocalib.rc"; 189 189 190 190 // -------------------------------------------------------------------------- … … 1473 1473 Bool_t MJCalibration::ReadHiLoCalibFile() 1474 1474 { 1475 1476 if (!fIsHiLoCalibration) 1475 if (!fIsHiLoCalibration) 1476 return kTRUE; 1477 1478 // We use the night time stamp to determine the period 1479 // because the night must be in the sequence file 1480 const MTime &night = fSequence.GetNight(); 1481 const Int_t period = night.GetMagicPeriod(); 1482 1483 // Open resource file 1484 MEnv env(fHiLoCalibFile); 1485 if (!env.IsValid()) 1486 { 1487 *fLog << err << "ERROR - Resource file " << fHiLoCalibFile; 1488 *fLog << " could not be opened... abort." << endl; 1489 return kFALSE; 1490 } 1491 1492 // Check for a valid entry for the correct period 1493 TString fname = env.GetValue(Form("%02d", period), ""); 1494 if (fname.IsNull()) 1495 { 1496 *fLog << err << "ERROR - No entry for period " << period; 1497 *fLog << " found in " << fHiLoCalibFile << "... looking for default." << endl; 1498 return kFALSE; 1499 /* 1500 *fLog << warn << "WARNING - No entry for period " << period; 1501 *fLog << " found in " << fHiLoCalibFile << "... looking for default." << endl; 1502 1503 fname = env.GetValue("00", ""); 1504 if (fname.IsNull()) 1505 { 1506 *fLog << err << "ERROR - No default entry (00) found in "; 1507 *fLog << fHiLoCalibFile << "... abort." << endl; 1508 return kFALSE; 1509 }*/ 1510 } 1511 1512 *fLog << inf << "Reading Hi-/Lo-Gain calibration constants from " << fname << endl; 1513 1514 // Open file with calibration constants 1515 TFile file(fname, "READ"); 1516 if (!file.IsOpen()) 1517 { 1518 *fLog << err << "ERROR - Couldn't open file " << fname << " for reading... abort." << endl; 1519 return kFALSE; 1520 } 1521 1522 // read calibration constants 1523 MHCamEvent hilocam; 1524 if (hilocam.Read()<=0) 1525 { 1526 *fLog << err << "ERROR - Unable to read MHCamEvent from " << fname << "... abort." << endl; 1527 return kFALSE; 1528 } 1529 1530 // Get histogram with constants 1531 MHCamera *hist = hilocam.GetHist(); 1532 if (!hist) 1533 { 1534 *fLog << err << "ERROR - MHCamEvent from " << fname << " empty... abort." << endl; 1535 return kFALSE; 1536 } 1537 1538 // Do some sanity stuff 1539 if (fCalibrationCam.GetSize() < 1) 1540 fCalibrationCam.InitSize(hist->GetNumPixels()); 1541 1542 if (fBadPixels.GetSize() < 1) 1543 fBadPixels.InitSize(hist->GetNumPixels()); 1544 1545 if ((UInt_t)fCalibrationCam.GetSize() != hist->GetNumPixels()) 1546 { 1547 *fLog << err << "ERROR - Size mismatch MHCamEvent and MCalibrationChargeCam.. abort." << endl; 1548 return kFALSE; 1549 } 1550 1551 // Copy the constants to their final location 1552 // FIXME: For what the hell do we need to have the constants in 1553 // in MCalibrationChargeCam? 1554 for (UInt_t i=0; i<hist->GetNumPixels(); i++) 1555 { 1556 hist->SetBit(MHCamera::kProfile); 1557 Double_t v = hist->GetBinContent(i); 1558 hist->SetBit(MHCamera::kErrorMean); 1559 Double_t e = hist->GetBinError(i); 1560 hist->ResetBit(MHCamera::kErrorMean); 1561 Double_t s = hist->GetBinError(i); 1562 1563 if (!hist->IsUsed(i)) 1564 { 1565 fBadPixels[i].SetUncalibrated(MBadPixelsPix::kConversionHiLoNotValid); 1566 v = e = s = -1; 1567 } 1568 1569 MCalibrationChargePix &cpix = (MCalibrationChargePix&)fCalibrationCam[i]; 1570 cpix.SetConversionHiLo(v); 1571 cpix.SetConversionHiLoErr(e); 1572 cpix.SetConversionHiLoSigma(s); 1573 } 1574 1477 1575 return kTRUE; 1478 1479 TFile file(fHiLoCalibFile,"READ");1480 if (!file.IsOpen())1481 {1482 *fLog << err << "ERROR - Couldn't open file " << fHiLoCalibFile << " for reading... abort." << endl;1483 return kFALSE;1484 }1485 1486 MCalibrationHiLoCam hilocam;1487 if (hilocam.Read()<=0)1488 {1489 *fLog << err << "Unable to read MCalibrationHiLoCam from " << fHiLoCalibFile << "... abort." << endl;1490 return kFALSE;1491 }1492 if (hilocam.GetSize() < 1)1493 {1494 *fLog << err << "MCalibationHiLoCam is un-initialized in file " << fHiLoCalibFile << "... abort." << endl;1495 return kFALSE;1496 }1497 1498 *fLog << all << "Hi-/Lo-Gain intercalibration constants read from " << fHiLoCalibFile << endl << endl;1499 1500 if (fCalibrationCam.GetSize() < 1)1501 fCalibrationCam.InitSize(hilocam.GetSize());1502 1503 if (fBadPixels.GetSize() < 1)1504 fBadPixels.InitSize(hilocam.GetSize());1505 1506 if (fCalibrationCam.GetSize() != hilocam.GetSize())1507 {1508 *fLog << err << "Size mismatch MCalibationHiLoCam and MCalibrationChargeCam.. abort." << endl;1509 return kFALSE;1510 }1511 1512 for (Int_t i=0;i<hilocam.GetSize();i++)1513 {1514 const MCalibrationHiLoPix &pix = (MCalibrationHiLoPix&)hilocam[i];1515 1516 const Float_t ratio = pix.GetHiLoChargeRatio();1517 const Float_t raterr = pix.GetHiLoChargeRatioErr();1518 const Float_t sigma = pix.GetHiLoChargeRatioSigma();1519 1520 if (ratio < 0.)1521 {1522 fBadPixels[i].SetUncalibrated(MBadPixelsPix::kConversionHiLoNotValid);1523 continue;1524 }1525 1526 MCalibrationChargePix &cpix = (MCalibrationChargePix&)fCalibrationCam[i];1527 1528 cpix.SetConversionHiLo(ratio);1529 cpix.SetConversionHiLoErr(raterr);1530 cpix.SetConversionHiLoSigma(sigma);1531 }1532 1533 return kTRUE;1534 1576 } 1535 1577
Note:
See TracChangeset
for help on using the changeset viewer.