Ignore:
Timestamp:
01/26/04 13:50:17 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MArrivalTime.cc

    r2910 r2911  
    6565void MArrivalTime::Reset()
    6666{
    67     // Do not use 'TArray::Reset()' or memset. It sets all single
    68     // bytes to -1 (in other words, it fills the array with 0xff)
    69     for (int i=0; i<fData.GetSize(); i++)
    70         fData[i] = -1;
     67  //
     68  // Do not use 'TArray::Reset()' or memset. It sets all single
     69  // bytes to -1 (in other words, it fills the array with 0xff)
     70  for (int i=0; i<fData.GetSize(); i++)
     71    fData[i] = -1;
    7172}
    7273
     
    8081// Set the arrival time in one pixel
    8182//
    82 void MArrivalTime::SetTime(Int_t i, Float_t t)
     83void MArrivalTime::SetTime(const Int_t i, const Float_t t)
    8384{
    8485    fData[i] = t;
    85 }
    86 
    87 // -------------------------------------------------------------------------
    88 //
    89 // Calculates the arrival time for each pixel
    90 // Possible Methods
    91 // Case 1: Spline5 (From TSpline5 Root Class)
    92 //
    93 //
    94 void MArrivalTime::Calc(const Byte_t *fadcSamples, const Short_t nSlice,
    95                         const Short_t idx)
    96 {
    97 
    98 //Some casts are needed because TSpline5 constructor accepts only Double_t values
    99     Double_t ptr[nSlice];
    100 
    101     for (Int_t i = 0; i < nSlice; i++)
    102         ptr[i]=(Double_t)fadcSamples[i];
    103 
    104     TSpline5 *spline = new TSpline5("spline",(Double_t) 0,
    105                                     (Double_t)(nSlice - 1),ptr,nSlice);
    106 //Now find the maximum evaluating the spline function at every 1/10 time slice
    107     Double_t abscissa=0.0;
    108     Double_t maxAb=0.0;
    109     Double_t maxOrd=0.0;
    110     Double_t swap;
    111     while (abscissa <= nSlice - 1)
    112     {
    113         swap=spline->Eval(abscissa);
    114         if (swap > maxOrd)
    115         {
    116             maxOrd = swap;
    117             maxAb  = abscissa;
    118         }
    119         abscissa += 0.1;
    120     }
    121     fData[idx]=maxAb;
    12286}
    12387
  • trunk/MagicSoft/Mars/manalysis/MArrivalTime.h

    r2910 r2911  
    3838    UInt_t GetNumPixels() const { return fData.GetSize(); }
    3939
    40     void SetTime(Int_t i, Float_t time);
    41     const TArrayF &GetData() const { return fData; }
    42     Double_t operator[](int i) { return fData[i]; }
    43 
    44     void Calc(const Byte_t *fadcSamples, const Short_t nSlice, const Short_t idx);
    4540    void EvalClusters(const MRawEvtData &evt, const MGeomCam &geom);
    4641    void CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
    4742                         Short_t idx, Short_t *dimCluster);
     43
     44    void SetTime(const Int_t i, const Float_t time);
     45   
     46    const TArrayF &GetData() const { return fData; }
     47
     48    Double_t operator[](int i) { return fData[i]; }
    4849
    4950    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc

    r2910 r2911  
    6161MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title)
    6262{
     63
    6364    fName  = name  ? name  : "MArrivalTimeCalc";
    6465    fTitle = title ? title : "Calculate photons arrival time";
     
    111112}
    112113
    113 
    114114// --------------------------------------------------------------------------
    115115//
     
    119119Int_t MArrivalTimeCalc::Process()
    120120{
    121     MRawEvtPixelIter pixel(fRawEvt);
    122 
    123     while (pixel.Next())
    124     {
    125         const UInt_t idx = pixel.GetPixelId();
    126 
    127         // If pixel is saturated we use LoGains
    128         if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
     121
     122  MRawEvtPixelIter pixel(fRawEvt);
     123 
     124  while (pixel.Next())
     125    {
     126     
     127      const UInt_t idx = pixel.GetPixelId();
     128      Float_t max = 0.;
     129
     130
     131      //
     132      // If pixel is saturated we use LoGains
     133      //
     134      if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
     135        {
     136         
     137          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
     138          max = Calc(pixel.GetLoGainSamples(),nslices);
     139        }
     140     
     141
     142      //
     143      // Use HiGains
     144      //
     145      else if (pixel.HasLoGain())
     146        {
     147         
     148          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
     149          max = Calc(pixel.GetHiGainSamples(),nslices);
     150        }
     151     
     152      //
     153      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
     154      //
     155      fArrTime->SetTime(idx,max);
     156     
     157    }
     158   
     159  fArrTime->SetReadyToSave();
     160 
     161  return kTRUE;
     162}
     163
     164//
     165// Calculates the arrival time for each pixel
     166// Possible Methods
     167// Case 1: Spline5 (From TSpline5 Root Class)
     168//
     169//
     170Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices)
     171{
     172
     173  //
     174  // Initialize a double pointer with filled FADC slices
     175  //
     176  Double_t ptr[nslices];
     177
     178  //
     179  // Initialize the spline
     180  //
     181  for (Int_t i = 0; i < nslices; i++)
     182    ptr[i]=(Double_t)fadcSamples[i];
     183 
     184  TSpline5 spline("spline",0.,(Double_t)(nslices - 1),ptr,nslices);
     185
     186  //
     187  // Now find the maximum evaluating the spline function at every 1/10 time slice
     188  //
     189  Double_t abscissa=0.0;
     190  Double_t maxAb=0.0;
     191  Double_t maxOrd=0.0;
     192  Double_t swap = 0.0;
     193
     194  while (abscissa <= nslices - 1)
     195    {
     196
     197      swap = spline.Eval(abscissa);
     198
     199      if (swap > maxOrd)
    129200        {
    130             const Byte_t *ptr = pixel.GetLoGainSamples();
    131             const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
    132             fArrTime->Calc(ptr, nSlice, idx);
     201          maxOrd = swap;
     202          maxAb  = abscissa;
    133203        }
    134         // Use HiGains
    135         else
    136         {
    137             const Byte_t *ptr = pixel.GetHiGainSamples();
    138             const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
    139             fArrTime->Calc(ptr, nSlice, idx);
    140         }
    141         // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
    142     }
    143    
    144     fArrTime->SetReadyToSave();
    145 
    146     return kTRUE;
    147 }
     204      abscissa += 0.1;
     205    }
     206
     207  return (Float_t)maxAb;
     208}
     209
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.h

    r2910 r2911  
    77
    88class MRawEvtData;
     9class MRawRunHeader;
    910class MArrivalTime;
    1011
    1112class MArrivalTimeCalc : public MTask
    1213{
    13 private:
    14     MRawEvtData  *fRawEvt;     // raw event data (time slices)
    15     MArrivalTime *fArrTime;    // Container with the photons arrival times
    1614
     15    MRawEvtData    *fRawEvt;     // raw event data (time slices)
     16    MRawRunHeader  *fRunHeader;  // RunHeader information
     17
     18    MArrivalTime   *fArrTime;    // Container with the photons arrival times
     19
     20    Int_t PreProcess(MParList *pList);
    1721    Bool_t ReInit(MParList *pList);
    18     Int_t  PreProcess(MParList *pList);
    19     Int_t  Process();
    20     Int_t  PostProcess() {return kTRUE;}
     22    Int_t Process();
     23    Int_t PostProcess() {return kTRUE;}
    2124
     25    Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices);
     26   
    2227public:
    2328    MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
Note: See TracChangeset for help on using the changeset viewer.