TpcLheSegments.cxx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // TpcLheSegments class - divide $\phi$- $\theta$-station in cells //
  4. // //
  5. ///////////////////////////////////////////////////////////////////////////////////
  6. #include "TpcLheSegments.h"
  7. #include "TpcLheHit.h"
  8. #include "TpcLheCMTrack.h"
  9. #include "TpcLheCMPoint.h"
  10. #include "TObjArray.h"
  11. #include <iomanip>
  12. ClassImp(TpcLheSegments)
  13. //#define TRACKSEG
  14. //#define SEGMENTS
  15. //________________________________________________________________
  16. TpcLheSegments::TpcLheSegments() {
  17. //---
  18. fVertex = NULL;
  19. // fNumOfStation = 1; // The number of stations
  20. fNumThetaSegment = 30;
  21. fNumPhiSegment = 20;
  22. fBounds = fNumThetaSegment * fNumPhiSegment;
  23. fPhiMax = 2.* TMath::Pi();
  24. fPhiMin = 0.;
  25. fThetaMax = TMath::Pi();
  26. fThetaMin = -TMath::Pi();
  27. }
  28. //________________________________________________________________
  29. TpcLheSegments::TpcLheSegments( Int_t nTheta, Int_t nPhi) {
  30. //
  31. fVertex = NULL;
  32. fNumThetaSegment = nTheta; //
  33. fNumPhiSegment = nPhi; //
  34. fBounds = fNumThetaSegment * fNumPhiSegment;
  35. }
  36. //_________________________________________________________________
  37. TpcLheSegments::~TpcLheSegments() {
  38. //
  39. delete fVertex;
  40. if(fSegments) fSegments->Delete();
  41. delete fSegments;
  42. }
  43. //________________________________________________________________
  44. void TpcLheSegments::Init() {
  45. //---
  46. fSegments = new TObjArray(fBounds); //
  47. for (Int_t iv = 0; iv < fBounds; iv++) {
  48. fSegments->AddAt(new TObjArray(0), iv);
  49. }
  50. }
  51. //________________________________________________________________
  52. void TpcLheSegments::Clear() {
  53. //---
  54. TIter next(fSegments);
  55. TObjArray *cell;
  56. while((cell = (TObjArray*) next())) {
  57. cell->Clear();
  58. }
  59. }
  60. //________________________________________________________________
  61. void TpcLheSegments::FillSegments(TClonesArray *fCMHits) {
  62. //---
  63. Clear();
  64. #ifdef TRACKSEG
  65. Int_t cur_track = 0;
  66. cout << "\n track " << " station " <<
  67. " theta " << " theta segm " <<
  68. " phi " << " phi_seg " <<
  69. " seg " << "\n";
  70. #endif
  71. for (Int_t i = 0; i < fCMHits->GetEntriesFast(); i++) {
  72. TpcLheCMPoint* h = (TpcLheCMPoint *)fCMHits->At(i);
  73. h->SetUsage(kFALSE);
  74. // h->Print();
  75. Int_t iseg =
  76. GetSegm(GetThetaSegm(h), GetPhiSegm(h));
  77. ((TObjArray *)fSegments->At(iseg))->AddLast(h);
  78. #ifdef TRACKSEG
  79. if (cur_track != h->GetTrackID()) {
  80. cur_track = h->GetTrackID();
  81. cout << endl;
  82. }
  83. cout.width(5);
  84. cout << h->GetTrackID() << " " << GetRadiusSegm(h) << " ";
  85. cout << setw(10) << setprecision(4) << h->GetTheta() << " ";
  86. cout.width(4); cout << GetThetaSegm(h) << " ";
  87. cout << setw(10) << setprecision(4) << h->GetPhi() << " ";
  88. cout.width(4); cout << GetPhiSegm(h);
  89. cout.width(10); cout << iseg << "\n";
  90. #endif
  91. }
  92. #ifdef SEGMENTS
  93. PrintSegments();
  94. #endif
  95. }
  96. //________________________________________________________________
  97. void TpcLheSegments::PrintSegments() {
  98. cout << "TpcLheSegments::PrintSegments()\n";
  99. // This function loops over all hits in segment
  100. TObjArray *segment;
  101. TpcLheCMPoint *hit;
  102. Int_t st_num = 0;
  103. // loop over theta segments
  104. for (Int_t theta_segm_counter = 0;
  105. theta_segm_counter < fNumThetaSegment;
  106. theta_segm_counter++) {
  107. // go over theta in two directions, one segment in each direction alternately
  108. Int_t theta_segm;
  109. theta_segm = theta_segm_counter;
  110. // loop over phi segments
  111. for(Int_t phi_segm = 0; phi_segm < fNumPhiSegment; phi_segm++) {
  112. // loop over entries in one segment
  113. segment = (TObjArray *)fSegments->At(GetSegm(theta_segm, phi_segm));
  114. Int_t entries = segment->GetEntriesFast();
  115. if (entries) {
  116. cout << "\n segment " <<
  117. GetSegm(theta_segm, phi_segm) << ": " <<
  118. " entries " << entries << endl;
  119. for (Int_t hit_num = 0; hit_num < entries; hit_num++) {
  120. hit = (TpcLheCMPoint *)segment->At(hit_num);
  121. cout << "\n hit #" << hit->GetHitNumber();
  122. cout << " trackID " << hit->GetTrackID();
  123. // cout << " station " << hit->GetStation();
  124. cout << " theta = " << theta_segm;
  125. cout << " phi = " << phi_segm;
  126. }
  127. } // if (entries)
  128. }
  129. }
  130. // } // station
  131. }
  132. //________________________________________________________________
  133. void TpcLheSegments::PrintSegmentContents(Int_t n_seg) {
  134. //---
  135. TObjArray *segment = (TObjArray *)fSegments->At(n_seg);
  136. Int_t entries = segment->GetEntriesFast();
  137. // cout << "\n segment " <<
  138. // GetSegm(theta_segm, phi_segm) << ": ";
  139. if (entries) {
  140. for (Int_t hit_num = 0; hit_num < entries; hit_num++) {
  141. TpcLheCMPoint* hit = (TpcLheCMPoint *)segment->At(hit_num);
  142. cout << "\n hit ";
  143. cout << " geant # " << hit->GetTrackID();
  144. // cout << " station " << hit->GetStation();
  145. // cout << " theta = " << theta_segm;
  146. // cout << " phi = " << phi_segm;
  147. cout << " is used = " << Int_t (hit->GetUsage());
  148. }
  149. } // if (entries)
  150. else {
  151. cout << "\n segment is empty\n ";
  152. }
  153. }