StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrsZeroSuppressedReader.cc
1 /***************************************************************************
2  *
3  * $Id: StTrsZeroSuppressedReader.cc,v 1.14 2008/06/20 15:01:21 fisyak Exp $
4  *
5  * Authors: bl, mcbs
6  ***************************************************************************
7  *
8  * Description: Access to the digital information via the abstract
9  * interface...this is the OLD UNPACKER
10  ***************************************************************************
11  *
12  * $Log: StTrsZeroSuppressedReader.cc,v $
13  * Revision 1.14 2008/06/20 15:01:21 fisyak
14  * move from StTrsData to StTpcRawData
15  *
16  * Revision 1.13 2005/09/09 22:12:49 perev
17  * Bug fix + IdTruth added
18  *
19  * Revision 1.11 2005/07/19 22:23:05 perev
20  * Bug fix
21  *
22  * Revision 1.10 2003/12/24 13:44:54 fisyak
23  * Add (GEANT) track Id information in Trs; propagate it via St_tpcdaq_Maker; account interface change in StTrsZeroSuppressedReaded in StMixerMaker
24  *
25  * Revision 1.9 2003/09/19 22:17:50 jecc
26  * Fix bug in getSequences intruced during gcc 3.2 updates
27  *
28  * Revision 1.8 2003/09/02 17:59:19 perev
29  * gcc 3.2 updates + WarnOff
30  *
31  * Revision 1.7 2000/06/07 02:03:12 lasiuk
32  * exit/abort ultimatum
33  *
34  * Revision 1.6 2000/03/15 23:33:55 calderon
35  * Remove extra messages
36  *
37  * Revision 1.5 2000/03/15 18:08:56 calderon
38  * ZSR is no longer a singleton. Two will be needed for mixer chain.
39  *
40  * Revision 1.4 2000/03/14 01:00:24 calderon
41  * remove annoying beep
42  *
43  * Revision 1.3 2000/01/10 23:14:31 lasiuk
44  * Include MACROS for compatiblity with SUN CC5
45  *
46  * Revision 1.2 1999/12/08 02:10:43 calderon
47  * Modified to eliminate warnings on Linux.
48  *
49  * Revision 1.1 1999/11/05 22:18:17 calderon
50  *
51  * Made private copy constructor and operator= in StTrsDigitalSector.
52  * Renamed DigitalSignalGenerators: Fast -> Old, Parameterized -> Fast
53  * and use new "Fast" as default.
54  * Added StTrsZeroSuppressedReader and StTrsZeroSuppressedReader for DAQ type
55  * data access.
56  * Removed vestigial for loop in sampleAnalogSignal() method.
57  * Write version of data format in .trs data file.
58  *
59  ***************************************************************************/
60 #include "StTrsZeroSuppressedReader.hh"
61 #include <assert.h>
62 #include <algorithm>
63 #include <iterator>
64 #if defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x500
65 using std::find;
66 using std::distance;
67 #endif
68 #ifndef ST_NO_EXCEPTIONS
69 # include <stdexcept>
70 # if !defined(ST_NO_NAMESPACES)
71  using std::out_of_range;
72 # endif
73 #endif
74 
75 #include "StGlobals.hh"
76 #include "StTrsRawDataEvent.hh"
77 //________________________________________________________________________________
78 StTrsZeroSuppressedReader::StTrsZeroSuppressedReader(StTpcRawData* ev) :mSector(-1), mTheSector(0), mTrsEvent(0) {
79 
80  assert(sizeof(StSequence) == sizeof(Sequence));
81  if (ev) {
82  mTrsEvent = dynamic_cast<StTrsRawDataEvent*>(ev);
83  if (!mTrsEvent) {
84  cerr << "Error constructing StTrsZeroSuppressedReader" << endl;
85  cerr << "Cast Failed! ev not of required type (StTrsRawDataEvent*)\n";
86  }
87  }
88 }
89 //________________________________________________________________________________
90 Int_t StTrsZeroSuppressedReader::setSector(Int_t sector)
91 {
92  // clear();
93  // Check if the data is there --> getSector() in the Unpacker!
94  // ...you may even want to check the mVersion to return the
95  // proper mZSR...
96 
97  if(checkTheData(sector)) {
98  mSector = sector;
99  mTheSector = mTrsEvent->getSector(sector);
100  return 1;
101  }
102  return 0;
103 }
104 //________________________________________________________________________________
105 Int_t StTrsZeroSuppressedReader::checkTheData(UInt_t which)
106 {
107  Int_t status(0);
108 
109  if(mTrsEvent->size() >= which) // bounds check
110  if ( (mTrsEvent->getSector(which)) ) status = 1;
111  return status;
112 }