EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichGeoTest.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichGeoTest.cxx
1 
8 #include "CbmRichGeoTest.h"
10 #include "FairRootManager.h"
11 #include "CbmRichHit.h"
12 #include "CbmRichRing.h"
13 #include "CbmTrackMatch.h"
14 #include "CbmMCTrack.h"
15 #include "CbmRichPoint.h"
16 #include "CbmRichRingFitterCOP.h"
18 #include "CbmGeoRichPar.h"
19 #include "FairGeoTransform.h"
20 #include "FairGeoNode.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
23 #include "CbmRichHitProducer.h"
24 #include "CbmDrawHist.h"
25 #include "std/utils/CbmLitUtils.h"
26 #include "CbmRichConverter.h"
27 #include "CbmReport.h"
28 #include "CbmStudyReport.h"
29 
30 #include "TH1D.h"
31 #include "TH2D.h"
32 #include "TH3D.h"
33 #include "TCanvas.h"
34 #include "TEllipse.h"
35 #include "TClonesArray.h"
36 #include "TMath.h"
37 #include "TPad.h"
38 #include "TLatex.h"
39 #include "TSystem.h"
40 #include "TStyle.h"
41 #include "TF1.h"
42 #include "TLegend.h"
43 
44 #include <iostream>
45 #include <vector>
46 #include <map>
47 #include <sstream>
48 #include <iomanip>
49 #include <string>
50 
51 #include <boost/assign/list_of.hpp>
52 #include <boost/property_tree/ptree.hpp>
53 #include <boost/property_tree/json_parser.hpp>
54 
55 using namespace std;
56 using boost::assign::list_of;
57 using boost::property_tree::ptree;
58 
60  FairTask("RichGeoTestQa"),
61 
62  fRichDetectorType("standard"),
63 
64  fOutputDir(""),
65 
66  fRichHits(NULL),
67  fRichRings(NULL),
68  fRichPoints(NULL),
69  fMCTracks(NULL),
70  fRichRingMatches(NULL),
71 
72  fDetZOrig(0.),
73  fTheta(0.),
74  fPhi(0.),
75  fSensNodes(NULL),
76  fPassNodes(NULL),
77  fPar(NULL),
78 
79  fCopFit(NULL),
80  fTauFit(NULL),
81  fCanvas(),
82  fEventNum(0),
83  fMinNofHits(0),
84 
85  fhHitsXY(NULL),
86  fhPointsXY(NULL),
87  fhNofPhotonsPerHit(NULL),
88 
89  fhNofHits(),
90  fhAaxisVsMom(),
91  fhBaxisVsMom(),
92  fhBoverA(),
93  fhXcYcEllipse(),
94  fhChi2EllipseVsMom(),
95  fhXcYcCircle(),
96  fhRadiusVsMom(),
97  fhChi2CircleVsMom(),
98  fhDRVsMom(),
99 
100  fhRadiusVsNofHits(NULL),
101  fhAaxisVsNofHits(NULL),
102  fhBaxisVsNofHits(NULL),
103  fhDiffAaxis(NULL),
104  fhDiffBaxis(NULL),
105  fhDiffXcEllipse(NULL),
106  fhDiffYcEllipse(NULL),
107  fhDiffXcCircle(NULL),
108  fhDiffYcCircle(NULL),
109  fhDiffRadius(NULL),
110 
111  fhDiffXhit(NULL),
112  fhDiffYhit(NULL),
113 
114  fMinAaxis(0.),
115  fMaxAaxis(0.),
116  fMinBaxis(0.),
117  fMaxBaxis(0.),
118  fMinRadius(0.),
119  fMaxRadius(0.),
120 
121  fhNofHitsAll(NULL),
122  fhNofHitsCircleFit(NULL),
123  fhNofHitsEllipseFit(NULL),
124  fhNofHitsCircleFitEff(NULL),
125  fhNofHitsEllipseFitEff(NULL),
126 
127  fh_mc_mom_el(NULL),
128  fh_mc_pty_el(NULL),
129  fh_acc_mom_el(NULL),
130  fh_acc_pty_el(NULL),
131 
132  fh_mc_mom_pi(NULL),
133  fh_mc_pty_pi(NULL),
134  fh_acc_mom_pi(NULL),
135  fh_acc_pty_pi(NULL),
136 
137  fhNofHitsXYZ(NULL),
138  fhNofPointsXYZ(NULL),
139  fhBoverAXYZ(NULL),
140  fhBaxisXYZ(NULL),
141  fhAaxisXYZ(NULL),
142  fhRadiusXYZ(NULL),
143  fhdRXYZ(NULL),
144 
145  fHists(),
146 
147  fNofDrawnRings(0)
148 
149 {
150  fEventNum = 0;
151  fNofDrawnRings = 0;
152  fMinNofHits = 7;
153 
154  fMinAaxis = 3.;
155  fMaxAaxis = 7.;
156  fMinBaxis = 3.;
157  fMaxBaxis = 7.;
158  fMinRadius = 3.;
159  fMaxRadius = 7.;
160 
161 }
162 
164 {
165 
166 }
167 
169 {
171  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
172  fPar=(CbmGeoRichPar*)(rtdb->getContainer("CbmGeoRichPar"));
173 }
174 
176 {
177  cout << "CbmRichGeoTest::Init"<<endl;
179  if (NULL == ioman) { Fatal("CbmRichGeoTest::Init","RootManager not instantised!"); }
180 
181  if (fRichDetectorType == "standard") {
184 
185  // get detector position:
186  FairGeoNode *det= dynamic_cast<FairGeoNode*> (fSensNodes->FindObject("rich1d#1"));
187  if (NULL == det) cout << " -I no RICH Geo Node found !!!!! " << endl;
188 
189  FairGeoTransform* detTr=det->getLabTransform(); // detector position in labsystem
190  FairGeoVector detPosLab=detTr->getTranslation(); // ... in cm
191  FairGeoTransform detCen=det->getCenterPosition(); // center in Detector system
192  FairGeoVector detPosCen=detCen.getTranslation();
193 
194  fDetZOrig = detPosLab.Z() + detPosCen.Z(); // z coordinate of photodetector (Labsystem, cm)
195  FairGeoRotation fdetR=detTr->getRotMatrix();
196  fTheta = TMath::ASin(fdetR(7)); // tilting angle around x-axis
197  fPhi = -1.*TMath::ASin(fdetR(2)); // tilting angle around y-axis
198  }
199 
200  fRichHits = (TClonesArray*) ioman->GetObject("RichHit");
201  if ( NULL == fRichHits) { Fatal("CbmRichGeoTest::Init","No RichHit array!"); }
202 
203  fRichRings = (TClonesArray*) ioman->GetObject("RichRing");
204  if ( NULL == fRichRings) { Fatal("CbmRichGeoTest::Init","No RichRing array!"); }
205 
206  fRichPoints = (TClonesArray*) ioman->GetObject("RichPoint");
207  if ( NULL == fRichPoints) { Fatal("CbmRichGeoTest::Init","No RichPoint array!"); }
208 
209  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
210  if ( NULL == fMCTracks) { Fatal("CbmRichGeoTest::Init","No MCTrack array!"); }
211 
212  fRichRingMatches = (TClonesArray*) ioman->GetObject("RichRingMatch");
213  if ( NULL == fRichRingMatches) { Fatal("CbmRichGeoTest::Init","No RichRingMatch array!"); }
214 
217 
218  InitHistograms();
219 
220  return kSUCCESS;
221 }
222 
224  Option_t* option)
225 {
226  fEventNum++;
227  cout << "CbmRichGeoTest, event No. " << fEventNum << endl;
228  FillMcHist();
229  RingParameters();
230  HitsAndPoints();
231 }
232 
234 {
235  double xMin = -110.;
236  double xMax = 110.;
237  int nBinsX = 28;
238  double yMin = -200;
239  double yMax = 200.;
240  int nBinsY = 40;
241  if (fRichDetectorType == "prototype"){
242  xMin = -10.;
243  xMax = 10.;
244  nBinsX = 50;
245  yMin = 25.;
246  yMax = 45.;
247  nBinsY = 50;
248  }
249 
250  fhHitsXY = new TH2D("fhHitsXY", "fhHitsXY;X [cm];Y [cm];Counter", nBinsX, xMin, xMax, nBinsY, yMin, yMax);
251  fHists.push_back(fhHitsXY);
252  fhPointsXY = new TH2D("fhPointsXY", "fhPointsXY;X [cm];Y [cm];Counter", nBinsX, xMin, xMax, nBinsY, yMin, yMax);
253  fHists.push_back(fhPointsXY);
254 
255  fhNofHits.resize(2);
256  fhBoverA.resize(2);
257  fhXcYcEllipse.resize(2);
258  fhXcYcCircle.resize(2);
259  fhBaxisVsMom.resize(2);
260  fhAaxisVsMom.resize(2);
261  fhRadiusVsMom.resize(2);
262  fhChi2EllipseVsMom.resize(2);
263  fhChi2CircleVsMom.resize(2);
264  fhDRVsMom.resize(2);
265  for (Int_t i = 0; i < 2; i++){
266  stringstream ss;
267  if (i == 0) ss << "_hits";
268  if (i == 1) ss << "_points";
269  string t = ss.str();
270  fhNofHits[i] = new TH1D(("fhNofHits"+t).c_str(), ("fhNofHits"+t+";Nof hits in ring;Yield").c_str(), 300, -.5, 299.5);
271  fHists.push_back(fhNofHits[i]);
272  // ellipse fitting parameters
273  fhBoverA[i] = new TH1D(("fhBoverA"+t).c_str(), ("fhBoverA"+t+";B/A;Yield").c_str(), 50, 0, 1);
274  fHists.push_back(fhBoverA[i]);
275  fhXcYcEllipse[i] = new TH2D(("fhXcYcEllipse"+t).c_str(), ("fhXcYcEllipse"+t+";x [cm];y [cm];Yield").c_str(), nBinsX, xMin, xMax, nBinsY, yMin, yMax);
276  fHists.push_back(fhXcYcEllipse[i]);
277  fhBaxisVsMom[i] = new TH2D(("fhBaxisVsMom"+t).c_str(), ("fhBaxisVsMom"+t+";p [GeV/c];B axis [cm];Yield").c_str(), 100, 0., 10, 200, 0., 10.);
278  fHists.push_back(fhBaxisVsMom[i]);
279  fhAaxisVsMom[i] = new TH2D(("fhAaxisVsMom"+t).c_str(), ("fhAaxisVsMom"+t+";p [GeV/c];A axis [cm];Yield").c_str(), 100, 0., 10, 200, 0., 10.);
280  fHists.push_back(fhAaxisVsMom[i]);
281  fhChi2EllipseVsMom[i] = new TH2D(("fhChi2EllipseVsMom"+t).c_str(), ("fhChi2EllipseVsMom"+t+";p [GeV/c];#Chi^{2};Yield").c_str(), 100, 0., 10., 50, 0., 0.5);
282  fHists.push_back(fhChi2EllipseVsMom[i]);
283  // circle fitting parameters
284  fhXcYcCircle[i] = new TH2D(("fhXcYcCircle"+t).c_str(), ("fhXcYcCircle"+t+";x [cm];y [cm];Yield").c_str(), nBinsX, xMin, xMax, nBinsY, yMin, yMax);
285  fHists.push_back(fhXcYcCircle[i]);
286  fhRadiusVsMom[i] = new TH2D(("fhRadiusVsMom"+t).c_str(), ("fhRadiusVsMom"+t+";p [GeV/c];Radius [cm];Yield").c_str(), 100, 0., 10, 200, 0., 10.);
287  fHists.push_back(fhRadiusVsMom[i]);
288  fhChi2CircleVsMom[i] = new TH2D(("fhChi2CircleVsMom"+t).c_str(), ("fhChi2CircleVsMom"+t+";p [GeV/c];#Chi^{2};Yield").c_str(), 100, 0., 10., 50, 0., .5);
289  fHists.push_back(fhChi2CircleVsMom[i]);
290  fhDRVsMom[i] = new TH2D(("fhDRVsMom"+t).c_str(), ("fhDRVsMom"+t+";p [GeV/c];dR [cm];Yield").c_str(), 100, 0, 10, 100, -1., 1.);
291  fHists.push_back(fhDRVsMom[i]);
292  }
293 
294  fhNofPhotonsPerHit = new TH1D("fhNofPhotonsPerHit", "fhNofPhotonsPerHit;Number of photons per hit;Yield", 10, -0.5, 9.5);
295  fHists.push_back(fhNofPhotonsPerHit);
296  // Difference between Mc Points and Hits fitting.
297  fhDiffAaxis = new TH2D("fhDiffAaxis", "fhDiffAaxis;Nof hits in ring;A_{point}-A_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
298  fHists.push_back(fhDiffAaxis);
299  fhDiffBaxis = new TH2D("fhDiffBaxis", "fhDiffBaxis;Nof hits in ring;B_{point}-B_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
300  fHists.push_back(fhDiffBaxis);
301  fhDiffXcEllipse = new TH2D("fhDiffXcEllipse", "fhDiffXcEllipse;Nof hits in ring;Xc_{point}-Xc_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
302  fHists.push_back(fhDiffXcEllipse);
303  fhDiffYcEllipse = new TH2D("fhDiffYcEllipse", "fhDiffYcEllipse;Nof hits in ring;Yc_{point}-Yc_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
304  fHists.push_back(fhDiffYcEllipse);
305  fhDiffXcCircle = new TH2D("fhDiffXcCircle", "fhDiffXcCircle;Nof hits in ring;Xc_{point}-Xc_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
306  fHists.push_back(fhDiffXcCircle);
307  fhDiffYcCircle = new TH2D("fhDiffYcCircle", "fhDiffYcCircle;Nof hits in ring;Yc_{point}-Yc_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
308  fHists.push_back(fhDiffYcCircle);
309  fhDiffRadius = new TH2D("fhDiffRadius", "fhDiffRadius;Nof hits in ring;Radius_{point}-Radius_{hit} [cm];Yield", 40, 0., 40., 100, -1.5, 1.5);
310  fHists.push_back(fhDiffRadius);
311 
312  // R, A, B distribution for different number of hits from 0 to 40.
313  fhRadiusVsNofHits = new TH2D("fhRadiusVsNofHits", "fhRadiusVsNofHits;Nof hits in ring;Radius [cm];Yield", 40, 0., 40., 100, 0., 10.);
314  fhAaxisVsNofHits = new TH2D("fhAaxisVsNofHits", "fhAaxisVsNofHits;Nof hits in ring;A axis [cm];Yield", 40, 0., 40., 100, 0., 10.);
315  fhBaxisVsNofHits = new TH2D("fhBaxisVsNofHits", "fhBaxisVsNofHits;Nof hits in ring;B axis [cm];Yield", 40, 0., 40., 100, 0., 10.);
316 
317  // Hits and points.
318  fhDiffXhit = new TH1D("fhDiffXhit", "fhDiffXhit;Y_{point}-Y_{hit} [cm];Yield", 200, -1., 1.);
319  fHists.push_back(fhDiffXhit);
320  fhDiffYhit = new TH1D("fhDiffYhit", "fhDiffYhit;Y_{point}-Y_{hit} [cm];Yield", 200, -1., 1.);
321  fHists.push_back(fhDiffYhit);
322 
323  // Fitting efficiency.
324  fhNofHitsAll = new TH1D("fhNofHitsAll", "fhNofHitsAll;Nof hits in ring;Yield", 50, 0., 50.);
325  fHists.push_back(fhNofHitsAll);
326  fhNofHitsCircleFit = new TH1D("fhNofHitsCircleFit", "fhNofHitsCircleFit;Nof hits in ring;Yield", 50, 0., 50.);
327  fHists.push_back(fhNofHitsCircleFit);
328  fhNofHitsEllipseFit = new TH1D("fhNofHitsEllipseFit", "fhNofHitsEllipseFit;Nof hits in ring;Yield", 50, 0., 50.);
329  fHists.push_back(fhNofHitsEllipseFit);
330  fhNofHitsCircleFitEff = new TH1D("fhNofHitsCircleFitEff", "fhNofHitsCircleFitEff;Nof hits in ring;Efficiency [%]", 50, 0., 50.);
331  fHists.push_back(fhNofHitsCircleFitEff);
332  fhNofHitsEllipseFitEff = new TH1D("fhNofHitsEllipseFitEff", "fhNofHitsEllipseFitEff;Nof hits in ring;Efficiency [%]", 50, 0., 50.);
333  fHists.push_back(fhNofHitsEllipseFitEff);
334 
335  // Detector acceptance efficiency vs. (pt,y) and p
336  fh_mc_mom_el = new TH1D("fh_mc_mom_el", "fh_mc_mom_el;p [GeV/c];Yield", 24, 0., 12.);
337  fHists.push_back(fh_mc_mom_el);
338  fh_mc_pty_el = new TH2D("fh_mc_pty_el", "fh_mc_pty_el;Rapidity;P_{t} [GeV/c];Yield", 25, 0., 4., 20, 0., 3.);
339  fHists.push_back(fh_mc_pty_el);
340  fh_acc_mom_el = new TH1D("fh_acc_mom_el", "fh_acc_mom_el;p [GeV/c];Yield", 24, 0., 12.);
341  fHists.push_back(fh_acc_mom_el);
342  fh_acc_pty_el = new TH2D("fh_acc_pty_el", "fh_acc_pty_el;Rapidity;P_{t} [GeV/c];Yield",25, 0., 4., 20, 0., 3.);
343  fHists.push_back(fh_acc_pty_el);
344 
345  fh_mc_mom_pi = new TH1D("fh_mc_mom_pi", "fh_mc_mom_pi;p [GeV/c];Yield", 24, 0., 12.);
346  fHists.push_back(fh_mc_mom_pi);
347  fh_mc_pty_pi = new TH2D("fh_mc_pty_pi", "fh_mc_pty_pi;Rapidity;P_{t} [GeV/c];Yield", 25, 0., 4., 20, 0., 3.);
348  fHists.push_back(fh_mc_pty_pi);
349  fh_acc_mom_pi = new TH1D("fh_acc_mom_pi", "fh_acc_mom_pi;p [GeV/c];Yield", 24, 0., 12.);
350  fHists.push_back(fh_acc_mom_pi);
351  fh_acc_pty_pi = new TH2D("fh_acc_pty_pi", "fh_acc_pty_pi;Rapidity;P_{t} [GeV/c];Yield", 25, 0., 4., 20, 0., 3.);
352  fHists.push_back(fh_acc_pty_pi);
353 
354  // Numbers in dependence on XY position onto the photodetector.
355  fhNofHitsXYZ = new TH3D("fhNofHitsXY", "fhNofHitsXY;X [cm];Y [cm];Nof hits in ring", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 50, 0., 50);
356  fHists.push_back(fhNofHitsXYZ);
357  fhNofPointsXYZ = new TH3D("fhNofPointsXYZ", "fhNofPointsXYZ;X [cm];Y [cm];Nof points in ring", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 50, 100., 300.);
358  fHists.push_back(fhNofPointsXYZ);
359  fhBoverAXYZ = new TH3D("fhBoverAXYZ", "fhBoverAXYZ;X [cm];Y [cm];B/A", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 50, 0., 1.);
360  fHists.push_back(fhBoverAXYZ);
361  fhBaxisXYZ = new TH3D("fhBaxisXYZ", "fhBaxisXYZ;X [cm];Y [cm];B axis [cm]", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 80, 3., 7.);
362  fHists.push_back(fhBaxisXYZ);
363  fhAaxisXYZ = new TH3D("fhAaxisXYZ", "fhAaxisXYZ;X [cm];Y [cm];A axis [cm]", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 80, 3., 7.);
364  fHists.push_back(fhAaxisXYZ);
365  fhRadiusXYZ = new TH3D("fhRadiusXYZ", "fhRadiusXYZ;X [cm];Y [cm];Radius [cm]", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 80, 3., 7.);
366  fHists.push_back(fhRadiusXYZ);
367  fhdRXYZ = new TH3D("fhdRXYZ", "fhdRXYZ;X [cm];Y [cm];dR [cm]", nBinsX, xMin, xMax, nBinsY, yMin, yMax, 100, -1., 1.);
368  fHists.push_back(fhdRXYZ);
370 }
371 
373 {
374  TCanvas *c1 = CreateCanvas("chi2_mean_fit_vs_bfield_scale", "chi2_mean_fit_vs_bfield_scale", 600, 600);
375  Double_t x[6]={0.2, 0.5, 0.7, 1., 1.5, 2.0};
376  Double_t y1[6]={0.023, 0.031, 0.034, 0.039, 0.039, 0.045};
377  TGraph* gr1 = new TGraph(6, x, y1);
378  gr1->GetXaxis()->SetTitle("Field scales");
379  gr1->GetYaxis()->SetTitle("a_{fit}^{#Chi^{2}.mean}");
380  TF1 *f1 = new TF1("f1", "[0]*x+[1]", 0., 2.1);
381  f1->SetLineColor(kBlack);
382  gr1->GetXaxis()->SetRangeUser(0.1, 2.1);
383  DrawGraph(gr1, kLinear, kLinear, "AP");
384  gr1->SetMarkerColor(4);
385  gr1->SetMarkerSize(2.5);
386  gr1->SetMarkerStyle(21);
387  gr1->Fit(f1, "RQ");
388  gr1->GetXaxis()->SetRangeUser(0.1, 2.1);
389  f1->SetLineColor(kBlack);
390  double p0 = f1->GetParameter(0);
391  double p1 = f1->GetParameter(1);
392  stringstream ss;
393  ss.precision(3);
394  ss << "y="<<lit::NumberToString(p0, 1)<<"*x+"<<lit::NumberToString(p1, 1);
395  TLegend* leg = new TLegend(0.15, 0.9, 0.85, 0.99);
396  leg->AddEntry(new TH2D(), ss.str().c_str(), "");
397  leg->SetFillColor(kWhite);
398  leg->SetFillStyle(0);
399  leg->SetBorderSize(0);
400  leg->Draw();
401 
402 
403  TCanvas *c2 = CreateCanvas("dr_rms_fit_vs_bfield_scale", "dr_rms_fit_vs_bfield_scale", 600, 600);
404  Double_t x2[6]={0.2, 0.5, 0.7, 1., 1.5, 2.0};
405  Double_t y2[6]={0.027, 0.04, 0.05, 0.057, 0.074, 0.08};
406  TGraph* gr2 = new TGraph(6, x2, y2);
407  gr2->GetXaxis()->SetTitle("Field scales");
408  gr2->GetYaxis()->SetTitle("a_{fit}^{dR.RMS}");
409  TF1 *f2 = new TF1("f2", "[0]*x+[1]", 0., 2.1);
410  f2->SetLineColor(kBlack);
411  DrawGraph(gr2, kLinear, kLinear, "AP");
412  gr2->SetMarkerColor(4);
413  gr2->SetMarkerSize(2.5);
414  gr2->SetMarkerStyle(21);
415  gr2->Fit(f2, "RQ");
416  gr2->GetXaxis()->SetRange(0., 2.1);
417  f2->SetLineColor(kBlack);
418  double p10 = f2->GetParameter(0);
419  double p11 = f2->GetParameter(1);
420  stringstream ss2;
421  ss2 << "y="<<lit::NumberToString(p10, 1)<<"*x+"<<lit::NumberToString(p11, 1);
422  TLegend* leg2 = new TLegend(0.15, 0.9, 0.85, 0.99);
423  leg2->AddEntry(new TH2D(), ss2.str().c_str(), "");
424  leg2->SetFillColor(kWhite);
425  leg2->SetFillStyle(0);
426  leg2->SetBorderSize(0);
427  leg2->Draw();
428 }
429 
431 {
432  for (Int_t i = 0; i < fMCTracks->GetEntriesFast(); i++){
433  CbmMCTrack* mcTrack = (CbmMCTrack*)fMCTracks->At(i);
434  if (!mcTrack) continue;
435  Int_t motherId = mcTrack->GetMotherId();
436  Int_t pdg = TMath::Abs(mcTrack->GetPdgCode());
437 
438  if (pdg == 11 && motherId == -1){
439  fh_mc_mom_el->Fill(mcTrack->GetP());
440  fh_mc_pty_el->Fill(mcTrack->GetRapidity(), mcTrack->GetPt());
441  }
442 
443  if (pdg == 211 && motherId == -1){
444  fh_mc_mom_pi->Fill(mcTrack->GetP());
445  fh_mc_pty_pi->Fill(mcTrack->GetRapidity(), mcTrack->GetPt());
446  }
447  }
448 }
449 
451 {
452  Int_t nofRings = fRichRings->GetEntriesFast();
453  for (Int_t iR = 0; iR < nofRings; iR++){
454  CbmRichRing *ring = (CbmRichRing*) fRichRings->At(iR);
455  if (NULL == ring) continue;
456  CbmTrackMatch* ringMatch = (CbmTrackMatch*) fRichRingMatches->At(iR);
457  if (NULL == ringMatch) continue;
458 
459  Int_t mcTrackId = ringMatch->GetMCTrackId();
460  if (mcTrackId < 0) continue;
461  CbmMCTrack* mcTrack = (CbmMCTrack*)fMCTracks->At(mcTrackId);
462  if (!mcTrack) continue;
463  Int_t motherId = mcTrack->GetMotherId();
464  Int_t pdg = TMath::Abs(mcTrack->GetPdgCode());
465  Double_t momentum = mcTrack->GetP();
466  Double_t pt = mcTrack->GetPt();
467  Double_t rapidity = mcTrack->GetRapidity();
468 
469 
470  if (ring->GetNofHits() >= fMinNofHits){
471  if (pdg == 11 && motherId == -1){
472  fh_acc_mom_el->Fill(momentum);
473  fh_acc_pty_el->Fill(rapidity, pt);
474  }
475  if (pdg == 211 && motherId == -1){
476  fh_acc_mom_pi->Fill(momentum);
477  fh_acc_pty_pi->Fill(rapidity, pt);
478  }
479  }
480 
481  if (pdg != 11 || motherId != -1) continue; // only primary electrons
482 
483  CbmRichRingLight ringPoint;
484  int nofRichPoints = fRichPoints->GetEntriesFast();
485  for (int iPoint = 0; iPoint < nofRichPoints; iPoint++){
486  CbmRichPoint* richPoint = (CbmRichPoint*) fRichPoints->At(iPoint);
487  if (NULL == richPoint) continue;
488  Int_t trackId = richPoint->GetTrackID();
489  if (trackId < 0) continue;
490  CbmMCTrack* mcTrackRich = (CbmMCTrack*)fMCTracks->At(trackId);
491  if (NULL == mcTrackRich) continue;
492  int motherIdRich = mcTrackRich->GetMotherId();
493  if (motherIdRich == mcTrackId){
494  TVector3 posPoint;
495  richPoint->Position(posPoint);
496  TVector3 detPoint;
497  //cout << "phi= " << fPhi << " fTheta = " << fTheta << " fDetZOrig = " << fDetZOrig << endl;
498  CbmRichHitProducer::TiltPoint(&posPoint, &detPoint, fPhi, fTheta, fDetZOrig);
499  CbmRichHitLight hit(detPoint.X(), detPoint.Y());
500  ringPoint.AddHit(hit);
501  }
502  }
503  fhNofHitsAll->Fill(ring->GetNofHits());
504 
505  CbmRichRingLight ringHit;
507 
508  FitAndFillHistCircle(0, &ringHit, momentum); //hits
509  FitAndFillHistCircle(1, &ringPoint, momentum); // points
510  FillMcVsHitFitCircle(&ringHit, &ringPoint);
511 
512  double r = ringHit.GetRadius();
513  double xc = ringHit.GetCenterX();
514  double yc = ringHit.GetCenterY();
515 
516  if (ringHit.GetRadius() > fMinRadius && ringHit.GetRadius() < fMaxRadius){
517  fhNofHitsCircleFit->Fill(ringHit.GetNofHits());
518  }
519  if (fNofDrawnRings < 10 && ringHit.GetNofHits() <= 500){
520  DrawRing(&ringHit, &ringPoint);
521  }
522 
523  FitAndFillHistEllipse(0, &ringHit, momentum);// hits
524  FitAndFillHistEllipse(1, &ringPoint, momentum); // points
525  FillMcVsHitFitEllipse(&ringHit, &ringPoint);
526 
527  if (ringHit.GetAaxis() > fMinAaxis && ringHit.GetAaxis() < fMaxAaxis
528  && ringHit.GetBaxis() > fMinBaxis && ringHit.GetAaxis() < fMaxBaxis ){
529  fhNofHitsEllipseFit->Fill(ringHit.GetNofHits());
530 
531  double np = ringPoint.GetNofHits();
532  double a = ringHit.GetAaxis();
533  double b = ringHit.GetBaxis();
534  double nh = ring->GetNofHits();
535 
536  fhNofHitsXYZ->Fill(xc, yc, nh);
537  fhNofPointsXYZ->Fill(xc, yc, np);
538  fhBoverAXYZ->Fill(xc, yc, b/a);
539  fhBaxisXYZ->Fill(xc, yc, b);
540  fhAaxisXYZ->Fill(xc, yc, a);
541  fhRadiusXYZ->Fill(xc, yc, r);
542 
543  for (int iH = 0; iH < ringHit.GetNofHits(); iH++){
544  double xh = ringHit.GetHit(iH).fX;
545  double yh = ringHit.GetHit(iH).fY;
546  double dr = r - sqrt((xc - xh)*(xc - xh) + (yc - yh)*(yc - yh));
547  fhdRXYZ->Fill(xc, yc, dr);
548  }
549  }
550  }// iR
551 }
552 
554  int histIndex,
555  CbmRichRingLight* ring,
556  double momentum)
557 {
558  fTauFit->DoFit(ring);
559  double axisA = ring->GetAaxis();
560  double axisB = ring->GetBaxis();
561  double xcEllipse = ring->GetCenterX();
562  double ycEllipse = ring->GetCenterY();
563  int nofHitsRing = ring->GetNofHits();
564  if (axisA > fMinAaxis && axisA < fMaxAaxis && axisB > fMinBaxis && axisB < fMaxBaxis ){
565  fhBoverA[histIndex]->Fill(axisB/axisA);
566  fhXcYcEllipse[histIndex]->Fill(xcEllipse, ycEllipse);
567  }
568  fhNofHits[histIndex]->Fill(nofHitsRing);
569  fhBaxisVsMom[histIndex]->Fill(momentum, axisB);
570  fhAaxisVsMom[histIndex]->Fill(momentum, axisA);
571  fhChi2EllipseVsMom[histIndex]->Fill(momentum, ring->GetChi2()/ring->GetNofHits());
572  if (histIndex == 0){ // only hit fit
573  fhAaxisVsNofHits->Fill(nofHitsRing, axisA);
574  fhBaxisVsNofHits->Fill(nofHitsRing, axisB);
575  }
576 }
577 
579  int histIndex,
580  CbmRichRingLight* ring,
581  double momentum)
582 {
583  fCopFit->DoFit(ring);
584  double radius = ring->GetRadius();
585  double xcCircle = ring->GetCenterX();
586  double ycCircle = ring->GetCenterY();
587  int nofHitsRing = ring->GetNofHits();
588  fhXcYcCircle[histIndex]->Fill(xcCircle, ycCircle);
589  fhRadiusVsMom[histIndex]->Fill(momentum, radius);
590  fhChi2CircleVsMom[histIndex]->Fill(momentum, ring->GetChi2()/ring->GetNofHits());
591 
592  for (int iH = 0; iH < ring->GetNofHits(); iH++){
593  double xh = ring->GetHit(iH).fX;
594  double yh = ring->GetHit(iH).fY;
595  double dr = radius - sqrt((xcCircle - xh)*(xcCircle - xh) + (ycCircle - yh)*(ycCircle - yh));
596  fhDRVsMom[histIndex]->Fill(momentum, dr);
597 
598  //if (histIndex == 0) {
599  // fhdRXYZ->Fill(xcCircle, ycCircle, dr);
600  //}
601  }
602 
603  if (histIndex == 0){ // only hit fit
604  fhRadiusVsNofHits->Fill(nofHitsRing, radius);
605  }
606 }
607 
609  CbmRichRingLight* ring,
610  CbmRichRingLight* ringMc)
611 {
612  fhDiffAaxis->Fill(ring->GetNofHits(), ringMc->GetAaxis() - ring->GetAaxis());
613  fhDiffBaxis->Fill(ring->GetNofHits(),ringMc->GetBaxis() - ring->GetBaxis());
614  fhDiffXcEllipse->Fill(ring->GetNofHits(),ringMc->GetCenterX() - ring->GetCenterX());
615  fhDiffYcEllipse->Fill(ring->GetNofHits(),ringMc->GetCenterY() - ring->GetCenterY());
616 }
617 
619  CbmRichRingLight* ring,
620  CbmRichRingLight* ringMc)
621 {
622  fhDiffXcCircle->Fill(ring->GetNofHits(),ringMc->GetCenterX() - ring->GetCenterX());
623  fhDiffYcCircle->Fill(ring->GetNofHits(),ringMc->GetCenterY() - ring->GetCenterY());
624  fhDiffRadius->Fill(ring->GetNofHits(),ringMc->GetRadius() - ring->GetRadius());
625 }
626 
628 {
629  Int_t nofHits = fRichHits->GetEntriesFast();
630  for (Int_t iH = 0; iH < nofHits; iH++){
631  CbmRichHit *hit = (CbmRichHit*) fRichHits->At(iH);
632  if ( hit == NULL ) continue;
633  Int_t pointInd = hit->GetRefId();
634  if (pointInd < 0) continue;
635  CbmRichPoint *point = (CbmRichPoint*) fRichPoints->At(pointInd);
636  if ( point == NULL ) continue;
637 
638  fhNofPhotonsPerHit->Fill(hit->GetNPhotons());
639 
640  TVector3 inPos(point->GetX(), point->GetY(), point->GetZ());
641  TVector3 outPos;
643  fhHitsXY->Fill(hit->GetX(), hit->GetY());
644  fhDiffXhit->Fill(hit->GetX() - outPos.X());
645  fhDiffYhit->Fill(hit->GetY() - outPos.Y());
646  }
647 
648  Int_t nofPoints = fRichPoints->GetEntriesFast();
649  for (Int_t iP = 0; iP < nofPoints; iP++){
651  if ( point == NULL ) continue;
652  TVector3 inPos(point->GetX(), point->GetY(), point->GetZ());
653  TVector3 outPos;
655  fhPointsXY->Fill(outPos.X(), outPos.Y());
656  }
657 }
658 
660  CbmRichRingLight* ringHit,
661  CbmRichRingLight* ringPoint)
662 {
663  stringstream ss;
664  ss << "Event" << fNofDrawnRings;
665  fNofDrawnRings++;
666  TCanvas *c = CreateCanvas(ss.str().c_str(), ss.str().c_str(), 500, 500);
667  c->SetGrid(true, true);
668  TH2D* pad = new TH2D("pad", ";X [cm];Y [cm]", 1, -15., 15., 1, -15., 15);
669  pad->SetStats(false);
670  pad->Draw();
671 
672  // find min and max x and y positions of the hits
673  // in order to shift drawing
674  double xmin = 99999., xmax = -99999., ymin = 99999., ymax = -99999.;
675  for (int i = 0; i < ringHit->GetNofHits(); i++){
676  double hitX = ringHit->GetHit(i).fX;
677  double hitY = ringHit->GetHit(i).fY;
678  if (xmin > hitX) xmin = hitX;
679  if (xmax < hitX) xmax = hitX;
680  if (ymin > hitY) ymin = hitY;
681  if (ymax < hitY) ymax = hitY;
682  }
683  double xCur = (xmin + xmax) / 2.;
684  double yCur = (ymin + ymax) / 2.;
685 
686  //Draw circle and center
687  TEllipse* circle = new TEllipse(ringHit->GetCenterX() - xCur,
688  ringHit->GetCenterY() - yCur, ringHit->GetRadius());
689  circle->SetFillStyle(0);
690  circle->SetLineWidth(3);
691  circle->Draw();
692  TEllipse* center = new TEllipse(ringHit->GetCenterX() - xCur, ringHit->GetCenterY() - yCur, .5);
693  center->Draw();
694 
695  // Draw hits
696  for (int i = 0; i < ringHit->GetNofHits(); i++){
697  TEllipse* hitDr = new TEllipse(ringHit->GetHit(i).fX - xCur, ringHit->GetHit(i).fY - yCur, .5);
698  hitDr->SetFillColor(kRed);
699  hitDr->Draw();
700  }
701 
702  // Draw MC Points
703  for (int i = 0; i < ringPoint->GetNofHits(); i++){
704  TEllipse* pointDr = new TEllipse(ringPoint->GetHit(i).fX - xCur, ringPoint->GetHit(i).fY - yCur, 0.15);
705  pointDr->SetFillColor(kBlue);
706  pointDr->Draw();
707  }
708 
709  //Draw information
710  stringstream ss2;
711  ss2 << "(r, n)=(" << setprecision(3) << ringHit->GetRadius() << ", " << ringHit->GetNofHits()<<")";
712  TLatex* latex = new TLatex(-8., 8., ss2.str().c_str());
713  latex->Draw();
714 }
715 
717 {
718  Int_t nofMc = (Int_t)fh_mc_mom_el->GetEntries();
719  TH1D* hist = (TH1D*)fhNofHits[0]->Clone("fhAccVsMinNofHitsHist");
720  hist->GetXaxis()->SetTitle("Required min nof hits in ring");
721  hist->GetYaxis()->SetTitle("Detector acceptance [%]");
722  Double_t sum = 0.;
723  for (int i = hist->GetNbinsX(); i > 1 ; i--){
724  sum += fhNofHits[0]->GetBinContent(i);
725  hist->SetBinContent(i, 100. * sum / nofMc);
726  }
727  return hist;
728 }
729 
731  TH2D* hist,
732  TH1D** meanHist,
733  TH1D** rmsHist)
734 {
735  *meanHist = (TH1D*)hist->ProjectionX( (string(hist->GetName()) + "_mean").c_str() )->Clone();
736  (*meanHist)->GetYaxis()->SetTitle( ("Mean and RMS. " + string(hist->GetYaxis()->GetTitle()) ).c_str());
737  *rmsHist = (TH1D*)hist->ProjectionX((string(hist->GetName()) + "_rms").c_str() )->Clone();
738  (*rmsHist)->GetYaxis()->SetTitle( ("RMS. "+ string(hist->GetYaxis()->GetTitle()) ).c_str());
739  for (Int_t i = 1; i <= hist->GetXaxis()->GetNbins(); i++){
740  stringstream ss;
741  ss << string(hist->GetName()) << "_py" << i;
742  TH1D* pr = hist->ProjectionY(ss.str().c_str(), i, i);
743  if (*meanHist == NULL || pr == NULL) continue;
744  (*meanHist)->SetBinContent(i, pr->GetMean());
745  (*meanHist)->SetBinError(i, pr->GetRMS());
746  (*rmsHist)->SetBinContent(i, pr->GetRMS());
747  }
748 }
749 
751  TH2D* hist,
752  const string& canvasName)
753 {
754  TH1D* mean, *rms;
755  CreateH2MeanRms(hist, &mean, &rms);
756  // TCanvas *c = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 900, 900);
757  /* c->Divide(2, 2);
758  c->cd(1);
759  DrawH2(hist);
760  c->cd(2);
761  TH1D* py = hist->ProjectionY( (string(hist->GetName())+ "_py" ).c_str() );
762  py->Scale(1./py->Integral());
763  py->GetYaxis()->SetTitle("Yield");
764  DrawH1(py);
765  string txt1 = lit::NumberToString<Double_t>(py->GetMean(), 2) + " / "
766  + lit::NumberToString<Double_t>(py->GetRMS(), 2);
767  TLatex text;
768  text.SetTextAlign(21);
769  text.SetTextSize(0.05);
770  text.DrawTextNDC(0.5, 0.92, txt1.c_str());
771  gPad->SetLogy(true);
772  c->cd(3);
773  DrawH1(mean);
774  c->cd(4);
775  DrawH1(rms);*/
776 
777  TCanvas *c1 = CreateCanvas((canvasName+"_py").c_str(), (canvasName+"_py").c_str(), 800, 800);
778  TH1D* py = hist->ProjectionY( (string(hist->GetName())+ "_py" ).c_str() );
779  py->Scale(1./py->Integral());
780  py->GetYaxis()->SetTitle("Yield");
781  DrawH1(py);
782  string txt1 = lit::NumberToString<Double_t>(py->GetMean(), 2) + " / " + lit::NumberToString<Double_t>(py->GetRMS(), 2);
783  TLatex text;
784  text.SetTextAlign(21);
785  text.SetTextSize(0.05);
786  text.DrawTextNDC(0.5, 0.92, txt1.c_str());
787  gPad->SetLogy(true);
788 
789  TCanvas *c2 = CreateCanvas((canvasName+"_mean").c_str(), (canvasName+"_mean").c_str(), 800, 800);
790  DrawH1(mean);
791 
792  TCanvas *c3 = CreateCanvas((canvasName+"_rms").c_str(), (canvasName+"_rms").c_str(), 800, 800);
793  DrawH1(rms);
794 }
795 
797  TH1D* hist)
798 {
799  // TH1D* py = hist->ProjectionY( (string(hist->GetName())+ "_py" ).c_str() );
800  hist->GetYaxis()->SetTitle("Yield");
801  DrawH1(hist);
802  hist->Scale(1./ hist->Integral());
803  hist->GetXaxis()->SetRangeUser(2., 8.);
804  hist->Fit("gaus", "Q");
805  TF1* func = hist->GetFunction("gaus");
806  if (func == NULL) return;
807  func->SetLineColor(kBlack);
808  double m = func->GetParameter(1);
809  double s = func->GetParameter(2);
810  string txt1 = lit::NumberToString<double>(m, 2) + " / " + lit::NumberToString<double>(s, 2);
811  TLatex text;
812  text.SetTextAlign(21);
813  text.SetTextSize(0.06);
814  text.DrawTextNDC(0.5, 0.92, txt1.c_str());
815  // gPad->SetLogy(true);
816 }
817 
819  TH1D* hist,
820  double xMinFit,
821  double xMaxFit,
822  double xMin,
823  double xMax,
824  const string& canvasName)
825 {
826  for (int i = 1; i < hist->GetNbinsX() - 1;i++){
827  double c0 = hist->GetBinContent(i);
828  double c1 = hist->GetBinContent(i+1);
829  if (c0 > 0 && c0 <= c1){
830  xMinFit = hist->GetBinCenter(i+1);
831  }
832  if (c0 > c1) {
833  break;
834  }
835  }
836  TCanvas *cDrRmsFit = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 600, 600);
837  TF1 *f1 = new TF1("f1", "[0]/x+[1]", xMinFit, xMaxFit);
838  f1->SetLineColor(kBlack);
839  DrawH1(hist);
840  hist->Fit(f1, "RQ");
841  hist->GetXaxis()->SetRangeUser(xMin, xMax);
842  f1->SetLineColor(kBlack);
843 
844  double p0 = f1->GetParameter(0);
845  double p1 = f1->GetParameter(1);
846  stringstream ss;
847  ss.precision(3);
848  ss << "y="<<lit::NumberToString(p0, 1)<<"/P+"<<lit::NumberToString(p1, 1);
849  TLegend* leg = new TLegend(0.15, 0.9, 0.85, 0.99);
850  leg->AddEntry(new TH2D(), ss.str().c_str(), "");
851  leg->SetFillColor(kWhite);
852  leg->SetFillStyle(0);
853  leg->SetBorderSize(0);
854  leg->Draw();
855 }
856 
858 {
860 
861  TCanvas *cHitsXY = CreateCanvas("richgeo_hits_xy", "richgeo_hits_xy", 800, 800);
862  DrawH2(fhHitsXY);
863 
864  TCanvas *cPointsXY = CreateCanvas("richgeo_points_xy", "richgeo_points_xy", 800, 800);
866 
867  for (int i = 0; i < 2; i++){
868  stringstream ss;
869  if (i == 0) ss << "richgeo_hits_";
870  if (i == 1) ss << "richgeo_points_";
871  TCanvas *cEllipseBoa = CreateCanvas((ss.str()+"ellipse_boa").c_str(), (ss.str()+"ellipse_boa").c_str(), 800, 800);
872  fhBoverA[i]->Scale(1./fhBoverA[i]->Integral());
873  DrawH1(fhBoverA[i]);
874  cout << (ss.str()+"ellipse_boa_mean") << fhBoverA[i]->GetMean() << endl;
875  gPad->SetLogy(true);
876 
877  TCanvas *cEllipseXcYc = CreateCanvas((ss.str()+"ellipse_xc_yc").c_str(), (ss.str()+"ellipse_xc_yc").c_str(), 800, 800);
878  DrawH2(fhXcYcEllipse[i]);
879 
880  DrawH2MeanRms(fhChi2EllipseVsMom[i], ss.str() + "chi2_ellipse_vs_mom");
881  DrawH2MeanRms(fhAaxisVsMom[i], ss.str() + "a_vs_mom");
882  DrawH2MeanRms(fhBaxisVsMom[i], ss.str() + "b_vs_mom");
883 
884  TCanvas *cCircle = CreateCanvas((ss.str()+"circle").c_str(), (ss.str()+"circle").c_str(), 800, 400);
885  cCircle->Divide(2,1);
886  cCircle->cd(1);
887  DrawH1(fhNofHits[i]);
888  cout << "Number of hits/points = " << fhNofHits[i]->GetMean() << endl;
889  gPad->SetLogy(true);
890  cCircle->cd(2);
891  DrawH2(fhXcYcCircle[i]);
892 
893  DrawH2MeanRms(fhChi2CircleVsMom[i], ss.str() + "chi2_circle_vs_mom");
894  DrawH2MeanRms(fhRadiusVsMom[i], ss.str() + "r_vs_mom");
895  DrawH2MeanRms(fhDRVsMom[i], ss.str() + "dr_vs_mom");
896 
897  TH1D* meanDr, *rmsDr;
898  CreateH2MeanRms(fhDRVsMom[i], &meanDr, &rmsDr);
899  FitH1OneOverX(rmsDr, 0.1, 2.9, 0.0, 3.0, ss.str() + "dr_rms_vs_mom_fit");
900 
901  TH1D* meanChi2, *rmsChi2;
902  CreateH2MeanRms(fhChi2CircleVsMom[i], &meanChi2, &rmsChi2);
903  FitH1OneOverX(meanChi2, 0.1, 2.9, 0.0, 3.0, ss.str() + "chi2_circle_mean_vs_mom_fit");
904  }
905 
906  TCanvas* cNofPhotons = CreateCanvas("richgeo_nof_photons_per_hit", "richgeo_nof_photons_per_hit", 800, 800);
907  fhNofPhotonsPerHit->Scale(1./fhNofPhotonsPerHit->Integral());
909 
910  TCanvas *cDiff2DEllipse = CreateCanvas("richgeo_diff2d_ellipse", "richgeo_diff2d_ellipse", 800, 800);
911  cDiff2DEllipse->Divide(2,2);
912  cDiff2DEllipse->cd(1);
914  cDiff2DEllipse->cd(2);
916  cDiff2DEllipse->cd(3);
918  cDiff2DEllipse->cd(4);
920 
921  TCanvas *cDiff2DCircle = CreateCanvas("richgeo_diff2d_circle", "richgeo_diff2d_circle", 1200, 400);
922  cDiff2DCircle->Divide(3,1);
923  cDiff2DCircle->cd(1);
925  cDiff2DCircle->cd(2);
927  cDiff2DCircle->cd(3);
929 
930  TCanvas *cDiff1DEllipse = CreateCanvas("richgeo_diff1d_ellipse", "richgeo_diff1d_ellipse", 800, 800);
931  cDiff1DEllipse->Divide(2,2);
932  cDiff1DEllipse->cd(1);
933  DrawH1(fhDiffAaxis->ProjectionY());
934  gPad->SetLogy(true);
935  cDiff1DEllipse->cd(2);
936  DrawH1(fhDiffBaxis->ProjectionY());
937  gPad->SetLogy(true);
938  cDiff1DEllipse->cd(3);
939  DrawH1(fhDiffXcEllipse->ProjectionY());
940  gPad->SetLogy(true);
941  cDiff1DEllipse->cd(4);
942  DrawH1(fhDiffYcEllipse->ProjectionY());
943  gPad->SetLogy(true);
944 
945  TCanvas *cDiff1DCircle = CreateCanvas("richgeo_diff1d_circle", "richgeo_diff1d_circle", 1200, 400);
946  cDiff1DCircle->Divide(3,1);
947  cDiff1DCircle->cd(1);
948  DrawH1(fhDiffXcCircle->ProjectionY());
949  gPad->SetLogy(true);
950  cDiff1DCircle->cd(2);
951  DrawH1(fhDiffYcCircle->ProjectionY());
952  gPad->SetLogy(true);
953  cDiff1DCircle->cd(3);
954  DrawH1(fhDiffRadius->ProjectionY());
955  gPad->SetLogy(true);
956 
957  TCanvas *cHits = CreateCanvas("richgeo_hits", "richgeo_hits", 1200, 600);
958  cHits->Divide(2,1);
959  cHits->cd(1);
961  cHits->cd(2);
963 
964  TCanvas *cFitEff = CreateCanvas("richgeo_fit_eff", "richgeo_fit_eff", 1200, 400);
965  cFitEff->Divide(3,1);
966  cFitEff->cd(1);
967  DrawH1( list_of((TH1D*)fhNofHitsAll->Clone())((TH1D*)fhNofHitsCircleFit->Clone())((TH1D*)fhNofHitsEllipseFit->Clone()),
968  list_of("All")("Circle fit")("Ellipse fit"), kLinear, kLog, true, 0.7, 0.7, 0.99, 0.99);
969  fhNofHitsCircleFitEff = DivideH1(fhNofHitsCircleFit, fhNofHitsAll, "", "", "Nof hits in ring", "Efficiency");
970  fhNofHitsEllipseFitEff = DivideH1(fhNofHitsEllipseFit, fhNofHitsAll, "", "", "Nof hits in ring", "Efficiency");
971  cFitEff->cd(2);
973  TLatex* circleFitEffTxt = new TLatex(15, 0.5, CalcEfficiency(fhNofHitsCircleFit, fhNofHitsAll).c_str());
974  circleFitEffTxt->Draw();
975  cFitEff->cd(3);
977  TLatex* ellipseFitEffTxt = new TLatex(15, 0.5, CalcEfficiency(fhNofHitsEllipseFit, fhNofHitsAll).c_str());
978  ellipseFitEffTxt->Draw();
979 
980  TCanvas *cAccEff = CreateCanvas("richgeo_acc_eff_el", "richgeo_acc_eff_el", 1200, 800);
981  cAccEff->Divide(3,2);
982  cAccEff->cd(1);
983  DrawH1(list_of(fh_mc_mom_el)(fh_acc_mom_el), list_of("MC")("ACC"), kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99);
984  cAccEff->cd(2);
986  cAccEff->cd(3);
988 
989 
990  TH1D* pxEff = DivideH1((TH1D*)fh_acc_mom_el->Clone(), (TH1D*)fh_mc_mom_el->Clone(), "pxEff", "", "p [GeV/c]", "Geometrical acceptance [%]");
991  TH2D* pyzEff = DivideH2((TH1D*)fh_acc_pty_el->Clone(), (TH1D*)fh_mc_pty_el->Clone(), "pyzEff", "", "Rapidity", "P_{t} [GeV/c]", "Geometrical acceptance [%]");
992  //cAccEff->cd(4);
993  TCanvas *cAccEff_mom = CreateCanvas("richgeo_acc_eff_el_mom", "richgeo_acc_eff_el_mom", 800, 800);
994  DrawH1(pxEff);
995  //TLatex* pxEffTxt = new TLatex(3, 0.5, CalcEfficiency(fh_acc_mom_el, fh_mc_mom_el).c_str());
996  //pxEffTxt->Draw();
997  TCanvas *cAccEff_pty = CreateCanvas("richgeo_acc_eff_el_pty", "richgeo_acc_eff_el_pty", 800, 800);
998  //cAccEff->cd(5);
999  DrawH2(pyzEff);
1000 
1001  TCanvas *cAccEffPi = CreateCanvas("richgeo_acc_eff_pi", "richgeo_acc_eff_pi", 1200, 800);
1002  cAccEffPi->Divide(3,2);
1003  cAccEffPi->cd(1);
1004  DrawH1(list_of(fh_mc_mom_pi)(fh_acc_mom_pi), list_of("MC")("ACC"), kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99);
1005  cAccEffPi->cd(2);
1007  cAccEffPi->cd(3);
1009  TH1D* pxPiEff = DivideH1((TH1D*)fh_acc_mom_pi->Clone(), (TH1D*)fh_mc_mom_pi->Clone(), "pxPiEff", "", "p [GeV/c]", "Geometrical acceptance [%]");
1010  TH2D* pyzPiEff = DivideH2((TH1D*)fh_acc_pty_pi->Clone(), (TH1D*)fh_mc_pty_pi->Clone(), "pyzPiEff", "", "Rapidity", "P_{t} [GeV/c]", "Geometrical acceptance [%]");
1011  // cAccEffPi->cd(4);
1012  TCanvas *cAccEffPi_mom = CreateCanvas("richgeo_acc_eff_pi_mom", "richgeo_acc_eff_pi_mom", 800, 800);
1013  DrawH1(pxPiEff);
1014  // TLatex* pxEffTxt = new TLatex(3, 0.5, CalcEfficiency(fh_acc_mom_pi, fh_mc_mom_pi).c_str());
1015  // pxEffTxt->Draw();
1016  //cAccEffPi->cd(5);
1017  TCanvas *cAccEffPi_pty = CreateCanvas("richgeo_acc_eff_pi_pty", "richgeo_acc_eff_pi_pty", 800, 800);
1018  DrawH2(pyzPiEff);
1019  pyzPiEff->GetZaxis()->SetRangeUser(0, 100);
1020 
1021  TCanvas *cAccEffElPi_mom = CreateCanvas("richgeo_acc_eff_el_pi_mom", "richgeo_acc_eff_el_pi_mom", 800, 800);
1022  DrawH1(list_of(pxEff)(pxPiEff), list_of("e^{#pm}")("#pi^{#pm}"), kLinear, kLinear, true, 0.7, 0.5, 0.87, 0.7);
1023 
1024 
1025  TCanvas *cAccEffZoom = CreateCanvas("richgeo_acc_eff_el_zoom", "richgeo_acc_eff_el_zoom", 1000, 500);
1026  cAccEffZoom->Divide(2,1);
1027  cAccEffZoom->cd(1);
1028  TH1D* fh_mc_mom_clone = (TH1D*)fh_mc_mom_el->Clone();
1029  TH1D* fh_acc_mom_clone = (TH1D*)fh_acc_mom_el->Clone();
1030  fh_mc_mom_clone->GetXaxis()->SetRangeUser(0., 3.);
1031  fh_acc_mom_clone->GetXaxis()->SetRangeUser(0., 3.);
1032  fh_mc_mom_clone->SetMinimum(0.);
1033  DrawH1(list_of(fh_mc_mom_clone)(fh_acc_mom_clone), list_of("MC")("ACC"), kLinear, kLog, true, 0.8, 0.8, 0.99, 0.99);
1034  gPad->SetLogy(false);
1035  cAccEffZoom->cd(2);
1036  TH1D* px_eff_clone = (TH1D*) pxEff->Clone();
1037  px_eff_clone->GetXaxis()->SetRangeUser(0., 3.);
1038  px_eff_clone->SetMinimum(0.);
1039  DrawH1(px_eff_clone);
1040 
1041  // Draw number vs position onto the photodetector plane
1042  DrawH3(fhNofHitsXYZ, "richgeo_numbers_vs_xy_hits", "Number of hits", 10, 30);
1043  DrawH3(fhNofPointsXYZ, "richgeo_numbers_vs_xy_points", "Number of points", 100., 300.);
1044  DrawH3(fhBoverAXYZ, "richgeo_numbers_vs_xy_boa", "B/A", 0.75, 1.0);
1045  DrawH3(fhBaxisXYZ, "richgeo_numbers_vs_xy_b", "B [cm]", 4., 5.);
1046  DrawH3(fhAaxisXYZ, "richgeo_numbers_vs_xy_a", "A [cm]", 4.4, 5.7);
1047  DrawH3(fhRadiusXYZ, "richgeo_numbers_vs_xy_r", "Radius [cm]", 4.2, 5.2);
1048  DrawH3(fhdRXYZ, "richgeo_numbers_vs_xy_dr", "dR [cm]", -.1, .1);
1049 
1050  TCanvas *cAccVsMinNofHits = CreateCanvas("richgeo_acc_vs_min_nof_hits", "richgeo_acc_vs_min_nof_hits", 600, 600);
1051  TH1D* h = CreateAccVsMinNofHitsHist();
1052  h->GetXaxis()->SetRangeUser(0., 40.0);
1053  DrawH1(h);
1054 
1055  DrawH2MeanRms(fhRadiusVsNofHits, "richgeo_hits_r_vs_nof_hits");
1056  DrawH2MeanRms(fhAaxisVsNofHits, "richgeo_hits_a_vs_nof_hits");
1057  DrawH2MeanRms(fhBaxisVsNofHits, "richgeo_hits_b_vs_nof_hits");
1058 
1059  TCanvas* cHitsRAB = CreateCanvas("richgeo_hits_rab", "richgeo_hits_rab", 1500, 600);
1060  cHitsRAB->Divide(3, 1);
1061  cHitsRAB->cd(1);
1062  DrawH1andFit(fhRadiusVsNofHits->ProjectionY( (string(fhRadiusVsNofHits->GetName())+ "_py" ).c_str() ));
1063  cHitsRAB->cd(2);
1064  DrawH1andFit(fhAaxisVsNofHits->ProjectionY( (string(fhAaxisVsNofHits->GetName())+ "_py" ).c_str() ));
1065  cHitsRAB->cd(3);
1066  DrawH1andFit(fhBaxisVsNofHits->ProjectionY( (string(fhBaxisVsNofHits->GetName())+ "_py" ).c_str() ));
1067 }
1068 
1070  TH3D* h,
1071  const string& cName,
1072  const string& zAxisTitle,
1073  double zMin,
1074  double zMax,
1075  bool doFit)
1076 {
1077  int nBinsX = h->GetNbinsX();
1078  int nBinsY = h->GetNbinsY();
1079  TH2D* h2Mean = (TH2D*)h->Project3D("yx")->Clone();
1080  TH2D* h2Rms = (TH2D*)h->Project3D("yx")->Clone();
1081 
1082  TCanvas *canvas;
1083  if (doFit) canvas = new TCanvas ("fit_func", "fit_func");
1084 
1085  for (int x = 1; x <= nBinsX; x++){
1086  for (int y = 1; y <= nBinsY; y++){
1087  stringstream ss;
1088  ss << h->GetName() << "_z_" << x << "_" << y;
1089  TH1D* hz = h->ProjectionZ(ss.str().c_str(), x, x, y, y);
1090  double m = 0.;
1091  double s = 0.;
1092  if (doFit) {
1093  hz->Fit("gaus", "QO");
1094  TF1* func = hz->GetFunction("gaus");
1095  if (func != NULL) {
1096  m = func->GetParameter(1);
1097  s = func->GetParameter(2);
1098  }
1099  } else {
1100  m = hz->GetMean();
1101  s = hz->GetRMS();
1102  }
1103  h2Mean->SetBinContent(x, y, m);
1104  h2Rms->SetBinContent(x, y, s);
1105  }
1106  }
1107 
1108  TCanvas *mean = CreateCanvas(string(cName+"_mean").c_str(), string(cName+"_mean").c_str(), 800, 800);
1109  h2Mean->GetZaxis()->SetTitle(string("Mean."+zAxisTitle).c_str());
1110  h2Mean->GetZaxis()->SetRangeUser(zMin, zMax);
1111  DrawH2(h2Mean);
1112  TCanvas *rms = CreateCanvas(string(cName+"_rms").c_str(), string(cName+"_rms").c_str(), 800, 800);
1113  h2Rms->GetZaxis()->SetTitle(string("RMS."+zAxisTitle).c_str());
1114  DrawH2(h2Rms);
1115 
1116 
1117  TCanvas* cHitsRAB = CreateCanvas(string(cName+"_local_xy").c_str(), string(cName+"_local_xy").c_str(), 800, 800);
1118  int x = h->GetXaxis()->FindBin(20);
1119  int y = h->GetYaxis()->FindBin(120);
1120  cout << x << " " << y << endl;
1121  TH1D* hz = h->ProjectionZ((string(h->GetName())+"_local_xy").c_str(), x, x, y, y);
1122  //if (hz->GetEntries() > 2) {
1123  DrawH1andFit(hz);
1124  //}
1125 
1126  if (canvas != NULL) delete canvas;
1127 
1128 }
1129 
1131  const string& title,
1132  const vector<string>& fileNames,
1133  const vector<string>& studyNames,
1134  const string& outputDir)
1135 {
1136  if (outputDir != "") gSystem->mkdir(outputDir.c_str(), true);
1137 
1138  CbmStudyReport* report = new CbmRichGeoTestStudyReport();
1139  fTitle = title;
1140  cout << "Report can be found here: " << outputDir << endl;
1141  report->Create(fileNames, studyNames, outputDir);
1142  delete report;
1143 }
1144 
1146 {
1147  DrawHist();
1148  for (Int_t i = 0; i < fHists.size(); i++){
1149  // if (NULL != fHists[i]) fHists[i]->Write();
1150  }
1151  fhNofHits[0]->Write();
1152  fhNofHits[1]->Write();
1153  fhNofPhotonsPerHit->Write();
1155 }
1156 
1158  TH1* histRec,
1159  TH1* histAcc)
1160 {
1161  if (histAcc->GetEntries() == 0) { return "0.0"; }
1162  else {
1163  Double_t eff = Double_t(histRec->GetEntries()) / Double_t(histAcc->GetEntries());
1164  stringstream ss;
1165  ss.precision(3);
1166  ss << eff;
1167  return ss.str();
1168  }
1169 }
1170 
1171 
1173  TH1D* h1,
1174  TH1D* h2,
1175  const string& name,
1176  const string& title,
1177  const string& axisX,
1178  const string& axisY)
1179 {
1180  h1->Sumw2();
1181  h2->Sumw2();
1182  TH1D* h3 = new TH1D(name.c_str(), string(title +";"+axisX+";"+ axisY).c_str(),
1183  h1->GetNbinsX(), h1->GetXaxis()->GetXmin(),h1->GetXaxis()->GetXmax());
1184  h3->Divide(h1, h2, 100., 1., "B");
1185  return h3;
1186 }
1187 
1189  TH1D* h1,
1190  TH1D* h2,
1191  const string& name,
1192  const string& title,
1193  const string& axisX,
1194  const string& axisY,
1195  const string& axisZ)
1196 {
1197  h1->Sumw2();
1198  h2->Sumw2();
1199  TH2D* h3 = new TH2D(name.c_str(), string(title +";"+axisX+";"+ axisY+";"+axisZ).c_str(),
1200  h1->GetNbinsX(), h1->GetXaxis()->GetXmin(),h1->GetXaxis()->GetXmax(),
1201  h1->GetNbinsY(), h1->GetYaxis()->GetXmin(),h1->GetYaxis()->GetXmax());
1202  h3->Divide(h1, h2, 100., 1., "B");
1203  return h3;
1204 }
1205 
1207  const string& name,
1208  const string& title,
1209  int width,
1210  int height)
1211 {
1212  TCanvas* c = new TCanvas(name.c_str(), title.c_str(), width, height);
1213  fCanvas.push_back(c);
1214  return c;
1215 }
1216 
1218 {
1219  for (int i = 0; i < fCanvas.size(); i++)
1220  {
1222  }
1223 }
1224 
1226