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

Legend:

Unmodified
Added
Removed
  • 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.