TpcLheSegments.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #ifndef LHE_SEGMENTS_H
  2. #define LHE_SEGMENTS_H
  3. // *************************************************************************
  4. // Author: Oleg Rogachevsky e-mail: rogach@sunhe.jinr.ru
  5. //
  6. // arrange all hits in theta-phi cells
  7. //
  8. // Created: 1-07-07
  9. // Modified:
  10. //
  11. // *************************************************************************
  12. #include "Riostream.h"
  13. #include "TClonesArray.h"
  14. #include "assert.h"
  15. #include "TpcLheCMPoint.h"
  16. using namespace std;
  17. class TpcLheSegments {
  18. protected:
  19. TObjArray *fSegments; // array of volume (theta, phi) elements
  20. TVector3 *fVertex;
  21. Int_t fNumThetaSegment; // number of theta segments
  22. Int_t fNumPhiSegment; // number of phi segments
  23. Int_t fBounds; // Number of cells (segments)
  24. // max. min. phi values
  25. Double_t fPhiMin;
  26. Double_t fPhiMax;
  27. // max. min. theta values
  28. Double_t fThetaMin;
  29. Double_t fThetaMax;
  30. public:
  31. TpcLheSegments(); //
  32. TpcLheSegments(Int_t nTheta, Int_t nPhi);
  33. virtual ~TpcLheSegments(); //
  34. void FillSegments(TClonesArray *hits); //
  35. void PrintSegmentContents(Int_t n);
  36. void PrintSegments();
  37. void Init();
  38. void Clear();
  39. // getters
  40. Int_t GetNumPhiSegments() { return fNumPhiSegment; } // returns # of phi
  41. Int_t GetNumThetaSegments() { return fNumThetaSegment; } // returns # of theta
  42. //Int_t GetRadiusSegm(const TpcLheCMPoint *hit); // returns # of station
  43. //Int_t GetRadiusSegm(Int_t segm); // number of station segment
  44. Int_t GetThetaSegm(const TpcLheCMPoint *hit); // returns # of theta
  45. Int_t GetThetaSegm(Int_t segm); // number of theta segment
  46. Int_t GetThetaSegm(Double_t s); // number of theta segment
  47. Int_t GetPhiSegm(const TpcLheCMPoint *hit); // returns # of phi
  48. Int_t GetPhiSegm(Int_t segm); // number of phi
  49. Int_t GetPhiSegm(Double_t al); // number of phi segment
  50. //Int_t GetStation(Int_t segm); // returns the station
  51. Double_t GetTheta(Int_t segm); // returns theta of a given theta segment
  52. Double_t GetPhi(Int_t segm); // returns phi of a given phi segment
  53. Double_t GetThetaMax() {return fThetaMax;} //
  54. Double_t GetPhiMax() {return fPhiMax;} //
  55. TObjArray *GetSegments() {return fSegments;} //
  56. Int_t GetSegm(Int_t theta_s, Int_t phi_s); // returns number of segment
  57. ClassDef(TpcLheSegments, 1) //
  58. };
  59. //_________________________________________________________________
  60. inline Int_t TpcLheSegments::GetThetaSegm(const TpcLheCMPoint *hit) {
  61. // Returns number of theta segment of a specific hit.
  62. Double_t theta = hit->GetTheta();
  63. Int_t theta_segm;
  64. if (theta < fThetaMin) {
  65. cout << " hit is smaller than fThetaMin\n";
  66. theta = fThetaMin;
  67. }
  68. if (theta > fThetaMax) {
  69. cout << " hit is larger than fThetaMax\n";
  70. theta = fThetaMax;
  71. }
  72. theta_segm = (Int_t)((theta - fThetaMin)/(fThetaMax - fThetaMin) *
  73. fNumThetaSegment );
  74. return theta_segm;
  75. }
  76. //_________________________________________________________________
  77. inline Int_t TpcLheSegments::GetThetaSegm(Double_t theta) {
  78. // Returns number of theta segment of a hit theta.
  79. if (theta > fThetaMax) return fNumThetaSegment - 1; //theta = fThetaMax;
  80. if (theta < fThetaMin) theta = fThetaMin;
  81. return (Int_t)((theta - fThetaMin)/(fThetaMax - fThetaMin) *
  82. fNumThetaSegment );
  83. }
  84. //_________________________________________________________________
  85. inline Double_t TpcLheSegments::GetTheta(Int_t segm) {
  86. // Returns the angle theta of a given segment.
  87. return segm * (fThetaMax - fThetaMin)/
  88. ((float) fNumThetaSegment) + fThetaMin;
  89. }
  90. //_________________________________________________________________
  91. inline Int_t TpcLheSegments::GetPhiSegm(const TpcLheCMPoint *hit) {
  92. // Returns number of phi segment of a hit.
  93. Double_t phi = hit->GetPhi();
  94. Int_t phi_segm = (Int_t)((phi - fPhiMin) * fNumPhiSegment /
  95. (fPhiMax - fPhiMin) );
  96. return phi_segm;
  97. }
  98. //_________________________________________________________________
  99. inline Int_t TpcLheSegments::GetPhiSegm(Double_t phi) {
  100. // Returns number of phi segment of a specific phi.
  101. if (phi > fPhiMax) phi = fPhiMax;
  102. if (phi < fPhiMin) phi = fPhiMin;
  103. return (Int_t)((phi - fPhiMin)/(fPhiMax - fPhiMin) *
  104. fNumPhiSegment );
  105. }
  106. //_________________________________________________________________
  107. inline Int_t TpcLheSegments::GetPhiSegm(Int_t segm) {
  108. // Returns number of phi segment of a specifiv segment.
  109. return (segm % (fNumThetaSegment * fNumPhiSegment)) %
  110. (fNumPhiSegment);
  111. }
  112. //_________________________________________________________________
  113. inline Double_t TpcLheSegments::GetPhi(Int_t segm) {
  114. // Returns the phi of the given segment.
  115. return segm * (fPhiMax - fPhiMin) /
  116. (fNumPhiSegment) + fPhiMin;
  117. }
  118. //_________________________________________________________________
  119. inline Int_t TpcLheSegments::
  120. GetSegm(Int_t theta_segm, Int_t phi_segm) {
  121. // Calculates the volume segment number from the segmented volumes
  122. // (segm = segm(theta,phi)).
  123. Int_t segm = theta_segm * (fNumPhiSegment) + phi_segm;
  124. if (segm >= fBounds) {
  125. cout << " Error in segment: "
  126. << " segm " << segm
  127. << " theta_segm " << theta_segm
  128. << " phi_segm " << phi_segm << endl;
  129. assert(kFALSE);
  130. return fBounds - 1;
  131. }
  132. else
  133. return segm;
  134. }
  135. #if 0
  136. //_________________________________________________________________
  137. inline Int_t TpcLheSegments::GetRadiusSegm(Int_t segm) {
  138. // Returns number of station segment of a specifiv segment.
  139. return (segm - GetPhiSegm(segm) - GetThetaSegm(segm)) /
  140. (fNumThetaSegment * fNumPhiSegment);
  141. }
  142. #endif
  143. //_________________________________________________________________
  144. inline Int_t TpcLheSegments::GetThetaSegm(Int_t segm) {
  145. // Returns number of theta segment of a specifiv segment.
  146. return (segm - GetPhiSegm(segm)) % (fNumThetaSegment * fNumPhiSegment) /
  147. (fNumPhiSegment);
  148. }
  149. #endif