Changeset 7043 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
05/17/05 12:08:31 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7042 r7043  
    2121
    2222                                                 -*-*- END OF LINE -*-*-
     23 2005/05/17 Thomas Bretz
     24 
     25   * callisto.rc, callisto_Dec04Jan05.rc:
     26     - added new comments diescribing setup of MFCosmics
     27
     28   * mfilter/MFCosmics.[h,cc]:
     29     - skip bad pixels using MBadPixelsCam
     30     - implemented a check in PostProcess about the fraction
     31       of events which survived or were rejected
     32     - added ReadEnv for setup
     33
     34   * mfilter/Makefile:
     35     - added mbadpixels
     36     - removed mmain and manalysis
     37
     38   * mhcalib/MHCalibrationChargeCam.h:
     39     - removed numbers from data member descrition -- too much
     40       to maintain
     41
     42   * mhcalib/MHCalibrationChargePINDiode.h:
     43     - incremented version number (undocumented from bcn)
     44
     45   * mjobs/MJCalibration.cc:
     46     - reorganized some TText output (undocumented from bcn)
     47     - overwrite the default of MaxNumberEmptyPixels by 0.05
     48       (undocumented from bcn)
     49
     50   * msignal/MExtractTimeAndChargeDigitalFilter.cc:
     51     - changed fgLoGainStartShift from -2.8 to -1.8
     52       (undocumented from bcn)
     53
     54   * msignal/MExtractTimeAndChargeSlidingWindow.h:
     55     - increased version number from 0 to 1 (undocumented from bcn)
     56
     57
     58
     59 2005/05/17 Markus Gaug (2005/05/16)
     60
     61   * msignal/MExtractor.[h,cc]
     62     - introduce two new variables: fResolutionPerPheHiGain and
     63       fResolutionPerPheLoGain, to be set by deriving extractors.
     64     - set version number one higher.
     65
     66   * msignal/MExtractFixedWindow.[h,cc]
     67   * msignal/MExtractTimeAndChargeSlidingWindow.[h,cc]
     68   * msignal/MExtractTimeAndChargeSpline.[h,cc]
     69   * msignal/MExtractTimeAndChargeDigitalFilter.[h,cc]
     70     - set the variables fResolutionPerPheHiGain and
     71       fResolutionPerPheLoGain
     72
     73   * msignal/MExtractPINDiode.[h,cc]
     74     - adapt to current PIN Diode signal, fit signal with Gaussian
     75     - set version number up by one.
     76     
     77   * msignal/MExtractedSignalPINDiode.[h,cc]
     78     - set new data member fExtractedChi2
     79     - set version number up by one.
     80
     81   * mhcalib/MHCalibrationChargePINDiode.cc
     82     - adapt one function to newly used names.
     83     - adapt signal tests.
     84
     85   * mjobs/MJPedestal.[h,cc]
     86     - read MBadPixelsCam together with extractor, if exisiting
     87       (necessary for bad pixels exclusion in pulse position search).
     88
     89   * mjobs/MJCalibration.[h,cc]
     90     - use MFCosmics in any case (not only for CT1-pulses) and apply
     91       a quality criteria depending on number of rejected events:
     92       MaxExcludedEvents (default: 50%).
     93
     94
     95
    2396 2005/05/17 Daniela Dorner
    2497
  • trunk/MagicSoft/Mars/callisto.rc

    r7035 r7043  
    112112# Configure MJCalibration
    113113# -------------------------------------------------------------------------
     114
    114115# Switch on relative time calibration
    115116#MJCalibration.RelTimeCalibration: Yes
    116117# Switch on intensity calibration
    117118#MJCalibration.IntensityCalibration: Yes
    118 # Set color to be used
    119 #MJCalibration.Color:
    120119# Type of used data format: raw, root, mc
    121120#MJCalibration.DataType: Root
     
    131130#MJCalibration.PixelCheck: Yes
    132131#MJCalibTest.PixelCheck: Yes
     132
     133# -------------------------------------------------------------------------
     134# Individual events check for calibration results
     135# -------------------------------------------------------------------------
     136
     137#ContCosmics.MaxEmptyPixels:      0.2
     138#ContCosmics.MaxExcludedFraction: 1
     139#ContCosmics.MinAcceptedFraction: 0
    133140
    134141# -------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/callisto_Dec04Jan05.rc

    r7035 r7043  
    122122# Configure MJCalibration
    123123# -------------------------------------------------------------------------
     124
    124125# Switch on relative time calibration
    125126#MJCalibration.RelTimeCalibration: Yes
     
    143144
    144145# -------------------------------------------------------------------------
     146# Individual events check for calibration results
     147# -------------------------------------------------------------------------
     148
     149#ContCosmics.MaxEmptyPixels:      0.2
     150#ContCosmics.MaxExcludedFraction: 1
     151#ContCosmics.MinAcceptedFraction: 0
     152
     153# -------------------------------------------------------------------------
    145154# In case of MOON DATA, uncomment the following lines:
    146155# (better: call callisto with option "-moon")
  • trunk/MagicSoft/Mars/mfilter/MFCosmics.cc

    r5803 r7043  
    1717!
    1818!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2004
     19!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
     20!
     21!   Copyright: MAGIC Software Development, 2000-2005
    2122!
    2223!
     
    3334//   the outer pixels have some defect).
    3435//
     36//   In the PostProcess we...
     37//    a) check the ratio of events which were accepted against
     38//       fMinAcceptedFraction.
     39//    b) check the ratio of events which were rejected against
     40//       fMaxExcludedFraction.
     41//
    3542//  Input Containers:
    3643//   MRawEvtData
    3744//   MPedestalCam
     45//   MBadPixelsCam
    3846//   MExtractedSignalCam
    3947//
     
    5563#include "MPedestalPix.h"
    5664
     65#include "MBadPixelsCam.h"
     66#include "MBadPixelsPix.h"
     67
    5768#include "MExtractedSignalCam.h"
    5869#include "MExtractedSignalPix.h"
     
    6980//
    7081MFCosmics::MFCosmics(const char *name, const char *title)
    71     : fPedestals(NULL), fSignals(NULL), fRawEvt(NULL),
    72     fNamePedestalCam(fgNamePedestalCam), fMaxEmptyPixels(0.2)
     82    : fPedestals(NULL), fSignals(NULL), fBadPixels(NULL), fRawEvt(NULL),
     83    fNamePedestalCam(fgNamePedestalCam), fMaxEmptyPixels(0.2),
     84    fMinAcceptedFraction(0), fMaxExcludedFraction(1)
    7385{
    7486    fName  = name  ? name  : "MFCosmics";
     
    99111    }
    100112
     113    fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
     114    if (!fBadPixels)
     115    {
     116        *fLog << err << "MBadPixelsCam not found... aborting." << endl;
     117        return kFALSE;
     118    }
     119
    101120    fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
    102121    if (!fSignals)
     
    133152{
    134153    fResult = CosmicsRejection();
    135 
    136154    fCut[fResult ? 0 : 1]++;
     155
    137156    return kTRUE;
    138157}
     
    163182        const UInt_t idx = pixel.GetPixelId();
    164183
    165         MExtractedSignalPix &sig =  (*fSignals)[idx];
    166         MPedestalPix        &ped =  (*fPedestals)[idx];
     184        if ((*fBadPixels)[idx].IsUnsuitable())
     185            continue;
     186
     187        const MExtractedSignalPix &sig =  (*fSignals)[idx];
     188        const MPedestalPix        &ped =  (*fPedestals)[idx];
    167189
    168190        const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
     
    186208}
    187209
     210// ---------------------------------------------------------
     211//
     212//   In the PostProcess we...
     213//    a) check the ratio of events which were accepted against
     214//       fMinAcceptedFraction.
     215//    b) check the ratio of events which were rejected against
     216//       fMaxExcludedFraction.
     217//
     218//   return failure (kFALSE) if condition is not fullfilled.
     219//
    188220Int_t MFCosmics::PostProcess()
    189221{
    190     if (GetNumExecutions()==0)
     222    const UInt_t n = GetNumExecutions();
     223    if (n==0)
    191224        return kTRUE;
    192225
     
    196229
    197230    *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
    198     *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
     231    *fLog << (int)(fCut[0]*100/n);
    199232    *fLog << "%) Detected cosmics " ;
    200233    *fLog << " (with fMaxEmptyPixels = " << fMaxEmptyPixels*100 << "%)" << endl;
    201234
    202235    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
    203     *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
     236    *fLog << (int)(fCut[1]*100/n);
    204237    *fLog << "%) No cosmics!" << endl;
    205238    *fLog << endl;
    206239
    207     return kTRUE;
    208 }
    209 
     240    const Float_t min = fMinAcceptedFraction*n;
     241    const Float_t max = fMaxExcludedFraction*n;
     242    if (fCut[0]<min)
     243    {
     244        *fLog << err << "ERROR - Fraction of accepted events " << min*100;
     245        *fLog << "% underrun " << fMinAcceptedFraction*100 << "%... abort." << endl;
     246        return kFALSE;
     247    }
     248    if (fCut[1]>max)
     249    {
     250        *fLog << err << "ERROR - Fraction of excluded events " << max*100;
     251        *fLog << "% exceeded " << fMaxExcludedFraction*100 << "%... abort." << endl;
     252        return kFALSE;
     253    }
     254
     255    return kTRUE;
     256}
     257
     258// --------------------------------------------------------------------------
     259//
     260// Read the setup from a TEnv, eg:
     261//   MFCosmics.MaxEmptyPixels:    0.2
     262//   MFCosmics.MaxExcludedFraction: 1
     263//   MFCosmics.MinAcceptedFraction: 0
     264//
     265Int_t MFCosmics::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     266{
     267    Bool_t rc = kFALSE;
     268    if (IsEnvDefined(env, prefix, "MaxEmptyPixels", print))
     269    {
     270        rc = kTRUE;
     271        SetMaxEmptyPixels(GetEnvValue(env, prefix, "MaxEmptyPixels", fMaxEmptyPixels));
     272    }
     273    if (IsEnvDefined(env, prefix, "MaxExcludedFraction", print))
     274    {
     275        rc = kTRUE;
     276        SetMaxExcludedFraction(GetEnvValue(env, prefix, "MaxExcludedFraction", fMaxExcludedFraction));
     277    }
     278    if (IsEnvDefined(env, prefix, "MinAcceptedFraction", print))
     279    {
     280        rc = kTRUE;
     281        fMinAcceptedFraction = GetEnvValue(env, prefix, "MinAcceptedFraction", fMinAcceptedFraction);
     282    }
     283    return rc;
     284}
  • trunk/MagicSoft/Mars/mfilter/MFCosmics.h

    r5803 r7043  
    99
    1010class MPedestalCam;
     11class MBadPixelsCam;
    1112class MExtractedSignalCam;
    1213
     
    1819    MPedestalCam        *fPedestals; // Pedestals of all pixels in the camera
    1920    MExtractedSignalCam *fSignals;   // Calibration events of all pixels in the camera
     21    MBadPixelsCam       *fBadPixels; // Bad pixel used for exclusions
    2022
    2123    MRawEvtData         *fRawEvt;    // raw event data (time slices)
     
    2931    Float_t fSqrtHiGainSamples;      // Square root of the number of used Hi-Gain Samples
    3032
     33    Float_t fMinAcceptedFraction;      // return error if exceeded
     34    Float_t fMaxExcludedFraction;      // return error if exceeded
     35
     36    // MFCosmics
     37    Bool_t CosmicsRejection() const;
     38
     39    // MTask
    3140    Bool_t ReInit(MParList *pList);
    3241    Int_t  PreProcess(MParList *pList);
    3342    Int_t  Process();
    3443    Int_t  PostProcess();
     44    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    3545
    36     Bool_t CosmicsRejection() const;
    37 
     46    // MFilter
    3847    Bool_t IsExpressionTrue() const { return fResult; }
    3948 
     
    4453    Float_t GetMaxEmptyPixels() const          { return fMaxEmptyPixels; }
    4554
    46     void SetNamePedestalCam(const char *name) { fNamePedestalCam = name; }
     55    void    SetMaxExcludedFraction(const Float_t n) { fMaxExcludedFraction = n;    }
     56    void    SetMinAcceptedFraction(const Float_t n) { fMinAcceptedFraction = n;    }
     57
     58    void    SetNamePedestalCam(const char *name) { fNamePedestalCam = name; }
    4759
    4860    ClassDef(MFCosmics, 0)   // Filter to perform a cosmics rejection
  • trunk/MagicSoft/Mars/mfilter/Makefile

    r6897 r7043  
    1111#------------------------------------------------------------------------------
    1212
    13 INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mmc -I../mdata \
    14            -I../manalysis -I../mfileio  -I../mgeom -I../mimage      \
    15            -I../mhbase -I../mmain -I../mgui -I../msignal -I../mpointing  \
    16            -I../mpedestal
     13INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mdata \
     14           -I../mfileio  -I../mgeom -I../mimage -I../mgui  \
     15           -I../mhbase -I../msignal -I../mpedestal -I../mbadpixels
    1716
    1817CINT     = Filter
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h

    r6385 r7043  
    2424private:
    2525
    26   static const Int_t   fgChargeHiGainNbins;          //! Nr. bins of HiGain Histograms  (now set to:  550  )
    27   static const Axis_t  fgChargeHiGainFirst;          //! First Bin of HiGain Histograms (now set to: -100.5)
    28   static const Axis_t  fgChargeHiGainLast;           //! Last Bin of HiGain Histograms  (now set to:  999.5)
    29   static const Int_t   fgChargeLoGainNbins;          //! First Bin of LoGain Histograms (now set to:  325  )
    30   static const Axis_t  fgChargeLoGainFirst;          //! First Bin of LoGain Histograms (now set to: -150.5)
    31   static const Axis_t  fgChargeLoGainLast;           //! Last Bin of LoGain Histograms  (now set to:  499.5)
    32   static const Float_t fgProbLimit;                  //! The default for fProbLimit    (now set to: 0.00001)
     26  static const Int_t   fgChargeHiGainNbins;          //! Nr. bins of HiGain Histograms
     27  static const Axis_t  fgChargeHiGainFirst;          //! First Bin of HiGain Histograms
     28  static const Axis_t  fgChargeHiGainLast;           //! Last Bin of HiGain Histograms
     29  static const Int_t   fgChargeLoGainNbins;          //! First Bin of LoGain Histograms
     30  static const Axis_t  fgChargeLoGainFirst;          //! First Bin of LoGain Histograms
     31  static const Axis_t  fgChargeLoGainLast;           //! Last Bin of LoGain Histograms
     32  static const Float_t fgProbLimit;                  //! The default for fProbLimit
    3333 
    34   static const TString fgReferenceFile;              //! default for fReferenceFile ("mjobs/calibrationref.rc")
     34  static const TString fgReferenceFile;              //! default for fReferenceFile
    3535
    3636  static const TString gsHistName;                   //! Default Histogram names
     
    4444  static const TString gsAbsHistYTitle;              //! Default Histogram y-axis titles abs.times
    4545 
    46   static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.01)
    47   static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit (now at: 0.005)
     46  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit
     47  static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit
    4848
    49   static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit    (now set to: 1.)
    50   static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
     49  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit
     50  static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit
    5151 
    52   Int_t   fLoGainNbins;                              // Number of LoGain bins       
     52  Int_t   fLoGainNbins;                              // Number of LoGain bins
    5353  Axis_t  fLoGainFirst;                              // Lower histogram limit low gain
    54   Axis_t  fLoGainLast;                               // Upper histogram limit low gain 
     54  Axis_t  fLoGainLast;                               // Upper histogram limit low gain
    5555
    5656  TString fAbsHistName;                              // Histogram names abs.times
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.cc

    r6528 r7043  
    191191  fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
    192192
     193  fExclusionMean  = 0;
     194  fExclusionSigma = 0; 
     195  fExclusionChi2  = 0;
     196
    193197  return kTRUE;
    194198
     
    250254  const Float_t signal = (float)extractor->GetExtractedSignal();
    251255  const Float_t time   = extractor->GetExtractedTime();
    252   const Float_t rms    = extractor->GetExtractedRms();
    253 
     256  const Float_t sigma    = extractor->GetExtractedSigma();
     257  const Float_t chi2    = extractor->GetExtractedChi2();
     258
     259  if (time < 3. || time > 24.)
     260    {
     261      fExclusionMean++;
     262      return kTRUE;
     263    }
     264 
     265  if (sigma < 5. || sigma > 18.)
     266    {
     267      fExclusionSigma++;
     268      return kTRUE;
     269    }
     270 
     271  if (chi2  > 0.35)
     272    {
     273      fExclusionChi2++;
     274      return kTRUE;
     275    }
     276 
    254277  FillHistAndArray(signal);
    255278  FillAbsTime(time);
    256   FillRmsCharge(rms);
     279  FillRmsCharge(sigma);
    257280
    258281  return kTRUE;
     
    293316  FitRmsCharge();
    294317
    295   CreateFourierSpectrum();
    296   fPINDiode->SetOscillating  ( !IsFourierSpectrumOK() );
    297 
    298318  fPINDiode->SetMean     (  fMean     );
    299319  fPINDiode->SetMeanVar  (  fMeanErr  * fMeanErr );
     
    311331
    312332  fPINDiode->SetValid(kTRUE);
    313 
    314   const Byte_t  loweredge  = fSigPIN->GetFirstUsedSlice();
    315   const Byte_t  upperedge  = fSigPIN->GetLastUsedSlice();
    316   const Float_t lowerlimit = (Float_t)loweredge + fTimeLowerLimit;
    317   const Float_t upperlimit = (Float_t)upperedge + fTimeUpperLimit; 
    318 
    319   if (GetAbsTimeMean() < lowerlimit)
    320     {
    321       *fLog << warn << GetDescriptor()
    322             << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," smaller than ",
    323                     lowerlimit," FADC slices from lower edge in PIN Diode") << endl;
    324       *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
    325       fPINDiode->SetValid(kFALSE);
    326     }
    327  
    328   if ( GetAbsTimeMean() > upperlimit )
    329     {
    330       *fLog << warn << GetDescriptor()
    331             << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," bigger than ",
    332                     upperlimit," FADC slices from upper edge in PIN Diode") << endl;
    333       *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
    334       fPINDiode->SetValid(kFALSE);
    335     }
    336333
    337334  return kTRUE;
  • trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargePINDiode.h

    r5098 r7043  
    6060  Float_t fTimeLowerLimit;                //  Limit dist. to first signal slice (units: FADC slices)
    6161  Float_t fTimeUpperLimit;                //  Limit dist. to last signal slice  (units: FADC slices)
     62
     63  Int_t   fExclusionMean;                 //  Number of events excluded by deviating mean
     64  Int_t   fExclusionSigma;                //  Number of events excluded by deviating sigma
     65  Int_t   fExclusionChi2;                 //  Number of events excluded by deviating chi2
    6266 
    6367public:
     
    7781        TH1F *GetHRmsCharge()                  { return &fHRmsCharge;       }
    7882  const TH1F *GetHRmsCharge()            const { return &fHRmsCharge;       }
    79   Float_t     GetRmsChargeMean()         const { return fRmsChargeMean;     }
    80   Float_t     GetRmsChargeMeanErr()      const { return fRmsChargeMeanErr;  }
    81   Float_t     GetRmsChargeSigma()        const { return fRmsChargeSigma;    }
    82   Float_t     GetRmsChargeSigmaErr()     const { return fRmsChargeSigmaErr; }
     83  Float_t     GetRmsChargeMean()      const { return fRmsChargeMean;     }
     84  Float_t     GetRmsChargeMeanErr()   const { return fRmsChargeMeanErr;  }
     85  Float_t     GetRmsChargeSigma()     const { return fRmsChargeSigma;    }
     86  Float_t     GetRmsChargeSigmaErr()  const { return fRmsChargeSigmaErr; }
    8387
     88  Int_t       GetExclusionMean()      const { return fExclusionMean;     }
     89  Int_t       GetExclusionSigma()     const { return fExclusionSigma;    }
     90  Int_t       GetExclusionChi2()      const { return fExclusionChi2;     }
     91 
     92 
    8493  // Fill histos
    8594  Bool_t FillRmsCharge(const Float_t q);
     
    108117  void SetHistYTitle( const char *name )  { fHistYTitle = name; }
    109118   
    110   ClassDef(MHCalibrationChargePINDiode, 1)  // Histogram class for Charge PIN Diode Calibration
     119  ClassDef(MHCalibrationChargePINDiode, 2)  // Histogram class for Charge PIN Diode Calibration
    111120};
    112121
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r7028 r7043  
    943943      TText *t3 = pave2->AddText(Form("Signal Sigma smaller Pedestal RMS:      %3i pixels",
    944944                                       CountBadPixels(&disp25,1)));
    945       t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol + 1.)));
     945      t3->SetTextColor(gStyle->GetColorPalette(Int_t(1./max2*numcol)));
    946946      t3->SetTextAlign(12);
    947 
    948       TText *t7 = pave2->AddText(Form("Deviating Number of Photo-electrons:     %3i pixels",
    949                                        CountBadPixels(&disp25,2)));
    950       t7->SetTextColor(gStyle->GetColorPalette(Int_t(2./max*numcol + 1.)));
    951       t7->SetTextAlign(12);
    952 
    953       TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:   %3i pixels",
     947      TText *tt1 = pave2->AddText(Form("High Gain Signals could not be fitted:    %3i pixels",
    954948                                       CountBadPixels(&disp25,3)));
    955       tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol + 1.)));
     949      tt1->SetTextColor(gStyle->GetColorPalette(Int_t(3./max2*numcol)));
    956950      tt1->SetTextAlign(12);
    957       TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:   %3i pixels",
     951      TText *tt2 = pave2->AddText(Form("Low  Gain Signals could not be fitted:    %3i pixels",
    958952                                       CountBadPixels(&disp25,4)));
    959       tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol + 1.)));
     953      tt2->SetTextColor(gStyle->GetColorPalette(Int_t(4./max2*numcol)));
    960954      tt2->SetTextAlign(12);
    961       TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:  %3i pixels",
     955      TText *tt3 = pave2->AddText(Form("Relative Arr. Times could not be fitted:   %3i pixels",
    962956                                       CountBadPixels(&disp25,5)));
    963       tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol + 1.)));
     957      tt3->SetTextColor(gStyle->GetColorPalette(Int_t(5./max2*numcol)));
    964958      tt3->SetTextAlign(12);
    965       TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                %3i pixels",
     959      TText *tt4 = pave2->AddText(Form("High Gain Signals Oscillation:                 %3i pixels",
    966960                                       CountBadPixels(&disp25,6)));
    967       tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol + 1.)));
     961      tt4->SetTextColor(gStyle->GetColorPalette(Int_t(6./max2*numcol)));
    968962      tt4->SetTextAlign(12);
    969963      TText *tt5 = pave2->AddText(Form("Low  Gain Signals Oscillation:                %3i pixels",
    970964                                       CountBadPixels(&disp25,7)));
    971       tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol + 1.)));
     965      tt5->SetTextColor(gStyle->GetColorPalette(Int_t(7./max2*numcol)));
    972966      tt5->SetTextAlign(12);
    973967      TText *tt6 = pave2->AddText(Form("Relative Arr. Times Oscillation:               %3i pixels",
    974968                                       CountBadPixels(&disp25,8)));
    975       tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol + 1.)));
     969      tt6->SetTextColor(gStyle->GetColorPalette(Int_t(8./max2*numcol)));
    976970      tt6->SetTextAlign(12);
    977       TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                        %3i pixels",
     971      TText *tt8 = pave2->AddText(Form("Deviating global F-Factor:                       %3i pixels",
    978972                                       CountBadPixels(&disp25,9)));
    979       tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol + 1.)));
     973      tt8->SetTextColor(gStyle->GetColorPalette(Int_t(9./max2*numcol)));
    980974      tt8->SetTextAlign(12);
    981975      pave2->Draw();
     
    15611555Bool_t MJCalibration::CheckEnvLocal()
    15621556{
    1563 
    15641557    TString dis = GetEnv("Display", "");
    15651558    if (dis.BeginsWith("Full", TString::kIgnoreCase))
     
    19351928    //
    19361929    MFCosmics cosmics;
    1937     MContinue cont(&cosmics);
    1938 
    1939     if (fColor == MCalibrationCam::kCT1)
    1940       tlist.AddToList(&cont);
     1930    cosmics.SetMaxEmptyPixels(0.05);
     1931    cosmics.SetMinAcceptedFraction(0.5);
     1932
     1933    MContinue cont(&cosmics, "ContCosmics");
     1934    tlist.AddToList(&cont);
    19411935
    19421936    MCalibColorSteer steer;
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r7029 r7043  
    154154}
    155155
    156 MExtractor *MJPedestal::ReadCalibration() const
     156MExtractor *MJPedestal::ReadCalibration()
    157157{
    158158    const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
     
    172172        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
    173173        return NULL;
     174    }
     175
     176    if (file.FindKey("MBadPixelsCam"))
     177    {
     178        MBadPixelsCam bad;
     179        if (bad.Read()<=0)
     180            *fLog << warn << "Unable to read MBadPixelsCam from " << fname << endl;
     181        else
     182            fBadPixels.Merge(bad);
    174183    }
    175184
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.h

    r6979 r7043  
    7474    Bool_t fIsUseHists;                      // Switch on histogramming or not
    7575
    76     MExtractor *ReadCalibration() const;
     76    MExtractor *ReadCalibration();
    7777    Bool_t ReadPedestalCam();
    7878    Bool_t WriteResult();
  • trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc

    r4984 r7043  
    150150  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
    151151  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 
    152  
     152
     153  const Int_t wshigain = fHiGainLast-fHiGainFirst+1;
     154  const Int_t wslogain = fLoGainLast-fLoGainFirst+1;
     155
     156  switch (wshigain)
     157    {
     158    case 2:
     159      SetResolutionPerPheHiGain(0.021);
     160      break;
     161    case 4:
     162    case 6:
     163    case 8:
     164    case 10:
     165    case 12:
     166    case 14:
     167      SetResolutionPerPheHiGain(0.011);     
     168      break;
     169    default:
     170        *fLog << warn << GetDescriptor() << ": Could not set the hi-gain extractor resolution/phe for window size " << wshigain << endl;
     171    }
     172 
     173  switch (wslogain)
     174    {
     175    case 4:
     176      SetResolutionPerPheLoGain(0.063);
     177      break;
     178    case 6:
     179      SetResolutionPerPheLoGain(0.017);
     180      break;
     181    case 8:
     182    case 10:
     183      SetResolutionPerPheLoGain(0.011);     
     184      break;
     185    default:
     186      *fLog << warn << GetDescriptor() << ": Could not set the lo-gain extractor resolution/phe for window size " << wslogain << endl;
     187    }
    153188}
    154189
  • trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc

    r4896 r7043  
    2525//////////////////////////////////////////////////////////////////////////////
    2626//
    27 //   MExtractPINDiode
     27//  MExtractPINDiode
    2828//
    2929//  Extracts the signal from a fixed window in a given range.
    3030//
    3131//  Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast)
    32 //  to modify the ranges. Ranges have to be an even number. In case of odd
    33 //  ranges, the last slice will be reduced by one.
     32//  to modify the ranges.
     33//
    3434//  Defaults are:
    3535//
    36 //   fHiGainFirst =  fgHiGainFirst =  3
    37 //   fHiGainLast  =  fgHiGainLast  =  14
    38 //   fLoGainFirst =  fgLoGainFirst =  3
    39 //   fLoGainLast  =  fgLoGainLast  =  14
     36//   fHiGainFirst =  fgHiGainFirst =  0
     37//   fHiGainLast  =  fgHiGainLast  =  29
     38//   fLoGainFirst =  fgLoGainFirst =  0
     39//   fLoGainLast  =  fgLoGainLast  =  0
     40//
     41//  The FADC slices are fit by a Gaussian around the pulse maximum.
     42//  The following figures show two typical (high-intensity and low-intensity)
     43//  pulses together with the applied fit:
     44//
     45//Begin_Html
     46/*
     47<img src="images/PINDiode_pulse_high.gif">
     48<img src="images/PINDiode_pulse_low.gif">
     49*/
     50//End_Html
     51//
     52// The fit ranges can be modified with the functions:
     53// - SetLowerFitLimit()
     54// - SetUpperFitLimit()
     55//
     56// Defaults are:
     57//   - fLowerFitLimit: 2
     58//   - fUpperFitLimit: 5
    4059//
    4160//////////////////////////////////////////////////////////////////////////////
     
    4463#include <fstream>
    4564
     65#include <TF1.h>
     66#include <TH1.h>
     67#include <TPad.h>
     68
    4669#include "MLog.h"
    4770#include "MLogManip.h"
     
    6184using namespace std;
    6285
    63 const UInt_t MExtractPINDiode::fgPINDiodeIdx     = 100;
    64 const Byte_t MExtractPINDiode::fgHiGainFirst =  0;
    65 const Byte_t MExtractPINDiode::fgHiGainLast  =  14;
    66 const Byte_t MExtractPINDiode::fgLoGainFirst =  0;
    67 const Byte_t MExtractPINDiode::fgLoGainLast  =  14;
     86const UInt_t MExtractPINDiode::fgPINDiodeIdx   =  3;
     87const Byte_t MExtractPINDiode::fgHiGainFirst   =  0;
     88const Byte_t MExtractPINDiode::fgHiGainLast    = 29;
     89const Byte_t MExtractPINDiode::fgLoGainFirst   =  0;
     90const Byte_t MExtractPINDiode::fgLoGainLast    =  0;
     91const Byte_t MExtractPINDiode::fgLowerFitLimit =  2;
     92const Byte_t MExtractPINDiode::fgUpperFitLimit =  5;
     93
    6894// --------------------------------------------------------------------------
    6995//
     
    7298// Calls:
    7399// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
    74 // - SetPINDiodeIdx()
     100//
     101// - Set fPINDiodeIdx   to fgPINDiodeIdx
     102// - Set fLowerFitLimit to fgLowerFitLimit
     103// - Set fUpperFitLimit to fgUpperFitLimit
    75104//
    76105MExtractPINDiode::MExtractPINDiode(const char *name, const char *title)
    77 {
    78  
     106    : fSlices(NULL)
     107{
     108
    79109  fName  = name  ? name  : "MExtractPINDiode";
    80110  fTitle = title ? title : "Task to extract the signal from the FADC slices";
     
    82112  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
    83113  SetPINDiodeIdx();
     114
     115  SetLowerFitLimit();
     116  SetUpperFitLimit(); 
     117
     118  fPedMean.Set(2);
     119}
     120
     121// --------------------------------------------------------------------------
     122//
     123// - delete the histogram fSlices, if it exists
     124//
     125MExtractPINDiode::~MExtractPINDiode()
     126{
     127  if (fSlices)
     128    delete fSlices;
    84129}
    85130
     
    89134//
    90135// Checks:
    91 // - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
    92 // - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
    93 // - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
    94 // - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
     136// - if the Hi Gain window is smaller than 4, set fHiGainLast to fHiGainFirst+3
    95137//
    96138// Calls:
     
    99141// Sets:
    100142// - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
    101 // - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
     143// - fNumLoGainSamples to: 0.
    102144// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
    103 // - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples) 
     145// - fSqrtLoGainSamples to: 0.
    104146// 
    105147void MExtractPINDiode::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
    106148{
    107149
    108   const Byte_t window = hilast-hifirst+1+lolast-lofirst+1;
    109   const Byte_t weven  = window & ~1;
    110 
    111   if (weven != window)
     150  lofirst = 0;
     151  lolast  = 0;
     152
     153  const Byte_t window = hilast-hifirst+1;
     154
     155  if (window<4)
    112156    {
    113157      *fLog << warn << GetDescriptor()
    114             << Form("%s%2i%s%2i",": Total window size has to be even, set last slice from "
    115                     ,(int)lolast," to ",(int)(lolast-1)) << endl;
    116       lolast -= 1;
    117     }
    118  
    119   if (window<2)
    120     {
    121       *fLog << warn << GetDescriptor()
    122             << Form("%s%2i%s%2i",": Total window is smaller than 2 FADC sampes, set last slice from"
    123                     ,(int)lolast," to ",(int)(lofirst+1)) << endl;
    124       hilast = hifirst+1;
    125     }
    126  
     158            << Form("%s%2i%s%2i",": Total window is smaller than 4 FADC sampes, set last slice from"
     159                    ,(int)lolast," to ",(int)(lofirst+3)) << endl;
     160      hilast = hifirst+3;
     161    }
    127162
    128163  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
    129164
    130165  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
    131   fNumLoGainSamples = (fLoGainLast == 0) ? 0. : (Float_t)(fLoGainLast-fLoGainFirst+1); 
     166  fNumLoGainSamples = 0.;
    132167
    133168  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
    134   fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 
    135  
    136   fNumSamples = (fLoGainLast == 0)
    137     ? fHiGainLast-fHiGainFirst+1
    138     : fHiGainLast-fHiGainFirst+1+fLoGainLast-fLoGainFirst+1;
    139   fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples);
     169  fSqrtLoGainSamples = 0.;
    140170 
    141171}
     
    149179// they were not found:
    150180//
     181//  - MRawEvtData2
    151182//  - MExtractedPINDiode
     183//
     184// Initializes fPedMean to:
     185// - fPedMean[0]: pedestal + AB-offset
     186// - fPedMean[1]: pedestal - AB-offset
     187//
     188// Initializes TH1F fSlices to [fHiGainFirst-0.5,fHiGainLast+0.5]
    152189//
    153190Int_t MExtractPINDiode::PreProcess(MParList *pList)
     
    157194    return kFALSE;
    158195 
     196  fRawEvt = NULL;
     197  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData2"));
     198  if (!fRawEvt)
     199    {
     200      *fLog << err << AddSerialNumber("MRawEvtData2") << " not found... aborting." << endl;
     201      return kFALSE;
     202    }
     203
    159204  fPINDiode = (MExtractedSignalPINDiode*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalPINDiode"));
    160205  if (!fPINDiode)
    161206    return kFALSE;
    162207
     208  fPedMean.Reset();
     209
    163210  const MPedestalPix &ped   = (*fPedestals)[fPINDiodeIdx];
    164211
    165     if (&ped)
    166       {
    167         fPedestal = ped.GetPedestal();
    168         fPedRms   = ped.GetPedestalRms();
    169       }
    170     else
    171       {
    172         *fLog << err << " Cannot find MPedestalPix of the PIN Diode (idx="
    173               << fPINDiodeIdx << ")" << endl;
     212  if (&ped)
     213    {
     214      fPedMean[0] = ped.GetPedestal() + ped.GetPedestalABoffset();
     215      fPedMean[1] = ped.GetPedestal() - ped.GetPedestalABoffset();     
     216    }
     217  else
     218    {
     219      *fLog << err << " Cannot find MPedestalPix of the PIN Diode (idx="
     220            << fPINDiodeIdx << ")" << endl;
    174221        return kFALSE;
    175       }
    176 
    177     return kTRUE;
     222    }
     223 
     224  if (fSlices)
     225    delete fSlices;
     226
     227  fSlices = new TH1F("PINDiode","PIN Diode fitted slices",(Int_t)(fHiGainLast-fHiGainFirst+1),
     228                     fHiGainFirst-0.5,fHiGainLast+0.5);
     229  fSlices->SetDirectory(NULL);
     230
     231  return kTRUE;
    178232}
    179233
     
    190244 
    191245  fPINDiode->SetUsedFADCSlices(fHiGainFirst, fLoGainLast);
    192  
     246
     247  *fLog << endl;
     248  *fLog << inf << "Taking " << fNumHiGainSamples
     249        << " HiGain samples from slice " << (Int_t)fHiGainFirst
     250        << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
     251
    193252  return kTRUE;
    194  
    195 }
    196 
    197 
    198 
    199 void MExtractPINDiode::FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
    200 {
    201 
    202   Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
    203 
     253}
     254
     255
     256
     257
     258// ----------------------------------------------------------------------------------
     259//
     260// Extracts the (pedestal-subtracted) FADC slices between fHiGainFirst and fHiGainLast
     261// and fills them into the histogram fSlices. Memorizes the position of maximum at
     262// maxpos.
     263//
     264// Checks for saturation
     265//
     266// Fits fSlices to a Gaussian in the ranges: maxpos-fLowerFitLimit, maxpos+fUpperFitLimit
     267//
     268// Writes fit results into MExtractedSignalPINDiode
     269//
     270Int_t MExtractPINDiode::Process()
     271{
     272
     273
     274  MRawEvtPixelIter pixel(fRawEvt);
     275 
     276  fPINDiode->Clear();
     277  fSlices->Reset();
     278 
     279  pixel.Jump(fPINDiodeIdx);
     280 
     281  Byte_t sat  = 0;
     282
     283  Int_t higainsamples = pixel.GetNumHiGainSamples();
     284  Int_t logainsamples = pixel.GetNumLoGainSamples();
     285 
     286  const Bool_t higainabflag = pixel.HasABFlag();
     287  Byte_t *ptr = pixel.GetHiGainSamples()+fHiGainFirst;
     288  Byte_t *end = ptr+higainsamples;
     289 
     290  Int_t cnt=0;
     291
     292  Float_t max = 0.;
     293  Int_t maxpos = 0;
     294 
    204295  while (ptr<end)
    205296    {
    206       sum  += *ptr;
    207       sum2 += *ptr * *ptr;
    208 
    209       if (*ptr++ >= fSaturationLimit)
    210         sat++;
    211     }
    212 }
    213 
    214 void MExtractPINDiode::FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
    215 {
    216 
    217   Byte_t *end = ptr +  fLoGainLast - fLoGainFirst  + 1;
    218 
    219   while (ptr<end)
    220     {
    221       sum  += *ptr;
    222       sum2 += *ptr * *ptr;
    223297     
    224       if (*ptr++ >= fSaturationLimit)
    225         sat++;
    226     }
    227 }
    228 
    229 
    230 
    231 // --------------------------------------------------------------------------
    232 //
    233 // Calculate the integral of the FADC time slices and store them as a new
    234 // pixel in the MExtractedPINDiode container.
    235 //
    236 Int_t MExtractPINDiode::Process()
    237 {
    238 
    239 
    240   MRawEvtPixelIter pixel(fRawEvt);
    241  
    242   fPINDiode->Clear();
    243  
    244   pixel.Jump(fPINDiodeIdx);
    245  
    246   Int_t sum   = 0;
    247   Int_t sum2  = 0;
    248   Byte_t sat  = 0;
    249   Int_t max   = 0;
    250  
    251   //
    252   // Calculate first the time:
    253   //
    254   const Int_t maxhi = pixel.GetIdxMaxHiGainSample();
    255   const Int_t maxlo = pixel.GetIdxMaxLoGainSample();
    256  
    257   if (maxhi > maxlo)
    258     max = maxhi;
    259   else
    260     max = maxlo + pixel.GetNumHiGainSamples();
    261  
    262   FindSignalandVarianceHiGain(pixel.GetHiGainSamples()+fHiGainFirst,sum,sum2,sat);
    263   if (pixel.HasLoGain())
    264     FindSignalandVarianceLoGain(pixel.GetLoGainSamples()+fLoGainFirst,sum,sum2,sat);
    265 
    266   const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1);
    267   const Float_t rms = TMath::Sqrt(var);
    268  
    269   //
    270   // FIXME: The following formulae have to be revised!!
    271   //
    272   fPINDiode->SetExtractedSignal(sum - fPedestal*fNumSamples, fPedRms*fSqrtSamples);
    273   fPINDiode->SetExtractedRms   (rms, rms/2./fSqrtSamples);
    274   fPINDiode->SetExtractedTime  (max, rms/fSqrtSamples);
    275   fPINDiode->SetSaturation(sat);
     298      if (*ptr >= fSaturationLimit)
     299        {
     300          sat++;
     301          break;
     302        }
     303
     304      const Float_t cont = (Float_t)*ptr - fPedMean[(cnt + higainabflag) & 0x1];
     305      fSlices->Fill(cnt,cont);
     306
     307      if (cont > max)
     308      {
     309        max = cont;
     310        maxpos = cnt;
     311      }
     312
     313      ptr++;
     314      cnt++;
     315    }
     316 
     317  cnt = 0;
     318 
     319  if (pixel.HasLoGain() && !sat)
     320    {
     321     
     322      ptr = pixel.GetLoGainSamples();
     323      end = ptr+logainsamples;
     324     
     325      const Bool_t logainabflag = (higainabflag + pixel.GetNumHiGainSamples()) & 0x1;
     326     
     327      while (ptr<end)
     328        {
     329         
     330          if (*ptr >= fSaturationLimit)
     331            {
     332              sat++;
     333              break;
     334            }
     335
     336          const Float_t cont = (Float_t)*ptr - fPedMean[(cnt + logainabflag) & 0x1];
     337         
     338          fSlices->Fill(cnt+ higainsamples,cont);
     339         
     340          if (cont > max)
     341            {
     342              max    = cont;
     343              maxpos = cnt+higainsamples;
     344            }
     345          ptr++;
     346          cnt++;
     347        }
     348    }
     349         
     350  if (sat)
     351    {
     352      fPINDiode->SetSaturation(1);
     353      return kTRUE;
     354    }
     355
     356  fSlices->Fit("gaus", "RQ", "", maxpos-fLowerFitLimit,maxpos+fUpperFitLimit);
     357 
     358  TF1 *gausfunc = fSlices->GetFunction("gaus");
     359
     360  fPINDiode->SetExtractedSignal(gausfunc->GetParameter(0), gausfunc->GetParError(0));
     361  fPINDiode->SetExtractedTime  (gausfunc->GetParameter(1), gausfunc->GetParError(1));
     362  fPINDiode->SetExtractedSigma (gausfunc->GetParameter(2), gausfunc->GetParError(2));
     363  fPINDiode->SetExtractedChi2  (gausfunc->GetChisquare());
    276364  fPINDiode->SetReadyToSave();
    277  
     365
    278366  return kTRUE;
    279367}
    280368
     369// ----------------------------------------------------------------------------------
     370//
     371// deletes fSlices and sets pointer to NULL
     372//
     373Int_t MExtractPINDiode::PostProcess()
     374{
     375 
     376  delete fSlices;
     377  fSlices = NULL;
     378 
     379  return kTRUE;
     380}
  • trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h

    r3962 r7043  
    1515#endif
    1616
     17#ifndef MARS_MArrayF
     18#include "MArrayF.h"
     19#endif
     20
     21class TH1F;
    1722class MExtractedSignalPINDiode;
     23
    1824class MExtractPINDiode : public MExtractor
    1925{
     
    2127
    2228  static const UInt_t fgPINDiodeIdx; 
    23   static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 3)
    24   static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 14)
    25   static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 3)
    26   static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to: 14)
     29  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (now set to: 3)
     30  static const Byte_t fgHiGainLast;      // Last  FADC slice Hi-Gain (now set to: 14)
     31  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (now set to: 3)
     32  static const Byte_t fgLoGainLast;      // Last  FADC slice Lo-Gain (now set to: 14)
    2733
    28   MExtractedSignalPINDiode  *fPINDiode;     // Extracted signal of the PIN Diode
     34  static const Byte_t fgLowerFitLimit;   // Default for fLowerFitLimit (now set to: 2)
     35  static const Byte_t fgUpperFitLimit;   // Default for fUpperFitLimit (now set to: 5)
    2936
    30   UInt_t  fPINDiodeIdx;
    31   Float_t fPedestal;
    32   Float_t fPedRms;
    33   Int_t   fNumSamples;
    34   Float_t fSqrtSamples;
     37  Byte_t fLowerFitLimit;                 // Number of FADC slices before maximum to start fit
     38  Byte_t fUpperFitLimit;                 // Number of FADC slices after maximum to end fit
    3539 
    36   void   FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
    37   void   FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
    38 
    39   Int_t  PreProcess(MParList *pList);
    40   Bool_t ReInit(MParList *pList); 
    41   Int_t  Process();
     40  MExtractedSignalPINDiode  *fPINDiode;  // Extracted signal of the PIN Diode
     41  TH1F                      *fSlices;    // Histogram to fit the slices
     42 
     43  UInt_t  fPINDiodeIdx;                  // PIN Diode pixel ID
     44 
     45  MArrayF fPedMean;                      // The used pedestals (0: ped+AB, 1: ped-AB)
     46 
     47  Int_t  PreProcess( MParList *pList );
     48  Bool_t ReInit    ( MParList *pList ); 
     49  Int_t  Process    ();
     50  Int_t  PostProcess();
    4251 
    4352public:
    4453
    4554  MExtractPINDiode(const char *name=NULL, const char *title=NULL);
     55  ~MExtractPINDiode(); 
    4656
    4757  // Setters
    4858  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
    49   void SetPINDiodeIdx(    const UInt_t idx=fgPINDiodeIdx    ) { fPINDiodeIdx     = idx; }   
     59  void SetPINDiodeIdx  ( const UInt_t idx=fgPINDiodeIdx    ) { fPINDiodeIdx   = idx; }
     60  void SetLowerFitLimit( const Byte_t lim=fgLowerFitLimit  ) { fLowerFitLimit = lim; }
     61  void SetUpperFitLimit( const Byte_t lim=fgUpperFitLimit  ) { fUpperFitLimit = lim; }     
    5062
    51   ClassDef(MExtractPINDiode, 0) // Signal Extractor for the PIN Diode
     63  ClassDef(MExtractPINDiode, 1) // Signal Extractor for the PIN Diode
    5264};
    5365
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc

    r7028 r7043  
    7878const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinHiGain    =  4;
    7979const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinLoGain    =  4;
    80 const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile        = "msignal/cosmics_weights46.dat";
     80const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile        = "msignal/cosmics_weights.dat";
    8181const Float_t MExtractTimeAndChargeDigitalFilter::fgOffsetLoGain           =  1.7; // 5 ns
    82 const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift       = -2.8;
     82const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift       = -1.8;
    8383
    8484// --------------------------------------------------------------------------
     
    753753
    754754    CalcBinningResArrays();
     755
     756    switch (fWindowSizeHiGain)
     757      {
     758      case 4:
     759        SetResolutionPerPheHiGain(0.036);
     760        break;
     761      case 6:
     762        SetResolutionPerPheHiGain(0.021);
     763        break;
     764      default:
     765        *fLog << warn << "Could not set the high-gain extractor resolution per phe for window size "
     766              << fWindowSizeHiGain << endl;
     767      }
     768
     769    switch (fWindowSizeLoGain)
     770      {
     771      case 4:
     772        SetResolutionPerPheLoGain(0.005);
     773        break;
     774      case 6:
     775        SetResolutionPerPheLoGain(0.004);
     776        break;
     777      default:
     778        *fLog << warn << "Could not set the low-gain extractor resolution per phe for window size "
     779              << fWindowSizeLoGain << endl;
     780      }
    755781
    756782    fWeightsSet = kTRUE;
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.cc

    r6840 r7043  
    7676const Byte_t  MExtractTimeAndChargeSlidingWindow::fgHiGainWindowSize = 6;
    7777const Byte_t  MExtractTimeAndChargeSlidingWindow::fgLoGainWindowSize = 6;
     78
    7879// --------------------------------------------------------------------------
    7980//
     
    176177  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
    177178
     179  switch (fWindowSizeHiGain)
     180    {
     181    case 2:
     182      SetResolutionPerPheHiGain(0.050);
     183      break;
     184    case 4:
     185      SetResolutionPerPheHiGain(0.039);
     186      break;
     187    case 6:
     188    case 8:
     189      SetResolutionPerPheHiGain(0.011);
     190      break;
     191    case 14:
     192      SetResolutionPerPheHiGain(0.009);
     193      break;
     194    default:
     195      *fLog << warn << GetDescriptor() << ": Could not set the high-gain extractor resolution per phe for window size "
     196            << fWindowSizeHiGain << endl;
     197    }
     198 
     199  switch (fWindowSizeLoGain)
     200    {
     201    case 2:
     202      SetResolutionPerPheLoGain(0.028);
     203      break;
     204    case 4:
     205      SetResolutionPerPheLoGain(0.013);
     206      break;
     207    case 6:
     208      SetResolutionPerPheLoGain(0.008);
     209      break;
     210    case 8:
     211    case 10:
     212      SetResolutionPerPheLoGain(0.005);
     213      break;
     214    default:
     215      *fLog << warn << GetDescriptor() << ": Could not set the low-gain extractor resolution per phe for window size "
     216            << fWindowSizeLoGain << endl;
     217    }
    178218}
    179219
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSlidingWindow.h

    r5511 r7043  
    1111
    1212class MPedestalPix;
     13
    1314class MExtractTimeAndChargeSlidingWindow : public MExtractTimeAndCharge
    1415{
    15 
    1616private:
    17  
    1817  static const Byte_t fgHiGainFirst;      //! Default for fHiGainFirst  (now set to: 2)
    1918  static const Byte_t fgHiGainLast;       //! Default for fHiGainLast   (now set to: 14)
     
    4948                               Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag);
    5049
    51   ClassDef(MExtractTimeAndChargeSlidingWindow, 0)   // Task to Extract Times and Charges using a Sliding Window
     50  ClassDef(MExtractTimeAndChargeSlidingWindow, 1)   // Task to Extract Times and Charges using a Sliding Window
    5251};
    5352
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc

    r7034 r7043  
    233233      fWindowSizeLoGain  = 1;
    234234      fRiseTimeHiGain    = 0.5;
     235
     236      SetResolutionPerPheHiGain(0.053);
     237      SetResolutionPerPheLoGain(0.016);
    235238     
    236239      return;
     
    242245      fNumHiGainSamples  = fRiseTimeHiGain + fFallTimeHiGain;
    243246      fNumLoGainSamples  = fLoGainLast ? fRiseTimeLoGain + fFallTimeLoGain : 0.;
    244       //      fNumLoGainSamples  *= 0.75;     
    245247
    246248      fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
    247249      fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
    248       fWindowSizeHiGain  = (Int_t)(fRiseTimeHiGain + fFallTimeHiGain);
    249       fWindowSizeLoGain  = (Int_t)((fRiseTimeLoGain + fFallTimeLoGain)*fLoGainStretch);
    250       //      fNumLoGainSamples  *= 0.75;     
    251     }
     250      fWindowSizeHiGain  = TMath::Nint(fRiseTimeHiGain + fFallTimeHiGain);
     251      // to ensure that for the case: 1.5, the window size becomes: 2 (at any compiler)
     252      fWindowSizeLoGain  = TMath::Nint(TMath::Ceil((fRiseTimeLoGain + fFallTimeLoGain)*fLoGainStretch));
     253    }
     254
     255    switch (fWindowSizeHiGain)
     256    {
     257    case 1:
     258      SetResolutionPerPheHiGain(0.041);
     259      break;
     260    case 2:
     261      SetResolutionPerPheHiGain(0.064);
     262      break;
     263    case 3:
     264    case 4:
     265      SetResolutionPerPheHiGain(0.050);
     266      break;
     267    case 5:
     268    case 6:
     269      SetResolutionPerPheHiGain(0.030);
     270      break;
     271    default:
     272        *fLog << warn << GetDescriptor() << ": Could not set the high-gain extractor resolution per phe for window size "
     273              << fWindowSizeHiGain << endl;
     274        break;
     275    }
     276
     277    switch (fWindowSizeLoGain)
     278    {
     279    case 1:
     280    case 2:
     281      SetResolutionPerPheLoGain(0.005);
     282      break;
     283    case 3:
     284    case 4:
     285      SetResolutionPerPheLoGain(0.017);
     286      break;
     287    case 5:
     288    case 6:
     289    case 7:
     290      SetResolutionPerPheLoGain(0.005);
     291      break;
     292    case 8:
     293    case 9:
     294      SetResolutionPerPheLoGain(0.005);
     295      break;
     296    default:
     297        *fLog << warn << "Could not set the low-gain extractor resolution per phe for window size "
     298              << fWindowSizeLoGain << endl;
     299        break;
     300     }
    252301}
    253302
  • trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.cc

    r3322 r7043  
    3939
    4040using namespace std;
    41 
    42 static const Float_t gkSignalInitializer = 99999.9;
    43 
    4441// ------------------------------------------------------------------------
    4542//
     
    4946// Additionally, the number of saturated Slices are stored.
    5047//
    51 // Default values for the extracted signals are: 99999.9
     48// Default values for the extracted signals are: -1.
    5249//
    5350MExtractedSignalPINDiode::MExtractedSignalPINDiode(const char* name, const char* title)
     
    6259// ------------------------------------------------------------------------
    6360//
    64 // Invalidate values
     61// Invalidate values to -1.
    6562//
    6663void MExtractedSignalPINDiode::Clear(Option_t *o)
    6764{
    68   fExtractedSignal          = gkSignalInitializer;
    69   fExtractedSignalErr       = gkSignalInitializer;
    70   fExtractedTime            = gkSignalInitializer;
    71   fExtractedTimeErr         = gkSignalInitializer;
    72   fExtractedRms             = gkSignalInitializer;
    73   fExtractedRmsErr          = gkSignalInitializer;
    7465
    75   fNumSaturated       = 0;
     66  fExtractedSignal          = -1.;
     67  fExtractedSignalErr       = -1.;
     68  fExtractedTime            = -1.;
     69  fExtractedTimeErr         = -1.;
     70  fExtractedSigma           = -1.;
     71  fExtractedSigmaErr        = -1.;
     72  fExtractedChi2            = -1.;
     73
     74  fSaturated  = kFALSE;
     75 
    7676}
    7777
     
    8585void MExtractedSignalPINDiode::SetExtractedSignal(const Float_t sig, const Float_t sigerr)   
    8686{
    87   fExtractedSignal      = sig;
     87  fExtractedSignal    = sig;
    8888  fExtractedSignalErr = sigerr;
    8989}
    9090
    91 void MExtractedSignalPINDiode::SetExtractedRms(const Float_t sig, const Float_t sigerr)   
     91void MExtractedSignalPINDiode::SetExtractedSigma(const Float_t sig, const Float_t sigerr)   
    9292{
    93   fExtractedRms      = sig;
    94   fExtractedRmsErr = sigerr;
     93  fExtractedSigma    = sig;
     94  fExtractedSigmaErr = sigerr;
    9595}
    9696
    9797void MExtractedSignalPINDiode::SetExtractedTime(const Float_t sig, const Float_t sigerr)   
    9898{
    99   fExtractedTime      = sig;
     99  fExtractedTime    = sig;
    100100  fExtractedTimeErr = sigerr;
    101101}
    102102
    103 
    104103Bool_t MExtractedSignalPINDiode::IsValid() const
    105104{
    106     return fExtractedSignal >= 0. || fExtractedSignalErr >= 0.;
    107 }
    108 
    109 void MExtractedSignalPINDiode::SetSaturation(const Byte_t numsat)
    110 {
    111   fNumSaturated = numsat;
     105  if (fSaturated)
     106    return kFALSE;
     107 
     108  return fExtractedSignal >= 0. || fExtractedSignalErr >= 0.;
    112109}
    113110
    114111void MExtractedSignalPINDiode::Print(Option_t *o) const
    115112{
    116   *fLog << " Signal: " << fExtractedSignal
    117         << " +- " << fExtractedSignalErr
    118         << " Nr. Saturation: " <<  fNumSaturated
     113  *fLog << Form(" Signal: %4.2f+-%4.2f",fExtractedSignal,fExtractedSignalErr)
     114        << Form(" Arr.Time: %4.2f+-%4.2f",fExtractedTime,fExtractedTimeErr)
     115        << Form(" Sigma: %4.2f+-%4.2f",fExtractedSigma,fExtractedSigmaErr)
     116        << Form(" Chi2: %5.2f",fExtractedChi2)
     117        << Form(" Saturation: %s",fSaturated ? "yes" : "no")
    119118        << endl;
    120119}
  • trunk/MagicSoft/Mars/msignal/MExtractedSignalPINDiode.h

    r4274 r7043  
    1010private:
    1111
    12   Float_t fExtractedSignal;    // mean value of the extracted signal
    13   Float_t fExtractedSignalErr; // error of the mean value of the extracted signal
    14   Float_t fExtractedTime;
    15   Float_t fExtractedTimeErr;
    16   Float_t fExtractedRms;
    17   Float_t fExtractedRmsErr;
    18 
    19   Byte_t fFirst;
    20   Byte_t fNumFADCSamples;
    21   Byte_t fNumSaturated;
     12  Float_t fExtractedSignal;    // Extracted signal amplitude
     13  Float_t fExtractedSignalErr; // Error extracted signal amplitude
     14  Float_t fExtractedTime;      // Position of signal amplitude
     15  Float_t fExtractedTimeErr;   // Error position of signal amplitude
     16  Float_t fExtractedSigma;     // Width Gauss fit
     17  Float_t fExtractedSigmaErr;  // Error of width
     18  Float_t fExtractedChi2;      // Chi2 Gauss fit   
     19 
     20  Byte_t fNumFADCSamples;      // Number of used FADC slices
     21  Byte_t fFirst;               // First FADC slice to start extraction
     22 
     23  Bool_t fSaturated;           // FADC saturation occurrance flag
    2224
    2325public:
    24     MExtractedSignalPINDiode(const char* name=NULL, const char* title=NULL);
    2526
    26     void Clear(Option_t *o="");
    27     void Print(Option_t *o="") const;
     27  MExtractedSignalPINDiode(const char* name=NULL, const char* title=NULL);
     28 
     29  void Clear(Option_t *o="");
     30 
     31  // Getter
     32  Float_t GetExtractedSignal()    const { return fExtractedSignal;       }
     33  Float_t GetExtractedSignalErr() const { return fExtractedSignalErr;    }
     34  Float_t GetExtractedTime()      const { return fExtractedTime;         }
     35  Float_t GetExtractedTimeErr()   const { return fExtractedTimeErr;      }
     36  Float_t GetExtractedSigma()     const { return fExtractedSigma;        }
     37  Float_t GetExtractedSigmaErr()  const { return fExtractedSigmaErr;     }
     38  Float_t GetExtractedChi2()      const { return fExtractedChi2;         } 
     39  Byte_t  GetNumFADCSamples()     const { return fNumFADCSamples;        }
     40 
     41  Bool_t  IsValid()    const;   
     42 
     43  // Print
     44  void Print(Option_t *o="") const;
    2845
    29     // Setter
    30     void SetExtractedSignal(const Float_t sig, const Float_t sigerr);
    31     void SetExtractedRms(  const Float_t sig, const Float_t sigerr);
    32     void SetExtractedTime(  const Float_t sig, const Float_t sigerr);
    33     void SetSaturation(   const Byte_t numsat);
    34     void SetUsedFADCSlices( const Byte_t first, const Byte_t num);
    35    
    36     // Getter
    37     Float_t GetExtractedSignal()    const { return fExtractedSignal;       }
    38     Float_t GetExtractedSignalErr() const { return fExtractedSignalErr;    }
    39     Float_t GetExtractedTime()      const { return fExtractedTime;         }
    40     Float_t GetExtractedTimeErr()   const { return fExtractedTimeErr;      }
    41     Float_t GetExtractedRms()       const { return fExtractedRms;          }
    42     Float_t GetExtractedRmsErr()    const { return fExtractedRmsErr;       }
    43     Byte_t  GetNumFADCSamples()     const { return fNumFADCSamples;        }
    44     Byte_t  GetFirstUsedSlice()     const { return fFirst;                 }
    45     Byte_t  GetLastUsedSlice()      const { return fFirst+fNumFADCSamples; }   
    46    
    47     Bool_t IsValid() const;   
     46  // Setter
     47  void SetExtractedSignal(const Float_t sig, const Float_t sigerr);
     48  void SetExtractedSigma(  const Float_t sig, const Float_t sigerr);
     49  void SetExtractedTime(  const Float_t sig, const Float_t sigerr);
     50  void SetExtractedChi2(  const Float_t chi ) { fExtractedChi2 = chi; }
     51  void SetSaturation  (   const Bool_t b=kTRUE) { fSaturated = b;  }
     52  void SetUsedFADCSlices( const Byte_t first, const Byte_t num);
    4853
    49     ClassDef(MExtractedSignalPINDiode, 1)       // Storage Container for Extracted Signal information of one pixel
     54  ClassDef(MExtractedSignalPINDiode, 2) // Storage Container for Extracted Signal information of one pixel
    5055};
    5156
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r6820 r7043  
    6464//End_Html
    6565//
     66// Class Version 6:
     67//  +Float_t fResolutionPerPheHiGain; // Extractor-dependent charge resolution per phe for high-gain (see TDAS-0502).
     68//  +Float_t fResolutionPerPheLoGain; // Extractor-dependent charge resolution per phe for low-gain  (see TDAS-0502).
     69//
     70//
    6671// Input Containers:
    6772//   MRawEvtData
     
    100105const TString MExtractor::fgNameSignalCam   = "MExtractedSignalCam";
    101106const Float_t MExtractor::fgOffsetLoGain    = 1.51;   // 5 ns
     107
    102108// --------------------------------------------------------------------------
    103109//
     
    116122//
    117123MExtractor::MExtractor(const char *name, const char *title)
    118     : fPedestals(NULL), fSignals(NULL), fRawEvt(NULL), fRunHeader(NULL),
    119       fHiLoLast(0), fNumHiGainSamples(0.), fNumLoGainSamples(0.)
     124    : fResolutionPerPheHiGain(0), fResolutionPerPheLoGain(0),
     125      fPedestals(NULL), fSignals(NULL), fRawEvt(NULL), fRunHeader(NULL),
     126      fHiLoLast(0), fNumHiGainSamples(0), fNumLoGainSamples(0)
    120127{
    121128    fName  = name  ? name  : "MExtractor";
  • trunk/MagicSoft/Mars/msignal/MExtractor.h

    r6820 r7043  
    2323{
    2424private:
    25 
    2625  static const Float_t fgOffsetLoGain;     //! Default for fOffsetLoGain (now set to 1.51 (= 5ns)
    2726 
    2827  Bool_t  fNoiseCalculation;               //! Flag if extractor determines noise contribution from pedestal file.
     28
     29  Float_t fResolutionPerPheHiGain;         // Extractor-dependent charge resolution per phe for high-gain (see TDAS-0502).
     30  Float_t fResolutionPerPheLoGain;         // Extractor-dependent charge resolution per phe for low-gain  (see TDAS-0502).
    2931 
    3032protected:
    31 
    3233  static const Byte_t  fgSaturationLimit;  //! Default for fSaturationLimit (now set to: 254)
    3334  static const TString fgNamePedestalCam;  //! "MPedestalCam"
     
    5455  Float_t  fSqrtHiGainSamples;             // Sqrt. nr. High Gain FADC slices used to extract the signal
    5556  Float_t  fSqrtLoGainSamples;             // Sqrt. nr. Low  Gain FADC slices used to extract the signal
    56                                            
     57
    5758  Byte_t   fSaturationLimit;               // Highest FADC slice value until being declared saturated
     59
    5860  TString  fNamePedestalCam;               // Name of the 'MPedestalCam' container
    5961  TString  fNameSignalCam;                 // Name of the 'MExtractedSignalCam' container
    6062
     63  // MExtractor
    6164  virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { }
    6265  virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const { }
    63  
     66
     67  void SetResolutionPerPheHiGain(Float_t f) { fResolutionPerPheHiGain=f; }
     68  void SetResolutionPerPheLoGain(Float_t f) { fResolutionPerPheLoGain=f; }
     69
    6470  Int_t   PreProcessStd(MParList *pList);
     71
     72  // MTask
    6573  Int_t   PreProcess( MParList *pList );
    6674  Bool_t  ReInit    ( MParList *pList );
     
    6977  Int_t   ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    7078
     79
    7180public:
    7281  MExtractor(const char *name=NULL, const char *title=NULL);
    7382 
    74   void Clear(Option_t *o="")
    75     {
    76       fHiGainFirst = fHiGainLast = fLoGainFirst = fLoGainLast = fHiLoLast = 0;
    77     }
    78 
     83  // getter
    7984  Byte_t  GetHiGainFirst()      const { return fHiGainFirst;      }
    8085  Byte_t  GetHiGainLast ()      const { return fHiGainLast ;      }
     
    8691
    8792  Bool_t  IsNoiseCalculation () const { return fNoiseCalculation; }
    88  
     93
     94  // Setter
     95  Float_t SetResolutionPerPheHiGain() const { return fResolutionPerPheHiGain; }
     96  Float_t SetResolutionPerPheLoGain() const { return fResolutionPerPheLoGain; }
     97
    8998  virtual void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
    9099
     
    97106  void SetPedestals (MPedestalCam *pedcam)   { fPedestals = pedcam; }
    98107
     108  // TObject
     109  void Clear(Option_t *o="")
     110    {
     111      fHiGainFirst = fHiGainLast = fLoGainFirst = fLoGainLast = fHiLoLast = 0;
     112    }
     113
    99114  void Print(Option_t *o="") const;
    100115
    101   ClassDef(MExtractor, 5) // Signal Extractor Base Class
     116  ClassDef(MExtractor, 6) // Signal Extractor Base Class
    102117};
    103118
Note: See TracChangeset for help on using the changeset viewer.