EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichEventDisplay.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichEventDisplay.cxx
1 
8 #include "CbmRichEventDisplay.h"
9 
10 #include "CbmRichHit.h"
11 #include "CbmRichRing.h"
12 #include "CbmTrackMatch.h"
13 #include "CbmRichPoint.h"
14 #include "CbmDrawHist.h"
15 #include "FairTrackParam.h"
16 
17 #include "FairMCPoint.h"
18 #include "CbmMCTrack.h"
19 #include "FairRootManager.h"
20 
21 #include "CbmDrawHist.h"
22 
23 #include "TClonesArray.h"
24 #include "TEllipse.h"
25 #include "TCanvas.h"
26 #include "TH2D.h"
27 #include "TMarker.h"
28 
29 #include <iostream>
30 #include <map>
31 #include <sstream>
32 
33 using namespace std;
34 
36  FairTask("CbmRichEventDisplay"),
37  fRichRings(NULL),
38  fRichHits(NULL),
39  fRichPoints(NULL),
40  fRichMatches(NULL),
41  fMcTracks(NULL),
42  fRichProjections(NULL),
43  fEventNum(0),
44  fDrawRings(true),
45  fDrawHits(true),
46  fDrawPoints(true),
47  fDrawProjections(true)
48 {
50 }
51 
53 {
54 }
55 
56 
58 {
60  if (NULL == ioman) {Fatal("CbmRichEventDisplay::Init", "RootManager not instantiated!");}
61 
62  fRichHits = (TClonesArray*) ioman->GetObject("RichHit");
63  if (NULL == fRichHits) {Fatal("CbmRichEventDisplay::Init", "No RichHit array!");}
64 
65  fRichRings = (TClonesArray*) ioman->GetObject("RichRing");
66  if (NULL == fRichRings) { Fatal("CbmRichEventDisplay::Init", "No RichRing array!");}
67 
68  fRichPoints = (TClonesArray*) ioman->GetObject("RichPoint");
69  if (NULL == fRichPoints) {Fatal("CbmRichEventDisplay::Init", "No RichPoint array!");}
70 
71  fRichMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
72  if (NULL == fRichMatches) {Fatal("CbmRichEventDisplay::Init", "No RichRingMatch array!");}
73 
74  fRichProjections = (TClonesArray*) ioman->GetObject("RichProjection");
75  if (NULL == fRichProjections) {Fatal("CbmRichEventDisplay::Init", "No RichProjection array!");}
76 
77  fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
78  if (NULL == fMcTracks ) {Fatal("CbmRichEventDisplay::Init", "No MCTrack array!");}
79 
80  return kSUCCESS;
81 }
82 
84  Option_t* opt)
85 {
86  fEventNum++;
88  DrawOneEvent();
89 }
90 
92 {
93  stringstream ss;
94  ss << "rich_event_display_event_"<< fEventNum;
95  TCanvas *c = new TCanvas(ss.str().c_str(), ss.str().c_str(), 800, 800);
96  c->Divide(1, 2);
97  c->cd(1);
98  TH2D* padU = new TH2D("padU", ";x [cm];y [cm]", 1, -110., 110., 1, 90., 180);
99  DrawH2(padU);
100  padU->GetYaxis()->SetTitleOffset(0.75);
101  gPad->SetLeftMargin(0.1);
102  gPad->SetRightMargin(0.05);
103  DrawOnePmtPlane("up");
104 
105  c->cd(2);
106  TH2D* padD = new TH2D("padD", ";x [cm];y [cm]", 1, -110., 110., 1, -180., -90.);
107  DrawH2(padD);
108  padD->GetYaxis()->SetTitleOffset(0.75);
109  gPad->SetLeftMargin(0.1);
110  gPad->SetRightMargin(0.05);
111  DrawOnePmtPlane("down");
112 }
113 
115  const string& plane)
116 {
117  //Draw Track projections
118  if (fDrawProjections) {
119  int nofProjections = fRichProjections->GetEntriesFast();
120  for (int iP = 0; iP < nofProjections; iP++){
122  if (NULL == pr) continue;
123  if ( (plane == "up" && pr->GetY() >= 0.) ||
124  (plane == "down" && pr->GetY() < 0.) ){
125  TMarker* m = new TMarker(pr->GetX(), pr->GetY(), 3.);
126  m->SetMarkerSize(0.7);
127  m->SetMarkerColor(kGreen+3);
128  m->Draw();
129  }
130  }
131  }
132 
133  // Draw hits
134  if (fDrawHits){
135  int nofHits = fRichHits->GetEntriesFast();
136  for (int iH = 0; iH < nofHits; iH++){
137  CbmRichHit* hit = (CbmRichHit*) fRichHits->At(iH);
138  if (NULL == hit) continue;
139  if ( (plane == "up" && hit->GetY() >= 0.) ||
140  (plane == "down" && hit->GetY() < 0.) ){
141 
142  TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), 0.6);
143  hitDr->SetFillColor(kRed);
144  hitDr->SetLineColor(kRed);
145  hitDr->Draw();
146  }
147  }
148  }
149 
150  // Draw rings
151  if (fDrawRings){
152  int nofRings = fRichRings->GetEntriesFast();
153  for (int iR = 0; iR < nofRings; iR++){
154  CbmRichRing* ring = (CbmRichRing*) fRichRings->At(iR);
155  if (NULL == ring) continue;
156  if ( (plane == "up" && ring->GetCenterY() >= 0.) ||
157  (plane == "down" && ring->GetCenterY() < 0.) ){
158  DrawCircle(ring);
159  }
160  }
161  }
162 
163  // Draw RICH MC Points
164  if (fDrawPoints) {
165  int nofPoints = fRichPoints->GetEntriesFast();
166  for (int iP = 0; iP < nofPoints; iP++){
168  if (NULL == point) continue;
169  if ( (plane == "up" && point->GetY() >= 0.) ||
170  (plane == "down" && point->GetY() < 0.) ){
171  TEllipse* pointDr = new TEllipse(point->GetX(), point->GetY(), 0.4);
172  pointDr->Draw();
173  }
174  }
175  }
176 
177 
178 }
179 
181  CbmRichRing* ring)
182 {
183  TEllipse* circle = new TEllipse(ring->GetCenterX(), ring->GetCenterY(), ring->GetRadius());
184  circle->SetFillStyle(0);
185  circle->SetLineWidth(2);
186  circle->SetLineColor(kBlue);
187  circle->Draw();
188  TMarker* center = new TMarker(ring->GetCenterX(), ring->GetCenterY(), 2);
189  center->SetMarkerColor(kBlue);
190  center->SetMarkerSize(0.4);
191  center->Draw();
192 }
193 
195 {
196 
197 }
198