Skip to content
Snippets Groups Projects
THcRawHodoHit.cxx 3.12 KiB
Newer Older
  • Learn to ignore specific revisions
  • /** \class THcRawHodoHit
        \ingroup DetSupport
    
    
    
    Class representing a single raw hit for a hodoscope paddle  
                                                                
     Contains plane, counter and pos/neg adc and tdc values   
                                                              
    
    */
    
    #include <cstring>
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    
    
    #include "THcRawHodoHit.h"
    
    void THcRawHodoHit::SetData(Int_t signal, Int_t data) {
    
        fADC_pos[fNRawHits[0]++] = data;
    
        fADC_neg[fNRawHits[1]++] = data;
    
        fTDC_pos[fNRawHits[2]++] = data;
    
        fTDC_neg[fNRawHits[3]++] = data;
    
    Int_t THcRawHodoHit::GetData(Int_t signal) {
    
      return(GetData(signal,0));
    }
    Int_t THcRawHodoHit::GetData(Int_t signal, UInt_t ihit) {
      Int_t value;
      if(ihit>= fNRawHits[signal]) {
        return(-1);
      }
    
        value = fADC_neg[ihit];
      } else if (signal==2) {
        value = fTDC_pos[ihit];
      } else if (signal==3) {
        value = fTDC_neg[ihit];
      } else {
        return(-1);			// Actually should throw an exception
      }
      // We are return -1 as a error, but reference subtracted
      // time can be negative.  
      if(fHasRef[signal]) {
        value -= fReferenceTime[signal];
      }
      return(value);
    }
    
    Int_t THcRawHodoHit::GetRawData(Int_t signal) {
      return(GetRawData(signal,0));
    }
    
    // Return a requested raw hit
    Int_t THcRawHodoHit::GetRawData(Int_t signal, UInt_t ihit) {
      if(ihit>= fNRawHits[signal]) {
        return(-1);
      }
      if(signal==0) {
        return(fADC_pos[ihit]);
      } else if (signal==1) {
        return(fADC_neg[ihit]);
      } else if (signal==2) {
        return(fTDC_pos[ihit]);
    
        return(fTDC_neg[ihit]);
      } else {
        return(-1);			// Actually should throw an exception
      }
    }
    
    // Set the reference time
    void THcRawHodoHit::SetReference(Int_t signal, Int_t reference) {
      fReferenceTime[signal] = reference;
      fHasRef[signal] = kTRUE;
    }
    Int_t THcRawHodoHit::GetReference(Int_t signal) {
      if(fHasRef[signal]) {
        return(fReferenceTime[signal]);
      } else {
        return(0);
    
    Bool_t THcRawHodoHit::HasReference(Int_t signal) {
      return(fHasRef[signal]);
    }
    
    //_____________________________________________________________________________
    
    THcRawHodoHit& THcRawHodoHit::operator=( const THcRawHodoHit& rhs )
    
    {
      // Assignment operator.
    
      THcRawHit::operator=(rhs);
      if ( this != &rhs ) {
    
        for(Int_t is=0;is<4;is++) {
          fReferenceTime[is] = rhs.fReferenceTime[is];
          fNRawHits[is] = rhs.fNRawHits[is];
          fHasRef[is] = rhs.fHasRef[is];
        }
        for(Int_t ih=0;ih<fNRawHits[0];ih++) {
          fADC_pos[ih] = rhs.fADC_pos[ih];
        }
        for(Int_t ih=0;ih<fNRawHits[1];ih++) {
          fADC_neg[ih] = rhs.fADC_neg[ih];
        }
        for(Int_t ih=0;ih<fNRawHits[2];ih++) {
          fTDC_pos[ih] = rhs.fTDC_pos[ih];
        }
        for(Int_t ih=0;ih<fNRawHits[3];ih++) {
          fTDC_neg[ih] = rhs.fTDC_neg[ih];
        }
    
      }
      return *this;
    }
    
    
    //////////////////////////////////////////////////////////////////////////
    
    ClassImp(THcRawHodoHit)