Changeset 8490


Ignore:
Timestamp:
05/11/07 11:25:46 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8489 r8490  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2007/05/11 Thomas Bretz
     22
     23   * mcalib/MCalibrationChargeCalc.cc, mhcalib/MHPedestalCam.cc,
     24     msignal/MExtractBlindPixel.cc:
     25     - replaced the call to GetTotalEntries by the product
     26       of the number of slices with the number of events of the
     27       individual pixel
     28
     29   * mpedestal/MExtractPedestal.[h,cc], mpedestal/MPedCalcPedRun.[h,cc],
     30     mpedestal/MPedCalcFromLoGain.[h,cc]:
     31     - unified the summing part of Process() into a new function
     32       CalcPixel in the base class
     33     - in MPedCalcPedRun individual pixels could be skipped due to
     34       high variations, but it was still divided by the number of events
     35       procesed. This let to a pedestal which was a tiny amount too
     36       small and gave an small positive offset of the randomly extracted
     37       pedestal.
     38     - unified the loops over the individual pixels to calculate the
     39       pixel-, area-, and sector-defaults for the whole camera into
     40       the base-class
     41     - moved fNumEventsUsed into the base-class and removed obsolete
     42       fUsedEvents
     43     - removed obsolete fTotalCounter, use the product of the number
     44       of slices and the number of events stored in each individual
     45       pixel instead
     46     - added some sanity checks not to calculate average and/or rms
     47       values if the statistics is too low (division by zero)
     48     - for calculating min and/or max values at most places now
     49       an int is used. This increases the range for further
     50       upgrade to 16bit samples.
     51
     52   * mpedestal/MPedestalCam.[h,cc]:
     53     - removed obsolete fTotalEntries and replaced by fNumSlices
     54       because the number of total entries depends on the number of
     55       events used for each individual pixel
     56     - adapted GetPixelContent accordingly
     57     - increased class version to 2
     58
     59
    2060
    2161 2007/05/10 Daniela Dorner
  • trunk/MagicSoft/Mars/NEWS

    r8489 r8490  
    2323     simplified the process of producing several movies from a single
    2424     sequence with different setup.
     25
     26   - callisto: In MPedCalcPedRun (which is the pedestal extraction from
     27     pedestal files) individual pixels could be skipped due to high
     28     variations. This was already the case for the pedestal extraction
     29     from th elo-gains since the beginning and properly handled
     30     there, but was introduced in the extraction from the pedestal files
     31     a while ago. To calculate the average value it was still divided
     32     by the number of events procesed not by the number of summands
     33     really summed. This let to a pedestal which was a tiny amount too
     34     small (for a few piels in the order of 0.1%). This led to an slightly
     35     positive offset of the randomly extracted pedestal for a few pixels.
     36     I doubt that this has a big effect on the result, because the effect
     37     on the individual numbers is quite small.
    2538
    2639   - callisto: the ArrTimeRmsLimit is now is a check of the deviation from
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r8484 r8490  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.179 2007-05-10 12:14:54 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.180 2007-05-11 10:25:44 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    10021002  const Float_t pedes  = ped.GetPedestal();
    10031003  const Float_t prms   = ped.GetPedestalRms();
    1004   const Int_t   num    = fPedestals->GetTotalEntries();
     1004  const Int_t   num    = fPedestals->GetNumSlices()*ped.GetNumEvents();
    10051005 
    10061006  //
  • trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.cc

    r8434 r8490  
    773773    return kFALSE;
    774774
    775   const Float_t ped      = (*fPedestalsOut)[idx].GetPedestal();
    776   const Float_t rms      = (*fPedestalsOut)[idx].GetPedestalRms();
    777 
    778   const Float_t entsqr    =  TMath::Sqrt((Float_t)fPedestalsOut->GetTotalEntries());
     775  const MPedestalPix &ppix = (*fPedestalsOut)[idx];
     776
     777  const Float_t ped = ppix.GetPedestal();
     778  const Float_t rms = ppix.GetPedestalRms();
     779
     780  const Float_t entsqr =  TMath::Sqrt((Float_t)fPedestalsOut->GetNumSlices()*ppix.GetNumEvents());
    779781
    780782  const Float_t pederr   = rms/entsqr;
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc

    r8371 r8490  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.28 2007-03-05 15:54:55 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.29 2007-05-11 10:25:45 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    2121!   Author(s): Thomas Bretz 01/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
    2222!
    23 !   Copyright: MAGIC Software Development, 2000-2006
     23!   Copyright: MAGIC Software Development, 2000-2007
    2424!
    2525!
     
    238238    fSectorFilled.Reset();
    239239    fSectorValid.Reset();
    240 
     240    fNumEventsUsed.Reset();
    241241}
    242242
     
    523523        fSumAB1.Set(npixels);
    524524
     525        fNumEventsUsed.Set(npixels);
     526
    525527        if (fUseSpecialPixels)
    526528        {
     
    613615{
    614616    // This is the fast workaround to put hi- and lo-gains together
    615     Byte_t *slices = fSignal->GetSamplesRaw(idx);//pixel.GetSamples();
     617    Byte_t *slices = fSignal->GetSamplesRaw(idx);
    616618
    617619    // Start 'real' work
    618     UShort_t max = 0;
    619     UShort_t min = (UShort_t)-1;
     620    UInt_t max = 0;
     621    UInt_t min = (UInt_t)-1;
    620622
    621623    // Find the maximum and minimum signal per slice in the high gain window
     
    700702}
    701703
    702 // --------------------------------------------------------------------------
    703 //
    704 //  The following resources are available:
    705 //    ExtractWindowFirst:    15
    706 //    ExtractWindowSize:      6
    707 //    PedestalUpdate:       yes
    708 //    RandomCalculation:    yes
    709 //
    710 Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    711 {
    712     Bool_t rc=kFALSE;
    713 
    714     // find resource for fUseSpecialPixels
    715     if (IsEnvDefined(env, prefix, "UseSpecialPixels", print))
    716     {
    717         SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels));
    718         rc = kTRUE;
    719     }
    720 
    721     if (IsEnvDefined(env, prefix, "IntermediateStorage", print))
    722     {
    723         SetIntermediateStorage(GetEnvValue(env, prefix, "IntermediateStorage", fIntermediateStorage));
    724         rc = kTRUE;
    725     }
    726 
    727     // find resource for random calculation
    728     if (IsEnvDefined(env, prefix, "RandomCalculation", print))
    729     {
    730         SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation));
    731         rc = kTRUE;
    732     }
    733 
    734     // Find resources for ExtractWindow
    735     Int_t ef = fExtractWinFirst;
    736     Int_t es = fExtractWinSize;
    737     if (IsEnvDefined(env, prefix, "ExtractWinFirst", print))
    738     {
    739         ef = GetEnvValue(env, prefix, "ExtractWinFirst", ef);
    740         rc = kTRUE;
    741     }
    742     if (IsEnvDefined(env, prefix, "ExtractWinSize", print))
    743     {
    744         es = GetEnvValue(env, prefix, "ExtractWinSize", es);
    745         rc = kTRUE;
    746     }
    747 
    748     SetExtractWindow(ef,es);
    749 
    750     // Find resources for CheckWindow
    751     Int_t cfs = fCheckWinFirst;
    752     Int_t cls = fCheckWinLast;
    753     if (IsEnvDefined(env, prefix, "CheckWinFirst", print))
    754     {
    755         cfs = GetEnvValue(env, prefix, "CheckWinFirst", cfs);
    756         rc = kTRUE;
    757     }
    758     if (IsEnvDefined(env, prefix, "CheckWinLast", print))
    759     {
    760         cls = GetEnvValue(env, prefix, "CheckWinLast", cls);
    761         rc = kTRUE;
    762     }
    763 
    764     SetCheckRange(cfs,cls);
    765 
    766     // find resource for maximum signal variation
    767     if (IsEnvDefined(env, prefix, "MaxSignalVar", print))
    768     {
    769         SetMaxSignalVar(GetEnvValue(env, prefix, "MaxSignalVar", fMaxSignalVar));
    770         rc = kTRUE;
    771     }
    772 
    773     // find resource for MPedestalCam
    774     if (IsEnvDefined(env, prefix, "NamePedestalCamIn", print))
    775     {
    776         SetNamePedestalCamIn(GetEnvValue(env, prefix, "NamePedestalCamIn", fNamePedestalCamIn));
    777         rc = kTRUE;
    778     }
    779 
    780     if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print))
    781     {
    782         SetNamePedestalCamInter(GetEnvValue(env, prefix, "NamePedestalCamInter", fNamePedestalCamInter));
    783         rc = kTRUE;
    784     }
    785 
    786     if (IsEnvDefined(env, prefix, "NamePedestalCamOut", print))
    787     {
    788         SetNamePedestalCamOut(GetEnvValue(env, prefix, "NamePedestalCamOut", fNamePedestalCamOut));
    789         rc = kTRUE;
    790     }
    791 
    792     return rc;
     704// ---------------------------------------------------------------------------------
     705//
     706// Check for the variation of the pixel. Return kFALSE if this pixel
     707// should not be used.
     708// Calculate the pedestal either with the extractor or by summing slices.
     709// And update all arrays.
     710//
     711Bool_t MExtractPedestal::CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels)
     712{
     713    const UInt_t idx = pixel.GetPixelId();
     714    if (!CheckVariation(idx))
     715        return kFALSE;
     716
     717    //extract pedestal
     718    UInt_t ab[2];
     719    const Float_t sum = fExtractor ?
     720        CalcExtractor(pixel, offset) :
     721        CalcSums(pixel, offset, ab[0], ab[1]);
     722
     723    fNumEventsUsed[idx]++;
     724
     725    if (fIntermediateStorage)
     726        (*fPedestalsInter)[idx].Set(sum, 0, 0, fNumEventsUsed[idx]);
     727
     728    const Float_t sqrsum = sum*sum;
     729
     730    fSumx[idx]  += sum;
     731    fSumx2[idx] += sqrsum;
     732
     733    if (!fExtractor && pixel.IsABFlagValid())
     734    {
     735        fSumAB0[idx] += ab[0];
     736        fSumAB1[idx] += ab[1];
     737    }
     738
     739    if (usespecialpixels)
     740        return kTRUE;
     741
     742    const UInt_t aidx   = (*fGeom)[idx].GetAidx();
     743    const UInt_t sector = (*fGeom)[idx].GetSector();
     744
     745    fAreaFilled[aidx]++;
     746    fSectorFilled[sector]++;
     747
     748    fAreaSumx[aidx]      += sum;
     749    fAreaSumx2[aidx]     += sqrsum;
     750    fSectorSumx[sector]  += sum;
     751    fSectorSumx2[sector] += sqrsum;
     752
     753    if (!fExtractor && pixel.IsABFlagValid())
     754    {
     755        fAreaSumAB0[aidx]   += ab[0];
     756        fAreaSumAB1[aidx]   += ab[1];
     757        fSectorSumAB0[aidx] += ab[0];
     758        fSectorSumAB1[aidx] += ab[1];
     759    }
     760
     761    return kTRUE;
    793762}
    794763
     
    803772// Stores the results in MPedestalCam[pixid]
    804773//
    805 void MExtractPedestal::CalcPixResults(const UInt_t nevts, const UInt_t pixid)
    806 {
     774void MExtractPedestal::CalcPixResults(const UInt_t pixid)
     775{
     776    const UInt_t  nevts = fNumEventsUsed[pixid];
     777    if (nevts<2)
     778        return;
     779
    807780    const Double_t sum  = fSumx[pixid];
    808781    const Double_t sum2 = fSumx2[pixid];
     
    843816// Stores the results in MPedestalCam::GetAverageArea(aidx)
    844817//
    845 void MExtractPedestal::CalcAreaResults(const UInt_t nevts, const UInt_t napix, const UInt_t aidx)
    846 {
     818void MExtractPedestal::CalcAreaResults(const UInt_t aidx)
     819{
     820    const UInt_t nevts = fAreaFilled[aidx];
     821    if (nevts<2)
     822        return;
     823
     824    const UInt_t napix = fAreaValid[aidx];
     825    if (napix<1)
     826        return;
     827
    847828    const Double_t sum  = fAreaSumx[aidx];
    848829    const Double_t sum2 = fAreaSumx2[aidx];
     
    888869// Stores the results in MPedestalCam::GetAverageSector(sector)
    889870//
    890 void MExtractPedestal::CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector)
    891 {
     871void MExtractPedestal::CalcSectorResults(const UInt_t sector)
     872{
     873    const UInt_t nevts = fSectorFilled[sector];
     874    if (nevts<2)
     875        return;
     876
     877    const UInt_t nspix = fSectorValid[sector];
     878    if (nspix<1)
     879        return;
     880
    892881    const Double_t sum  = fSectorSumx[sector];
    893882    const Double_t sum2 = fSectorSumx2[sector];
     
    923912}
    924913
     914// --------------------------------------------------------------------------
     915//
     916// Loop over the pixels to get the averaged pedestal
     917//
     918void MExtractPedestal::CalcPixResult()
     919{
     920    for (UInt_t idx=0; idx<fNumEventsUsed.GetSize(); idx++)
     921        CalcPixResults(idx);
     922}
     923
     924// --------------------------------------------------------------------------
     925//
     926// Loop over the sector indices to get the averaged pedestal per sector
     927//
     928void MExtractPedestal::CalcSectorResult()
     929{
     930    for (UInt_t sector=0; sector<fSectorFilled.GetSize(); sector++)
     931        CalcSectorResults(sector);
     932}
     933
     934// --------------------------------------------------------------------------
     935//
     936// Loop over the (two) area indices to get the averaged pedestal per aidx
     937//
     938void MExtractPedestal::CalcAreaResult()
     939{
     940    for (UInt_t aidx=0; aidx<fAreaFilled.GetSize(); aidx++)
     941        CalcAreaResults(aidx);
     942}
     943
    925944//-----------------------------------------------------------------------
    926945//
     
    942961    *fLog << "Max.allowed signal variation: " << fMaxSignalVar << endl;
    943962}
     963
     964// --------------------------------------------------------------------------
     965//
     966//  The following resources are available:
     967//    ExtractWindowFirst:    15
     968//    ExtractWindowSize:      6
     969//    PedestalUpdate:       yes
     970//    RandomCalculation:    yes
     971//
     972Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     973{
     974    Bool_t rc=kFALSE;
     975
     976    // find resource for fUseSpecialPixels
     977    if (IsEnvDefined(env, prefix, "UseSpecialPixels", print))
     978    {
     979        SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels));
     980        rc = kTRUE;
     981    }
     982
     983    if (IsEnvDefined(env, prefix, "IntermediateStorage", print))
     984    {
     985        SetIntermediateStorage(GetEnvValue(env, prefix, "IntermediateStorage", fIntermediateStorage));
     986        rc = kTRUE;
     987    }
     988
     989    // find resource for random calculation
     990    if (IsEnvDefined(env, prefix, "RandomCalculation", print))
     991    {
     992        SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation));
     993        rc = kTRUE;
     994    }
     995
     996    // Find resources for ExtractWindow
     997    Int_t ef = fExtractWinFirst;
     998    Int_t es = fExtractWinSize;
     999    if (IsEnvDefined(env, prefix, "ExtractWinFirst", print))
     1000    {
     1001        ef = GetEnvValue(env, prefix, "ExtractWinFirst", ef);
     1002        rc = kTRUE;
     1003    }
     1004    if (IsEnvDefined(env, prefix, "ExtractWinSize", print))
     1005    {
     1006        es = GetEnvValue(env, prefix, "ExtractWinSize", es);
     1007        rc = kTRUE;
     1008    }
     1009
     1010    SetExtractWindow(ef,es);
     1011
     1012    // Find resources for CheckWindow
     1013    Int_t cfs = fCheckWinFirst;
     1014    Int_t cls = fCheckWinLast;
     1015    if (IsEnvDefined(env, prefix, "CheckWinFirst", print))
     1016    {
     1017        cfs = GetEnvValue(env, prefix, "CheckWinFirst", cfs);
     1018        rc = kTRUE;
     1019    }
     1020    if (IsEnvDefined(env, prefix, "CheckWinLast", print))
     1021    {
     1022        cls = GetEnvValue(env, prefix, "CheckWinLast", cls);
     1023        rc = kTRUE;
     1024    }
     1025
     1026    SetCheckRange(cfs,cls);
     1027
     1028    // find resource for maximum signal variation
     1029    if (IsEnvDefined(env, prefix, "MaxSignalVar", print))
     1030    {
     1031        SetMaxSignalVar(GetEnvValue(env, prefix, "MaxSignalVar", fMaxSignalVar));
     1032        rc = kTRUE;
     1033    }
     1034
     1035    // find resource for MPedestalCam
     1036    if (IsEnvDefined(env, prefix, "NamePedestalCamIn", print))
     1037    {
     1038        SetNamePedestalCamIn(GetEnvValue(env, prefix, "NamePedestalCamIn", fNamePedestalCamIn));
     1039        rc = kTRUE;
     1040    }
     1041
     1042    if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print))
     1043    {
     1044        SetNamePedestalCamInter(GetEnvValue(env, prefix, "NamePedestalCamInter", fNamePedestalCamInter));
     1045        rc = kTRUE;
     1046    }
     1047
     1048    if (IsEnvDefined(env, prefix, "NamePedestalCamOut", print))
     1049    {
     1050        SetNamePedestalCamOut(GetEnvValue(env, prefix, "NamePedestalCamOut", fNamePedestalCamOut));
     1051        rc = kTRUE;
     1052    }
     1053
     1054    return rc;
     1055}
     1056
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h

    r8357 r8490  
    4040
    4141  Bool_t  fRandomCalculation;        // Is pedestalextraction by extractor random?
    42  
     42
     43  // Helper functions
     44  void CalcAreaResults(const UInt_t aidx);
     45  void CalcSectorResults(const UInt_t sector);
     46
    4347protected:
    44  
     48
    4549  Bool_t  fIntermediateStorage;      // Is pedestal stored every event?
    4650
     
    5357  MExtractTimeAndCharge *fExtractor; //  Possible Extractor
    5458  MPedestalSubtractedEvt *fSignal;   //!
    55  
     59
    5660  UShort_t fExtractWinFirst;         // First FADC slice to extract pedestal from
    5761  UShort_t fExtractWinSize;          // Number of slices to calculate the pedestal from
     
    8286  MArrayI fSectorValid;              // number of valid pixels within sector idx
    8387
     88  MArrayI fNumEventsUsed;            // Number of events used for pedestal calc for each pixel
     89
    8490  // MTask virtual functions
    8591  Int_t  PreProcess(MParList *pList);
     
    94100
    95101  // Helper functions
    96   void CalcPixResults   (const UInt_t nevts, const UInt_t pixid);
    97   void CalcAreaResults  (const UInt_t nevts, const UInt_t napix, const UInt_t aidx);
    98   void CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector);
     102  void CalcPixResults(const UInt_t pixid);
    99103
     104  void CalcPixResult();
     105  void CalcSectorResult();
     106  void CalcAreaResult();
     107
     108  Bool_t  CalcPixel(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t usespecialpixels=kFALSE);
    100109  Float_t CalcExtractor(const MRawEvtPixelIter &pixel, Int_t offset) const;
    101110  UInt_t  CalcSums(const MRawEvtPixelIter &pixel, Int_t offset, UInt_t &ab0, UInt_t &ab1) const;
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc

    r8361 r8490  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcFromLoGain.cc,v 1.37 2007-03-04 12:00:30 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MPedCalcFromLoGain.cc,v 1.38 2007-05-11 10:25:45 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    2626!   Author(s): Nepomuk Otte 10/2004 <mailto:otte@mppmu.mpg.de>
    2727!
    28 !   Copyright: MAGIC Software Development, 2000-2006
     28!   Copyright: MAGIC Software Development, 2000-2007
    2929!
    3030!
     
    145145#include "MRawEvtPixelIter.h"
    146146
    147 #include "MPedestalPix.h"
    148147#include "MPedestalCam.h"
    149 
    150 #include "MGeomPix.h"
    151 #include "MGeomCam.h"
    152 
    153 #include "MExtractPedestal.h"
    154 #include "MPedestalSubtractedEvt.h"
    155148
    156149ClassImp(MPedCalcFromLoGain);
     
    177170    SetPedestalUpdate(kTRUE);
    178171    SetNumDump();
    179 }
    180 
    181 // --------------------------------------------------------------------------
    182 //
    183 // Call MExtractPedestl::ResetArrays aand reset fNumAventsUsed and
    184 // fTotalCounter
    185 //
    186 void MPedCalcFromLoGain::ResetArrays()
    187 {
    188     MExtractPedestal::ResetArrays();
    189 
    190     fNumEventsUsed.Reset();
    191     fTotalCounter.Reset();
    192172}
    193173
     
    203183Bool_t MPedCalcFromLoGain::ReInit(MParList *pList)
    204184{
    205     // If the size is not yet set, set the size
    206     if (fSumx.GetSize()==0)
    207     {
    208         const Int_t npixels = fPedestalsOut->GetSize();
    209         fNumEventsUsed.Set(npixels);
    210         fTotalCounter.Set(npixels);
    211     }
    212 
    213185    if (!MExtractPedestal::ReInit(pList))
    214186        return kFALSE;
     
    232204    const Int_t nlo = fRunHeader->GetNumSamplesLoGain();
    233205
     206    const Int_t offset = nlo>0?nhi:0;
     207
    234208    // Real Process
    235209    MRawEvtPixelIter pixel(fRawEvt);
    236210    while (pixel.Next())
    237211    {
     212        if (!CalcPixel(pixel, offset))
     213            continue;
     214
    238215        const UInt_t idx = pixel.GetPixelId();
    239 
    240         if (!CheckVariation(idx))
    241             continue;
    242 
    243         //extract pedestal
    244         UInt_t ab[2];
    245         const Float_t sum = fExtractor ?
    246             CalcExtractor(pixel, nlo>0?nhi:0) :
    247             CalcSums(pixel, nlo>0?nhi:0, ab[0], ab[1]);
    248 
    249         const UInt_t aidx   = (*fGeom)[idx].GetAidx();
    250         const UInt_t sector = (*fGeom)[idx].GetSector();
    251 
    252         const Float_t sqrsum = sum*sum;
    253 
    254         fSumx[idx]           += sum;
    255         fSumx2[idx]          += sqrsum;
    256         fAreaSumx[aidx]      += sum;
    257         fAreaSumx2[aidx]     += sqrsum;
    258         fSectorSumx[sector]  += sum;
    259         fSectorSumx2[sector] += sqrsum;
    260 
    261         if (fIntermediateStorage)
    262             (*fPedestalsInter)[idx].Set(sum, 0, 0, fNumEventsUsed[idx]);
    263 
    264         fNumEventsUsed[idx]   ++;
    265         fAreaFilled   [aidx]  ++;
    266         fSectorFilled [sector]++;
    267 
    268         if (!fExtractor && pixel.IsABFlagValid())
    269         {
    270             fSumAB0[idx]        += ab[0];
    271             fSumAB1[idx]        += ab[1];
    272             fAreaSumAB0[aidx]   += ab[0];
    273             fAreaSumAB1[aidx]   += ab[1];
    274             fSectorSumAB0[aidx] += ab[0];
    275             fSectorSumAB1[aidx] += ab[1];
    276         }
    277 
    278216        if (!fPedestalUpdate || (UInt_t)fNumEventsUsed[idx]<fNumEventsDump)
    279217            continue;
    280218
    281         CalcPixResults(fNumEventsDump, idx);
    282         fTotalCounter[idx]++;
     219        CalcPixResults(idx);
    283220
    284221        fNumEventsUsed[idx]=0;
     
    289226    }
    290227
    291     if (!(GetNumExecutions() % fNumAreasDump))
     228    if (fNumAreasDump>0 && !(GetNumExecutions() % fNumAreasDump))
     229    {
    292230        CalcAreaResult();
    293 
    294     if (!(GetNumExecutions() % fNumSectorsDump))
     231        fAreaFilled.Reset();
     232    }
     233
     234    if (fNumSectorsDump>0 && !(GetNumExecutions() % fNumSectorsDump))
     235    {
    295236        CalcSectorResult();
     237        fSectorFilled.Reset();
     238    }
    296239
    297240    if (fPedestalUpdate)
     
    299242
    300243  return kTRUE;
    301 }
    302 
    303 // --------------------------------------------------------------------------
    304 //
    305 // Loop over the sector indices to get the averaged pedestal per sector
    306 //
    307 void MPedCalcFromLoGain::CalcSectorResult()
    308 {
    309     for (UInt_t sector=0; sector<fSectorFilled.GetSize(); sector++)
    310         if (fSectorValid[sector]>0)
    311             CalcSectorResults(fSectorFilled[sector], fSectorValid[sector], sector);
    312 }
    313 
    314 // --------------------------------------------------------------------------
    315 //
    316 // Loop over the (two) area indices to get the averaged pedestal per aidx
    317 //
    318 void MPedCalcFromLoGain::CalcAreaResult()
    319 {
    320     for (UInt_t aidx=0; aidx<fAreaFilled.GetSize(); aidx++)
    321         if (fAreaValid[aidx]>0)
    322             CalcAreaResults(fAreaFilled[aidx], fAreaValid[aidx], aidx);
    323 
    324244}
    325245
     
    336256    *fLog << flush << inf << "Calculating Pedestals..." << flush;
    337257
    338     const Int_t npix = fGeom->GetNumPixels();
    339     for (Int_t idx=0; idx<npix; idx++)
    340     {
    341         const ULong_t n = fNumEventsUsed[idx];
    342         if (n>1)
    343         {
    344             CalcPixResults(n, idx);
    345             fTotalCounter[idx]++;
    346         }
    347     }
    348 
     258    CalcPixResult();
    349259    CalcAreaResult();
    350260    CalcSectorResult();
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h

    r8357 r8490  
    44#ifndef MARS_MExtractPedestal
    55#include "MExtractPedestal.h"
    6 #endif
    7 
    8 #ifndef ROOT_TArrayI
    9 #include <TArrayI.h>
    106#endif
    117
     
    2824    UInt_t  fNumSectorsDump;           // Number of events after which averaged sectors gets updated
    2925
    30     TArrayI fNumEventsUsed;      //! Number of events used for pedestal calc for each pixel
    31     TArrayI fTotalCounter;       //! Counter for dumping values to Pedestal Container
    32 
    3326    Bool_t  fPedestalUpdate;           // Flag if the pedestal shall be updated after every fNumEventsDump
    3427
     
    4336    Int_t  Calc();
    4437
    45     //Helper function to extract slice values by slice number
    46     //void CalcExtractor(const MRawEvtPixelIter &pixel, Float_t &sum, MPedestalPix &ped);
    47     void ResetArrays();
    48 
    49     void CalcSectorResult();
    50     void CalcAreaResult();
    51 
    5238public:
    5339    MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL);
    5440
    5541    // Getters
    56     TArrayI *GetNumEventsUsed() { return &fNumEventsUsed; }
    57 
    5842    void SetNumEventsDump (UInt_t dumpevents=fgNumDump)  { fNumEventsDump  = dumpevents; }
    5943    void SetNumAreasDump  (UInt_t dumpevents=fgNumDump)  { fNumAreasDump   = dumpevents; }
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc

    r8296 r8490  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MPedCalcPedRun.cc,v 1.50 2007-02-03 20:03:35 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MPedCalcPedRun.cc,v 1.51 2007-05-11 10:25:45 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    2424!   Author(s): Markus Gaug 01/2004 <mailto:markus@ifae.es>
    2525!
    26 !   Copyright: MAGIC Software Development, 2000-2006
     26!   Copyright: MAGIC Software Development, 2000-2007
    2727!
    2828!
     
    127127#include "MLogManip.h"
    128128
    129 #include "MRawRunHeader.h" 
    130 #include "MRawEvtHeader.h" 
     129#include "MRawRunHeader.h"
    131130#include "MRawEvtPixelIter.h"
    132 #include "MRawEvtData.h"
    133 
    134 #include "MPedestalPix.h"
     131
    135132#include "MPedestalCam.h"
    136 
    137 #include "MGeomPix.h"
    138 #include "MGeomCam.h"
    139 
    140 #include "MExtractPedestal.h"
    141 #include "MPedestalSubtractedEvt.h"
    142133
    143134#include "MTriggerPattern.h"
     
    160151//
    161152MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
    162     : fIsFirstPedRun(kFALSE), fUsedEvents(0), fTrigPattern(NULL)
     153    : fIsFirstPedRun(kFALSE), fTrigPattern(NULL)
    163154{
    164155    fName  = name  ? name  : "MPedCalcPedRun";
     
    170161// --------------------------------------------------------------------------
    171162//
    172 // Call MExtractPedestal::reset and set fUsedEvents to 0.
     163// Call MExtractPedestal::ResetArrays
    173164//
    174165void MPedCalcPedRun::Reset()
    175166{
    176167    MExtractPedestal::ResetArrays();
    177     fUsedEvents = 0;
    178168}
    179169
     
    184174Int_t MPedCalcPedRun::PreProcess(MParList *pList)
    185175{
    186     fUsedEvents    = 0;
    187176    fIsFirstPedRun = kTRUE;
    188177    fIsNotPedRun   = kFALSE;
     
    272261        return kTRUE;
    273262
    274     fUsedEvents++;
    275 
    276263    MRawEvtPixelIter pixel(fRawEvt);
    277264    while (pixel.Next())
    278     {
    279         const UInt_t idx = pixel.GetPixelId();
    280 
    281         if (!CheckVariation(idx))
    282             continue;
    283 
    284         //extract pedestal
    285         UInt_t ab[2];
    286         const Float_t sum = fExtractor ?
    287             CalcExtractor(pixel, 0) :
    288             CalcSums(pixel, 0, ab[0], ab[1]);
    289 
    290         if (fIntermediateStorage)
    291             (*fPedestalsInter)[idx].Set(sum, 0, 0, fUsedEvents);
    292 
    293         const Float_t sqrsum = sum*sum;
    294 
    295         fSumx[idx]   += sum;
    296         fSumx2[idx]  += sqrsum;
    297 
    298         fSumAB0[idx] += ab[0];
    299         fSumAB1[idx] += ab[1];
    300 
    301         if (fUseSpecialPixels)
    302             continue;
    303 
    304         const UInt_t aidx   = (*fGeom)[idx].GetAidx();
    305         const UInt_t sector = (*fGeom)[idx].GetSector();
    306 
    307         fAreaSumx[aidx]      += sum;
    308         fAreaSumx2[aidx]     += sqrsum;
    309         fSectorSumx[sector]  += sum;
    310         fSectorSumx2[sector] += sqrsum;
    311 
    312         fAreaSumAB0[aidx]    += ab[0];
    313         fAreaSumAB1[aidx]    += ab[1];
    314         fSectorSumAB0[aidx]  += ab[0];
    315         fSectorSumAB1[aidx]  += ab[1];
    316     }
     265        CalcPixel(pixel, 0, fUseSpecialPixels);
    317266
    318267    fPedestalsOut->SetReadyToSave();
     
    327276Int_t MPedCalcPedRun::Finalize()
    328277{
    329     if (fUsedEvents == 0)
    330         return kTRUE;
    331 
    332278    //
    333279    // Necessary check for extraction of special pixels
     
    337283        return kTRUE;
    338284
    339     MRawEvtPixelIter pixel(fRawEvt);
    340     while (pixel.Next())
    341         CalcPixResults(fUsedEvents, pixel.GetPixelId());
     285    CalcPixResult();
    342286
    343287    if (!fUseSpecialPixels)
    344288    {
    345 
    346         //
    347         // Loop over the (two) area indices to get the averaged pedestal per aidx
    348         //
    349         for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
    350             if (fAreaValid[aidx]>0)
    351                 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);
    352 
    353         //
    354         // Loop over the (six) sector indices to get the averaged pedestal per sector
    355         //
    356         for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)
    357             if (fSectorValid[sector]>0)
    358                 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);
     289        CalcAreaResult();
     290        CalcSectorResult();
    359291    }
    360292
    361     fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);
     293    fPedestalsOut->SetNumSlices(fExtractWinSize);
    362294    fPedestalsOut->SetReadyToSave();
    363295
     
    405337
    406338    *fLog << "First pedrun out of sequence: " << (fIsFirstPedRun?"yes":"no") << endl;
    407     *fLog << "Number of used events so far: " << fUsedEvents << endl;
    408 }
     339}
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h

    r8357 r8490  
    1818    Bool_t  fIsFirstPedRun;    //! Flag to tell if the first run out of many is used
    1919    Bool_t  fIsNotPedRun;      //! Flag to tell if the current run is a pedestal run
    20     UInt_t  fUsedEvents;       // Number of used (not skipped) events
    2120
    2221    MTriggerPattern *fTrigPattern;  //! Trigger pattern decoded
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc

    r7804 r8490  
    2020!   Author(s): Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de>
    2121!
    22 !   Copyright: MAGIC Software Development, 2000-2004
     22!   Copyright: MAGIC Software Development, 2000-2007
    2323!
    2424!
     
    2626
    2727/////////////////////////////////////////////////////////////////////////////
    28 //                                                                         //
    29 // MPedestalCam                                                            //
    30 //                                                                         //
    31 // Hold the Pedestal information for all pixels in the camera              //
    32 //                                                                         //
     28//
     29// MPedestalCam
     30//
     31// Hold the Pedestal information for all pixels in the camera
     32//
     33// Class Version 2:
     34// ----------------
     35//  + fNumSlices
     36//  - fTotalEntries
     37//
    3338/////////////////////////////////////////////////////////////////////////////
    3439#include "MPedestalCam.h"
     
    7378//
    7479MPedestalCam::MPedestalCam(const char *name, const char *title)
    75     : fTotalEntries(0)
     80    : fNumSlices(0)
    7681{
    7782  fName  = name  ? name  : "MPedestalCam";
    7883  fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
    79  
     84
    8085  fArray            = new TClonesArray("MPedestalPix", 1);
    8186  fAverageAreas     = new TClonesArray("MPedestalPix", 1);
     
    107112
    108113  MPedestalCam &cam = (MPedestalCam&)obj;
    109  
     114
    110115  Int_t n = GetSize();
    111  
     116
    112117  if (n==0)
    113118    return;
    114  
     119
    115120  cam.InitSize(n);
    116121  for (int i=0; i<n; i++)
     
    272277    { fAverageAreas->R__FOR_EACH(TObject, Clear)(); }
    273278    { fAverageSectors->R__FOR_EACH(TObject, Clear)(); }
    274  
    275     fTotalEntries = 0;
     279
     280    fNumSlices = 0;
    276281}
    277282
     
    512517      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    513518        continue;
    514      
     519
    515520      const UInt_t sector = geom[i].GetSector();
    516      
     521
    517522      if (sec != sector)
    518523        continue;
    519524
    520525      const MPedestalPix &pix = (*this)[i];
    521      
     526
    522527      rms  += pix.GetPedestalRms();
    523528      rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
    524529      nr   ++;
    525      
     530
    526531    }
    527532
     
    530535  arr[1] = nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0;
    531536  return arr;
    532  
    533537}
    534538
     
    542546        return kFALSE;
    543547
    544     const Float_t ped      = (*this)[idx].GetPedestal();
    545     const Float_t rms      = (*this)[idx].GetPedestalRms();
     548    const Float_t ped = (*this)[idx].GetPedestal();
     549    const Float_t rms = (*this)[idx].GetPedestalRms();
    546550
    547551    switch (type)
     
    551555        break;
    552556    case 1:
    553         val = fTotalEntries > 0 ?
    554             rms/TMath::Sqrt((Float_t)fTotalEntries)
    555           : (*this)[idx].GetPedestalError();
     557        val = fNumSlices>0 ?
     558            rms/TMath::Sqrt((Float_t)fNumSlices*(*this)[idx].GetNumEvents())
     559            : (*this)[idx].GetPedestalError();
    556560        break;
    557561    case 2:
     
    559563        break;
    560564    case 3:
    561         val = fTotalEntries > 0 ?
    562           rms/TMath::Sqrt((Float_t)fTotalEntries*2.)
     565        val = fNumSlices>0 ?
     566          rms/TMath::Sqrt((Float_t)fNumSlices*(*this)[idx].GetNumEvents()*2.)
    563567          : (*this)[idx].GetPedestalRmsError();
    564568        break;
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h

    r7188 r8490  
    2323  TClonesArray *fAverageSectors;  //-> Array of MPedestalPix, one per camera sector
    2424
    25   UInt_t fTotalEntries;  // Total number of times, the Process was executed (to estimate the error of pedestal)
     25  UInt_t fNumSlices;  // Total number of slices
    2626
    2727  void PrintArr(const TCollection &list) const;
     
    4545  Float_t             GetPedestalMax   ( const MGeomCam *cam ) const;
    4646  Int_t               GetSize          ()                      const;
    47   ULong_t             GetTotalEntries  ()                      const { return fTotalEntries; }
     47  ULong_t             GetNumSlices() const { return fNumSlices; }
    4848
    4949  TArrayF GetAveragedPedPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
     
    6363 
    6464  // Setters
    65   void SetTotalEntries(const ULong_t n) { fTotalEntries = n; }
     65  void SetNumSlices(const ULong_t n) { fNumSlices = n; }
    6666 
    6767  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
    6868  void DrawPixelContent(Int_t idx) const;
    6969
    70   ClassDef(MPedestalCam, 1)     // Storage Container for all pedestal information of the camera
     70  ClassDef(MPedestalCam, 2)     // Storage Container for all pedestal information of the camera
    7171};
    7272
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc

    r8362 r8490  
    241241          fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples, i );
    242242          fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples
    243                                  / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()), i );
     243                                 / TMath::Sqrt((Float_t)fPedestals->GetNumSlices()*pedpix.GetNumEvents()), i );
    244244          fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples), i );
    245245          fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2., i );
Note: See TracChangeset for help on using the changeset viewer.