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