StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsTriggerMaker.h
1 // -*- mode: c++ -*-
2 //
3 // Pibero Djawotho <pibero@tamu.edu>
4 // Texas A&M
5 // 13 July 2012
6 //
7 // FMS trigger simulator
8 //
9 
10 #ifndef ST_FMS_TRIGGER_MAKER_H
11 #define ST_FMS_TRIGGER_MAKER_H
12 
13 class TH2F;
14 
15 #include <cstring>
16 #if !defined(__CINT__)
17 #include "Board.hh"
18 #include "Crate.hh"
19 #include "bits.hh"
20 #else
21 class Board;
22 class Crate;
23 #endif
24 #include "TDatime.h"
25 #include "StMaker.h"
26 
27 class StFmsTriggerMaker : public StMaker {
28 public:
29  StFmsTriggerMaker(const char* name = "fmstrigger");
30 
31  void Clear(Option_t* option = "");
32  int Init();
33  int InitRun(int runNumber);
34  int Make();
35  int Finish();
36 
37  // Input mode
38  void useTrgData() { mUseTrgData = 1;}
39  void useMuDst() { mUseMuDst = 1;}
40  void useStEvent() { mUseStEvent = 1; }
41 
42  // Some controls
43  void overwriteThr(char* name, int value);
44  void forceRunNumber(int run) {mForceRun=run;}
45  void useDsmData() {mUseDsmData=1;}
46  void useQTSim() {mUseDsmData=0;}
47 
48  //
49  // QT and DSM algorithms and cabling for 2011:
50  //
51  // http://www.star.bnl.gov/public/trg/TSL/Software/FMS_2011.pdf
52  // http://www.star.bnl.gov/public/trg/TSL/Schematics/FMS_Crate_Cable_Map.pdf
53  // http://www.star.bnl.gov/public/trg/TSL/Schematics/FEQ_Crate_Cable_Map.pdf
54  //
55  int FP201output(int t=MAXPP) const { return fp201.output[t]; }
56  int FM0xxoutput(int number, int t=MAXPP) const;
57  int FM1xxoutput(int number, int t=MAXPP) const;
58 
59  int FP201input(int ch, int t=MAXPP) const;
60  int FM0xxinput(int number, int ch, int t=MAXPP) const;
61  int FM1xxinput(int number, int ch, int t=MAXPP) const;
62 
63  int FP201data(int ch) const;
64  int FM0xxdata(int number, int ch, int t=MAXPP) const;
65  int FM1xxdata(int number, int ch, int t=MAXPP) const;
66 
67  int FP201userdata(int ch, int t=MAXPP) const;
68  int FM0xxuserdata(int number, int ch, int t=MAXPP) const;
69  int FM1xxuserdata(int number, int ch, int t=MAXPP) const;
70 
71  int FmsHighTowerTh0(int t=MAXPP) const { return btest(fp201.output[t],0); } // Small cells
72  int FmsHighTowerTh1(int t=MAXPP) const { return btest(fp201.output[t],1); } // Large cells
73  int FmsSmallClusterTh0(int t=MAXPP) const { return btest(fp201.output[t],2); }
74  int FmsSmallClusterTh1(int t=MAXPP) const { return btest(fp201.output[t],3); }
75  int FmsSmallClusterTh2(int t=MAXPP) const { return btest(fp201.output[t],4); }
76  int FmsLargeClusterTh0(int t=MAXPP) const { return btest(fp201.output[t],5); }
77  int FmsLargeClusterTh1(int t=MAXPP) const { return btest(fp201.output[t],6); }
78  int FmsLargeClusterTh2(int t=MAXPP) const { return btest(fp201.output[t],7); }
79  int FmsJetPatchTh0(int t=MAXPP) const { return btest(fp201.output[t],8); }
80  int FmsJetPatchTh1(int t=MAXPP) const { return btest(fp201.output[t],9); }
81  int FmsJetPatchTh2(int t=MAXPP) const { return btest(fp201.output[t],10); }
82  int FmsDijet(int t=MAXPP) const { return btest(fp201.output[t],11); }
83  int FPE(int t=MAXPP) const { return btest(fp201.output[t],14); }
84 
85  //
86  // Additions for 2012:
87  //
88  // http://www.star.bnl.gov/public/trg/TSL/Software/FMS.pdf
89  //
90  int FmsFPEcombo1(int t=MAXPP) const { return btest(fp201.output[t],12); }
91  int FmsFPEcombo2(int t=MAXPP) const { return btest(fp201.output[t],13); }
92 
93 private:
94  int loadRegisters(int runNumber);
95  int MakeMuDst();
96  int MakeStEvent();
97  int MakeTrgData();
98 
99  Crate& crateAt(int i) { return crates[i-1]; }
100  const Crate& crateAt(int i) const { return crates[i-1]; }
101 
102  void runFpeQtLayer(int t=MAXPP);
103  void runFmsQtLayer(int t=MAXPP);
104  void runFmsLayer0(int t=MAXPP);
105  void runFpeLayer1(int t=MAXPP);
106  void runFmsLayer1(int t=MAXPP);
107  void runFpdLayer2(int t=MAXPP);
108 
109  template<class T>
110  void writeQtCrate(const T* hit, int t=MAXPP);
111  void writeQtCrate(int crate, int slot, int ch, int adc, int t=MAXPP);
112  void writeDsmData(int t=MAXPP);
113 
114  void writeFpeQtLayerToFpeLayer1(Crate& sim, int t=MAXPP);
115  void writeFmsQtLayerToFmsLayer0(Crate& sim, int t=MAXPP);
116  void writeFmsLayer0ToFmsLayer1(Crate& sim, int t=MAXPP);
117  void writeFpeLayer1ToFpdLayer2(Crate& sim, int t=MAXPP);
118  void writeFmsLayer1ToFpdLayer2(Crate& sim, int t=MAXPP);
119  void writeFpdLayer2ToFpdLayer3(Crate& sim, int t=MAXPP);
120 
121  void fillQtHistogram(const Crate& qtcrate, TH2F* hqtadc, int t=MAXPP);
122  void fillQtHistograms(int t=MAXPP);
123 
124  // DB time stamp
125  TDatime mDBTime;
126 
127  // Input mode
128  int mUseTrgData;
129  int mUseMuDst;
130  int mUseStEvent;
131 
132  // Crates
133  enum { NCRATES = 14 };
134 #if !defined(__CINT__)
135 
136  Crate crates[NCRATES];
137 
138  Crate& l1;
139  Crate& fms;
140  Crate& mix;
141  Crate& feq;
142  Crate& qt1;
143  Crate& qt2;
144  Crate& qt3;
145  Crate& qt4;
146 
147  // L1 crate
148  Board& fp201;
149 
150  // FMS crate
151  Board& fm001;
152  Board& fm002;
153  Board& fm003;
154  Board& fm004;
155  Board& fm005;
156  Board& fm006;
157  Board& fm007;
158  Board& fm008;
159  Board& fm009;
160  Board& fm010;
161  Board& fm011;
162  Board& fm012;
163  Board& fm101;
164  Board& fm102;
165  Board& fm103;
166  Board& fm104;
167 
168  // MIX crate
169  Board& fe101;
170 
171  // FEQ crate
172  Board& fe001;
173  Board& fe002;
174  Board& fe003;
175  Board& fe004;
176  Board& fs001;
177  Board& fs002;
178  Board& fs003;
179  Board& fs004;
180  Board& fs005;
181  Board& fs006;
182 #else
183  Crate *crates;
184 
185  Crate* l1;
186  Crate* fms;
187  Crate* mix;
188  Crate* feq;
189  Crate* qt1;
190  Crate* qt2;
191  Crate* qt3;
192  Crate* qt4;
193 
194  // L1 crate
195  Board* fp201;
196 
197  // FMS crate
198  Board* fm001;
199  Board* fm002;
200  Board* fm003;
201  Board* fm004;
202  Board* fm005;
203  Board* fm006;
204  Board* fm007;
205  Board* fm008;
206  Board* fm009;
207  Board* fm010;
208  Board* fm011;
209  Board* fm012;
210  Board* fm101;
211  Board* fm102;
212  Board* fm103;
213  Board* fm104;
214 
215  // MIX crate
216  Board* fe101;
217 
218  // FEQ crate
219  Board* fe001;
220  Board* fe002;
221  Board* fe003;
222  Board* fe004;
223  Board* fs001;
224  Board* fs002;
225  Board* fs003;
226  Board* fs004;
227  Board* fs005;
228  Board* fs006;
229 
230 #endif
231  // QA histograms
232  TH2F* hqt1adc;
233  TH2F* hqt2adc;
234  TH2F* hqt3adc;
235  TH2F* hqt4adc;
236  TH2F* hfeqadc;
237 
238  //run# overwrites
239  Int_t mForceRun;
240 
241  //thresholds overwrites
242  static const int MAX=100;
243  Int_t mNThrOW;
244  TString mThrOWName[MAX];
245  Int_t mThrOWValue[MAX];
246 
247  //0 = Use simulatied QT data 1=use DSM input from data
248  Int_t mUseDsmData;
249 
250  // # of pre/post from data
251  Int_t mNPre;
252  Int_t mNPost;
253 
254  //number of ADC=0xFFF
255  Int_t mNFFF;
256 
257  ClassDef(StFmsTriggerMaker,0);
258 };
259 
260 #endif // ST_FMS_TRIGGER_SIMU_H
261 
Definition: Crate.hh:193
Definition: Board.hh:14
void Clear(Option_t *option="")
User defined functions.