CbmRoot
Loading...
Searching...
No Matches
CbmRichEventDisplay.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2023 UGiessen, JINR-LIT
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Supriya Das, Semen Lebedev [committer], Martin Beyer, Florian Uhlig */
4
11#include "CbmRichEventDisplay.h"
12
13#include "CbmDigiManager.h"
14#include "CbmDrawHist.h"
15#include "CbmEvent.h"
16#include "CbmHistManager.h"
17#include "CbmRichGeoManager.h"
18#include "CbmRichHit.h"
19#include "CbmRichPoint.h"
20#include "CbmRichRing.h"
21
22#include <FairRootManager.h>
23#include <FairTrackParam.h>
24
25#include <TCanvas.h>
26#include <TClonesArray.h>
27#include <TEllipse.h>
28#include <TH2.h>
29#include <TMarker.h>
30
31#include <string>
32
34{
35 FairRootManager* ioman = FairRootManager::Instance();
36 if (!ioman) LOG(fatal) << "CbmRichEventDisplay::Init: RootManager not instantiated!";
37
40 if (!fDigiManager->IsPresent(ECbmModuleId::kRich)) LOG(fatal) << "CbmRichEventDisplay::Init: No RichDigi array!";
41
42 fCbmEvents = static_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
43 if (!fCbmEvents) LOG(fatal) << "CbmRichEventDisplay::Init: No CbmEvent array!";
44
45 fRichPoints = static_cast<TClonesArray*>(ioman->GetObject("RichPoint"));
46 if (!fRichPoints && fDrawPoints) LOG(fatal) << "CbmRichEventDisplay::Init: No RichPoint array!";
47
48 fRichHits = static_cast<TClonesArray*>(ioman->GetObject("RichHit"));
49 if (!fRichHits && fDrawHits) LOG(fatal) << "CbmRichEventDisplay::Init: No RichHit array!";
50
51 fRichRings = static_cast<TClonesArray*>(ioman->GetObject("RichRing"));
52 if (!fRichRings && fDrawRings) LOG(fatal) << "CbmRichEventDisplay::Init: No RichRing array!";
53
54 fRichProjections = static_cast<TClonesArray*>(ioman->GetObject("RichProjection"));
55 if (!fRichProjections && fDrawProjections) LOG(fatal) << "CbmRichEventDisplay::Init: No RichProjection array!";
56
57 fHM = new CbmHistManager();
58
59 return kSUCCESS;
60}
61
62void CbmRichEventDisplay::Exec(Option_t* /*opt*/)
63{
65 for (Int_t i = 0; i < fCbmEvents->GetEntriesFast(); i++) {
66 fEventNum++;
67 CbmEvent* event = static_cast<CbmEvent*>(fCbmEvents->At(i));
68 DrawOneEvent(event);
69 }
70}
71
73{
74 std::stringstream ss;
75 ss << "rich_event_display_event_" << fEventNum;
76 TCanvas* c = fHM->CreateCanvas(ss.str().c_str(), ss.str().c_str(), 800, 800);
77 c->Divide(1, 2);
78 c->cd(1);
79 TH2D* padU = new TH2D("padU", ";x [cm];y [cm]", 1, -120., 120., 1, 120., 210);
80 DrawH2(padU);
81 padU->GetYaxis()->SetTitleOffset(0.75);
82 gPad->SetLeftMargin(0.1);
83 gPad->SetRightMargin(0.05);
84 DrawOnePmtPlane("up", event);
85
86 c->cd(2);
87 TH2D* padD = new TH2D("padD", ";x [cm];y [cm]", 1, -120., 120., 1, -210., -120.);
88 DrawH2(padD);
89 padD->GetYaxis()->SetTitleOffset(0.75);
90 gPad->SetLeftMargin(0.1);
91 gPad->SetRightMargin(0.05);
92 DrawOnePmtPlane("down", event);
93}
94
95void CbmRichEventDisplay::DrawOnePmtPlane(const std::string& plane, CbmEvent* event)
96{
97 // Draw Track projections
98 if (fDrawProjections) {
99 int nofProjections = event->GetNofData(ECbmDataType::kRichTrackProjection);
100 for (int iP = 0; iP < nofProjections; iP++) {
101 FairTrackParam* pr =
102 (FairTrackParam*) fRichProjections->At(event->GetIndex(ECbmDataType::kRichTrackProjection, iP));
103 if (!pr) continue;
104 // FIXME: only draw successful projections
105 if ((plane == "up" && pr->GetY() >= 0.) || (plane == "down" && pr->GetY() < 0.)) {
106 TMarker* m = new TMarker(pr->GetX(), pr->GetY(), 3.);
107 m->SetMarkerSize(0.7);
108 m->SetMarkerColor(kGreen + 3);
109 m->Draw();
110 }
111 }
112 }
113
114 // Draw hits
115 if (fDrawHits) {
116 int nofHits = event->GetNofData(ECbmDataType::kRichHit);
117 for (int iH = 0; iH < nofHits; iH++) {
119 if (!hit) continue;
120 if ((plane == "up" && hit->GetY() >= 0.) || (plane == "down" && hit->GetY() < 0.)) {
121 TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), 0.6);
122 hitDr->SetFillColor(kRed);
123 hitDr->SetLineColor(kRed);
124 hitDr->Draw();
125 }
126 }
127 }
128
129 // Draw rings
130 if (fDrawRings) {
131 int nofRings = event->GetNofData(ECbmDataType::kRichRing);
132 for (int iR = 0; iR < nofRings; iR++) {
134 if (!ring) continue;
135 if ((plane == "up" && ring->GetCenterY() >= 0.) || (plane == "down" && ring->GetCenterY() < 0.)) {
136 DrawEllipse(ring);
137 }
138 }
139 }
140
141 // Draw RICH MC Points
142 // Slow for large ts
143 if (fDrawPoints) {
144 Double_t evStart = event->GetStartTime();
145 Double_t evStop = event->GetEndTime();
146 int nofPoints = fRichPoints->GetEntriesFast();
147 for (int iP = 0; iP < nofPoints; iP++) {
148 CbmRichPoint* point = (CbmRichPoint*) fRichPoints->At(iP);
149 if (!point) continue;
150 Double_t pointTime = point->GetTime();
151 if (pointTime > evStart && pointTime < evStop) continue;
152 if ((plane == "up" && point->GetY() >= 0.) || (plane == "down" && point->GetY() < 0.)) {
153 TVector3 posPoint(point->GetX(), point->GetY(), point->GetZ());
154 TVector3 detPoint;
155 CbmRichGeoManager::GetInstance().RotatePoint(&posPoint, &detPoint, false);
156 TEllipse* pointDr = new TEllipse(detPoint.X(), detPoint.Y(), 0.2);
157 pointDr->Draw();
158 }
159 }
160 }
161}
162
164{
165 TEllipse* circle = new TEllipse(ring->GetCenterX(), ring->GetCenterY(), ring->GetRadius());
166 circle->SetFillStyle(0);
167 circle->SetLineWidth(2);
168 circle->SetLineColor(kBlue);
169 circle->Draw();
170 TMarker* center = new TMarker(ring->GetCenterX(), ring->GetCenterY(), 2);
171 center->SetMarkerColor(kBlue);
172 center->SetMarkerSize(0.4);
173 center->Draw();
174}
175
177
ClassImp(CbmConverterManager)
@ kRich
Ring-Imaging Cherenkov Detector.
void SetDefaultDrawStyle()
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
Histogram manager.
Event display for the RICH detector.
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
static CbmDigiManager * Instance()
Static instance.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
uint32_t GetIndex(ECbmDataType type, uint32_t iData)
Definition CbmEvent.cxx:42
Histogram manager.
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.
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
Event display for the RICH detector.
void DrawOnePmtPlane(const std::string &plane, CbmEvent *event)
void DrawEllipse(CbmRichRing *ring)
void DrawOneEvent(CbmEvent *event)
CbmDigiManager * fDigiManager
void Exec(Option_t *opt)
TClonesArray * fRichProjections
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
static CbmRichGeoManager & GetInstance()
float GetRadius() const
Definition CbmRichRing.h:79
float GetCenterX() const
Definition CbmRichRing.h:77
float GetCenterY() const
Definition CbmRichRing.h:78