Changeset 4649


Ignore:
Timestamp:
08/17/04 13:37:28 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4648 r4649  
    2727       with Florian
    2828
    29 
     29   * mcalib/MCalibrationTestPix.[h,cc]
     30   * mcalib/MCalibrationTestCam.[h,cc]
     31   * mcalib/Makefile
     32   * mcalib/CalibLinkDef.h
     33     - new container class to store results of MCalibrationTestCalc
     34       and MHCalibrationTestCam
     35
     36   * mcalib/MCalibrationTestCalc,[h,cc]
     37     - adapted to use of MCalibrationTestCam
     38   
    3039
    3140 2004/08/17: Thomas Bretz
  • trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h

    r4542 r4649  
    1818#pragma link C++ class MCalibrationQEPix+;
    1919#pragma link C++ class MCalibrationTestCalc+;
     20#pragma link C++ class MCalibrationTestCam+;
     21#pragma link C++ class MCalibrationTestPix+;
    2022#pragma link C++ class MCalibrationChargeCalc+;
    2123#pragma link C++ class MCalibrationChargeCam+;
  • trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.cc

    r4570 r4649  
    6464#include "MHCalibrationTestPix.h"
    6565
     66#include "MCalibrationTestCam.h"
     67#include "MCalibrationTestPix.h"
     68
    6669#include "MBadPixelsCam.h"
    6770#include "MBadPixelsPix.h"
     
    8588//
    8689MCalibrationTestCalc::MCalibrationTestCalc(const char *name, const char *title)
    87     : fMaxNumBadPixelsCluster(-1),
    88       fBadPixels(NULL), fTestCam(NULL), fGeom(NULL)
     90    : fBadPixels(NULL), fTestCam(NULL), fCam(NULL), fGeom(NULL)
    8991{
    9092       
     
    112114  // Containers that are created in case that they are not there.
    113115  //
    114   fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
     116  fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
    115117  if (!fBadPixels)
    116118    {
    117119      *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
     120      return kFALSE;
     121    }
     122 
     123  fCam = (MCalibrationTestCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationTestCam"));
     124  if (!fCam)
     125    {
     126      *fLog << err << "Could not find or create MCalibrationTestCam ... aborting." << endl;
    118127      return kFALSE;
    119128    }
     
    170179{
    171180
    172   //  if (GetNumExecutions()==0)
    173   //    return kFALSE;
     181  if (GetNumExecutions()==0)
     182    return kFALSE;
    174183
    175184  //
     
    184193  FinalizeCalibratedPhotons();
    185194  FinalizeNotInterpolated();
    186   CalcMaxNumBadPixelsCluster();
     195  const Int_t maxbad = CalcMaxNumBadPixelsCluster();
    187196
    188197
     
    193202    {
    194203      *fLog << " " << setw(7) << "Not interpolateable Pixels: "
    195             << Form("%s%3i%s%3i","Inner: ",fNumUninterpolateable[0],
    196                     " Outer: ",fNumUninterpolateable[1]) << endl;
     204            << Form("%s%3i%s%3i","Inner: ",fCam->GetNumUninterpolated(0),
     205                    " Outer: ",fCam->GetNumUninterpolated(1)) << endl;
    197206      *fLog << " " << setw(7) << "Biggest not-interpolateable cluster: "
    198             << fMaxNumBadPixelsCluster << endl;
    199     }
    200  
     207            << maxbad << endl;
     208    }
     209 
     210  fCam->SetNumUninterpolatedInMaxCluster(maxbad);
     211
    201212  *fLog << endl; 
    202213  SetLogStream(&gLog);
     
    251262    {
    252263     
    253       MHCalibrationTestPix &pix = (MHCalibrationTestPix&)(*fTestCam)[i];
     264      MHCalibrationTestPix &hist = (MHCalibrationTestPix&)(*fTestCam)[i];
     265      MCalibrationTestPix  &pix =                         (*fCam)[i];
    254266      //
    255267      // We assume that the pixels have been interpolated so far.
    256268      // The MBadPixelsCam does not give any more information
    257269      //
    258       if (pix.IsEmpty())
    259           continue;
    260 
    261       const Double_t nphot = pix.GetMean();
    262       const Int_t    aidx  = (*fGeom)[i].GetAidx();
     270      if (hist.IsEmpty())
     271        {
     272          pix.SetExcluded();
     273          continue;
     274        }
     275     
     276
     277      const Double_t nphot    = hist.GetMean();
     278      const Double_t nphoterr = hist.GetMeanErr();
     279      const Int_t    aidx     = (*fGeom)[i].GetAidx();
    263280
    264281      camphotons.Fill(i,nphot);
    265282      camphotons.SetUsed(i);
     283
     284      pix.SetNumPhotons   ( nphot    );
     285      pix.SetNumPhotonsErr( nphoterr );
    266286
    267287      areaphotons [aidx] += nphot;
     
    299319          continue;
    300320        }
    301      
    302       lowlim [aidx] = areaphotons[aidx] - fPhotErrLimit*TMath::Sqrt(areavars[aidx]);
    303       upplim [aidx] = areaphotons[aidx] + fPhotErrLimit*TMath::Sqrt(areavars[aidx]);
     321
     322      const Float_t areamean = areaphotons[aidx];
     323      const Float_t areaerr  = TMath::Sqrt(areavars[aidx]);
     324     
     325      MCalibrationTestPix &avpix = fCam->GetAverageArea(aidx);
     326      avpix.SetNumPhotons   (areamean);
     327      avpix.SetNumPhotonsErr(areaerr );
     328
     329      lowlim [aidx] = areamean - fPhotErrLimit*areaerr;
     330      upplim [aidx] = areamean + fPhotErrLimit*areaerr;
    304331
    305332      TArrayI area(1);
     
    338365      fittedsigma[aidx] = sigma;
    339366     
     367      avpix.SetNumPhotons   (mean );
     368      avpix.SetNumPhotonsErr(sigma);
     369
    340370      lowlim  [aidx] = mean  - fPhotErrLimit*sigma;
    341371      upplim  [aidx] = mean  + fPhotErrLimit*sigma;
     
    361391    {
    362392     
    363       MHCalibrationTestPix &pix = (MHCalibrationTestPix&)(*fTestCam)[i];
    364 
    365       const Int_t    aidx   = (*fGeom)[i].GetAidx();
    366       const Int_t    sector = (*fGeom)[i].GetSector();
    367       const Float_t  area   = (*fGeom)[i].GetA();
    368       const Double_t nphot  = pix.GetMean();
     393      MHCalibrationTestPix &hist = (MHCalibrationTestPix&)(*fTestCam)[i];
     394      MCalibrationTestPix  &pix =                         (*fCam)[i];
     395
     396      const Int_t    aidx         = (*fGeom)[i].GetAidx();
     397      const Int_t    sector       = (*fGeom)[i].GetSector();
     398      const Double_t nphot        = hist.GetMean();
     399      const Double_t nphotpera    = nphot            / (*fGeom)[i].GetA();
     400      const Double_t nphotperaerr = hist.GetMeanErr()/ (*fGeom)[i].GetA();
     401
     402      pix.SetNumPhotonsPerArea   ( nphotpera    );
     403      pix.SetNumPhotonsPerAreaErr( nphotperaerr );
    369404
    370405      if ( nphot < lowlim[aidx] || nphot > upplim[aidx] )
     
    376411          bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhots );
    377412          bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun     );
    378           continue;
    379         }
    380      
    381       areavars     [aidx] += nphot*nphot/area/area;
    382       areaphotons  [aidx] += nphot/area;
     413          pix.SetExcluded();
     414          continue;
     415        }
     416     
     417      areavars     [aidx] += nphotpera*nphotpera;
     418      areaphotons  [aidx] += nphotpera;
    383419      numareavalid [aidx] ++;
    384420
    385       sectorvars    [sector] += nphot*nphot/area/area;
    386       sectorphotons [sector] += nphot/area;
     421      sectorvars    [sector] += nphotpera*nphotpera;
     422      sectorphotons [sector] += nphotpera;
    387423      numsectorvalid[sector] ++;
    388424    }
     
    392428  for (UInt_t aidx=0; aidx<nareas; aidx++)
    393429    {
    394 
     430     
    395431      if (numareavalid[aidx] == 1)
    396432        areavars[aidx] = 0.;
     
    407443        }
    408444     
     445
     446      MCalibrationTestPix &avpix = fCam->GetAverageArea(aidx);
     447
    409448      if (areavars[aidx] < 0. || areaphotons[aidx] <= 0.)
    410449        {
     
    413452                << aidx << " could not be calculated! Mean: " << areaphotons[aidx]
    414453                << " Variance: " << areavars[aidx] << endl;
    415           continue;
    416         }
    417      
     454          avpix.SetExcluded();
     455          continue;
     456        }
     457
     458      const Float_t areaerr = TMath::Sqrt(areavars[aidx]);
     459     
     460      avpix.SetNumPhotonsPerArea   (areaphotons[aidx]);
     461      avpix.SetNumPhotonsPerAreaErr(areaerr );
     462
    418463      *fLog << inf << GetDescriptor() << ": Mean number of equiv. Cher. photons "
    419464            << "per area in area idx " << aidx << ": " 
    420             << Form("%5.3f+-%5.4f  [ph/mm^2]",areaphotons[aidx],TMath::Sqrt(areavars[aidx])) << endl;
     465            << Form("%5.3f+-%5.4f  [ph/mm^2]",areaphotons[aidx],areaerr) << endl;
    421466    }
    422467
     
    442487        }
    443488     
     489      MCalibrationTestPix &avpix = fCam->GetAverageSector(sector);
     490
    444491      if (sectorvars[sector] < 0. || sectorphotons[sector] <= 0.)
    445492        {
     
    448495                << sector << " could not be calculated! Mean: " << sectorphotons[sector]
    449496                << " Variance: " << sectorvars[sector] << endl;
    450           continue;
    451         }
    452      
    453  
     497          avpix.SetExcluded();
     498          continue;
     499        }
     500     
     501 
     502      const Float_t sectorerr = TMath::Sqrt(sectorvars[sector]);
     503
     504      avpix.SetNumPhotonsPerArea   (sectorphotons[sector]);
     505      avpix.SetNumPhotonsPerAreaErr(sectorerr );
     506
    454507      *fLog << inf << GetDescriptor() << ": Mean number of equiv. Cher. photons "
    455508            << "per area in sector " << sector << ":   " 
    456             << Form("%5.3f+-%5.4f  [ph/mm^2]",sectorphotons[sector],TMath::Sqrt(sectorvars[sector])) << endl;
     509            << Form("%5.3f+-%5.4f  [ph/mm^2]",sectorphotons[sector],sectorerr) << endl;
    457510    }
    458511
     
    468521{
    469522 
    470   const TArrayI &arr = fTestCam->GetNotInterpolateablePixels();
    471523  const Int_t areas  = fGeom->GetNumAreas();
    472 
    473524  TArrayI *newarr[areas];
    474525
     
    476527    newarr[aidx] = new TArrayI(0);
    477528
    478   fNumUninterpolateable.Set(areas);
    479 
    480   for (Int_t i=0; i<arr.GetSize(); i++)
    481     {
    482       const Int_t id   = arr[i];
    483       const Int_t aidx = (*fGeom)[id].GetAidx();
    484       const Int_t size = newarr[aidx]->GetSize();
    485       newarr[aidx]->Set(size+1);
    486       newarr[aidx]->AddAt(id,size);
    487       fNumUninterpolateable[aidx]++;
     529  for (Int_t i=0; i<fCam->GetSize(); i++)
     530    {
     531      const Int_t aidx = (*fGeom)[i].GetAidx();
     532      if ((*fCam)[i].IsExcluded())
     533        {
     534          const Int_t size = newarr[aidx]->GetSize();
     535          newarr[aidx]->Set(size+1);
     536          newarr[aidx]->AddAt(i,size);
     537        }
    488538    }
    489539
     
    500550          num++;
    501551        }
     552      fCam->SetNumUninterpolated(newarr[aidx]->GetSize(),aidx);
    502553      *fLog << endl;
    503554    }
    504 
    505 
    506555 
    507556  *fLog << " " << setw(7) << num << " total not interpolateable pixels " << endl;
     
    509558}
    510559
    511 void MCalibrationTestCalc::CalcMaxNumBadPixelsCluster()
     560Int_t MCalibrationTestCalc::CalcMaxNumBadPixelsCluster()
    512561{
    513562
     
    516565 
    517566  if (size == 0)
    518     {
    519       fMaxNumBadPixelsCluster = 0;
    520       return;
    521     }
     567    return 0;
    522568 
    523569  if (size == 1)
    524     {
    525       fMaxNumBadPixelsCluster = 1;
    526       return;
    527     }
     570    return 1;
    528571
    529572  TArrayI knownpixels(0);
     
    546589    }
    547590
    548   fMaxNumBadPixelsCluster = oldclustersize;
     591  return oldclustersize;
    549592
    550593}
     
    619662}
    620663
    621 const Int_t MCalibrationTestCalc::GetNumUninterpolateable(const Int_t aidx) const
    622 {
    623   if (aidx < 0)
    624     return -1;
    625 
    626   return aidx > fNumUninterpolateable.GetSize() ? -1 : fNumUninterpolateable[aidx];
    627 }
  • trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.h

    r4568 r4649  
    2020
    2121class MHCalibrationTestCam;
     22class MCalibrationTestCam;
    2223class MBadPixelsCam;
    2324class MGeomCam;
     
    3031  // Variables
    3132  Float_t fPhotErrLimit;               // Limit acceptance nr. cal. phots w.r.t. area idx mean (in sigmas)
    32   Int_t   fMaxNumBadPixelsCluster;     // Number of not interpolateable pixels in biggest cluster
    33 
    34   TArrayI fNumUninterpolateable;       // Number uninterpolated Pixels per area index
    3533
    3634  TString fOutputPath;                 // Path to the output file
     
    4038  MBadPixelsCam         *fBadPixels;   //! Bad Pixels
    4139  MHCalibrationTestCam  *fTestCam;     //! Calibrated Photons in the camera
     40  MCalibrationTestCam   *fCam;         //! Storage Calibrated Photons in the camera
    4241  MGeomCam              *fGeom;        //! Camera geometry
    4342
     
    4746  void   FinalizeNotInterpolated();
    4847  void   FinalizeCalibratedPhotons() const;
    49   void   CalcMaxNumBadPixelsCluster();
     48  Int_t  CalcMaxNumBadPixelsCluster();
    5049  void   LoopNeighbours( const TArrayI &arr, TArrayI &known, Int_t &clustersize, const Int_t idx );
    5150 
     
    5958  MCalibrationTestCalc(const char *name=NULL, const char *title=NULL);
    6059
    61   const Int_t GetMaxNumBadPixelsCluster () const  { return fMaxNumBadPixelsCluster; }
    62   const Int_t GetNumUninterpolateable   ( const Int_t aidx ) const;
    63 
    6460  void SetOutputFile  ( TString file="TestCalibStat.txt" );
    6561  void SetOutputPath  ( TString path="."                 );
  • trunk/MagicSoft/Mars/mcalib/Makefile

    r4542 r4649  
    4343           MCalibrationPedCam.cc \
    4444           MCalibrationTestCalc.cc \
     45           MCalibrationTestCam.cc \
     46           MCalibrationTestPix.cc \
    4547           MCalibrationChargeCalc.cc \
    4648           MCalibrationChargeCam.cc \
Note: See TracChangeset for help on using the changeset viewer.