StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTpcRawData.h
1 /***************************************************************************
2  *
3  * $Id: StTpcRawData.h,v 2.14 2018/09/27 22:01:24 ullrich Exp $
4  *
5  * Author: Yuri Fisyak, Mar 2008
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StTpcRawData.h,v $
13  * Revision 2.14 2018/09/27 22:01:24 ullrich
14  * Added missing inheritance, SObject, for StDigitalPair
15  *
16  * Revision 2.13 2018/09/27 20:03:33 ullrich
17  * Added ClassDef for StDigitalPair
18  *
19  * Revision 2.12 2018/04/05 03:16:20 smirnovd
20  * Make StTpcDigitalSector compatible with iTPC
21  *
22  * Revision 2.11 2018/02/18 23:18:45 perev
23  * Remove iTPC related update
24  *
25  * Revision 2.9 2012/05/07 14:41:59 fisyak
26  * Remove hardcoded separation between Inner and Outer Sectors
27  *
28  * Revision 2.8 2011/03/31 19:27:47 fisyak
29  * Add more safety for work with pixel data
30  *
31  * Revision 2.7 2009/11/23 22:20:51 ullrich
32  * Minor cleanup performed, fixed compiler warnings.
33  *
34  * Revision 2.6 2009/10/12 23:52:32 fisyak
35  * Fix relation npad from pad row
36  *
37  * Revision 2.5 2008/07/31 20:47:27 fisyak
38  * Modify operator += and =
39  *
40  * Revision 2.4 2008/06/20 14:56:34 fisyak
41  * Add protection for pad no.
42  *
43  * Revision 2.3 2008/05/27 14:40:08 fisyak
44  * keep pixel raw data as short istead of uchar
45  *
46  * Revision 2.2 2008/04/24 16:06:25 fisyak
47  * Clean up before next move
48  *
49  * Revision 2.1 2008/03/13 16:42:24 ullrich
50  * Initial Revision
51  *
52  **************************************************************************/
53 #ifndef StTpcRawData_h
54 #define StTpcRawData_h
55 
56 #include "StObject.h"
57 #include <vector>
58 #include <utility>
59 #include "StSequence.hh"
60 #include "StTpcPixel.h"
61 #include "StDetectorDbMaker/St_tpcPadPlanesC.h"
62 #include "StDetectorDbMaker/St_tpcPadConfigC.h"
63 #define __MaxNumberOfTimeBins__ 512
64 typedef std::vector<Short_t> StVectorADC;
65 typedef std::vector<UShort_t> StVectorIDT;
66 
67 class StDigitalPair : public StObject {
68 public:
69  StDigitalPair(UShort_t time=0) {mTime=time;}
70  virtual ~StDigitalPair() {}
71  void add(Short_t adc) {mAdc.push_back(adc);}
72  void add(Short_t adc,Int_t idt) {mAdc.push_back(adc); mIdt.push_back(idt);}
73 
74  Short_t* adc() const {return (Short_t*)&mAdc[0];}
75  Bool_t isIdt() const {return mAdc.size() == mIdt.size();}
76  UShort_t*idt() const {return (UShort_t*) (isIdt() ? &mIdt[0] : 0);}
77  Int_t size() const {return mAdc.size();}
78  UShort_t time() const {return mTime;}
79 
80 private:
81  UShort_t mTime;
82  StVectorADC mAdc;
83  StVectorIDT mIdt;
84  ClassDef(StDigitalPair,1)
85 };
86 
87 typedef std::vector<StDigitalPair> StDigitalTimeBins;
88 typedef std::vector<StDigitalTimeBins> StDigitalPadRow;
89 typedef std::vector<StDigitalPadRow> StDigitalSector;
90 
91 typedef std::vector<StDigitalPair>::iterator StDigitalTimeBinIterator;
92 typedef StDigitalTimeBins::iterator StDigitalTimeBinsIterator;
93 typedef StDigitalPadRow::iterator StDigitalPadRowIterator;
94 typedef StDigitalSector::iterator StDigitalRowIterator;
95 
96 typedef std::vector<StSequence> StVecSequence;
97 typedef std::vector<UShort_t*> StVecIds;
98 typedef std::vector<UChar_t> StVecPads;
99 typedef std::vector<UChar_t> StVecUChar;
100 typedef std::vector<Int_t> StVecInt;
101 typedef std::vector<StTpcPixel> StVectPixel;
102 
103 class StTpcDigitalSector : public StObject {
104 public:
105  StTpcDigitalSector(void *db = 0);
106  StTpcDigitalSector(int sector);
107  virtual ~StTpcDigitalSector() {}
108  // access functions
109  const StDigitalTimeBins* timeBinsOfRowAndPad(Int_t rowN, Int_t padN) const { return (&mData[(rowN-1)][(padN-1)]);}
110  StDigitalTimeBins* timeBinsOfRowAndPad(Int_t rowN, Int_t padN) { return (&mData[(rowN-1)][(padN-1)]);}
111  StDigitalPadRow* padsOfRow(Int_t rowN) { return (&mData[(rowN-1)]);}
112  StDigitalSector* rows() { return (&mData);}
113 
114  Int_t numberOfRows() const { return mData.size();}
115  Int_t numberOfPadsInRow(Int_t rowN) const { return mData[(rowN-1)].size();}
116  Int_t numberOfTimeBins(Int_t rowN, Int_t padN) const { return mData[(rowN-1)][(padN-1)].size();}
117 
118  // Adding
119  void assignTimeBins(int row , int pad, StDigitalTimeBins*);
120  Int_t getSequences(Int_t row, Int_t pad, Int_t *nSeq, StSequence** seq, UShort_t ***Id);
121  Int_t getPadList(Int_t row, UChar_t **padList);
122  Int_t getTimeAdc(Int_t row, Int_t pad, Short_t ADCs[__MaxNumberOfTimeBins__],
123  UShort_t IDTs[__MaxNumberOfTimeBins__]); // with 8 => 10 conversion
124  Int_t getTimeAdc(Int_t row, Int_t pad, UChar_t ADCs[__MaxNumberOfTimeBins__],
125  UShort_t IDTs[__MaxNumberOfTimeBins__]);
126  Int_t putTimeAdc(Int_t row, Int_t pad, Short_t *ADCs, UShort_t *IDTs = 0); // with 10 => 8 conversion
127  Int_t putTimeAdc(Int_t row, Int_t pad, UChar_t *ADCs, UShort_t *IDTs = 0);
128  void setSector(Int_t sector) {mSector = sector;}
129  void clear();
130  Int_t cleanup();
131  virtual void Print(const Option_t *opt="") const;
132  virtual Int_t PrintTimeAdc(Int_t row, Int_t pad) const;
133  StTpcDigitalSector &operator+= (StTpcDigitalSector& v);
134  Int_t numberOfPadsAtRow(Int_t row) {return (row > 0 && row <= mNoRows) ? St_tpcPadConfigC::instance()->padsPerRow(mSector, row) : 0;}
135  StTpcDigitalSector& operator=(const StTpcDigitalSector&);
136  Int_t sector() {return mSector;}
137  Int_t numberOfRows() {return mNoRows;}
138 private:
140 
141 private:
142  StDigitalSector mData;
143  Int_t mSector;
144  StVecPads mPadList;
145  StVecSequence mSequence;
146  StVecIds mIds;
147  Int_t mNoRows;
148  ClassDef(StTpcDigitalSector,2)
149 };
150 
151 class StTpcRawData : public StObject {
152 public:
153  StTpcRawData(Int_t noSectors = 24) {setNoSectors(noSectors);}
154  virtual ~StTpcRawData() {clear();}
155  UInt_t size() {return mSectors.size();}
156  UInt_t getNoSectors() {return size();}
157  StTpcDigitalSector *GetSector(UInt_t sector) {return sector > 0 && sector <= size() ? mSectors[sector-1] : 0;}
158  StTpcDigitalSector *getSector(UInt_t sector) {return GetSector(sector);}
159  Int_t getVecOfPixels(StVectPixel &pixels, Int_t sector, Int_t row, Int_t padMin = 1, Int_t padMax = -1,
160  Int_t tMin = 0, Int_t tMax = -1);
161  void setNoSectors(UInt_t noSectors = 0) {mSectors.resize(noSectors); for (UInt_t i = 0; i < noSectors; i++) mSectors[i] = 0;}
162  void setSector(UInt_t sector, StTpcDigitalSector* digitSector);
163  void clear() {Clear();}
164  void Clear(const Option_t *opt = "");
165  StTpcRawData &operator+= (StTpcRawData& v);
166  virtual void Print(const Option_t *opt="") const;
167 private:
168  std::vector<StTpcDigitalSector*> mSectors;
169  ClassDef(StTpcRawData,1)
170  };
171 #endif