Changeset 3212


Ignore:
Timestamp:
02/17/04 09:48:21 (21 years ago)
Author:
raducci
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3211 r3212  
    1313  * macros/spline.C
    1414    - changed according to the MCubicSpline new constructors
     15
     16  * manalysis/MArrivalTimeCalc.[h,cc]
     17    - changed to use the MCubicSpline class intead of the TSpline class
     18    - warning: now the arrival time is again the maximum of the spline,
     19      soon it will be changed to half maximum
    1520
    1621
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc

    r3032 r3212  
    4141#include "MArrivalTimeCalc.h"
    4242
    43 #include <TSpline.h>
     43#include "MCubicSpline.h"
    4444
    4545#include "MLog.h"
     
    6161// Default constructor.
    6262//
    63 // Initialize step size by default to 0.03 time slices == 100 ps.
    6463//
    65 MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
    66     : fStepSize(0.03)
     64MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
    6765{
    6866
     
    132130     
    133131      const UInt_t idx = pixel.GetPixelId();
    134       Float_t max = 0.;
     132      Float_t time = 0.;
    135133
    136134
     
    142140         
    143141          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
    144           max = Calc(pixel.GetLoGainSamples(),nslices);
     142          time = Calc(pixel.GetLoGainSamples(),nslices);
    145143        }
    146144     
     
    153151         
    154152          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
    155           max = Calc(pixel.GetHiGainSamples(),nslices);
     153          time = Calc(pixel.GetHiGainSamples(),nslices);
    156154        }
    157155     
     
    159157      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
    160158      //
    161       fArrTime->SetTime(idx,max);
     159      fArrTime->SetTime(idx,time);
    162160     
    163161    }
     
    172170// Calculates the arrival time for each pixel
    173171// Possible Methods
    174 // Case 1: Spline5 (From TSpline5 Root Class)
     172// Case 1: MCubicSpline (3rd order spline)
    175173//
    176174Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
     
    178176
    179177  //
    180   // Initialize a double pointer with filled FADC slices
     178  // Initialize the spline
    181179  //
    182   Double_t ptr[nslices];
     180    MCubicSpline *spline = new MCubicSpline(fadcSamples); 
    183181
    184182  //
    185   // Initialize the spline
     183  // Now find the maximum 
    186184  //
    187   for (Int_t i=0; i<nslices; i++)
    188     ptr[i]=(Double_t)fadcSamples[i];
    189  
    190   TSpline5 spline("spline",0.,(Double_t)(nslices - 1),ptr,nslices);
    191 
    192   //
    193   // Now find the half maximum (!)
    194   // evaluating the spline function at every fStepSize time slice
    195   //
    196   Double_t abscissa=0;
    197   Double_t maxAb   =0;
    198   Double_t maxOrd  =0;
    199 
    200   while (abscissa <= nslices - 1)
    201     {
    202       const Double_t swap = spline.Eval(abscissa);
    203 
    204       if (swap > maxOrd)
    205         {
    206           maxOrd = swap;
    207           maxAb  = abscissa;
    208         }
    209       // make step size a bit bigger first
    210       abscissa += fStepSize;
    211       //      abscissa += fStepSize;
    212     }
    213 
    214   //
    215   // another (much smaller) loop to move back from the maximum
    216   //
    217   Double_t halfMaxAb = 0;
    218 
    219   abscissa = maxAb;
    220  
    221   while (abscissa > 0)
    222     {
    223      
    224       const Double_t swap = spline.Eval(abscissa);
    225      
    226       if (swap < maxOrd/2.)
    227         {
    228           halfMaxAb = abscissa;
    229           break;
    230         }
    231      
    232       abscissa -= fStepSize;
    233     }
    234  
    235 
    236   //  return (Float_t)maxAb;
    237   return (Float_t)halfMaxAb;
     185   return (Float_t)spline->EvalAbMax();
    238186}
    239187
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h

    r2921 r3212  
    2424
    2525    Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices);
    26 
    27     Float_t fStepSize;           // The step size to evaluate the time
    28    
     26 
    2927public:
    3028    MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
    3129    ~MArrivalTimeCalc(){}
    32 
    33     void SetStepSize(Float_t s)      { fStepSize = s;   }
    34    
     30 
    3531    ClassDef(MArrivalTimeCalc, 0)   // Task to calculate Arrival Times from raw data
    3632};
Note: See TracChangeset for help on using the changeset viewer.