Changeset 4384 for trunk/MagicSoft


Ignore:
Timestamp:
07/14/04 21:44:14 (20 years ago)
Author:
hbartko
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4382 r4384  
    1919
    2020                                                 -*-*- END OF LINE -*-*-
     21
     22
     23 2004/07/14: Hendrik Bartko
     24  * mpedestal/MPedPhotCam.[h,cc]
     25    - added average areas and sectors (in analogy MPedestalCam)
     26    - added new function InitAreas(const UInt_t i)
     27    - added new function InitSectors(const UInt_t i)
     28    - added new function GetNumAreas()
     29    - added new function GetNumSectors()
     30    - added new function ReCalc, computes the average values for the
     31      sectors from all pixels which are not marked
     32      MBadPixelsPix::kUnsuitableRun
     33  * mpedestal/MPedPhotPix.[h,cc]
     34    - added a variable for the number of events from which the
     35      pedestals are computed
     36  * manalysis/MGeomApply.cc
     37    - changed initialization of MPedPhotCam
     38
     39
    2140
    2241 2004/07/14: Markus Gaug
  • trunk/MagicSoft/Mars/manalysis/MGeomApply.cc

    r3752 r4384  
    1818!   Author(s): Thomas Bretz, 09/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!              Markus Gaug,  03/2004 <mailto:markus@ifae.es>
    20 !
     20!              Hendrik Bartko, 07/2003 <mailto:hbartko@mppmu.mpg.de>
     21!         
    2122!   Copyright: MAGIC Software Development, 2000-2004
    2223!
     
    156157    MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
    157158    if (pedphot)
    158         pedphot->InitSize(cam->GetNumPixels());
     159        pedphot->Init(*cam);
    159160
    160161    MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
  • trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.cc

    r3803 r4384  
    1717!
    1818!   Author(s): Thomas Bretz, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2003
     19!              Hendrik Bartko, 07/2003 <mailto:hbartko@mppmu.mpg.de>
     20!
     21!   Copyright: MAGIC Software Development, 2000-2004
    2122!
    2223!
     
    3031// of photons)
    3132//
     33// Version 2:
     34// ----------
     35//   - added fAreas
     36//   - added fSectors
     37//
    3238/////////////////////////////////////////////////////////////////////////////
    3339#include "MPedPhotCam.h"
    34 #include "MPedPhotPix.h"
    35 
     40
     41#include <TArrayI.h>
     42#include <TArrayD.h>
    3643#include <TClonesArray.h>
    3744
     
    3946#include "MLogManip.h"
    4047
     48#include "MPedPhotPix.h"
     49
    4150#include "MGeomCam.h"
     51#include "MGeomPix.h"
     52
     53#include "MBadPixelsCam.h"
     54#include "MBadPixelsPix.h"
    4255
    4356ClassImp(MPedPhotCam);
     
    5467    fTitle = title ? title : "Storage container for all Pedestal Information in the camera (in units of photons)";
    5568
    56     fArray = new TClonesArray("MPedPhotPix", 1);
    57 
    58 //    for (int i=0; i<577; i++)
    59 //        new ((*fArray)[i]) MPedPhotPix;
     69    fArray   = new TClonesArray("MPedPhotPix", 1);
     70    fAreas   = new TClonesArray("MPedPhotPix", 1);
     71    fSectors = new TClonesArray("MPedPhotPix", 1);
    6072}
    6173
     
    6779{
    6880    delete fArray;
     81    delete fAreas;
     82    delete fSectors;
    6983}
    7084
     
    7892}
    7993
     94// -------------------------------------------------------------------
     95//
     96// Calls TClonesArray::ExpandCreate() for:
     97// - fAverageAreas
     98//
     99void MPedPhotCam::InitAreas(const UInt_t i)
     100{
     101    fAreas->ExpandCreate(i);
     102}
     103
     104// -------------------------------------------------------------------
     105//
     106// Calls TClonesArray::ExpandCreate() for:
     107// - fAverageSectors
     108//
     109void MPedPhotCam::InitSectors(const UInt_t i)
     110{
     111    fSectors->ExpandCreate(i);
     112}
     113
     114// -------------------------------------------------------------------
     115//
     116// Calls:
     117// - InitSize()
     118// - InitAverageAreas()
     119// - InitAverageSectors()
     120//
     121void MPedPhotCam::Init(const MGeomCam &geom)
     122{
     123    InitSize(geom.GetNumPixels());
     124    InitAreas(geom.GetNumAreas());
     125    InitSectors(geom.GetNumSectors());
     126}
     127
     128
    80129// --------------------------------------------------------------------------
    81130//
     
    89138// --------------------------------------------------------------------------
    90139//
     140// Get the size of the MPedPhotCam
     141//
     142Int_t MPedPhotCam::GetNumSectors() const
     143{
     144    return fSectors->GetEntriesFast();
     145}
     146
     147// --------------------------------------------------------------------------
     148//
     149// Get the size of the MPedPhotCam
     150//
     151Int_t MPedPhotCam::GetNumAreas() const
     152{
     153    return fAreas->GetEntriesFast();
     154}
     155
     156// --------------------------------------------------------------------------
     157//
    91158// Get i-th pixel (pixel number)
    92159//
     
    100167// Get i-th pixel (pixel number)
    101168//
    102 MPedPhotPix &MPedPhotCam::operator[](Int_t i) const
     169const MPedPhotPix &MPedPhotCam::operator[](Int_t i) const
    103170{
    104171    return *static_cast<MPedPhotPix*>(fArray->UncheckedAt(i));
    105172}
    106173
    107 /*
    108 // --------------------------------------------------------------------------
    109 //
    110 // Check if position i is inside bounds
    111 //
    112 Bool_t MPedPhotCam::CheckBounds(Int_t i)
    113 {
    114     return i < fArray->GetEntriesFast();
    115 }
    116 */
     174// --------------------------------------------------------------------------
     175//
     176// Get i-th average pixel (area number)
     177//
     178MPedPhotPix &MPedPhotCam::GetArea(UInt_t i)
     179{
     180    return *static_cast<MPedPhotPix*>(fAreas->UncheckedAt(i));
     181}
     182
     183// --------------------------------------------------------------------------
     184//
     185// Get i-th average pixel (sector number)
     186//
     187MPedPhotPix &MPedPhotCam::GetSector(UInt_t i)
     188{
     189    return *static_cast<MPedPhotPix*>(fSectors->UncheckedAt(i));
     190}
     191
     192// --------------------------------------------------------------------------
     193//
     194// Get i-th average pixel (area number)
     195//
     196const MPedPhotPix &MPedPhotCam::GetArea(UInt_t i)const
     197{
     198    return *static_cast<MPedPhotPix*>(fAreas->UncheckedAt(i));
     199}
     200
     201// --------------------------------------------------------------------------
     202//
     203// Get i-th average pixel (sector number)
     204//
     205const MPedPhotPix &MPedPhotCam::GetSector(UInt_t i) const
     206{
     207    return *static_cast<MPedPhotPix*>(fSectors->UncheckedAt(i));
     208}
     209
     210// --------------------------------------------------------------------------
     211//
     212// Call clear of all three TClonesArray
     213//
    117214void MPedPhotCam::Clear(Option_t *o)
    118215{
    119     fArray->ForEach(TObject, Clear)();
    120 }
    121 
     216    { fArray->ForEach(TObject, Clear)(); }
     217    { fAreas->ForEach(TObject, Clear)(); }
     218    { fSectors->ForEach(TObject, Clear)(); }
     219}
     220
     221// --------------------------------------------------------------------------
     222//
     223// Calculates the avarage pedestal and pedestal rms for all sectors
     224// and pixel sizes. The geometry container is used to get the necessary
     225// geometry information (sector number, size index) If the bad pixel
     226// container is given all pixels which have the flag 'bad' are ignored
     227// in the calculation of the sector and size average.
     228//
     229void MPedPhotCam::ReCalc(const MGeomCam &geom, MBadPixelsCam *bad)
     230{
     231   
     232    const Int_t np = GetSize();
     233    const Int_t ns = GetNumSectors();
     234    const Int_t na = GetNumAreas();
     235
     236   
     237
     238    TArrayI acnt(na);
     239    TArrayI scnt(ns);
     240    TArrayD asumx(na);
     241    TArrayD ssumx(ns);
     242    TArrayD asumr(na);
     243    TArrayD ssumr(ns);
     244
     245
     246    for (int i=0; i<np; i++)
     247    {
     248       
     249
     250      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     251        continue; //was: .IsBad()       
     252
     253        // Create sums for areas and sectors
     254        const UInt_t aidx = geom[i].GetAidx();
     255        const UInt_t sect = geom[i].GetSector();
     256
     257        const MPedPhotPix &pix = (*this)[i];
     258
     259        const UInt_t  ne   = pix.GetNumEvents();
     260        const Float_t mean = pix.GetMean();
     261        const Float_t rms  = pix.GetRms();
     262
     263        asumx[aidx] += ne*mean;
     264        asumr[aidx] += ne*rms;
     265        acnt[aidx]  += ne;
     266
     267        ssumx[sect] += ne*mean;
     268        ssumr[sect] += ne*rms;
     269        scnt[sect]  += ne;
     270   
     271
     272    }
     273
     274    for (int i=0; i<ns; i++){
     275      if (scnt[i]>0)  GetSector(i).Set(ssumx[i]/scnt[i], ssumr[i]/scnt[i], scnt[i]);
     276      else GetSector(i).Set(-1., -1., 0);
     277    }
     278
     279    for (int i=0; i<na; i++){
     280      if (acnt[i]>0) GetArea(i).Set(asumx[i]/acnt[i], asumr[i]/acnt[i], acnt[i]);
     281      else  GetArea(i).Set(-1., -1., 0);
     282    }
     283}
     284
     285// --------------------------------------------------------------------------
     286//
     287// print contents
     288//
    122289void MPedPhotCam::Print(Option_t *o) const
    123290{
     
    138305    }
    139306}
    140 /*
    141 Float_t MPedPhotCam::GetPedestalMin(const MGeomCam *geom) const
    142 {
    143     if (fArray->GetEntries() <= 0)
    144         return 50.;
    145 
    146     Float_t minval = (*this)[0].GetPedestalRms();
    147 
    148     for (Int_t i=1; i<fArray->GetEntries(); i++)
    149     {
    150         const MPedPhotPix &pix = (*this)[i];
    151 
    152         Float_t testval = pix.GetPedestalRms();
    153 
    154         if (geom)
    155             testval *= geom->GetPixRatio(i);
    156 
    157         if (testval < minval)
    158             minval = testval;
    159     }
    160     return minval;
    161 }
    162 
    163 Float_t MPedPhotCam::GetPedestalMax(const MGeomCam *geom) const
    164 {
    165     if (fArray->GetEntries() <= 0)
    166         return 50.;
    167 
    168     Float_t maxval = (*this)[0].GetPedestalRms();
    169 
    170     for (Int_t i=1; i<fArray->GetEntries(); i++)
    171     {
    172         const MPedPhotPix &pix = (*this)[i];
    173 
    174         Float_t testval = pix.GetPedestalRms();
    175 
    176         if (geom)
    177             testval *= geom->GetPixRatio(i);
    178 
    179         if (testval > maxval)
    180             maxval = testval;
    181     }
    182     return maxval;
    183 }
    184 */
     307
     308// --------------------------------------------------------------------------
     309//
     310// See MCamEvent
     311//
    185312Bool_t MPedPhotCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    186313{
     314
     315    const Float_t ped      = (*this)[idx].GetMean();
     316    const Float_t rms      = (*this)[idx].GetRms();
     317    const UInt_t  nevt     = (*this)[idx].GetNumEvents();
     318
     319
     320    Float_t pederr;
     321    Float_t rmserr;
     322
     323    if (nevt>0)
     324    {
     325        pederr = rms/TMath::Sqrt((Float_t)nevt);
     326        rmserr = rms/TMath::Sqrt((Float_t)nevt)/2.;
     327    }
     328    else
     329    {
     330        pederr = -1;
     331        rmserr = -1;
     332    }
     333
    187334    switch (type)
    188335    {
    189336    case 0:
    190         val = (*this)[idx].GetMean();
     337        val = ped;// (*this)[idx].GetMean();
    191338        break;
    192339    case 1:
    193         val = (*this)[idx].GetRms();
     340        val = rms; // (*this)[idx].GetRms();
     341        break;
     342    case 2:
     343        val = pederr; // new
     344        break;
     345    case 3:
     346      val = rmserr; // new
    194347        break;
    195348    default:
  • trunk/MagicSoft/Mars/mpedestal/MPedPhotCam.h

    r3803 r4384  
    1313class MGeomCam;
    1414class MPedPhotPix;
     15class MBadPixelsCam;
    1516
    1617class MPedPhotCam : public MParContainer, public MCamEvent
    1718{
    1819private:
    19     TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer?
     20    TClonesArray *fArray;    // FIXME: Change TClonesArray away from a pointer?
     21    TClonesArray *fAreas;    //-> Array of MPedPhotPix, one per pixel area
     22    TClonesArray *fSectors;  //-> Array of MPedPhotPix, one per camera sector
     23
     24    //  void InitSize(const UInt_t i);
     25    void InitAreas(const UInt_t i);
     26    void InitSectors(const UInt_t i);
    2027
    2128public:
     
    2532    void Clear(Option_t *o="");
    2633
    27     void InitSize(const UInt_t i);
     34    void Init(const MGeomCam &geom);
     35    void InitSize(const UInt_t i); // HB
    2836    Int_t GetSize() const;
    2937
    3038    MPedPhotPix &operator[](Int_t i);
    31     MPedPhotPix &operator[](Int_t i) const;
     39    const MPedPhotPix &operator[](Int_t i) const;
    3240
    33     //    Float_t GetPedestalMin(const MGeomCam *cam) const;
    34     //    Float_t GetPedestalMax(const MGeomCam *cam) const;
     41          MPedPhotPix &GetArea(UInt_t i);
     42    const MPedPhotPix &GetArea(UInt_t i) const;
    3543
    36     //    Bool_t CheckBounds(Int_t i);
     44    Int_t GetNumAreas() const;
     45
     46          MPedPhotPix &GetSector(UInt_t i);
     47    const MPedPhotPix &GetSector(UInt_t i) const;
     48
     49    Int_t GetNumSectors() const;
    3750
    3851    void Print(Option_t *o="") const;
     52
     53    void ReCalc(const MGeomCam &geom, MBadPixelsCam *bad);
    3954
    4055    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    4156    void DrawPixelContent(Int_t num) const;
    4257
    43     ClassDef(MPedPhotCam, 1)    // Storage Container for all pedestal information of the camera (in units of photons)
     58    ClassDef(MPedPhotCam, 2)    // Storage Container for all pedestal information of the camera (in units of photons)
    4459};
    4560
  • trunk/MagicSoft/Mars/mpedestal/MPedPhotPix.cc

    r3803 r4384  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
     18!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2001
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    2828//
    2929// This is the storage container to hold informations about the pedestal
    30 // (offset) value of one Pixel (PMT) in units of photons
     30// (offset) value of one Pixel (PMT) in units of photons.
     31//
     32// Version 2:
     33// ----------
     34//   - added fNumEvents
    3135//
    3236/////////////////////////////////////////////////////////////////////////////
     
    5054    fMean = -1;
    5155    fRms  = -1;
     56    fNumEvents = 0;
    5257}
    53 
  • trunk/MagicSoft/Mars/mpedestal/MPedPhotPix.h

    r3803 r4384  
    99{
    1010private:
    11     Float_t fMean; // [phot] mean value of pedestal (should be 0)
    12     Float_t fRms;  // [phot] rms of mean
     11    Float_t fMean;      // [phot] mean value of pedestal (should be 0)
     12    Float_t fRms;       // [phot] rms of mean
     13
     14    UInt_t  fNumEvents; // [n] number of events used to calculate mean (0=n/a)
    1315
    1416public:
     
    1719    void Clear(Option_t *o="");
    1820
    19     Float_t GetMean() const { return fMean; }
    20     Float_t GetRms() const  { return fRms; }
     21    Float_t GetMean() const      { return fMean; }
     22    Float_t GetRms() const       { return fRms; }
     23    UInt_t  GetNumEvents() const { return fNumEvents; }
    2124
    2225    //void SetMean(Float_t f) { fMean = f; }
    2326    void SetRms(Float_t f)  { fRms  = f; }
    24     void Set(Float_t m, Float_t r) { fMean = m; fRms = r; }
     27    void Set(Float_t m, Float_t r, UInt_t n=1) { fMean = m; fRms = r; fNumEvents=n; }
    2528
    2629    Bool_t IsValid() const { return fRms>=0; }
    2730
    28     ClassDef(MPedPhotPix, 1) // Storage Container for Pedestal information of one pixel in units of photons
     31    ClassDef(MPedPhotPix, 2) // Storage Container for Pedestal information of one pixel in units of photons
    2932};
    3033
Note: See TracChangeset for help on using the changeset viewer.