Changeset 11555 for trunk/Mars/mraw


Ignore:
Timestamp:
07/24/11 11:04:43 (13 years ago)
Author:
tbretz
Message:
added fIsSigned; adapted GetSample; added GetMin; changed code in GetMax
Location:
trunk/Mars/mraw
Files:
2 edited

Legend:

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

    r11489 r11555  
    5050//   ------------------
    5151//    + MArrayS *fStartCell
     52//    + Bool_t   fIsSigned
    5253//
    5354//   Version 7
     
    113114//
    114115MRawEvtData::MRawEvtData(const char *name, const char *title)
    115     : fRunHeader(0), fNumBytesPerSample(1)
     116    : fRunHeader(0), fNumBytesPerSample(1), fIsSigned(false)
    116117{
    117118    fName  = name  ? name  : "MRawEvtData";
     
    288289    name += pix.GetPixelId();
    289290
     291    fIsSigned = kTRUE;
    290292
    291293    Bool_t same = str.Contains("same");
     294
     295    cout << "MIN/MAX=" << fNumBytesPerSample << " " << GetMin() << " " << GetMax() << endl;
    292296
    293297    if (str.BeginsWith("graph"))
     
    304308
    305309        graphhi->SetMaximum(GetMax()+0.5);
    306         graphhi->SetMinimum(0);
     310        graphhi->SetMinimum(GetMin());
    307311
    308312        graphhi->SetBit(kCanDelete);
     
    310314
    311315        TH1F *histhi = graphhi->GetHistogram();
    312         histhi->SetMinimum(0);
     316        histhi->SetMinimum(GetMin());
    313317        histhi->SetMaximum(GetMax()+0.5);
    314318 
     
    325329
    326330        TH1F *histh = new TH1F(name, "FADC Samples", nh+nl, -0.5, nh+nl-.5);
    327         histh->SetMinimum(0);
     331        histh->SetMinimum(GetMin());
    328332        histh->SetMaximum(GetMax()+0.5);
    329333        histh->SetXTitle("Time [FADC Slices]");
  • trunk/Mars/mraw/MRawEvtData.h

    r11489 r11555  
    4040    UShort_t fNumBytesPerSample;
    4141
     42    Bool_t fIsSigned;
     43
    4244    Int_t fConnectedPixels;       //!
    4345
     
    4749    Int_t GetNumBytes() const;
    4850
    49     UInt_t GetSample(const void *ptr, Int_t n) // Helper for Draw
     51    Long_t GetSample(const void *ptr, Int_t n) // Helper for Draw
    5052    {
     53        fIsSigned = kTRUE;
    5154        switch (fNumBytesPerSample)
    5255        {
    53         case 1: return reinterpret_cast<const Byte_t*>(ptr)[n];
    54         case 2: return reinterpret_cast<const UShort_t*>(ptr)[n];
    55         case 4: return reinterpret_cast<const UInt_t*>(ptr)[n];
     56        case 1: return fIsSigned ? (Long_t)reinterpret_cast<const Char_t*>(ptr)[n]  : (Long_t)reinterpret_cast<const Byte_t*>(ptr)[n];
     57        case 2: return fIsSigned ? (Long_t)reinterpret_cast<const Short_t*>(ptr)[n] : (Long_t)reinterpret_cast<const UShort_t*>(ptr)[n];
     58        case 4: return fIsSigned ? (Long_t)reinterpret_cast<const Int_t*>(ptr)[n]   : (Long_t)reinterpret_cast<const UInt_t*>(ptr)[n];
    5659        }
    5760        return 0;
     
    9194    UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
    9295    UInt_t   GetScale() const { return 1<<((fNumBytesPerSample-1)*8); }
    93     UInt_t   GetMax() const   { return (UInt_t)(~1)>>((4-fNumBytesPerSample)*8); }
    94 
     96    Long_t   GetMin() const   { return fIsSigned ? -GetMax()-1 : 0; }
     97    Long_t   GetMax() const   {
     98        switch (fNumBytesPerSample)
     99        {
     100        case 1: return fIsSigned ?       0x7f :       0xff;
     101        case 2: return fIsSigned ?     0x7fff :     0xffff;
     102        case 4: return fIsSigned ? 0x7fffffff : 0xffffffff;
     103        }
     104    return 0;
     105    }
    95106    Byte_t   *GetSamples() const;
    96107    UShort_t *GetStartCells() const;
Note: See TracChangeset for help on using the changeset viewer.