StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSstDaqMaker.h
1 
6 /***************************************************************************
7  *
8  * $Id: StSstDaqMaker.h,v 1.11 2017/04/25 00:32:03 perev Exp $
9  *
10  * Author: Long Zhou, Nov 2013, according codes from Hao Qiu
11  ***************************************************************************
12  *
13  * Description:
14  * Read SST strips info from daq format.
15  *
16  ***************************************************************************
17  *
18  * $Log: StSstDaqMaker.h,v $
19  * Revision 1.11 2017/04/25 00:32:03 perev
20  * Int_t ==> UInt_t to avoid wrong cast
21  *
22  * Revision 1.10 2016/06/23 20:24:12 bouchet
23  * sstBadStrips table decoding and use
24  *
25  * Revision 1.9 2016/02/03 15:50:48 zhoulong
26  * Added some protection to avoid chain crash when there is no available calibration table
27  *
28  * Revision 1.8 2015/12/14 14:33:42 zhoulong
29  * fixed CMN failed chip rejection error
30  *
31  * Revision 1.7 2015/11/05 21:56:44 zhoulong
32  * Add pedestal subtraction and CMN suppression algorithm and did some clearence
33  *
34  * Revision 1.5 2015/07/06 18:53:10 bouchet
35  * blanks removed to make C++ compiler happy (Thanks Yuri)
36  *
37  * Revision 1.4 2015/07/06 18:38:19 bouchet
38  * initialization of variables and pointers (Thanks Yuri)
39  *
40  * Revision 1.3 2015/06/24 20:58:11 bouchet
41  * added codes for using sstChipCorrect and sstMaskChip tables ; replaced StSsdConfig by StSstConfig
42  *
43  * Revision 1.2 2015/06/24 19:41:54 smirnovd
44  * StSstDaqMaker: Removed undefined method Finish()
45  *
46  * Revision 1.1 2015/06/09 18:32:00 jeromel
47  * Clean check-in vrsion of long time ago reviewed SST daq code
48  *
49  * Revision 1.11 2015/02/04 22:27:33 zhoulong
50  * merged DAQ maker for Run14 and Run15.
51  *
52  * Revision 1.10 2015/01/10 20:18:18 zhoulong
53  * 1>remove constant shift. 2>fixed delete pedestal table issue
54  *
55  * Revision 1.9 2015/01/05 22:07:23 smirnovd
56  * StSstDaqMaker: Removed quite pointless overriding methods
57  *
58  * Revision 1.8 2015/01/05 21:58:56 smirnovd
59  * Do not use automatic ROOT I/O as this is a StMaker. Makers are not persistent
60  *
61  * Revision 1.7 2015/01/05 21:58:48 smirnovd
62  * StSstDaqMaker/: Updated style with astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
63  *
64  * Revision 1.6 2014/11/10 14:46:37 zhoulong
65  * Fixed delete spa_strip table issue
66  *
67  * Revision 1.5 2014/09/30 18:00:10 zhoulong
68  * Fixed alot of issue, and remove histograms, ntuple.
69  *
70  * Revision 1.4 2014/06/05 14:55:24 zhoulong
71  * Added some code to compatible Thorsten's LC FPGA and correct readout channel shift in old LC FPGA
72  *
73  *
74  **************************************************************************/
75 #ifndef STSSTDAQMAKER_H
76 #define STSSTDAQMAKER_H
77 
78 #include "StMaker.h"
79 #include "StRTSBaseMaker.h"
80 #include "TH2.h"
81 #include <vector>
82 #include <map>
83 #include "TFile.h"
84 
85 class StSstConfig;
86 class St_sstConfiguration;
87 class St_sstStripCalib;
88 class St_spa_strip;
89 class St_sstNoise;
90 class sstConfiguration_st;
91 class sstChipCorrect_st;
92 class sstStripCalib_st;
93 class sstBadStrips_st;
94 class sstNoise_st;
95 
97 {
98 public:
99  StSstDaqMaker(const char *name = "sst_raw");
100  virtual ~StSstDaqMaker();
101  virtual Int_t InitRun(Int_t runumber);
102  virtual Int_t Make();
103  void Clear(const Option_t * = "");
104  virtual const char *GetCVS() const {
105  static const char cvs[] = "Tag $Name: $ $Id: StSstDaqMaker.h,v 1.11 2017/04/25 00:32:03 perev Exp $ built " __DATE__ " " __TIME__;
106  return cvs;
107  }
108 
109 private:
110  Int_t GetHitsDataLength(int FiberNumber);
111  void DecodeRdoData();
112  void DecodeHitsData();
113  void DecodeRawWords(UInt_t *val, int vallength, int channel);
114  void DecodeRawWords_r15(UInt_t *val, int vallength, int channel);
115  void DecodeCompressedWords(UInt_t *val, int valength, int channel);
116  UInt_t Mid(Int_t start, Int_t end, UInt_t input);
117  Int_t Shift(int runnumber, int &channel);
118  void FindLadderSide(int RDO, int channel, int &ladder, int &side);
119  void FindStripNumber(int &strip);
120  void FindChannelNumber(int &channel);
121  void PrintConfiguration(Int_t runumber, sstConfiguration_st *config);
122  void FillData(vector<vector<int> > vadc, vector<vector<float> > vcmnoise, Int_t id_side, Int_t ladder, Int_t valength);
123  void FillData_FixTH(vector<vector<int> > vadc, vector<vector<float> > vcmnoise, Int_t id_side, Int_t ladder, Int_t valength);
124 
125  Float_t CalculateCommonModeNoise(vector<int> vtemp);
126  Float_t CalculateCommonModeNoiseSimple(vector<int> vtemp);
127  Float_t CalculateCommonModeNoise_FPGA(vector<int> vtemp);
128  void FillReadOutPedTable(sstStripCalib_st *noise); /* Pedestal rms */
129  void FillDefaultReadOutPedTable();
130  void FillNoiseTable(sstNoise_st *noise); /* Intrinsic noise */
131  void FillDefaultNoiseTable();
132  void FillChipNoiseTable(sstChipCorrect_st *chipCorrectTable);
133  void FillDefaultChipNoiseTable();
134  void FillBadStripsTable(sstBadStrips_st* badStripTable);
135  Int_t idWaferToWafer(Int_t idWafer);
136  Int_t idWaferToLadderNumb(Int_t idWafer);
137 
138  Char_t mBeg[1];
139  StSstConfig *mConfig;
140  sstConfiguration_st *mConfigTable;
141  St_spa_strip *spa_strip;
142  St_sstStripCalib *stripCal;
143  /* St_sstStripCalib *mStripCalib; */
144  /* St_sstNoise *mNoise; */
145  /* St_sstChipCorrect *mChipCorrect; */
146 
147  UInt_t *mRdoData;
148  Int_t mRdoDataLength;
149  UInt_t *mHeaderData;
150  UInt_t *mTrailerData;
151  Int_t mTrailerDataLength;
152  UInt_t *mAdc[8];//8 Fiber data pointer
153  UInt_t *mAdcHeader[8];
154  UInt_t mAdcLength[8];
155  Int_t mMode;// 0: Physical run , 1: pedestal run
156  Int_t mRdoFlag;
157  Int_t mFiberFlag[8];
158  UInt_t mFlag[8];//daq file flag.
159  Int_t mTrigger;
160  Int_t mSec;//sector number.(in Tonko's pedestal bank)
161  Int_t mFiber;//Fiber number (in Tonko's pedestal bank)
162  Int_t mPed;
163  Int_t mRms;
164  Int_t mRDO;//RDO number
165  Int_t mChannel[8];
166  UInt_t mDataMode[8];// Raw or Compressed data .
167  Int_t mEventnumber;
168  Int_t mEventrunumber;
169  UInt_t mEventTime;// Current event RHIC clock
170  UInt_t mPEventTime;// Previous event RHIC cloc
171  Int_t mCorrectFactor[1920][2]; //chip correction table.
172  Int_t mNoiseCut[1920][2]; //Reject Noise.
173  Char_t mEnd[1];
174  Int_t mRunNum;
175  map<Int_t, Int_t> mReadOutPed; //ReadOut Pedestal.
176  map<Int_t, Float_t> mIntrinsicRms; //Intrinsic Rms
177  map<Int_t, char> mBadStrip; //strips status
178  //DAQ File parameters(please look at the SSD data formata document. )
179  static const UInt_t HEADER_LENGTH = 8;
180  static const UInt_t FIBER_HEADER_LENGTH = 10;
181  static const UInt_t HEADER_TOKEN = 0xAAAAAAAA;
182  static const UInt_t END_TOKEN = 0xBBBBBBBB;
183  static const UInt_t TCD_TOKEN = 0xCCCCCCCC;
184  static const UInt_t FIBER_LINK_TOKEN = 0xDDDDDDDD;
185  static const UInt_t TCD_END_TOKEN = 0xEEEEEEEE;
186  static const UInt_t RDO_START = 24;//RDO Number Start bit
187  static const UInt_t RDO_END = 28;//RDO Number End bit
188  static const UInt_t TRIG_START = 0;//TCD trigger word start
189  static const UInt_t TRIG_END = 20;//TCD trigger word end
190  static const UInt_t FIBER_START = 28;//Fiber Input Start bit
191  static const UInt_t FIBER_END = 31;//Fiber Input End bit
192  static const UInt_t HYBRID_ONE_START = 0;//Hyirid 0 start bit
193  static const UInt_t HYBRID_ONE_END = 10;//Hyirid 0 end bit
194  static const UInt_t HYBRID_TWO_START = 10;
195  static const UInt_t HYBRID_TWO_END = 20;
196  static const UInt_t HYBRID_THREE_START = 20;
197  static const UInt_t HYBRID_THREE_END = 30;
198  static const UInt_t COM_ADC_START = 0;
199  static const UInt_t COM_ADC_END = 10;
200  static const UInt_t HYBRID_START = 10;
201  static const UInt_t HYBRID_END = 14;
202  static const UInt_t STRIP_START = 14;
203  static const UInt_t STRIP_END = 24;
204  static const UInt_t ERROR_START = 28;//CMN Err Code Start Bit
205  static const UInt_t ERROR_END = 32;//CMN Err Code End Bit
206  static const UInt_t ADC_START = 4;//adc length start bit
207  static const UInt_t ADC_END = 20;//adc length end bit
208  static const UInt_t DATAMODE_START = 0;//adc mode start bit
209  static const UInt_t DATAMODE_END = 4;//adc mode end bit
210  static const UInt_t RAWMODE = 0x0;//0x0 Raw data mode
211  static const UInt_t COMPRESSEDMODE = 0x1;//0x1 ZS mode
212  static const UInt_t CMNSMODE = 0x3;//0x3 CMN suppressed mode
213  static const UInt_t FLAG_START = 20;//flag start bit
214  static const UInt_t FLAG_END = 32;//flag end bit
215  static const UInt_t NORMAL = 0x0;//0x000 //normal flag
216  static const UInt_t NODATA = 0x1;//0x001 //no data
217  static const UInt_t OVERFLOWFLAG = 0x2;//0x002 //over flow
218  static const UInt_t EARLY_ABORT = 0x3;//0x003 //early abort
219  static const UInt_t WRONG_PIPE_MODE = 0x4;//0x004 //wrong pipe mode
220  static const UInt_t ADC_LENGTH_LIMIT = 4106;//adc length limit,include fiber header
221  static const UInt_t CMNERRORCODE = 0xB;//CMN algorithm failed error code
222 
223  //SSD hardware parameters
224  static const Int_t nSstRdo = 5;
225  static const Int_t nSstSide = 2;
226  static const Int_t nSstLadder = 20;
227  static const Int_t nSstFiberPerRdo = 8;
228  static const Int_t nSstWaferPerLadder = 16;
229  static const Int_t nSstChipPerWafer = 6;
230  static const Int_t nSstStripsPerWafer = 768;
231  static const Int_t nSstStripsPerChip = 128;
232  static const Int_t nSigmaCut = 4; /* N*Sigma Cuts */
233  static const Int_t nRmsCut = 10;
234  static const Int_t RDO2LADDER[5][8];//Ladder cards number in each RDO channel .
235  static const Int_t ReadOutMap[128];
236  static const Int_t Rev_ReadOutMap[128]; // strip number 2 readout channelmap
237 
238  ClassDef(StSstDaqMaker, 0)
239 };
240 
241 #endif
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
virtual Int_t Make()