StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcTriggerMaker.h
1 //
3 //
4 // StEmcTriggerMaker R. Fatemi (Oct 26, 2006)
5 //
6 // The structure of this class was first developed by J.Klay and Alex Suaide in 2001.
7 // It was originally designed to fill StEvent with the simulated L0 trigger response
8 // but to my understanding was never fully implemented
9 //
10 // Early in 2005, using code originally developed by Alex Stopolsky to emulate the BEMC
11 // FEE output, I expanded the code to return full BEMC L0 trigger emulation. This code
12 // was motivated by the need to run the same trigger algorithm over data and simulation.
13 // All DSM outputs are stored (for data only) in StTriggerDetector class. The ultimate
14 // design vision is that StEmcTriggerMaker serves as access to the StBemcTrigger and
15 // StEemcTrigger classes which mock up the BEMC/EEMC FEE + L0 DSM trigger algorithms.
16 // Interface to L2 should also take place in this class.
17 //
18 // $Id: StEmcTriggerMaker.h,v 1.18 2007/05/12 12:45:53 rfatemi Exp $
19 //
20 // $Log: StEmcTriggerMaker.h,v $
21 // Revision 1.18 2007/05/12 12:45:53 rfatemi
22 // Added BHT2 for 2003, new access scheme extends back to 2003+2004, remove all access to StEmcPedestal tables
23 //
24 // Revision 1.17 2007/05/02 17:36:22 kocolosk
25 // added decoder wrapper method that correlates tower and trigger patch.
26 // Useful for HTTP in particular.
27 //
28 // Revision 1.16 2007/04/30 01:00:25 rfatemi
29 // Update for new trigger interface
30 //
31 // Revision 1.15 2007/04/24 15:53:18 kocolosk
32 // added new interface methods to get trigger thresholds and decisions based on trigId
33 //
35 
36 #ifndef STAR_StEmcTriggerMaker
37 #define STAR_StEmcTriggerMaker
38 
39 #ifndef StMaker_H
40 #include "StMaker.h"
41 #endif
42 #include <TH1.h>
43 #include <TH2.h>
44 #include "emc_def.h"
45 #include "StBemcTrigger.h"
46 #include "StEmcUtil/database/StBemcTables.h"
47 #include "StMessMgr.h"
48 
49 #include <map>
50 using namespace std;
51 
52 #define kNPatches 300
53 #define kNJet 12
54 #define kNTowers 4800
55 #define k12bits 4096
56 
57 class StEvent;
58 class St_db_Maker;
59 
60 class StEmcTriggerMaker : public StMaker
61 {
62 private:
63  StBemcTrigger* mBemcTrigger;
64 
65  int isTrig[50];
66  int TowJetId[50];
67  int DsmAdc[50];
68  int numHT[12];//# of HT which pass HT trigger
69  int numJP[12];//# of JP which pass JP trigger
70  int numHTTP[6];//# of HT-TP which pass HTTP trigger
71  int HT12005array[kNTowers];//array of towers which pass trigger
72  int HT22005array[kNTowers];//array of towers which pass trigger
73  int JP12005array[kNJet];//array of JP's which pass trigger
74  int JP22005array[kNJet];//array of JP's which pass trigger
75  int JPSI2005adc[kNJet];//array of adc for highest tower in JP
76  int JPSI2005id[kNJet];//array of id for highest tower in JP
77  int BL12006arrayADC[kNJet/2];//array of level 1 DSM 5 bit ADC from 2x1 PATCH sum
78 
79  int mIs2003HT1;
80  int mIs2003HT2;
81  int mIs2004HT1;
82  int mIs2004JP1;
83  int mIs2004HT2;
84  int mIs2004JP2;
85  int mIs2005HT1;
86  int mIs2005JP1;
87  int mIs2005HT2;
88  int mIs2005JP2;
89  int mIs2005ADJ;
90  int mIs2005JPSI;
91  int mIs2006JP0[6];
92  int mIs2006HT2[6];
93  int mIs2006JP1[6];
94  int mIs2006JPSI[6];
95  int mIs2006HTTP[6];
96 
97  int HT1_ID_2003;
98  int HT2_ID_2003;
99  int HT1_ID_2004;
100  int HT2_ID_2004;
101  int JP1_ID_2004;
102  int JP2_ID_2004;
103  int HT1_ID_2005;
104  int HT2_ID_2005;
105  int JP1_ID_2005;
106  int JP2_ID_2005;
107  int ADJ_ID_2005;
108  int HT2_ID_2006[6];
109  int JP0_ID_2006[6];
110  int JP1_ID_2006[6];
111 
112  int HT1_DSM_2003;
113  int HT2_DSM_2003;
114  int HT1_DSM_2004;
115  int HT2_DSM_2004;
116  int JP1_DSM_2004;
117  int JP2_DSM_2004;
118  int HT1_DSM_2005;
119  int HT2_DSM_2005;
120  int JP1_DSM_2005;
121  int JP2_DSM_2005;
122  int ADJ_DSM_2005;
123  int HT2_DSM_2006[6];
124  int JP0_DSM_2006[6];
125  int JP1_DSM_2006[6];
126  int BETOT_DSM_2006;
127 
128  int numHT1_2005;
129  int numHT2_2005;
130  int numJP1_2005;
131  int numJP2_2005;
132  int numADJ_2005;
133  int HT1_2005_array[kNTowers];
134  int HT2_2005_array[kNTowers];
135  int JP1_2005_array[kNJet];
136  int JP2_2005_array[kNJet];
137  int ADJ_2005_array[kNJet];
138  int JPSI_2005_ADC[kNJet];
139  int JPSI_2005_ID[kNJet];
140  int numHT2_2006[6];
141  int numJP0_2006[6];
142  int numJP1_2006[6];
143  int HT2_2006_array[6][kNTowers];
144  int JP0_2006_array[6][kNJet];
145  int JP1_2006_array[6][kNJet];
146  int JPSI_2006_ADC[6][kNJet];
147  int JPSI_2006_ID[6][kNJet];
148  int numHTTP_2006[6];
149  int HTTP_2006_arrayTP[6][kNPatches];
150  int HTTP_2006_arrayHT[6][kNPatches];
151  int HTTP_2006_arrayTP_ADC[6][kNPatches];
152  int HTTP_2006_arrayHT_ADC[6][kNPatches];
153  int BL1_2006_arrayADC[kNJet/2];
154 
155 protected:
156 public:
157  StEmcTriggerMaker(const char *name="bemctrigger");
158  virtual ~StEmcTriggerMaker();
159 
160  virtual Int_t Init();
161  virtual Int_t Make();
162  virtual Int_t Finish();
163 
164  void fillStEvent(StEvent*);
165  void saveHistograms(char*);
166  // void setSaveStEvent(bool a) {mSaveStEvent = a;}
167  void set2006Trigger(int);
168 
170  int isTrigger(int trigId);
172  int barrelTowerThreshold(int trigId, int softId=1);
174  int barrelTriggerPatchThreshold(int trigId, int patchId=1);
176  int barrelJetPatchThreshold(int trigId, int patchId=1);
179 
181  map<int,int> barrelTowersAboveThreshold(int trigId);
183  map<int,int> barrelTriggerPatchesAboveThreshold(int trigId);
185  map<int,int> barrelJetPatchesAboveThreshold(int trigId);
186 
187  int barrelTriggerPatchForTower(int softId);
188 
189  int endcapTowerThreshold(int trigId);
190  int endcapTriggerPatchThreshold(int trigId);
191  int endcapJetPatchThreshold(int trigId);
192 
193  map<int,int> endcapTowersAboveThreshold(int trigId);
194  map<int,int> endcapTriggerPatchesAboveThreshold(int trigId);
195  map<int,int> endcapJetPatchesAboveThreshold(int trigId);
196 
198  int totalEnergyThreshold(int trigId);
200  int totalEnergy();
201 
202 
203  int is2003HT1() {return mIs2003HT1;}//1=true,0=false,-1=problem
204  int is2003HT2() {return mIs2003HT2;}
205  int is2004HT1() {return mIs2004HT1;}
206  int is2004HT2() {return mIs2004HT2;}
207  int is2004JP1() {return mIs2004JP1;}
208  int is2004JP2() {return mIs2004JP2;}
209  int is2005HT1() {return mIs2005HT1;}
210  int is2005HT2() {return mIs2005HT2;}
211  int is2005JP1() {return mIs2005JP1;}
212  int is2005JP2() {return mIs2005JP2;}
213  int is2005ADJ() {return mIs2005ADJ;}
214  int is2005JPSI() {return mIs2005JPSI;}
215 
216  int get2003HT1_ID() {return HT1_ID_2003;}//tower/JP id of trigger
217  int get2003HT2_ID() {return HT2_ID_2003;}
218  int get2004HT1_ID() {return HT1_ID_2004;}
219  int get2004HT2_ID() {return HT2_ID_2004;}
220  int get2004JP1_ID() {return JP1_ID_2004;}
221  int get2004JP2_ID() {return JP2_ID_2004;}
222  int get2005HT1_ID() {return HT1_ID_2005;}
223  int get2005HT2_ID() {return HT2_ID_2005;}
224  int get2005JP1_ID() {return JP1_ID_2005;}
225  int get2005JP2_ID() {return JP2_ID_2005;}
226  int get2005ADJ_ID() {return ADJ_ID_2005;}
227 
228  int get2003HT1_ADC() {return HT1_DSM_2003;}//6 bit DSM ADC
229  int get2003HT2_ADC() {return HT2_DSM_2003;}
230  int get2004HT1_ADC() {return HT1_DSM_2004;}
231  int get2004HT2_ADC() {return HT2_DSM_2004;}
232  int get2004JP1_ADC() {return JP1_DSM_2004;}
233  int get2004JP2_ADC() {return JP2_DSM_2004;}
234  int get2005HT1_ADC() {return HT1_DSM_2005;}
235  int get2005HT2_ADC() {return HT2_DSM_2005;}
236  int get2005JP1_ADC() {return JP1_DSM_2005;}
237  int get2005JP2_ADC() {return JP2_DSM_2005;}
238  int get2005ADJ_ADC() {return ADJ_DSM_2005;}
239 
240  void get2005HT1_TOWS(int, int*);//array of tow ids passing HT1_2005 trig
241  void get2005HT2_TOWS(int, int*);//array of tow ids passing HT2_2005 trig
242  int get2005HT1_NTOWS() {return numHT1_2005;}//# tows passing HT1_2005 trig
243  int get2005HT2_NTOWS() {return numHT2_2005;}//# tows passing HT2_2005 trig
244 
245  void get2005JP1_PATCHES(int, int*);//array of patches passing JP1_2005
246  void get2005JP2_PATCHES(int, int*);//array of patches passing JP2_2005
247  int get2005JP1_NPATCHES() {return numJP1_2005;}//# patches passing JP1_2005
248  int get2005JP2_NPATCHES() {return numJP2_2005;}//# patches passing JP2_2005
249 
250  void get2005JPSI_ADC(int, int*);//array of HT adc for each JP
251  void get2005JPSI_ID(int, int*);//array of HT id for each JP
252  void get2006BL1_ADC(int, int*);//array of DSM_L1 ADC values
253 
254 
255  StBemcTrigger* getTrigger()
256  {
257  return mBemcTrigger;
258  }
259 
260  void setDbMaker(St_db_Maker *dbMk)
261  {
262  //mBemcTrigger->setDbMaker(dbMk);
263  //This has been disabled so as to use StBemcTables but
264  //allow old code not to break
265  }
266 
267  StBemcTables* tables;
268 
269  void setTableMaker(StBemcTables *bemcTab)
270  {
271  mBemcTrigger->setTableMaker(bemcTab);
272  }
273 
274  int trigPatch[300];
275 
276  ClassDef(StEmcTriggerMaker,0)
277  };
278 #endif