00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #ifndef StTriggerData2009_hh
00075 #define StTriggerData2009_hh
00076
00077 #include "StTriggerData.h"
00078 #include "StDaqLib/TRG/trgStructures2009.h"
00079
00080 class StTriggerData2009 : public StTriggerData {
00081 public:
00082 StTriggerData2009();
00083 StTriggerData2009(const TriggerDataBlk2009* data, int run);
00084 StTriggerData2009(const TriggerDataBlk2009* data, int run, int bs, int dbg=0);
00085 ~StTriggerData2009();
00086
00087 void readData() {readData(0,0);}
00088 void readData(const TriggerDataBlk2009* data, int bs);
00089 void dump() const;
00090
00091
00092 unsigned int version() const;
00093 unsigned int numberOfPreXing() const;
00094 unsigned int numberOfPostXing() const;
00095
00096
00097 unsigned int eventNumber() const;
00098 unsigned int token() const;
00099 unsigned int triggerWord() const;
00100 unsigned int actionWord() const;
00101 unsigned short busyStatus() const;
00102 unsigned short dsmInput() const;
00103 unsigned short trgToken() const;
00104 unsigned short dsmAddress() const;
00105 unsigned short mAddBits() const;
00106 unsigned short bcData(int channel) const;
00107
00108
00109 int L2ResultsOffset(StL2AlgorithmId id) const;
00110 bool isL2Triggered(StL2TriggerResultType id) const;
00111 unsigned long long l2sum() const;
00112
00113
00114 unsigned int bunchCounterHigh() const;
00115 unsigned int bunchCounterLow() const;
00116 unsigned int bunchId48Bit() const;
00117 unsigned int bunchId7Bit() const;
00118 unsigned int spinBit() const;
00119 unsigned int spinBitYellowFilled() const;
00120 unsigned int spinBitYellowUp() const;
00121 unsigned int spinBitYellowDown() const;
00122 unsigned int spinBitYellowUnpol() const;
00123 unsigned int spinBitBlueFilled() const;
00124 unsigned int spinBitBlueUp() const;
00125 unsigned int spinBitBlueDown() const;
00126 unsigned int spinBitBlueUnpol() const;
00127
00128
00129 unsigned short tcuBits() const;
00130 unsigned short lastDSM(int address) const;
00131 unsigned short bemcLayer1DSM(int channel, int prepost=0) const;
00132 unsigned short eemcLayer1DSM(int channel, int prepost=0) const;
00133 unsigned short emcLayer2DSM(int channel) const;
00134 unsigned short fpdLayer1DSMRaw(StBeamDirection eastwest, int channel, int prepost=0) const;
00135
00136 unsigned short fpdLayer2DSMRaw(int channel) const;
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 unsigned short bbcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00147 unsigned short bbcTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00148 unsigned short bbcADCSum(StBeamDirection eastwest, int prepost=0) const;
00149 unsigned short bbcADCSumLargeTile(StBeamDirection eastwest, int prepost=0) const;
00150 unsigned short bbcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
00151 unsigned short bbcTimeDifference() const;
00152 unsigned short bbcEarliestTDCLarge(StBeamDirection eastwest, int prepost=0) const;
00153 unsigned short bbcTimeDifferenceLarge() const;
00154
00155
00156 unsigned short fpd(StBeamDirection eastwest, int module, int pmt, int prepost=0) const;
00157 unsigned short fpdSum(StBeamDirection eastwest, int module) const;
00158
00159
00160 unsigned short nQTdata(int prepost=0) const;
00161 unsigned int* QTdata(int prepost=0) const;
00162 unsigned short fmsADC(int crt, int adr, int ch, int prepost=0) const;
00163 unsigned short fmsTDC(int crt, int adr, int ch, int prepost=0) const;
00164
00165
00166 bool zdcPresent(int prepost=0) const;
00167 unsigned short zdcAtChannel(int channel, int prepost=0) const;
00168 unsigned short zdcAtAddress(int address, int prepost=0) const;
00169 unsigned short zdcUnAttenuated(StBeamDirection eastwest, int prepost=0) const;
00170 unsigned short zdcAttenuated(StBeamDirection eastwest, int prepost=0) const;
00171 unsigned short zdcADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00172 unsigned short zdcTDC(StBeamDirection eastwest, int prepost=0) const;
00173 unsigned short zdcPmtTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00174 unsigned short zdcHardwareSum(int prepost=0) const;
00175
00176 unsigned short zdcEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
00177 bool zdcSumADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
00178 bool zdcFrontADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
00179 bool zdcBackADCaboveThreshold(StBeamDirection eastwest, int prepost=0) const;
00180 unsigned short zdcTruncatedSum(StBeamDirection eastwest, int prepost=0) const;
00181
00182 bool zdcSumADCaboveThresholdL2(StBeamDirection eastwest) const;
00183 bool zdcFrontADCaboveThresholdL2(StBeamDirection eastwest) const;
00184 bool zdcBackADCaboveThresholdL2(StBeamDirection eastwest) const;
00185 unsigned short zdcTimeDifference() const;
00186
00187 bool zdcSumADCaboveThresholdL3(StBeamDirection eastwest) const;
00188 bool zdcFrontADCaboveThresholdL3(StBeamDirection eastwest) const;
00189 bool zdcBackADCaboveThresholdL3(StBeamDirection eastwest) const;
00190 bool zdcTimeDifferenceInWindow() const;
00191
00192
00193 bool zdcSMDPresent(int prepost=0) const;
00194 unsigned short zdcSMD(StBeamDirection eastwest, int verthori, int strip, int prepost=0) const;
00195 unsigned short zdcSMDHighestStrip(StBeamDirection eastwest, int verthori, int prepost=0) const;
00196
00197
00198 unsigned char bemcHighTower(int patch_id, int prepost=0) const;
00199 unsigned char bemcJetPatch (int patch_id, int prepost=0) const;
00200 unsigned char eemcHighTower(int patch_id, int prepost=0) const;
00201 unsigned char eemcJetPatch (int patch_id, int prepost=0) const;
00202 unsigned char bemcHighestTowerADC(int prepost=0) const;
00203 unsigned char eemcHighestTowerADC(int prepost=0) const;
00204
00205
00206 unsigned short vpdADC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00207 unsigned short vpdTDC(StBeamDirection eastwest, int pmt, int prepost=0) const;
00208 unsigned short vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
00209 unsigned short vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost=0) const;
00210 unsigned short vpdEarliestTDC(StBeamDirection eastwest, int prepost=0) const;
00211 unsigned short vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost=0) const;
00212 unsigned short vpdTimeDifference() const;
00213
00214
00215 unsigned short mtdAtAddress(int address, int prepost=0) const;
00216 unsigned short mtdAdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
00217 unsigned short mtdTdc(StBeamDirection eastwest, int pmt, int prepost=0) const;
00218 unsigned char mtdDsmAtCh(int ch, int prepost=0) const;
00219 bool mtdDsmHit(int pmt, int prepost=0) const;
00220 unsigned short mtdgemAtAddress(int address, int prepost=0) const;
00221
00222
00223 unsigned short tofAtAddress(int address, int prepost=0) const;
00224 unsigned short tofTrayMultiplicity(int tray, int prepost=0) const;
00225 unsigned short tofMultiplicity(int prepost=0) const;
00226
00227
00228 unsigned short pp2ppADC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
00229 unsigned short pp2ppTAC(StBeamDirection eastwest, int vh, int udio, int ch, int prepost=0) const;
00230 unsigned long pp2ppDSM(int prepost=0) const;
00231
00232
00233 char* getTriggerStructure();
00234 TriggerDataBlk2009* getTriggerStructure2009();
00235 int getRawSize() const;
00236
00237 unsigned char* getDsm0_BEMCE(int prepost=0) const;
00238 unsigned char* getDsm0_BEMCW(int prepost=0) const;
00239 unsigned short* getDsm1_BEMC(int prepost=0) const;
00240 unsigned char* getDsm0_EEMC(int prepost=0) const;
00241 unsigned short* getDsm1_EEMC(int prepost=0) const;
00242 unsigned short* getDsm2_EMC() const;
00243
00244 unsigned short* getDsm3() const;
00245 unsigned char* getDsm_FMS(int prepost=0) const;
00246
00247
00248 unsigned short* getDsm1_FMS(int prepost=0) const;
00249 unsigned short* getDsm2_FMS() const;
00250 unsigned int l2ResultLength() const;
00251 const unsigned int* l2Result() const;
00252
00253
00254 void killFMS();
00255
00256 protected:
00257 TriggerDataBlk2009 *mData;
00258
00259 EvtDescData2009* EvtDesc;
00260 L1_DSM_Data2009* L1_DSM;
00261 TrgSumData2009* TrgSum;
00262 BELayerBlock2009* mBC1[11];
00263 QTBlock2009* mMXQ[11];
00264 MIXBlock2009* mMIX[11];
00265 BWestBlock2009* mBCW[11];
00266 BEastBlock2009* mBCE[11];
00267 QTBlock2009* mFEQ[11];
00268 BBCBlock2009* mBBC[11];
00269 QTBlock2009* mBBQ[11];
00270 FMSBlock2009* mFMS[11];
00271 QTBlock2009* mQT1[11];
00272 QTBlock2009* mQT2[11];
00273 QTBlock2009* mQT3[11];
00274 QTBlock2009* mQT4[11];
00275 unsigned short mxq[11][16][32],feq[11][16][32],bbq[11][16][32],qt1[11][16][32],qt2[11][16][32],qt3[11][16][32],qt4[11][16][32];
00276 unsigned char tmxq[11][16][32],tfeq[11][16][32],tbbq[11][16][32],tqt1[11][16][32],tqt2[11][16][32],tqt3[11][16][32],tqt4[11][16][32];
00277
00278 void swapOfflen(TrgOfflen2009* offlen);
00279 void swapDataBlk(TriggerDataBlk2009* TrgData);
00280 void swapEvtDesc(EvtDescData2009* EvtDesc);
00281 void swapL1_DSM(L1_DSM_Data2009* L1_DSM);
00282 void swapTrgSum(TrgSumData2009* TrgSum);
00283 void swapRawDetOfflen(TrgOfflen2009* offlen);
00284 void swapRawDet(DataBlock2009* data, int name, int hlength, int bs);
00285
00286 ClassDef(StTriggerData2009,1)
00287 };
00288
00289 inline void StTriggerData2009::swapOfflen(TrgOfflen2009* offlen)
00290 {
00291 swapI((unsigned int*)&offlen->offset);
00292 swapI((unsigned int*)&offlen->length);
00293 }
00294
00295 inline void StTriggerData2009::swapDataBlk(TriggerDataBlk2009 *TrgData)
00296 {
00297 swapI((unsigned int*)&TrgData->FormatVersion);
00298 swapI((unsigned int*)&TrgData->totalTriggerLength);
00299 swapI((unsigned int*)&TrgData->eventNumber);
00300 swapOfflen(&TrgData->EventDesc_ofl);
00301 swapOfflen(&TrgData->L1_DSM_ofl);
00302 swapOfflen(&TrgData->Summary_ofl);
00303 swapIn((unsigned int*)TrgData->PrePostList,10);
00304 }
00305
00306 inline void StTriggerData2009::swapEvtDesc(EvtDescData2009* EvtDesc)
00307 {
00308 swapIn((unsigned int*)&EvtDesc->length,3);
00309 swapSCC((unsigned int*)&EvtDesc->actionWdDetectorBitMask);
00310 swapSSn((unsigned int*)&EvtDesc->TrgToken,12);
00311 }
00312
00313 inline void StTriggerData2009::swapL1_DSM(L1_DSM_Data2009* L1_DSM)
00314 {
00315 swapI((unsigned int*)&L1_DSM->length);
00316 swapSSn((unsigned int*)L1_DSM->TOF,16+8*6);
00317 }
00318
00319 inline void StTriggerData2009::swapTrgSum(TrgSumData2009* TrgSum)
00320 {
00321 swapIn((unsigned int*)&TrgSum->length,1+2+2+32+64+64);
00322 }
00323
00324 inline void StTriggerData2009::swapRawDetOfflen(TrgOfflen2009* offlen)
00325 {
00326 int i;
00327 for (i=0; i<y9MAX_OFFLEN; i++) {
00328 swapOfflen(&offlen[i]);
00329 if (mDebug>0) printf("Offlen id=%2d offset=%d length=%d\n", i, offlen[i].offset, offlen[i].length);
00330 }
00331 }
00332
00333 inline void StTriggerData2009::swapRawDet(DataBlock2009* data, int name, int hlength,int bs)
00334 {
00335 BELayerBlock2009* bc1;
00336 MIXBlock2009* mix;
00337 BBCBlock2009 *bbc;
00338 QTBlock2009* qtdata;
00339 int header_length = 8;
00340 if(bs) swapI((unsigned int*)&data->length);
00341 switch(name){
00342 case y9MXQ_CONF_NUM : case y9FEQ_CONF_NUM : case y9BBQ_CONF_NUM :
00343 case y9QT1_CONF_NUM : case y9QT2_CONF_NUM : case y9QT3_CONF_NUM : case y9QT4_CONF_NUM :
00344 header_length = 12; break;
00345 }
00346 if (hlength != data->length + header_length){
00347 mErrorFlag = mErrorFlag | (1 << name);
00348 printf("StTriggerData2009: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n",
00349 name,data->name[0],data->name[1],data->name[2],data->name[3],
00350 hlength,data->length,header_length);
00351 printf("StTriggerData2009: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n",
00352 name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag);
00353 data=0;
00354 return;
00355 }
00356 if (bs){
00357 switch(name){
00358 case y9BC1_CONF_NUM :
00359 bc1 = (BELayerBlock2009*) data;
00360 swapSSn((unsigned int*)bc1->BEMClayer1,48);
00361 swapSSn((unsigned int*)bc1->EEMClayer1,16);
00362 break;
00363 case y9MIX_CONF_NUM :
00364 mix = (MIXBlock2009*) data;
00365 swapSSn((unsigned int*)mix->FPDEastNSLayer1,8);
00366 swapSSn((unsigned int*)mix->TOFLayer1,8+48);
00367 break;
00368 case y9BCW_CONF_NUM :
00369
00370 break;
00371 case y9BCE_CONF_NUM :
00372
00373 break;
00374 case y9BBC_CONF_NUM :
00375 bbc = (BBCBlock2009*) data;
00376 swapSSn((unsigned int*)bbc->BBClayer1,16+8+8);
00377 break;
00378 case y9FMS_CONF_NUM :
00379
00380 break;
00381 case y9MXQ_CONF_NUM :
00382 case y9FEQ_CONF_NUM :
00383 case y9BBQ_CONF_NUM :
00384 case y9QT1_CONF_NUM :
00385 case y9QT2_CONF_NUM :
00386 case y9QT3_CONF_NUM :
00387 case y9QT4_CONF_NUM :
00388 qtdata = (QTBlock2009*) data;
00389 swapI((unsigned int*)&qtdata->dataLoss);
00390 swapIn(qtdata->data, qtdata->length/4);
00391 break;
00392 }
00393 }
00394 if(mDebug>0)
00395 printf("Read id=%2d name=%1c%1c%1c%1c length=%d\n",
00396 name,data->name[0],data->name[1],data->name[2],data->name[3],data->length);
00397 }
00398
00399 #endif