Ignore:
Timestamp:
04/13/04 19:41:03 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r3709 r3723  
    2323!
    2424\* ======================================================================== */
    25 
    2625/////////////////////////////////////////////////////////////////////////////
    2726//
    2827//  MJCalibration
     28//
     29//  Do one calibration loop over serious of runs with the same pulser
     30//  colour and the same intensity. The following containers (rectangular) and
     31//  tasks (ellipses) are called to produce an MCalibrationChargeCam and to
     32//  update the MCalibrationQECam: (MCalibrate is not called from this class)
    2933//
    3034//Begin_Html
     
    3337*/
    3438//End_Html
     39//
     40// See also: MHCalibrationChargePix, MHCalibrationChargeCam, MHGausEvents
     41//           MHCalibrationChargeBlindPix, MHCalibrationChargePINDiode
     42//           MCalibrationChargePix, MCalibrationChargeCam, MCalibrationChargeCalc
     43//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode,
     44//           MCalibrationQECam, MBadPixelsPix, MBadPixelsCam
    3545//
    3646/////////////////////////////////////////////////////////////////////////////
     
    5666
    5767#include "MPedestalCam.h"
     68#include "MCalibrationQECam.h"
    5869#include "MCalibrationChargeCam.h"
    5970#include "MCalibrationChargePINDiode.h"
     
    8091using namespace std;
    8192
     93// --------------------------------------------------------------------------
     94//
     95// Default constructor.
     96//
     97// Sets fRuns to 0
     98//
    8299MJCalibration::MJCalibration(const char *name, const char *title) : fRuns(0)
    83100{
     
    86103}
    87104
     105// --------------------------------------------------------------------------
     106//
     107// Draw the MHCamera into the MStatusDisplay:
     108//
     109// 1) Draw it as histogram (MHCamera::DrawCopy("hist")
     110// 2) Draw it as a camera, with MHCamera::SetPrettyPalette() set.
     111// 3) If "rad" is not zero, draw its values vs. the radius from the camera center.
     112//    (DrawRadialProfile())
     113// 4) Depending on the variable "fit", draw the values projection on the y-axis
     114//    (DrawProjection()):
     115//    0: don't draw
     116//    1: Draw fit to Single Gauss (for distributions flat-fielded over the whole camera)
     117//    2: Draw and fit to Double Gauss (for distributions different for inner and outer pixels)
     118//    3: Draw and fit to Triple Gauss (for distributions with inner, outer pixels and outliers)
     119//    4: Draw and fit to Polynomial grade 0: (for the probability distributions)
     120//    >4: Draw and don;t fit.
     121//
     122void MJCalibration::CamDraw(TCanvas &c, const Int_t x, const Int_t y, const MHCamera &cam1,
     123                            const Int_t fit, const Int_t rad)
     124{
     125    c.cd(x);
     126    gPad->SetBorderMode(0);
     127    gPad->SetTicks();
     128    MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
     129    obj1->SetDirectory(NULL);
     130
     131    c.cd(x+y);
     132    gPad->SetBorderMode(0);
     133    obj1->SetPrettyPalette();
     134    obj1->AddNotify(&fCalibrationCam);
     135    obj1->Draw();
     136
     137    if (rad)
     138      {
     139        c.cd(x+2*y);
     140        gPad->SetBorderMode(0);
     141        gPad->SetTicks();
     142        DrawRadialProfile(obj1);
     143      }
     144   
     145
     146    if (!fit)
     147        return;
     148
     149    c.cd(rad ? x+3*y : x+2*y);
     150    gPad->SetBorderMode(0);
     151    gPad->SetTicks();
     152    DrawProjection(obj1, fit);
     153}
     154
     155// --------------------------------------------------------------------------
     156//
     157// Display the results in MStatusDisplay:
     158//
     159// - Add "Calibration" to the MStatusDisplay title
     160// - Retrieve the MGeomCam from MParList
     161// - Initialize the following MHCamera's:
     162//   1)  MCalibrationPix::GetMean()
     163//   2)  MCalibrationPix::Sigma()
     164//   3)  MCalibrationChargePix::GetRSigma()
     165//   4)  MCalibrationChargePix::GetRSigmaPerCharge()
     166//   5)  MCalibrationChargePix::GetPheFFactorMethod()
     167//   6)  MCalibrationChargePix::GetMeanConvFADC2Phe()
     168//   7)  MCalibrationChargePix::GetMeanFFactorFADC2Phot()
     169//   8)  MCalibrationQEPix::GetQECascadesFFactor()
     170//   9)  MCalibrationQEPix::GetQECascadesBlindPixel()
     171//   10) MCalibrationQEPix::GetQECascadesPINDiode()
     172//   11) MCalibrationQEPix::GetQECascadesCombined()
     173//   12) MCalibrationQEPix::IsAverageQEFFactorAvailable()
     174//   13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable()
     175//   14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable()
     176//   15) MCalibrationQEPix::IsAverageQECombinedAvailable()
     177//   16) MCalibrationChargePix::IsHiGainSaturation()
     178//   17) MCalibrationPix::GetHiLoMeansDivided()
     179//   18) MCalibrationPix::GetHiLoSigmasDivided()
     180//   19) MCalibrationChargePix::GetHiGainPickup()
     181//   20) MCalibrationChargePix::GetLoGainPickup()
     182//   21) MCalibrationChargePix::GetHiGainBlackout()
     183//   22) MCalibrationChargePix::GetLoGainBlackout()
     184//   23) MCalibrationPix::IsExcluded()
     185//   24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
     186//   25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
     187//   26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
     188//   27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
     189//   28) MCalibrationChargePix::GetAbsTimeMean()
     190//   29) MCalibrationChargePix::GetAbsTimeRms()
     191//
     192void MJCalibration::DisplayResult(MParList &plist)
     193{
     194    if (!fDisplay)
     195        return;
     196
     197    //
     198    // Update display
     199    //
     200    TString title = fDisplay->GetTitle();
     201    title += "--  Calibration ";
     202    title += fRuns->GetRunsAsString();
     203    title += "  --";
     204    fDisplay->SetTitle(title);
     205
     206    //
     207    // Get container from list
     208    //
     209    MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
     210
     211    // Create histograms to display
     212    MHCamera disp1 (geomcam, "Cal;Charge",            "Fitted Mean Charges");
     213    MHCamera disp2 (geomcam, "Cal;SigmaCharge",       "Sigma of Fitted Charges");
     214    MHCamera disp3 (geomcam, "Cal;RSigma",            "Reduced Sigmas");
     215    MHCamera disp4 (geomcam, "Cal;RSigma/Charge",     "Reduced Sigma per Charge");
     216    MHCamera disp5 (geomcam, "Cal;FFactorPhe",        "Nr. of Phe's (F-Factor Method)");
     217    MHCamera disp6 (geomcam, "Cal;FFactorConv",       "Conversion Factor (F-Factor Method)");
     218    MHCamera disp7 (geomcam, "Cal;FFactorFFactor",    "Total F-Factor (F-Factor Method)");
     219    MHCamera disp8 (geomcam, "Cal;CascadesQEFFactor", "Cascades QE (F-Factor Method)");
     220    MHCamera disp9 (geomcam, "Cal;CascadesQEBlindPix","Cascades QE (Blind Pixel Method)");
     221    MHCamera disp10(geomcam, "Cal;CascadesQEPINDiode","Cascades QE (PIN Diode Method)");
     222    MHCamera disp11(geomcam, "Cal;CascadesQECombined","Cascades QE (Combined Method)");
     223    MHCamera disp12(geomcam, "Cal;FFactorValid",      "Pixels with valid F-Factor calibration");
     224    MHCamera disp13(geomcam, "Cal;BlindPixelValid",   "Pixels with valid BlindPixel calibration");
     225    MHCamera disp14(geomcam, "Cal;PINdiodeValid",     "Pixels with valid PINDiode calibration");
     226    MHCamera disp15(geomcam, "Cal;CombinedValid",     "Pixels with valid Combined calibration");
     227    MHCamera disp16(geomcam, "Cal;Saturation",        "Pixels with saturated Hi Gain");
     228    MHCamera disp17(geomcam, "Cal;ConversionMeans",   "Conversion HiGain.vs.LoGain Means");
     229    MHCamera disp18(geomcam, "Cal;ConversionSigmas",  "Conversion HiGain.vs.LoGain Sigmas");
     230    MHCamera disp19(geomcam, "Cal;HiGainPickup",      "Number Pickup events Hi Gain");
     231    MHCamera disp20(geomcam, "Cal;LoGainPickup",      "Number Pickup events Lo Gain");
     232    MHCamera disp21(geomcam, "Cal;HiGainBlackout",    "Number Blackout events Hi Gain");
     233    MHCamera disp22(geomcam, "Cal;LoGainBlackout",    "Number Blackout events Lo Gain");
     234    MHCamera disp23(geomcam, "Cal;Excluded",          "Pixels previously excluded");
     235    MHCamera disp24(geomcam, "Bad;UnSuitable",        "Pixels not suited for further analysis");
     236    MHCamera disp25(geomcam, "Bad;UnReliable",        "Pixels not reliable for further analysis");
     237    MHCamera disp26(geomcam, "Bad;HiGainOscillating", "Oscillating Pixels High Gain");
     238    MHCamera disp27(geomcam, "Bad;LoGainOscillating", "Oscillating Pixels Low Gain");
     239    MHCamera disp28(geomcam, "Cal;AbsTimeMean",       "Abs. Arrival Times");
     240    MHCamera disp29(geomcam, "Cal;AbsTimeRms",        "RMS of Arrival Times");
     241
     242    // Fitted charge means and sigmas
     243    disp1.SetCamContent(fCalibrationCam,  0);
     244    disp1.SetCamError(  fCalibrationCam,  1);
     245    disp2.SetCamContent(fCalibrationCam,  2);
     246    disp2.SetCamError(  fCalibrationCam,  3);
     247
     248    // Reduced Sigmas and reduced sigmas per charge
     249    disp3.SetCamContent(fCalibrationCam,  5);
     250    disp3.SetCamError(  fCalibrationCam,  6);
     251    disp4.SetCamContent(fCalibrationCam,  7);
     252    disp4.SetCamError(  fCalibrationCam,  8);
     253
     254    // F-Factor Method
     255    disp5.SetCamContent(fCalibrationCam,  9);
     256    disp5.SetCamError(  fCalibrationCam, 10);
     257    disp6.SetCamContent(fCalibrationCam, 11);
     258    disp6.SetCamError(  fCalibrationCam, 12);
     259    disp7.SetCamContent(fCalibrationCam, 13);
     260    disp7.SetCamError(  fCalibrationCam, 14);
     261
     262    // Quantum Efficiencies
     263    disp8.SetCamContent (fQECam, 0 );
     264    disp8.SetCamError   (fQECam, 1 );
     265    disp9.SetCamContent (fQECam, 2 );
     266    disp9.SetCamError   (fQECam, 3 );
     267    disp10.SetCamContent(fQECam, 4 );
     268    disp10.SetCamError  (fQECam, 5 );
     269    disp11.SetCamContent(fQECam, 6 );
     270    disp11.SetCamError  (fQECam, 7 );
     271
     272    // Valid flags
     273    disp12.SetCamContent(fQECam, 8 );
     274    disp13.SetCamContent(fQECam, 9 );
     275    disp14.SetCamContent(fQECam, 10);
     276    disp15.SetCamContent(fQECam, 11);
     277
     278    // Conversion Hi-Lo
     279    disp16.SetCamContent(fCalibrationCam, 25);
     280    disp17.SetCamContent(fCalibrationCam, 16);
     281    disp17.SetCamError  (fCalibrationCam, 17);
     282    disp18.SetCamContent(fCalibrationCam, 18);
     283    disp18.SetCamError  (fCalibrationCam, 19);
     284
     285    // Pickup and Blackout
     286    disp19.SetCamContent(fCalibrationCam, 21);
     287    disp20.SetCamContent(fCalibrationCam, 22);
     288    disp21.SetCamContent(fCalibrationCam, 23);
     289    disp22.SetCamContent(fCalibrationCam, 24);
     290
     291    // Pixels with defects
     292    disp23.SetCamContent(fCalibrationCam, 20);
     293    disp24.SetCamContent(fBadPixels, 1);
     294    disp25.SetCamContent(fBadPixels, 3);
     295
     296    // Oscillations
     297    disp26.SetCamContent(fBadPixels, 10);
     298    disp27.SetCamContent(fBadPixels, 11);
     299
     300    // Arrival Times
     301    disp28.SetCamContent(fCalibrationCam, 26);
     302    disp28.SetCamError(  fCalibrationCam, 27);
     303    disp29.SetCamContent(fCalibrationCam, 27);
     304
     305    disp1.SetYTitle("Q [FADC counts]");
     306    disp2.SetYTitle("\\sigma_{Q} [FADC counts]");
     307
     308    disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
     309    disp4.SetYTitle("Red.Sigma/<Q> [1]");
     310
     311    disp5.SetYTitle("Nr. Phe's [1]");
     312    disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
     313    disp7.SetYTitle("Total F-Factor [1]");
     314
     315    disp8.SetYTitle("QE [1]");
     316    disp9.SetYTitle("QE [1]");
     317    disp10.SetYTitle("QE [1]");
     318    disp11.SetYTitle("QE [1]");
     319
     320    disp12.SetYTitle("[1]");
     321    disp13.SetYTitle("[1]");
     322    disp14.SetYTitle("[1]");
     323    disp15.SetYTitle("[1]");
     324    disp16.SetYTitle("[1]");
     325
     326    disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]");
     327    disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]");
     328
     329    disp19.SetYTitle("[1]");
     330    disp20.SetYTitle("[1]");
     331    disp21.SetYTitle("[1]");
     332    disp22.SetYTitle("[1]");
     333    disp23.SetYTitle("[1]");
     334    disp24.SetYTitle("[1]");
     335    disp25.SetYTitle("[1]");
     336    disp26.SetYTitle("[1]");
     337    disp27.SetYTitle("[1]");
     338
     339    disp28.SetYTitle("Mean Abs. Time [FADC slice]");
     340    disp29.SetYTitle("RMS Abs. Time [FADC slices]");
     341
     342    gStyle->SetOptStat(1111);
     343    gStyle->SetOptFit();
     344
     345    // Charges
     346    TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
     347    c1.Divide(2, 4);
     348
     349    CamDraw(c1, 1, 2, disp1, 2, 1);
     350    CamDraw(c1, 2, 2, disp2, 2, 1);
     351
     352    // Reduced Sigmas
     353    TCanvas &c3 = fDisplay->AddTab("Red.Sigma");
     354    c3.Divide(2,4);
     355
     356    CamDraw(c3, 1, 2, disp3, 2, 1);
     357    CamDraw(c3, 2, 2, disp4, 2, 1);
     358
     359    //  F-Factor
     360    TCanvas &c4 = fDisplay->AddTab("Phe's");
     361    c4.Divide(3,4);
     362
     363    CamDraw(c4, 1, 3, disp5, 2, 1);
     364    CamDraw(c4, 2, 3, disp6, 2, 1);
     365    CamDraw(c4, 3, 3, disp7, 2, 1);
     366
     367    // QE's
     368    TCanvas &c5 = fDisplay->AddTab("QE's");
     369    c5.Divide(4,4);
     370
     371    CamDraw(c5, 1, 4, disp8,  2, 1);
     372    CamDraw(c5, 2, 4, disp9,  2, 1);
     373    CamDraw(c5, 3, 4, disp10, 2, 1);
     374    CamDraw(c5, 4, 4, disp11, 2, 1);
     375
     376    // Validity
     377    TCanvas &c6 = fDisplay->AddTab("Valid");
     378    c6.Divide(4,2);
     379
     380    CamDraw(c6, 1, 4, disp12, 0);
     381    CamDraw(c6, 2, 4, disp13, 0);
     382    CamDraw(c6, 3, 4, disp14, 0);
     383    CamDraw(c6, 4, 4, disp15, 0);
     384
     385    // Other info
     386    TCanvas &c7 = fDisplay->AddTab("HiLoGain");
     387    c7.Divide(3,3);
     388
     389    CamDraw(c7, 1, 3, disp16, 0);
     390    CamDraw(c7, 2, 3, disp17, 1);
     391    CamDraw(c7, 3, 3, disp18, 1);
     392
     393    // Pickup
     394    TCanvas &c8 = fDisplay->AddTab("Pickup");
     395    c8.Divide(4,2);
     396
     397    CamDraw(c8, 1, 4, disp19, 0);
     398    CamDraw(c8, 2, 4, disp20, 0);
     399    CamDraw(c8, 3, 4, disp21, 0);
     400    CamDraw(c8, 4, 4, disp22, 0);
     401
     402    // Defects
     403    TCanvas &c9 = fDisplay->AddTab("Defect");
     404    c9.Divide(5,2);
     405
     406    CamDraw(c9, 1, 5, disp23, 0);
     407    CamDraw(c9, 2, 5, disp24, 0);
     408    CamDraw(c9, 3, 5, disp25, 0);
     409    CamDraw(c9, 4, 5, disp26, 0);
     410    CamDraw(c9, 5, 5, disp27, 0);
     411
     412    // Abs. Times
     413    TCanvas &c10 = fDisplay->AddTab("Abs. Times");
     414    c10.Divide(2,3);
     415   
     416    CamDraw(c10, 1, 2, disp28, 2);
     417    CamDraw(c10, 2, 2, disp29, 1);
     418
     419}
     420
     421// --------------------------------------------------------------------------
     422//
     423// Draw a projection of MHCamera onto the y-axis values. Depending on the
     424// variable fit, the following fits are performed:
     425//
     426// 1: Single Gauss (for distributions flat-fielded over the whole camera)
     427// 2: Double Gauss (for distributions different for inner and outer pixels)
     428// 3: Triple Gauss (for distributions with inner, outer pixels and outliers)
     429// 4: flat         (for the probability distributions)
     430//
     431// Moreover, sectors 6,1 and 2 of the camera and sectors 3,4 and 5 are
     432// drawn separately, for inner and outer pixels.
     433//
    88434void MJCalibration::DrawProjection(MHCamera *obj, Int_t fit) const
    89435{
     
    215561}
    216562
     563// --------------------------------------------------------------------------
     564//
     565// Draw a projection of MHCamera vs. the radius from the central pixel.
     566//
     567// The inner and outer pixels are drawn separately, both fitted by a polynomial
     568// of grade 1.
     569//
    217570void MJCalibration::DrawRadialProfile(MHCamera *obj) const
    218571{
     
    262615
    263616
    264 void MJCalibration::CamDraw(TCanvas &c, const Int_t x, const Int_t y, const MHCamera &cam1,
    265                             const Int_t fit, const Int_t rad)
    266 {
    267     c.cd(x);
    268     gPad->SetBorderMode(0);
    269     gPad->SetTicks();
    270     MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
    271     obj1->SetDirectory(NULL);
    272 
    273     c.cd(x+y);
    274     gPad->SetBorderMode(0);
    275     obj1->SetPrettyPalette();
    276     obj1->AddNotify(&fCalibrationCam);
    277     obj1->Draw();
    278 
    279     if (rad)
    280       {
    281         c.cd(x+2*y);
    282         gPad->SetBorderMode(0);
    283         gPad->SetTicks();
    284         DrawRadialProfile(obj1);
    285       }
    286    
    287 
    288     if (!fit)
    289         return;
    290 
    291     c.cd(rad ? x+3*y : x+2*y);
    292     gPad->SetBorderMode(0);
    293     gPad->SetTicks();
    294     DrawProjection(obj1, fit);
    295 }
    296 
    297 
    298 void MJCalibration::DisplayResult(MParList &plist)
    299 {
    300     if (!fDisplay)
    301         return;
    302 
    303     //
    304     // Update display
    305     //
    306     TString title = fDisplay->GetTitle();
    307     title += "--  Calibration ";
    308     title += fRuns->GetRunsAsString();
    309     title += "  --";
    310     fDisplay->SetTitle(title);
    311 
    312     //
    313     // Get container from list
    314     //
    315     MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
    316 
    317     // Create histograms to display
    318     MHCamera disp1 (geomcam, "Cal;Charge",         "Fitted Mean Charges");
    319     MHCamera disp2 (geomcam, "Cal;SigmaCharge",    "Sigma of Fitted Charges");
    320     MHCamera disp3 (geomcam, "Cal;RSigma",         "Reduced Sigmas");
    321     MHCamera disp4 (geomcam, "Cal;RSigma/Charge",  "Reduced Sigma per Charge");
    322     MHCamera disp5 (geomcam, "Cal;FFactorPhe",     "Nr. of Phe's (F-Factor Method)");
    323     MHCamera disp6 (geomcam, "Cal;FFactorConv",    "Conversion Factor (F-Factor Method)");
    324     MHCamera disp7 (geomcam, "Cal;BlindPixConv",   "Conversion Factor (Blind Pixel Method)");
    325     MHCamera disp8 (geomcam, "Cal;PINDiodeConv",   "Conversion Factor (PIN Diode Method)");
    326     MHCamera disp9 (geomcam, "Cal;FFactorValid",   "Pixels with valid F-Factor calibration");
    327     MHCamera disp10(geomcam, "Cal;BlindPixelValid","Pixels with valid BlindPixel calibration");
    328     MHCamera disp11(geomcam, "Cal;PINdiodeValid",  "Pixels with valid PINDiode calibration");
    329     MHCamera disp12(geomcam, "Cal;Excluded",       "Pixels previously excluded");
    330     MHCamera disp13(geomcam, "Cal;Saturation",     "Pixels with saturated Hi Gain");
    331     MHCamera disp14(geomcam, "Cal;HiGainPickup",   "Number Pickup events Hi Gain");
    332     MHCamera disp15(geomcam, "Cal;LoGainPickup",   "Number Pickup events Lo Gain");
    333     MHCamera disp16(geomcam, "Bad;UnSuitable",     "Pixels not suited for further analysis");
    334     MHCamera disp17(geomcam, "Bad;UnReliable",     "Pixels not reliable for further analysis");
    335     MHCamera disp18(geomcam, "Bad;Oscillation",    "Oscillating Pixels");
    336     MHCamera disp19(geomcam, "Cal;AbsTimeMean",    "Abs. Arrival Times");
    337     MHCamera disp20(geomcam, "Cal;AbsTimeRms",     "RMS of Arrival Times");
    338 
    339     // Fitted charge means and sigmas
    340     disp1.SetCamContent(fCalibrationCam,  0);
    341     disp1.SetCamError(  fCalibrationCam,  1);
    342     disp2.SetCamContent(fCalibrationCam,  2);
    343     disp2.SetCamError(  fCalibrationCam,  3);
    344 
    345     // Reduced Sigmas and reduced sigmas per charge
    346     disp3.SetCamContent(fCalibrationCam,  5);
    347     disp3.SetCamError(  fCalibrationCam,  6);
    348     disp4.SetCamContent(fCalibrationCam,  7);
    349     disp4.SetCamError(  fCalibrationCam,  8);
    350 
    351     // Conversion Factors, Methods
    352     disp5.SetCamContent(fCalibrationCam,  9);
    353     disp5.SetCamError(  fCalibrationCam, 10);
    354     disp6.SetCamContent(fCalibrationCam, 11);
    355     disp6.SetCamError(  fCalibrationCam, 12);
    356     disp7.SetCamContent(fCalibrationCam, 13);
    357     disp7.SetCamError(  fCalibrationCam, 14);
    358     disp8.SetCamContent(fCalibrationCam, 16);
    359     disp8.SetCamError(  fCalibrationCam, 17);
    360 
    361     // Valid flags
    362     disp9.SetCamContent (fCalibrationCam, 15);
    363     disp10.SetCamContent(fCalibrationCam, 20);
    364     disp11.SetCamContent(fCalibrationCam, 25);
    365 
    366     // Pixels behavior
    367     disp12.SetCamContent(fCalibrationCam, 26);
    368     disp13.SetCamContent(fCalibrationCam, 29);
    369     disp14.SetCamContent(fCalibrationCam, 27);
    370     disp15.SetCamContent(fCalibrationCam, 28);
    371 
    372     // Pixels with defects
    373     disp16.SetCamContent(fBadPixels, 1);
    374     disp17.SetCamContent(fBadPixels, 3);
    375     disp18.SetCamContent(fBadPixels, 8);
    376 
    377     // Arrival Times
    378     disp19.SetCamContent(fCalibrationCam, 34);
    379     disp19.SetCamError(  fCalibrationCam, 35);
    380     disp20.SetCamContent(fCalibrationCam, 35);
    381 
    382     disp1.SetYTitle("Q [FADC units]");
    383     disp2.SetYTitle("\\sigma_{Q} [FADC units]");
    384 
    385     disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
    386     disp4.SetYTitle("Red.Sigma/<Q> [1]");
    387 
    388     disp5.SetYTitle("PhE [#]");
    389     disp6.SetYTitle("Conv.Factor [PhE/FADC units]");
    390 
    391     disp7.SetYTitle("Conv.Factor [Phot/FADC Count]");
    392     disp8.SetYTitle("Conv.Factor [Phot/FADC Count]");
    393 
    394     disp9.SetYTitle("[1]");
    395     disp10.SetYTitle("[1]");
    396     disp11.SetYTitle("[1]");
    397     disp12.SetYTitle("[1]");
    398     disp13.SetYTitle("[1]");
    399     disp14.SetYTitle("[1]");
    400     disp15.SetYTitle("[1]");
    401     disp16.SetYTitle("[1]");
    402     disp17.SetYTitle("[1]");
    403     disp18.SetYTitle("[1]");
    404     disp19.SetYTitle("Mean Abs. Time [FADC slice]");
    405     disp20.SetYTitle("RMS Abs. Time [FADC slices]");
    406 
    407     gStyle->SetOptStat(1111);
    408     gStyle->SetOptFit();
    409 
    410     // Charges
    411     TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
    412     c1.Divide(2, 4);
    413 
    414     CamDraw(c1, 1, 2, disp1, 2, 1);
    415     CamDraw(c1, 2, 2, disp2, 2, 1);
    416 
    417     // Reduced Sigmas
    418     TCanvas &c3 = fDisplay->AddTab("Red.Sigma");
    419     c3.Divide(2,4);
    420 
    421     CamDraw(c3, 1, 2, disp3, 2, 1);
    422     CamDraw(c3, 2, 2, disp4, 2, 1);
    423 
    424     //  Methods
    425     TCanvas &c4 = fDisplay->AddTab("Methods");
    426     c4.Divide(4,4);
    427 
    428     CamDraw(c4, 1, 4, disp5, 2, 1);
    429     CamDraw(c4, 2, 4, disp6, 2, 1);
    430     CamDraw(c4, 3, 4, disp7, 2, 1);
    431     CamDraw(c4, 4, 4, disp8, 2, 1);
    432 
    433     // Validity
    434     TCanvas &c5 = fDisplay->AddTab("Validity");
    435     c5.Divide(3,2);
    436 
    437     CamDraw(c5, 1, 3, disp9 , 0);
    438     CamDraw(c5, 2, 3, disp10, 0);
    439     CamDraw(c5, 3, 3, disp11, 0);
    440 
    441     // Other info
    442     TCanvas &c6 = fDisplay->AddTab("Behavior");
    443     c6.Divide(4,2);
    444 
    445     CamDraw(c6, 1, 4, disp12, 0);
    446     CamDraw(c6, 2, 4, disp13, 0);
    447     CamDraw(c6, 3, 4, disp14, 0);
    448     CamDraw(c6, 4, 4, disp15, 0);
    449 
    450     // Defects
    451     TCanvas &c7 = fDisplay->AddTab("Defects");
    452     c7.Divide(3,2);
    453 
    454     CamDraw(c7, 1, 3, disp16, 0);
    455     CamDraw(c7, 2, 3, disp17, 0);
    456     CamDraw(c7, 3, 3, disp18, 0);
    457 
    458     // Abs. Times
    459     TCanvas &c8 = fDisplay->AddTab("Abs. Times");
    460     c8.Divide(2,3);
    461    
    462     CamDraw(c8, 1, 2, disp19, 2);
    463     CamDraw(c8, 2, 2, disp20, 1);
    464 
    465 }
    466 
    467 Bool_t MJCalibration::WriteResult()
    468 {
    469     if (fOutputPath.IsNull())
    470         return kTRUE;
    471 
    472     const TString oname(GetOutputFile());
    473 
    474     *fLog << inf << "Writing to file: " << oname << endl;
    475 
    476     TFile file(oname, "UPDATE");
    477 
    478     if (fDisplay && fDisplay->Write()<=0)
    479     {
    480         *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
    481         return kFALSE;
    482     }
    483 
    484     if (fCalibrationCam.Write()<=0)
    485     {
    486         *fLog << err << "Unable to write MCalibrationCam to " << oname << endl;
    487         return kFALSE;
    488     }
    489 
    490     if (fBadPixels.Write()<=0)
    491     {
    492         *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
    493         return kFALSE;
    494     }
    495 
    496     return kTRUE;
    497 
    498 }
    499 
    500 void MJCalibration::SetOutputPath(const char *path)
    501 {
    502     fOutputPath = path;
    503     if (fOutputPath.EndsWith("/"))
    504         fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
    505 }
    506 
     617// --------------------------------------------------------------------------
     618//
     619// Retrieve the output file written by WriteResult()
     620//
     621TString MJCalibration::GetOutputFile() const
     622{
     623    if (!fRuns)
     624        return "";
     625
     626    return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
     627}
     628
     629
     630// --------------------------------------------------------------------------
     631//
     632// Call the ProcessFile(MPedestalCam)
     633//
    507634Bool_t MJCalibration::Process(MPedestalCam &pedcam)
    508635{
     
    513640}
    514641
    515 TString MJCalibration::GetOutputFile() const
     642// --------------------------------------------------------------------------
     643//
     644// Execute the task list and the eventloop:
     645//
     646// - Check if there are fRuns, otherwise return
     647// - Check for consistency between run numbers and number of files
     648// - Add fRuns to MReadMarsFile
     649// - Put into MParList:
     650//   1) MPedestalCam          (pedcam)
     651//   2) MCalibrationQECam     (fQECam)
     652//   3) MCalibrationChargeCam (fCalibrationCam)
     653//   4) MBadPixelsCam         (fBadPixels)
     654//   5) MCalibrationChargePINDiode
     655//   6) MCalibrationChargeBlindPix
     656// - Put into the MTaskList:
     657//   1)  MReadMarsFile
     658//   2)  MBadPixelsMerge
     659//   3)  MGeomApply
     660//   4)  MExtractSignal2
     661//   5)  MExtractPINDiode
     662//   6)  MExtractBlindPixel
     663//   7)  MContinue(MFCosmics)
     664//   8)  MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode")
     665//   9)  MFillH("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel")
     666//   10) MFillH("MHCalibrationChargeCam",      "MExtractedSignalCam")
     667//   11) MCalibrationChargeCalc
     668// - Execute MEvtLoop
     669// - DisplayResult()
     670// - WriteResult()
     671//
     672Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
    516673{
    517674    if (!fRuns)
    518         return "";
    519 
    520     return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
    521 }
    522 
    523 Bool_t MJCalibration::ReadCalibrationCam()
    524 {
    525     const TString fname = GetOutputFile();
    526 
    527     if (gSystem->AccessPathName(fname, kFileExists))
    528     {
    529         *fLog << err << "Input file " << fname << " doesn't exist." << endl;
    530         return kFALSE;
    531     }
    532 
    533     *fLog << inf << "Reading from file: " << fname << endl;
    534 
    535     TFile file(fname, "READ");
    536     if (fCalibrationCam.Read()<=0)
    537     {
    538         *fLog << err << "Unable to read MCalibrationCam from " << fname << endl;
    539         return kFALSE;
    540     }
    541 
    542     if (file.FindKey("MBadPixelsCam"))
    543     {
    544         MBadPixelsCam bad;
    545         if (bad.Read()<=0)
    546         {
    547             *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
    548             return kFALSE;
    549         }
    550         fBadPixels.Merge(bad);
    551     }
    552 
    553     if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
    554         fDisplay->Read();
    555 
    556     return kTRUE;
    557 }
    558 
    559 
    560 Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
    561 {
    562     if (!fRuns)
    563675    {
    564676        *fLog << err << "No Runs choosen... abort." << endl;
    565677        return kFALSE;
    566678    }
     679
    567680    if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
    568681    {
     
    590703    MParList plist;
    591704    plist.AddToList(&pedcam);
     705    plist.AddToList(&fBadPixels);
     706    plist.AddToList(&fQECam);
    592707    plist.AddToList(&fCalibrationCam);
    593     plist.AddToList(&fBadPixels);
    594708    plist.AddToList(&pindiode);
    595709    plist.AddToList(&blindpix);
     
    599713
    600714    MGeomApply               apply;
    601     MBadPixelsMerge          merge(&fBadPixels);
     715    //    MBadPixelsMerge          merge(&fBadPixels);
    602716    MExtractPINDiode         pinext;
    603717    MExtractBlindPixel       blindext;
     
    622736    MContinue cont(&cosmics);
    623737
    624     //calcalc.SkipBlindPixelFit();
    625 
    626738    tlist.AddToList(&read);
    627     tlist.AddToList(&merge);
     739    //    tlist.AddToList(&merge);
    628740    tlist.AddToList(&apply);
    629741    tlist.AddToList(&extract);
     
    660772    return kTRUE;
    661773}
     774
     775// --------------------------------------------------------------------------
     776//
     777// Read the following containers from GetOutputFile()
     778// - MCalibrationChargeCam
     779// - MCalibrationQECam
     780// - MBadPixelsCam
     781//
     782Bool_t MJCalibration::ReadCalibrationCam()
     783{
     784    const TString fname = GetOutputFile();
     785
     786    if (gSystem->AccessPathName(fname, kFileExists))
     787    {
     788        *fLog << err << "Input file " << fname << " doesn't exist." << endl;
     789        return kFALSE;
     790    }
     791
     792    *fLog << inf << "Reading from file: " << fname << endl;
     793
     794    TFile file(fname, "READ");
     795    if (fCalibrationCam.Read()<=0)
     796    {
     797        *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
     798        return kFALSE;
     799    }
     800
     801    if (fQECam.Read()<=0)
     802    {
     803        *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
     804        return kFALSE;
     805    }
     806
     807    if (file.FindKey("MBadPixelsCam"))
     808    {
     809        MBadPixelsCam bad;
     810        if (bad.Read()<=0)
     811        {
     812            *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
     813            return kFALSE;
     814        }
     815        fBadPixels.Merge(bad);
     816    }
     817
     818    if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
     819        fDisplay->Read();
     820
     821    return kTRUE;
     822}
     823
     824
     825// --------------------------------------------------------------------------
     826//
     827// Set the path for output files, written by WriteResult()
     828//
     829void MJCalibration::SetOutputPath(const char *path)
     830{
     831    fOutputPath = path;
     832    if (fOutputPath.EndsWith("/"))
     833        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
     834}
     835
     836
     837// --------------------------------------------------------------------------
     838//
     839// Write the result into the output file GetOutputFile(), if fOutputPath exists.
     840//
     841// The following containers are written:
     842// - MStatusDisplay
     843// - MCalibrationChargeCam
     844// - MCalibrationQECam
     845// - MBadPixelsCam
     846//
     847Bool_t MJCalibration::WriteResult()
     848{
     849    if (fOutputPath.IsNull())
     850        return kTRUE;
     851
     852    const TString oname(GetOutputFile());
     853
     854    *fLog << inf << "Writing to file: " << oname << endl;
     855
     856    TFile file(oname, "UPDATE");
     857
     858    if (fDisplay && fDisplay->Write()<=0)
     859    {
     860        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
     861        return kFALSE;
     862    }
     863
     864    if (fCalibrationCam.Write()<=0)
     865    {
     866        *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
     867        return kFALSE;
     868    }
     869
     870    if (fQECam.Write()<=0)
     871    {
     872        *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
     873        return kFALSE;
     874    }
     875
     876    if (fBadPixels.Write()<=0)
     877    {
     878        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
     879        return kFALSE;
     880    }
     881
     882    return kTRUE;
     883
     884}
     885
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.h

    r3709 r3723  
    5858  Bool_t Process    ( MPedestalCam &pedcam );
    5959 
    60   ClassDef(MJCalibration, 0) // Tool to create a calibration file (MCalibrationCam)
     60  ClassDef(MJCalibration, 0) // Tool to run a calibration per pulser colour and intensity
    6161};
    6262
Note: See TracChangeset for help on using the changeset viewer.