Changeset 3936


Ignore:
Timestamp:
05/03/04 13:39:47 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc

    r3700 r3936  
    8888//
    8989MCalibrationCam::MCalibrationCam(const char *name, const char *title)
    90     : fNumHiGainFADCSlices(0.), fNumLoGainFADCSlices(0.), fPulserColor(kNONE),
     90    : fNumUnsuitable(),
     91      fNumUnreliable(),
     92      fNumHiGainFADCSlices(0.), fNumLoGainFADCSlices(0.), fPulserColor(kNONE),
    9193      fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
    9294{
     
    189191  fAverageAreas->ExpandCreate(i);
    190192  fAverageBadAreas->ExpandCreate(i);
     193 
     194  fNumUnsuitable.Set(i);
     195  fNumUnreliable.Set(i);
    191196}
    192197
     
    219224// --------------------------------------------------------------------------
    220225//
     226// Returns the number of un-suitable pixels per area index and -1 if
     227// the area index exceeds the initialized array.
     228//
     229const Int_t MCalibrationCam::GetNumUnsuitable( Int_t aidx ) const
     230{
     231  if (aidx < 0)
     232    return -1;
     233
     234  return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
     235}
     236
     237// --------------------------------------------------------------------------
     238//
     239// Returns the number of un-reliable pixels per area index and -1 if
     240// the area index exceeds the initialized array.
     241//
     242const Int_t MCalibrationCam::GetNumUnreliable( Int_t aidx ) const
     243{
     244  if (aidx < 0)
     245    return -1;
     246
     247  return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
     248}
     249
     250
     251// --------------------------------------------------------------------------
     252//
     253// Returns the current size of the TClonesArray fAverageAreas
     254// independently if the MCalibrationPix is filled with values or not.
     255//
     256const Int_t MCalibrationCam::GetAverageAreas() const
     257{
     258  return fAverageAreas->GetEntriesFast();
     259}
     260
     261// --------------------------------------------------------------------------
     262//
     263// Returns the current size of the TClonesArray fAverageSectors
     264// independently if the MCalibrationPix is filled with values or not.
     265//
     266const Int_t MCalibrationCam::GetAverageSectors() const
     267{
     268  return fAverageSectors->GetEntriesFast();
     269}
     270
     271
     272// --------------------------------------------------------------------------
     273//
     274// Get i-th pixel (pixel number)
     275//
     276MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
     277{
     278  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
     279}
     280
     281// --------------------------------------------------------------------------
     282//
     283// Get i-th pixel (pixel number)
     284//
     285const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
     286{
     287  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
     288}
     289
    221290// Returns the current size of the TClonesArray fPixels
    222291// independently if the MCalibrationPix is filled with values or not.
    223 //
    224292const Int_t MCalibrationCam::GetSize() const
    225293{
     
    229297// --------------------------------------------------------------------------
    230298//
    231 // Returns the current size of the TClonesArray fAverageAreas
    232 // independently if the MCalibrationPix is filled with values or not.
    233 //
    234 const Int_t MCalibrationCam::GetAverageAreas() const
    235 {
    236   return fAverageAreas->GetEntriesFast();
    237 }
    238 
    239 // --------------------------------------------------------------------------
    240 //
    241 // Returns the current size of the TClonesArray fAverageSectors
    242 // independently if the MCalibrationPix is filled with values or not.
    243 //
    244 const Int_t MCalibrationCam::GetAverageSectors() const
    245 {
    246   return fAverageSectors->GetEntriesFast();
    247 }
    248 
    249 
    250 // --------------------------------------------------------------------------
    251 //
    252 // Get i-th pixel (pixel number)
    253 //
    254 MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
    255 {
    256   return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
    257 }
    258 
    259 // --------------------------------------------------------------------------
    260 //
    261 // Get i-th pixel (pixel number)
    262 //
    263 const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
    264 {
    265   return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
    266 }
    267 
    268 // --------------------------------------------------------------------------
    269 //
    270299// Get i-th average pixel (area number)
    271300//
     
    360389}
    361390
     391void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
     392{
     393  if (aidx < 0)
     394    return;
     395
     396  if (aidx < fNumUnsuitable.GetSize())
     397    fNumUnsuitable[aidx] = i; 
     398}
     399
     400void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
     401{
     402  if (aidx < 0)
     403    return;
     404  if (aidx < fNumUnreliable.GetSize())
     405    fNumUnreliable[aidx] = i;
     406}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationCam.h

    r3835 r3936  
    88#include "MCamEvent.h"
    99#endif
     10#ifndef ROOT_TArrayI
     11#include "TArrayI.h"
     12#endif
    1013
    1114class TClonesArray;
     
    1518class MBadPixelsCam;
    1619class MGeomCam;
    17 
    1820class MCalibrationCam : public MParContainer, public MCamEvent
    1921{
     
    2426 
    2527protected:
     28
     29  TArrayI fNumUnsuitable;
     30  TArrayI fNumUnreliable;
    2631
    2732  Float_t fNumHiGainFADCSlices;      // Number High-Gain FADC slices used by extractor     
     
    5762  const Float_t          GetNumHiGainFADCSlices()         const { return fNumHiGainFADCSlices; }
    5863  const Float_t          GetNumLoGainFADCSlices()         const { return fNumLoGainFADCSlices; } 
     64  const Int_t            GetNumUnsuitable   ( Int_t aidx) const;
     65  const Int_t            GetNumUnreliable   ( Int_t aidx) const;
     66
    5967  virtual Bool_t         GetPixelContent     ( Double_t &val, Int_t idx,
    6068                                               const MGeomCam &cam, Int_t type=0) const;
     
    7482  void  SetNumHiGainFADCSlices ( const Float_t f              )  { fNumHiGainFADCSlices = f; }
    7583  void  SetNumLoGainFADCSlices ( const Float_t f              )  { fNumLoGainFADCSlices = f; } 
     84  void  SetNumUnsuitable     ( const UInt_t i, const Int_t aidx); 
     85  void  SetNumUnreliable      ( const UInt_t i, const Int_t aidx);
    7686  void  SetPulserColor         ( const PulserColor_t col=kCT1 )  { fPulserColor = col; }
    7787 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3923 r3936  
    14441444 
    14451445  *fLog << inf << endl;
    1446   *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
     1446  *fLog << GetDescriptor() << ": Charge Calibration status:" << endl;
    14471447  *fLog << dec << setfill(' ');
    14481448
     
    14791479
    14801480  for (Int_t aidx=0; aidx<nareas; aidx++)
    1481     fCam->SetNumUncalibrated(counts[aidx], aidx);
     1481    fCam->SetNumUnsuitable(counts[aidx], aidx);
    14821482
    14831483  if (fGeom->InheritsFrom("MGeomCamMagic"))
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc

    r3896 r3936  
    155155// Calls:
    156156// - MCalibrationCam::Init()
    157 // - fNumUncalibrated.Set(NumAreas);
    158 // - fNumUnreliable.Set(NumAreas);
    159157//
    160158void MCalibrationChargeCam::Init(const MGeomCam &geom)
    161159{
    162   fNumUncalibrated.Set(geom.GetNumAreas());
    163   fNumUnreliable  .Set(geom.GetNumAreas());
    164160  MCalibrationCam::Init(geom);
    165161}
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h

    r3837 r3936  
    1414private:
    1515 
    16   TArrayI fNumUncalibrated;
    17   TArrayI fNumUnreliable;
    18 
    1916  Byte_t  fFlags;                    // Bit-field to hold the flags
    2017
     
    3229  // Getters
    3330  Bool_t GetConversionFactorFFactor( Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor );
    34   Int_t  GetNumUncalibrated        ( const Int_t aidx) const   { return fNumUncalibrated[aidx]; }
    35   Int_t  GetNumUnreliable          ( const Int_t aidx) const   { return fNumUnreliable  [aidx]; }
    3631  Bool_t GetPixelContent           ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    3732  Bool_t IsFFactorMethodValid()      const;
     
    4540  // Setters   
    4641  void   SetFFactorMethodValid ( const Bool_t b=kTRUE );
    47   void   SetNumUncalibrated    ( const Int_t i, const Int_t aidx)   { fNumUncalibrated[aidx] = i; }
    48   void   SetNumUnreliable      ( const Int_t i, const Int_t aidx)   { fNumUnreliable  [aidx] = i; }
    4942
    5043  ClassDef(MCalibrationChargeCam, 1) // Container Charge Calibration Results Camera
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.cc

    r3917 r3936  
    7272using namespace std;
    7373
    74 const Float_t MCalibrationRelTimeCalc::fgRelTimeRelErrLimit      = 3.;
     74const Float_t MCalibrationRelTimeCalc::fgRelTimeRelErrLimit      = 6.;
    7575// --------------------------------------------------------------------------
    7676//
     
    219219  // First loop over pixels, call FinalizePedestals and FinalizeRelTimes
    220220  //
    221   Int_t   nvalid      = 0;
    222 
    223   for (Int_t pixid=0; pixid<fCam->GetSize(); pixid++)
    224     {
    225 
    226       MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[pixid];
    227       //
    228       // Check if the pixel has been excluded from the fits
    229       //
    230       if (pix.IsExcluded())
    231         continue;
    232 
    233       MBadPixelsPix &bad = (*fBadPixels)[pixid];
    234 
    235       if (FinalizeRelTimes(pix,bad))
    236         nvalid++;
    237     }
    238  
    239   //
    240   // The Michele check ...
    241   //
    242   if (nvalid == 0)
    243   {
    244       *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. "
    245             << "Did you forget to fill the histograms "
    246             << "(filling MHCalibrationRelTimeCam from MArrivalTimeCam using MFillH) ? " << endl;
    247       *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
    248             << "instead of a calibration run " << endl;
    249     return kFALSE;
    250   }
    251 
    252   for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
    253     {
    254 
    255       MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)fCam->GetAverageArea(aidx);
    256       FinalizeRelTimes(pix, fCam->GetAverageBadArea(aidx));
    257     }
    258  
    259   for (UInt_t sector=0; sector<fGeom->GetNumSectors(); sector++)
    260     {
    261 
    262       MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)fCam->GetAverageSector(sector);
    263       FinalizeRelTimes(pix, fCam->GetAverageBadSector(sector));
    264     }
    265  
     221  FinalizeRelTimes();
     222
    266223  //
    267224  // Finalize Bad Pixels
     
    281238
    282239  PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,   
    283                     Form("%s%2.1f%s","Time resolution less than ",fRelTimeRelErrLimit," sigma from Mean:           "));
     240                    Form("%s%2.1f%s","Time resolution less than ",fRelTimeRelErrLimit," sigma from Mean:   "));
    284241  PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
    285242                    "Pixels with changing Rel. Times   over time:      ");
     
    301258//              MBadPixelsPix::kDeviatingTimeResolution if excluded.
    302259//
    303 Bool_t MCalibrationRelTimeCalc::FinalizeRelTimes(MCalibrationRelTimePix &cal, MBadPixelsPix &bad)
     260void MCalibrationRelTimeCalc::FinalizeRelTimes()
    304261{
    305262
     
    309266  Float_t lowlim      [nareas];
    310267  Float_t upplim      [nareas];
    311   Float_t areaerrs    [nareas];
    312   Float_t areamean    [nareas];
     268  Float_t areasum     [nareas];
     269  Float_t areasum2    [nareas];
    313270  Int_t   numareavalid[nareas];
    314271
    315272  memset(lowlim        ,0, nareas   * sizeof(Float_t));
    316273  memset(upplim        ,0, nareas   * sizeof(Float_t));
    317   memset(areaerrs      ,0, nareas   * sizeof(Float_t));
    318   memset(areamean      ,0, nareas   * sizeof(Float_t));
     274  memset(areasum       ,0, nareas   * sizeof(Float_t));
     275  memset(areasum2      ,0, nareas   * sizeof(Float_t));
    319276  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
    320277
     
    326283    {
    327284     
    328       MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)  [i];
    329       MBadPixelsPix         &bad = (*fBadPixels)[i];
    330      
    331       if (!pix.IsExcluded())
     285      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
     286      MBadPixelsPix          &bad = (*fBadPixels)[i];
     287     
     288      if (pix.IsExcluded())
    332289        continue;
    333290
     
    338295        continue;
    339296     
     297      const Float_t res   = pix.GetTimePrecision();
     298      const Int_t   aidx  = (*fGeom)[i].GetAidx();
     299
     300      areasum     [aidx] += res;
     301      areasum2    [aidx] += res*res;
     302      numareavalid[aidx] ++;
     303    }
     304
     305
     306  for (UInt_t aidx=0; aidx<nareas; aidx++)
     307    {
     308      if (numareavalid[aidx] == 0)
     309        {
     310          *fLog << warn << GetDescriptor() << ": No pixels with valid time resolution found "
     311                << "in area index: " << aidx << endl;
     312          continue;
     313        }
     314 
     315      // Calculate the rms out of sum2:
     316      areasum2[aidx]  = (areasum2[aidx] - areasum[aidx]*areasum[aidx]/numareavalid[aidx]);
     317      areasum [aidx] /= numareavalid[aidx];
     318      areasum2[aidx] /= (numareavalid[aidx]-1.);
     319      lowlim  [aidx]  = areamean[aidx] - fRelTimeRelErrLimit*areasum2[aidx];
     320      upplim  [aidx]  = areamean[aidx] + fRelTimeRelErrLimit*areasum2[aidx];
     321    }
     322 
     323
     324
     325  for (UInt_t i=0; i<npixels; i++)
     326    {
     327     
     328      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
     329      MBadPixelsPix          &bad = (*fBadPixels)[i];
     330     
     331      if (pix.IsExcluded())
     332        continue;
     333     
     334      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     335        continue;
     336     
    340337      const Float_t res  = pix.GetTimePrecision();
    341       const Float_t perr  = pix.GetTimePrecisionErr();
    342       const Int_t   aidx  = (*fGeom)[i].GetAidx();
    343 
    344       areamean    [aidx] += res;
    345       areaerrs    [aidx] += perr;
    346       numareavalid[aidx] ++;
    347     }
    348 
    349 
    350 
    351   for (UInt_t i=0; i<nareas; i++)
    352     {
    353       if (numareavalid[i] == 0)
    354         {
    355           *fLog << warn << GetDescriptor() << ": No pixels with valid number of photo-electrons found "
    356                 << "in area index: " << i << endl;
    357           continue;
    358         }
    359  
    360       areamean[i] = areamean[i] / numareavalid[i];
    361       areaerrs[i] = areaerrs[i] / numareavalid[i];
    362       lowlim  [i] = areamean[i] - fRelTimeRelErrLimit*areaerrs[i];
    363       upplim  [i] = areamean[i] + fRelTimeRelErrLimit*areaerrs[i];
    364     }
    365 
    366 
    367 
    368   //
    369   // Second loop: Exclude pixels deviating by more than fRelTimeErrLimit sigma.
    370   //
    371   for (UInt_t i=0; i<npixels; i++)
    372     {
    373      
    374       MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
    375 
    376       if (!pix.IsExcluded())
    377         continue;
    378 
    379       const Float_t res  = pix.GetTimePrecision();
    380 
    381       MBadPixelsPix         &bad = (*fBadPixels)[i];
    382338      const Int_t   aidx   = (*fGeom)[i].GetAidx();
    383 
     339     
    384340      if ( res < lowlim[aidx] || res > upplim[aidx] )
    385341        {
    386342          *fLog << warn << GetDescriptor() << ": Deviating time resolution: "
    387                 << Form("%4.2f",res) << " out of accepted limits: ["
     343            << Form("%4.2f",res) << " out of accepted limits: ["
    388344                << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
    389345          bad.SetUncalibrated( MBadPixelsPix::kDeviatingTimeResolution);
    390           bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun    );
    391346          pix.SetExcluded();
    392347        }
    393348    }
    394  
    395   return kTRUE;
    396 }
    397 
     349}
    398350
    399351
     
    441393 
    442394  *fLog << inf << endl;
    443   *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
     395  *fLog << GetDescriptor() << ": Rel. Times Calibration status:" << endl;
    444396  *fLog << dec << setfill(' ');
    445397
     
    460412
    461413  for (Int_t aidx=0; aidx<nareas; aidx++)
    462     fCam->SetNumUncalibrated(counts[aidx], aidx);
     414    fCam->SetNumUnsuitable(counts[aidx], aidx);
    463415
    464416  if (fGeom->InheritsFrom("MGeomCamMagic"))
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCalc.h

    r3917 r3936  
    3232private:
    3333
    34   static const Float_t fgRelTimeRelErrLimit;      //! Default for fRelTimeRelErrLimit      (now set to: 1.)
     34  static const Float_t fgRelTimeRelErrLimit;      //! Default for fRelTimeRelErrLimit      (now set to: 6.)
    3535 
    3636  // Variables
    3737  Float_t fRelTimeRelErrLimit;                  // Limit acceptance rel. error mean (in abs. numbers)
    3838  Byte_t  fFlags;                              // Bit-field for the flags
    39 
     39 
    4040  // Pointers
    4141  MBadPixelsCam              *fBadPixels;      //  Bad Pixels
     
    4747
    4848  // functions
    49   Bool_t FinalizeRelTimes        ( MCalibrationRelTimePix &cal, MBadPixelsPix &bad      );
     49  void   FinalizeAverageResolution();
     50  void   FinalizeRelTimes     ();
    5051  void   FinalizeBadPixels      ();
    5152  void   FinalizeUnsuitablePixels();
  • trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.h

    r3917 r3936  
    1313class MCalibrationRelTimeCam : public MCalibrationCam
    1414{
    15 private:
    16  
    17   TArrayI fNumUncalibrated;
    18   TArrayI fNumUnreliable;
    19 
    2015public:
    2116
    2217  MCalibrationRelTimeCam(const char *name=NULL, const char *title=NULL);
    2318  ~MCalibrationRelTimeCam() {}
    24 
    25   Int_t  GetNumUncalibrated        ( const Int_t aidx) const   { return fNumUncalibrated[aidx]; }
    26   Int_t  GetNumUnreliable          ( const Int_t aidx) const   { return fNumUnreliable  [aidx]; }
    2719
    2820  // Prints
     
    3325  void DrawPixelContent(Int_t num) const;   
    3426
    35   void   SetNumUncalibrated    ( const Int_t i, const Int_t aidx)   { fNumUncalibrated[aidx] = i; }
    36   void   SetNumUnreliable      ( const Int_t i, const Int_t aidx)   { fNumUnreliable  [aidx] = i; }
    37  
    3827  ClassDef(MCalibrationRelTimeCam, 1)   // Container Rel. Arrival Time Calibration Results Camera
    3928};
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r3929 r3936  
    16081608                  for (int j=0; j<2; j++)
    16091609                    {
    1610                       half[j]->SetLineColor(kRed+i+j);
     1610                      half[j]->SetLineColor(kRed+i+2*j);
    16111611                      half[j]->SetDirectory(0);
    16121612                      half[j]->SetBit(kCanDelete);
Note: See TracChangeset for help on using the changeset viewer.