Ignore:
Timestamp:
08/12/04 21:36:20 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.h

    r4599 r4603  
    5252  MCerPhotEvt           *fCerPhotEvt;       // Cerenkov Photon Event used for calculation
    5353 
    54   UShort_t fCalibrationMode;
     54  UShort_t fCalibrationMode;                // Flag defining the calibration mode (CalibrationMode_t)
    5555  Byte_t   fPedestalFlag;                   // Flags defining to calibrate the pedestal each event or each run
    5656 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r4542 r4603  
    231231const Float_t MCalibrationChargeCalc::fgLambdaErrLimit         = 0.2;
    232232const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.5;
    233 const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 3.5;
     233const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 4.5;
    234234const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
    235235// --------------------------------------------------------------------------
     
    582582    return kFALSE;
    583583
     584  *fLog << endl;
     585
    584586  if (fPINDiode)
    585587    if (!fPINDiode->IsValid())
     
    606608      }
    607609 
     610  *fLog << endl;
    608611  //
    609612  // First loop over pixels, call FinalizePedestals and FinalizeCharges
     
    627630      FinalizePedestals(ped,pix,aidx);
    628631
    629       if (FinalizeCharges(pix,bad))
     632      if (FinalizeCharges(pix,bad,"pixel  "))
    630633        nvalid++;
    631634    }
    632  
     635
     636  *fLog << endl; 
    633637  //
    634638  // The Michele check ...
     
    651655
    652656      FinalizePedestals(ped,pix,aidx);
    653       FinalizeCharges(pix, fCam->GetAverageBadArea(aidx));
    654     }
    655  
     657      FinalizeCharges(pix, fCam->GetAverageBadArea(aidx),"area id");
     658    }
     659 
     660  *fLog << endl;
     661
    656662  for (UInt_t sector=0; sector<fGeom->GetNumSectors(); sector++)
    657663    {
     
    661667      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
    662668      FinalizePedestals(ped,pix, 0);
    663       FinalizeCharges(pix, fCam->GetAverageBadSector(sector));
    664     }
    665  
     669    }
     670 
     671  *fLog << endl;
     672
    666673  //
    667674  // Finalize Bad Pixels
     
    681688    fCam->SetFFactorMethodValid(kTRUE);
    682689 
     690  *fLog << endl;
    683691  //
    684692  // Finalize Blind Pixel
     
    821829//       if not succesful.
    822830//
    823 Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
     831Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what)
    824832{
    825833
     
    829837  if (cal.GetMean() < fChargeLimit*cal.GetPedRms())
    830838    {
    831       *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
    832             << fChargeLimit << " Pedestal RMS: " <<  cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
     839      *fLog << warn << GetDescriptor()
     840            << Form(": Fitted Charge: %5.2f is smaller than %2.1f",cal.GetMean(),fChargeLimit)
     841            << Form("   Pedestal RMS: %5.2f in %s%4i",cal.GetPedRms(),what,cal.GetPixId()) << endl;
    833842      bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
    834843    }
     
    836845   if (cal.GetMean() < fChargeRelErrLimit*cal.GetMeanErr())
    837846    {
    838       *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
    839             << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr()
    840             << " in Pixel  " << cal.GetPixId() << endl;
     847      *fLog << warn << GetDescriptor()
     848            << Form(": Fitted Charge: %4.2f is smaller than %2.1f",cal.GetMean(),fChargeRelErrLimit)
     849            << Form(" times its error: %4.2f in %s%4i",cal.GetMeanErr(),what,cal.GetPixId()) << endl;
    841850      bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
    842851    }
     
    844853  if (cal.GetSigma() < cal.GetPedRms())
    845854    {
    846       *fLog << warn << GetDescriptor() << ": Sigma of Fitted Charge: " << cal.GetSigma()
    847             << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
     855      *fLog << warn << GetDescriptor()
     856            << Form(": Sigma of Fitted Charge: %6.2f is smaller than",cal.GetSigma())
     857            << Form(" Ped. RMS: %5.2f in %s%4i",cal.GetPedRms(),what,cal.GetPixId()) << endl;
    848858      bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
    849859    }
     
    852862    {
    853863      *fLog << warn << GetDescriptor()
    854             << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
     864            << Form(": Could not calculate the reduced sigma in %s:               ",what)
     865            << Form("         %4i",cal.GetPixId())
     866            << endl;
    855867      bad.SetUncalibrated(MBadPixelsPix::kChargeIsPedestal);
    856868      return kFALSE;
     
    860872    {
    861873      *fLog << warn << GetDescriptor()
    862             << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
     874            << Form(": Could not calculate the F-Factor in %s:                    ",what)
     875            << Form("         %4i",cal.GetPixId())
     876            << endl;
    863877      bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
    864878      return kFALSE;
     
    10081022        }
    10091023
    1010       areavars[i] = (areavars[i] - areaphes[i]*areaphes[i]/numareavalid[i]) / (numareavalid[i]-1.);
    1011       areaphes[i] = areaphes[i] / numareavalid[i];
    1012 
     1024      if (numareavalid[i] == 1)
     1025        areavars[i] = 0.;
     1026      else if (numareavalid[i] == 0)
     1027        {
     1028          areaphes[i]    = -1.;
     1029          areaweights[i] = -1.;
     1030        }
     1031      else
     1032        {
     1033          areavars[i] = (areavars[i] - areaphes[i]*areaphes[i]/numareavalid[i]) / (numareavalid[i]-1);
     1034          areaphes[i] = areaphes[i] / numareavalid[i];
     1035        }
     1036     
    10131037      if (areavars[i] < 0.)
    10141038        {
     
    10291053      const Float_t sigma = hist->GetFunction("gaus")->GetParameter(2);
    10301054      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
     1055
     1056      if (IsDebug())
     1057        camphes.DrawClone();
    10311058
    10321059      if (ndf < 2)
     
    10531080        }
    10541081     
    1055       *fLog << inf << endl;
    1056       *fLog << inf << GetDescriptor() << ": Mean Number of photo-electrons "
    1057             << "in the camera with area index: " << i << ": "
    1058             << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
    1059       *fLog << inf << endl;
     1082      *fLog << inf << GetDescriptor() << ": Mean number of photo-electrons "
     1083            << "with area idx " << i << ": "
     1084            << Form("%7.2f+-%6.2f",mean,sigma) << endl;
    10601085
    10611086      lowlim  [i] = mean  - fPheErrLimit*sigma;
     
    10641089      delete hist;
    10651090    }
     1091
     1092  *fLog << endl;
    10661093
    10671094  memset(numareavalid,0,nareas*sizeof(Int_t));
     
    10941121      const Int_t   aidx   = (*fGeom)[i].GetAidx();
    10951122      const Int_t   sector = (*fGeom)[i].GetSector();
     1123      const Float_t area   = (*fGeom)[i].GetA();
    10961124      const Float_t nphe   = pix.GetPheFFactorMethod();
    10971125
    10981126      if ( nphe < lowlim[aidx] || nphe > upplim[aidx] )
    10991127        {
    1100           *fLog << warn << GetDescriptor() << ": Deviating number of photo-electrons: "
    1101                 << Form("%4.2f",nphe) << " out of accepted limits: ["
    1102                 << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
     1128          *fLog << warn << GetDescriptor() << ": Number of phes: "
     1129                << Form("%7.2f out of %3.1f sigma limit: ",nphe,fPheErrLimit)
     1130                << Form("[%7.2f,%7.2f] pixel%4i",lowlim[aidx],upplim[aidx],i) << endl;
    11031131          bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
    11041132          bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun    );
     
    11071135        }
    11081136     
    1109       //      const Float_t weight = 1./nvar;
    1110       //      areaweights   [aidx]   += weight;
    1111       //      areaphes      [aidx]   += weight*nphe;
    11121137      areaweights   [aidx]   += nphe*nphe;
    11131138      areaphes      [aidx]   += nphe;
     
    11161141      if (aidx == 0)
    11171142        fNumInnerFFactorMethodUsed++;
    1118       //       sectorweights [sector] += weight;
    1119       //      sectorphes    [sector] += weight*nphe;
    1120       sectorweights [sector] += nphe*nphe;
    1121       sectorphes    [sector] += nphe;
     1143
     1144      sectorweights [sector] += nphe*nphe/area/area;
     1145      sectorphes    [sector] += nphe/area;
    11221146      numsectorvalid[sector] ++;
    11231147    }
    11241148
     1149  *fLog << endl;
     1150
    11251151  for (UInt_t aidx=0; aidx<nareas; aidx++)
    11261152    {
     
    11281154      MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
    11291155
    1130       areaweights[aidx] -=  areaphes[aidx]*areaphes[aidx]/numareavalid[aidx];
    1131       areaphes[aidx]    /=  numareavalid[aidx];
    1132       areaweights[aidx] /=  numareavalid[aidx]-1.;
    1133      
    1134       if (areaweights[aidx] <= 0. || areaphes[aidx] <= 0.)
    1135         {
    1136           *fLog << warn << " Mean number of phe's from area index " << aidx << " cannot be calculated: "
    1137                 << " Mean number of phes: "  << areaphes[aidx]
     1156      if (numareavalid[aidx] == 1)
     1157        areaweights[aidx] = 0.;
     1158      else if (numareavalid[aidx] == 0)
     1159        {
     1160          areaphes[aidx]    = -1.;
     1161          areaweights[aidx] = -1.;
     1162        }
     1163      else
     1164        {
     1165          areaweights[aidx] = (areaweights[aidx] - areaphes[aidx]*areaphes[aidx]/numareavalid[aidx])
     1166                            / (numareavalid[aidx]-1);
     1167          areaphes[aidx]    /=  numareavalid[aidx];
     1168        }
     1169     
     1170      if (areaweights[aidx] < 0. || areaphes[aidx] <= 0.)
     1171        {
     1172          *fLog << warn << GetDescriptor()
     1173                << ": Mean number phes from area index " << aidx << " could not be calculated: "
     1174                << " Mean: "  << areaphes[aidx]
    11381175                << " Variance: " << areaweights[aidx]    << endl;
    11391176          apix.SetFFactorMethodValid(kFALSE);
     
    11411178        }
    11421179     
    1143       *fLog << inf << "Replacing number photo-electrons of average area idx " << aidx << ": "
    1144             << Form("%5.3f%s%5.3f",apix.GetPheFFactorMethod()," +- ",apix.GetPheFFactorMethodErr()) << endl;
    1145       *fLog << inf << "  by average number of photo-electrons from area idx " << aidx <<  ": "
    1146             << Form("%5.3f%s%5.3f",areaphes[aidx]," +- ",TMath::Sqrt(areaweights[aidx])) << endl;
     1180      *fLog << inf << "Average total number phes in area idx " << aidx << ": "
     1181            << Form("%7.2f%s%6.2f",areaphes[aidx]," +- ",TMath::Sqrt(areaweights[aidx])) << endl;
    11471182                   
    1148       //      apix.SetPheFFactorMethod   ( areaphes[aidx]/ areaweights[aidx] );
    1149       //      apix.SetPheFFactorMethodVar(    1.         / areaweights[aidx] );     
    11501183      apix.SetPheFFactorMethod   ( areaphes[aidx] );
    11511184      apix.SetPheFFactorMethodVar( areaweights[aidx] / numareavalid[aidx] );     
     
    11541187    }
    11551188
     1189  *fLog << endl;
     1190
    11561191  for (UInt_t sector=0; sector<nsectors; sector++)
    11571192    {
    11581193
    1159       sectorweights[sector] -=  sectorphes[sector]*sectorphes[sector]/numsectorvalid[sector];
    1160       sectorphes[sector]    /=  numsectorvalid[sector];
    1161       sectorweights[sector] /=  numsectorvalid[sector]-1.;
    1162 
     1194      if (numsectorvalid[sector] == 1)
     1195        sectorweights[sector] = 0.;
     1196      else if (numsectorvalid[sector] == 0)
     1197        {
     1198          sectorphes[sector]    = -1.;
     1199          sectorweights[sector] = -1.;
     1200        }
     1201      else
     1202        {
     1203          sectorweights[sector] = (sectorweights[sector]
     1204                                   - sectorphes[sector]*sectorphes[sector]/numsectorvalid[sector]
     1205                                  )
     1206                                / (numsectorvalid[sector]-1.);
     1207          sectorphes[sector]     /=  numsectorvalid[sector];
     1208        }
     1209     
    11631210      MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
    11641211
    1165       if (sectorweights[sector] <= 0. || sectorphes[sector] <= 0.)
    1166         {
    1167           *fLog << warn << " Mean number of phe's from sector " << sector << " cannot be calculated: "
    1168                 << " Mean number of phes: "  << sectorphes[sector]
     1212      if (sectorweights[sector] < 0. || sectorphes[sector] <= 0.)
     1213        {
     1214          *fLog << warn << GetDescriptor()
     1215                <<": Mean number phes per area for sector " << sector << " could not be calculated: "
     1216                << " Mean: "  << sectorphes[sector]
    11691217                << " Variance: "             << sectorweights[sector]    << endl;
    11701218          spix.SetFFactorMethodValid(kFALSE);
     
    11721220        }
    11731221
    1174       *fLog << inf << "Replacing number photo-electrons of average sector " << sector << ": "
    1175             << Form("%5.3f%s%5.3f",spix.GetPheFFactorMethod()," +- ",spix.GetPheFFactorMethodErr()) << endl;
    1176       *fLog << inf << "   by average number photo-electrons from sector " << sector <<  ": "
    1177             << Form("%5.3f%s%5.3f",sectorphes[sector]," +- ",TMath::Sqrt(sectorweights[sector])) << endl;
    1178 
    1179       //      spix.SetPheFFactorMethod   ( sectorphes[sector]/ sectorweights[sector] );
    1180       //      spix.SetPheFFactorMethodVar(    1.        / sectorweights[sector] );     
     1222      *fLog << inf << "Average number phes per area in sector " << sector << ": "
     1223            << Form("%5.2f+-%4.2f  [phe/mm^2]",sectorphes[sector],TMath::Sqrt(sectorweights[sector]))
     1224            << endl;
     1225
    11811226      spix.SetPheFFactorMethod   ( sectorphes[sector] );
    11821227      spix.SetPheFFactorMethodVar( sectorweights[sector] / numsectorvalid[sector]);     
     
    14531498      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
    14541499
     1500      if (IsDebug())
     1501        camffactor.DrawClone();
     1502
    14551503      if (ndf < 2)
    14561504        {
     
    14761524        }
    14771525
    1478       *fLog << inf << endl;
    1479       *fLog << inf << GetDescriptor() << ": Mean F-Factor "
    1480             << "in the camera with area index: " << i << ": "
    1481             << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
    1482       *fLog << inf << endl;
    1483 
    1484       lowlim  [i] = mean  - fFFactorErrLimit*sigma;
     1526      *fLog << inf << GetDescriptor() << ": Mean overall F-Factor (photons to FADC counts) "
     1527            << "with area index: " << i << ": "
     1528            << Form("%4.2f+-%4.2f",mean,sigma) << endl;
     1529
     1530      lowlim  [i] = 1.1;
    14851531      upplim  [i] = mean  + fFFactorErrLimit*sigma;
    14861532
    14871533      delete hist;
    14881534    }
     1535 
     1536  *fLog << endl;
    14891537 
    14901538  for (UInt_t i=0; i<npixels; i++)
     
    15021550      if ( ffactor < lowlim[aidx] || ffactor > upplim[aidx] )
    15031551        {
    1504           *fLog << warn << GetDescriptor() << ": Deviating F-Factor: "
    1505                 << Form("%4.2f",ffactor) << " out of accepted limits: ["
    1506                 << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
     1552          *fLog << warn << GetDescriptor() << ": Overall F-Factor: "
     1553                << Form("%5.2f out of %3.1f sigma limit: ",ffactor,fFFactorErrLimit)
     1554                << Form("[%5.2f,%5.2f] pixel %4i",lowlim[aidx],upplim[aidx],i) << endl;
    15071555          bad.SetUncalibrated( MBadPixelsPix::kDeviatingFFactor );
    15081556          bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun    );
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r4542 r4603  
    5353  static const Float_t fgLambdaCheckLimit;     //! Default for fLambdaCheckLimit   (now set to: 0.2)
    5454  static const Float_t fgLambdaErrLimit;       //! Default for fLabmdaErrLimit     (now set to: 0.5)
    55   static const Float_t fgPheErrLimit;          //! Default for fPheErrLimit        (now set to: 4.)
    56   static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.)
     55  static const Float_t fgPheErrLimit;          //! Default for fPheErrLimit        (now set to: 4.5)
     56  static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.5)
    5757 
    5858  // Variables
     
    9595  const char* GetOutputFile();
    9696  void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
    97   Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad                           );
     97  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
    9898  Bool_t FinalizePINDiode        ();
    9999  Bool_t FinalizeBlindPixel      ();
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r4192 r4603  
    130130  fAverageAreas     = new TClonesArray("MCalibrationChargePix",1);
    131131  fAverageSectors   = new TClonesArray("MCalibrationChargePix",1);
    132  
     132
    133133  Clear();
    134134}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc

    r4334 r4603  
    723723  if (fRSigmaSquare <= 0.)
    724724    {
    725       *fLog << warn
    726             << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
    727             << fPixId << endl;
     725      if (IsDebug())
     726        *fLog << warn
     727              << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
     728              << fPixId << endl;
    728729      return kFALSE;
    729730    }
     
    863864  if (convrelvar > limit || convrelvar < 0.)
    864865    {
    865       *fLog << warn << GetDescriptor() << ": Conversion F-Factor Method Rel. Variance: "
    866             << convrelvar << " above limits of: [0," << Form("%3.2f",limit)
    867             << "] in pixel: " << fPixId << endl;
     866      *fLog << warn << GetDescriptor() << ":  Conv. F-Factor Method Rel. Var.: "
     867            << Form("%4.3f out of limits: [0,%3.2f] in pixel:%4i",convrelvar,limit,fPixId) << endl;
    868868      return kFALSE;
    869869    }
  • trunk/MagicSoft/Mars/mcalib/MHCalibrationCam.cc

    r4337 r4603  
    646646  if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    647647    hist.SetExcluded();
    648  
     648
    649649  hist.InitBins();
    650650  hist.ChangeHistId(i);
Note: See TracChangeset for help on using the changeset viewer.