diff --git a/StRoot/StDaqLib/TRG/trgStructures2022.h b/StRoot/StDaqLib/TRG/trgStructures2022.h new file mode 100644 index 00000000000..ce14fdc3fd8 --- /dev/null +++ b/StRoot/StDaqLib/TRG/trgStructures2022.h @@ -0,0 +1,196 @@ +#ifndef trgStructures2022_h +#define trgStructures2022_h +/****** +* +* Layout of new Trigger Data Block +* +* J.M. Nelson 30 January 2009 +* +* Notes: The event descriptor will describe data from either +* the Mk1 or Mk2 TCUs. The variable TCU_Mark will be 1 for Mk1 +* and 2 for the Mk2 TCU. Variables not used by one or other of the +* TCUs will be zero. +* +* The data block structure will always begin with a 4 character +* name, followed by the byte-count of data following. The structure of +* data will depend on the configuration of particular crates. +* +* Note: PrePost data will only be available on local trigger disks and +* will not be present in event files. +* +* 8Dec16: JMN changed FORMAT_VERSION +* 3Oct17: je - removed DAQ10k TPCpreMask from MIX added EPDlayer# to BBC +* 6Dec18: je - modified BBCBlock structure for added EPD DSMs +* 4Jan19: JMN removed redundant info from BBCBlock +* 12Oct21: JMN and JE: remove FPD[8] from L1_DSM_Data and +* FPDEastNSLayer1[8] from MIXBlock +* Updated FORMAT_VERSION to 47 +* +******************************************************************************/ +#define y22FORMAT_VERSION 0x21101247 /* Format: yymmddvv */ +#define y22MAX_TRG_BLK_SIZE 122896 /* Current total: 113.25k bytes for pre/post non-zero suppressed data. Allow 120k */ +#define y22MAX_OFFLEN 20 /* Depends on the number of crates in the system */ + +#define y22MAX_CONF_NUM 20 +#define y22RCC_CONF_NUM 0 +#define y22L1_CONF_NUM 1 +#define y22BC1_CONF_NUM 2 +#define y22MXQ_CONF_NUM 3 +#define y22MIX_CONF_NUM 4 +#define y22BCW_CONF_NUM 5 +#define y22BCE_CONF_NUM 6 +#define y22EQ3_CONF_NUM 7 +#define y22BBC_CONF_NUM 8 +#define y22BBQ_CONF_NUM 9 +#define y22FMS_CONF_NUM 10 +#define y22QT1_CONF_NUM 11 +#define y22QT2_CONF_NUM 12 +#define y22QT3_CONF_NUM 13 +#define y22QT4_CONF_NUM 14 +#define y22EQ1_CONF_NUM 15 +#define y22EQ2_CONF_NUM 16 +#define y22INF_CONF_NUM 20 + + +#define y22ADD_BIT_PREPILEUP 0 /* pileup present */ +#define y22ADD_BIT_POSTPILEUP 1 +#define y22ADD_BIT_FORCE 5 /* Force store of this event */ +#define y22ADD_BIT_L2_5 6 /* Level 2.5 abort */ +#define y22ADD_BIT_SIM 7 /* Simulated event - used by DAQ */ + + /* Event Descriptor Data Structures */ + +//#pragma pack(1) + +typedef struct { + char name[3]; /* Contains EVD */ + char TrgDataFmtVer; /* Exception for use by DAQ (LS byte of FORMAT_VERSION) */ + int length; /* Byte count of data that follows */ + unsigned int bunchXing_hi; + unsigned int bunchXing_lo; /* Two parts of RHIC bunch crossing number */ + unsigned short actionWdDetectorBitMask; /* from Fifo 1 */ + unsigned char actionWdTrgCommand; /* from Fifo 1 */ + unsigned char actionWdDaqCommand; /* from Fifo 1 */ + unsigned short TrgToken; /* from Fifo 2 */ + unsigned short addBits; /* used by trigger/daq: bit 5=Force store; bit 6=L2.5 abort; bit 7=1 is fake data */ + unsigned short DSMInput; /* only for use with Mk1 TCU. 0 if Mk2 TCU is used */ + unsigned short externalBusy; /* from Fifo 9 (Fifo 3 Mk1 TCU) */ + unsigned short internalBusy; /* from Fifo 9 (Mk2 TCU) */ + unsigned short trgDetMask; // After 11/8/16 + unsigned short tcuCtrBunch_hi; // After 11/8/16 + unsigned short DSMAddress; /* from Fifo 10 (Fifo 6 Mk1 TCU) */ + unsigned short TCU_Mark; /* TCU_Mark Mk1=1 Mk2=2 */ + unsigned short npre; // (crate_mask & 0xfff) << 4 | npre (after 11/8/16) + + unsigned short npost; // (crate_mask & 0xfff000)>>8| npost (after 11/8/16) + unsigned short res1; // (crate_mask & 0xff000000)>>20 | res1&0xf (after 11/8/16) +} EvtDescData2022; + + /* L1 DSM data structures */ + +typedef struct { + char name[4]; /* Contains L1DS */ + int length; /* Byte count of data that follows */ + unsigned short TOF[8]; /* TOF and MTD data */ + unsigned short VTX[8]; /* Separate VPD, ZDC and BBC DSMs have been replaced with this one */ + unsigned short EMC[8]; /* Contents of 1 EMC IB - results of separate BEMC and EEMC DSMs */ + unsigned short TPCMask[8]; /* TPC mask for DAQ10K */ + unsigned short BCdata[16]; /* Contents of 2 Bunch Crossing DSMs IB's */ + unsigned short specialTriggers[8]; /* Contents of 1 Special Trigger DSM - all the special trigger requests */ + unsigned short lastDSM[8]; /* Contents of last DSM IB - results of all DSM trees */ +} L1_DSM_Data2022; + + /* Trigger Summary Data Structures */ + +typedef struct { + char name[4]; /* Contains TSUM */ + int length; /* Byte count of data that follows */ + unsigned int L1Sum[2]; /* L1 Summary */ + unsigned int L2Sum[2]; /* L2 Summary */ + unsigned int L1Result[32]; /* Result from L1 CPU */ + unsigned int L2Result[64]; /* Result from L2 CPU */ + unsigned int C2Result[64]; /* Result from last algorithm */ + unsigned int LocalClocks[32]; /* localClock values from RCC2*/ +} TrgSumData2022; + +typedef struct { + char name[4]; + int length; /* Byte count of data that follows */ + unsigned int data[1]; /* NB: this definition is generic but would vary depending on actual data */ +} DataBlock2022; + +typedef struct { + char name[4]; /* Contains BBC */ + int length; /* Byte count of data that follows */ + unsigned short BBClayer1[8]; /* BBC-small layer1 DSM feeding VT201 DSM */ + unsigned short EPDlayer1a[8]; /* layer1 DSM feeding QT32C TAC info to VT201 DSM */ + unsigned short ZDClayer1[8]; /* layer1 ZDC DSM that feeds the VT201 DSM */ + unsigned short VPD[8]; /* layer1 VPD DSM feeding ADC & TAC values to VT201*/ + unsigned short EPDlayer0t[16]; /* layer0 EPD DSM feeding east & west TAC to EP101 */ + unsigned short EPDlayer1b[8]; /* 2nd layer1 EPD DSM taking EPD QT ADC data to VT201 */ + unsigned short EPDlayer0a[16]; /* layer0 EPD DSM feeding east & west QT32C adcs to EP102 */ + unsigned char EPDlayer0h[32]; /* layer0 EPD DSM feeding east & west QT32B to EP102 */ +} BBCBlock2022; + + +typedef struct { + char name[4]; /* Contains MIX */ + int length; /* Byte count of data that follows */ + unsigned char MTD_P2PLayer1[16]; /* Data from MTD and PP2PP */ + unsigned short TOFLayer1[8]; /* This is TOF Layer 1 */ + unsigned short TOF[48]; /* TOF data */ +/* unsigned short TPCpreMask[24]; */ /* EMC, MTD, & TOF TPC Grid Masks je-removed starting run 18 */ +} MIXBlock2022; + +typedef struct { + char name[4]; + int length; /* Byte count of data that follows */ + int dataLoss; /* Byte count of data truncated due to buffer limitations */ + unsigned int data[1]; /* NB: this definition is generic but would vary depending on actual data */ +} QTBlock2022; + +typedef struct { + char name[4]; + int length; + unsigned char BEMCEast[240]; /* 15 DSMs covering the East half of BEMC */ +} BEastBlock2022; + +typedef struct { + char name[4]; + int length; + unsigned char BEMCWest[240]; /* 15 DSMs covering the West half of BEMC */ +} BWestBlock2022; + +typedef struct { + char name[4]; + int length; + unsigned short BEMClayer1[48]; /* 6 DSMs for BEMC at layer1 */ + unsigned short EEMClayer1[16]; /* 2 DSMs for EEMC at layer1 */ + unsigned char EEMC[144]; /* 9 DSMs for EEMC at layer0 */ +} BELayerBlock2022; + +typedef struct { + char name[4]; + int length; + unsigned char FMS[256]; /* 16 DSMs for FMS */ +} FMSBlock2022; + +typedef struct { + int offset; /* Offset (in bytes) from the start of Trigger block to data */ + int length; /* Length (in bytes) of data */ +} TrgOfflen2022; + +typedef struct { + int FormatVersion; /* Trigger Data Definition Version yymmddvv */ + int totalTriggerLength; /* Total length (bytes) of complete Trigger Block */ + int eventNumber; /* Event number in this run */ + TrgOfflen2022 EventDesc_ofl; /* Offset/length pair to Event Descriptor */ + TrgOfflen2022 L1_DSM_ofl; /* Offset/length pair to L1 DSM Data */ + TrgOfflen2022 Summary_ofl; /* Offset/length pair to Summary Data */ + TrgOfflen2022 MainX[y22MAX_OFFLEN]; /* Offset/length pairs for main crossing */ + int PrePostList[10]; /* Offsets to offset/length pairs to Pre and Post crossing */ + int raw_data[y22MAX_TRG_BLK_SIZE/4]; /* Storage for raw data */ +} TriggerDataBlk2022; + +#endif + diff --git a/StRoot/StEvent/StEventClusteringHints.cxx b/StRoot/StEvent/StEventClusteringHints.cxx index 9a7a0aa9255..dbeaa055309 100755 --- a/StRoot/StEvent/StEventClusteringHints.cxx +++ b/StRoot/StEvent/StEventClusteringHints.cxx @@ -178,6 +178,7 @@ StEventClusteringHints::StEventClusteringHints() setBranch("StTriggerData2017", "evt_trigger", 3); setBranch("StTriggerData2018", "evt_trigger", 3); setBranch("StTriggerData2019", "evt_trigger", 3); + setBranch("StTriggerData2022", "evt_trigger", 3); setBranch("StSPtrVecTrackDetectorInfo", "evt_tracks", 4); setBranch("StSPtrVecPrimaryVertex", "evt_tracks", 4); setBranch("StSPtrVecTrackNode", "evt_tracks", 4); @@ -252,6 +253,7 @@ StEventClusteringHints::StEventClusteringHints() setBranch("StTriggerData2017", "event", 1); setBranch("StTriggerData2018", "event", 1); setBranch("StTriggerData2019", "event", 1); + setBranch("StTriggerData2022", "event", 1); setBranch("StSPtrVecKinkVertex", "event", 1); setBranch("StSPtrVecV0Vertex", "event", 1); setBranch("StSPtrVecXiVertex", "event", 1); diff --git a/StRoot/StEvent/StEventLinkDef.h b/StRoot/StEvent/StEventLinkDef.h index d17024c4b81..827ad617a34 100644 --- a/StRoot/StEvent/StEventLinkDef.h +++ b/StRoot/StEvent/StEventLinkDef.h @@ -38,6 +38,7 @@ #pragma link C++ class StTriggerData2017-; #pragma link C++ class StTriggerData2018-; #pragma link C++ class StTriggerData2019-; +#pragma link C++ class StTriggerData2022-; //IncFile=StDaqLib/TRG/trgStructures.h #pragma link C++ class TrgDataType+; @@ -212,6 +213,21 @@ #pragma link C++ class FMSBlock2019+; #pragma link C++ class TrgOfflen2019+; +//IncFile=StDaqLib/TRG/trgStructures2022.h +#pragma link C++ class TriggerDataBlk2022+; +#pragma link C++ class EvtDescData2022+; +#pragma link C++ class TrgSumData2022+; +#pragma link C++ class L1_DSM_Data2022+; +#pragma link C++ class DataBlock2022+; +#pragma link C++ class BBCBlock2022+; +#pragma link C++ class MIXBlock2022+; +#pragma link C++ class QTBlock2022+; +#pragma link C++ class BEastBlock2022+; +#pragma link C++ class BWestBlock2022+; +#pragma link C++ class BELayerBlock2022+; +#pragma link C++ class FMSBlock2022+; +#pragma link C++ class TrgOfflen2022+; + #pragma link C++ function operator<<(ostream&, const StPxlHit&); #pragma link C++ function operator<<(ostream&, const StIstHit&); #pragma link C++ function operator<<(ostream&, const StTpcPixel&); diff --git a/StRoot/StEvent/StTriggerData2022.cxx b/StRoot/StEvent/StTriggerData2022.cxx new file mode 100644 index 00000000000..8e84ead2286 --- /dev/null +++ b/StRoot/StEvent/StTriggerData2022.cxx @@ -0,0 +1,1874 @@ +/*************************************************************************** + * + * $Id: StTriggerData2022.cxx,v 2.4 2020/05/15 15:40:20 ullrich Exp $ + * + * Author: Akio Ogawa, October 13, 2017 + *************************************************************************** + * + * Description: Concrete implementation of StTriggerData for 2022. + * + *************************************************************************** + * + * $Log: StTriggerData2022.cxx,v $ + * Revision 2.4 2020/05/15 15:40:20 ullrich + * Added protection from corrupt Qt board data (Akio) + * + * Revision 2.3 2022/07/03 08:30:25 ullrich + * correct blue filled bunch bit, and cleaning up unused spin bits (Akio) + * + * Revision 2.2 2022/06/25 15:50:16 ullrich + * Improved QT board error reports/handling. Added EPD access functions. (Akio) + * + * Revision 2.1 2022/01/07 15:49:06 ullrich + * Initial Revision. + * + * + **************************************************************************/ +#include +#include +#include +#include "StTriggerData2022.h" + +ClassImp(StTriggerData2022) + +StTriggerData2022::StTriggerData2022():mData() +{ + mDebug = 0; + // printf("StTriggerData2022 Default Constructor\n"); +} + +StTriggerData2022::StTriggerData2022(const TriggerDataBlk2022* data, int run):mData() +{ + //printf("StTriggerData2022 Constructor with trigger data block\n"); + mYear=2022; mRun = run; mDebug = 0; + mData = new TriggerDataBlk2022; + readData(data,1); +} + +StTriggerData2022::StTriggerData2022(const TriggerDataBlk2022* data, int run, int bs, int dbg):mData() +{ + mYear=2022; mRun = run; mDebug = dbg; + if(mDebug==1) printf("StTriggerData2022 Constructor with trigger data block and byteswap option=%d\n",bs); + mData = new TriggerDataBlk2022; + readData(data,bs); +} + +void StTriggerData2022::blindRunInfo() +{ + mRun=1000000*int(mRun/1000000); + mData->eventNumber = 0; + EvtDesc->bunchXing_hi = 0; + EvtDesc->bunchXing_lo = 0; + L1_DSM->BCdata[2] = 0; + L1_DSM->BCdata[3] = 0; + L1_DSM->BCdata[10] = 0; + L1_DSM->BCdata[11] = 0; +} + +void StTriggerData2022::readData(const TriggerDataBlk2022* data, int bs) { + int copyflag=1; + if (data==0) {copyflag=0;} + if(mDebug==1) printf("StTriggerData2022::readData copyflag=%d byteswap=%d data=%p mData=%p\n",copyflag,bs,data,mData); + + if (copyflag==1){ + unsigned int ver = data->FormatVersion; + if (bs) swapI(&ver); + + if (ver == y22FORMAT_VERSION ) { + if (mDebug==1) printf("StTriggerData2022: version = 0x%x (0x%x or 0x08121140)\n",ver,y22FORMAT_VERSION); + } + else { + mErrorFlag = mErrorFlag | 0x1; + printf("StTriggerData2022: version = 0x%x != (0x%x)\n",ver,y22FORMAT_VERSION); + assert(0); + } + + unsigned int size = data->totalTriggerLength; + if (bs) swapI(&size); + if (size > y22MAX_TRG_BLK_SIZE) { + gMessMgr->Warning() << "StTriggerData2022: Data length = " << size + << " is bigger than max = " << y22MAX_TRG_BLK_SIZE + << endm; + assert(0); + } + if (mDebug==1) printf("StTriggerData2022: size = %d, maxsize = %d\n",size,y22MAX_TRG_BLK_SIZE); + memcpy(mData,data,size); + memset((char*)mData+size,0,sizeof(TriggerDataBlk2022)-size); + } + + if (bs) swapDataBlk(mData); + if (mDebug==1){ + printf("StTriggerData2022: version = 0x%x (0x%x)\n",mData->FormatVersion,y22FORMAT_VERSION); + printf("StTriggerData2022: size = %d, maxsize = %d\n",mData->totalTriggerLength,y22MAX_TRG_BLK_SIZE); + printf("EventDesc length=%10d offset=%10d\n",mData->EventDesc_ofl.length,mData->EventDesc_ofl.offset); + printf("L1_DSM length=%10d offset=%10d\n",mData->L1_DSM_ofl.length,mData->L1_DSM_ofl.offset); + printf("Summary length=%10d offset=%10d\n",mData->Summary_ofl.length,mData->Summary_ofl.offset); + } + + EvtDesc=0; L1_DSM=0; TrgSum=0; + if (mData->EventDesc_ofl.length > 0) EvtDesc = (EvtDescData2022*)((char*)mData + mData->EventDesc_ofl.offset); + if (mData->L1_DSM_ofl.length > 0) L1_DSM = (L1_DSM_Data2022*)((char*)mData + mData->L1_DSM_ofl.offset); + if (mData->Summary_ofl.length > 0) TrgSum = (TrgSumData2022* )((char*)mData + mData->Summary_ofl.offset); + if (bs){ + if (EvtDesc) swapEvtDesc(EvtDesc); + if (L1_DSM) swapL1_DSM(L1_DSM); + if (TrgSum) swapTrgSum(TrgSum); + } + if (EvtDesc==0 || L1_DSM==0 || TrgSum==0){ + mErrorFlag = mErrorFlag | 0x1; + gMessMgr->Warning() << "StTriggerData2022: EvtDesc, L1_DSM or TrgSum is missing" + <<" mErrorFlag="<10 || npost<0 || npost>10){ + mErrorFlag = mErrorFlag | 0x2; + gMessMgr->Warning() << "StTriggerData2022: Invalid npre/post = "<< npre << " / " << npost + <<" mErrorFlag="<MainX; + } + else { + //printf("Prepost list offset = %d\n",mData->PrePostList[i-1]); + if (mData->PrePostList[i-1]==0) continue; + offlen = (TrgOfflen2022*) ((char*)mData + mData->PrePostList[i-1]); + } + if (bs) swapRawDetOfflen(offlen); + for(int k=0; k(offlen[k].length + offlen[k].offset) > static_cast(mData->totalTriggerLength)) { + mErrorFlag = mErrorFlag | (1 << k); + gMessMgr->Warning() << "StTriggerData2022: offset ("<totalTriggerLength<<") for data block id="<= 0) if (mBC1[buffer]) return mBC1[buffer]->BEMClayer1[channel]; + return 0; +} + +unsigned short StTriggerData2022::eemcLayer1DSM(int channel, int prepost) const { + const int n_eemc_layer1=16; + if (channel<0 || channel >=n_eemc_layer1) { + gMessMgr->Warning() << "Endap DSM layer 1 out of range (" << channel << ")" << endm; + return 0; + } + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMClayer1[channel]; + return 0; +} + +unsigned short StTriggerData2022::emcLayer2DSM(int channel) const { + const int n_emc_layer2=8; + if (channel<0 || channel >=n_emc_layer2) { + gMessMgr->Warning() << "EMC DSM layer 2 out of range (" << channel << ")" << endm; + return 0; + } + return L1_DSM->EMC[channel]; +} + +unsigned short StTriggerData2022::tpcMaskDSM(int channel) const { + const int n_tpcMask=8; + if (channel<0 || channel >=n_tpcMask) { + gMessMgr->Warning() << "TPCMask DSM out of range (" << channel << ")" << endm; + return 0; + } + return L1_DSM->TPCMask[channel]; +} + +unsigned char StTriggerData2022::bemcHighTower(int patch_id, int prepost) const { + // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=300; // Full barrel + if ( patch_id < 0 || patch_id >= m_max_patch) { + gMessMgr->Warning() << "Invalid Barrel patch id: " << patch_id << endm; + return 0; + } + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + int dsm=patch_id/10; + int channel=patch_id%10; + unsigned short trg_word; + if (dsm>=15) { + if (mBCE[buffer]) + trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast); + else + return 0; + } + else { + if (mBCW[buffer]) + trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest); + else + return 0; + } + return trg_word & 0x3F; + } + return 0; +} + +unsigned char StTriggerData2022::bemcJetPatch (int patch_id, int prepost) const +{ + // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=300; // Full barrel + if ( patch_id < 0 || patch_id >= m_max_patch) { + gMessMgr->Warning() << "Invalid Barrel patch id: " << patch_id << endm; + return 0; + } + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + int dsm=patch_id/10; + int channel=patch_id%10; + unsigned short trg_word; + if (dsm>=15) { + if (mBCE[buffer]) + trg_word=decodeEmc12bit(dsm-15,channel,mBCE[buffer]->BEMCEast); + else + return 0; + } + else { + if (mBCW[buffer]) + trg_word=decodeEmc12bit(dsm,channel,mBCW[buffer]->BEMCWest); + else + return 0; + } + return trg_word >> 6; + } + return 0; +} + + +unsigned char StTriggerData2022::eemcHighTower(int patch_id, int prepost) const +{ + // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=90; + if ( patch_id < 0 || patch_id >= m_max_patch) { + gMessMgr->Warning() << "Invalid Endcap patch id" << endm; + return 0; + } + int buffer = prepostAddress(prepost); + if (buffer >= 0 && mBC1[buffer]) { + int dsm=patch_id/10; + int channel=patch_id%10; + unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC); + return trg_word & 0x3F; + } + return 0; +} + +unsigned char StTriggerData2022::eemcJetPatch (int patch_id, int prepost) const +{ + // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=90; + if ( patch_id < 0 || patch_id >= m_max_patch) { + gMessMgr->Warning() << "Invalid Endcap patch id" << endm; + return 0; + } + int buffer = prepostAddress(prepost); + if (buffer >= 0 && mBC1[buffer]) { + int dsm=patch_id/10; + int channel=patch_id%10; + unsigned short trg_word = decodeEmc12bit(dsm,channel,mBC1[buffer]->EEMC); + return trg_word >> 6; + } + return 0; +} + +unsigned char StTriggerData2022::bemcHighestTowerADC(int prepost) const { + // Unpacking of Bemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=300; // Full barrel + unsigned char h=0; + for (int i=1; ihh) h=hh; + } + return h; +} + +unsigned char StTriggerData2022::eemcHighestTowerADC(int prepost) const { + // Unpacking of Eemc trigger data (level 0 DSM input, trigger patches) + const int m_max_patch=90; + unsigned char h=0; + for (int i=1; ihh) h=hh; + } + return h; +} + +char* StTriggerData2022::getTriggerStructure() +{ + return (char*) mData; +} + +TriggerDataBlk2022* StTriggerData2022::getTriggerStructure2022() +{ + return mData; +} + +int StTriggerData2022::getRawSize() const +{ + return mData->totalTriggerLength; +} + +unsigned char* StTriggerData2022::getDsm0_BEMCE(int prepost) const { + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBCE[buffer]) return mBCE[buffer]->BEMCEast; + return 0; +} + +unsigned char* StTriggerData2022::getDsm0_BEMCW(int prepost) const { + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBCW[buffer]) return mBCW[buffer]->BEMCWest; + return 0; +} + +unsigned short* StTriggerData2022::getDsm1_BEMC(int prepost) const { + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->BEMClayer1; + return 0; +} + +unsigned char* StTriggerData2022::getDsm0_EEMC(int prepost) const { + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMC; + return 0; +} + +unsigned short* StTriggerData2022::getDsm1_EEMC(int prepost) const{ + int buffer = prepostAddress(prepost); + if (buffer >= 0) if (mBC1[buffer]) return mBC1[buffer]->EEMClayer1; + return 0; +} + +unsigned short* StTriggerData2022::getDsm2_EMC() const{ + return L1_DSM->EMC; +} + +unsigned short* StTriggerData2022::getDsm3() const{ + return L1_DSM->lastDSM; +} + +int StTriggerData2022::L2ResultsOffset(StL2AlgorithmId id) const +{ + switch(id) { + default: return -999999999; + } +} + +bool StTriggerData2022::isL2Triggered(StL2TriggerResultType id) const +{ + return false; +} + +unsigned int StTriggerData2022::l2ResultLength() const +{ + return sizeof(TrgSum->L2Result)/sizeof(unsigned int); +} + +const unsigned int* StTriggerData2022::l2Result() const +{ + return TrgSum->L2Result; +} + +unsigned long long StTriggerData2022::l2sum() const +{ + //printf("L2sum0=%08o\n",TrgSum->L2Sum[0]); + //printf("L2sum1=%08o\n",TrgSum->L2Sum[1]); + unsigned long long hi = TrgSum->L2Sum[1]; + unsigned long long lo = TrgSum->L2Sum[0]; + unsigned long long mask=(hi<<32) | lo; + return mask; +} + +unsigned short StTriggerData2022::vpdADC(StBeamDirection eastwest, int pmt, int prepost) const +{ + static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27}; + if (pmt<1 || pmt>16) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + if (mRun<=12003001) {return bbq[buffer][10+(int)eastwest*2][map[pmt-1]];} + else {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];} + } + return 0; +} + +unsigned short StTriggerData2022::vpdTDC(StBeamDirection eastwest, int pmt, int prepost) const +{ + static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27}; + if (pmt<1 || pmt>16) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + if (mRun<=12003001) {return bbq[buffer][10+(int)eastwest*2][map[pmt-1]+4];} + else {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];} + } + return 0; +} + +unsigned short StTriggerData2022::vpdADCHighThr(StBeamDirection eastwest, int pmt, int prepost) const +{ + static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27}; + if (pmt<1 || pmt>16) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + if (mRun<=12003001) {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]];} + else {return mxq[buffer][6+(int)eastwest*2][map[pmt-1]];} + } + return 0; +} + +unsigned short StTriggerData2022::vpdTDCHighThr(StBeamDirection eastwest, int pmt, int prepost) const +{ + static const int map[16] = {0, 1, 2, 3, 8, 9,10,11,16,17,18,19,24,25,26,27}; + if (pmt<1 || pmt>16) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0) { + if (mRun<=12003001) {return bbq[buffer][6+(int)eastwest*2][map[pmt-1]+4];} + else {return mxq[buffer][6+(int)eastwest*2][map[pmt-1]+4];}; + } + return 0; +} + +unsigned short StTriggerData2022::vpdEarliestTDC(StBeamDirection eastwest, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0){ + if (mBBC[buffer]){ + if (mRun<=10096084){ + if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;} + else {return mBBC[buffer]->VPD[4]%4096;} + } + else if(mRun<=12003001) { + if (eastwest==east) {return mBBC[buffer]->VPD[2]%4096;} + else {return mBBC[buffer]->VPD[0]%4096;} + } + else { + if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;} + else {return mBBC[buffer]->VPD[4]%4096;} + } + + } + } + return 0; +} + +unsigned short StTriggerData2022::vpdEarliestTDCHighThr(StBeamDirection eastwest, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0){ + if (mRun<=10365999){ + return 0; + } + else if(mRun<=12003001) { + if (mBBC[buffer]){ + if (eastwest==east) {return mBBC[buffer]->VPD[6]%4096;} + else {return mBBC[buffer]->VPD[4]%4096;} + } + }else if(mRun<=14001001){ + if(mMIX[buffer]){ + if (eastwest==east) {return mMIX[buffer]->MTD_P2PLayer1[13] + ((mMIX[buffer]->MTD_P2PLayer1[12]&0x0f)<<8);} + else {return mMIX[buffer]->MTD_P2PLayer1[9] + ((mMIX[buffer]->MTD_P2PLayer1[8]&0x0f)<<8);} + } + }else { + if(mMIX[buffer]){ + if (eastwest==east) {return mMIX[buffer]->MTD_P2PLayer1[11] + ((mMIX[buffer]->MTD_P2PLayer1[10]&0xf)<<8);} + else {return (mMIX[buffer]->MTD_P2PLayer1[10]>>4) + ((mMIX[buffer]->MTD_P2PLayer1[9]&0xff)<<4);} + } + } + } + return 0; +} + +unsigned short StTriggerData2022::vpdADCSum(StBeamDirection eastwest, int prepost) const +{ + if(eastwest==east){ + return (bbcVP101(4,prepost) & 0x7ff); + }else{ + return (bbcVP101(6,prepost) & 0x7ff); + } +} + +float StTriggerData2022::vpdMeanTimeDifference(int prepost) const +{ + // return L1_DSM->VTX[7]%8192; + unsigned int ne=(bbcVP101(4,prepost) >> 11) & 0x1f; + unsigned int nw=(bbcVP101(6,prepost) >> 11) & 0x1f; + unsigned int se=bbcVP101(5,prepost); + unsigned int sw=bbcVP101(7,prepost); + int nwse=nw*se; + int nesw=ne*sw; + int nenw=ne*nw; + if(nenw>0) return float(nwse-nesw)/float(nenw); + return -2000.0; +} + +unsigned short StTriggerData2022::bbcVP101(int ch, int prepost) const +{ + int map[8]={3, 2, 1, 0, 7, 6, 5, 4}; + if(ch<0 || ch>7) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0 && mBBC[buffer]){ + return mBBC[buffer]->VPD[map[ch]]; + } + return 0; +} + + +unsigned short StTriggerData2022::dsmTF201Ch(int ch) const // read TF201 data +{ + int map[8]={3, 2, 1, 0, 7, 6, 5, 4}; + return L1_DSM->TOF[map[ch]]; //ch4-7 currently unused +} + +unsigned short StTriggerData2022::mtd4AtAddress(int address, int prepost) const // read QT4 data +{ + if (mRun<=15001001) return 0; // Run-14 onwards... + int buffer = prepostAddress(prepost); + if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][14][address]; + return 0; +} + +unsigned short StTriggerData2022::fmsADC(int crt, int adr, int ch, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && crt>=1 && crt<=7 && adr>=0 && adr<16 && ch>=0 && ch<=31){ + switch(crt){ + case 0: return bbq[buffer][adr][ch]; + case 1: return qt1[buffer][adr][ch]; + case 2: return qt2[buffer][adr][ch]; + case 3: return qt3[buffer][adr][ch]; + case 4: return qt4[buffer][adr][ch]; + case 5: return eq3[buffer][adr][ch]; + case 6: return eq1[buffer][adr][ch]; + case 7: return eq2[buffer][adr][ch]; + } + } + return 0; +} + +unsigned short StTriggerData2022::fmsTDC(int crt, int adr, int ch, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && crt>=0 && crt<=7 && adr>=0 && adr<16 && ch>=0 && ch<=31){ + switch(crt){ + case 0: return tbbq[buffer][adr][ch]; + case 1: return tqt1[buffer][adr][ch]; + case 2: return tqt2[buffer][adr][ch]; + case 3: return tqt3[buffer][adr][ch]; + case 4: return tqt4[buffer][adr][ch]; + case 5: return teq3[buffer][adr][ch]; + case 6: return teq1[buffer][adr][ch]; + case 7: return teq2[buffer][adr][ch]; + } + } + return 0; +} + +unsigned short StTriggerData2022::epdADC(int crt, int adr, int ch, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && crt>=1 && crt<=3 && adr>=0 && adr<16 && ch>=0 && ch<=31){ + switch(crt){ + case 1: return eq1[buffer][adr][ch]; + case 2: return eq2[buffer][adr][ch]; + case 3: return eq3[buffer][adr][ch]; + } + } + return 0; +} + +unsigned short StTriggerData2022::epdTDC(int crt, int adr, int ch, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && crt>=1 && crt<=3 && adr>=0 && adr<16 && ch>=0 && ch<=31){ + switch(crt){ + case 1: return teq1[buffer][adr][ch]; + case 2: return teq2[buffer][adr][ch]; + case 3: return teq3[buffer][adr][ch]; + } + } + return 0; +} + +unsigned short StTriggerData2022::mxqAtSlotAddress(int address, int prepost, int slot) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && address>=0 && address<32){ + if (slot >= 0 && slot<16){ + return mxq[buffer][slot][address]; + } + } + return 0; +} + +unsigned short StTriggerData2022::mtdQtAtCh(int qtid, int address, int prepost) const +{ // read all the MTD QTs data, and the range of qtid is 1-8 + int map1[4] = {0, 10, 12, 14}; + int map2[8] = {0, 9, 10, 11, 12, 13, 14, 15}; + int map3[4] = {0, 9, 11, 13}; + + int buffer = prepostAddress(prepost); + if(buffer>=0 && qtid>0 && address>=0 && address<32){ + if(mRun<=12003001){ + if(qtid>1) return 0; + else return mxq[buffer][map1[qtid-1]][address]; + } + else if(mRun<=14001001){ + if(qtid>2) return 0; + else return mxq[buffer][map1[qtid-1]][address]; + } + else if(mRun<=15001001){ + if(qtid>3) return 0; + else return mxq[buffer][map1[qtid-1]][address]; + } + else if(mRun<=17001001){ + if(qtid>4) return 0; + else return mxq[buffer][map1[qtid-1]][address]; + } + else if(mRun<=18001001){ + if(qtid>8) return 0; + else return mxq[buffer][map2[qtid-1]][address]; + } + else{ + if(qtid>4) return 0; + else return mxq[buffer][map3[qtid-1]][address]; + } + } + + return 0; +} + +unsigned short StTriggerData2022::mtdAtAddress(int address, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][0][address]; + return 0; +} + +unsigned short StTriggerData2022::mtdgemAtAddress(int address, int prepost) const +{ + if (mRun<=12003001) return 0; + int buffer = prepostAddress(prepost); + if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][10][address]; + return 0; +} + +unsigned short StTriggerData2022::mtd3AtAddress(int address, int prepost) const +{ + if (mRun<=14001001) return 0; // Run-13 onwards... + int buffer = prepostAddress(prepost); + if (buffer >= 0 && address>=0 && address<32) return mxq[buffer][12][address]; + return 0; +} + + +unsigned short StTriggerData2022::mtdAdc(StBeamDirection eastwest, int pmt, int prepost) const +{ + //pmt in not used for 2022, it is place holder for next year + int buffer = prepostAddress(prepost); + if (buffer >= 0 && pmt==0){ + if (eastwest==east) { + if (mRun<=10133008) return mxq[buffer][0][0]; + else return mxq[buffer][0][24]; + } + if (eastwest==west) return mxq[buffer][0][8]; + } + return 0; +} + +unsigned short StTriggerData2022::mtdTdc(StBeamDirection eastwest, int pmt, int prepost) const +{ + //pmt in not used for 2022, it is place holder for next year + int buffer = prepostAddress(prepost); + if (buffer >= 0 && pmt==0){ + if (eastwest==east) { + if (mRun<=10133008) return mxq[buffer][0][4]; + else return mxq[buffer][0][28]; + } + if (eastwest==west) return mxq[buffer][0][12]; + } + return 0; +} + +unsigned char StTriggerData2022::mtdDsmAtCh(int ch, int prepost) const +{ + int map[16] = {7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}; + //int map2[8] = {3, 2, 1, 0, 7, 6, 5, 4}; + int buffer = prepostAddress(prepost); + if (buffer >= 0 && ch>=0){ + if(mMIX[buffer]){ + if(ch<16){ + return mMIX[buffer]->MTD_P2PLayer1[map[ch]]; + }else if(ch<32){ + //int add= 8 + map2[(ch-16)/2]; + unsigned char v=0; + //if(ch%2==0){ v=(unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0xff00)>>8);} + //else { v=(unsigned char)((mMIX[buffer]->TPCpreMask[add] & 0x00ff) );} + return v; + } + } + } + return 0; +} + +bool StTriggerData2022::mtdDsmHit(int pmt, int prepost) const +{ + //pmt in not used for 2022, it is place holder for next year + int buffer = prepostAddress(prepost); + if (buffer >= 0){ + if(mMIX[buffer]){ + if(mRun<10133008 && mRun<11000000){ + if( (mMIX[buffer]->MTD_P2PLayer1[5] & 0x1) && (mMIX[buffer]->MTD_P2PLayer1[5] & 0x10) ) return true; + } + else{ + if(prepost!=0) return false; + return (L1_DSM->TOF[3] & 0x1); + } + } + } + return false; +} + +unsigned short StTriggerData2022::mtdVpdTacDiff() const +{ + return (L1_DSM->TOF[3] & 0x3fff); +} + +unsigned short StTriggerData2022::tofAtAddress(int address, int prepost) const +{ + int buffer = prepostAddress(prepost); + if (buffer>=0 && address>=0 && address<48) { + if (mMIX[buffer]) return mMIX[buffer]->TOF[address]; + } + return 0; +} + +unsigned short StTriggerData2022::tofTrayMultiplicity(int tray, int prepost) const +{ + int dsmmap[8] = {3,2,1,0,7,6,5,4}; + int traydsm[120] = { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}; + int traych[120] = { 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, + 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, + 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, + 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17, + 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17, + 18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17}; + int buffer = prepostAddress(prepost); + if (buffer>=0 && tray>=1 && tray<=120) { + if (mMIX[buffer]) { + int address = traydsm[tray-1]*8 + dsmmap[traych[tray-1]/3]; + int ch = traych[tray-1]%3; + return (mMIX[buffer]->TOF[address] >> (5*ch)) & 0x1f; + } + } + return 0; +} + +unsigned short StTriggerData2022::tofMultiplicity(int prepost) const +{ + if (prepost==0) return L1_DSM->TOF[1]%8192; + return 0; +} + +void StTriggerData2022::dump() const +{ + printf("***** StTriggerData Dump *****\n"); + printf(" mDebug=%d mData=%p\n",mDebug,mData); + printf(" Year=%d EvtDesc version=%x header version%x\n",year(),version(),mData->FormatVersion); + printf(" Run#=%d Event#=%d\n",mRun,eventNumber()); + printf(" %d pre and %d post crossing data available\n",numberOfPreXing(),numberOfPostXing()); + printf(" Token=%d TriggerWord=%x ActionWord=%x BusyStatus=%x\n", + token(), triggerWord(), actionWord(), busyStatus()); + printf(" TUC Bits=%d : ",tcuBits()); + for (int i=0; i<16; i++) {printf(" %d",(tcuBits()>>(15-i))%2);}; printf("\n"); + printf(" BunchId 7bit=%d 48bit=%d\n",bunchId7Bit(), bunchId48Bit()); + printf(" Spin Bits=%d : ",spinBit()); + for (int i=0; i<8; i++) {printf(" %d",(spinBit()>>(7-i))%2);}; printf("\n"); + // printf(" CTB ADC : "); for (int i=0; i<240;i++){ printf("%d ",ctb(i,0)); }; printf("\n"); + printf(" BBC East ADC : "); for (int i=1; i<=16;i++){ printf("%2d ",bbcADC(east,i,0)); }; printf("\n"); + printf(" BBC East TAC : "); for (int i=1; i<=16;i++){ printf("%2d ",bbcTDC(east,i,0)); }; printf("\n"); + printf(" BBC West ADC : "); for (int i=1; i<=16;i++){ printf("%2d ",bbcADC(west,i,0)); }; printf("\n"); + printf(" BBC West TAC : "); for (int i=1; i<=16;i++){ printf("%2d ",bbcTDC(west,i,0)); }; printf("\n"); + for (int i=-numberOfPreXing(); i<=static_cast(numberOfPostXing()); i++){ + printf(" BBC Sums %d xing : ",i); + printf("East=%d West=%d Large tile East=%d West=%d\n", + bbcADCSum(east,i),bbcADCSum(west,i), + bbcADCSumLargeTile(east,i),bbcADCSumLargeTile(west,i)); + } + printf(" BBC Earilest : "); printf("East=%d West=%d Difference+256=%d\n", + bbcEarliestTDC(east,0),bbcEarliestTDC(west,0),bbcTimeDifference()); + printf(" ZDC Earilest : "); printf("East=%d West=%d Difference=%d\n", + zdcEarliestTDC(east,0),zdcEarliestTDC(west,0),zdcTimeDifference()); + printf(" ZDC Sum(A) East : ");printf("%d ",zdcAttenuated(east)); printf("\n"); + printf(" ZDC Sum(A) West : ");printf("%d ",zdcAttenuated(west)); printf("\n"); + printf(" ZDC Sum(UA) East : ");printf("%d ",zdcUnAttenuated(east)); printf("\n"); + printf(" ZDC Sum(UA) West : ");printf("%d ",zdcUnAttenuated(west)); printf("\n"); + printf(" VPD E Earliest TAC : %d\n", vpdEarliestTDC(east)); + printf(" VPD W Earliest TAC : %d\n", vpdEarliestTDC(west)); + printf(" VPD TimeDifference : %d\n", vpdTimeDifference()); + printf(" L2 result : \n"); + for (int j=0; j<4 ;j++) { for (int k=0; k<16; k++) {printf("%u ",*(l2Result()+j*16+k)); } printf("\n");} + printf("BBClayer1:"); + int buffer = prepostAddress(0); + if (buffer >=0){ + if (mBBC[buffer]){ + for (int i = 0;i < 8;i++) printf(" %1x %04X", i, mBBC[buffer]->BBClayer1[i]); + } + } + printf("\n"); + printf("ZDClayer1:"); + if (buffer >=0){ + if (mBBC[buffer]){ + for (int i = 0;i < 8;i++) printf(" %1x %04X", i, mBBC[buffer]->ZDClayer1[i]); + } + } + printf("\n"); + printf("VPDlayer1:"); + if (buffer >=0){ + if (mBBC[buffer]){ + for (int i = 0;i < 8;i++) printf(" %1x %04X", i, mBBC[buffer]->VPD[i]); + } + } + printf("TOFMult=%d\n",tofMultiplicity()); + printf("\n"); + + //EPD + int map[3][16]={ {0x01,0x02,0xff, 0x03,0x04,0xff, 0x05,0x06,0xff, 0x07,0x08,0xff, 0x09,0x0a,0x0b, 0xff}, + {0x11,0x12,0xff, 0x13,0x14,0xff, 0x15,0x16,0xff, 0x17,0x18,0xff, 0x19,0x1a,0x1b, 0xff}, + {0x21,0x22,0xff, 0x23,0x24,0xff, 0x25,0x26,0xff, 0x27,0x28,0xff, 0x29,0x2a,0xff, 0xff}}; + int mbc[3][16]={ {0x0b,0x0b,0xff, 0x0b,0x0b,0xff, 0x0b,0x0b,0xff, 0x0c,0x0c,0xff, 0x0c,0x0c,0x0c, 0xff}, + {0x0b,0x0b,0xff, 0x0b,0x0b,0xff, 0x0b,0x0b,0xff, 0x0c,0x0c,0xff, 0x0c,0x0c,0x0c, 0xff}, + {0x0b,0x0b,0xff, 0x0b,0x0c,0xff, 0x0c,0x0b,0xff, 0x0b,0x0b,0xff, 0x0c,0x0c,0xff, 0xff}}; + int epdm[3][16]; memset(epdm,0,sizeof(epdm)); + for(int c=1; c<=3; c++){ + for(int s=0; s<16; s++){ + int bd=map[c][s] & 0x0f; + printf("EQ%1d S=%2d EQ0%02x bd=%1x 1/2 : ",c,s,map[c-1][s],bd); + for (int ch=0; ch<32; ch++){ + if(ch==16) printf("\nEQ%1d S=%2d EQ0%02x bd=%1x 2/2 : ",c,s,map[c-1][s],bd); + printf("%4d ",epdADC(c,s,ch)); + if(map[c-1][s]<0xff){ + if(mbc[c-1][s]==0xb){ + if(epdADC(c,s,ch)>16) epdm[c-1][bd]++; + }else if(mbc[c-1][s]==0xc && (ch/4)%2==0){ + if(epdADC(c,s,ch)>16 && epdADC(c,s,ch+4)>300 && epdADC(c,s,ch+4)<2900) epdm[c-1][bd]++; + } + } + } + printf(" mult=%d\n",epdm[c-1][bd]); + } + } + printf("EP001 TAC+hit: "); for(int c=0; c<8; c++){ printf("%4x ",epdLayer0t(c));} printf("\n"); + printf("EP002 TAC+hit: "); for(int c=8; c<16; c++){ printf("%4x ",epdLayer0t(c));} printf("\n"); + printf("EP003 Nhit: "); for(int c=0; c<8; c++){ printf("%2d ",epdLayer0aMult(c));} printf("\n"); + printf("EP004 Nhit: "); for(int c=8; c<16; c++){ printf("%2d ",epdLayer0aMult(c));} printf("\n"); + printf("EP005 Nhit1: "); for(int c=0; c<10; c++){ printf("%2d ",epdLayer0hMult(c,1));} printf("\n"); + printf("EP005 Nhit2: "); for(int c=0; c<10; c++){ printf("%2d ",epdLayer0hMult(c,2));} printf("\n"); + printf("EP006 Nhit1: "); for(int c=10; c<20; c++){ printf("%2d ",epdLayer0hMult(c,1));} printf("\n"); + printf("EP006 Nhit2: "); for(int c=10; c<20; c++){ printf("%2d ",epdLayer0hMult(c,2));} printf("\n"); + for(int c=1; c<=3; c++){ + for(int q=1; q<=11; q++){ + int eq=(c-1)*0x10 + q; + printf("mult-EQ%03x %02x %02x | %02x : %02x\n",eq,epdNHitsQT(c,q,1),epdNHitsQT(c,q,2),epdm[c-1][q],epdNHitsQT(c,q,1)^epdm[c-1][q]); + } + printf("\n"); + } + printf("EP102 : "); for(int c=0; c<8; c++){ printf("%04x ", epdLayer1b(c));} printf("\n"); + printf("EP102 east Mult : "); for(int r=1; r<=5; r++){ printf("%3d ", epdLayer1bMult(east, r));} printf("\n"); + printf("EP102 west Mult : "); for(int r=1; r<=5; r++){ printf("%3d ", epdLayer1bMult(west, r));} printf("\n"); + printf("EPD(VP201) mult total = %3d diff= %3d\n",epdMultTotal(),epdMultDiff()); + + printf("VTX:"); + if (L1_DSM){ + for (int i = 0;i < 8;i++) printf(" %1x %04X", i, L1_DSM->VTX[i]); + } + printf("\n"); + printf("Last DSM:"); + if (L1_DSM){ + for (int i = 0;i < 8;i++) printf(" %1x %04X", i, L1_DSM->lastDSM[i]); + } + printf("\n"); + printf("***** End StTriggerData Dump *****\n"); +} + +void StTriggerData2022::swapRawDet(DataBlock2022* data, int name, int hlength,int bs) +{ + BELayerBlock2022* bc1; + MIXBlock2022* mix; + BBCBlock2022 *bbc; + QTBlock2022* qtdata; + int header_length = 8; + if(bs) swapI((unsigned int*)&data->length); + switch(name){ + case y22MXQ_CONF_NUM : case y22EQ3_CONF_NUM : case y22BBQ_CONF_NUM : + case y22QT1_CONF_NUM : case y22QT2_CONF_NUM : case y22QT3_CONF_NUM : case y22QT4_CONF_NUM : + case y22EQ1_CONF_NUM : case y22EQ2_CONF_NUM : + header_length = 12; break; + } + if (hlength != data->length + header_length){ + mErrorFlag = mErrorFlag | (1 << name); + printf("StTriggerData2022: Error reading Block=%2d [%1c%1c%1c%1c] length %d != %d + %d\n", + name,data->name[0],data->name[1],data->name[2],data->name[3], + hlength,data->length,header_length); + printf("StTriggerData2022: Droping the data block =%2d [%1c%1c%1c%1c] with ErrorFlag=0x%x\n", + name,data->name[0],data->name[1],data->name[2],data->name[3],mErrorFlag); + data=0; + return; + } + if (bs){ + switch(name){ + case y22BC1_CONF_NUM : + bc1 = (BELayerBlock2022*) data; + swapSSn((unsigned int*)bc1->BEMClayer1,48); + swapSSn((unsigned int*)bc1->EEMClayer1,16); + break; + case y22MIX_CONF_NUM : + mix = (MIXBlock2022*) data; + //swapSSn((unsigned int*)mix->FPDEastNSLayer1,8); //FPDEastNSLayer1 removed + swapSSn((unsigned int*)mix->TOFLayer1,8+48); + break; + case y22BCW_CONF_NUM : + //only char + break; + case y22BCE_CONF_NUM : + //only char + break; + case y22BBC_CONF_NUM : + bbc = (BBCBlock2022*) data; + swapSSn((unsigned int*)bbc->BBClayer1,8+8+8+8+16+8+16); + //char EPDlayer0h doesn't need swap + break; + case y22FMS_CONF_NUM : + //only char + break; + case y22MXQ_CONF_NUM : + case y22EQ3_CONF_NUM : + case y22BBQ_CONF_NUM : + case y22QT1_CONF_NUM : + case y22QT2_CONF_NUM : + case y22QT3_CONF_NUM : + case y22QT4_CONF_NUM : + case y22EQ1_CONF_NUM : + case y22EQ2_CONF_NUM : + qtdata = (QTBlock2022*) data; + swapI((unsigned int*)&qtdata->dataLoss); + swapIn(qtdata->data, qtdata->length/4); + break; + } + } + if(mDebug>0) + printf("Read id=%2d name=%1c%1c%1c%1c length=%d\n", + name,data->name[0],data->name[1],data->name[2],data->name[3],data->length); +} + +void StTriggerData2022::Streamer(TBuffer &R__b) +{ + // Stream an object of class StTriggerData2022. + + if (R__b.IsReading()) { + R__b.ReadClassBuffer(StTriggerData2022::Class(),this); + // cout << "StTriggerData2022::Streamer read trigger data!!!"<offset); + swapI((unsigned int*)&offlen->length); +} + +inline void StTriggerData2022::swapDataBlk(TriggerDataBlk2022 *TrgData) +{ + swapI((unsigned int*)&TrgData->FormatVersion); + swapI((unsigned int*)&TrgData->totalTriggerLength); + swapI((unsigned int*)&TrgData->eventNumber); + swapOfflen(&TrgData->EventDesc_ofl); + swapOfflen(&TrgData->L1_DSM_ofl); + swapOfflen(&TrgData->Summary_ofl); + swapIn((unsigned int*)TrgData->PrePostList,10); +} + +inline void StTriggerData2022::swapEvtDesc(EvtDescData2022* EvtDesc) +{ + swapIn((unsigned int*)&EvtDesc->length,3); + swapSCC((unsigned int*)&EvtDesc->actionWdDetectorBitMask); + swapSSn((unsigned int*)&EvtDesc->TrgToken,12); +} + +inline void StTriggerData2022::swapL1_DSM(L1_DSM_Data2022* L1_DSM) +{ + swapI((unsigned int*)&L1_DSM->length); + swapSSn((unsigned int*)L1_DSM->TOF,16+8*6); //removed FPD[8] +} + +inline void StTriggerData2022::swapTrgSum(TrgSumData2022* TrgSum) +{ + swapIn((unsigned int*)&TrgSum->length,1+2+2+32+64+64); +} + +inline void StTriggerData2022::swapRawDetOfflen(TrgOfflen2022* offlen) +{ + int i; + for (i=0; i0) printf("Offlen id=%2d offset=%d length=%d\n", i, offlen[i].offset, offlen[i].length); + } +} + +#endif diff --git a/StRoot/StTriggerDataMaker/StTriggerDataMaker.cxx b/StRoot/StTriggerDataMaker/StTriggerDataMaker.cxx index 004f655e812..c32dea91288 100644 --- a/StRoot/StTriggerDataMaker/StTriggerDataMaker.cxx +++ b/StRoot/StTriggerDataMaker/StTriggerDataMaker.cxx @@ -27,6 +27,8 @@ #include "StEvent/StTriggerData2018.h" #include "StDaqLib/TRG/trgStructures2019.h" #include "StEvent/StTriggerData2019.h" +#include "StDaqLib/TRG/trgStructures2022.h" +#include "StEvent/StTriggerData2022.h" #include "TFile.h" #include "TH1.h" @@ -60,6 +62,7 @@ Int_t StTriggerDataMaker::Make() const TriggerDataBlk2017 *trgdata2017=0; const TriggerDataBlk2018 *trgdata2018=0; const TriggerDataBlk2019 *trgdata2019=0; + const TriggerDataBlk2022 *trgdata2022=0; St_DataSet* daqReaderDS = GetDataSet("StDAQReader"); if (!daqReaderDS) return kStWarn; @@ -107,10 +110,8 @@ Int_t StTriggerDataMaker::Make() char* data = daqData->GetTable(); if(data){ char version = data[3]; - { - LOG_INFO << Form("StTriggerDataMaker Make() found new data formt with version = %02x%02x%02x%02x\n", - data[0],data[1],data[2],data[3]); - } + LOG_INFO << Form("StTriggerDataMaker Make() found new data formt with version = %02x%02x%02x%02x", + data[0],data[1],data[2],data[3]) << endm; switch(version){ case 0x40: year=2009; @@ -147,6 +148,11 @@ Int_t StTriggerDataMaker::Make() trgdata2019 = (TriggerDataBlk2019*)data; AddData(new TObjectSet("StTriggerData",new StTriggerData2019(trgdata2019,run,1,mDebug),kTRUE)); break; + case 0x47: + year=2022; + trgdata2022 = (TriggerDataBlk2022*)data; + AddData(new TObjectSet("StTriggerData",new StTriggerData2022(trgdata2022,run,1,mDebug),kTRUE)); + break; default: LOG_INFO << "StTriggerDataMaker Make() found new data but with unknown version = " << version << endm; } @@ -166,7 +172,7 @@ Int_t StTriggerDataMaker::Make() if (os) { StTriggerData* pTrg = (StTriggerData*)os->GetObject(); if(pTrg){ - //if(mDebug>0) pTrg->dump(); + // if(mDebug>0) pTrg->dump(); unsigned int err = pTrg->errorFlag(); LOG_DEBUG << "StTriggerDataMaker Make() finished. Found trigger data for year "<< year <<" mErrorFlag="<