Changeset 3962


Ignore:
Timestamp:
05/04/04 17:29:39 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3961 r3962  
    6565   * mcalib/MHGausEvents.cc
    6666     - took out fEvents(0) and fHGausHist() from constructor
     67
     68   * msignal/MExtractor.cc
     69   * msignal/MExtractPINDiode.cc
     70     - fixed StreamPrimitive
     71
     72   * msignal/MExtractBlindPixel.[h,cc]
     73     - deriving from MExtractor, possibility to filter NSB events
     74
    6775 
    6876 2004/05/03: Thomas Bretz
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc

    r3681 r3962  
    2727//   MExtractBlindPixel
    2828//
     29//  Extracts the signal from a fixed window in a given range.
     30//
     31//  Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast)
     32//  to modify the ranges. The "lo-gain" ranges are used for the NSB rejection
     33//  whereas the high-gain ranges for blind pixel signal extraction. "High-gain"
     34//  ranges can extend to the slices stored as "low-gain" in MRawEvtPixelIter
     35//  Defaults are:
     36//
     37//   fHiGainFirst =  fgHiGainFirst =  12
     38//   fHiGainLast  =  fgHiGainLast  =  16
     39//   fLoGainFirst =  fgLoGainFirst =  0
     40//   fLoGainLast  =  fgLoGainLast  =  10
     41//
    2942//////////////////////////////////////////////////////////////////////////////
    3043#include "MExtractBlindPixel.h"
     
    4053#include "MRawEvtPixelIter.h"
    4154
     55#include "MExtractedSignalBlindPixel.h"
     56
    4257#include "MPedestalCam.h"
    4358#include "MPedestalPix.h"
    4459
    45 #include "MExtractedSignalBlindPixel.h"
    46 
    4760ClassImp(MExtractBlindPixel);
    4861
    4962using namespace std;
    5063
    51 const Int_t  MExtractBlindPixel::fgBlindPixelIdx   = 559;
    52 const Byte_t MExtractBlindPixel::fgSaturationLimit = 254;
    53 const Byte_t MExtractBlindPixel::fgFirst =  3;
    54 const Byte_t MExtractBlindPixel::fgLast  = 16;
    55 
     64const Int_t  MExtractBlindPixel::fgBlindPixelIdx  = 559;
     65const Int_t  MExtractBlindPixel::fgNSBFilterLimit = 800;
     66const Byte_t MExtractBlindPixel::fgHiGainFirst    =  12;
     67const Byte_t MExtractBlindPixel::fgHiGainLast     =  29;
     68const Byte_t MExtractBlindPixel::fgLoGainFirst    =  0;
     69const Byte_t MExtractBlindPixel::fgLoGainLast     =  10;
    5670// --------------------------------------------------------------------------
    5771//
    5872// Default constructor.
    5973//
     74// Initializes:
     75// - fBlindPixelIdx to fgBlindPixelIdx
     76// - fNSBFilterLimit to fgNSBFilterLimit
     77//
     78// Calls:
     79// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
     80//
    6081MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title)
    61     : fSaturationLimit(fgSaturationLimit)
    6282{
    6383 
     
    6888 
    6989  SetBlindPixelIdx();
    70   SetSaturationLimit();
    71   SetRange();
    72 }
    73 
    74 void MExtractBlindPixel::SetRange(Byte_t first, Byte_t last)
    75 {
    76 
    77     fNumSamples = last-first+1;
    78     fFirst      = first;
    79     fLast       = last;
    80 
    81     fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples);
     90  SetNSBFilterLimit();
     91  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
     92
     93}
     94
     95void MExtractBlindPixel::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
     96{
     97
     98  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
     99
     100  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
     101  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1); 
     102
     103  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
     104  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 
     105 
    82106}
    83107
     
    94118Int_t MExtractBlindPixel::PreProcess(MParList *pList)
    95119{
    96     fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
    97     if (!fRawEvt)
    98     {
    99         *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
    100         return kFALSE;
    101     }
    102 
    103     fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
    104     if (!fPedestals)
    105     {
    106         *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting." << endl;
    107         return kFALSE;
    108     }
    109 
    110     fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
    111     if (!fBlindPixel)
    112         return kFALSE;
    113 
    114     fBlindPixel->SetUsedFADCSlices(fFirst, fLast);
    115     fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx);
    116 
    117     return kTRUE;
     120
     121  if (!MExtractor::PreProcess(pList))
     122    return kFALSE;
     123 
     124  fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
     125  if (!fBlindPixel)
     126    return kFALSE;
     127
     128  fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx);
     129  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
     130 
     131  MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx];   
     132 
     133  if (&pedpix)
     134    {
     135      fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples );
     136      fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples
     137                                 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) );
     138      fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples) );
     139      fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. );
     140    }
     141 
     142  return kTRUE;
     143}
     144
     145// --------------------------------------------------------------------------
     146//
     147// FindSignalHiGain:
     148//
     149// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
     150// - Sum up contents of *ptr
     151// - If *ptr is greater than fSaturationLimit, raise sat by 1
     152// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
     153// - Add contents of *logain to sum
     154//
     155void MExtractBlindPixel::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Int_t &sum, Byte_t &sat) const
     156{
     157
     158  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
     159 
     160  while (ptr<end)
     161    {
     162      sum += *ptr;
     163     
     164      if (*ptr++ >= fSaturationLimit)
     165        sat++;
     166    }
     167
     168  if (fHiLoLast == 0)
     169    return;
     170 
     171  end = logain + fHiLoLast;
     172  while (logain<end)
     173    {
     174      sum += *logain;
     175     
     176      if (*logain++ >= fSaturationLimit)
     177            sat++;
     178    }
     179
     180}
     181
     182// --------------------------------------------------------------------------
     183//
     184// FindSignalFilter:
     185//
     186// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
     187// - Sum up contents of *ptr
     188// - If *ptr is greater than fSaturationLimit, raise sat by 1
     189//
     190void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
     191{
     192
     193  Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
     194 
     195  while (ptr<end)
     196    {
     197      sum += *ptr;
     198     
     199      if (*ptr++ >= fSaturationLimit)
     200        sat++;
     201    }
    118202}
    119203
     
    126210{
    127211
    128     MRawEvtPixelIter pixel(fRawEvt);
    129 
    130     fBlindPixel->Clear();
    131 
    132     pixel.Jump(fBlindPixelIdx);
    133  
    134     const UInt_t nhigain = pixel.GetNumHiGainSamples();
    135 
    136     Byte_t *ptr = pixel.GetHiGainSamples();
    137    
    138     //
    139     // We need a dedicated signal extractor for the blind pixel
    140     //
    141     Int_t  diff  = 0;
    142     UInt_t first = fFirst;
    143     UInt_t last  = fLast;
    144     UInt_t sat  = 0;
    145 
    146     if (last > nhigain)
    147       {
    148         diff = last - nhigain;
    149         last = nhigain;
    150       }
    151    
    152    
    153     Byte_t *start   = ptr + first - 1;
    154     Byte_t *end     = ptr + last  - 1;
    155    
    156     ptr = start;
    157    
    158     Int_t sum = 0;
    159    
    160     while (ptr<=end)
    161       {
    162         sum += *ptr;
    163 
    164         if (*ptr++ >= fSaturationLimit)
    165           sat++;
    166       }
    167    
    168     if (diff > 0)
    169       {
    170         ptr = pixel.GetLoGainSamples();
    171         end = ptr + diff - 1;
    172        
    173         while (ptr<=end)
    174           {
    175 
    176             sum += *ptr;
    177 
    178             if (*ptr++ >= fSaturationLimit)
    179               sat++;
    180 
    181           }
    182       }
    183    
    184     fBlindPixel->SetExtractedSignal(sum);
    185     fBlindPixel->SetNumSaturated(sat);
    186     fBlindPixel->SetReadyToSave();
    187 
    188     return kTRUE;
    189 }
    190 
    191 Int_t MExtractBlindPixel::PostProcess()
    192 {
    193 
    194     MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx];   
    195 
    196     if (&pedpix)
    197     {
    198          fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumSamples );
    199          fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumSamples / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) );
    200          fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumSamples) );
    201          fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. );
    202     }
    203 
    204     return kTRUE;
    205 
    206 }
    207 
    208 // --------------------------------------------------------------------------
    209 //
    210 // Implementation of SavePrimitive. Used to write the call to a constructor
    211 // to a macro. In the original root implementation it is used to write
    212 // gui elements to a macro-file.
    213 //
    214 void MExtractBlindPixel::StreamPrimitive(ofstream &out) const
    215 {
    216     out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    217     out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
    218 
    219     if (fSaturationLimit!=fgSaturationLimit)
    220     {
    221         out << "   " << GetUniqueName() << ".SetSaturationLimit(";
    222         out << (int)fSaturationLimit << ");" << endl;
    223     }
    224 
    225     const Bool_t arg2 = fNumSamples+fFirst-1 != fgLast;
    226     const Bool_t arg1 = arg2 || fFirst != fgFirst;
    227 
    228     if (!arg1)
    229         return;
    230 
    231     out << "   " << GetUniqueName() << ".SetRange(";
    232     out << (int)fFirst;
    233     if (arg2)
    234       out << ", " << (int)(fNumSamples+fFirst-1);
    235     out << ");" << endl;
    236 }
     212  MRawEvtPixelIter pixel(fRawEvt);
     213 
     214  fBlindPixel->Clear();
     215 
     216  pixel.Jump(fBlindPixelIdx);
     217 
     218  Int_t sum   = 0;
     219  Byte_t sat  = 0;
     220
     221  FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
     222
     223  if (sum > fNSBFilterLimit)
     224    {
     225      sum = -1;
     226      fBlindPixel->SetExtractedSignal(sum);
     227      fBlindPixel->SetNumSaturated(sat);
     228      fBlindPixel->SetReadyToSave();
     229      return kTRUE;
     230    }
     231
     232  sum = 0;
     233  sat = 0;
     234
     235  FindSignalHiGain(pixel.GetHiGainSamples()+fLoGainFirst, pixel.GetLoGainSamples(), sum, sat);
     236 
     237  fBlindPixel->SetExtractedSignal(sum);
     238  fBlindPixel->SetNumSaturated(sat);
     239  fBlindPixel->SetReadyToSave();
     240 
     241  return kTRUE;
     242}
     243
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h

    r3322 r3962  
    44/////////////////////////////////////////////////////////////////////////////
    55//                                                                         //
    6 // MExtractBlindPixel                                                        //
     6// MExtractBlindPixel                                                      //
    77//                                                                         //
    88// Integrates the time slices of the all pixels of a calibration event     //
     
    1111/////////////////////////////////////////////////////////////////////////////
    1212
    13 #ifndef MARS_MTask
    14 #include "MTask.h"
     13#ifndef MARS_MExtractor
     14#include "MExtractor.h"
    1515#endif
    1616
    17 class MRawEvtData;
    18 class MRawRunHeader;
    19 class MRawEvtPixelIter;
    20 class MPedestalCam;
    2117class MExtractedSignalBlindPixel;
    22 class MExtractBlindPixel : public MTask
     18class MExtractBlindPixel : public MExtractor
    2319{
    2420private:
    2521
    26   static const Int_t  fgBlindPixelIdx; 
    27   static const Byte_t fgSaturationLimit;
    28   static const Byte_t fgFirst;
    29   static const Byte_t fgLast;
     22  static const Int_t  fgBlindPixelIdx;
     23  static const Int_t  fgNSBFilterLimit; 
     24  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 0)
     25  static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 11)
     26  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 0)
     27  static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to:  2)
    3028
    3129  MExtractedSignalBlindPixel  *fBlindPixel;   // Extracted signal of the Blind Pixel
    3230
    33   MRawEvtData         *fRawEvt;       // raw event data (time slices)
    34   MRawRunHeader       *fRunHeader;    // RunHeader information
    35   MPedestalCam        *fPedestals;    // pointer to the pedestal information
     31  Int_t   fBlindPixelIdx;
     32  Int_t   fNSBFilterLimit; 
     33
     34  void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Int_t &sum, Byte_t &sat) const;
     35  void FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const;
    3636 
    37   Byte_t  fFirst;
    38   Byte_t  fLast;
    39   Byte_t  fNumSamples;
    40   Float_t fSqrtSamples;
    41   Byte_t  fSaturationLimit;
    42 
    43   Int_t  fBlindPixelIdx;
    4437  Int_t  PreProcess(MParList *pList);
    4538  Int_t  Process();
    46   Int_t  PostProcess();
    47   void   StreamPrimitive(ofstream &out) const;
    48  
     39
    4940public:
    5041
     
    5243
    5344  // Setters
    54   void SetRange(const Byte_t first=fgFirst, const Byte_t last=fgLast);
    55   void SetSaturationLimit(const Byte_t lim=fgSaturationLimit) { fSaturationLimit = lim; }
    56   void SetBlindPixelIdx(  const  Int_t idx=fgBlindPixelIdx  ) { fBlindPixelIdx   = idx; } 
     45  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
     46  void SetBlindPixelIdx(  const  Int_t idx=fgBlindPixelIdx  ) { fBlindPixelIdx   = idx; }
     47  void SetNSBFilterLimit(  const  Int_t lim=fgNSBFilterLimit ) { fNSBFilterLimit     = lim; }   
    5748
    58   ClassDef(MExtractBlindPixel, 0) // Task to fill the Extracted BlindPixel Containers from raw data
     49  ClassDef(MExtractBlindPixel, 0) // Signal Extractor for the Blind Pixel
    5950};
    6051
  • trunk/MagicSoft/Mars/msignal/MExtractPINDiode.cc

    r3951 r3962  
    4141//////////////////////////////////////////////////////////////////////////////
    4242#include "MExtractPINDiode.h"
    43 #include "MExtractor.h"
    4443
    4544#include <fstream>
     
    278277}
    279278
    280 // --------------------------------------------------------------------------
    281 //
    282 // Implementation of SavePrimitive. Used to write the call to a constructor
    283 // to a macro. In the original root implementation it is used to write
    284 // gui elements to a macro-file.
    285 //
    286 void MExtractPINDiode::StreamPrimitive(ofstream &out) const
    287 {
    288     out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    289     out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
    290 
    291     if (fSaturationLimit!=fgSaturationLimit)
    292     {
    293         out << "   " << GetUniqueName() << ".SetSaturationLimit(";
    294         out << (int)fSaturationLimit << ");" << endl;
    295     }
    296 
    297     const Bool_t arg2 = fNumSamples+fHiGainFirst-1 != fgLoGainLast;
    298     const Bool_t arg1 = arg2 || fHiGainFirst != fgHiGainFirst;
    299 
    300     if (!arg1)
    301         return;
    302 
    303     out << "   " << GetUniqueName() << ".SetRange(";
    304     out << (int)fHiGainFirst;
    305     if (arg2)
    306       out << ", " << (int)(fNumSamples+fHiGainFirst-1);
    307     out << ");" << endl;
    308 }
  • trunk/MagicSoft/Mars/msignal/MExtractPINDiode.h

    r3951 r3962  
    4040  Bool_t ReInit(MParList *pList); 
    4141  Int_t  Process();
    42   void   StreamPrimitive(ofstream &out) const;
    4342 
    4443public:
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r3958 r3962  
    279279void MExtractor::StreamPrimitive(ofstream &out) const
    280280{
    281 }
    282 
     281
     282  out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
     283  out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
     284 
     285  if (fSaturationLimit!=fgSaturationLimit)
     286    {
     287      out << "   " << GetUniqueName() << ".SetSaturationLimit(";
     288      out << (int)fSaturationLimit << ");" << endl;
     289    }
     290 
     291  out << "   " << GetUniqueName() << ".SetRange(";
     292  out << (int)fHiGainFirst;
     293  out << ", " << (int)fHiGainLast;
     294  out << ", " << (int)fLoGainFirst;
     295  out << ", " << (int)fLoGainLast;
     296  out << ");" << endl;
     297}
     298
Note: See TracChangeset for help on using the changeset viewer.