Changeset 8571 for trunk


Ignore:
Timestamp:
06/17/07 15:51:55 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8566 r8571  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2007/06/17 Thomas Bretz
     22
     23   * mpedestal/MExtractPedestal.[h,cc],
     24     mpedestal/MPedestalSubtract.cc,
     25     mpedestal/MPedestalSubtractedEvt.[h,cc]:
     26     - changed USample_t finally from Byte_t to UShort_t
     27     - adapted Memcpy accordingly
     28
     29   * mraw/MRawEvtData.[h,cc]:
     30     - increased class version to 7
     31     - added fNumBytesPerSample for simplification
     32     - take fNumBytesPerSample into account
     33     - changed draw and print option accordingly
     34     - changed reading of pixel information (in fact it is a
     35       simplification allowed by the flexible storage format)
     36     - added a private GetSample  member function to be used in
     37       data access for drawing a pixel
     38     - added returning of the scale (2^((numbytes-1)*8))
     39     - FIXME: GetPixelContent must be reimplemented!
     40
     41   * mraw/MRawEvtPixelIter.[h,cc]:
     42     - changed according to changes in MRawEvtData to support
     43       flexible daza format
     44     - removed a lot of old, obsolete and unsused member functions
     45
     46
    2047
    2148 2007/06/16 Thomas Bretz
  • trunk/MagicSoft/Mars/NEWS

    r8546 r8571  
    1212     data of about 15% (175evt/s instead of 150evt/s)
    1313
     14   - callisto: finally the raw data we read is now real 16bit (with
     15     10bit precision) for MUX data and not a stripped 8bit number
     16     anymore. Due to scaling of the numbers (without precision loss
     17     into an [0-256[ range, the final numbers for pedestal, pedestalrms
     18     and extacted signal don't change. However, at all places where
     19     raw data is directly accessed (eg. saturation and variation
     20     limits in the signal- and pedestal-extraction) the numbers
     21     refer still to the data's 16bit range.
    1422
    1523
     
    4957     pedestal files) individual pixels could be skipped due to high
    5058     variations. This was already the case for the pedestal extraction
    51      from th elo-gains since the beginning and properly handled
     59     from the lo-gains since the beginning and properly handled
    5260     there, but was introduced in the extraction from the pedestal files
    5361     a while ago. To calculate the average value it was still divided
  • trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h

    r8564 r8571  
    2424class MRawEvtPixelIter;
    2525
    26 //typedef UShort_t USample_t;
    27 typedef Byte_t USample_t;
     26typedef UShort_t USample_t;
    2827
    2928class MExtractPedestal : public MTask
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtract.cc

    r8565 r8571  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.6 2007-06-16 22:05:27 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MPedestalSubtract.cc,v 1.7 2007-06-17 14:51:55 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    131131void MPedestalSubtract::Memcpy(void *dest, Int_t offset, void *src, Int_t cnt) const
    132132{
    133         memcpy(dest+offset, src, cnt);
    134 /*
    135133    if (fRawEvt->GetNumBytesPerSample()==2)
    136134        memcpy((UShort_t*)dest+offset, src, cnt*2);
     
    141139            *ptr = *b++;
    142140    }
    143  */
    144141}
    145142
  • trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h

    r8565 r8571  
    1515#endif
    1616
    17 //typedef UShort_t USample_t;
    18 typedef Byte_t USample_t;
     17typedef UShort_t USample_t;
    1918
    2019class MPedestalSubtractedEvt : public MParContainer, public MCamEvent
     
    2221private:
    2322    MArrayF fSamples;        // list of all samples with pedestal subtracted
    24     MArrayB fSamplesRaw;     // list of all samples (raw)
    25 //    MArrayS fSamplesRaw;     // list of all samples (raw)
     23    MArrayS fSamplesRaw;     // list of all samples (raw)
    2624
    2725    UInt_t fNumSamples;      // number of samples per pixel
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r8364 r8571  
    4747//
    4848//
     49//   Version 7
     50//   ------------------
     51//    + UShort_t fNumBytesPerSample;
     52//
    4953//   Version 6
    5054//   ------------------
     
    148152    // value set so far. So we use the old methid to determin the
    149153    // numbers and calculate them from the length of the arrays.
    150     return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/fHiGainPixId->GetSize() : 0;
     154    return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/(fHiGainPixId->GetSize()*fNumBytesPerSample) : 0;
    151155}
    152156
     
    160164    // value set so far. So we use the old methid to determin the
    161165    // numbers and calculate them from the length of the arrays.
    162     return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/fLoGainPixId->GetSize() : 0;
     166    return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/(fLoGainPixId->GetSize()*fNumBytesPerSample) : 0;
    163167}
    164168
     
    189193    const UShort_t nLoSamp = GetNumLoGainSamples();
    190194
     195    const UShort_t bps     = GetNumBytesPerSample();
     196
    191197    fLog->unsetf(ios::showbase);
    192198
     
    212218        *fLog << (manip?dec:hex) << setfill(manip?' ':'0');
    213219
    214         const Byte_t *hi = pixel.GetHiGainSamples();
    215         const Byte_t *lo = pixel.GetLoGainSamples();
    216 
    217         for (int j=0; j<nHiSamp; j++)
     220        const Byte_t *hi = (Byte_t*)pixel.GetHiGainSamples();
     221        const Byte_t *lo = (Byte_t*)pixel.GetLoGainSamples();
     222
     223        for (int j=0; j<nHiSamp*bps; j++)
    218224        {
    219225            *fLog << setw(manip?3:2);
    220             *fLog << ((UShort_t)hi[j]&0xff);
     226            *fLog << (hi[j]&0xff);
    221227            if (manip)
    222228                *fLog << ' ';
    223229        }
    224230
    225         for (int j=0; j<nLoSamp; j++)
     231        for (int j=0; j<nLoSamp*bps; j++)
    226232        {
    227233            *fLog << setw(manip?3:2);
     
    270276    }
    271277
    272     const Byte_t *higains = pix.GetHiGainSamples();
    273     const Byte_t *logains = pix.GetLoGainSamples();
     278    const void *higains = pix.GetHiGainSamples();
     279    const void *logains = pix.GetLoGainSamples();
    274280
    275281    const Int_t nh = GetNumHiGainSamples();
     
    289295
    290296        for (int i=0; i<nh; i++)
    291             graphhi->SetPoint(graphhi->GetN(), i, higains[i]);
     297            graphhi->SetPoint(graphhi->GetN(), i, GetSample(higains, i));
    292298        for (int i=0; i<nl; i++)
    293             graphhi->SetPoint(graphhi->GetN(), i+nh, logains[i]);
     299            graphhi->SetPoint(graphhi->GetN(), i+nh, GetSample(logains, i));
    294300
    295301        graphhi->SetMaximum(256);
     
    321327        histh->SetDirectory(NULL);
    322328        for (int i=0; i<nh; i++)
    323             histh->Fill(i, higains[i]);
     329            histh->Fill(i, GetSample(higains, i));
    324330        for (int i=0; i<nl; i++)
    325             histh->Fill(i, logains[i]);
     331            histh->Fill(i, GetSample(logains, i));
    326332        histh->SetBit(kCanDelete);
    327333        histh->Draw(same ? "same" : "");
     
    330336    }
    331337
    332     *fLog << warn << dbginf << "Warning - You must specify either 'GRAPH' or 'HIST'" << endl;
     338    *fLog << warn << dbginf << "WARNING - You must specify either 'GRAPH' or 'HIST'" << endl;
    333339}
    334340
     
    341347{
    342348    // fRunHeader should not be set only in the constructor!
    343     const Int_t numhi = fRunHeader ? fRunHeader->GetNumSamplesHiGain() : -1;
    344     const Int_t numlo = fRunHeader ? fRunHeader->GetNumSamplesLoGain() : -1;
     349    const Int_t numhi  = fRunHeader ? fRunHeader->GetNumSamplesHiGain()  : 0;
     350    const Int_t numlo  = fRunHeader ? fRunHeader->GetNumSamplesLoGain()  : 0;
     351
     352    fNumBytesPerSample = fRunHeader ? fRunHeader->GetNumBytesPerSample() : 1;
    345353
    346354    fHiGainPixId       = new MArrayS(numconnected);
    347355    fLoGainPixId       = new MArrayS(0);
    348     fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo));
     356    fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo)*fNumBytesPerSample);
    349357    fLoGainFadcSamples = new MArrayB(0);
    350358
     
    466474    const UInt_t ns = fRunHeader->GetNumSamples();
    467475
    468     // position in higain array
    469     Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*ns;
    470 
    471476    // bytes per sample
    472477    const Int_t bps = fRunHeader->GetNumBytesPerSample();
     
    475480    const Int_t nb = ns*bps;
    476481
     482    // position in higain array
     483    Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*nb;
     484
    477485    // Set pixel index
    478486    fHiGainPixId->AddAt(npix, fConnectedPixels++);
    479487
    480488    // Read data for one pixel
    481     if (bps==1)
    482     {
    483         fin.read((char*)pos, nb);
    484         return;
    485     }
    486 
    487     // Read data for one pixel
    488     Byte_t arr[nb];
    489     fin.read((char*)arr, nb);
    490 
    491     for (Byte_t *p=arr+bps-1; p<arr+nb; p+=bps)
    492         *pos++ = *p;
     489    fin.read((char*)pos, nb);
    493490}
    494491
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.h

    r8353 r8571  
    3636    MArrayB *fABFlags;            //-> A information about the exact trigger position
    3737
     38    UShort_t fNumBytesPerSample;
     39
    3840    Int_t fConnectedPixels;       //!
    3941
     
    4244
    4345    Int_t GetNumBytes() const;
     46
     47    UInt_t GetSample(const void *ptr, Int_t n) // Helper for Draw
     48    {
     49        switch (n)
     50        {
     51        case 1: return *(Byte_t*)ptr;
     52        case 2: return *(UShort_t*)ptr;
     53        case 3: return *(Int_t*)ptr;
     54        }
     55        return 0;
     56    }
    4457
    4558public:
     
    6881    UShort_t GetNumPixels() const;
    6982
     83    UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
     84    UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
     85
    7086    void ReadPixel(istream &fin, Int_t npix);
    7187    void SetABFlag(Int_t npix, Bool_t ab);
     
    86102        ;
    87103
    88     ClassDef(MRawEvtData, 6) //Container to store the raw Event Data
     104    ClassDef(MRawEvtData, 7) //Container to store the raw Event Data
    89105};
    90106
  • 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 */
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h

    r8364 r8571  
    3030    UShort_t  fNumEntry;
    3131
    32     Byte_t fNumHiGainSamples;   //!
    33     Byte_t fNumLoGainSamples;   //!
     32    Byte_t fNumBytesHiGain;   //!
     33    Byte_t fNumBytesLoGain;   //!
     34
     35    UShort_t fNumBytesPerSample; //!
    3436
    3537    MRawEvtData *fData;         //! pointer to object which we are iterating
     
    6668    }
    6769
    68     Byte_t *GetHiGainSamples() const
     70    void *GetHiGainSamples() const
    6971    {
    7072        //
     
    7779    }
    7880
    79     /*
    80      This function is dangerous as long as MC with split hi-/lo-gain are used
    81     Byte_t *GetSamples() const
    82     {
    83         //
    84         // return a pointer to the fadc samples of the hi gains
    85         // WARNING: Don't forget to get the number of valid entries
    86         //          (GetNumSamples) to know how many entries of the array
    87         //          belong to the actual pixel
    88         //
    89         return fHiGainPos;
    90     }
    91     */
     81    Byte_t  GetNumBytes() const { return fNumBytesHiGain+fNumBytesLoGain; }
    9282
    93 //    Byte_t  GetNumHiGainSamples() const { return fNumHiGainSamples ; }// Use is deprecated!
    94 //    Byte_t  GetNumLoGainSamples() const { return fNumLoGainSamples ; }// Use is deprecated!
    95     Byte_t  GetNumSamples() const { return fNumHiGainSamples+fNumLoGainSamples; }
    96 
    97 //    Byte_t  GetIdxMaxHiGainSample(const Byte_t hifirst=0, const Byte_t hilast=0xff) const;
    98 //    Short_t GetIdxMaxLoGainSample(const Byte_t lofirst=0, const Byte_t lolast=0xff) const;
    99 
    100 //    Byte_t  GetMaxHiGainSample(const Byte_t hifirst=0, const Byte_t hilast=0xff) const;
    101 
    102 //    ULong_t GetSumHiGainSamples() const;
    103 //    ULong_t GetSumSqrHiGainSamples() const;
    104 //    Float_t GetVarHiGainSamples() const;
    105 
    106 //    Byte_t  GetMaxLoGainSample() const;
    107 //    Short_t GetIdxMaxHiLoGainSample() const;
    108 
    109 //    ULong_t GetSumLoGainSamples() const;
    110 //    ULong_t GetSumSqrLoGainSamples() const;
    111 
    112     Bool_t HasLoGain() const { return fNumLoGainSamples>0; }
     83    Bool_t HasLoGain() const { return fNumBytesLoGain>0; }
    11384    Bool_t IsABFlagValid() const { return fABFlags ? kTRUE : kFALSE; }
    11485    Bool_t HasABFlag() const
     
    12798    }
    12899
    129     Byte_t *GetLoGainSamples() const
     100    void *GetLoGainSamples() const
    130101    {
    131102        //
Note: See TracChangeset for help on using the changeset viewer.