1 #include "St_trg_Maker.h"
2 #include "StDaqLib/TRG/trgStructures2003.h"
3 #include "St_DataSetIter.h"
4 #include "StDAQMaker/StDAQReader.h"
5 #include "StDAQMaker/StTRGReader.h"
6 #include "tables/St_dst_L0_Trigger_Table.h"
7 #include "tables/St_dst_L1_Trigger_Table.h"
8 #include "tables/St_dst_L2_Trigger_Table.h"
9 #include "tables/St_dst_TrgDet_Table.h"
10 #include "tables/St_ctu_raw_Table.h"
12 #include "tables/St_mwc_raw_Table.h"
14 #include "tables/St_dst_TrgDet_Table.h"
17 void St_trg_Maker::SecondDstDaq2003(St_dst_L0_Trigger *dst2) {
20 dst_L0_Trigger_st *tt = dst2->GetTable();
21 tt->TrgToken = mS2003->EvtDesc.TrgToken;
22 tt->TriggerActionWd = mActionWord;
23 tt->DSMInput = mS2003->EvtDesc.DSMInput;
24 tt->DSMAddress = mS2003->EvtDesc.DSMAddress;
25 tt->TriggerWd = mS2003->EvtDesc.TriggerWord;
26 tt->DetectorBusy = mS2003->EvtDesc.modifiedBusyStatus;
27 tt->addBits = mS2003->EvtDesc.addBits;
28 for(i=0;i<32;i++) tt->CPA[i]=mS2003->TrgSum.DSMdata.CPA[i];
29 tt->MWC_CTB_mul = mS2003->TrgSum.DSMdata.lastDSM[2];
30 tt->MWC_CTB_dipole = 0;
31 tt->MWC_CTB_topology = 0;
32 tt->MWC_CTB_moment = 0;
37 int npre,npost,pp,tray,slat;
38 dst_TrgDet_st *tt = dst1->GetTable();
40 tt->bunchXing_lo=mS2003->EvtDesc.bunchXing_lo;
41 tt->bunchXing_hi=(mS2003->EvtDesc.bunchXing_hi)&(0xFFFF);
42 npre=mS2003->EvtDesc.npre;
43 npost=mS2003->EvtDesc.npost;
46 for(pp=0;pp<1+npre+npost;pp++) {
49 for(slat=0;slat<2;slat++) {
50 for(tray=0;tray<120;tray++) {
51 tt->nCtb[tray][slat][pp]=mS2003->rawTriggerDet[pp].CTB[ctbmap[tray][slat]];
52 tt->timeCtb[tray][slat][pp]=0;
57 int i,subsector,sector;
58 for(sector=0;sector<24;sector++) {
59 for(subsector=0;subsector<4;subsector++) {
60 tt->nMwc[sector][subsector][pp]=mS2003->rawTriggerDet[pp].MWC[mwcmap[sector][subsector]];
63 for(i=0;i<16;i++) tt->ctbaux[i][pp]=mS2003->rawTriggerDet[pp].CTB[auxctbmap[i]];
64 for(i=0;i<32;i++) tt->mwcaux[i][pp]=mS2003->rawTriggerDet[pp].MWC[auxmwcmap[i]];
69 Int_t St_trg_Maker::SanityCheck2003() {
71 x=mS2003->TrgSum.L1SumBytes; assert(x==0x0084||x==0x8400);
72 x=mS2003->TrgSum.L2SumBytes; assert(x==0x0084||x==0x8400);
77 #ifdef LATER_THAN_YEAR_2000 // Year 2000 trgStructures.h does not have BEMC.
78 #define BYTESPERDSM 16 //The number of output bytes the 20 signals are packed into
79 typedef unsigned char byte;
81 int tower_map[10] = {0,1,2,3,4,5,6,7,8,9};
82 int swapByteOrder[16] = {7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8};
90 int AA_dsm_to_patch[5] = {0,0,15,16,17};
91 int pp_dsm_to_patch[7] = {0,0,15,28,16,29,17};
95 void St_trg_Maker::Emc2003(St_dst_TrgDet *dst1) {
96 dst_TrgDet_st *tt = dst1->GetTable();
104 std::time_t utime = info.UnixTime;
105 std::tm *time = gmtime(&utime);
106 int year=1900+time->tm_year;
107 int month=1+time->tm_mon;
108 int day=time->tm_mday;
110 sprintf(text1,
"%04d%02d%02d",year,month,day);
111 unsigned int date=atoi(text1);
112 if (date < 20011201) {
117 byte dsmval[NUMDSM][BYTESPERDSM];
118 byte val[BYTESPERDSM];
119 byte hi_tower,tower_sum;
120 int i,j,k,index,nt,patch,sort;
122 for (i=0; i<NUMDSM ; i++) {
123 for (j=0; j < BYTESPERDSM; j++) {
125 dsmval[i][j] = mS2003->rawTriggerDet[0].BEMC[index];
131 for (i=2; i<NUMDSM; i++) {
133 if (date < 20011201) {
134 patch = AA_dsm_to_patch[i];
136 patch = pp_dsm_to_patch[i];
138 for (j=0; j<BYTESPERDSM; j++) {
139 k = swapByteOrder[j];
140 val[k] = dsmval[i][j];
144 for (index=0; index<5; index++) {
147 hi_tower = (val[k] & 0x3f);
148 tower_sum = ((val[k]>>6) & 0x3) + ((val[k+1] & 0xF)<<2);
150 sort = tower_map[nt] + 10*patch;
151 assert(sort>=0&&sort<300);
152 tt->emcHiTower[sort] = hi_tower;
153 tt->emcTrigPatch[sort] = tower_sum;
158 hi_tower = ((val[k+1]>>4) & 0xF) + ((val[k+2] & 0x3)<<4);
159 tower_sum = ((val[k+2]>>2) & 0x3F);
161 sort = tower_map[nt] + 10*patch;
162 assert(sort>=0&&sort<300);
163 tt->emcHiTower[sort] = hi_tower;
164 tt->emcTrigPatch[sort] = tower_sum;
171 #endif // LATER_THAN_YEAR_2000
177 int St_trg_Maker::Daq2003(
St_DataSet *herb,St_dst_TrgDet *dst1,St_dst_L0_Trigger *dst2,
178 St_dst_L1_Trigger *dst3,St_dst_L2_Trigger *dst4) {
180 char *ptr,isLaser=0,isPhysics=0,isPulser=0,thisEventOk=0;
182 fVictor=fVictorPrelim->getTRGReader(); assert(fVictor);
185 assert(fVictor->thereIsTriggerData());
191 ptr=(
char*)(fVictor->getData());
195 ( (
unsigned short)(mS2003->EvtDesc.actionWdTrgCommand) * 16 * 16 * 16 ) +
196 ( (
unsigned short)(mS2003->EvtDesc.actionWdDaqCommand) * 16 * 16 ) +
197 ( mS2003->EvtDesc.actionWdDetectorBitMask & 0x00ff );
205 LOG_INFO << Form(
"Daq2003 : ActionWrdCommand is 0x%0x TriggerWord 0x%0x",
206 mS2003->EvtDesc.actionWdTrgCommand,
207 mS2003->EvtDesc.TriggerWord) << endm;
210 if( (((mActionWord)&0xf000)==0x9000 ) &&
211 (((mActionWord)&0x0001)==0x0001 )
216 if(mActionWord>>12==4) isPhysics=7;
217 if(mS2003->EvtDesc.TriggerWord==0xf101) isPulser=7;
219 if((
m_Mode )==0) thisEventOk=7;
220 if((
m_Mode&1)&&isPhysics) thisEventOk=7;
221 if((
m_Mode&2)&&isLaser) thisEventOk=7;
222 if((
m_Mode&4)&&isPulser) thisEventOk=7;
225 const char *oo =
"unknown";
226 if(isPhysics) oo=
"Physics";
227 if(isLaser) oo=
"Laser";
228 if(isPulser) oo=
"Pulser";
230 LOG_INFO <<Form(
"Daq2003 : %s event. TrgActionWd=0x%x. TriggerWd=0x%0x. Returning %s. m_Mode=%d.\n",
232 mS2003->EvtDesc.TriggerWord,
233 thisEventOk?
"kStOK":
"kStErr",
236 if (!thisEventOk)
return kStErr;
243 SecondDstDaq2003(dst2);
244 TakeCareOfL1andL2Daq2003(dst3,dst4);
245 #ifdef LATER_THAN_YEAR_2000 // Year 2000 trgStructures.h does not have BEMC.
251 cout <<
"St_trg_Maker:: Daq2003 : Event has been accepted" << endl;
256 void St_trg_Maker::TakeCareOfL1andL2Daq2003(St_dst_L1_Trigger *dst3,St_dst_L2_Trigger *dst4) {
258 dst_L1_Trigger_st *tt1 = dst3->GetTable();
259 dst_L2_Trigger_st *tt2 = dst4->GetTable();
261 tt1->L1_result[i] = mS2003->TrgSum.L1Result[i];
262 tt2->L2_result[i] = mS2003->TrgSum.L2Result[i];
265 void St_trg_Maker::VpdDaq2003(St_dst_TrgDet *dst1) {
267 dst_TrgDet_st *tt = dst1->GetTable();
276 void St_trg_Maker::ZdcDaq2003(St_dst_TrgDet *dst1) {
278 dst_TrgDet_st *tt = dst1->GetTable();
279 for(i=0;i<8;i++) tt->lastDSM[i]=mS2003->TrgSum.DSMdata.lastDSM[i];
281 tt->adcZDC[i]=mS2003->rawTriggerDet[0].ZDC[i];
283 tt->BCdata[i]=mS2003->TrgSum.DSMdata.BCdata[i];
285 tt->adcZDCEast=mS2003->rawTriggerDet[0].ZDC[13];
286 tt->adcZDCWest=mS2003->rawTriggerDet[0].ZDC[10];
287 tt->adcZDCsum=mS2003->rawTriggerDet[0].ZDC[13]+mS2003->rawTriggerDet[0].ZDC[10];
294 dst_TrgDet_st *tt = dst1->GetTable();
295 for(i=0; i < 80 ;i++) {
296 tt->BBC[i] = (
unsigned short) mS2003->rawTriggerDet[0].BBC[i];
301 void St_trg_Maker::dumpDataToScreenAndExit2003() {
void CtbMwcDaq2003(St_dst_TrgDet *dst1)
This method copies Ctb and Mwc trigger data to the dst_TrgDet_st table.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
void BbcDaq2003(St_dst_TrgDet *dst)
Following this layout of one routine per trigger to recover.