Changeset 2785 for trunk/MagicSoft


Ignore:
Timestamp:
01/13/04 15:46:33 (21 years ago)
Author:
raducci
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
3 edited

Legend:

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

    r2756 r2785  
    5555}
    5656
     57// Sets every pixel arrival time to -1
     58void MArrivalTime::CleanArray(const MGeomCam &geom)
     59{
     60    fData.Set(geom.GetNumPixels());
     61    fData.Reset(-1.0);
     62}
     63
    5764//
    5865// Calculates the arrival time for each pixel
     
    6269//
    6370
    64 void MArrivalTime::Calc(const MRawEvtData &evt, const MGeomCam &geom)
    65 {
    66     const Int_t n = geom.GetNumPixels();
    67 
    68     fData.Set(n);
    69     fData.Reset();
    70 
    71     MRawEvtPixelIter pixel((MRawEvtData*)&evt);
    72    
    73     while ( pixel.Next() )
    74     {
    75         const UInt_t idx = pixel.GetPixelId();
    76 
    77 //If pixel has saturated and hasn't lo gains we return -1
    78 
    79         if (pixel.GetMaxHiGainSample() == 0xff)
    80         {   
    81             if (!pixel.HasLoGain())       
    82             {
    83                 fData[idx]=-1.0;
    84             }
    85             else //Calculate time using Lo Gains
    86             {
    87                 Byte_t *ptr = pixel.GetLoGainSamples();
    88 
    89                 Int_t nSlice = evt.GetNumLoGainSamples();
     71void MArrivalTime::Calc(const Byte_t *fadcSamples, const Short_t nSlice,
     72              const Short_t idx, const MGeomCam &geom)
     73{
     74
    9075//Some casts are needed because TSpline5 constructor accepts only Double_t values
    91                 Double_t ptr2[nSlice];
    92                 for (Int_t i = 0; i < nSlice; i++)
    93                     ptr2[i]=(Double_t)ptr[i];
    94                 TSpline5 *spline = new TSpline5("spline",(Double_t) 0,(Double_t)(nSlice - 1),ptr2,nSlice);
     76    Double_t ptr[nSlice];
     77
     78    for (Int_t i = 0; i < nSlice; i++)
     79        ptr[i]=(Double_t)fadcSamples[i];
     80
     81    TSpline5 *spline = new TSpline5("spline",(Double_t) 0,
     82                                    (Double_t)(nSlice - 1),ptr,nSlice);
    9583//Now find the maximum evaluating the spline function at every 1/10 time slice
    96                 Double_t abscissa=0.0;
    97                 Double_t maxAb=0.0;
    98                 Double_t maxOrd=0.0;
    99                 Double_t swap;
    100                 while (abscissa <= nSlice - 1)
    101                 {
    102                     swap=spline->Eval(abscissa);
    103                     if (swap > maxOrd)
    104                     {
    105                         maxOrd = swap;
    106                         maxAb  = abscissa;
    107                     }
    108                     abscissa += 0.1;
    109                 }
    110                 fData[idx]=maxAb;
    111             }
     84    Double_t abscissa=0.0;
     85    Double_t maxAb=0.0;
     86    Double_t maxOrd=0.0;
     87    Double_t swap;
     88    while (abscissa <= nSlice - 1)
     89    {
     90        swap=spline->Eval(abscissa);
     91        if (swap > maxOrd)
     92        {
     93            maxOrd = swap;
     94            maxAb  = abscissa;
    11295        }
    113         else //Calculate time using Hi Gains
    114         {
    115             Byte_t *ptr = pixel.GetHiGainSamples();
    116 
    117             Int_t nSlice = evt.GetNumHiGainSamples();
    118 //Some casts are needed because TSpline5 constructor accepts only Double_t values
    119             Double_t  ptr2[nSlice];
    120             for (Int_t i = 0; i < nSlice; i++)
    121                 ptr2[i]=(Double_t)ptr[i];
    122             TSpline5 *spline = new TSpline5("spline",(Double_t) 0,(Double_t)(nSlice - 1),ptr2,nSlice);
    123 //Now find the maximum evaluating the spline function at every 1/10 time slice
    124             Double_t abscissa=0.0;
    125             Double_t maxAb=0.0;
    126             Double_t maxOrd=0.0;
    127             Double_t swap;
    128             while (abscissa <= nSlice - 1)
    129             {
    130                 swap=spline->Eval(abscissa);
    131                 if (swap > maxOrd)
    132                 {
    133                     maxOrd = swap;
    134                     maxAb  = abscissa;
    135                 }
    136                 abscissa += 0.1;
    137             }
    138             fData[idx]=maxAb;
    139         }
    140     }
     96        abscissa += 0.1;
     97    }
     98    fData[idx]=maxAb;
    14199}
    142100
     
    157115
    158116    fData2.Set(n);
    159     fData2.Reset(-1);
     117    fData2.Reset(-1.0);
    160118    fData3.Set(n);
    161     fData3.Reset(-1);
     119    fData3.Reset(-1.0);
    162120    fData4.Set(n);
    163     fData4.Reset(-1);
     121    fData4.Reset(-1.0);
    164122    fData5.Set(n);
    165     fData5.Reset(-1);
     123    fData5.Reset(-1.0);
    166124
    167125    MRawEvtPixelIter pixel((MRawEvtData*)&evt);
     
    181139    }
    182140// End of fakeData preparation
    183 
     141    *fLog << warn << "fin qui bene" << endl;
    184142// Max dimension of cluster
    185143    Short_t dimCluster;
  • trunk/MagicSoft/Mars/manalysis/MArrivalTime.h

    r2756 r2785  
    3838    UInt_t GetNumPixels() const { return fData.GetSize(); }
    3939
    40     void Calc(const MRawEvtData &evt, const MGeomCam &geom); // Calculates arrival times
     40    void CleanArray(const MGeomCam &geom); //Sets every arr time to -1
    4141
    42     void  MArrivalTime::EvalClusters(const MRawEvtData &evt, const MGeomCam &geom);
     42    void Calc(const Byte_t *fadcSamples, const Short_t nSlice,
     43              const Short_t idx, const MGeomCam &geom); // Calculates arrival times
    4344
    44     void MArrivalTime::CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
     45    void EvalClusters(const MRawEvtData &evt, const MGeomCam &geom);
     46
     47    void CheckNeighbours(const MRawEvtData &evt, const MGeomCam &geom,
    4548                                       Short_t idx, Short_t *dimCluster);
    4649
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc.cc

    r2752 r2785  
    129129    MRawEvtPixelIter pixel(fRawEvt);
    130130
    131     fArrTime->Calc((const MRawEvtData&) *fRawEvt,(const MGeomCam&) *fGeom);
     131// Every pixel is set to -1
     132    fArrTime->CleanArray((const MGeomCam&) *fGeom);
     133
     134    while (pixel.Next())
     135    {
     136        const UInt_t idx = pixel.GetPixelId();
     137// If pixel is saturated we use LoGains
     138        if (pixel.GetMaxHiGainSample() == 0xff && pixel.HasLoGain())
     139        {
     140            const Byte_t *ptr = pixel.GetLoGainSamples();
     141            const Short_t nSlice = fRawEvt->GetNumLoGainSamples();
     142            fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
     143        }
     144// Use HiGains
     145        else
     146        {
     147            const Byte_t *ptr = pixel.GetHiGainSamples();
     148            const Short_t nSlice = fRawEvt->GetNumHiGainSamples();
     149            fArrTime->Calc(ptr, nSlice, idx, (const MGeomCam&) *fGeom);
     150        }
     151// If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
     152    }
     153   
    132154    fArrTime->SetReadyToSave();
    133155
    134     while (pixel.Next()){;}
    135    
    136156    return kTRUE;
    137157}
Note: See TracChangeset for help on using the changeset viewer.