Ignore:
Timestamp:
07/14/04 18:12:32 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc

    r4342 r4374  
    6161using namespace std;
    6262
    63 const Int_t   MExtractBlindPixel::fgBlindPixelIdx  = 559;
    64 const Int_t   MExtractBlindPixel::fgNSBFilterLimit =  70;
    65 const Byte_t  MExtractBlindPixel::fgHiGainFirst    =  10;
    66 const Byte_t  MExtractBlindPixel::fgHiGainLast     =  29;
    67 const Byte_t  MExtractBlindPixel::fgLoGainFirst    =   0;
    68 const Byte_t  MExtractBlindPixel::fgLoGainLast     =   6;
    69 const Float_t MExtractBlindPixel::fgResolution    = 0.003;
     63const UInt_t  MExtractBlindPixel::fgBlindPixelIds[3] = { 559, 560, 561 };
     64const UInt_t  MExtractBlindPixel::fgBlindPixelIdx    = 559;
     65const Byte_t  MExtractBlindPixel::fgFirst            =   0;
     66const Byte_t  MExtractBlindPixel::fgLast             =   7;
     67const Byte_t  MExtractBlindPixel::fgHiGainFirst      =  10;
     68const Byte_t  MExtractBlindPixel::fgHiGainLast       =  29;
     69const Byte_t  MExtractBlindPixel::fgLoGainFirst      =   0;
     70const Byte_t  MExtractBlindPixel::fgLoGainLast       =   6;
     71const Int_t   MExtractBlindPixel::fgNSBFilterLimit   =  70;
     72const Float_t MExtractBlindPixel::fgResolution       = 0.003;
     73const UInt_t  MExtractBlindPixel::gkModificationRun  = 31693;
     74const Float_t MExtractBlindPixel::gkOverflow         = 300.;
    7075// --------------------------------------------------------------------------
    7176//
     
    7681// - fNSBFilterLimit to fgNSBFilterLimit
    7782// - fResolution to fgResolution
     83// - fExtractionType to kAmplitude
    7884//
    7985// Calls:
     
    9197  AddToBranchList("MRawEvtData.*");
    9298
    93   fBlindPixelIdx.Set(1);
    94  
    95   SetBlindPixelIdx();
    9699  SetResolution();
    97100  SetNSBFilterLimit();
    98101  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
    99 
    100 }
    101 
     102 
     103  SetFirst();
     104  SetLast();
     105
     106  SetExtractionType();
     107
     108  Clear();
     109
     110}
     111
     112// --------------------------------------------------------------------------
     113//
     114// Destructor:
     115//
     116// - Deletes, (if not NULL):
     117//   fHiGainSignal;
     118//   fHiGainFirstDeriv;
     119//   fHiGainSecondDeriv;
     120//
    102121MExtractBlindPixel::~MExtractBlindPixel()
    103122{
    104123
    105124  if (fHiGainSignal)
    106     delete fHiGainSignal;
     125    delete [] fHiGainSignal;
    107126  if (fHiGainFirstDeriv)
    108     delete fHiGainFirstDeriv;
     127    delete [] fHiGainFirstDeriv;
    109128  if (fHiGainSecondDeriv)
    110     delete fHiGainSecondDeriv;
     129    delete [] fHiGainSecondDeriv;
     130
     131}
     132
     133// --------------------------------------------------------------------------
     134//
     135// Clear
     136//
     137// Initializes:
     138// - fModified to kFALSE
     139// - fBlindPixelIdx to 0
     140//
     141// Calls:
     142// - SetBlindPixelIdx()
     143//
     144// Deletes and sets to NULL (if exists):
     145// - fHiGainSignal
     146// - fHiGainFirstDeriv
     147// - fHiGainSecondDeriv
     148//
     149void MExtractBlindPixel::Clear( const Option_t *o)
     150{
     151
     152  fModified = kFALSE;
     153
     154  fBlindPixelIdx.Set(0);
     155  SetBlindPixelIdx();
     156
     157  if (fHiGainSignal)
     158    {
     159      delete [] fHiGainSignal;
     160      fHiGainSignal = NULL;
     161    }
     162  if (fHiGainFirstDeriv)
     163    {
     164      delete [] fHiGainFirstDeriv;
     165      fHiGainFirstDeriv = NULL;
     166    }
     167  if (fHiGainSecondDeriv)
     168    {
     169      delete [] fHiGainSecondDeriv;
     170      fHiGainSecondDeriv = NULL;
     171    }
    111172
    112173}
     
    129190// --------------------------------------------------------------------------
    130191//
    131 // The PreProcess searches for the following input containers:
    132 //  - MRawEvtData
     192// Calls:
     193// - MExtractor::PreProcess(pList)
     194//
     195// Sets fModified to kTRUE if the current run number is greater or equal gkModificationRun
    133196//
    134197// The following output containers are also searched and created if
     
    137200//  - MExtractedBlindPixel
    138201//
     202//
     203//
    139204Int_t MExtractBlindPixel::PreProcess(MParList *pList)
    140205{
     
    142207  if (!MExtractor::PreProcess(pList))
    143208    return kFALSE;
    144  
     209
    145210  fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
    146211  if (!fBlindPixel)
    147212    return kFALSE;
    148213
    149   fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(0));
    150   fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
    151  
    152   MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx.At(0)];   
    153  
    154   if (&pedpix)
    155     {
    156       fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples );
    157       fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples
    158                                  / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) );
    159       fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples) );
    160       fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. );
    161     }
    162214 
    163215  return kTRUE;
     
    184236 
    185237  if (fHiGainSignal)
    186     delete fHiGainSignal;
     238    delete [] fHiGainSignal;
    187239  if (fHiGainFirstDeriv)
    188     delete fHiGainFirstDeriv;
     240    delete [] fHiGainFirstDeriv;
    189241  if (fHiGainSecondDeriv)
    190     delete fHiGainSecondDeriv;
     242    delete [] fHiGainSecondDeriv;
     243
     244  if ( fRunHeader->GetRunNumber() >= gkModificationRun )
     245  {
     246      fModified = kTRUE;
     247      SetRange(fFirst,fLast);
     248      for (Int_t i=0;i<3;i++)
     249      {
     250          SetBlindPixelIdx(fgBlindPixelIds[i],i);
     251          fBlindPixel->SetBlindPixelIdx(fgBlindPixelIds[i],i);
     252      }
     253  }
     254  else
     255  {
     256      fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(0));
     257  }
     258
     259  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
     260 
     261  for (Int_t i=0;i<fBlindPixelIdx.GetSize();i++)
     262  {
     263
     264      MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx.At(i)];   
     265     
     266      if (&pedpix)
     267      {
     268          fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples, i );
     269          fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples
     270                                 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()), i );
     271          fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples), i );
     272          fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2., i );
     273      }
     274  }
    191275
    192276  const Int_t firstdesired   = (Int_t)fHiGainFirst;
     
    194278 
    195279  if (firstdesired > lastavailable)
    196     {
     280  {
    197281      const Int_t diff = firstdesired - lastavailable;
    198282      *fLog << endl;
     
    235319  const Int_t range = fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
    236320
    237   fHiGainSignal = new Float_t[range];
     321  fHiGainSignal      = new Float_t[range];
    238322  memset(fHiGainSignal,0,range*sizeof(Float_t));
    239   fHiGainFirstDeriv = new Float_t[range];
     323  fHiGainFirstDeriv  = new Float_t[range];
    240324  memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
    241325  fHiGainSecondDeriv = new Float_t[range];
    242326  memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
    243 
    244327
    245328  *fLog << endl;
     
    267350// - Add contents of *logain to sum
    268351//
    269 void MExtractBlindPixel::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
     352void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
    270353{
    271354
     
    309392// - Add contents of *logain to sum
    310393//
    311 void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
     394void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
    312395{
    313396
     
    325408
    326409      range = fHiGainLast - fHiGainFirst + 1;
     410
    327411      end   = ptr + range;
    328412      //
    329413      // Check for saturation in all other slices
    330414      //
    331       while (++p<end)
     415      while (p++<end)
     416        {
     417         
     418          fHiGainSignal[count] = (Float_t)*p;
     419          summ += *p;
     420
     421          if (*p > max)
     422            {
     423              max    = *p;
     424              maxpos =  count;
     425            }
     426         
     427          count++;
     428
     429          if (*p >= fSaturationLimit)
     430              sat++;
     431        }
     432    }
     433 
     434  if (fHiLoLast != 0)
     435    {
     436     
     437      p    = logain + fHiLoFirst;
     438      end  = logain + fHiLoLast + 1;
     439     
     440      while (p<end)
    332441        {
    333442         
     
    344453          count++;
    345454
    346           if (*p >= fSaturationLimit)
    347             {
     455          if (*p++ >= fSaturationLimit)
    348456              sat++;
    349               break;
    350             }
    351457        }
    352458    }
    353  
    354   if (fHiLoLast != 0)
    355     {
    356      
    357       p    = logain + fHiLoFirst;
    358       end  = logain + fHiLoLast + 1;
    359      
    360       while (p<end)
    361         {
    362          
    363           fHiGainSignal[count] = (Float_t)*p;
    364           summ += *p;
    365 
    366           if (*p > max)
    367             {
    368               max    = *p;
    369               maxpos =  count;
    370             }
    371          
    372           range++;
    373           count++;
    374 
    375           if (*p++ >= fSaturationLimit)
    376             {
    377               sat++;
    378               break;
    379             }
    380         }
    381     }
    382 
    383   //  sum = (Float_t)summ;
    384   //  return;
    385  
     459
    386460  //
    387461  // allow one saturated slice
    388462  //
    389463  if (sat > 1)
     464  {
     465    sum = gkOverflow;
    390466    return;
     467  }
    391468
    392469  //
     
    394471  //
    395472  if (maxpos < 2)
     473  {
     474    sum = (Float_t)max;
    396475    return;
     476  }
    397477
    398478  Float_t pp;
    399   fHiGainSecondDeriv[0] = 0.;
    400   fHiGainFirstDeriv[0]  = 0.;
    401479
    402480  for (Int_t i=1;i<range-1;i++)
     
    586664    {
    587665 
    588       pixel.Jump(fBlindPixelIdx.At(id));
     666      pixel.Jump(fBlindPixelIdx[id]);
    589667     
    590668      Int_t sum   = 0;
    591669      Byte_t sat  = 0;
    592670
    593       FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
    594 
    595       if (sum > fNSBFilterLimit)
    596         {
    597           fBlindPixel->SetExtractedSignal(-1.);
    598           fBlindPixel->SetNumSaturated(sat);
    599           fBlindPixel->SetReadyToSave();
    600           continue;
    601         }
    602      
     671      if (!fModified)
     672      {
     673
     674          FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
     675         
     676          if (sum > fNSBFilterLimit)
     677          {
     678              fBlindPixel->SetExtractedSignal(-1.);
     679              fBlindPixel->SetNumSaturated(sat);
     680              fBlindPixel->SetReadyToSave();
     681              continue;
     682          }
     683      }
     684
    603685      Float_t newsum = 0.;
    604686      sat = 0;
    605687     
    606       FindSignalHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
     688      if (IsExtractionType(kAmplitude))
     689        FindAmplitude   (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
     690      else
     691        FindIntegral    (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
    607692 
    608693      fBlindPixel->SetExtractedSignal(newsum,id);
     
    614699}
    615700
     701// --------------------------------------------------------------------------
     702//
     703// Sets the extraction type. Available are: kAmplitude and kIntegral
     704//
     705Bool_t MExtractBlindPixel::IsExtractionType( const ExtractionType_t typ )
     706{
     707 
     708  return TESTBIT( fExtractionType, typ );
     709
     710}
     711
     712// --------------------------------------------------------------------------
     713//
     714// Sets the extraction type. Available are: kAmplitude and kIntegral
     715//
     716void MExtractBlindPixel::SetExtractionType( const ExtractionType_t typ )
     717{
     718 
     719  fExtractionType = 0;
     720  SETBIT( fExtractionType, typ );
     721
     722}
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h

    r4342 r4374  
    11#ifndef MARS_MExtractBlindPixel
    22#define MARS_MExtractBlindPixel
    3 
    4 /////////////////////////////////////////////////////////////////////////////
    5 //                                                                         //
    6 // MExtractBlindPixel                                                      //
    7 //                                                                         //
    8 // Integrates the time slices of the all pixels of a calibration event     //
    9 // and substract the pedestal value                                        //
    10 //                                                                         //
    11 /////////////////////////////////////////////////////////////////////////////
    123
    134#ifndef MARS_MExtractor
     
    2415private:
    2516
    26   static const Int_t  fgBlindPixelIdx;
    27   static const Int_t  fgNSBFilterLimit; 
    28   static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 0)
    29   static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 11)
    30   static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 0)
    31   static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to:  2)
    32   static const Float_t fgResolution;     // Default for fResolution   (now set to: 0.003)
    33  
    34   MExtractedSignalBlindPixel  *fBlindPixel;   // Extracted signal of the Blind Pixel
     17  static const UInt_t  fgBlindPixelIds[3]; //! Default blind pixel indices after modification run
     18  static const UInt_t  fgBlindPixelIdx;    //! Default blind pixels index before modification run
     19  static const Byte_t  fgFirst;            //! Default First FADC slice after modification run (currently set to: 2  )
     20  static const Byte_t  fgLast ;            //! Default Last  FADC slice after modification run (currently set to: 13 )
     21  static const Byte_t  fgHiGainFirst;      //! Default First FADC slice Hi-Gain Signal (currently set to: 10   )
     22  static const Byte_t  fgHiGainLast;       //! Default Last  FADC slice Hi-Gain Signal (currently set to: 29   )
     23  static const Byte_t  fgLoGainFirst;      //! Default First FADC slice Filter         (currently set to: 0    )
     24  static const Byte_t  fgLoGainLast;       //! Default Last  FADC slice Filter         (currently set to: 6    )
     25  static const Int_t   fgNSBFilterLimit;   //! Default for fNSBFilterLimit
     26  static const Float_t fgResolution;       //! Default for fResolution         (currently set to: 0.003)
     27  static const UInt_t  gkModificationRun;  //! The run number from which on three blind pixels are used
     28  static const Float_t gkOverflow;         //! Default sum to assign overflow in case of saturation
    3529
    36   Byte_t  fHiLoFirst;
     30  MExtractedSignalBlindPixel  *fBlindPixel;  // Extracted signal of the Blind Pixel
     31
     32  Byte_t   fFirst;
     33  Byte_t   fLast;
     34  Byte_t   fHiLoFirst;
    3735  Float_t *fHiGainSignal;                     // Need fast access to the signals in a float way
    3836  Float_t *fHiGainFirstDeriv;
     
    4341  Int_t   fNSBFilterLimit; 
    4442
    45   void FindAmplitude(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const;
    46   void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const;
    47   void FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const;
     43  Bool_t  fModified;
     44  Byte_t  fExtractionType;                   
     45
     46  enum ExtractionType_t { kAmplitude, kIntegral };
     47
     48  void FindAmplitude   (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
     49  void FindIntegral    (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
     50  void FindSignalFilter(Byte_t *ptr,                          Int_t &sum, Byte_t &sat) const;
    4851 
    4952  Int_t  PreProcess(MParList *pList);
     
    5558  MExtractBlindPixel(const char *name=NULL, const char *title=NULL);
    5659  ~MExtractBlindPixel();
     60
     61  void Clear( const Option_t *o ="");
    5762 
     63  // Getters
     64  Bool_t IsExtractionType ( const ExtractionType_t typ );
     65
    5866  // Setters
    59   void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
     67  void SetExtractionType( const ExtractionType_t typ=kAmplitude );
     68  void SetFirst( const Byte_t first=fgFirst) { fFirst = first; }
     69  void SetLast ( const Byte_t last =fgLast)  { fLast  = last; }
     70  void SetRange( const Byte_t hifirst=0, const Byte_t hilast=0,
     71                 const Byte_t lofirst=0, const Byte_t lolast=0);
    6072  void SetBlindPixelIdx(  const  Int_t idx=fgBlindPixelIdx, const Int_t nr=0) {
    61     if (nr>fBlindPixelIdx.GetSize()+1)
     73    if (nr>fBlindPixelIdx.GetSize()-1)
    6274      fBlindPixelIdx.Set(nr+1);
    6375    fBlindPixelIdx.AddAt(idx,nr); }
  • trunk/MagicSoft/Mars/msignal/MExtractedSignalBlindPixel.cc

    r4311 r4374  
    2727// MExtractedSignalBlindPixel
    2828//
    29 // This is the storage container to hold informations about the extracted signal
    30 // (offset) value of the calibration Blind Pixel.
    31 //
     29// The storage container of the extracted signal of the calibration Blind Pixel(s).
     30// Additionally, the number of saturated Slices are stored.
    3231// There is place for various blind pixels set into the camera in  July. Default
    3332// is one blind pixel.
     33//
     34// Default values for the extracted signals are: gkSignalInitializer
    3435//
    3536/////////////////////////////////////////////////////////////////////////////
     
    4748// ------------------------------------------------------------------------
    4849//
    49 // MExtractedSignalBlindPixel holds the extracted signal
    50 // of the FADC slices and its error.
    5150//
    52 // Additionally, the number of saturated Slices are stored.
    53 //
    54 // Default values for the extracted signals are: 99999.9
     51// Sets:
     52// - the dimenstion of fBlindPixelIdx to 1
     53// - the dimenstion of fExtractedSignal to 1
     54// - the dimenstion of fNumSaturated to 1
     55// - the dimenstion of fPed. to 1;     
     56// - the dimenstion of fPedErr. to 1;)   
     57// - the dimenstion of fPedRms. to 1;   
     58// - the dimenstion of fPedRmsErr. to 1;
     59//
     60// Calls:
     61// - Clear()
    5562//
    5663MExtractedSignalBlindPixel::MExtractedSignalBlindPixel(const char* name, const char* title)
     
    7481// ------------------------------------------------------------------------
    7582//
    76 // Invalidate values
     83// Set values of:
     84// - fNumSaturated   
     85// - fExtractedSignal
     86// to gkSignalInitializer
    7787//
    7888void MExtractedSignalBlindPixel::Clear(Option_t *o)
     
    8393      fNumSaturated   .AddAt(gkSignalInitializer,i);
    8494      fExtractedSignal.AddAt(gkSignalInitializer,i);
    85       fPed            .AddAt(gkSignalInitializer,i);     
    86       fPedErr         .AddAt(gkSignalInitializer,i);   
    87       fPedRms         .AddAt(gkSignalInitializer,i);   
    88       fPedRmsErr      .AddAt(gkSignalInitializer,i); 
    8995    }
    90  
    9196}
    9297
     98// ------------------------------------------------------------------------
     99//
     100// Set number num of used FADC slices, starting from (including) first
     101//
    93102void MExtractedSignalBlindPixel::SetUsedFADCSlices(const Byte_t first, const Byte_t num)   
    94103{
     
    97106}
    98107
    99 
     108// --------------------------------------------------------------------------------------------
     109//
     110// Returns true, if fExtractedSignal is greater or equal 0 and smaller than gkSignalInitializer
     111//
    100112Bool_t MExtractedSignalBlindPixel::IsValid( const Int_t i ) const
    101113{
     
    103115}
    104116
     117// --------------------------------------------------------------------------------------------
     118//
     119// Prints for all stored blind pixels the ID, the signal and the number of saturated slices
     120//
    105121void MExtractedSignalBlindPixel::Print(Option_t *o) const
    106122{
Note: See TracChangeset for help on using the changeset viewer.