10 #include "StPicoMessMgr.h"
11 #include "StPicoMtdTrigger.h"
17 mVpdTacSum(0), mTHUBtime{},
18 mQTtacSum{}, mMT101Tac{}, mMT101Id{}, mTF201TriggerBit(0),
19 mShouldHaveRejectEvent(-1) {
25 UShort_t mtdQTtac[8][16],
const int QTtoModule[8][8],
26 const Int_t QTSlewBinEdge[8][16][8],
27 const Int_t QTSlewCorr[8][16][8]) {
30 int year = runnumber / 1e6 + 1999;
32 if ((runnumber % 1000000) / 1000 >= 273) year += 1;
35 UShort_t mtd_qt_tac_min = 100;
36 if (runnumber >= 16045067) mtd_qt_tac_min = 80;
37 if (runnumber >= 18070005) mtd_qt_tac_min = 200;
38 UShort_t mtd_qt_tac_diff_range_abs = 600;
39 if (year == 2015) mtd_qt_tac_diff_range_abs = 1023;
43 for (Int_t im = 0; im < kNQTboard; im++) {
44 for (Int_t i = 0; i < 8; i++) {
45 if (year == 2016 && i % 2 == 0) {
51 for (Int_t k=0; k<2; k++) {
52 j[k] = mtdQTtac[im][i*2+k];
53 a[k] = mtdQTadc[im][i*2+k];
56 if (a[k]>0 && a[k]<=QTSlewBinEdge[im][i*2+k][0]) {
60 for (Int_t l=1; l<8; l++) {
61 if (a[k] > QTSlewBinEdge[im][i*2+k][l-1] && a[k]<=QTSlewBinEdge[im][i*2+k][l]) {
68 j[k] += QTSlewCorr[im][i * 2 + k][slew_bin];
72 if (j[0] <= mtd_qt_tac_min || j[0] >= mtd_qt_tac_max ||
73 j[1] <= mtd_qt_tac_min || j[1] >= mtd_qt_tac_max ||
74 ::abs(j[0] - j[1]) >= mtd_qt_tac_diff_range_abs) {
80 Int_t module = QTtoModule[im][i];
85 mQTtacSum[im][i] = UShort_t( j[0] + j[1] + abs(module-3)*1./8 * (j[0]-j[1]) );
93 for (Int_t i = 0; i < kNQTboard; i++) {
94 for(Int_t j = 0; j < 2; j++) {
95 mMT101Tac[i][j] = mt101Tac[i][j];
96 mMT101Id[i][j] = mt101Id[i][j];
105 UInt_t decision = dsmBit1;
106 UInt_t decision2 = dsmBit2;
107 mTF201TriggerBit = 0;
109 for (Int_t i = 0; i < 4; i++) {
110 for (Int_t j = 0; j < 2; j++) {
113 mTF201TriggerBit |= ((decision >> (i * 2 + j + 4)) & 0x1) << (qt * 2 + j);
115 mTF201TriggerBit |= ((decision2 >> (i * 2 + j + 4)) & 0x1) << (qt * 2 + j);
119 mTF201TriggerBit |= ((decision >> (i * 2 + j + 4)) & 0x1) << (qt * 2 + j);
124 LOG_DEBUG <<
"input1 = " << (std::bitset<16>) decision <<
"\n"
125 <<
"input2 = " << (std::bitset<16>) decision2 <<
"\n"
126 <<
"output = " << (std::bitset<16>) mTF201TriggerBit
132 mVpdTacSum = trigger.mVpdTacSum;
133 for(Int_t iIter=0; iIter<2; iIter++) {
134 mTHUBtime[iIter] = trigger.mTHUBtime[iIter];
137 for(UShort_t iQTboard=0; iQTboard<kNQTboard; iQTboard++) {
139 for(UShort_t iIter=0; iIter<8; iIter++) {
140 mQTtacSum[iQTboard][iIter] = trigger.mQTtacSum[iQTboard][iIter];
143 for(UShort_t iIter=0; iIter<2; iIter++) {
144 mMT101Tac[iQTboard][iIter] = trigger.mMT101Tac[iQTboard][iIter];
145 mMT101Id[iQTboard][iIter] = trigger.mMT101Id[iQTboard][iIter];
149 mTF201TriggerBit = trigger.mTF201TriggerBit;
150 mShouldHaveRejectEvent = trigger.mShouldHaveRejectEvent;
164 if (qt < 1 || qt > kNQTboard) {
165 LOG_ERROR <<
"Wrong qt board number: " << qt << endm;
169 UShort_t max1 = 0, max2 = 0;
170 for (Int_t i = 0; i < 8; i++) {
171 if (max1 < mQTtacSum[qt - 1][i]) {
174 max1 = mQTtacSum[qt - 1][i];
177 else if (max2 < mQTtacSum[qt - 1][i]) {
178 max2 = mQTtacSum[qt - 1][i];
186 LOG_INFO <<
" VPD TAC sum: " << mVpdTacSum
187 <<
" THUB time ( " << mTHUBtime[0] <<
" , " << mTHUBtime[1] <<
" )" << endm;
188 LOG_INFO <<
"TCU trigger bit: " << mTF201TriggerBit
189 <<
" Should have reject event: " << mShouldHaveRejectEvent
virtual void Print(const Char_t *option="") const
Print MTD trigger information.
Class storing MTD trigger information including VPD, QT, MT101, TF201.
void setQTtacSum(Int_t runnumber, UShort_t mtdQTadc[8][16], UShort_t mtdQTtac[8][16], const Int_t QTtoModule[8][8], const Int_t QTSlewBinEdge[8][16][8], const Int_t QTSlewCorr[8][16][8])
Set TAC sum (j2+j3) for each position in each QT board.
StPicoMtdTrigger()
Default constructor.
void getMaximumQTtac(const Int_t qt, Int_t &pos1, Int_t &pos2)
virtual ~StPicoMtdTrigger()
Destructor.
void setMT101(UShort_t mt101Tac[8][2], UShort_t mt101Id[8][2])
Set two largest TACsum for all QT boards.
void setTF201TriggerBit(Int_t year, UInt_t dsmBit1, UInt_t dsmBit2)
Set trigger bit in TCU that used for online trigger.