Ignore:
Timestamp:
11/01/06 15:48:31 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8171 r8192  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndCharge.cc,v 1.57 2006-10-27 13:49:42 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndCharge.cc,v 1.58 2006-11-01 15:48:31 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    167167// --------------------------------------------------------------------------
    168168//
     169// Return the x-value lower than sat0 at which the signal has been
     170// fallen bwlow maxcont/2. This time is determined using a simple second
     171// order polynomial interpolation.
     172//
     173Double_t MExtractTimeAndCharge::GetSaturationTime(Int_t sat0, const Float_t *sig, Int_t maxcont) const
     174{
     175    const Int_t p = sat0>1 ? sat0-2 : sat0-1;
     176    if (sat0<=0)
     177        return 0;
     178
     179    // Find the place at which the signal is maxcont/2
     180    const TVector3 vx(sig[p], sig[p+1], sig[p+2]);
     181    const TVector3 vy(p, p+1, p+2);
     182
     183    return MMath::InterpolParabLin(vx, vy, maxcont/2);
     184}
     185
     186// --------------------------------------------------------------------------
     187//
    169188// Calculate the integral of the FADC time slices and store them as a new
    170189// pixel in the MArrivalTimeCam container.
     
    199218        // Do not even try to extract the hi-gain if we have
    200219        // more than one saturating slice
     220        const Int_t rangehi = fHiGainLast - fHiGainFirst + 1;
     221
    201222        if (numsathi<2)
    202         {
    203             const Int_t rangehi = fHiGainLast - fHiGainFirst + 1;
    204223            FindTimeAndChargeHiGain2(sig+fHiGainFirst, rangehi,
    205224                                     sumhi, deltasumhi, timehi, deltatimehi,
    206225                                     numsathi, maxposhi);
    207 
    208 
    209             // Make sure that in cases the time couldn't be correctly determined
    210             // more meaningfull default values are assigned
    211             //if (timehi<fHiGainFirst || timehi>=fHiGainLast-1)
    212             if (deltatimehi>-0.5 && (timehi<0 || timehi>=fHiGainLast-fHiGainFirst+1))
    213                 timehi = gRandom->Uniform(fHiGainLast-fHiGainFirst+1);
    214 
    215             timehi += fHiGainFirst;
    216         }
    217226
    218227        // If we have saturating slices try to get a better estimate
     
    221230        if (numsathi>1)
    222231        {
    223             const Int_t p = sathi0>1 ? sathi0-2 : sathi0-1;
    224             if (sathi0>0)
    225             {
    226                 // Find the place at which the signal is maxcont/2
    227                 const TVector3 vx(sig[p], sig[p+1], sig[p+2]);
    228                 const TVector3 vy(p, p+1, p+2);
    229                 timehi=MMath::InterpolParabLin(vx, vy, maxcont/2);
    230             }
    231             else
    232                 timehi=0;
     232            timehi = GetSaturationTime(sathi0, sig, maxcont)-fHiGainFirst;
     233            deltatimehi = 0;
    233234        }
     235
     236        // Make sure that in cases the time couldn't be correctly determined
     237        // more meaningfull default values are assigned.
     238        // For extractors like the digital filter and the spline
     239        // we allow extracpolation by one slice.
     240        if (deltatimehi>-0.5 && (timehi<-1 || timehi>=rangehi))
     241        {
     242            // Flag this as unreliable!
     243            timehi = gRandom->Uniform(rangehi+1)-1;
     244            // deltatimehi=-1;
     245        }
     246
     247        timehi += fHiGainFirst;
    234248
    235249        Float_t sumlo =0, deltasumlo =-1;  // invalidate logain of MExtractedSignalPix
     
    280294            //
    281295            // The jitter in the hi-/lo-gain offset ssems to be around +/-0.5
    282             first = TMath::FloorNint(timehi+numh+fOffsetLoGain+fLoGainStartShift);
     296            if (deltatimehi>-0.5)
     297                first = TMath::FloorNint(timehi+numh+fOffsetLoGain+fLoGainStartShift);
     298            //else ???
     299
    283300            if (first<0)
    284301                first = 0;
     
    302319            numsatlo = fSignal->GetSaturation(pixidx, fSaturationLimit, satlo0, satlo1);
    303320
    304             FindTimeAndChargeLoGain2(sig+first, last-first+1,
     321            const Int_t rangelo = last-first+1;
     322            FindTimeAndChargeLoGain2(sig+first, rangelo,
    305323                                     sumlo, deltasumlo, timelo, deltatimelo,
    306324                                     numsatlo, maxposlo);
    307325
     326            // If we have saturating slices try to get a better estimate
     327            // of the arrival time than timehi or sathi0. This is
     328            // usefull to know where to start lo-gain extraction.
     329            if (numsatlo>1)
     330            {
     331                timelo = GetSaturationTime(satlo0, sig, maxlo)-numh-first;
     332                deltatimelo = 0;
     333            }
     334
    308335            // Make sure that in cases the time couldn't be correctly determined
    309336            // more meaningfull default values are assigned
    310             //if (timehi<fHiGainFirst || timehi>=fHiGainLast-1)
    311             if (deltatimelo>-0.5 && (timelo<0 || timelo>=last-first+1))
    312                 timelo = gRandom->Uniform(last-first+1);
     337            // For extractors like the digital filter and the spline
     338            // we allow extracpolation by one slice.
     339            if (deltatimelo>-0.5 && (timelo<-1 || timelo>=rangelo))
     340            {
     341                // Flag this as unreliable!
     342                timelo = gRandom->Uniform(rangelo+1)-1;
     343                //deltatimelo=-1;
     344            }
    313345
    314346            timelo += first-numh;
     
    323355            //    deltatimelo = -1;
    324356        }
     357
    325358
    326359        // Now store the result in the corresponding containers
Note: See TracChangeset for help on using the changeset viewer.