StPicoMtdTrigger.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include <iostream>
  2. #include <bitset>
  3. #include "StTriggerData.h"
  4. #include "StMessMgr.h"
  5. #include "StPicoMtdTrigger.h"
  6. ClassImp(StPicoMtdTrigger)
  7. //----------------------------------------------------------------------------------
  8. StPicoMtdTrigger::StPicoMtdTrigger()
  9. {
  10. memset(mQTtacSum,0,sizeof(mQTtacSum));
  11. memset(mMT101Tac,0,sizeof(mMT101Tac));
  12. memset(mMT101Id,0,sizeof(mMT101Id));
  13. mTF201TriggerBit = 0;
  14. }
  15. //----------------------------------------------------------------------------------
  16. StPicoMtdTrigger::StPicoMtdTrigger(const StTriggerData *trigger)
  17. {
  18. // QT information
  19. UShort_t mtdQTtac[4][16];
  20. for(Int_t i=0; i<32; i++)
  21. {
  22. if((i/4)%2==1)
  23. {
  24. mtdQTtac[0][i-i/4*2-2] = trigger->mtdAtAddress(i,0);
  25. mtdQTtac[1][i-i/4*2-2] = trigger->mtdgemAtAddress(i,0);
  26. mtdQTtac[2][i-i/4*2-2] = trigger->mtd3AtAddress(i,0);
  27. mtdQTtac[3][i-i/4*2-2] = trigger->mtd4AtAddress(i,0);
  28. }
  29. }
  30. for(Int_t im=0; im<4; im++)
  31. {
  32. for(Int_t i=0; i<16; i++)
  33. {
  34. if(i%2==1) continue;
  35. mQTtacSum[im][i/2] = 0;
  36. Int_t j2 = mtdQTtac[im][i];
  37. Int_t j3 = mtdQTtac[im][i+1];
  38. if(j2<mtd_qt_tac_min || j2>mtd_qt_tac_max ||
  39. j3<mtd_qt_tac_min || j3>mtd_qt_tac_max ||
  40. TMath::Abs(j2-j3)>mtd_qt_tac_diff_range_abs) continue;
  41. mQTtacSum[im][i/2] = j2 + j3;
  42. }
  43. }
  44. // MT101
  45. for(Int_t i = 0; i < 4; i++)
  46. {
  47. mMT101Tac[i][0] = (trigger->mtdDsmAtCh(3*i,0)) + ((trigger->mtdDsmAtCh(3*i+1,0)&0x3)<<8);
  48. mMT101Id[i][0] = (trigger->mtdDsmAtCh(3*i+1,0)&0xc)>>2;
  49. mMT101Tac[i][1] = (trigger->mtdDsmAtCh(3*i+1,0)>>4) + ((trigger->mtdDsmAtCh(3*i+2,0)&0x3f)<<4);
  50. mMT101Id[i][1] = (trigger->mtdDsmAtCh(3*i+2,0)&0xc0)>>6;
  51. }
  52. // TF201
  53. mTF201TriggerBit = 0;
  54. UShort_t decision = trigger->dsmTF201Ch(0);
  55. for(Int_t i=0; i<8; i++)
  56. {
  57. mTF201TriggerBit |= ((decision>>(i+4))&0x1)<<i;
  58. }
  59. LOG_DEBUG << "input = " << (std::bitset<16>) decision << endm;
  60. LOG_DEBUG << "output = " << (std::bitset<8>) mTF201TriggerBit << endm;
  61. }
  62. //----------------------------------------------------------------------------------
  63. StPicoMtdTrigger::~StPicoMtdTrigger()
  64. {
  65. }
  66. //----------------------------------------------------------------------------------
  67. void StPicoMtdTrigger::getMaximumQTtac(const Int_t qt, Int_t& pos1, Int_t& pos2)
  68. {
  69. pos1 = 0;
  70. pos2 = 0;
  71. UShort_t max1 = 0, max2 = 0;
  72. for(Int_t i=0; i<8; i++)
  73. {
  74. if(max1 < mQTtacSum[qt-1][i])
  75. {
  76. max2 = max1;
  77. pos2 = pos1;
  78. max1 = mQTtacSum[qt-1][i];
  79. pos1 = i+1;
  80. }
  81. else if(max2 < mQTtacSum[qt-1][i])
  82. {
  83. max2 = mQTtacSum[qt-1][i];
  84. pos2 = i+1;
  85. }
  86. }
  87. }