CbmRoot
CbmRichDraw.h
Go to the documentation of this file.
1 
2 #ifndef RICH_CbmRichDraw
3 #define RICH_CbmRichDraw
4 
5 #include "CbmRichDetectorData.h" // for CbmRichPmtData, CbmRichPixelData
6 #include "CbmRichDigiMapManager.h" // for CbmRichDigiMapManager
7 #include "CbmRichGeoManager.h" // for CbmRichGeoManager
8 
9 #include <RtypesCore.h> // for ROOT data types
10 #include <TCanvas.h> // for TCanvas
11 #include <TGraph2D.h> // for TGraph2D
12 #include <TH2.h> // for TH2D
13 #include <TPad.h> // for gPad
14 #include <TVector3.h> // for TVector3
15 
16 #include <vector> // for vector
17 
18 class CbmRichDraw {
19 
20 public:
21  static void DrawPmtH2(TH2* h, TCanvas* c, Bool_t usePmtBins = false) {
22  if (c == nullptr) return;
23  c->Divide(1, 2);
24  c->cd(1);
25  TH2D* hUp = (TH2D*) h->Clone();
26  DrawH2(hUp);
27  if (usePmtBins) {
28  std::vector<Double_t> yPmtBins = CbmRichDraw::GetPmtHistYbins();
29  hUp->GetYaxis()->SetRange(yPmtBins.size() / 2 + 1, yPmtBins.size());
30  } else {
31  hUp->GetYaxis()->SetRangeUser(120, 210);
32  }
33  hUp->GetYaxis()->SetTitleOffset(0.75);
34  hUp->GetZaxis()->SetTitleOffset(0.87);
35  gPad->SetLeftMargin(0.1);
36  gPad->SetRightMargin(0.15);
37  c->cd(2);
38  TH2D* hDown = (TH2D*) h->Clone();
39  if (usePmtBins) {
40  std::vector<Double_t> yPmtBins = CbmRichDraw::GetPmtHistYbins();
41  hDown->GetYaxis()->SetRange(0, yPmtBins.size() / 2 - 1);
42  } else {
43  hDown->GetYaxis()->SetRangeUser(-210, -120);
44  }
45  DrawH2(hDown);
46  hDown->GetYaxis()->SetTitleOffset(0.75);
47  hDown->GetZaxis()->SetTitleOffset(0.87);
48  gPad->SetLeftMargin(0.1);
49  gPad->SetRightMargin(0.15);
50  }
51 
52  static void DrawPmtGraph2D(TGraph2D* gUp, TGraph2D* gDown, TCanvas* c) {
53  if (c == nullptr) return;
54  c->Divide(1, 2);
55  c->cd(1);
56  DrawGraph2D(gUp);
57  gUp->GetYaxis()->SetTitleOffset(0.75);
58  gUp->GetZaxis()->SetTitleOffset(0.87);
59  gPad->SetLeftMargin(0.1);
60  gPad->SetRightMargin(0.15);
61  c->cd(2);
62  DrawGraph2D(gDown);
63  gDown->GetYaxis()->SetTitleOffset(0.75);
64  gDown->GetZaxis()->SetTitleOffset(0.87);
65  gPad->SetLeftMargin(0.1);
66  gPad->SetRightMargin(0.15);
67  }
68 
69  static std::vector<Double_t> GetPmtHistXbins() {
70  return CbmRichDraw::GetPmtHistBins(true);
71  }
72 
73  static std::vector<Double_t> GetPmtHistYbins() {
74  return CbmRichDraw::GetPmtHistBins(false);
75  }
76 
77 private:
78  static std::vector<Double_t> GetPmtHistBins(Bool_t isX) {
79  std::vector<Double_t> initVec;
80  std::vector<Int_t> pmts = CbmRichDigiMapManager::GetInstance().GetPmtIds();
81  for (Int_t pmtId : pmts) {
82  CbmRichPmtData* pmtData =
84  TVector3 inPos(pmtData->fX, pmtData->fY, pmtData->fZ);
85  TVector3 outPos;
87  if (isX) {
88  initVec.push_back(outPos.X() - 0.5 * pmtData->fWidth);
89  initVec.push_back(outPos.X() + 0.5 * pmtData->fWidth);
90  } else {
91  initVec.push_back(outPos.Y() - 0.5 * pmtData->fHeight);
92  initVec.push_back(outPos.Y() + 0.5 * pmtData->fHeight);
93  }
94  }
95  sort(initVec.begin(), initVec.end());
96 
97  std::vector<Double_t> uniVec;
98  for (unsigned int i = 0; i < initVec.size(); i++) {
99  if (i == 0) uniVec.push_back(initVec[i]);
100  if (initVec[i] - uniVec[uniVec.size() - 1] > 0.000001)
101  uniVec.push_back(initVec[i]);
102  }
103 
104  // cout << "uniVec.size():" << uniVec.size() << endl;
105  // for (int i = 0; i < uniVec.size(); i++) {
106  // cout << std::setprecision(9);
107  // cout << fixed;
108  // cout << uniVec[i] << " " ;
109  // }
110  // cout << endl;
111 
112  return uniVec;
113  }
114 };
115 
116 #endif
CbmRichPmtData::fY
Double_t fY
Definition: CbmRichDetectorData.h:42
CbmRichDraw::GetPmtHistBins
static std::vector< Double_t > GetPmtHistBins(Bool_t isX)
Definition: CbmRichDraw.h:78
CbmRichDigiMapManager::GetPmtIds
std::vector< Int_t > GetPmtIds()
Definition: CbmRichDigiMapManager.cxx:285
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichDraw::DrawPmtGraph2D
static void DrawPmtGraph2D(TGraph2D *gUp, TGraph2D *gDown, TCanvas *c)
Definition: CbmRichDraw.h:52
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichDigiMapManager::GetPmtDataById
CbmRichPmtData * GetPmtDataById(Int_t id)
Definition: CbmRichDigiMapManager.cxx:288
CbmRichDigiMapManager.h
DrawGraph2D
void DrawGraph2D(TGraph2D *graph, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Definition: CbmDrawHist.cxx:224
CbmRichPmtData::fZ
Double_t fZ
Definition: CbmRichDetectorData.h:43
CbmRichPmtData
Definition: CbmRichDetectorData.h:26
CbmRichGeoManager.h
CbmRichDraw::GetPmtHistYbins
static std::vector< Double_t > GetPmtHistYbins()
Definition: CbmRichDraw.h:73
CbmRichDetectorData.h
CbmRichDraw::DrawPmtH2
static void DrawPmtH2(TH2 *h, TCanvas *c, Bool_t usePmtBins=false)
Definition: CbmRichDraw.h:21
h
Data class with information on a STS local track.
CbmRichGeoManager::RotatePoint
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
Definition: CbmRichGeoManager.cxx:407
CbmRichPmtData::fX
Double_t fX
Definition: CbmRichDetectorData.h:41
CbmRichPmtData::fWidth
Double_t fWidth
Definition: CbmRichDetectorData.h:44
CbmRichDraw
Definition: CbmRichDraw.h:18
DrawH2
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Definition: CbmDrawHist.cxx:84
CbmRichDigiMapManager::GetInstance
static CbmRichDigiMapManager & GetInstance()
Definition: CbmRichDigiMapManager.h:29
CbmRichDraw::GetPmtHistXbins
static std::vector< Double_t > GetPmtHistXbins()
Definition: CbmRichDraw.h:69
CbmRichPmtData::fHeight
Double_t fHeight
Definition: CbmRichDetectorData.h:45