Changeset 3232 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/18/04 16:50:18 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3231 r3232  
    4545   * mraw/MRawFileRead.cc:
    4646     - don't print warning in case of none executions
     47
     48   * manalysis/MArrivalTimeCalc2.cc:
     49     - added some const-qualifiers
    4750
    4851
  • trunk/MagicSoft/Mars/manalysis/MArrivalTimeCalc2.cc

    r3213 r3232  
    7777void MArrivalTimeCalc2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
    7878{
    79 
    8079    fNumHiGainSamples = hilast-hifirst+1;
    8180    fNumLoGainSamples = lolast-lofirst+1;
     
    8483    fLoGainFirst = lofirst;
    8584
    86    
    8785    fWindowSize = windowsize & ~1;
    8886
    8987    if (fWindowSize != windowsize)
    9088      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
    91    
     89
    9290    if (fWindowSize<2)
    9391    {
     
    9593      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to two samples" << endl;
    9694    }
    97    
     95
    9896    if (fWindowSize > fNumHiGainSamples)
    9997    {
     
    10199      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
    102100    }
    103    
     101
    104102    if (fWindowSize > fNumLoGainSamples)
    105103    {
     
    109107
    110108    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
    111 
    112 }
    113 
    114 
     109}
    115110
    116111// --------------------------------------------------------------------------
     
    134129    }
    135130
    136 
    137    
    138 
    139131    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
    140132    if (!fPedestals)
     
    147139    if (!fArrivalTime)
    148140        return kFALSE;
    149  
     141
    150142    return kTRUE;
    151143}
     
    157149    Int_t sum=0;    // integral content of the actual window
    158150    Int_t max = 0;  // highest integral content of all windows
    159      
     151
    160152    //
    161153    // Calculate the sum of the first fWindowSize slices
     
    163155    sat = 0;
    164156    Byte_t *p = ptr;
    165  
    166157
    167158    while (p<ptr+fWindowSize)
     
    198189    }
    199190
    200 
    201191    // now calculate the time for the maximum window
    202 
    203 
    204     Int_t timesignalsum = 0; 
     192    Int_t timesignalsum = 0;
    205193    Int_t timesquaredsum =0;
    206     Int_t timesum =0;   
    207    
    208    
     194    Int_t timesum =0;
     195
    209196    for (p=ptrmax; p < ptrmax + fWindowSize; p++)
    210197    {
    211       timesignalsum += *p*(p-ptr);
    212       timesum += p-ptr;
    213       timesquaredsum  += (p-ptr)*(p-ptr);
    214     }
    215    
    216 
    217     float pedsubsum = max - fWindowSize*pedes;
    218 
    219     float pedsubtimesignalsum = timesignalsum - timesum*pedes;
    220 
    221     time = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum : 1;
    222 
     198        timesignalsum += *p*(p-ptr);
     199        timesum += p-ptr;
     200        timesquaredsum  += (p-ptr)*(p-ptr);
     201    }
     202
     203    const Float_t pedsubsum = max - fWindowSize*pedes;
     204    const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
     205
     206    time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum : 1;
    223207    deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fWindowSize*time) : 1;
    224208}
     
    232216{
    233217    MRawEvtPixelIter pixel(fRawEvt);
    234    
    235218
    236219    Int_t sat=0;
     
    251234
    252235        MArrivalTimePix &pix = (*fArrivalTime)[pixid];
    253      
     236
    254237        const Float_t pedes  = ped.GetPedestal();
    255238        const Float_t pedrms = ped.GetPedestalRms();
    256239
    257 
    258240        FindSignalTime(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, timehi, deltatimehi, sathi, pedes, pedrms);
    259241        FindSignalTime(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, timelo, deltatimelo, satlo, pedes, pedrms);
    260        
    261         if (satlo)
     242
     243        if (satlo)
    262244            sat++;
    263      
    264         pix.SetArrivalTime(timehi, deltatimehi,
    265                            timelo, deltatimelo);       
    266        
     245
     246        pix.SetArrivalTime(timehi, deltatimehi, timelo, deltatimelo);
    267247        pix.SetGainSaturation(sathi, sathi, satlo);
    268 
    269 
    270     } /* while (pixel.Next()) */
     248    }
    271249
    272250    fArrivalTime->SetReadyToSave();
     
    278256        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
    279257
    280  
    281258    return kTRUE;
    282259}
Note: See TracChangeset for help on using the changeset viewer.