Changeset 2629 for trunk/MagicSoft


Ignore:
Timestamp:
12/10/03 08:24:42 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/calibration.C

    r2628 r2629  
    218218    disp15.SetYTitle("Conversion Factor [Ph/FADC count]");
    219219
     220    disp1.SetPrettyPalette();
     221    disp3.SetPrettyPalette();
     222    disp5.SetPrettyPalette();
     223    disp6.SetPrettyPalette();
     224    disp7.SetPrettyPalette();
     225    disp8.SetPrettyPalette();
     226    disp9.SetPrettyPalette();
     227    disp10.SetPrettyPalette();
     228    disp11.SetPrettyPalette();
     229    disp12.SetPrettyPalette();
     230    disp13.SetPrettyPalette();
     231    disp14.SetPrettyPalette();
     232    disp15.SetPrettyPalette();
     233
     234
     235
    220236    MStatusDisplay *d2 = new MStatusDisplay;
    221237 
  • trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc

    r2627 r2629  
    107107
    108108
    109   if (fHiGainSaturation)
     109  if (fHist->UseLoGain())
    110110    {
     111      SetHiGainSaturation();
     112
    111113      if(!fHist->FitChargeLoGain())
    112114        {
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc

    r2599 r2629  
    5050#include "MPedestalCam.h"
    5151
     52#include "MGeomCamMagic.h"
     53
    5254ClassImp(MPedCalcPedRun);
    5355
     
    6163    AddToBranchList("fHiGainPixId");
    6264    AddToBranchList("fHiGainFadcSamples");
     65   
     66    fCounter=0;
    6367}
    6468
     
    7579    if (!fPedestals)
    7680        return kFALSE;
     81
     82    MGeomCamMagic magiccam;
     83
     84    fSumx.Set(magiccam.GetNumPixels());
     85    fSumx2.Set(magiccam.GetNumPixels());
     86   
     87    for(UInt_t i=0;i<magiccam.GetNumPixels();i++)
     88    {
     89        fSumx.AddAt(0,i);
     90        fSumx2.AddAt(0,i);
     91    }
    7792
    7893    return kTRUE;
     
    110125    while (pixel.Next())
    111126    {
    112              Byte_t *ptr = pixel.GetHiGainSamples();
    113         const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
     127        Byte_t shift=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? 0:1;
     128              Byte_t *ptr = pixel.GetHiGainSamples();
     129        const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples()-shift;
    114130
    115131        const Float_t higainped = CalcHiGainMean(ptr, end);
     
    118134        const UInt_t pixid = pixel.GetPixelId();
    119135        MPedestalPix &pix = (*fPedestals)[pixid];
    120 
     136       
     137        // cumulate the sum of pedestals and of pedestal squares
     138        fSumx.AddAt(higainped+fSumx.At(pixid),pixid);
     139        fSumx2.AddAt(GetSumx2(ptr, end)+fSumx2.At(pixid),pixid);
     140
     141        // set the value of the pedestal and rms computed from the processed event
    121142        pix.Set(higainped, higainrms);
    122 
    123     }
     143    }
     144
     145
     146    fCounter++;
    124147
    125148    fPedestals->SetReadyToSave();
     
    128151}
    129152
     153Int_t MPedCalcPedRun::PostProcess()
     154{
     155// Compute pedestals and rms from the whole run
     156
     157    MRawEvtPixelIter pixel(fRawEvt);
     158
     159    while (pixel.Next())
     160    {
     161        const UInt_t pixid = pixel.GetPixelId();
     162        MPedestalPix &pix = (*fPedestals)[pixid];
     163
     164        const Int_t N = fCounter;
     165        const Float_t sum = fSumx.At(pixid);
     166        const Float_t sum2 = fSumx2.At(pixid);
     167        const Float_t higainped = sum/N;
     168        const Float_t higainrms = sqrt(1./(N-1.)*(sum2-sum*sum/N));
     169        pix.Set(higainped,higainrms);
     170
     171    }
     172    return kTRUE;
     173
     174}
     175
     176
    130177Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const
    131178{
    132179    Int_t sum=0;
     180    Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1;
    133181
    134182    do sum += *ptr;
    135183    while (++ptr != end);
    136 
    137     return (Float_t)sum/fNumHiGainSamples;
     184   
     185    return (Float_t)sum/EvenNumSamples;
     186}
     187
     188
     189
     190Float_t MPedCalcPedRun::GetSumx2(Byte_t *ptr, const Byte_t *end) const
     191{
     192    Float_t square = 0;
     193
     194    // Take an even number of time slices to avoid biases due to A/B effect
     195    Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1;
     196
     197    do
     198    {
     199        const Float_t val = (Float_t)(*ptr);
     200
     201        square += val*val;
     202    } while (++ptr != end);
     203
     204    return square/EvenNumSamples;
    138205}
    139206
     
    142209{
    143210    Float_t rms = 0;
     211    Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1;
    144212
    145213    do
     
    150218    } while (++ptr != end);
    151219
    152     return sqrt(rms/fNumHiGainSamples);
    153 }
     220    return sqrt(rms/EvenNumSamples);
     221}
     222
     223
     224
    154225/*
    155226Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h

    r2539 r2629  
    1414#endif
    1515
     16#include <TArrayF.h>
     17
    1618class MRawRunHeader;
    1719class MRawEvtData;
     
    2224    Byte_t fNumHiGainSamples;
    2325
     26    Int_t fCounter; // keep number of processed events
     27
    2428    MRawRunHeader *fRunheader; // raw event run header
    2529    MRawEvtData  *fRawEvt;     // raw event data (time slices)
    2630    MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
    2731
     32    TArrayF fSumx;   // sum of values
     33    TArrayF fSumx2;  // sum of squared values
     34
    2835    Float_t CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const;
    2936    Float_t CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const;
    30     //Float_t CalcHiGainMeanErr(Float_t higainrms) const;
     37    Float_t GetSumx2(Byte_t* ptr, const Byte_t* end) const;
     38   //Float_t CalcHiGainMeanErr(Float_t higainrms) const;
    3139    //Float_t CalcHiGainRmsErr(Float_t higainrms) const;
    3240
     
    3543    Int_t PreProcess(MParList *pList);
    3644    Int_t Process();
     45    Int_t PostProcess();
    3746
    3847public:
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc

    r2627 r2629  
    264264}
    265265
     266
     267Bool_t MHCalibrationPixel::UseLoGain()
     268{
     269
     270  if (fHChargeHiGain->GetEntries() > fHChargeLoGain->GetEntries())
     271    {
     272      fUseLoGain = kFALSE;
     273      return kFALSE;
     274    }
     275  else
     276    {
     277      fUseLoGain = kTRUE;
     278      return kTRUE;
     279    }
     280}
    266281
    267282
  • trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h

    r2627 r2629  
    9393  Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return fHChargevsNHiGain->Fill(n,q) > -1; }
    9494
    95   void SetUseLoGain()                      { fUseLoGain = kTRUE; }
     95  void   SetUseLoGain()                          { fUseLoGain = kTRUE; }
     96  Bool_t UseLoGain();
    9697
    9798  const TH1F *GetHCharge()                 { return fHChargeHiGain;    }
Note: See TracChangeset for help on using the changeset viewer.