CbmRoot
Loading...
Searching...
No Matches
CbmRichMCbmSEDisplay.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
6
7#include "CbmRichHit.h"
8#include "CbmRichRing.h"
9#include "CbmTofTracklet.h"
10#include "TCanvas.h"
11#include "TClonesArray.h"
12#include "TEllipse.h"
13#include "TH1D.h"
14#include "TLine.h"
15#include "TMarker.h"
16#include "TPad.h"
17#include "TSystem.h"
18
19#include <TBox.h>
20
21#include <sstream>
22#include <string>
23
24
26 : fRichHits(nullptr)
27 , fRichRings(nullptr)
28 , fTofTracks(nullptr)
29 , fXOffsetHisto(0.)
30 , fTotRichMin(23.7)
31 , fTotRichMax(30.)
32 , fNofDrawnEvents(0)
33 , fMaxNofDrawnEvents(100)
34 , fOutputDir("result")
35 , fLEMin(0.0)
36 , fLEMax(200.0)
37 , fHM(nullptr)
38{
39}
40
42 : fRichHits(nullptr)
43 , fRichRings(nullptr)
44 , fTofTracks(nullptr)
45 , fXOffsetHisto(0.)
46 , fTotRichMin(23.7)
47 , fTotRichMax(30.)
48 , fNofDrawnEvents(0)
49 , fMaxNofDrawnEvents(100)
50 , fOutputDir("result")
51 , fLEMin(0.0)
52 , fLEMax(200.0)
53 , fHM(manager)
54{
55}
56
57
58void CbmRichMCbmSEDisplay::DrawEvent(CbmEvent* ev, std::vector<int>& ringIndx, bool full = true)
59{
60
61 // ---- General Size of PMTs [cm] -------------------------------------------------
62 double pmtWidth = 5.20;
63 double pmtHeight = 5.20;
64 double pmtGap = 0.10;
65 // --------------------------------------------------------------------------------
66
67
68 // ---- Positioning ---------------------------------------------------------------
69 double left = 0.0;
70 double top = 0.0;
71 if (full == true) {
72 left = -16.85 + fXOffsetHisto + 6.225;
73 top = 23.7;
74 }
75 // -------------------------------------------------------------------------------
76
77
78 // ---- Limiting Output ----------------------------------------------------------
80 // -------------------------------------------------------------------------------
81
82
83 // ---- Throw away too clean events ----------------------------------------------
84 if (ev->GetNofData(ECbmDataType::kRichHit) <= 4) return;
85 // -------------------------------------------------------------------------------
86
87
88 // ---- Init Canvas Layout for Event ---------------------------------------------
90 std::string dir = fOutputDir + "/png/" + fFileName + "/";
91 gSystem->mkdir(dir.c_str(), true); // create directory if it does not exist
92 //std::cout<<"makeDir: "<<dir.c_str() << " "<<gSystem->mkdir(dir.c_str(), true)<<std::endl;
93
94 stringstream ss;
95 ss << fFileName << "/CbmEvent" << fNofDrawnEvents;
96 TCanvas* c = nullptr;
97 if (full == true) {
98 c = fHM->CreateCanvas(ss.str().c_str(), ss.str().c_str(), 600, 1250);
99 }
100 else {
101 c = fHM->CreateCanvas(ss.str().c_str(), ss.str().c_str(), 800, 800);
102 }
103 c->SetGrid(true, true);
104 TPad* pad_event = new TPad("pad_event", "event", 0, 0.20, 1, 1);
105 TH2D* pad = nullptr;
106 if (full == true) {
107 pad = new TH2D(ss.str().c_str(), (ss.str() + ";X [cm];Y [cm]").c_str(), 1, -18. + fXOffsetHisto + 6.225,
108 5. + fXOffsetHisto + 6.225, 1, -26., 26.);
109 }
110 else {
111 pad = new TH2D(ss.str().c_str(), (ss.str() + ";X [cm];Y [cm]").c_str(), 1, -15. + fXOffsetHisto + 6.225,
112 10. + fXOffsetHisto + 6.225, 1, -5., 20);
113 }
114
115 Int_t BinSize = (Int_t)(fLEMax - fLEMin);
116 TPad* pad_time = new TPad("pad_time", "timeDist", 0, 0, 1, 0.20);
117 TH1D* timeDistRichHit = new TH1D((ss.str() + "timeDistRichHit").c_str(), ";LE [ns];Entries", BinSize, fLEMin, fLEMax);
118 TH1D* timeDistRichHitToT =
119 new TH1D((ss.str() + "timeDistRichHitToT").c_str(), ";LE [ns];Entries", BinSize, fLEMin, fLEMax);
120 TH1D* timeDistTofTrack =
121 new TH1D((ss.str() + "timeDistTofTrack").c_str(), ";LE [ns];Entries", BinSize, fLEMin, fLEMax);
122 pad_event->Draw();
123 pad_time->Draw();
124 pad_event->cd();
125 //pad_event->SetBottomMargin(0);
126 pad->SetStats(false);
127 pad->Draw();
128
129 if (full == true) {
130 for (unsigned int x = 0; x < 4; ++x) {
131 for (unsigned int y = 0; y < 9; ++y) {
132 double pmtLeft = left + (pmtWidth + pmtGap) * x;
133 double pmtTop = top - (pmtHeight + pmtGap) * y;
134 TBox* box = new TBox(pmtLeft, pmtTop, pmtLeft + pmtWidth, pmtTop - pmtHeight);
135 //box->SetFillColorAlpha(8,0.2);
136 box->Draw();
137
138 pmtLeft += 0.175;
139 pmtTop -= 0.175;
140 for (unsigned int pX = 0; pX < 8; ++pX) {
141 for (unsigned int pY = 0; pY < 8; ++pY) {
142 double xStart = 0.0;
143 double xEnd = 0.0;
144 double yStart = 0.0;
145 double yEnd = 0.0;
146 if (pX == 0) {
147 xStart = pmtLeft;
148 xEnd = pmtLeft + 0.625;
149 }
150 else if (pX < 7) {
151 xStart = pmtLeft + 0.625 + 0.6 * (pX - 1);
152 xEnd = pmtLeft + 0.625 + 0.6 * (pX);
153 }
154 else if (pX == 7) {
155 xStart = pmtLeft + 0.625 + 0.6 * 6;
156 xEnd = pmtLeft + 0.625 * 2 + 0.6 * 6;
157 }
158
159 if (pY == 0) {
160 yStart = pmtTop;
161 yEnd = pmtTop - 0.625;
162 }
163 else if (pY < 7) {
164 yStart = pmtTop - 0.625 - 0.6 * (pY - 1);
165 yEnd = pmtTop - 0.625 - 0.6 * (pY);
166 }
167 else if (pY == 7) {
168 yStart = pmtTop - 0.625 - 0.6 * 6;
169 yEnd = pmtTop - 0.625 * 2 - 0.6 * 6;
170 }
171
172 TBox* box1 = new TBox(xStart, yStart, xEnd, yEnd);
173 box1->SetLineWidth(1.);
174 //box1->SetFillColorAlpha(30.,0.1);
175 //box1->SetLineColorAlpha(30.,0.5);
176
177 box1->Draw("l");
178 }
179 }
180 }
181 }
182 }
183
184 if (full == true) {
185 //rough Drawing of RichDetectorAcceptance
186 /*
187 TLine *line0 = new TLine( left , top, right, top);
188 line0->Draw();
189 TLine *line1 = new TLine( right, top, right, bottom);
190 line1->Draw();
191 TLine *line2 = new TLine( right, bottom, left, bottom);
192 line2->Draw();
193 TLine *line3 = new TLine( left , bottom, left, top);
194 line3->Draw();
195 */
196 }
197 // -------------------------------------------------------------------------------
198
199
200 // find min and max x and y positions of the hits
201 // in order to shift drawing
202
203
204 double hitZ = 0;
205 uint nofDrawHits = 0;
206
207 // ---- Draw Rich Hits -----------------------------------------------------------
208 for (size_t j = 0; j < ev->GetNofData(ECbmDataType::kRichHit); j++) {
209 auto iRichHit = ev->GetIndex(ECbmDataType::kRichHit, j);
210 CbmRichHit* hit = static_cast<CbmRichHit*>(fRichHits->At(iRichHit));
211 if (nullptr == hit) continue;
212 TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), .25);
213 timeDistRichHit->Fill(hit->GetTime() - ev->GetStartTime());
214 if (doToT(hit)) { // Good ToT selection
215 hitDr->SetFillColor(kCyan);
216 timeDistRichHitToT->Fill(hit->GetTime() - ev->GetStartTime());
217 }
218 else {
219 hitDr->SetFillColor(kBlue);
220 }
221 hitZ += hit->GetZ();
222 nofDrawHits++;
223 hitDr->Draw();
224 }
225 // -------------------------------------------------------------------------------
226
227
228 // ---- Draw Rich Rings and Ring Hits --------------------------------------------
229 for (unsigned int rings = 0; rings < ringIndx.size(); rings++) {
230 CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(ringIndx[rings]));
231
232 //Draw Ring
233 TEllipse* circle = new TEllipse(ring->GetCenterX(), ring->GetCenterY(), ring->GetRadius());
234 circle->SetFillStyle(0);
235 circle->SetLineWidth(3);
236 circle->Draw();
237 TEllipse* center = new TEllipse(ring->GetCenterX(), ring->GetCenterY(), .1);
238 center->Draw();
239
240 // Draw Ring Hits
241 for (int i = 0; i < ring->GetNofHits(); i++) {
242 Int_t hitInd = ring->GetHit(i);
243 CbmRichHit* hit = (CbmRichHit*) fRichHits->At(hitInd);
244 if (nullptr == hit) continue;
245 TEllipse* hitDr = new TEllipse(hit->GetX(), hit->GetY(), .125);
246 if (doToT(hit)) { // Good ToT selection
247 hitDr->SetFillColor(kMagenta);
248 }
249 else {
250 hitDr->SetFillColor(kRed);
251 }
252 //hitZ += hit->GetZ();
253 //nofDrawHits++;
254 hitDr->Draw();
255 }
256 }
257 hitZ /= nofDrawHits;
258 // -------------------------------------------------------------------------------
259
260 // ---- Draw Tracks in RICH Plane ------------------------------------------------
261 auto nofTofTracks = ev->GetNofData(ECbmDataType::kTofTrack);
262 for (size_t j = 0; j < nofTofTracks; j++) {
263 auto iTofTrack = ev->GetIndex(ECbmDataType::kTofTrack, j);
264 CbmTofTracklet* track = static_cast<CbmTofTracklet*>(fTofTracks->At(iTofTrack));
265 if (nullptr == track) continue;
266 timeDistTofTrack->Fill(track->GetTime() - ev->GetStartTime());
267 TEllipse* hitDr = new TEllipse(track->GetFitX(hitZ), track->GetFitY(hitZ), .25);
268 hitDr->SetFillColor(kGreen);
269 hitDr->Draw();
270 }
271 // -------------------------------------------------------------------------------
272
273
274 // ---- Draw LE time distribution ------------------------------------------------
275 pad_time->cd();
276 pad_time->SetTitle("");
277 pad_time->SetTopMargin(0);
278 pad_time->SetBottomMargin(0.25);
279 timeDistRichHit->SetFillColor(kBlue);
280 timeDistRichHit->SetStats(false);
281 timeDistRichHit->GetXaxis()->SetLabelSize(0.06);
282 timeDistRichHit->GetXaxis()->SetTitleSize(0.08);
283 timeDistRichHit->GetYaxis()->SetLabelSize(0.06);
284 timeDistRichHit->GetYaxis()->SetTitleSize(0.08);
285 timeDistRichHit->GetYaxis()->SetTitleOffset(0.52);
286 timeDistRichHit->Draw("HIST");
287 timeDistRichHitToT->SetFillColor(kCyan);
288 timeDistRichHitToT->Draw("HIST SAME");
289 timeDistTofTrack->SetFillColor(kGreen);
290 timeDistTofTrack->Draw("HIST SAME");
291 // -------------------------------------------------------------------------------
292}
TClonesArray * rings
TClonesArray * fTofTracks
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:53
double GetStartTime() const
Definition CbmEvent.h:140
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.
double GetTime() const
Definition CbmHit.h:76
double GetZ() const
Definition CbmHit.h:71
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
void DrawEvent(CbmEvent *ev, std::vector< int > &ringIndx, bool full)
Draw histograms.
CbmRichMCbmSEDisplay()
Standard constructor.
uint32_t GetHit(int32_t i) const
Definition CbmRichRing.h:39
float GetRadius() const
Definition CbmRichRing.h:79
int32_t GetNofHits() const
Definition CbmRichRing.h:37
float GetCenterX() const
Definition CbmRichRing.h:77
float GetCenterY() const
Definition CbmRichRing.h:78
Provides information on attaching a TofHit to a TofTrack.
double GetFitY(double Z)
double GetTime() const
double GetFitX(double Z)