Ignore:
Timestamp:
10/24/06 13:40:58 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
3 edited

Legend:

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

    r8155 r8158  
    6161#include "MRawEvtPixelIter.h"
    6262
     63#include "MPedestalSubtractedEvt.h"
    6364#include "MExtractedSignalBlindPixel.h"
    6465
    6566#include "MPedestalCam.h"
    6667#include "MPedestalPix.h"
     68
     69#include "MCalibrationBlindCam.h"
     70#include "MCalibrationBlindPix.h"
     71
     72#include "MExtralgoSpline.h"
    6773
    6874ClassImp(MExtractBlindPixel);
     
    7884const Float_t MExtractBlindPixel::fgResolution       = 0.003;
    7985const Float_t MExtractBlindPixel::gkOverflow         = 300.;
     86
    8087// --------------------------------------------------------------------------
    8188//
     
    9299//
    93100MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title)
    94     : fBlindPixel(0), fHiLoLast(0), fDataType(0)
     101    : fBlindPixel(0), /*fHiLoLast(0),*/ fDataType(0)
    95102{
    96103 
     
    102109  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
    103110 
    104   SetNumBlindPixels();
     111//  SetNumBlindPixels();
     112  fBlindPixelIdx.Set(1);
     113  fBlindPixelIdx[0] = fgBlindPixelIdx;
    105114
    106115  Clear();
     
    128137    fExtractionType = 0;
    129138
    130     fBlindPixelIdx.Set(0);
    131     SetBlindPixelIdx();
     139    fBlindPixelIdx.Set(1);
     140    fBlindPixelIdx[0] = fgBlindPixelIdx;
     141}
     142
     143void MExtractBlindPixel::SetBlindPixels(const MCalibrationBlindCam &cam)
     144{
     145    const Int_t n = cam.GetSize();
     146
     147    fBlindPixelIdx.Set(n);
     148    for (Int_t i=0; i<n; i++)
     149        fBlindPixelIdx[i] = cam[i].GetPixId();
    132150}
    133151
     
    138156
    139157  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
    140   if (lolast)
    141     fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);
    142   else
     158//  if (lolast)
     159//    fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);
     160//  else
    143161    fNumLoGainSamples = 0.;
    144162
     
    146164  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples); 
    147165 
    148   fHiLoFirst = 0;
    149   fHiLoLast  = 0;
     166  //fHiLoFirst = 0;
     167  //fHiLoLast  = 0;
    150168}
    151169
     
    170188    return kFALSE;
    171189
    172   if (IsDataType(kRawEvt2))
    173     fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData2"));
    174   else
    175     fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
    176 
     190  const TString raw = IsDataType(kRawEvt2) ? "MRawEvtData2" : "MRawEvtData";
     191  const TString sig = IsDataType(kRawEvt2) ? "MPedestalSubtractedEvt2" : "MPedestalSubtractedEvt";
     192
     193  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber(raw), "MRawEvtData");
    177194  if (!fRawEvt)
    178195    {
    179       *fLog << err << GetDescriptor()
    180             << Form("%s%s",IsDataType(kRawEvt2) ? "MRawEvtData2" : "MRawEvtData",
    181                     " not found... aborting.") << endl;
     196      *fLog << err << raw << " [MRawEvtData] not found... aborting." << endl;
    182197      return kFALSE;
    183198    }
     199
     200  fSignal = (MPedestalSubtractedEvt*)pList->FindObject(AddSerialNumber(sig), "MPedestalSubtractedEvt");
     201  if (!fSignal)
     202    {
     203      *fLog << err << sig << " [MPedestalSubtractedEvt] not found... aborting." << endl;
     204      return kFALSE;
     205    }
     206
    184207  return kTRUE;
    185208}
     
    204227{
    205228 
    206   for (Int_t i=0;i<fNumBlindPixels;i++)
    207     fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(i),i);
     229  for (UInt_t i=0;i<fBlindPixelIdx.GetSize();i++)
     230      fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx[i], i);
    208231
    209232  fBlindPixel->SetExtractionType(fExtractionType);
     
    223246      }
    224247  }
    225 
     248/*
    226249  const Int_t higainsamples = fRunHeader->GetNumSamplesHiGain();
    227250  const Int_t logainsamples = fRunHeader->GetNumSamplesLoGain();
     
    265288      fHiLoLast   = logainsamples ? diff : 0;
    266289    }
    267 
    268   const Int_t range = fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
    269 
    270   fHiGainSignal.Set(range);
    271   fHiGainSignal.Reset();
     290 */
     291  const Int_t range = fHiGainLast-fHiGainFirst+1; //fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
     292
     293//  fHiGainSignal.Set(range);
     294//  fHiGainSignal.Reset();
    272295
    273296  fHiGainFirstDeriv.Set(range);
     
    280303  *fLog << inf << "Extracting "
    281304      << (IsExtractionType(kAmplitude) ? "Amplitude" : " Integral")
    282       << " using " << range << " FADC samples from "
    283       << (fHiLoFirst ? "Low Gain slice" : " High Gain slice")
    284       << (fHiLoFirst ? (Int_t)fHiLoFirst : (Int_t)fHiGainFirst)
    285       << " to (including) "
    286       << (fHiLoLast ? "Low Gain slice" : "High Gain slice")
    287       << (fHiLoLast ?  (Int_t)fHiLoLast-1 : (Int_t)fHiGainLast)
    288       << endl;
     305      << " using " << range << " FADC samples from slice "
     306      << (Int_t)fHiGainFirst << " to " << (Int_t)fHiGainLast << " (incl)" << endl;
    289307
    290308  if (IsExtractionType(kFilter))
    291309    *fLog << inf << "Will use Filter using "
    292310          << (Int_t)(fLoGainLast-fLoGainFirst+1) << " FADC slices"
    293           << " from High Gain slice " << (Int_t)fLoGainFirst
    294           << " to High Gain slice " << (Int_t)fLoGainLast << endl;
     311          << " from slice " << (Int_t)fLoGainFirst
     312          << " to " << (Int_t)fLoGainLast << endl;
    295313
    296314  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, range);
     
    303321//
    304322// FindSignalHiGain:
     323//
     324// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
     325// - Sum up contents of *ptr
     326// - If *ptr is greater than fSaturationLimit, raise sat by 1
     327// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
     328// - Add contents of *logain to sum
     329//
     330/*
     331void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
     332{
     333    const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
     334
     335    Int_t summ = 0;
     336    while (p<end)
     337    {
     338        summ += *ptr;
     339
     340        if (*ptr++ >= fSaturationLimit)
     341            sat++;
     342    }
     343
     344    sum = (Float_t)summ;
     345}
     346*/
     347
     348// --------------------------------------------------------------------------
     349//
     350// FindSignalPhe:
    305351//
    306352// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
     
    310356// - Add contents of *logain to sum
    311357//
    312 void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
    313 {
    314 
    315   Int_t summ = 0;
    316   Byte_t *p   = ptr;
    317   Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
    318 
    319   if (fHiLoFirst == 0)
    320     {
    321 
    322       while (p<end)
    323         {
    324           summ += *ptr;
    325          
    326           if (*p++ >= fSaturationLimit)
    327             sat++;
    328         }
    329      
    330     }
    331  
    332   p   = logain + fHiLoFirst; 
    333   end = logain + fHiLoLast;
    334   while (p<end)
    335     {
    336       summ += *p;
    337 
    338       if (*p++ >= fSaturationLimit)
    339             sat++;
    340     }
    341 
    342   sum = (Float_t)summ;
    343 }
    344 
    345 // --------------------------------------------------------------------------
    346 //
    347 // FindSignalPhe:
    348 //
    349 // - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
    350 // - Sum up contents of *ptr
    351 // - If *ptr is greater than fSaturationLimit, raise sat by 1
    352 // - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
    353 // - Add contents of *logain to sum
    354 //
    355 void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
    356 {
    357 
     358//void MExtractBlindPixel::FindAmplitude(Float_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
     359Float_t MExtractBlindPixel::FindAmplitude(Int_t idx, Int_t numsat) const
     360{
     361    Int_t sat0 = fHiGainFirst; // First slice to extract and first saturating slice
     362    Int_t sat1 = fHiGainLast;  // Last  slice to extract and last saturating slice
     363
     364    Int_t maxcont;
     365    Int_t maxpos = fSignal->GetMax(idx, sat0, sat1, maxcont);
     366
     367//    numsat = fSignal->GetSaturation(idx, fSaturationLimit, sat0, sat1);
     368
     369    const Float_t *ptr = fSignal->GetSamples(idx);
     370    const Int_t    num = fHiGainLast-fHiGainFirst+1;
     371
     372    MExtralgoSpline s(ptr, num, fHiGainFirstDeriv.GetArray(), fHiGainSecondDeriv.GetArray());
     373
     374    s.SetExtractionType(MExtralgoSpline::kAmplitude);
     375
     376    s.Extract(numsat, maxpos);
     377
     378    return s.GetSignal();
     379/*
    358380  Int_t range   = 0;
    359381  Int_t count   = 0;
     
    586608        }
    587609    }
    588 
     610  */
    589611}
    590612
     
    596618// - Sum up contents of *ptr
    597619// - If *ptr is greater than fSaturationLimit, raise sat by 1
    598 //
    599 void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
    600 {
    601 
    602   Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
     620//
     621/*
     622void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t range, Int_t &sum, Byte_t &sat) const
     623{
     624
     625  Byte_t *end = ptr + range;
    603626 
    604627  while (ptr<end)
     
    610633    }
    611634}
     635*/
    612636
    613637// --------------------------------------------------------------------------
     
    624648 
    625649  for (UInt_t id=0;id<fBlindPixelIdx.GetSize();id++)
    626     {
    627  
    628       pixel.Jump(fBlindPixelIdx[id]);
    629      
    630       Int_t sum   = 0;
    631       Byte_t sat  = 0;
    632 
     650  {
     651      // Be carefull: GetSaturation changed sat0 and sat1
     652      Int_t sat0 = fHiGainFirst; // First slice to extract and first saturating slice
     653      Int_t sat1 = fHiGainLast;  // Last  slice to extract and last saturating slice
     654
     655      const Int_t sat = fSignal->GetSaturation(fBlindPixelIdx[id], fSaturationLimit, sat0, sat1);
     656     
    633657      if (IsExtractionType(kFilter))
    634658      {
    635 
    636           FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
    637          
     659          // FIXME: fLoGain* is used to determine the FILTER/CHECK range
     660          const Int_t numh = pixel.GetNumHiGainSamples();
     661
     662          const Int_t sum = fSignal->GetIntegralRaw(fBlindPixelIdx[id], fLoGainFirst+numh, fLoGainLast+numh);
    638663          if (sum > fNSBFilterLimit)
    639664          {
     
    644669          }
    645670
     671          /*
    646672          sum = 0;
    647673          if (pixel.HasLoGain())
    648             FindSignalFilter(pixel.GetLoGainSamples(), sum, sat);         
    649 
    650           /*
     674            FindSignalFilter(sl+pixel.GetNumLoGainSamples()+fLoGainFirst, fLoGainLast - fLoGainFirst + 1, sum, sat);
     675
    651676          if (fModified)
    652677            {
     
    661686          */
    662687      }
    663      
     688
     689
    664690      Float_t newsum = 0.;
    665       sat = 0;
    666      
    667691      if (IsExtractionType(kAmplitude))
    668         FindAmplitude   (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
     692          newsum = FindAmplitude(fBlindPixelIdx[id], sat);
    669693      else
    670         FindIntegral    (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
    671  
    672 
    673       fBlindPixel->SetExtractedSignal(newsum,id);
    674       fBlindPixel->SetNumSaturated(sat,id);
    675     }
    676  
     694          newsum = fSignal->GetIntegralRaw(fBlindPixelIdx[id], fHiGainFirst, fHiGainLast);
     695 
     696      fBlindPixel->SetExtractedSignal(newsum, id);
     697      fBlindPixel->SetNumSaturated(sat, id);
     698  }
     699
    677700  fBlindPixel->SetReadyToSave();
    678701  return kTRUE;
     
    686709Bool_t MExtractBlindPixel::IsDataType( const DataType_t typ )
    687710{
    688  
    689711  return TESTBIT( fDataType, typ );
    690 
    691712}
    692713
     
    698719Bool_t MExtractBlindPixel::IsExtractionType( const ExtractionType_t typ )
    699720{
    700  
    701721  return TESTBIT( fExtractionType, typ );
    702 
    703722}
    704723
  • trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.h

    r8155 r8158  
    1313#endif
    1414
     15class MCalibrationBlindCam;
    1516class MExtractedSignalBlindPixel;
    1617
     
    3031  MExtractedSignalBlindPixel *fBlindPixel; // Extracted signal of the Blind Pixel
    3132
    32   Byte_t   fHiLoFirst;                     // If not zero, start extraction from fHiLoFirst slice of Low-Gain
    33   Byte_t   fHiLoLast;
     33//  Byte_t   fHiLoFirst;                     // If not zero, start extraction from fHiLoFirst slice of Low-Gain
     34//  Byte_t   fHiLoLast;
    3435
    35   MArrayF  fHiGainSignal;                  //! Need fast access to the signals in a float way
     36//  MArrayF  fHiGainSignal;                  //! Need fast access to the signals in a float way
    3637  MArrayF  fHiGainFirstDeriv;              //! First derivative at intersection
    3738  MArrayF  fHiGainSecondDeriv;             //! Second derivative at intersection
     
    4344  Byte_t  fExtractionType;                 // What extraction type has been chosen?
    4445  Byte_t  fDataType;                       // What data container type is needed? 
    45   Int_t   fNumBlindPixels;                 // Current number of blind pixels
     46//  Int_t   fNumBlindPixels;                 // Current number of blind pixels
    4647
    4748public:
     
    5051
    5152private:
    52   void FindAmplitude   (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
    53   void FindIntegral    (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
    54   void FindSignalFilter(Byte_t *ptr,                          Int_t &sum, Byte_t &sat) const;
     53  Float_t FindAmplitude(Int_t idx, Int_t numsat) const;
     54//  void FindIntegral    (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
     55//  void FindSignalFilter(Byte_t *ptr, Int_t range,             Int_t &sum, Byte_t &sat) const;
    5556 
    5657  Int_t  PreProcess(MParList *pList);
     
    6970
    7071  // Setters
     72  /*
    7173  void SetBlindPixelIdx(  const Int_t  idx=fgBlindPixelIdx, const UInt_t nr=0 )
    7274  {
     
    7476          fBlindPixelIdx.Set(nr+1);
    7577      fBlindPixelIdx[nr] = idx;
    76   }
     78      }
     79      */
     80
     81  void SetBlindPixels(const MCalibrationBlindCam &cam);
     82
    7783  void SetExtractionType( const ExtractionType_t typ=kAmplitude );
    7884  void SetDataType    ( const DataType_t       typ=kRawEvt    ); 
    7985  void SetNSBFilterLimit( const Int_t   lim=fgNSBFilterLimit )  { fNSBFilterLimit = lim;   }     
    8086 
    81   void SetNumBlindPixels( const Int_t   num=1 )  { fNumBlindPixels = num;   }
     87//  void SetNumBlindPixels( const Int_t   num=1 )  { fNumBlindPixels = num;   }
    8288 
    8389  void SetRange         ( const Byte_t  hifirst=0, const Byte_t hilast=0,
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeSpline.cc

    r8154 r8158  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndChargeSpline.cc,v 1.61 2006-10-24 08:24:52 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndChargeSpline.cc,v 1.62 2006-10-24 12:39:00 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    182182//
    183183MExtractTimeAndChargeSpline::MExtractTimeAndChargeSpline(const char *name, const char *title)
    184     : fRandomIter(0), fExtractionType(kIntegral)
     184    : /*fRandomIter(0),*/ fExtractionType(kIntegral)
    185185{
    186186
     
    377377
    378378    s.SetRiseFallTime(fRiseTimeHiGain, fFallTimeHiGain);
    379     s.SetResolution(fResolution);
     379//    s.SetResolution(fResolution);
    380380
    381381    if (IsNoiseCalculation())
    382382    {
    383         if (fRandomIter == int(1./fResolution))
    384             fRandomIter = 0;
    385 
    386         sum = s.ExtractNoise(fRandomIter);
    387         fRandomIter++;
     383//        if (fRandomIter == int(1./fResolution))
     384//            fRandomIter = 0;
     385
     386        sum = s.ExtractNoise(/*fRandomIter*/);
     387//        fRandomIter++;
    388388        return;
    389389    }
     
    402402
    403403    s.SetRiseFallTime(fRiseTimeLoGain, fFallTimeLoGain);
    404     s.SetResolution(fResolution);
     404//    s.SetResolution(fResolution);
    405405
    406406    if (IsNoiseCalculation())
    407407    {
    408         if (fRandomIter == int(1./fResolution))
    409             fRandomIter = 0;
    410 
    411         sum = s.ExtractNoise(fRandomIter);
     408//        if (fRandomIter == int(1./fResolution))
     409//            fRandomIter = 0;
     410
     411        sum = s.ExtractNoise(/*fRandomIter*/);
    412412        return;
    413413    }
Note: See TracChangeset for help on using the changeset viewer.