Changeset 8565 for trunk


Ignore:
Timestamp:
06/16/07 23:10:47 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc

    r8502 r8565  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.5 2007-05-14 09:53:15 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.6 2007-06-16 22:05:27 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    129129}
    130130
     131void MPedestalSubtract::Memcpy(void *dest, Int_t offset, void *src, Int_t cnt) const
     132{
     133        memcpy(dest+offset, src, cnt);
     134/*
     135    if (fRawEvt->GetNumBytesPerSample()==2)
     136        memcpy((UShort_t*)dest+offset, src, cnt*2);
     137    else
     138    {
     139        const Byte_t *b = (Byte_t*)src+offset;
     140        for (USample_t *ptr=(USample_t*)dest; ptr<(USample_t*)dest+cnt; ptr++)
     141            *ptr = *b++;
     142    }
     143 */
     144}
     145
    131146// --------------------------------------------------------------------------
    132147//
     
    137152    const Int_t numh = fRawEvt->GetNumHiGainSamples();
    138153    const Int_t numl = fRawEvt->GetNumLoGainSamples();
     154
     155    const UInt_t scale = fRawEvt->GetScale();
    139156
    140157    // initialize fSignal
     
    154171        }
    155172        // Get pointer were to store merged raw data
    156         Byte_t *sample = fSignal->GetSamplesRaw(pixidx);
     173        USample_t *sample = fSignal->GetSamplesRaw(pixidx);
    157174
    158175        // copy hi- and lo-gains samples together
    159         memcpy(sample,      pixel.GetHiGainSamples(), numh);
    160         memcpy(sample+numh, pixel.GetLoGainSamples(), numl);
     176        Memcpy(sample, 0,    pixel.GetHiGainSamples(), numh);
     177        Memcpy(sample, numh, pixel.GetLoGainSamples(), numl);
    161178
    162179        // start of destination array, end of hi-gain destination array
     
    165182        Float_t *end = beg + fSignal->GetNumSamples();
    166183
    167         const Byte_t *src = sample;
     184        const USample_t *src = sample;
    168185
    169186        // if no pedestals are given just convert the data into
     
    172189        {
    173190            while (beg<end)
    174                 *beg++ = *src++;
     191                *beg++ = *src;//Float_t(*src++)/scale;
    175192            continue;
    176193        }
     
    191208        // FIXME: Shell we really subtract the pedestal from saturating slices???
    192209        for (Float_t *ptr=beg; ptr<end; ptr++)
    193             *ptr = (Float_t)*src++ - mean[(ptr-beg)&1];
     210            *ptr = Float_t(*src++)/scale - mean[(ptr-beg)&1];
    194211    }
    195212
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.h

    r8154 r8565  
    2626    Int_t  Process();
    2727
     28    void Memcpy(void *sample, Int_t offset, void *ptr, Int_t cnt) const;
     29
    2830public:
    2931    MPedestalSubtract(const char *name=NULL, const char *title=NULL);
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc

    r8561 r8565  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.5 2007-06-15 12:58:57 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.6 2007-06-16 22:08:00 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    8282// The user is responsible not to exceed the slices for one pixel!
    8383//
    84 Byte_t *MPedestalSubtractedEvt::GetSamplesRaw(UInt_t pixel) const
     84USample_t *MPedestalSubtractedEvt::GetSamplesRaw(UInt_t pixel) const
    8585{
    8686    return pixel>=fNumPixels ? NULL : fSamplesRaw.GetArray()+pixel*fNumSamples;
     
    103103{
    104104    // Determin saturation of hi-gains
    105     Byte_t *p0 = GetSamplesRaw(idx);
    106 
    107     Byte_t *sat0 = 0; // first saturating slice
    108     Byte_t *sat1 = 0; // last  saturating slice
     105    USample_t *p0 = GetSamplesRaw(idx);
     106
     107    USample_t *sat0 = 0; // first saturating slice
     108    USample_t *sat1 = 0; // last  saturating slice
    109109
    110110    Int_t num = 0;
    111111
    112     const Byte_t *end = p0+last;
    113     for (Byte_t *ptr=p0+first; ptr<=end; ptr++)
     112    const USample_t *end = p0+last;
     113    for (USample_t *ptr=p0+first; ptr<=end; ptr++)
    114114    {
    115115        if (*ptr>=limit)
     
    170170{
    171171    // Get pointer to first slice to be considered
    172     Byte_t const *sam = GetSamplesRaw(idx);
    173 
    174     Byte_t const *beg = sam+first;
     172    USample_t const *sam = GetSamplesRaw(idx);
     173
     174    USample_t const *beg = sam+first;
    175175
    176176    // The best information so far: the first slice is the maximum
    177     const Byte_t *max = beg;
    178 
    179     for (const Byte_t *ptr=beg+1; ptr<=sam+last; ptr++)
     177    const USample_t *max = beg;
     178
     179    for (const USample_t *ptr=beg+1; ptr<=sam+last; ptr++)
    180180        if (*ptr>*max)
    181181            max = ptr;
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h

    r8519 r8565  
    1111#include "MArrayF.h"
    1212#endif
    13 #ifndef MARS_MArrayB
    14 #include "MArrayB.h"
     13#ifndef MARS_MArrayS
     14#include "MArrayS.h"
    1515#endif
     16
     17//typedef UShort_t USample_t;
     18typedef Byte_t USample_t;
    1619
    1720class MPedestalSubtractedEvt : public MParContainer, public MCamEvent
     
    2023    MArrayF fSamples;        // list of all samples with pedestal subtracted
    2124    MArrayB fSamplesRaw;     // list of all samples (raw)
     25//    MArrayS fSamplesRaw;     // list of all samples (raw)
    2226
    2327    UInt_t fNumSamples;      // number of samples per pixel
     
    3337    void InitSamples(UInt_t samples, UInt_t pixels=0);
    3438
    35     Float_t *GetSamples(UInt_t pixel) const;
    36     Byte_t *GetSamplesRaw(UInt_t pixel) const;
     39    Float_t   *GetSamples(UInt_t pixel) const;
     40    USample_t *GetSamplesRaw(UInt_t pixel) const;
    3741
    3842    UInt_t   GetNumSamples() const { return fNumSamples; }
     
    101105    Int_t GetIntegralRaw(Int_t idx, Int_t first, Int_t last) const
    102106    {
    103         Byte_t *ptr = GetSamplesRaw(idx);
     107        USample_t *ptr = GetSamplesRaw(idx);
    104108
    105         const Byte_t *end = ptr + last - first + 1;
     109        const USample_t *end = ptr + last - first + 1;
    106110
    107111        Int_t sum = 0;
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r8383 r8565  
    115115    UShort_t GetNumNormalPixels() const;
    116116    UShort_t GetNumSpecialPixels() const;
     117    UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
    117118
    118119    UInt_t GetNumSamplesPerCrate() const
Note: See TracChangeset for help on using the changeset viewer.