TV1720RawData.h

Go to the documentation of this file.
00001 #ifndef TV1720RawData_hxx_seen
00002 #define TV1720RawData_hxx_seen
00003 
00004 #include <vector>
00005 
00006 #include "TGenericData.hxx"
00007 
00008 
00009 /// Class to store information from a single V1720 ZLE pulse.
00010 class TV1720RawZlePulse {
00011 
00012  public:
00013   
00014   /// Constructor
00015  TV1720RawZlePulse(int firstBin, std::vector<uint32_t> samples):
00016   fFirstBin(firstBin),fSamples(samples){};
00017 
00018  TV1720RawZlePulse(){};
00019   
00020 
00021   /// Get the first bin for this pulse
00022   int GetFirstBin() const {
00023     return fFirstBin;    
00024   }
00025 
00026   /// Get the number of samples.
00027   int GetNSamples() const {
00028     return fSamples.size();
00029   }
00030 
00031   /// Get the first bin for this pulse
00032   int GetSample(int i) const {
00033     if(i >= 0 && i < (int)fSamples.size())
00034       return fSamples[i];
00035     
00036     return -1;
00037   }
00038 
00039  private:
00040   
00041   /// The first bin for this ZLE pulse.
00042   int fFirstBin;
00043 
00044   /// The set of samples for this ZLE pulse.
00045   std::vector<uint32_t> fSamples;
00046     
00047 
00048 };
00049 
00050 /// Class to store information from a single V1720 channel.
00051 /// Class will store either the full ADC waveform (if not compressed)
00052 /// or a vector of TV1720RawZlePulse (if compressed).
00053 class TV1720RawChannel {
00054   
00055  public:
00056 
00057   /// constructor
00058  TV1720RawChannel(int channel, bool iscompressed): 
00059   fChannelNumber(channel),fIsZLECompressed(iscompressed){
00060       
00061   }
00062 
00063 
00064   int GetChannelNumber() const {return fChannelNumber;};
00065 
00066   
00067   bool IsZLECompressed() const {return fIsZLECompressed;};
00068   
00069   
00070   /// Get the ADC sample for a particular bin (for uncompressed data).
00071   int GetNSamples() const{return fWaveform.size();};
00072 
00073   /// Get the ADC sample for a particular bin (for uncompressed data).
00074   int GetADCSample(int i) const{
00075     if(i >= 0 && i < (int)fWaveform.size())
00076       return fWaveform[i];
00077 
00078     // otherwise, return error value.
00079     return -1;
00080   }
00081 
00082   /// Get the number of ZLE pulses (for compressed data)
00083   int GetNZlePulses() const {return fZlePulses.size();};
00084   
00085 
00086   /// Get the ZLE pulse (for compressed data
00087   TV1720RawZlePulse GetZlePulse(int i) const { 
00088     if(i >= 0 && i < (int)fZlePulses.size())
00089       return fZlePulses[i];
00090 
00091     // otherwise, return error value.
00092     return TV1720RawZlePulse();
00093 
00094   }
00095 
00096   /// Returns true for objects with no ADC samples or ZLE pulses.
00097   int IsEmpty() const {
00098     if(fZlePulses.size()==0 && fWaveform.size()==0)
00099       return true;
00100     return false;
00101   }
00102 
00103   /// Add an ADC sample
00104   /// Warning: this method just adds an ADC sample to the back 
00105   /// of the vector.  Must add in order and must not add any sample twice.
00106   void AddADCSample(uint32_t sample){ fWaveform.push_back(sample);};
00107   
00108   /// Add an ZLE pulse
00109   /// Warning: this method just adds a ZLE pulse to the back
00110   /// of the vector.  Must add in order and must not add any pulse twice.
00111   void AddZlePulse(TV1720RawZlePulse pulse){ fZlePulses.push_back(pulse);};
00112   
00113 
00114  private:
00115 
00116   /// Channel number
00117   int fChannelNumber;
00118 
00119   /// Is ZLE compressed
00120   bool fIsZLECompressed;
00121   
00122   std::vector<TV1720RawZlePulse> fZlePulses;
00123   std::vector<uint32_t> fWaveform;
00124 
00125 };
00126 
00127 
00128 /// Class to store data from CAEN V1720, 250MHz FADC.
00129 ///
00130 /// Full info on CAEN V1720 module
00131 /// http://daq-plone.triumf.ca/HR/VME/CAEN/v1720rev9.pdf/view
00132 ///
00133 /// This class encapsulates the data from a single board (in a single MIDAS bank).
00134 /// This decoder is for the default or ZLE version of the firmware.  Not the DPP firmware
00135 class TV1720RawData: public TGenericData {
00136 
00137 public:
00138 
00139   /// Constructor
00140   TV1720RawData(int bklen, int bktype, const char* name, void *pdata);
00141 
00142   /// Get the number of 32-bit words in bank.
00143   uint32_t GetEventSize() const {return (fGlobalHeader0 & 0xffffff);};
00144 
00145   /// Get the channel mask; ie, the set of channels for which we 
00146   /// have data for this event.
00147   uint32_t GetChannelMask() const {return (fGlobalHeader1 & 0xff);};
00148 
00149   /// Is the V1720 data ZLE compressed?
00150   bool IsZLECompressed() const {return ((fGlobalHeader1 >> 24) & 0x1);};
00151 
00152   /// Get event counter
00153   uint32_t GetEventCounter() const {return ((fGlobalHeader2) & 0xffffff);};
00154 
00155   /// Get trigger tag
00156   uint32_t GetTriggerTag() const {return ((fGlobalHeader3) & 0xffffffff);};
00157 
00158 
00159   /// Get Number of channels in this bank.
00160   int GetNChannels() const {return fMeasurements.size();}
00161   
00162   /// Get Channel Data
00163   TV1720RawChannel GetChannelData(int i) {
00164     if(i >= 0 && i < (int)fMeasurements.size())
00165       return fMeasurements[i];
00166 
00167     return TV1720RawChannel(0,0);
00168   }
00169   
00170 
00171   void Print();
00172 
00173 
00174 private:
00175 
00176   /// Helper method to handle ZLE compressed data.
00177   void HandlZLECompressedData();
00178 
00179   /// Helper method to handle uncompressed data.
00180   void HandlUncompressedData();
00181 
00182   /// The overall global headers
00183   uint32_t fGlobalHeader0;
00184   uint32_t fGlobalHeader1;
00185   uint32_t fGlobalHeader2;
00186   uint32_t fGlobalHeader3;
00187   
00188 
00189   /// Vector of V1720 measurements
00190   std::vector<TV1720RawChannel> fMeasurements;
00191 
00192 };
00193 
00194 #endif

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1