CbmRoot
CbmRichEventDisplay.cxx
Go to the documentation of this file.
1 
7 #include "CbmRichEventDisplay.h"
8 
9 #include "CbmDrawHist.h" // for DrawH2, SetDefaultDrawStyle
10 #include "CbmHistManager.h" // for CbmHistManager
11 #include "CbmRichHit.h" // for CbmRichHit
12 #include "CbmRichPoint.h" // for CbmRichPoint
13 #include "CbmRichRing.h" // for CbmRichRing
14 
15 #include <FairRootManager.h> // for FairRootManager
16 #include <FairTask.h> // for FairTask, InitStatus, kSUCCESS
17 #include <FairTrackParam.h> // for FairTrackParam
18 
19 #include <TAxis.h> // for TAxis
20 #include <TCanvas.h> // for TCanvas
21 #include <TClonesArray.h> // for TClonesArray
22 #include <TEllipse.h> // for TEllipse
23 #include <TGenericClassInfo.h> // for TGenericClassInfo
24 #include <TH2.h> // for TH2D
25 #include <TMarker.h> // for TMarker
26 #include <TVirtualPad.h> // for TVirtualPad, gPad
27 
28 #include <iostream> // for string, stringstream, operator<<, bas...
29 #include <string> // for operator==, basic_string, char_traits
30 
31 using namespace std;
32 
34  : FairTask("CbmRichEventDisplay")
35  , fRichRings(nullptr)
36  , fRichHits(nullptr)
37  , fRichPoints(nullptr)
38  , fRichMatches(nullptr)
39  , fRichProjections(nullptr)
40  , fMcTracks(nullptr)
41  , fOutputDir("")
42  , fHM(nullptr)
43  , fEventNum(0)
44  , fDrawRings(true)
45  , fDrawHits(true)
46  , fDrawPoints(true)
47  , fDrawProjections(true) {
49 }
50 
52 
53 
55  FairRootManager* ioman = FairRootManager::Instance();
56  if (nullptr == ioman) {
57  Fatal("CbmRichEventDisplay::Init", "RootManager not instantiated!");
58  }
59 
60  fRichHits = (TClonesArray*) ioman->GetObject("RichHit");
61  if (nullptr == fRichHits) {
62  Fatal("CbmRichEventDisplay::Init", "No RichHit array!");
63  }
64 
65  fRichRings = (TClonesArray*) ioman->GetObject("RichRing");
66  if (nullptr == fRichRings) {
67  Fatal("CbmRichEventDisplay::Init", "No RichRing array!");
68  }
69 
70  fRichPoints = (TClonesArray*) ioman->GetObject("RichPoint");
71  if (nullptr == fRichPoints) {
72  Fatal("CbmRichEventDisplay::Init", "No RichPoint array!");
73  }
74 
75  fRichMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
76  if (nullptr == fRichMatches) {
77  Fatal("CbmRichEventDisplay::Init", "No RichRingMatch array!");
78  }
79 
80  fRichProjections = (TClonesArray*) ioman->GetObject("RichProjection");
81  if (nullptr == fRichProjections) {
82  Fatal("CbmRichEventDisplay::Init", "No RichProjection array!");
83  }
84 
85  fMcTracks = (TClonesArray*) ioman->GetObject("MCTrack");
86  if (nullptr == fMcTracks) {
87  Fatal("CbmRichEventDisplay::Init", "No MCTrack array!");
88  }
89 
90  fHM = new CbmHistManager();
91 
92  return kSUCCESS;
93 }
94 
95 void CbmRichEventDisplay::Exec(Option_t* /*opt*/) {
96  fEventNum++;
98  DrawOneEvent();
99 }
100 
102  stringstream ss;
103  ss << "rich_event_display_event_" << fEventNum;
104  TCanvas* c = fHM->CreateCanvas(ss.str().c_str(), ss.str().c_str(), 800, 800);
105  c->Divide(1, 2);
106  c->cd(1);
107  TH2D* padU = new TH2D("padU", ";x [cm];y [cm]", 1, -120., 120., 1, 120., 210);
108  DrawH2(padU);
109  padU->GetYaxis()->SetTitleOffset(0.75);
110  gPad->SetLeftMargin(0.1);
111  gPad->SetRightMargin(0.05);
112  DrawOnePmtPlane("up");
113 
114  c->cd(2);
115  TH2D* padD =
116  new TH2D("padD", ";x [cm];y [cm]", 1, -120., 120., 1, -210., -120.);
117  DrawH2(padD);
118  padD->GetYaxis()->SetTitleOffset(0.75);
119  gPad->SetLeftMargin(0.1);
120  gPad->SetRightMargin(0.05);
121  DrawOnePmtPlane("down");
122 }
123 
124 void CbmRichEventDisplay::DrawOnePmtPlane(const string& plane) {
125  //Draw Track projections
126  if (fDrawProjections) {
127  int nofProjections = fRichProjections->GetEntriesFast();
128  for (int iP = 0; iP < nofProjections; iP++) {
129  FairTrackParam* pr = (FairTrackParam*) fRichProjections->At(iP);
130  if (nullptr == pr) continue;
131  if ((plane == "up" && pr->GetY() >= 0.)
132  || (plane == "down" && pr->GetY() < 0.)) {
133  TMarker* m = new TMarker(pr->GetX(), pr->GetY(), 3.);
134  m->SetMarkerSize(0.7);
135  m->SetMarkerColor(kGreen + 3);
136  m->Draw();
137  }
138  }
139  }
140 
141  // Draw hits
142  if (fDrawHits) {
143  int nofHits = fRichHits->GetEntriesFast();
144  for (int iH = 0; iH < nofHits; iH++) {
145  CbmRichHit* hit = (CbmRichHit*) fRichHits->At(iH);
146  if (nullptr == hit) continue;
147  if ((plane == "up" && hit->GetY() >= 0.)
148  || (plane == "down" && hit->GetY() < 0.)) {
149 
150  TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), 0.6);
151  hitDr->SetFillColor(kRed);
152  hitDr->SetLineColor(kRed);
153  hitDr->Draw();
154  }
155  }
156  }
157 
158  // Draw rings
159  if (fDrawRings) {
160  int nofRings = fRichRings->GetEntriesFast();
161  for (int iR = 0; iR < nofRings; iR++) {
162  CbmRichRing* ring = (CbmRichRing*) fRichRings->At(iR);
163  if (nullptr == ring) continue;
164  if ((plane == "up" && ring->GetCenterY() >= 0.)
165  || (plane == "down" && ring->GetCenterY() < 0.)) {
166  DrawCircle(ring);
167  }
168  }
169  }
170 
171  // Draw RICH MC Points
172  if (fDrawPoints) {
173  int nofPoints = fRichPoints->GetEntriesFast();
174  for (int iP = 0; iP < nofPoints; iP++) {
175  CbmRichPoint* point = (CbmRichPoint*) fRichPoints->At(iP);
176  if (nullptr == point) continue;
177  if ((plane == "up" && point->GetY() >= 0.)
178  || (plane == "down" && point->GetY() < 0.)) {
179  TEllipse* pointDr = new TEllipse(point->GetX(), point->GetY(), 0.4);
180  pointDr->Draw();
181  }
182  }
183  }
184 }
185 
187  TEllipse* circle =
188  new TEllipse(ring->GetCenterX(), ring->GetCenterY(), ring->GetRadius());
189  circle->SetFillStyle(0);
190  circle->SetLineWidth(2);
191  circle->SetLineColor(kBlue);
192  circle->Draw();
193  TMarker* center = new TMarker(ring->GetCenterX(), ring->GetCenterY(), 2);
194  center->SetMarkerColor(kBlue);
195  center->SetMarkerSize(0.4);
196  center->Draw();
197 }
198 
200 
CbmRichEventDisplay::DrawOnePmtPlane
void DrawOnePmtPlane(const std::string &plane)
Definition: CbmRichEventDisplay.cxx:124
CbmRichPoint.h
CbmRichEventDisplay::DrawCircle
void DrawCircle(CbmRichRing *ring)
Definition: CbmRichEventDisplay.cxx:186
CbmRichEventDisplay::fRichProjections
TClonesArray * fRichProjections
Definition: CbmRichEventDisplay.h:78
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmRichEventDisplay::fRichHits
TClonesArray * fRichHits
Definition: CbmRichEventDisplay.h:75
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmRichEventDisplay::fRichRings
TClonesArray * fRichRings
Definition: CbmRichEventDisplay.h:74
CbmRichEventDisplay::fOutputDir
std::string fOutputDir
Definition: CbmRichEventDisplay.h:82
CbmRichEventDisplay.h
Event display for the RICH detector.
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichRing.h
CbmDrawHist.h
Helper functions for drawing 1D and 2D histograms and graphs.
CbmRichEventDisplay::CbmRichEventDisplay
CbmRichEventDisplay()
Default constructor.
Definition: CbmRichEventDisplay.cxx:33
CbmHistManager.h
Histogram manager.
CbmRichEventDisplay::fDrawHits
bool fDrawHits
Definition: CbmRichEventDisplay.h:88
CbmRichEventDisplay::DrawOneEvent
void DrawOneEvent()
Definition: CbmRichEventDisplay.cxx:101
CbmHistManager
Histogram manager.
Definition: CbmHistManager.h:41
CbmRichEventDisplay::fDrawRings
bool fDrawRings
Definition: CbmRichEventDisplay.h:87
CbmRichEventDisplay::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmRichEventDisplay.cxx:199
CbmRichEventDisplay::fHM
CbmHistManager * fHM
Definition: CbmRichEventDisplay.h:83
CbmRichEventDisplay::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmRichEventDisplay.cxx:54
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmRichEventDisplay::fRichPoints
TClonesArray * fRichPoints
Definition: CbmRichEventDisplay.h:76
CbmHistManager::CreateCanvas
TCanvas * CreateCanvas(const std::string &name, const std::string &title, Int_t width, Int_t height)
Create and draw TCanvas and store pointer to it.
Definition: core/base/CbmHistManager.cxx:267
CbmHistManager::SaveCanvasToImage
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
Definition: core/base/CbmHistManager.cxx:276
CbmRichEventDisplay::Exec
virtual void Exec(Option_t *opt)
Inherited from FairTask.
Definition: CbmRichEventDisplay.cxx:95
m
__m128 m
Definition: L1/vectors/P4_F32vec4.h:26
CbmRichRing::GetRadius
Float_t GetRadius() const
Definition: CbmRichRing.h:82
CbmRichEventDisplay::fDrawProjections
bool fDrawProjections
Definition: CbmRichEventDisplay.h:90
CbmRichRing::GetCenterY
Float_t GetCenterY() const
Definition: CbmRichRing.h:81
CbmRichEventDisplay::fEventNum
int fEventNum
Definition: CbmRichEventDisplay.h:85
CbmRichEventDisplay::fMcTracks
TClonesArray * fMcTracks
Definition: CbmRichEventDisplay.h:80
DrawH2
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Definition: CbmDrawHist.cxx:84
SetDefaultDrawStyle
void SetDefaultDrawStyle()
Definition: CbmDrawHist.cxx:33
CbmRichEventDisplay::fDrawPoints
bool fDrawPoints
Definition: CbmRichEventDisplay.h:89
CbmRichHit.h
CbmRichPoint
Definition: CbmRichPoint.h:24
CbmRichEventDisplay
Event display for the RICH detector.
Definition: CbmRichEventDisplay.h:35
CbmRichEventDisplay::fRichMatches
TClonesArray * fRichMatches
Definition: CbmRichEventDisplay.h:77
CbmRichRing::GetCenterX
Float_t GetCenterX() const
Definition: CbmRichRing.h:80
CbmRichHit
Definition: CbmRichHit.h:19
CbmRichEventDisplay::~CbmRichEventDisplay
virtual ~CbmRichEventDisplay()
Destructor.
Definition: CbmRichEventDisplay.cxx:51