Ignore:
Timestamp:
01/06/09 13:07:00 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8938 r9212  
    9191#include "MArrayS.h"
    9292#include "MArrayB.h"
     93#include "MArrayI.h"
    9394#include "MGeomCam.h"
    9495
     
    396397//  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
    397398//
    398 void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data)
     399void MRawEvtData::AddPixel(UShort_t nOfPixel, const TArrayC &data)
    399400{
    400401    const Int_t n = fRunHeader->GetNumSamples();
    401     if (data->GetSize()!=n)
     402    if (data.GetSize()!=n)
    402403    {
    403404        *fLog << err << "RawEvtData::AddPixel: Error, number of samples in ";
    404         *fLog << "TArrayC " << data->GetSize() << " doesn't match current number " << n << endl;
     405        *fLog << "TArrayC " << data.GetSize() << " doesn't match current number " << n << endl;
    405406        return;
    406407    }
     
    424425    // add the new slices as last entries to array
    425426    //
    426     fHiGainFadcSamples->AddAt((Byte_t*)data->GetArray(), fHiGainFadcSamples->GetSize()-n, n);
    427 }
     427    fHiGainFadcSamples->AddAt((Byte_t*)data.GetArray(), fHiGainFadcSamples->GetSize()-n, n);
     428}
     429
     430// --------------------------------------------------------------------------
     431//
     432// Add the contents of the MArrayI to the fHiGainFadcSamples
     433// One Integer is added to one sample in the array.
     434//
     435void MRawEvtData::Set(const MArrayI &data)
     436{
     437    const UInt_t n = fRunHeader->GetNumSamples()*fConnectedPixels;
     438
     439    Byte_t *dest = fHiGainFadcSamples->GetArray();
     440
     441    UInt_t *src  = reinterpret_cast<UInt_t*>(data.GetArray());
     442    UInt_t *end  = reinterpret_cast<UInt_t*>(data.GetArray()) + n;
     443
     444    switch (fNumBytesPerSample)
     445    {
     446    case 1:
     447        {
     448            Byte_t *ptr = reinterpret_cast<Byte_t*>(dest);
     449            while (src<end)
     450                *ptr++ = *src++;
     451        }
     452        return;
     453
     454    case 2:
     455        {
     456            UShort_t *ptr = reinterpret_cast<UShort_t*>(dest);
     457            while (src<end)
     458                *ptr++ = *src++;
     459        }
     460        return;
     461
     462    case 4:
     463        memcpy(dest, data.GetArray(), n*4);
     464        return;
     465    }
     466}
     467
    428468/*
    429469void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag)
Note: See TracChangeset for help on using the changeset viewer.