Changeset 8564 for trunk/MagicSoft


Ignore:
Timestamp:
06/16/07 22:59:26 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mpedestal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc

    r8519 r8564  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.31 2007-05-16 13:56:17 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MExtractPedestal.cc,v 1.32 2007-06-16 21:59:19 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    179179const TString  MExtractPedestal::fgNameRawEvtData  = "MRawEvtData";
    180180
    181 const UShort_t MExtractPedestal::fgCheckWinFirst   =  0;
    182 const UShort_t MExtractPedestal::fgCheckWinLast    = 29;
    183 const UShort_t MExtractPedestal::fgMaxSignalVar    = 40;
     181const UShort_t MExtractPedestal::fgCheckWinFirst   =   0;
     182const UShort_t MExtractPedestal::fgCheckWinLast    =  29;
     183const UShort_t MExtractPedestal::fgMaxSignalVar    =  40;
     184const UShort_t MExtractPedestal::fgMaxSignalAbs    = 250;
    184185
    185186// --------------------------------------------------------------------------
     
    210211    SetCheckRange(fgCheckWinFirst, fgCheckWinLast);
    211212    SetMaxSignalVar(fgMaxSignalVar);
     213    SetMaxSignalAbs(fgMaxSignalAbs);
    212214
    213215    Clear();
     
    598600//
    599601// Check whether the signal variation between fCheckWinFirst and fCheckWinLast
    600 // exceeds fMaxSignalVar or the signal is greater than 250
     602// exceeds fMaxSignalVar or the signal is greater than fMaxSignalAbs
    601603//
    602604Bool_t MExtractPedestal::CheckVariation(UInt_t idx) const
    603605{
    604606    // This is the fast workaround to put hi- and lo-gains together
    605     Byte_t *slices = fSignal->GetSamplesRaw(idx);
     607    USample_t *slices = fSignal->GetSamplesRaw(idx);
    606608
    607609    // Start 'real' work
    608     UInt_t max = 0;
    609     UInt_t min = (UInt_t)-1;
     610    USample_t max = 0;
     611    USample_t min = (USample_t)-1;
    610612
    611613    // Find the maximum and minimum signal per slice in the high gain window
    612     for (Byte_t *slice=slices+fCheckWinFirst; slice<=slices+fCheckWinLast; slice++)
     614    for (USample_t *slice=slices+fCheckWinFirst; slice<=slices+fCheckWinLast; slice++)
    613615    {
    614616        if (*slice > max)
     
    620622    // If the maximum in the high gain window is smaller than
    621623    // FIXME: Precompiled value!
    622     return max-min<fMaxSignalVar && max<250;
     624    return max-min<fMaxSignalVar && max<fMaxSignalAbs;
    623625}
    624626
     
    648650
    649651    // Do some handling if maxpos is last slice?
    650     const Int_t maxposhi = fSignal->GetMaxPos(idx, start, start+range-1);
     652    const Int_t maxposhi = fRandomCalculation ? 0 : fSignal->GetMaxPos(idx, start, start+range-1);
    651653
    652654    const Float_t *sig = fSignal->GetSamples(idx);
     
    659661                                         dummy[0], dummy[1], dummy[2],
    660662                                         0, maxposhi);
     663
    661664    return sum;
    662665}
     
    672675    const Int_t first = fExtractWinFirst+offset;
    673676
    674     Byte_t *ptr = fSignal->GetSamplesRaw(pixel.GetPixelId())+first;
    675     Byte_t *end = ptr + fExtractWinSize;
     677    USample_t *ptr = fSignal->GetSamplesRaw(pixel.GetPixelId())+first;
     678    USample_t *end = ptr + fExtractWinSize;
    676679
    677680    Int_t abflag = pixel.HasABFlag() + first;
     
    786789    // multiplies by this number
    787790
     791    // scale to 256
     792    const UInt_t scale = fExtractor ? 1 : fRunHeader->GetScale();
     793
     794    ped    /= scale;
     795    abOffs /= scale;
     796
    788797    // 5. Calculate the RMS from the Variance:
    789     const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
     798    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var)/scale;
    790799
    791800    // abOffs contains only half of the signal as ped.
     
    834843    // multiplies by this number
    835844
     845    // scale to 256
     846    const UInt_t scale = fExtractor ? 1 : fRunHeader->GetScale();
     847
    836848    // 5. Scale the mean, variance and AB-noise to the number of pixels:
    837     ped    /= napix;
    838     var    /= napix;
    839     abOffs /= napix;
     849    ped    /= napix*scale;
     850    abOffs /= napix*scale;
    840851
    841852    // 6. Calculate the RMS from the Variance:
    842     const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
     853    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var)/scale;
    843854
    844855    // abOffs contains only half of the signal as ped.
     
    887898    // multiplies by this number
    888899
     900    // scale to 256
     901    const UInt_t scale = fExtractor ? 1 : fRunHeader->GetScale();
     902
    889903    // 5. Scale the mean, variance and AB-noise to the number of pixels:
    890     ped    /= nspix;
    891     var    /= nspix;
    892     abOffs /= nspix;
     904    ped    /= nspix*scale;
     905    abOffs /= nspix*scale;
    893906
    894907    // 6. Calculate the RMS from the Variance:
    895     const Double_t rms = var<0 ? 0 : TMath::Sqrt(var);
     908    const Double_t rms = var<0 ? 0 : TMath::Sqrt(var)/scale;
    896909
    897910    // abOffs contains only half of the signal as ped.
     
    947960    *fLog << "CheckWindow from slice " << fCheckWinFirst   << " to " << fCheckWinLast << " incl." << endl;
    948961    *fLog << "Max.allowed signal variation: " << fMaxSignalVar << endl;
     962    *fLog << "Max.allowed signal absolute:  " << fMaxSignalAbs << endl;
    949963}
    950964
     
    10201034    }
    10211035
     1036    if (IsEnvDefined(env, prefix, "MaxSignalAbs", print))
     1037    {
     1038        SetMaxSignalAbs(GetEnvValue(env, prefix, "MaxSignalAbs", fMaxSignalAbs));
     1039        rc = kTRUE;
     1040    }
     1041
     1042    // find resource for MPedestalCam
    10221043    if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print))
    10231044    {
     
    10341055    return rc;
    10351056}
    1036 
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h

    r8498 r8564  
    2424class MRawEvtPixelIter;
    2525
     26//typedef UShort_t USample_t;
     27typedef Byte_t USample_t;
     28
    2629class MExtractPedestal : public MTask
    2730{
     
    3336  static const UShort_t fgCheckWinLast;     //! Last FADC slice to check for signal  (currently set to: 29)
    3437  static const UShort_t fgMaxSignalVar;     //! The maximum difference between the highest and lowest slice
     38  static const UShort_t fgMaxSignalAbs;     //! The maximum absolte slice
    3539
    3640  TString fNamePedestalCamOut;       // Name of the outgoing 'MPedestalCam' container
     
    6468
    6569  UShort_t fMaxSignalVar;
     70  UShort_t fMaxSignalAbs;
    6671
    6772  Bool_t  fUseSpecialPixels;         // Flag if the special pixels shall be treated
     
    125130  virtual Bool_t SetRangeFromExtractor(const MExtractor &ext) = 0;
    126131
    127   void SetMaxSignalVar(UShort_t maxvar=40)  { fMaxSignalVar = maxvar;    }
     132  void SetMaxSignalVar(UShort_t maxvar=40)   { fMaxSignalVar = maxvar; }
     133  void SetMaxSignalAbs(UShort_t maxabs=250)  { fMaxSignalAbs = maxabs; }
    128134
    129135  // names
Note: See TracChangeset for help on using the changeset viewer.