Ignore:
Timestamp:
12/01/04 20:49:05 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r5511 r5544  
    177177//
    178178MExtractTimeAndChargeSpline::MExtractTimeAndChargeSpline(const char *name, const char *title)
    179     : fAbMax(0.), fAbMaxPos(0.), fHalfMax(0.)
     179    : fAbMax(0.), fAbMaxPos(0.), fHalfMax(0.), fRandomIter(0)
    180180{
    181181
     
    251251// --------------------------------------------------------------------------
    252252//
    253 // ReInit
    254 //
    255 // Calls:
    256 // - MExtractTimeAndCharge::ReInit(pList);
    257 // - Deletes all arrays, if not NULL
    258 // - Creates new arrays according to the extraction range
    259 //
    260 Bool_t MExtractTimeAndChargeSpline::ReInit(MParList *pList)
     253// InitArrays
     254//
     255// Gets called in the ReInit() and initialized the arrays
     256//
     257Bool_t MExtractTimeAndChargeSpline::InitArrays()
    261258{
    262259
     260  Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
     261
     262  fHiGainSignal     .Set(range);
     263  fHiGainFirstDeriv .Set(range);
     264  fHiGainSecondDeriv.Set(range);
     265
     266  range = fLoGainLast - fLoGainFirst + 1;
     267
     268  fLoGainSignal     .Set(range);
     269  fLoGainFirstDeriv .Set(range);
     270  fLoGainSecondDeriv.Set(range);
     271
     272  fHiGainSignal     .Reset();
     273  fHiGainFirstDeriv .Reset();
     274  fHiGainSecondDeriv.Reset();
     275
     276  fLoGainSignal     .Reset();
     277  fLoGainFirstDeriv .Reset();
     278  fLoGainSecondDeriv.Reset();
     279 
    263280  if (IsExtractionType(kAmplitude))
    264281    {
     
    280297      fWindowSizeLoGain  = (Int_t)(fRiseTime + fFallTime+1);
    281298    }
    282 
    283   if (!MExtractTimeAndCharge::ReInit(pList))
    284     return kFALSE;
    285 
    286   return kTRUE;
    287 }
    288 
    289 // --------------------------------------------------------------------------
    290 //
    291 // InitArrays
    292 //
    293 // Gets called in the ReInit() and initialized the arrays
    294 //
    295 Bool_t MExtractTimeAndChargeSpline::InitArrays()
    296 {
    297 
    298   Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
    299 
    300   fHiGainSignal     .Set(range);
    301   fHiGainFirstDeriv .Set(range);
    302   fHiGainSecondDeriv.Set(range);
    303 
    304   range = fLoGainLast - fLoGainFirst + 1;
    305 
    306   fLoGainSignal     .Set(range);
    307   fLoGainFirstDeriv .Set(range);
    308   fLoGainSecondDeriv.Set(range);
    309 
    310   fHiGainSignal     .Reset();
    311   fHiGainFirstDeriv .Reset();
    312   fHiGainSecondDeriv.Reset();
    313 
    314   fLoGainSignal     .Reset();
    315   fLoGainFirstDeriv .Reset();
    316   fLoGainSecondDeriv.Reset();
    317299
    318300  return kTRUE;
     
    415397  if (IsNoiseCalculation() && IsExtractionType(kAmplitude))
    416398    {
    417       //
    418       // Take the spline value at the middle of the third slice (to avoid egde effects)
    419       //
    420       sum = 0.5*fHiGainSignal[2]
    421           + 0.5*fHiGainSignal[3]
    422           + (-0.375)*fHiGainSecondDeriv[2]
    423           + (-0.375)*fHiGainSecondDeriv[3];
     399      if (fRandomIter == (TMath::Floor(1./fResolution)))
     400        fRandomIter = 0;
     401
     402      const Float_t b = fRandomIter * fResolution;
     403      const Float_t a = 1. - b;
     404
     405      fRandomIter++;
     406
     407      sum = a*fHiGainSignal[1]
     408          + b*fHiGainSignal[2]
     409          + (a*a*a-a)*fHiGainSecondDeriv[1]
     410          + (b*b*b-b)*fHiGainSecondDeriv[2];
    424411      return;
    425412    }
     
    531518  // Try a better precision.
    532519  //
    533   const Float_t up = fAbMaxPos+step-0.035;
    534   const Float_t lo = fAbMaxPos-step+0.035;
     520  const Float_t up = fAbMaxPos+step - 1.5*fResolution;
     521  const Float_t lo = fAbMaxPos-step + 1.5*fResolution;
    535522  const Float_t maxpossave = fAbMaxPos;
    536523 
     
    539526  b     = x - lower;
    540527 
    541   step  = 0.025; // step size of 83 ps
     528  step  = fResolution; // step size of 83 ps
    542529 
    543530  while (x<up)
     
    562549
    563550  //
    564   // Second, try from time down to time-0.2 in steps of 0.025.
     551  // Second, try from time down to time-0.2 in steps of fResolution.
    565552  //
    566553  x     = maxpossave;
     
    571558  // which requires new setting of klocont and khicont
    572559  //
    573   if (x < klo + 0.02)
     560  if (x < klo + fResolution/2.)
    574561    {
    575562      klo--;
     
    605592    {
    606593      time = (Float_t)fHiGainFirst + fAbMaxPos;
    607       dtime = 0.025;
     594      dtime = fResolution;
    608595    }
    609596  else
     
    892879  // Try a better precision.
    893880  //
    894   const Float_t up = fAbMaxPos+step-0.035;
    895   const Float_t lo = fAbMaxPos-step+0.035;
     881  const Float_t up = fAbMaxPos+step - 1.5*fResolution;
     882  const Float_t lo = fAbMaxPos-step + 1.5*fResolution;
    896883  const Float_t maxpossave = fAbMaxPos;
    897884 
     
    900887  b     = x - lower;
    901888 
    902   step  = 0.025; // step size of 83 ps
     889  step  = fResolution; // step size of fResolution (33 ps )
    903890 
    904891  while (x<up)
     
    932919  // which requires new setting of klocont and khicont
    933920  //
    934   if (x < klo + 0.02)
     921  if (x < klo + fResolution/2.)
    935922    {
    936923      klo--;
     
    966953    {
    967954      time = (Float_t)fLoGainFirst + fAbMaxPos;
    968       dtime = 0.02;
     955      dtime = fResolution;
    969956    }
    970957  else
Note: See TracChangeset for help on using the changeset viewer.