Ignore:
Timestamp:
06/17/07 15:51:55 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc

    r8364 r8571  
    6363MRawEvtPixelIter::MRawEvtPixelIter(MRawEvtData *dat) : fABFlags(0), fData(dat)
    6464{
    65     fNumHiGainSamples = dat->GetNumHiGainSamples();
    66     fNumLoGainSamples = dat->GetNumLoGainSamples();
     65    fNumBytesHiGain  = dat->GetNumHiGainSamples()*dat->GetNumBytesPerSample();
     66    fNumBytesLoGain  = dat->GetNumLoGainSamples()*dat->GetNumBytesPerSample();
    6767
    6868    Reset();
     
    9191        fNumHiGainEntry++;
    9292        fHiGainId++;
    93         fHiGainPos += fNumHiGainSamples;
     93        fHiGainPos += fNumBytesHiGain;
    9494
    9595        fNumLoGainEntry++;
    9696        fLoGainId++;
    97         fLoGainPos += fNumLoGainSamples;
     97        fLoGainPos += fNumBytesLoGain;
    9898    }
    9999    else
     
    102102        fLoGainId       = ++fHiGainId;
    103103
    104         fHiGainPos     += fNumHiGainSamples+fNumLoGainSamples;
    105         fLoGainPos      = fHiGainPos + fNumHiGainSamples;
     104        fHiGainPos     += fNumBytesHiGain+fNumBytesLoGain;
     105        fLoGainPos      = fHiGainPos + fNumBytesHiGain;
    106106    }
    107107
     
    137137    {
    138138        fLoGainId  = fData->fLoGainPixId->GetArray();
    139         fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fNumHiGainSamples;
    140         fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fNumLoGainSamples;
     139        fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fNumBytesHiGain;
     140        fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fNumBytesLoGain;
    141141    }
    142142    else
    143143    {
    144144        fLoGainId  = fHiGainId;
    145         fLoGainPos = fHiGainPos+fNumHiGainSamples;
    146         fHiGainPos = fData->fHiGainFadcSamples->GetArray()-(fNumHiGainSamples+fNumLoGainSamples);
     145        fLoGainPos = fHiGainPos+fNumBytesHiGain;
     146        fHiGainPos = fData->fHiGainFadcSamples->GetArray()-(fNumBytesHiGain+fNumBytesLoGain);
    147147    }
    148148
     
    163163    fData->Draw(Form("%s%d", t, *fHiGainId));
    164164}
    165 
    166 /*
    167 // --------------------------------------------------------------------------
    168 //
    169 // Returns the index of the FADC slice the maximum signal in. If the highest
    170 // slices have the same value the first one is returned.
    171 //
    172 Byte_t MRawEvtPixelIter::GetIdxMaxHiGainSample(const Byte_t hifirst, const Byte_t hilast) const
    173 {
    174     const Int_t l = hilast>fNumHiGainSamples  ? fNumHiGainSamples : hilast+1;
    175 
    176     Byte_t *beg = fHiGainPos+hifirst;
    177 
    178     Byte_t *ptr = beg+1;
    179     Byte_t *max = beg;
    180     const Byte_t *end = fHiGainPos + l;
    181 
    182     do if (*ptr>*max) max = ptr;
    183     while (++ptr != end);
    184 
    185     return max-fHiGainPos;
    186 }
    187 
    188 // --------------------------------------------------------------------------
    189 //
    190 // Returns the index of the FADC slice the maximum signal in. If no lo-gains
    191 // are available -1 is returned. If the highest slices have the same value
    192 // the first one is returned.
    193 //
    194 Short_t MRawEvtPixelIter::GetIdxMaxLoGainSample(const Byte_t lofirst, const Byte_t lolast) const
    195 {
    196     if (!HasLoGain())
    197         return -1; // means: not found
    198 
    199     const Int_t l = lolast>fNumLoGainSamples  ? fNumLoGainSamples : lolast+1;
    200 
    201     Byte_t *beg = fLoGainPos+lofirst;
    202 
    203     Byte_t *ptr = beg+1;
    204     Byte_t *max = beg;
    205     const Byte_t *end = fLoGainPos + l;
    206 
    207     do if (*ptr>*max) max = ptr;
    208     while (++ptr != end);
    209 
    210     return max-fLoGainPos;
    211 }
    212 
    213 // --------------------------------------------------------------------------
    214 //
    215 // Returns the maximum signal of all sliced in the hi gain samples
    216 //
    217 Byte_t MRawEvtPixelIter::GetMaxHiGainSample(const Byte_t hifirst, const Byte_t hilast) const
    218 {
    219     Byte_t max = 0;
    220 
    221     const Int_t f = hifirst;
    222     const Int_t l = hilast>fNumHiGainSamples  ? fNumHiGainSamples : hilast+1;
    223 
    224     for (int i=f; i<l; i++)
    225         if (fHiGainPos[i]>max)
    226             max = fHiGainPos[i];
    227 
    228     return max;
    229 }
    230 
    231 // --------------------------------------------------------------------------
    232 //
    233 // returns the sum of all hi gain fadc samples of the actual pixel
    234 //
    235 ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const
    236 {
    237     //
    238     // return the sum of the hi gain samples of the present pixel
    239     //
    240     Byte_t *ptr = fHiGainPos;
    241     const Byte_t *end = fHiGainPos + fNumHiGainSamples;
    242 
    243     ULong_t sum=0;
    244 
    245     do sum += *ptr++;
    246     while (ptr != end);
    247 
    248     return sum;
    249 }
    250 
    251 // --------------------------------------------------------------------------
    252 //
    253 // returns the sum of squares of all hi gain fadc sample of the actual pixel
    254 //
    255 ULong_t MRawEvtPixelIter::GetSumSqrHiGainSamples() const
    256 {
    257     //
    258     // return the sum of the squares of the hi gain samples of the present pixel
    259     //
    260     Byte_t *ptr = fHiGainPos;
    261     const Byte_t *end = fHiGainPos + fNumHiGainSamples;
    262 
    263     ULong_t sum=0;
    264 
    265     do sum += (*ptr)*(*ptr);
    266     while (++ptr != end);
    267 
    268     return sum;
    269 }
    270 
    271 // --------------------------------------------------------------------------
    272 //
    273 // Returns the variance (sigma^2) of the HiGainSamples
    274 //
    275 Float_t MRawEvtPixelIter::GetVarHiGainSamples() const
    276 {
    277     Byte_t *ptr = fHiGainPos;
    278     const Byte_t *end = fHiGainPos + fNumHiGainSamples;
    279 
    280     ULong_t sum=0;
    281     ULong_t sqsum=0;
    282 
    283     do {
    284         sum += *ptr;
    285         sqsum += (*ptr)*(*ptr);
    286     } while (++ptr != end);
    287 
    288     return (sqsum-(Float_t)sum*sum/fNumHiGainSamples)/(fNumHiGainSamples-1);
    289 }
    290 
    291 // --------------------------------------------------------------------------
    292 //
    293 // Returns the index of the maximum FADC slice from high gain at first. If
    294 // high gain is saturated it returns the low gain one.
    295 // If no lo-gains are existing and the hi-gains have saturating values
    296 // a negative value (-1) is returned.
    297 //
    298 Short_t MRawEvtPixelIter::GetIdxMaxHiLoGainSample() const
    299 {
    300     Byte_t max  = 0;
    301     Char_t maxi = 0;
    302 
    303     for (int i=fNumHiGainSamples-1; i>=0; i--)
    304         if (fHiGainPos[i]>max)
    305         {
    306             max  = fHiGainPos[i];
    307             maxi = i;
    308         }
    309 
    310     return max<0xff ? maxi : GetIdxMaxLoGainSample();
    311 }
    312 
    313 // --------------------------------------------------------------------------
    314 //
    315 // Returns the maximum signal of all sliced in the hi gain samples
    316 //
    317 Byte_t MRawEvtPixelIter::GetMaxLoGainSample() const
    318 {
    319     Byte_t max = 0;
    320 
    321     for (int i=fNumLoGainSamples-1; i>=0; i--)
    322         if (fLoGainPos[i]>max)
    323             max = fLoGainPos[i];
    324 
    325     return max;
    326 }
    327 
    328 // --------------------------------------------------------------------------
    329 //
    330 // returns the sum of all lo gain fadc samples of the actual pixel.
    331 // if no lo gain information is available 0 is returned.
    332 //
    333 ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const
    334 {
    335     //
    336     // return the sum of the lo gain samples of the present pixel
    337     //
    338     if (!HasLoGain())
    339         return 0;
    340 
    341     Byte_t *ptr = fLoGainPos;
    342     const Byte_t *end = fLoGainPos + fNumLoGainSamples;
    343 
    344     ULong_t sum=0;
    345 
    346     do sum += *ptr++;
    347     while (ptr != end);
    348 
    349     return sum;
    350 }
    351 
    352 // --------------------------------------------------------------------------
    353 //
    354 // returns the sum of squares of all hi gain fadc sample of the actual pixel
    355 //
    356 ULong_t MRawEvtPixelIter::GetSumSqrLoGainSamples() const
    357 {
    358     //
    359     // return the sum of the lo gain samples squares of the present pixel
    360     //
    361     if (!HasLoGain())
    362         return 0;
    363 
    364     Byte_t *ptr = fLoGainPos;
    365     const Byte_t *end = fLoGainPos + fNumLoGainSamples;
    366 
    367     ULong_t sum=0;
    368 
    369     do sum += (*ptr)*(*ptr);
    370     while (++ptr != end);
    371 
    372     return sum;
    373 }
    374 */
Note: See TracChangeset for help on using the changeset viewer.