StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHybridDaqData.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtHybridDaqData.cc,v 1.5 2009/08/26 17:51:35 fine Exp $
4  *
5  * Author: Marcelo Munhoz
6  ***************************************************************************
7  *
8  * Description: SVT Hybrid Data BASE class
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtHybridDaqData.cc,v $
13  * Revision 1.5 2009/08/26 17:51:35 fine
14  * fix the compilation issues under SL5_64_bits gcc 4.3.2
15  *
16  * Revision 1.4 2005/07/23 03:37:34 perev
17  * IdTruth + Cleanup
18  *
19  * Revision 1.3 2001/10/24 16:49:43 munhoz
20  * adding capability to retrieve t0 and first SCA
21  *
22  * Revision 1.2 2001/07/11 23:29:48 munhoz
23  * adding capability for zero suppressed and pedestal reading
24  *
25  * Revision 1.1 2000/06/13 20:42:06 caines
26  * StRoot/StSvtDaqMaker
27  *
28  **************************************************************************/
30 // //
31 // This is the class to access the data from each hybrid. //
32 // //
34 
35 #include "StSvtHybridDaqData.hh"
36 #include "StSequence.hh"
37 #include "StDAQMaker/StSVTReader.h"
38 #include <cassert>
39 
40 ClassImp(StSvtHybridDaqData)
41 
42 StSvtHybridDaqData::StSvtHybridDaqData(int barrel, int ladder, int wafer, int hybrid, StSVTReader* reader, const char* option) :
43  StSvtHybridData(barrel, ladder, wafer, hybrid)
44 {
45  assert(sizeof(TPCSequence)==sizeof(StSequence));
46  assert(&(((TPCSequence*)1)->startTimeBin)==&(((StSequence*)1)->startTimeBin));
47  assert(&(((TPCSequence*)1)->Length )==&(((StSequence*)1)->length ));
48  assert(&(((TPCSequence*)1)->FirstAdc )==&(((StSequence*)1)->firstAdc ));
49 
50  if (reader)
51  setHybridData(reader,option);
52 }
53 
54 int StSvtHybridDaqData::setHybridData(StSVTReader* reader, const char* option)
55 {
56  // fills the data members of this object,
57  // so one can access the data through the two methods mentioned below.
58  // Therefore, it must be invoked before the access methods.
59  // This method can be overloaded to allow other types of input data (simulators, ASCII files, etc.).
60  // If everything goes OK, it returns kTRUE.
61 
62  int anode, n, status=0, ianode;
63  unsigned char* array;
64 
65  // Initialize anodeList with maximum number of anodes
66  int nAnodes = 240;
67 
68  if ( !strncmp(option, "RAW", strlen("RAW")) ) {
69 
70  seq.resize(nAnodes);
71 
72  for (ianode=0;ianode<nAnodes;ianode++) {
73 
74  anode = ianode + 1;
75  seq[ianode].mAnode= anode;
76  status = reader->getRawADC(mBarrel, mLadder, mWafer, mHybrid, anode, n, array);
77 
78  if (status != 1) return status;
79  // nSeq[ianode] = n;
80  n = 1; // VP
81  seq[ianode].resize(n);
82 
83  for (int iseq=0;iseq<n;iseq++) {
84  seq[ianode][iseq].startTimeBin = iseq;
85  seq[ianode][iseq].length = 128;
86  seq[ianode][iseq].firstAdc = array;
87  }
88  }
89  }
90 
91  else if ( !strncmp(option, "ZS", strlen("ZS")) ) {
92 
93 
94  // fill anodeList
95  nAnodes = reader->getAnodeList(mBarrel, mLadder, mWafer, mHybrid, array);
96 
97  //printf("SvtHybridDaqData:barrel %d, ladder %d, wafer %d, hybrid %d\n",mBarrel,mLadder,mWafer,mHybrid);
98 
99  // check if reader returns a positive number. Otherwise, there is some problem...
100  if (nAnodes < 0) return nAnodes;
101 
102  // Initialization
103  seq.resize(nAnodes);
104 
105  TPCSequence *tempseq=0;
106 
107  // loop through all relevant anodes and fill sequences
108  for (ianode=0;ianode<nAnodes;ianode++) {
109 
110  anode = (int)array[ianode];
111  seq[ianode].mAnode= anode;
112  status = reader->getSequences(mBarrel, mLadder, mWafer, mHybrid, anode, n, tempseq);
113 
114  if (status < 0) return status;
115 
116  seq[ianode].resize(n);
117  memcpy(&(seq[ianode][0]),tempseq,n*sizeof(StSequence));
118  }
119  }
120  setAnodeList();
121  mSCAZero = (unsigned char)reader->getSCAZero();
122  mTimeZero = (unsigned char)reader->getTimeZero();
123 
124  return status;
125 }