MpdZdcDigi.cxx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*************************************************************************************
  2. *
  3. * MpdZdcDigi
  4. * Class for digital data taken from MpdZdc detector
  5. *
  6. * Author: Elena Litvinenko
  7. * e-mail: litvin@nf.jinr.ru
  8. * Version: 18-Apr-2008
  9. * Modified March 2021 by A.Strijak
  10. *
  11. ************************************************************************************/
  12. #include "MpdZdcDigi.h"
  13. #include "MpdZdcDigiScheme.h"
  14. #include <iostream>
  15. using std::cout;
  16. using std::endl;
  17. static const Int_t kADCBits = 30; // build-in constant
  18. static const Double_t kADCResolution=1e-9; // build-in constant
  19. static const Double_t kEnergyDigiThreshold=0; // build-in constant
  20. char MpdZdcDigi::fWasInitialized = 0;
  21. Int_t MpdZdcDigi::fADCBits = kADCBits;
  22. Double_t MpdZdcDigi::fADCResolution = kADCResolution;
  23. Double_t MpdZdcDigi::fEnergyDigiThreshold = kEnergyDigiThreshold;
  24. // -------------------------------------------------------------------------
  25. MpdZdcDigi::MpdZdcDigi()
  26. {
  27. fDetectorID = -1;
  28. fModuleID = -1;
  29. fChannelID = -1;
  30. fELoss = 0;
  31. fELossDigi = 0;
  32. fELossReco = 0.;
  33. fIsPsd = kFALSE;
  34. }
  35. // -------------------------------------------------------------------------
  36. MpdZdcDigi::MpdZdcDigi(Int_t pfDetectorID, Int_t pfModuleID, Int_t pfChannelID, Double_t pfELoss, Bool_t pIsPsd )
  37. {
  38. fDetectorID = pfDetectorID;
  39. fModuleID = pfModuleID;
  40. fChannelID = pfChannelID;
  41. fELossDigi = 0;
  42. InitStatic(pIsPsd);
  43. fELoss = pfELoss;
  44. }
  45. // -------------------------------------------------------------------------
  46. MpdZdcDigi::MpdZdcDigi(MpdZdcPoint *p, Bool_t pIsPsd)
  47. {
  48. fDetectorID = -1;
  49. fModuleID = -1;
  50. fChannelID = -1;
  51. fELoss = 0;
  52. fELossDigi = 0;
  53. MpdZdcDigiScheme *pDigiScheme = MpdZdcDigiScheme::Instance();
  54. if ((pDigiScheme)&&(p)) {
  55. Int_t detID, modID, chanID;
  56. pDigiScheme->SplitDigiID(pDigiScheme->GetDigiIdFromCoords(p->GetX(),p->GetY(),p->GetZ()),detID, modID, chanID);
  57. fDetectorID = detID;
  58. fModuleID = modID;
  59. fChannelID = chanID;
  60. fELoss = p->GetEnergyLoss();
  61. }
  62. InitStatic(pIsPsd);
  63. }
  64. // -------------------------------------------------------------------------
  65. MpdZdcDigi::~MpdZdcDigi()
  66. {
  67. }
  68. // -------------------------------------------------------------------------
  69. void MpdZdcDigi::Clear()
  70. {
  71. fWasInitialized=0;
  72. fIsPsd=kFALSE;
  73. fADCBits = kADCBits;
  74. fADCResolution = kADCResolution;
  75. fEnergyDigiThreshold = kEnergyDigiThreshold;
  76. fELossDigi = 0;
  77. fELoss = 0;
  78. }
  79. // -------------------------------------------------------------------------
  80. // -------------------------------------------------------------------------
  81. void MpdZdcDigi::InitStatic(Bool_t pIsPsd)
  82. {
  83. Bool_t do_init = ((fIsPsd!=pIsPsd)||(!fWasInitialized));
  84. if (do_init) {
  85. Clear();
  86. fIsPsd = pIsPsd;
  87. fWasInitialized=1;
  88. MpdZdcDigiScheme *pDigiScheme = MpdZdcDigiScheme::Instance();
  89. if (pDigiScheme) {
  90. MpdZdcDigiPar* pZdcDigiPar=0;
  91. if (pIsPsd)
  92. pZdcDigiPar = (MpdZdcDigiPar*)pDigiScheme->GetZdcPsdDigiPar();
  93. else
  94. pZdcDigiPar = pDigiScheme->GetZdcDigiPar();
  95. if (pZdcDigiPar) {
  96. fADCBits = pZdcDigiPar->GetADCBits();
  97. fADCResolution = pZdcDigiPar->GetADCResolution();
  98. fEnergyDigiThreshold = pZdcDigiPar->GetEnergyDigiThreshold();
  99. fWasInitialized=2;
  100. }
  101. }
  102. }
  103. }
  104. // -------------------------------------------------------------------------
  105. void MpdZdcDigi::Print(const Option_t* opt)
  106. {
  107. cout << " MpdZdcDigi DetID:" << fDetectorID << " ModuleID:" << fModuleID<< " ChanID:" << fChannelID<<
  108. " ELossDigi:" << fELossDigi<< " ELoss: " << fELoss << " IsPsd: " <<
  109. fIsPsd << " [Bits:" << fADCBits <<", Resol:" << fADCResolution <<
  110. ", Thresh:" << fEnergyDigiThreshold << ", Init:"<< fWasInitialized << "]" << endl;
  111. }
  112. // -------------------------------------------------------------------------
  113. UInt_t MpdZdcDigi::AddZdcPoint (MpdZdcPoint *p)
  114. {
  115. MpdZdcDigiScheme *pDigiScheme = MpdZdcDigiScheme::Instance();
  116. if ((pDigiScheme)&&(p)) {
  117. Int_t detID, modID, chanID;
  118. pDigiScheme->SplitDigiID(pDigiScheme->GetDigiIdFromCoords(p->GetX(),p->GetY(),p->GetZ()),detID, modID, chanID);
  119. if ((fDetectorID == detID)&&(fModuleID == modID)&&(fChannelID == chanID))
  120. fELoss += p->GetEnergyLoss();
  121. }
  122. return 0;
  123. }
  124. // -------------------------------------------------------------------------
  125. UInt_t MpdZdcDigi::ADC (Double_t pfELoss)
  126. {
  127. // if (pfELoss<=fEnergyDigiThreshold) {
  128. if (pfELoss>0) {
  129. UInt_t tmp = 0;
  130. tmp = (UInt_t)(pfELoss/fADCResolution);
  131. return ( tmp & ( (2<<(fADCBits-1)) - 1 ) );
  132. }
  133. else
  134. return 0;
  135. }
  136. // -------------------------------------------------------------------------
  137. ClassImp(MpdZdcDigi)