CbmRoot
CbmRichMirrorSortingCorrection.cxx
Go to the documentation of this file.
2 #include "FairLogger.h"
3 #include "FairRootManager.h"
5 
6 // ----- PART 1 ----- //
7 #include "CbmGlobalTrack.h"
8 #include "CbmRichConverter.h"
9 #include "CbmRichRingFitterCOP.h"
11 #include "CbmRichUtil.h"
12 #include "CbmUtils.h"
13 #include "TCanvas.h"
14 #include "TClonesArray.h"
15 #include "TH2D.h"
16 #include "TLegend.h"
17 #include "TVector3.h"
18 #include <vector>
19 
20 // ----- PART 2 ----- //
21 #include "CbmRichGeoManager.h"
22 #include "CbmRichPoint.h"
23 #include "TGeoManager.h"
24 #include "TGeoNavigator.h"
25 class TGeoNode;
26 class TGeoMatrix;
27 #include "CbmDrawHist.h"
28 #include "CbmTrackMatchNew.h"
29 #include "TMCProcess.h"
30 #include "TStyle.h"
31 #include "string.h"
32 #include <fstream>
33 #include <iostream>
34 #include <sstream>
35 
36 using namespace std;
37 
38 
40  : FairTask("CbmRichMirrorSortingCorrection")
41  , fEventNb(0)
42  , fHM(NULL)
43  , fHM2(NULL)
44  , fDiffHistoMap()
45  , fCopFit(NULL)
46  , fTauFit(NULL)
47  , fGlobalTracks(NULL)
48  , fRichRings(NULL)
49  , fMCTracks(NULL)
50  , fMirrorPoints(NULL)
51  , fRefPlanePoints(NULL)
52  , fPmtPoints(NULL)
53  , fRichProjections(NULL)
54  , fTrackParams(NULL)
55  , fRichRingMatches(NULL)
56  , fStsTrackMatches(NULL)
57  , fTrackCenterDistanceIdeal(0)
58  , fTrackCenterDistanceCorrected(0)
59  , fTrackCenterDistanceUncorrected(0)
60  , fCorrectionMatching("")
61  , fThreshold(0)
62  , fOutputDir("")
63  , fCorrectionTableDir("")
64  , fStudyName("") {}
65 
67 
69  FairRootManager* manager = FairRootManager::Instance();
70 
71  fGlobalTracks = (TClonesArray*) manager->GetObject("GlobalTrack");
72  if (NULL == fGlobalTracks) {
73  Fatal("CbmRichMirrorSortingCorrection::Init", "No GlobalTrack array!");
74  }
75 
76  fRichRings = (TClonesArray*) manager->GetObject("RichRing");
77  if (NULL == fRichRings) {
78  Fatal("CbmRichMirrorSortingCorrection::Init", "No RichRing array !");
79  }
80 
81  fMCTracks = (TClonesArray*) manager->GetObject("MCTrack");
82  if (NULL == fMCTracks) {
83  Fatal("CbmRichMirrorSortingCorrection::Init", "No MCTracks array !");
84  }
85 
86  fMirrorPoints = (TClonesArray*) manager->GetObject("RichMirrorPoint");
87  if (NULL == fMirrorPoints) {
88  Fatal("CbmRichMirrorSortingCorrection::Init",
89  "No RichMirrorPoints array !");
90  }
91 
92  fRefPlanePoints = (TClonesArray*) manager->GetObject("RefPlanePoint");
93  if (NULL == fRefPlanePoints) {
94  Fatal("CbmRichMirrorSortingCorrection::Init",
95  "No RichRefPlanePoint array !");
96  }
97 
98  fPmtPoints = (TClonesArray*) manager->GetObject("RichPoint");
99  if (NULL == fPmtPoints) {
100  Fatal("CbmRichMirrorSortingCorrection::Init", "No RichPoint array !");
101  }
102 
103  fRichProjections = (TClonesArray*) manager->GetObject("RichProjection");
104  if (NULL == fRichProjections) {
105  Fatal("CbmRichMirrorSortingCorrection::Init", "No RichProjection array !");
106  }
107 
108  fTrackParams = (TClonesArray*) manager->GetObject("RichTrackParamZ");
109  if (NULL == fTrackParams) {
110  Fatal("CbmRichMirrorSortingCorrection::Init", "No RichTrackParamZ array!");
111  }
112 
113  fRichRingMatches = (TClonesArray*) manager->GetObject("RichRingMatch");
114  if (NULL == fRichRingMatches) {
115  Fatal("CbmRichMirrorSortingCorrection::Init", "No RichRingMatch array!");
116  }
117 
118  fStsTrackMatches = (TClonesArray*) manager->GetObject("StsTrackMatch");
119  if (NULL == fStsTrackMatches) {
120  Fatal("CbmRichMirrorSortingCorrection::Init", "No StsTrackMatch array!");
121  }
122 
126 
128 
129  InitHistoMap();
130 
131  return kSUCCESS;
132 }
133 
135  fHM = new CbmHistManager();
136 
137  Double_t upperScaleLimit = 6., bin = 400.;
138  // fhDistance => fhDistanceCenterToExtrapolatedTrack.
139  fHM->Create1<TH1D>("fhDistanceCenterToExtrapolatedTrack",
140  "fhDistanceCenterToExtrapolatedTrack;Distance fitted "
141  "center to extrapolated track;Number of entries",
142  bin,
143  0.,
144  upperScaleLimit);
145  fHM->Create1<TH1D>("fhDistanceCorrected",
146  "fhDistanceCorrected;Distance a [cm];A.U.",
147  bin,
148  0.,
149  upperScaleLimit);
150  fHM->Create1<TH1D>(
151  "fhDifferenceX",
152  "fhDifferenceX;Difference in X (fitted center - extrapolated track);A.U.",
153  bin,
154  -upperScaleLimit,
155  upperScaleLimit);
156  fHM->Create1<TH1D>(
157  "fhDifferenceY",
158  "fhDifferenceY;Difference in Y (fitted center - extrapolated track);A.U.",
159  bin,
160  -upperScaleLimit,
161  upperScaleLimit);
162 
163  fHM->Create1<TH1D>("fhDistanceUncorrected",
164  "fhDistanceUncorrected;Distance a [cm];A.U.",
165  bin,
166  0.,
167  upperScaleLimit);
168  fHM->Create1<TH1D>(
169  "fhDifferenceXUncorrected",
170  "fhDifferenceXUncorrected;Difference in X uncorrected [cm];A.U.",
171  bin,
172  -upperScaleLimit,
173  upperScaleLimit);
174  fHM->Create1<TH1D>(
175  "fhDifferenceYUncorrected",
176  "fhDifferenceYUncorrected;Difference in Y uncorrected [cm];A.U.",
177  bin,
178  -upperScaleLimit,
179  upperScaleLimit);
180 
181  fHM->Create1<TH1D>("fhDistanceIdeal",
182  "fhDistanceIdeal;Distance a [cm];A.U.",
183  bin,
184  0.,
185  upperScaleLimit);
186  fHM->Create1<TH1D>("fhDifferenceXIdeal",
187  "fhDifferenceXIdeal;Difference in X ideal [cm];A.U.",
188  bin,
189  -upperScaleLimit,
190  upperScaleLimit);
191  fHM->Create1<TH1D>("fhDifferenceYIdeal",
192  "fhDifferenceYIdeal;Difference in Y ideal [cm];A.U.",
193  bin,
194  -upperScaleLimit,
195  upperScaleLimit);
196 
197  fHM->Create1<TH1D>("fHistoDiffX",
198  "fHistoDiffX;Histogram difference between corrected and "
199  "ideal X positions;A.U.",
200  bin,
201  0.,
202  upperScaleLimit);
203  fHM->Create1<TH1D>("fHistoDiffY",
204  "fHistoDiffY;Histogram difference between corrected and "
205  "ideal Y positions;A.U.",
206  bin,
207  0.,
208  upperScaleLimit);
209 
210  fHM->Create1<TH1D>("fHistoBoA",
211  "fHistoBoA;Histogram B axis over A axis;A.U.",
212  bin,
213  0.,
214  upperScaleLimit);
215 }
216 
218  //fHM2 = new CbmHistManager();
219  Double_t upperScaleLimit = 6., bin = 400.;
220  TString strCorrX = "fhDifferenceCorrectedX_mirror_tile_",
221  strCorrY = "fhDifferenceCorrectedY_mirror_tile_",
222  strDiffCorrX = "DiffCorrX_mirror_tile_",
223  strDiffCorrY = "DiffCorrY_mirror_tile_";
224  stringstream ssDiffCorrX, ssDiffCorrY, ssCorrX, ssCorrY;
225  TString strUncorrX = "fhDifferenceUncorrectedX_mirror_tile_",
226  strUncorrY = "fhDifferenceUncorrectedY_mirror_tile_",
227  strDiffUncorrX = "DiffUncorrX_mirror_tile_",
228  strDiffUncorrY = "DiffUncorrY_mirror_tile_";
229  stringstream ssDiffUncorrX, ssDiffUncorrY, ssUncorrX, ssUncorrY;
230  TString strIdealX = "fhDifferenceIdealX_mirror_tile_",
231  strIdealY = "fhDifferenceIdealY_mirror_tile_",
232  strDiffIdealX = "DiffIdealX_mirror_tile_",
233  strDiffIdealY = "DiffIdealY_mirror_tile_";
234  stringstream ssDiffIdealX, ssDiffIdealY, ssIdealX, ssIdealY;
235 
236  cout << endl << "Init histo: " << endl << endl;
237  for (Int_t j = 0; j < 4; j++) {
238  for (Int_t i = 0; i < 10; i++) {
239  ssDiffCorrX << strDiffCorrX << j << "_" << i;
240  ssDiffCorrY << strDiffCorrY << j << "_" << i;
241  ssCorrX << strCorrX << j << "_" << i;
242  ssCorrY << strCorrY << j << "_" << i;
243  fDiffHistoMap[ssDiffCorrX.str().c_str()] =
244  new TH1D(ssCorrX.str().c_str(),
245  ";Difference in X (fitted center - extrapolated track);A.U.",
246  bin,
247  0.,
248  upperScaleLimit);
249  fDiffHistoMap[ssDiffCorrY.str().c_str()] =
250  new TH1D(ssCorrY.str().c_str(),
251  ";Difference in Y (fitted center - extrapolated track);A.U.",
252  bin,
253  0.,
254  upperScaleLimit);
255 
256  ssDiffUncorrX << strDiffUncorrX << j << "_" << i;
257  ssDiffUncorrY << strDiffUncorrY << j << "_" << i;
258  ssUncorrX << strUncorrX << j << "_" << i;
259  ssUncorrY << strUncorrY << j << "_" << i;
260  fDiffHistoMap[ssDiffUncorrX.str().c_str()] =
261  new TH1D(ssUncorrX.str().c_str(),
262  ";Difference in X (fitted center - extrapolated track);A.U.",
263  bin,
264  0.,
265  upperScaleLimit);
266  fDiffHistoMap[ssDiffUncorrY.str().c_str()] =
267  new TH1D(ssUncorrY.str().c_str(),
268  ";Difference in Y (fitted center - extrapolated track);A.U.",
269  bin,
270  0.,
271  upperScaleLimit);
272 
273  ssDiffIdealX << strDiffIdealX << j << "_" << i;
274  ssDiffIdealY << strDiffIdealY << j << "_" << i;
275  ssIdealX << strIdealX << j << "_" << i;
276  ssIdealY << strIdealY << j << "_" << i;
277  fDiffHistoMap[ssDiffIdealX.str().c_str()] =
278  new TH1D(ssIdealX.str().c_str(),
279  ";Difference in X (fitted center - extrapolated track);A.U.",
280  bin,
281  0.,
282  upperScaleLimit);
283  fDiffHistoMap[ssDiffIdealY.str().c_str()] =
284  new TH1D(ssIdealY.str().c_str(),
285  ";Difference in Y (fitted center - extrapolated track);A.U.",
286  bin,
287  0.,
288  upperScaleLimit);
289 
290  // cout << "CorrX: " << ssDiffCorrX.str().c_str() << ", " << ssCorrX.str().c_str() << endl << "UncorrX: " << ssDiffUncorrX.str().c_str() << ", " <<
291  // ssUncorrX.str().c_str() << endl << "IdealX: " << ssDiffIdealX.str().c_str() << ", " << ssIdealX.str().c_str() << endl << endl;
292 
293  ssDiffCorrX.str("");
294  ssCorrX.str("");
295  ssDiffCorrY.str("");
296  ssCorrY.str("");
297  ssDiffUncorrX.str("");
298  ssUncorrX.str("");
299  ssDiffUncorrY.str("");
300  ssUncorrY.str("");
301  ssDiffIdealX.str("");
302  ssIdealX.str("");
303  ssDiffIdealY.str("");
304  ssIdealY.str("");
305  }
306  }
307 
308  //fHM = new CbmHistManager();
309  Double_t xMin = -120., xMax = 120., nBinsX1 = 60, yMax = 200., range = 3.;
310  stringstream ss;
311 
312  for (Int_t k = 1; k < 3; k++) {
313  ss << k;
314  fHM->Create3<TH3D>("fhRingTrackDistVsXYTruematch" + ss.str(),
315  "fhRingTrackDistVsXYTruematch" + ss.str()
316  + ";X [cm];Y [cm];Ring-track distance [cm]",
317  60,
318  xMin,
319  xMax,
320  104,
321  110.,
322  200.,
323  100,
324  0.,
325  5.);
326  fHM->Create2<TH2D>("fhRingTrackDistVsXTruematch" + ss.str(),
327  "fhRingTrackDistVsXTruematch" + ss.str()
328  + ";X [cm];Ring-track distance [cm]",
329  nBinsX1,
330  xMin,
331  xMax,
332  100,
333  0.,
334  5.);
335  fHM->Create2<TH2D>("fhRingTrackDistVsYTruematch" + ss.str(),
336  "fhRingTrackDistVsYTruematch" + ss.str()
337  + ";Abs(Y) [cm];Ring-track distance [cm]",
338  34,
339  110.,
340  yMax,
341  100,
342  0.,
343  5.);
344  fHM->Create3<TH3D>("fhRingTrackDistDiffXRingVsXYTruematch" + ss.str(),
345  "fhRingTrackDistDiffXRingVsXYTruematch" + ss.str()
346  + ";X [cm];Y [cm];X Ring-track distance [cm]",
347  60,
348  xMin,
349  xMax,
350  104,
351  110,
352  200,
353  200,
354  -range,
355  range);
356  fHM->Create3<TH3D>("fhRingTrackDistDiffYRingVsXYTruematch" + ss.str(),
357  "fhRingTrackDistDiffYRingVsXYTruematch" + ss.str()
358  + ";X [cm];Y [cm];Y Ring-track distance [cm]",
359  60,
360  xMin,
361  xMax,
362  104,
363  110,
364  200,
365  200,
366  -range,
367  range);
368  ss.str("");
369  }
370 
371  fHM->Create1<TH1D>("fDistUncorr",
372  "fDistUncorr;Uncorrected Distance;Number of entries",
373  600,
374  -10.,
375  10);
376  fHM->Create1<TH1D>("fDistCorr",
377  "fDistCorr;Corrected Distance;Number of entries",
378  600,
379  -10.,
380  10);
381 
382  /*
383 // Double_t upperScaleLimit = 6., bin = 400.;
384  fDiffHistoMap["DiffCorrX_mirror_tile_2_8"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_2_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
385  fDiffHistoMap["DiffCorrY_mirror_tile_2_8"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_2_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
386  fDiffHistoMap["DiffUncorrX_mirror_tile_2_8"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_2_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
387  fDiffHistoMap["DiffUncorrY_mirror_tile_2_8"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_2_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
388  fDiffHistoMap["DiffIdealX_mirror_tile_2_8"] = new TH1D("fhDifferenceIdealX_mirror_tile_2_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
389  fDiffHistoMap["DiffIdealY_mirror_tile_2_8"] = new TH1D("fhDifferenceIdealY_mirror_tile_2_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
390 
391  fDiffHistoMap["DiffCorrX_mirror_tile_1_3"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_1_3", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
392  fDiffHistoMap["DiffCorrY_mirror_tile_1_3"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_1_3", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
393  fDiffHistoMap["DiffUncorrX_mirror_tile_1_3"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_1_3", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
394  fDiffHistoMap["DiffUncorrY_mirror_tile_1_3"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_1_3", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
395  fDiffHistoMap["DiffIdealX_mirror_tile_1_3"] = new TH1D("fhDifferenceIdealX_mirror_tile_1_3", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
396  fDiffHistoMap["DiffIdealY_mirror_tile_1_3"] = new TH1D("fhDifferenceIdealY_mirror_tile_1_3", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
397 
398  fDiffHistoMap["DiffCorrX_mirror_tile_1_4"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_1_4", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
399  fDiffHistoMap["DiffCorrY_mirror_tile_1_4"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_1_4", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
400  fDiffHistoMap["DiffUncorrX_mirror_tile_1_4"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_1_4", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
401  fDiffHistoMap["DiffUncorrY_mirror_tile_1_4"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_1_4", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
402  fDiffHistoMap["DiffIdealX_mirror_tile_1_4"] = new TH1D("fhDifferenceIdealX_mirror_tile_1_4", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
403  fDiffHistoMap["DiffIdealY_mirror_tile_1_4"] = new TH1D("fhDifferenceIdealY_mirror_tile_1_4", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
404 
405  fDiffHistoMap["DiffCorrX_mirror_tile_0_8"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_0_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
406  fDiffHistoMap["DiffCorrY_mirror_tile_0_8"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_0_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
407  fDiffHistoMap["DiffUncorrX_mirror_tile_0_8"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_0_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
408  fDiffHistoMap["DiffUncorrY_mirror_tile_0_8"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_0_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
409  fDiffHistoMap["DiffIdealX_mirror_tile_0_8"] = new TH1D("fhDifferenceIdealX_mirror_tile_0_8", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
410  fDiffHistoMap["DiffIdealY_mirror_tile_0_8"] = new TH1D("fhDifferenceIdealY_mirror_tile_0_8", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
411 
412  fDiffHistoMap["DiffCorrX_mirror_tile_1_5"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_1_5", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
413  fDiffHistoMap["DiffCorrY_mirror_tile_1_5"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_1_5", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
414  fDiffHistoMap["DiffUncorrX_mirror_tile_1_5"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_1_5", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
415  fDiffHistoMap["DiffUncorrY_mirror_tile_1_5"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_1_5", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
416  fDiffHistoMap["DiffIdealX_mirror_tile_1_5"] = new TH1D("fhDifferenceIdealX_mirror_tile_1_5", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
417  fDiffHistoMap["DiffIdealY_mirror_tile_1_5"] = new TH1D("fhDifferenceIdealY_mirror_tile_1_5", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
418 
419  fDiffHistoMap["DiffCorrX_mirror_tile_0_1"] = new TH1D("fhDifferenceCorrectedX_mirror_tile_0_1", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
420  fDiffHistoMap["DiffCorrY_mirror_tile_0_1"] = new TH1D("fhDifferenceCorrectedY_mirror_tile_0_1", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
421  fDiffHistoMap["DiffUncorrX_mirror_tile_0_1"] = new TH1D("fhDifferenceUncorrectedX_mirror_tile_0_1", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
422  fDiffHistoMap["DiffUncorrY_mirror_tile_0_1"] = new TH1D("fhDifferenceUncorrectedY_mirror_tile_0_1", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
423  fDiffHistoMap["DiffIdealX_mirror_tile_0_1"] = new TH1D("fhDifferenceIdealX_mirror_tile_0_1", ";Difference in X (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
424  fDiffHistoMap["DiffIdealY_mirror_tile_0_1"] = new TH1D("fhDifferenceIdealY_mirror_tile_0_1", ";Difference in Y (fitted center - extrapolated track);A.U.", bin, 0., upperScaleLimit);
425 */
426 
427  /*fDiffHistoMap["fhDifferenceX_mirror_tile_2_8"] = "X_mirror_tile_2_8";
428  fDiffHistoMap["fhDifferenceY_mirror_tile_2_8"] = "Y_mirror_tile_2_8";
429  fDiffHistoMap["fhDifferenceX_mirror_tile_1_3"] = "X_mirror_tile_1_3";
430  fDiffHistoMap["fhDifferenceY_mirror_tile_1_3"] = "Y_mirror_tile_1_3";
431  fDiffHistoMap["fhDifferenceX_mirror_tile_1_4"] = "X_mirror_tile_1_4";
432  fDiffHistoMap["fhDifferenceY_mirror_tile_1_4"] = "Y_mirror_tile_1_4";
433 
434  for (std::map<string,string>::iterator it=fDiffHistoMap.begin(); it!=fDiffHistoMap.end(); ++it) { // Initialize all the histograms, using map IDs as inputs.
435  cout << "first: " << it->first << " and second: " << it->second << endl;
436  fHM2->Create1<TH1D>(it->first, it->first + ";Difference in X (fitted center - extrapolated track);A.U.", bin, -upperScaleLimit, upperScaleLimit);
437  }*/
438 }
439 
440 void CbmRichMirrorSortingCorrection::Exec(Option_t* Option) {
441  fEventNb++;
442  cout << "CbmRichMirrorSortingCorrection: Event #" << fEventNb << endl;
443  TVector3 momentum, outPos, outPosUnCorr, outPosIdeal;
444  Double_t constantePMT = 0., trackX = 0., trackY = 0.;
445  vector<Double_t> vect(2, 0), ptM(3, 0), ptC(3, 0), ptCIdeal(3, 0), ptR1(3, 0),
446  ptR2Center(3, 0), ptR2Mirr(3, 0), ptPR2(3, 0), ptPMirr(3, 0),
447  normalPMT(3, 0);
448  vector<Double_t> ptR2CenterUnCorr(3, 0), ptR2CenterIdeal(3, 0),
449  ptR2MirrUnCorr(3, 0), ptR2MirrIdeal(3, 0), ptPMirrUnCorr(3, 0),
450  ptPMirrIdeal(3, 0), ptPR2UnCorr(3, 0), ptPR2Ideal(3, 0);
451  ptC[0] = 0.;
452  ptC.at(0) = 0., ptC.at(1) = 132.594000, ptC.at(2) = 54.267226;
453  TVector3 mirrorPoint, dirCos, pos;
454  Double_t nx = 0., ny = 0., nz = 0.;
455  TGeoNode* mirrNode;
456  CbmRichPoint *mirrPoint, *refPlanePoint;
457 
458  if (fRichRings->GetEntries() != 0) {
459  cout << "Nb of rings in evt = " << fRichRings->GetEntries() << endl << endl;
460  GetPmtNormal(fPmtPoints->GetEntries(), normalPMT, constantePMT);
461  //cout << "Calculated normal vector to PMT plane = {" << normalPMT.at(0) << ", " << normalPMT.at(1) << ", " << normalPMT.at(2) << "} and constante d = " << constantePMT << endl;
462 
463  for (Int_t iGlobalTrack = 0; iGlobalTrack < fGlobalTracks->GetEntriesFast();
464  iGlobalTrack++) {
465  // ----- PART 1 ----- //
466  // Ring-Track matching + Ring fit + Track momentum:
467  CbmGlobalTrack* gTrack =
468  (CbmGlobalTrack*) fGlobalTracks->At(iGlobalTrack);
469  Int_t richInd = gTrack->GetRichRingIndex();
470  Int_t stsInd = gTrack->GetStsTrackIndex();
471  //cout << "richInd: " << richInd << endl;
472  if (richInd < 0) {
473  cout << "Error richInd < 0" << endl;
474  continue;
475  }
476  CbmRichRing* ring = (CbmRichRing*) fRichRings->At(richInd);
477  if (ring == NULL) {
478  cout << "Error ring == NULL!" << endl;
479  continue;
480  }
481  //Int_t ringTrackID = ring->GetTrackID(); //Old code not working with changes for new matching method.
482  //cout << "ringTrackID: " << ringTrackID << endl;
483  CbmTrackMatchNew* cbmRichTrackMatch =
484  (CbmTrackMatchNew*) fRichRingMatches->At(richInd);
485  CbmTrackMatchNew* cbmStsTrackMatch =
486  (CbmTrackMatchNew*) fStsTrackMatches->At(stsInd);
487  if (NULL == cbmRichTrackMatch) { continue; }
488  cout << "Nof true hits = " << cbmRichTrackMatch->GetNofTrueHits() << endl;
489  cout << "Nof wrong hits = " << cbmRichTrackMatch->GetNofWrongHits()
490  << endl;
491  Int_t mcRichTrackId = cbmRichTrackMatch->GetMatchedLink().GetIndex();
492  Int_t mcStsTrackId = cbmStsTrackMatch->GetMatchedLink().GetIndex();
493  //cout << "mcTrackId: " << mcRichTrackId << endl;
494  if (mcRichTrackId < 0) continue;
495  //if (mcStsTrackId != ringTrackID) { //Old code not working with changes for new matching method.
496  if (mcStsTrackId != mcRichTrackId) {
497  cout << "Error StsTrackIndex and TrackIndex from Ring do not match!"
498  << endl;
499  continue;
500  }
501  CbmMCTrack* mcTrack = (CbmMCTrack*) fMCTracks->At(mcRichTrackId);
502  if (!mcTrack) continue;
503  CbmMCTrack* mcTrack2 = (CbmMCTrack*) fMCTracks->At(mcStsTrackId);
504 
505  CbmRichRingLight ringL;
507  fCopFit->DoFit(&ringL);
508  //fTauFit->DoFit(&ringL);
509  cout << "ring Center Coo: " << ringL.GetCenterX() << ", "
510  << ringL.GetCenterY() << endl;
511  mcTrack->GetMomentum(momentum);
512  //FairTrackParam* pTrack = (FairTrackParam*) fRichProjections->At(ringTrackID); //Old code not working with changes for new matching method.
513  FairTrackParam* pTrack = (FairTrackParam*) fRichProjections->At(stsInd);
514  if (pTrack == NULL) {
515  cout << "CbmRichMirrorSortingCorrection::Exec : pTrack = NULL." << endl;
516  continue;
517  }
518  trackX = pTrack->GetX(), trackY = pTrack->GetY();
519  cout << "Track: " << trackX << ", " << trackY << endl;
520 
521  // ----- PART 2 ----- //
522  // Mirror ID via TGeoNavigator + Extrap hit:
523  Int_t trackMotherId = mcTrack->GetMotherId();
524  Int_t pdg = TMath::Abs(mcTrack->GetPdgCode());
525  if (trackMotherId == -1) {
526  if (fMirrorPoints->GetEntries() > 0) {
527  //loop on mirrorPoint and compare w/ TrackID->GetTrackId to get correct one
528  for (Int_t iMirrPt = 0; iMirrPt < fMirrorPoints->GetEntries();
529  iMirrPt++) {
530  mirrPoint = (CbmRichPoint*) fMirrorPoints->At(iMirrPt);
531  if (mirrPoint == 0) { continue; }
532  //cout << "Mirror point track ID: " << mirrPoint->GetTrackID() << endl;
533  if (mirrPoint->GetTrackID() == mcRichTrackId) { break; }
534  }
535  ptM.at(0) = mirrPoint->GetX(), ptM.at(1) = mirrPoint->GetY(),
536  ptM.at(2) = mirrPoint->GetZ();
537  //cout << "mirrPoint: {" << mirrPoint->GetX() << ", " << mirrPoint->GetY() << ", " << mirrPoint->GetZ() << "}" << endl;
538  mirrNode = gGeoManager->FindNode(ptM.at(0), ptM.at(1), ptM.at(2));
539  //cout << "Mirror node name: " << mirrNode->GetName() << " and full path " << gGeoManager->GetPath() << endl;
540  string str1 = gGeoManager->GetPath(), str2 = "mirror_tile_",
541  str3 = "";
542  std::size_t found = str1.find(str2);
543  if (found != std::string::npos) {
544  //cout << "first 'mirror_tile_type' found at: " << found << '\n';
545  Int_t end = str2.length() + 3;
546  str3 = str1.substr(found, end);
547  }
548  cout << "Mirror ID: " << str3 << endl;
549 
550  if (mirrNode) {
551  TGeoNavigator* navi = gGeoManager->GetCurrentNavigator();
552  //cout << "Navigator path: " << navi->GetPath() << endl;
553  ptCIdeal.at(0) = navi->GetCurrentMatrix()->GetTranslation()[0];
554  ptCIdeal.at(1) = navi->GetCurrentMatrix()->GetTranslation()[1];
555  ptCIdeal.at(2) = navi->GetCurrentMatrix()->GetTranslation()[2];
556  cout << "Sphere center coordinates of the aligned mirror tile, "
557  "ideal = {"
558  << ptCIdeal.at(0) << ", " << ptCIdeal.at(1) << ", "
559  << ptCIdeal.at(2) << "}" << endl;
560  for (Int_t iRefPt = 0; iRefPt < fRefPlanePoints->GetEntries();
561  iRefPt++) {
562  refPlanePoint = (CbmRichPoint*) fRefPlanePoints->At(iRefPt);
563  //cout << "Refl plane point track ID: " << refPlanePoint->GetTrackID() << endl;
564  if (refPlanePoint->GetTrackID() == mcRichTrackId) { break; }
565  }
566  ptR1.at(0) = refPlanePoint->GetX(),
567  ptR1.at(1) = refPlanePoint->GetY(),
568  ptR1.at(2) = refPlanePoint->GetZ();
569  cout << "Refl plane point coo = {" << ptR1[0] << ", " << ptR1[1]
570  << ", " << ptR1[2] << "}" << endl;
571  ComputeR2(
572  ptR2Center, ptR2Mirr, ptM, ptC, ptR1, navi, "Corrected", str3);
573  ComputeR2(ptR2CenterUnCorr,
574  ptR2MirrUnCorr,
575  ptM,
576  ptC,
577  ptR1,
578  navi,
579  "Uncorrected",
580  str3);
581  ComputeR2(ptR2CenterIdeal,
582  ptR2MirrIdeal,
583  ptM,
584  ptCIdeal,
585  ptR1,
586  navi,
587  "Uncorrected",
588  str3);
589  ComputeP(ptPMirr, ptPR2, normalPMT, ptM, ptR2Mirr, constantePMT);
590  ComputeP(ptPMirrUnCorr,
591  ptPR2UnCorr,
592  normalPMT,
593  ptM,
594  ptR2MirrUnCorr,
595  constantePMT);
596  ComputeP(ptPMirrIdeal,
597  ptPR2Ideal,
598  normalPMT,
599  ptM,
600  ptR2MirrIdeal,
601  constantePMT);
602  cout << "PMT points mirr coordinates before rotation = {"
603  << ptPMirr[0] << ", " << ptPMirr[1] << ", " << ptPMirr[2]
604  << "}" << endl;
605  cout << "PMT points mirr uncorr coordinates before rotation = {"
606  << ptPMirrUnCorr[0] << ", " << ptPMirrUnCorr[1] << ", "
607  << ptPMirrUnCorr[2] << "}" << endl;
608  cout << "PMT points mirr ideal coordinates before rotation = {"
609  << ptPMirrIdeal[0] << ", " << ptPMirrIdeal[1] << ", "
610  << ptPMirrIdeal[2] << "}" << endl;
611 
612  TVector3 inPos(ptPMirr.at(0), ptPMirr.at(1), ptPMirr.at(2));
613  CbmRichGeoManager::GetInstance().RotatePoint(&inPos, &outPos);
614  cout << endl
615  << "New PMT points coordinates = {" << outPos.x() << ", "
616  << outPos.y() << ", " << outPos.z() << "}" << endl;
617  TVector3 inPosUnCorr(
618  ptPMirrUnCorr.at(0), ptPMirrUnCorr.at(1), ptPMirrUnCorr.at(2));
620  &outPosUnCorr);
621  cout << "New mirror points coordinates = {" << outPosUnCorr.x()
622  << ", " << outPosUnCorr.y() << ", " << outPosUnCorr.z() << "}"
623  << endl;
624  TVector3 inPosIdeal(
625  ptPMirrIdeal.at(0), ptPMirrIdeal.at(1), ptPMirrIdeal.at(2));
627  &outPosIdeal);
628  cout << "New mirror points coordinates = {" << outPosIdeal.x()
629  << ", " << outPosIdeal.y() << ", " << outPosIdeal.z() << "}"
630  << endl
631  << endl;
632 
633  cout << "pTrack [X,Y]: " << pTrack->GetX() << ", " << pTrack->GetY()
634  << endl;
635  if (fCorrectionMatching == "standard") {
636  pTrack->SetX(outPosUnCorr.x());
637  pTrack->SetY(outPosUnCorr.y());
638  } else if (fCorrectionMatching == "correction") {
639  pTrack->SetX(outPos.x());
640  pTrack->SetY(outPos.y());
641  } else if (fCorrectionMatching == "ideal") {
642  pTrack->SetX(outPosIdeal.x());
643  pTrack->SetY(outPosIdeal.y());
644  }
645 
646  FillHistProjection(outPosIdeal,
647  outPosUnCorr,
648  outPos,
649  ringL,
650  normalPMT,
651  constantePMT,
652  str3);
653 
654  cout << "pTrack [X,Y]: " << pTrack->GetX() << ", " << pTrack->GetY()
655  << endl;
656  FillRingTrackDistanceCorr(ring, pTrack, mcTrack2);
657  }
658  } else {
659  cout << "No mirror points registered." << endl;
660  }
661  } else {
662  cout << "Not a mother particle." << endl;
663  }
664  //ComputeAngles();
665  }
666  } else {
667  cout << "CbmRichMirrorSortingCorrection::Exec No rings in event were found."
668  << endl;
669  }
670 
672 }
673 
675  vector<Double_t>& normalPMT,
676  Double_t& normalCste) {
677  //cout << endl << "//------------------------------ CbmRichMirrorSortingAlignment: Calculate PMT Normal ------------------------------//" << endl << endl;
678 
679  Int_t pmtTrackID, pmtMotherID;
680  Double_t buffNormX = 0., buffNormY = 0., buffNormZ = 0., k = 0.,
681  scalarProd = 0.;
682  Double_t pmtPt[] = {0., 0., 0.};
683  Double_t a[] = {0., 0., 0.}, b[] = {0., 0., 0.}, c[] = {0., 0., 0.};
684  CbmMCTrack* track;
685 
686  /*
687  * Selection of three points (A, B, C), which form a plan and from which the calculation of the normal of the plan can be computed.
688  * Formula used is: vect(AB) x vect(AC) = normal.
689  * Normalize the normal vector obtained and check with three random points from the PMT plane, whether the scalar product is equal to zero.
690  */
691  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
692  CbmRichPoint* pmtPoint = (CbmRichPoint*) fPmtPoints->At(iPmt);
693  pmtTrackID = pmtPoint->GetTrackID();
694  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
695  pmtMotherID = track->GetMotherId();
696  a[0] = pmtPoint->GetX(), a[1] = pmtPoint->GetY(), a[2] = pmtPoint->GetZ();
697  //cout << "a[0] = " << a[0] << ", a[1] = " << a[1] << " et a[2] = " << a[2] << endl;
698  break;
699  }
700  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
701  CbmRichPoint* pmtPoint = (CbmRichPoint*) fPmtPoints->At(iPmt);
702  pmtTrackID = pmtPoint->GetTrackID();
703  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
704  pmtMotherID = track->GetMotherId();
705  //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
706  if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2)
707  + TMath::Power(a[1] - pmtPoint->GetY(), 2)
708  + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
709  > 7) {
710  b[0] = pmtPoint->GetX(), b[1] = pmtPoint->GetY(), b[2] = pmtPoint->GetZ();
711  //cout << "b[0] = " << b[0] << ", b[1] = " << b[1] << " et b[2] = " << b[2] << endl;
712  break;
713  }
714  }
715  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
716  CbmRichPoint* pmtPoint = (CbmRichPoint*) fPmtPoints->At(iPmt);
717  pmtTrackID = pmtPoint->GetTrackID();
718  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
719  pmtMotherID = track->GetMotherId();
720  //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
721  if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2)
722  + TMath::Power(a[1] - pmtPoint->GetY(), 2)
723  + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
724  > 7
725  && TMath::Sqrt(TMath::Power(b[0] - pmtPoint->GetX(), 2)
726  + TMath::Power(b[1] - pmtPoint->GetY(), 2)
727  + TMath::Power(b[2] - pmtPoint->GetZ(), 2))
728  > 7) {
729  c[0] = pmtPoint->GetX(), c[1] = pmtPoint->GetY(), c[2] = pmtPoint->GetZ();
730  //cout << "c[0] = " << c[0] << ", c[1] = " << c[1] << " et c[2] = " << c[2] << endl;
731  break;
732  }
733  }
734 
735  k = (b[0] - a[0]) / (c[0] - a[0]);
736  if ((b[1] - a[1]) - (k * (c[1] - a[1])) == 0
737  || (b[2] - a[2]) - (k * (c[2] - a[2])) == 0) {
738  cout << "Error in normal calculation, vect_AB and vect_AC are collinear."
739  << endl;
740  } else {
741  buffNormX = (b[1] - a[1]) * (c[2] - a[2]) - (b[2] - a[2]) * (c[1] - a[1]);
742  buffNormY = (b[2] - a[2]) * (c[0] - a[0]) - (b[0] - a[0]) * (c[2] - a[2]);
743  buffNormZ = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
744  normalPMT.at(0) =
745  buffNormX
746  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
747  + TMath::Power(buffNormZ, 2));
748  normalPMT.at(1) =
749  buffNormY
750  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
751  + TMath::Power(buffNormZ, 2));
752  normalPMT.at(2) =
753  buffNormZ
754  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
755  + TMath::Power(buffNormZ, 2));
756  }
757 
758  CbmRichPoint* pmtPoint1 = (CbmRichPoint*) fPmtPoints->At(20);
759  scalarProd = normalPMT.at(0) * (pmtPoint1->GetX() - a[0])
760  + normalPMT.at(1) * (pmtPoint1->GetY() - a[1])
761  + normalPMT.at(2) * (pmtPoint1->GetZ() - a[2]);
762  //cout << "1st scalar product between vectAM and normale = " << scalarProd << endl;
763  // To determine the constant term of the plane equation, inject the coordinates of a pmt point, which should solve it: a*x+b*y+c*z+d=0.
764  normalCste =
765  -1
766  * (normalPMT.at(0) * pmtPoint1->GetX() + normalPMT.at(1) * pmtPoint1->GetY()
767  + normalPMT.at(2) * pmtPoint1->GetZ());
768  CbmRichPoint* pmtPoint2 = (CbmRichPoint*) fPmtPoints->At(15);
769  scalarProd = normalPMT.at(0) * (pmtPoint2->GetX() - a[0])
770  + normalPMT.at(1) * (pmtPoint2->GetY() - a[1])
771  + normalPMT.at(2) * (pmtPoint2->GetZ() - a[2]);
772  //cout << "2nd scalar product between vectAM and normale = " << scalarProd << endl;
773  CbmRichPoint* pmtPoint3 = (CbmRichPoint*) fPmtPoints->At(25);
774  scalarProd = normalPMT.at(0) * (pmtPoint3->GetX() - a[0])
775  + normalPMT.at(1) * (pmtPoint3->GetY() - a[1])
776  + normalPMT.at(2) * (pmtPoint3->GetZ() - a[2]);
777  //cout << "3nd scalar product between vectAM and normale = " << scalarProd << endl;
778 }
779 
780 void CbmRichMirrorSortingCorrection::ComputeR2(vector<Double_t>& ptR2Center,
781  vector<Double_t>& ptR2Mirr,
782  vector<Double_t> ptM,
783  vector<Double_t> ptC,
784  vector<Double_t> ptR1,
785  TGeoNavigator* navi,
786  TString option,
787  TString mirrorTileName) {
788  //cout << endl << "//------------------------------ CbmRichCorrection: ComputeR2 ------------------------------//" << endl << endl;
789 
790  vector<Double_t> normalMirr(3), ptCNew(3), ptTileCenter(3);
791  Double_t t1 = 0., t2 = 0., t3 = 0.;
792 
793  if (option == "Corrected") {
794  // Use the correction information from text file, to the tile sphere center:
795  // Reading misalignment information from correction_param.txt text file.
796  Int_t lineCounter = 1, lineIndex = 0;
797  //TString str = fOutputDir + "correction_param_array_" + fStudyName + ".txt";
798  TString str =
799  fCorrectionTableDir + "/correction_table/correction_param_array.txt";
800  string fileLine = "", strMisX = "", strMisY = "";
801  Double_t misX = 0., misY = 0.;
802  ifstream corrFile;
803  corrFile.open(str);
804 
805  /*std::ifstream inFile(corrFile);
806  if(!inFile) {
807  cout << endl << "Failed to open file " << corrFile;
808  return;
809  }
810  double d1 = 0.;
811  double d2 = 0.;
812  while(!inFile.eof()) {
813  inFile >> d1 >> d2;
814  cout << d1 << " " << d2 << endl;;
815  }*/
816 
817  if (corrFile.is_open()) {
818  while (!corrFile.eof()) {
819  getline(corrFile, fileLine);
820  lineIndex = fileLine.find(mirrorTileName, 0);
821  if (lineIndex != string::npos) {
822  //cout << mirrorTileName << " has been found in the file at line: " << lineCounter << " and position: " << lineIndex << "." << endl;
823  break;
824  }
825  lineCounter++;
826  }
827  // getline(corrFile, strMisX);
828  corrFile >> misY;
829  //cout << "number at line: " << lineCounter+2 << " = " << misX << "." << endl;
830  // getline(corrFile, strMisY);
831  corrFile >> misX;
832  //cout << "number at line: " << lineCounter+3 << " = " << misY << "." << endl;
833 
834  /*std::istringstream i1(strMisX);
835  i1 >> misX;
836  std::istringstream i2(strMisY);
837  i2 >> misY;
838  double sum = misX + misY;
839  cout << "x1 = " << misX << ", x2 = " << misY << ", sum = " << sum << endl;*/
840 
841  corrFile.close();
842  } else {
843  cout << "Error in CbmRichCorrection: unable to open parameter file!"
844  << endl;
845  cout << "Parameter file path: " << str << endl << endl;
846  //sleep(5);
847  }
848  //cout << "Misalignment parameters read from file = [" << outputFit.at(0) << " ; " << outputFit.at(1) << " ; " << outputFit.at(2) << " ; " << outputFit.at(3) << "]" << endl;
849 
850  //ptCNew.at(0) = TMath::Abs(ptC.at(0) - TMath::Abs(outputFit.at(3)));
851  //ptCNew.at(1) = TMath::Abs(ptC.at(1) - TMath::Abs(outputFit.at(2)));
852  cout << "Correction parameters = " << misX << ", " << misY << endl;
853  ptCNew.at(0) = ptC.at(0) + misX;
854  ptCNew.at(1) = ptC.at(1) + misY;
855  ptCNew.at(2) = ptC.at(2);
856  ptTileCenter.at(0) = navi->GetMotherMatrix()->GetTranslation()[0];
857  ptTileCenter.at(1) = navi->GetMotherMatrix()->GetTranslation()[1];
858  ptTileCenter.at(2) = navi->GetMotherMatrix()->GetTranslation()[2];
859  //cout << "Mirror tile center coordinates = {" << ptTileCenter.at(0) << ", " << ptTileCenter.at(1) << ", " << ptTileCenter.at(2) << "}" << endl;
860  Double_t x = 0., y = 0., z = 0., dist = 0., dist2 = 0., z2 = 0.;
861  x = TMath::Power(ptCNew.at(0) - ptTileCenter.at(0), 2);
862  y = TMath::Power(ptCNew.at(1) - ptTileCenter.at(1), 2);
863  z = TMath::Power(ptCNew.at(2) - ptTileCenter.at(2), 2);
864  dist = TMath::Sqrt(x + y + z);
865  z2 = ptTileCenter.at(2) - TMath::Sqrt(TMath::Power(300, 2) - x - y)
866  - ptCNew.at(2);
867  //cout << "{x, y, z} = {" << x << ", " << y << ", " << z << "}, dist = " << dist << " and z2 = " << z2 << endl;
868  dist2 = TMath::Sqrt(x + y + TMath::Power(z2 - ptTileCenter.at(2), 2));
869  //cout << "dist2 = " << dist2 << endl;
870  ptCNew.at(2) += z2;
871  cout << "Sphere center coordinates of the rotated mirror tile, after "
872  "correction, = {"
873  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
874  << endl;
875  } else if (option == "Uncorrected") {
876  // Keep the same tile sphere center, with no correction information.
877  ptCNew = ptC;
878  cout << "Sphere center coordinates of the rotated mirror tile, without "
879  "correction = {"
880  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
881  << endl;
882  } else {
883  //cout << "No input given in function ComputeR2! Uncorrected parameters for the sphere center of the tile will be used!" << endl;
884  ptCNew = ptC;
885  //cout << "Sphere center coordinates of the rotated mirror tile, without correction = {" << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}" << endl;
886  }
887 
888  normalMirr.at(0) = (ptCNew.at(0) - ptM.at(0))
889  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
890  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
891  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
892  normalMirr.at(1) = (ptCNew.at(1) - ptM.at(1))
893  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
894  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
895  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
896  normalMirr.at(2) = (ptCNew.at(2) - ptM.at(2))
897  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
898  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
899  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
900  //cout << "Calculated and normalized normal of mirror tile = {" << normalMirr.at(0) << ", " << normalMirr.at(1) << ", " << normalMirr.at(2) << "}" << endl;
901 
902  t1 = ((ptR1.at(0) - ptM.at(0)) * (ptCNew.at(0) - ptM.at(0))
903  + (ptR1.at(1) - ptM.at(1)) * (ptCNew.at(1) - ptM.at(1))
904  + (ptR1.at(2) - ptM.at(2)) * (ptCNew.at(2) - ptM.at(2)))
905  / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
906  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
907  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
908  ptR2Center.at(0) =
909  2 * (ptM.at(0) + t1 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
910  ptR2Center.at(1) =
911  2 * (ptM.at(1) + t1 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
912  ptR2Center.at(2) =
913  2 * (ptM.at(2) + t1 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
914  t2 = ((ptR1.at(0) - ptCNew.at(0)) * (ptCNew.at(0) - ptM.at(0))
915  + (ptR1.at(1) - ptCNew.at(1)) * (ptCNew.at(1) - ptM.at(1))
916  + (ptR1.at(2) - ptCNew.at(2)) * (ptCNew.at(2) - ptM.at(2)))
917  / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
918  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
919  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
920  ptR2Mirr.at(0) =
921  2 * (ptCNew.at(0) + t2 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
922  ptR2Mirr.at(1) =
923  2 * (ptCNew.at(1) + t2 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
924  ptR2Mirr.at(2) =
925  2 * (ptCNew.at(2) + t2 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
926  /*//SAME AS calculation of t2 above
927  t3 = ((ptR1.at(0)-ptCNew.at(0))*(ptCNew.at(0)-ptM.at(0)) + (ptR1.at(1)-ptCNew.at(1))*(ptCNew.at(1)-ptM.at(1)) + (ptR1.at(2)-ptCNew.at(2))*(ptCNew.at(2)-ptM.at(2)))/TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0),2)+TMath::Power(ptCNew.at(1) - ptM.at(1),2)+TMath::Power(ptCNew.at(2) - ptM.at(2),2));
928  reflectedPtCooVectSphereUnity[0] = 2*(ptCNew.at(0)+t3*(normalMirr.at(0)))-ptR1.at(0);
929  reflectedPtCooVectSphereUnity[1] = 2*(ptCNew.at(1)+t3*(normalMirr.at(1)))-ptR1.at(1);
930  reflectedPtCooVectSphereUnity[2] = 2*(ptCNew.at(2)+t3*(normalMirr.at(2)))-ptR1.at(2);*/
931  //cout << "* using mirror point M to define \U00000394: {" << ptR2Center.at(0) << ", " << ptR2Center.at(1) << ", " << ptR2Center.at(2) << "}" << endl;
932  //cout << "Ref Pt Coo using unity Mirror-Sphere vector & sphere pt = {" << reflectedPtCooVectSphereUnity[0] << ", " << reflectedPtCooVectSphereUnity[1] << ", " << reflectedPtCooVectSphereUnity[2] << "}" << endl << endl;
933  //cout << "NofPMTPoints = " << NofPMTPoints << endl;
934 
935  //cout << "Coordinates of point R2 on reflective plane after reflection on the mirror tile:" << endl;
936  //cout << "* using sphere center C to define \U00000394: {" << ptR2Mirr.at(0) << ", " << ptR2Mirr.at(1) << ", " << ptR2Mirr.at(2) << "}" << endl;
937 }
938 
939 void CbmRichMirrorSortingCorrection::ComputeP(vector<Double_t>& ptPMirr,
940  vector<Double_t>& ptPR2,
941  vector<Double_t> normalPMT,
942  vector<Double_t> ptM,
943  vector<Double_t> ptR2Mirr,
944  Double_t constantePMT) {
945  //cout << endl << "//------------------------------ CbmRichCorrection: ComputeP ------------------------------//" << endl << endl;
946 
947  Double_t k1 = 0., k2 = 0., checkCalc1 = 0., checkCalc2 = 0.;
948 
949  k1 = -1
950  * ((normalPMT.at(0) * ptM.at(0) + normalPMT.at(1) * ptM.at(1)
951  + normalPMT.at(2) * ptM.at(2) + constantePMT)
952  / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0))
953  + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
954  + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
955  ptPMirr.at(0) = ptM.at(0) + k1 * (ptR2Mirr.at(0) - ptM.at(0));
956  ptPMirr.at(1) = ptM.at(1) + k1 * (ptR2Mirr.at(1) - ptM.at(1));
957  ptPMirr.at(2) = ptM.at(2) + k1 * (ptR2Mirr.at(2) - ptM.at(2));
958  k2 = -1
959  * ((normalPMT.at(0) * ptR2Mirr.at(0) + normalPMT.at(1) * ptR2Mirr.at(1)
960  + normalPMT.at(2) * ptR2Mirr.at(2) + constantePMT)
961  / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0))
962  + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
963  + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
964  ptPR2.at(0) = ptR2Mirr.at(0) + k2 * (ptR2Mirr.at(0) - ptM.at(0));
965  ptPR2.at(1) = ptR2Mirr.at(1) + k2 * (ptR2Mirr.at(1) - ptM.at(1));
966  ptPR2.at(2) = ptR2Mirr.at(2) + k2 * (ptR2Mirr.at(2) - ptM.at(2));
967  //cout << "Coordinates of point P on PMT plane, after reflection on the mirror tile and extrapolation to the PMT plane:" << endl;
968  //cout << "* using mirror point M to define \U0001D49F ': {" << ptPMirr.at(0) << ", " << ptPMirr.at(1) << ", " << ptPMirr.at(2) << "}" << endl;
969  //cout << "* using reflected point R2 to define \U0001D49F ': {" << ptPR2.at(0) << ", " << ptPR2.at(1) << ", " << ptPR2.at(2) << "}" << endl;
970  checkCalc1 = ptPMirr.at(0) * normalPMT.at(0) + ptPMirr.at(1) * normalPMT.at(1)
971  + ptPMirr.at(2) * normalPMT.at(2) + constantePMT;
972  cout << "Check whether extrapolated track point on PMT plane verifies its "
973  "equation (value should be 0.):"
974  << endl;
975  //cout << "* using mirror point M, checkCalc = " << checkCalc1 << endl;
976  checkCalc2 = ptPR2.at(0) * normalPMT.at(0) + ptPR2.at(1) * normalPMT.at(1)
977  + ptPR2.at(2) * normalPMT.at(2) + constantePMT;
978  cout << "* using reflected point R2, checkCalc = " << checkCalc2 << endl;
979 }
980 
982  TVector3 outPosIdeal,
983  TVector3 outPosUnCorr,
984  TVector3 outPos,
985  CbmRichRingLight ringL,
986  vector<Double_t> normalPMT,
987  Double_t constantePMT,
988  string str) {
989  Double_t ringCenter[] = {0, 0, 0}, distToExtrapTrackHit = 0,
990  distToExtrapTrackHitInPlane = 0,
991  distToExtrapTrackHitInPlaneUnCorr = 0,
992  distToExtrapTrackHitInPlaneIdeal = 0;
993  string histoNameX = "", histoNameY = "";
994  string nameX = "", nameY = "";
995 
996  ringCenter[0] = ringL.GetCenterX();
997  ringCenter[1] = ringL.GetCenterY();
998  ringCenter[2] = -1
999  * ((normalPMT.at(0) * ringCenter[0]
1000  + normalPMT.at(1) * ringCenter[1] + constantePMT)
1001  / normalPMT.at(2));
1002 
1003  // Calculation using the corrected mirror hit/position, using the correction method
1004  vector<Double_t> r(3),
1005  p(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1006  r.at(0) = ringCenter[0], r.at(1) = ringCenter[1], r.at(2) = ringCenter[2];
1007  p.at(0) = outPos.x(), p.at(1) = outPos.y(), p.at(2) = outPos.z();
1008  cout << "Ring center coordinates = {" << ringCenter[0] << ", "
1009  << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1010  cout << "Difference in X = " << TMath::Abs(r.at(0) - p.at(0)) << "; \t"
1011  << "Difference in Y = " << TMath::Abs(r.at(1) - p.at(1)) << "; \t"
1012  << "Difference in Z = " << TMath::Abs(r.at(2) - p.at(2)) << endl;
1013 
1014  nameX = string("DiffCorrX_") + str;
1015  nameY = string("DiffCorrY_") + str;
1016  for (std::map<string, TH1D*>::iterator it = fDiffHistoMap.begin();
1017  it != fDiffHistoMap.end();
1018  ++it) {
1019  if (nameX.compare(it->first) == 0) {
1020  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(0) - p.at(0)));
1021  }
1022  if (nameY.compare(it->first) == 0) {
1023  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(1) - p.at(1)));
1024  }
1025  }
1026 
1027  distToExtrapTrackHit = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0), 2)
1028  + TMath::Power(r.at(1) - p.at(1), 2)
1029  + TMath::Power(r.at(2) - p.at(2), 2));
1030  distToExtrapTrackHitInPlane = TMath::Sqrt(
1031  TMath::Power(r.at(0) - p.at(0), 2) + TMath::Power(r.at(1) - p.at(1), 2));
1032  cout << "Distance between fitted ring center and extrapolated track hit = "
1033  << distToExtrapTrackHit << endl;
1034  cout << "Distance between fitted ring center and extrapolated track hit in "
1035  "plane = "
1036  << distToExtrapTrackHitInPlane << endl;
1037  fHM->H1("fhDistanceCenterToExtrapolatedTrack")->Fill(distToExtrapTrackHit);
1038  fHM->H1("fhDistanceCorrected")->Fill(distToExtrapTrackHitInPlane);
1039 
1040  // Calculation using the uncorrected mirror hit/position
1041  vector<Double_t> pUncorr(
1042  3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1043  pUncorr.at(0) = outPosUnCorr.x(), pUncorr.at(1) = outPosUnCorr.y(),
1044  pUncorr.at(2) = outPosUnCorr.z();
1045  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1046  cout << "Difference in X w/o correction = "
1047  << TMath::Abs(r.at(0) - pUncorr.at(0)) << "; \t"
1048  << "Difference in Y = " << TMath::Abs(r.at(1) - pUncorr.at(1)) << "; \t"
1049  << "Difference in Z = " << TMath::Abs(r.at(2) - pUncorr.at(2)) << endl;
1050 
1051  nameX = string("DiffUncorrX_") + str;
1052  nameY = string("DiffUncorrY_") + str;
1053  for (std::map<string, TH1D*>::iterator it = fDiffHistoMap.begin();
1054  it != fDiffHistoMap.end();
1055  ++it) {
1056  if (nameX.compare(it->first) == 0) {
1057  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(0) - pUncorr.at(0)));
1058  }
1059  if (nameY.compare(it->first) == 0) {
1060  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(1) - pUncorr.at(1)));
1061  }
1062  }
1063 
1064  distToExtrapTrackHitInPlaneUnCorr =
1065  TMath::Sqrt(TMath::Power(r.at(0) - pUncorr.at(0), 2)
1066  + TMath::Power(r.at(1) - pUncorr.at(1), 2));
1067  fHM->H1("fhDistanceUncorrected")->Fill(distToExtrapTrackHitInPlaneUnCorr);
1068  cout << "Distance between fitted ring center and extrapolated track hit in "
1069  "plane = "
1070  << distToExtrapTrackHitInPlaneUnCorr << endl;
1071 
1072  // Calculation using the ideally corrected mirror hit/position
1073  vector<Double_t> pIdeal(
1074  3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1075  pIdeal.at(0) = outPosIdeal.x(), pIdeal.at(1) = outPosIdeal.y(),
1076  pIdeal.at(2) = outPosIdeal.z();
1077  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1078  cout << "Difference in X w/ ideal correction = "
1079  << TMath::Abs(r.at(0) - pIdeal.at(0)) << "; \t"
1080  << "Difference in Y = " << TMath::Abs(r.at(1) - pIdeal.at(1)) << "; \t"
1081  << "Difference in Z = " << TMath::Abs(r.at(2) - pIdeal.at(2)) << endl;
1082 
1083  nameX = string("DiffIdealX_") + str;
1084  nameY = string("DiffIdealY_") + str;
1085  for (std::map<string, TH1D*>::iterator it = fDiffHistoMap.begin();
1086  it != fDiffHistoMap.end();
1087  ++it) {
1088  if (nameX.compare(it->first) == 0) {
1089  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(0) - pIdeal.at(0)));
1090  }
1091  if (nameY.compare(it->first) == 0) {
1092  fDiffHistoMap[it->first]->Fill(TMath::Abs(r.at(1) - pIdeal.at(1)));
1093  }
1094  }
1095 
1096  distToExtrapTrackHitInPlaneIdeal =
1097  TMath::Sqrt(TMath::Power(r.at(0) - pIdeal.at(0), 2)
1098  + TMath::Power(r.at(1) - pIdeal.at(1), 2));
1099  fHM->H1("fhDistanceIdeal")->Fill(distToExtrapTrackHitInPlaneIdeal);
1100  cout << "Distance between fitted ring center and extrapolated track hit in "
1101  "plane = "
1102  << distToExtrapTrackHitInPlaneIdeal << endl
1103  << endl;
1104  //}
1105  //else { cout << "No identical ring mother ID and mirror track ID ..." << endl;}
1106 
1107  if (distToExtrapTrackHitInPlane < 25.
1108  && distToExtrapTrackHitInPlaneUnCorr < 25.
1109  && distToExtrapTrackHitInPlaneIdeal < 25.) {
1110  //cout << "SEVERAL: " << distToExtrapTrackHitInPlane << endl << distToExtrapTrackHitInPlaneUnCorr << endl << distToExtrapTrackHitInPlaneIdeal << endl << endl;
1111  fTrackCenterDistanceCorrected += distToExtrapTrackHitInPlane;
1112  fTrackCenterDistanceUncorrected += distToExtrapTrackHitInPlaneUnCorr;
1113  fTrackCenterDistanceIdeal += distToExtrapTrackHitInPlaneIdeal;
1114  } else {
1115  cout << "Distance hit-ring too high!" << endl;
1116  //sleep(5);
1117  }
1118 }
1119 
1120 void CbmRichMirrorSortingCorrection::DrawMap(Int_t axisX, Int_t axisY) {
1121  //vector<TCanvas> Can(40);
1122  Int_t counterX = 1, counterY = 1, canX = 1500, canY = 400;
1123  vector<TH1D*> histoVectX, histoVectY;
1124  vector<string> stringVectX, stringVectY;
1125  TString strX = "X_mirror_tile_", strY = "Y_mirror_tile_", str1 = "",
1126  str2 = "";
1127  stringstream ssX, ssY, str3, str4;
1128  ssX << strX << axisY << "_" << axisX;
1129  ssY << strY << axisY << "_" << axisX;
1130  cout << "ssX: " << ssX.str().c_str() << " and ssY: " << ssY.str().c_str()
1131  << endl
1132  << endl;
1133 
1134  for (std::map<string, TH1D*>::iterator it = fDiffHistoMap.begin();
1135  it != fDiffHistoMap.end();
1136  ++it) {
1137  if (it->first.find(ssX.str().c_str()) != std::string::npos
1138  && it->second->GetEntries() > fThreshold) {
1139  // cout << "ssX: " << ssX.str().c_str() << " and histo key: " << it->first << endl;
1140  cout << "Histo entries: " << it->second->GetEntries() << endl;
1141  stringVectX.push_back(it->first);
1142  histoVectX.push_back(it->second);
1143  } else if (it->first.find(ssY.str().c_str()) != std::string::npos
1144  && it->second->GetEntries() > fThreshold) {
1145  // cout << "ssY: " << ssY.str().c_str() << " and histo key: " << it->first << endl;
1146  stringVectY.push_back(it->first);
1147  histoVectY.push_back(it->second);
1148  }
1149  }
1150 
1151  if (!histoVectX.empty()) {
1152  cout << "Vector size: " << histoVectX.size() << endl;
1153  TCanvas* c1 = new TCanvas(ssX.str().c_str(), ssX.str().c_str(), canX, canY);
1154  c1->Divide(3, 1);
1155  for (Int_t i = 0; i < 3; i++) {
1156  c1->cd(counterX);
1157  histoVectX[i]->Draw();
1158  histoVectX[i]->SetTitle(stringVectX[i].c_str());
1159  histoVectX[i]->SetLineColor(counterX + 1);
1160  histoVectX[i]->SetLineWidth(2);
1161  histoVectX[i]->Write();
1162  counterX++;
1163  }
1164  Cbm::SaveCanvasAsImage(c1, string(fOutputDir.Data() + fStudyName), "png");
1165  }
1166 
1167  if (!histoVectY.empty()) {
1168  TCanvas* c2 = new TCanvas(ssY.str().c_str(), ssY.str().c_str(), canX, canY);
1169  c2->Divide(3, 1);
1170  for (Int_t i = 0; i < 3; i++) {
1171  c2->cd(counterY);
1172  histoVectY[i]->Draw();
1173  histoVectY[i]->SetTitle(stringVectY[i].c_str());
1174  histoVectY[i]->SetLineColor(counterY + 1);
1175  histoVectY[i]->SetLineWidth(2);
1176  histoVectY[i]->Write();
1177  counterY++;
1178  }
1179  Cbm::SaveCanvasAsImage(c2, string(fOutputDir.Data() + fStudyName), "png");
1180  }
1181 
1182  histoVectX.clear();
1183  histoVectY.clear();
1184 }
1185 
1187  int counter1 = 1, counter2 = 1, counter3 = 1, counter4 = 1, counter5 = 1,
1188  counter6 = 1, counter7 = 1, counter8 = 1, counter9 = 1, counter10 = 1,
1189  counter11 = 1, counter12 = 1;
1190 
1191  // vector<TCanvas> Can;
1192  // std::stringstream ss;
1193  // ss << "X_mirror_" << X << "_" << Y;
1194  // ss.str();
1195  // ss.str().c_str();
1196  // for ( Int_t i=0; i<10; i++ ) {
1197  // ss << can << i;
1198  // TCan* c = new TCan(ss.str().c_str(), )
1199  // draw
1200  // }
1201 
1202  // vector<TCanvas> CanVect(80);
1203  cout << endl << "CALLING FUNCTION 'DRAWMAP()' ... " << endl << endl;
1204  for (Int_t j = 0; j < 4; j++) {
1205  for (Int_t i = 0; i < 10; i++) {
1206  DrawMap(i, j);
1207  }
1208  }
1209 
1210  /* TCanvas* can1 = new TCanvas("X_mirror_tile_0_1","X_mirror_tile_0_1",1500,400);
1211  can1->Divide(3,1);
1212  TCanvas* can2 = new TCanvas("Y_mirror_tile_0_1","Y_mirror_tile_0_1",1500,400);
1213  can2->Divide(3,1);
1214  TCanvas* can3 = new TCanvas("X_mirror_tile_1_5","X_mirror_tile_1_5",1500,400);
1215  can3->Divide(3,1);
1216  TCanvas* can4 = new TCanvas("Y_mirror_tile_1_5","Y_mirror_tile_1_5",1500,400);
1217  can4->Divide(3,1);
1218  TCanvas* can5 = new TCanvas("X_mirror_tile_2_8","X_mirror_tile_2_8",1500,400);
1219  can5->Divide(3,1);
1220  TCanvas* can6 = new TCanvas("Y_mirror_tile_2_8","Y_mirror_tile_2_8",1500,400);
1221  can6->Divide(3,1);
1222  TCanvas* can7 = new TCanvas("X_mirror_tile_1_3","X_mirror_tile_1_3",1500,400);
1223  can7->Divide(3,1);
1224  TCanvas* can8 = new TCanvas("Y_mirror_tile_1_3","Y_mirror_tile_1_3",1500,400);
1225  can8->Divide(3,1);
1226  TCanvas* can9 = new TCanvas("X_mirror_tile_1_4","X_mirror_tile_1_4",1500,400);
1227  can9->Divide(3,1);
1228  TCanvas* can10 = new TCanvas("Y_mirror_tile_1_4","Y_mirror_tile_1_4",1500,400);
1229  can10->Divide(3,1);
1230  TCanvas* can11 = new TCanvas("X_mirror_tile_0_8","X_mirror_tile_0_8",1500,400);
1231  can11->Divide(3,1);
1232  TCanvas* can12 = new TCanvas("Y_mirror_tile_0_8","Y_mirror_tile_0_8",1500,400);
1233  can12->Divide(3,1);
1234 
1235 
1236  for (std::map<string,TH1D*>::iterator it=fDiffHistoMap.begin(); it!=fDiffHistoMap.end(); ++it) {
1237  if ( it->first.find("X_mirror_tile_0_1")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1238  can1->cd(counter1);
1239  fDiffHistoMap[it->first]->Draw();
1240  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1241  fDiffHistoMap[it->first]->SetLineColor(counter1+1);
1242  fDiffHistoMap[it->first]->SetLineWidth(2);
1243  fDiffHistoMap[it->first]->Write();
1244  counter1++;
1245  }
1246  else if ( it->first.find("Y_mirror_tile_0_1")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1247  can2->cd(counter2);
1248  fDiffHistoMap[it->first]->Draw();
1249  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1250  fDiffHistoMap[it->first]->SetLineColor(counter2+1);
1251  fDiffHistoMap[it->first]->SetLineWidth(2);
1252  fDiffHistoMap[it->first]->Write();
1253  counter2++;
1254  }
1255  else if ( it->first.find("X_mirror_tile_1_5")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1256  can3->cd(counter3);
1257  fDiffHistoMap[it->first]->Draw();
1258  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1259  fDiffHistoMap[it->first]->SetLineColor(counter3+1);
1260  fDiffHistoMap[it->first]->SetLineWidth(2);
1261  fDiffHistoMap[it->first]->Write();
1262  counter3++;
1263  }
1264  else if ( it->first.find("Y_mirror_tile_1_5")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1265  can4->cd(counter4);
1266  fDiffHistoMap[it->first]->Draw();
1267  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1268  fDiffHistoMap[it->first]->SetLineColor(counter4+1);
1269  fDiffHistoMap[it->first]->SetLineWidth(2);
1270  fDiffHistoMap[it->first]->Write();
1271  counter4++;
1272  }
1273  else if ( it->first.find("X_mirror_tile_2_8")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1274  can5->cd(counter5);
1275  fDiffHistoMap[it->first]->Draw();
1276  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1277  fDiffHistoMap[it->first]->SetLineColor(counter5+1);
1278  fDiffHistoMap[it->first]->SetLineWidth(2);
1279  fDiffHistoMap[it->first]->Write();
1280  counter5++;
1281  }
1282  else if ( it->first.find("Y_mirror_tile_2_8")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1283  can6->cd(counter6);
1284  fDiffHistoMap[it->first]->Draw();
1285  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1286  fDiffHistoMap[it->first]->SetLineColor(counter6+1);
1287  fDiffHistoMap[it->first]->SetLineWidth(2);
1288  fDiffHistoMap[it->first]->Write();
1289  counter6++;
1290  }
1291  else if ( it->first.find("X_mirror_tile_1_3")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1292  can7->cd(counter7);
1293  fDiffHistoMap[it->first]->Draw();
1294  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1295  fDiffHistoMap[it->first]->SetLineColor(counter7+1);
1296  fDiffHistoMap[it->first]->SetLineWidth(2);
1297  counter7++;
1298  }
1299  else if ( it->first.find("Y_mirror_tile_1_3")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1300  can8->cd(counter8);
1301  fDiffHistoMap[it->first]->Draw();
1302  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1303  fDiffHistoMap[it->first]->SetLineColor(counter8+1);
1304  fDiffHistoMap[it->first]->SetLineWidth(2);
1305  counter8++;
1306  }
1307  else if ( it->first.find("X_mirror_tile_1_4")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1308  can9->cd(counter9);
1309  fDiffHistoMap[it->first]->Draw();
1310  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1311  fDiffHistoMap[it->first]->SetLineColor(counter9+1);
1312  fDiffHistoMap[it->first]->SetLineWidth(2);
1313  fDiffHistoMap[it->first]->Write();
1314  counter9++;
1315  }
1316  else if ( it->first.find("Y_mirror_tile_1_4")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1317  can10->cd(counter10);
1318  //fDiffHistoMap[it->first]->Draw();
1319  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1320  fDiffHistoMap[it->first]->SetLineColor(counter10+1);
1321  fDiffHistoMap[it->first]->SetLineWidth(2);
1322  fDiffHistoMap[it->first]->Write();
1323  counter10++;
1324  }
1325  else if ( it->first.find("X_mirror_tile_0_8")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1326  can11->cd(counter11);
1327  fDiffHistoMap[it->first]->Draw();
1328  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1329  fDiffHistoMap[it->first]->SetLineColor(counter11+1);
1330  fDiffHistoMap[it->first]->SetLineWidth(2);
1331  fDiffHistoMap[it->first]->Write();
1332  counter11++;
1333  }
1334  else if ( it->first.find("Y_mirror_tile_0_8")!=std::string::npos && it->second->GetEntries() > fThreshold ) {
1335  can12->cd(counter12);
1336  fDiffHistoMap[it->first]->Draw();
1337  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1338  fDiffHistoMap[it->first]->SetLineColor(counter12+1);
1339  fDiffHistoMap[it->first]->SetLineWidth(2);
1340  fDiffHistoMap[it->first]->Write();
1341  counter12++;
1342  }
1343  else if ( it->second->GetEntries() > fThreshold ) {
1344  TCanvas* can = new TCanvas();
1345  fDiffHistoMap[it->first]->Draw();
1346  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1347  fDiffHistoMap[it->first]->SetLineColor(4);
1348  fDiffHistoMap[it->first]->SetLineWidth(2);
1349  fDiffHistoMap[it->first]->Write();
1350  }
1351  }
1352 
1353  Cbm::SaveCanvasAsImage(can1, string(fOutputDir.Data()+fStudyName), "png");
1354  Cbm::SaveCanvasAsImage(can2, string(fOutputDir.Data()+fStudyName), "png");
1355  Cbm::SaveCanvasAsImage(can3, string(fOutputDir.Data()+fStudyName), "png");
1356  Cbm::SaveCanvasAsImage(can4, string(fOutputDir.Data()+fStudyName), "png");*/
1357  //Cbm::SaveCanvasAsImage(can5, string(fOutputDir.Data()+fStudyName), "png");
1358  //Cbm::SaveCanvasAsImage(can6, string(fOutputDir.Data()+fStudyName), "png");
1359  //Cbm::SaveCanvasAsImage(can7, string(fOutputDir.Data()+fStudyName), "png");
1360  //Cbm::SaveCanvasAsImage(can8, string(fOutputDir.Data()+fStudyName), "png");
1361  //Cbm::SaveCanvasAsImage(can9, string(fOutputDir.Data()+fStudyName), "png");
1362  //Cbm::SaveCanvasAsImage(can10, string(fOutputDir.Data()+fStudyName), "png");
1363  //Cbm::SaveCanvasAsImage(can11, string(fOutputDir.Data()+fStudyName), "png");
1364  //Cbm::SaveCanvasAsImage(can12, string(fOutputDir.Data()+fStudyName), "png");
1365 
1366  /* char title[128];
1367  for (std::map<string,TH1D*>::iterator it=fDiffHistoMap.begin(); it!=fDiffHistoMap.end(); ++it) {
1368  TCanvas* can = new TCanvas();
1369  fDiffHistoMap[it->first]->Draw();
1370  //title = (it->first).c_str();
1371  fDiffHistoMap[it->first]->SetTitle((it->first).c_str());
1372  fDiffHistoMap[it->first]->SetLineColor(4);
1373  fDiffHistoMap[it->first]->SetLineWidth(2);
1374  //Cbm::SaveCanvasAsImage(can, string(fOutputDir.Data()), "png");
1375  }
1376 */
1377 }
1378 
1380  for (Int_t iTrack = 0; iTrack < fGlobalTracks->GetEntriesFast(); iTrack++) {
1381  const CbmGlobalTrack* globalTrack =
1382  static_cast<const CbmGlobalTrack*>(fGlobalTracks->At(iTrack));
1383  Int_t stsId = globalTrack->GetStsTrackIndex();
1384  Int_t richId = globalTrack->GetRichRingIndex();
1385  if (stsId < 0 || richId < 0) continue;
1386  const CbmTrackMatchNew* stsTrackMatch =
1387  static_cast<const CbmTrackMatchNew*>(fStsTrackMatches->At(stsId));
1388  if (stsTrackMatch == NULL) continue;
1389  int stsMcTrackId = stsTrackMatch->GetMatchedLink().GetIndex();
1390  const CbmTrackMatchNew* richRingMatch =
1391  static_cast<const CbmTrackMatchNew*>(fRichRingMatches->At(richId));
1392  if (richRingMatch == NULL) continue;
1393  int richMcTrackId = richRingMatch->GetMatchedLink().GetIndex();
1394  const CbmRichRing* ring =
1395  static_cast<const CbmRichRing*>(fRichRings->At(richId));
1396  if (NULL == ring) continue;
1397  Double_t rtDistance = CbmRichUtil::GetRingTrackDistance(iTrack);
1398  Double_t rtDistanceX = CbmRichUtil::GetRingTrackDistanceX(iTrack);
1399  Double_t rtDistanceY = CbmRichUtil::GetRingTrackDistanceY(iTrack);
1400  Double_t xc = ring->GetCenterX();
1401  Double_t yc = ring->GetCenterY();
1402 
1403  CbmMCTrack* mctrack = static_cast<CbmMCTrack*>(fMCTracks->At(stsMcTrackId));
1404  if (mctrack == NULL) continue;
1405  bool isEl = IsMcPrimaryElectron(mctrack);
1406 
1407  if (isEl && stsMcTrackId == richMcTrackId) {
1408  Int_t k = 1;
1409  stringstream ss;
1410  ss << k;
1411  fHM->H3("fhRingTrackDistVsXYTruematch" + ss.str())
1412  ->Fill(xc, yc, rtDistance);
1413  fHM->H2("fhRingTrackDistVsXTruematch" + ss.str())->Fill(xc, rtDistance);
1414  fHM->H2("fhRingTrackDistVsYTruematch" + ss.str())
1415  ->Fill(abs(yc), rtDistance);
1416  fHM->H3("fhRingTrackDistDiffXRingVsXYTruematch" + ss.str())
1417  ->Fill(xc, yc, rtDistanceX);
1418  fHM->H3("fhRingTrackDistDiffYRingVsXYTruematch" + ss.str())
1419  ->Fill(xc, yc, rtDistanceY);
1420  if (rtDistance >= -10 && rtDistance <= 10) {
1421  fHM->H1("fDistUncorr")->Fill(rtDistance);
1422  }
1423  ss.str("");
1424  }
1425  }
1426 }
1427 
1429  const CbmRichRing* richRing,
1430  const FairTrackParam* pTrack,
1431  const CbmMCTrack* mcTrack) {
1432  Double_t xRing = richRing->GetCenterX();
1433  Double_t yRing = richRing->GetCenterY();
1434  Double_t dx = richRing->GetCenterX() - pTrack->GetX();
1435  Double_t dy = richRing->GetCenterY() - pTrack->GetY();
1436  Double_t dist = TMath::Sqrt(dx * dx + dy * dy);
1437 
1438  bool isEl = IsMcPrimaryElectron(mcTrack);
1439  if (isEl) {
1440  Int_t k = 2;
1441  stringstream ss;
1442  ss << k;
1443  fHM->H3("fhRingTrackDistVsXYTruematch" + ss.str())
1444  ->Fill(xRing, yRing, dist);
1445  fHM->H2("fhRingTrackDistVsXTruematch" + ss.str())->Fill(xRing, dist);
1446  fHM->H2("fhRingTrackDistVsYTruematch" + ss.str())->Fill(abs(yRing), dist);
1447  fHM->H3("fhRingTrackDistDiffXRingVsXYTruematch" + ss.str())
1448  ->Fill(xRing, yRing, dist);
1449  fHM->H3("fhRingTrackDistDiffYRingVsXYTruematch" + ss.str())
1450  ->Fill(xRing, yRing, dist);
1451  if (dist >= -10 && dist <= 10) { fHM->H1("fDistCorr")->Fill(dist); }
1452  ss.str("");
1453  }
1454 }
1455 
1457  const CbmMCTrack* mctrack) {
1458  if (mctrack == NULL) return false;
1459  int pdg = TMath::Abs(mctrack->GetPdgCode());
1460  if (mctrack->GetGeantProcessId() == kPPrimary && pdg == 11) return true;
1461  return false;
1462 }
1463 
1465  stringstream ss;
1466  ss << k;
1467  {
1468  TCanvas* c = fHM->CreateCanvas("fh_ring_track_distance_vs_xy_truematch" + k,
1469  "fh_ring_track_distance_vs_xy_truematch" + k,
1470  1800,
1471  600);
1472  c->Divide(3, 1);
1473  c->cd(1);
1474  DrawH3Profile(
1475  fHM->H3("fhRingTrackDistVsXYTruematch" + ss.str()), true, false, 0., 2.);
1476  c->cd(2);
1478  fHM->H2("fhRingTrackDistVsXTruematch" + ss.str()), false, true);
1479  fHM->H2("fhRingTrackDistVsXTruematch" + ss.str())
1480  ->GetYaxis()
1481  ->SetRangeUser(0., 1.5);
1482  c->cd(3);
1484  fHM->H2("fhRingTrackDistVsYTruematch" + ss.str()), false, true);
1485  fHM->H2("fhRingTrackDistVsYTruematch" + ss.str())
1486  ->GetYaxis()
1487  ->SetRangeUser(0., 1.5);
1488  }
1489 
1490  Double_t range = 2.5;
1491  {
1492  TCanvas* c = fHM->CreateCanvas(
1493  "fh_ring_track_distance_diff_x_y_ring_vs_xy_truematch" + k,
1494  "fh_ring_track_distance_diff_x_y_ring_vs_xy_truematch" + k,
1495  1800,
1496  600);
1497  c->Divide(2, 1);
1498  c->cd(1);
1499  DrawH3Profile(fHM->H3("fhRingTrackDistDiffXRingVsXYTruematch" + ss.str()),
1500  true,
1501  false,
1502  -range,
1503  range);
1504  c->cd(2);
1505  DrawH3Profile(fHM->H3("fhRingTrackDistDiffYRingVsXYTruematch" + ss.str()),
1506  true,
1507  false,
1508  -range,
1509  range);
1510  }
1511 }
1512 
1514  TCanvas* c1 = fHM->CreateCanvas(
1515  "fh_distance_distribution_corr", "fh_distance_distribution_corr", 600, 900);
1516  DrawH1andFitGauss(fHM->H1("fDistCorr"), true, false, -2., 4.);
1517 }
1518 
1520  //DrawHistProjection();
1523  DrawDistanceComp();
1524 
1525  TDirectory* oldir = gDirectory;
1526  TFile* outFile = FairRootManager::Instance()->GetOutFile();
1527  if (outFile != NULL) { fHM->WriteToFile(); }
1528  gDirectory->cd(oldir->GetPath());
1529 
1530  string str1 = fOutputDir.Data();
1531  string str2 = fStudyName.Data();
1532  string str = str1 + "/" + str2;
1533  cout << endl << endl << "output string: " << str << endl << endl;
1534  fHM->SaveCanvasToImage(str);
1535 
1536  // TString s = fOutputDir + "track_ring_distances_" + fStudyName + ".txt";
1537  TString s = fOutputDir + "/correction_table/track_ring_distances.txt";
1538  ofstream corrFile;
1539  corrFile.open(s, std::ofstream::trunc);
1540  if (corrFile.is_open()) {
1541  corrFile << "number of events: " << fEventNb << endl;
1542  corrFile
1543  << setprecision(9)
1544  << "Mean distance between track hit and ring center ; corrected case = "
1546  << " and total sum = " << fTrackCenterDistanceCorrected << endl;
1547  corrFile
1548  << "Mean distance between track hit and ring center ; uncorrected case = "
1550  << " and total sum = " << fTrackCenterDistanceUncorrected << endl;
1551  corrFile
1552  << "Mean distance between track hit and ring center ; ideal case = "
1554  << " and total sum = " << fTrackCenterDistanceIdeal << endl;
1555  } else {
1556  cout << "Error in CbmRichMirrorSortingAlignment::Finish ; unable to open "
1557  "parameter file!"
1558  << endl;
1559  }
1560 
1561  cout << "number of events: " << fEventNb << endl;
1562  cout << setprecision(9)
1563  << "Mean distance between track hit and ring center ; corrected case = "
1565  << " and total sum = " << fTrackCenterDistanceCorrected << endl;
1566  cout
1567  << "Mean distance between track hit and ring center ; uncorrected case = "
1569  << " and total sum = " << fTrackCenterDistanceUncorrected << endl;
1570  cout << "Mean distance between track hit and ring center ; ideal case = "
1572  << " and total sum = " << fTrackCenterDistanceIdeal << endl;
1573 }
1575 
1576 
1577  /*void CbmRichMirrorSortingCorrection::FillHistProjection(TVector3 outPosIdeal, TVector3 outPosUnCorr, TVector3 outPos, CbmRichRingLight ringL, vector<Double_t> normalPMT, Double_t constantePMT, string str)
1578 {
1579  Double_t ringCenter[] = {0, 0, 0}, distToExtrapTrackHit = 0, distToExtrapTrackHitInPlane = 0, distToExtrapTrackHitInPlaneUnCorr = 0, distToExtrapTrackHitInPlaneIdeal = 0;
1580  string histoNameX = "", histoNameY = "";
1581  string nameX = "", nameY = "";
1582 
1583  ringCenter[0] = ringL.GetCenterX();
1584  ringCenter[1] = ringL.GetCenterY();
1585  ringCenter[2] = -1*((normalPMT.at(0)*ringCenter[0] + normalPMT.at(1)*ringCenter[1] + constantePMT)/normalPMT.at(2));
1586 
1587  vector<Double_t> r(3), p(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1588  r.at(0) = ringCenter[0], r.at(1) = ringCenter[1], r.at(2) = ringCenter[2];
1589  p.at(0) = outPos.x(), p.at(1) = outPos.y(), p.at(2) = outPos.z();
1590  cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1591  cout << "Difference in X = " << TMath::Abs(r.at(0) - p.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - p.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - p.at(2)) << endl;
1592 
1593  nameX = string("X_") + str;
1594  nameY = string("Y_") + str;
1595  for (std::map<string,string>::iterator it=fDiffHistoMap.begin(); it!=fDiffHistoMap.end(); ++it) {
1596  if ( nameX.compare(it->second) == 0 ) {
1597  fHM2->H1(it->first)->Fill(TMath::Abs(r.at(0) - p.at(0)));
1598  }
1599  if ( nameY.compare(it->second) == 0 ) {
1600  fHM2->H1(it->first)->Fill(TMath::Abs(r.at(1) - p.at(1)));
1601  }
1602  }
1603 
1604  distToExtrapTrackHit = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0),2) + TMath::Power(r.at(1) - p.at(1),2) + TMath::Power(r.at(2) - p.at(2),2));
1605  distToExtrapTrackHitInPlane = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0),2) + TMath::Power(r.at(1) - p.at(1),2));
1606  fHM->H1("fhDistanceCenterToExtrapolatedTrack")->Fill(distToExtrapTrackHit);
1607  fHM->H1("fhDistanceCorrected")->Fill(distToExtrapTrackHitInPlane);
1608  //cout << "Distance between fitted ring center and extrapolated track hit = " << distToExtrapTrackHit << endl;
1609  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlane << endl;
1610 
1611  vector<Double_t> pUnCorr(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1612  pUnCorr.at(0) = outPosUnCorr.x(), pUnCorr.at(1) = outPosUnCorr.y(), pUnCorr.at(2) = outPosUnCorr.z();
1613  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1614  cout << "Difference in X w/o correction = " << TMath::Abs(r.at(0) - pUnCorr.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - pUnCorr.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - pUnCorr.at(2)) << endl;
1615  fHM->H1("fhDifferenceXUncorrected")->Fill(TMath::Abs(r.at(0) - pUnCorr.at(0)));
1616  fHM->H1("fhDifferenceYUncorrected")->Fill(TMath::Abs(r.at(1) - pUnCorr.at(1)));
1617  distToExtrapTrackHitInPlaneUnCorr = TMath::Sqrt(TMath::Power(r.at(0) - pUnCorr.at(0),2) + TMath::Power(r.at(1) - pUnCorr.at(1),2));
1618  fHM->H1("fhDistanceUncorrected")->Fill(distToExtrapTrackHitInPlaneUnCorr);
1619  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlaneUnCorr << endl;
1620 
1621  vector<Double_t> pIdeal(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1622  pIdeal.at(0) = outPosIdeal.x(), pIdeal.at(1) = outPosIdeal.y(), pIdeal.at(2) = outPosIdeal.z();
1623  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1624  cout << "Difference in X w/ ideal correction = " << TMath::Abs(r.at(0) - pIdeal.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - pIdeal.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - pIdeal.at(2)) << endl;
1625  fHM->H1("fhDifferenceXIdeal")->Fill(TMath::Abs(r.at(0) - pIdeal.at(0)));
1626  fHM->H1("fhDifferenceYIdeal")->Fill(TMath::Abs(r.at(1) - pIdeal.at(1)));
1627  distToExtrapTrackHitInPlaneIdeal = TMath::Sqrt(TMath::Power(r.at(0) - pIdeal.at(0),2) + TMath::Power(r.at(1) - pIdeal.at(1),2));
1628  fHM->H1("fhDistanceIdeal")->Fill(distToExtrapTrackHitInPlaneIdeal);
1629  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlaneIdeal << endl << endl;
1630  //}
1631  //else { cout << "No identical ring mother ID and mirror track ID ..." << endl;}
1632 }
1633 
1634 /*void CbmRichMirrorSortingCorrection::FillHistProjection(TVector3 outPosIdeal, TVector3 outPosUnCorr, TVector3 outPos, CbmRichRingLight ringL, vector<Double_t> normalPMT, Double_t constantePMT)
1635 {
1636  Double_t ringCenter[] = {0, 0, 0}, distToExtrapTrackHit = 0, distToExtrapTrackHitInPlane = 0, distToExtrapTrackHitInPlaneUnCorr = 0, distToExtrapTrackHitInPlaneIdeal = 0;
1637 
1638  ringCenter[0] = ringL.GetCenterX();
1639  ringCenter[1] = ringL.GetCenterY();
1640  ringCenter[2] = -1*((normalPMT.at(0)*ringCenter[0] + normalPMT.at(1)*ringCenter[1] + constantePMT)/normalPMT.at(2));
1641 
1642  vector<Double_t> r(3), p(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1643  r.at(0) = TMath::Abs(ringCenter[0]), r.at(1) = TMath::Abs(ringCenter[1]), r.at(2) = TMath::Abs(ringCenter[2]);
1644  p.at(0) = TMath::Abs(outPos.x()), p.at(1) = TMath::Abs(outPos.y()), p.at(2) = TMath::Abs(outPos.z());
1645  cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1646  cout << "Difference in X = " << TMath::Abs(r.at(0) - p.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - p.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - p.at(2)) << endl;
1647  fHM->H1("fhDifferenceX")->Fill(TMath::Abs(r.at(0) - p.at(0)));
1648  fHM->H1("fhDifferenceY")->Fill(TMath::Abs(r.at(1) - p.at(1)));
1649  distToExtrapTrackHit = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0),2) + TMath::Power(r.at(1) - p.at(1),2) + TMath::Power(r.at(2) - p.at(2),2));
1650  distToExtrapTrackHitInPlane = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0),2) + TMath::Power(r.at(1) - p.at(1),2));
1651  fHM->H1("fhDistanceCenterToExtrapolatedTrack")->Fill(distToExtrapTrackHit);
1652  fHM->H1("fhDistanceCorrected")->Fill(distToExtrapTrackHitInPlane);
1653  //cout << "Distance between fitted ring center and extrapolated track hit = " << distToExtrapTrackHit << endl;
1654  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlane << endl;
1655 
1656  vector<Double_t> pUnCorr(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1657  pUnCorr.at(0) = TMath::Abs(outPosUnCorr.x()), pUnCorr.at(1) = TMath::Abs(outPosUnCorr.y()), pUnCorr.at(2) = TMath::Abs(outPosUnCorr.z());
1658  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1659  cout << "Difference in X w/o correction = " << TMath::Abs(r.at(0) - pUnCorr.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - pUnCorr.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - pUnCorr.at(2)) << endl;
1660  fHM->H1("fhDifferenceXUncorrected")->Fill(TMath::Abs(r.at(0) - pUnCorr.at(0)));
1661  fHM->H1("fhDifferenceYUncorrected")->Fill(TMath::Abs(r.at(1) - pUnCorr.at(1)));
1662  distToExtrapTrackHitInPlaneUnCorr = TMath::Sqrt(TMath::Power(r.at(0) - pUnCorr.at(0),2) + TMath::Power(r.at(1) - pUnCorr.at(1),2));
1663  fHM->H1("fhDistanceUncorrected")->Fill(distToExtrapTrackHitInPlaneUnCorr);
1664  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlaneUnCorr << endl;
1665 
1666  vector<Double_t> pIdeal(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1667  pIdeal.at(0) = TMath::Abs(outPosIdeal.x()), pIdeal.at(1) = TMath::Abs(outPosIdeal.y()), pIdeal.at(2) = TMath::Abs(outPosIdeal.z());
1668  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1669  cout << "Difference in X w/ ideal correction = " << TMath::Abs(r.at(0) - pIdeal.at(0)) << "; \t" << "Difference in Y = " << TMath::Abs(r.at(1) - pIdeal.at(1)) << "; \t" << "Difference in Z = " << TMath::Abs(r.at(2) - pIdeal.at(2)) << endl;
1670  fHM->H1("fhDifferenceXIdeal")->Fill(TMath::Abs(r.at(0) - pIdeal.at(0)));
1671  fHM->H1("fhDifferenceYIdeal")->Fill(TMath::Abs(r.at(1) - pIdeal.at(1)));
1672  distToExtrapTrackHitInPlaneIdeal = TMath::Sqrt(TMath::Power(r.at(0) - pIdeal.at(0),2) + TMath::Power(r.at(1) - pIdeal.at(1),2));
1673  fHM->H1("fhDistanceIdeal")->Fill(distToExtrapTrackHitInPlaneIdeal);
1674  cout << "Distance between fitted ring center and extrapolated track hit in plane = " << distToExtrapTrackHitInPlaneIdeal << endl << endl;
1675  //}
1676  //else { cout << "No identical ring mother ID and mirror track ID ..." << endl;}
1677 }
1678 
1679 
1680 void CbmRichMirrorSortingCorrection::DrawHistProjection()
1681 {
1682  char leg[128];
1683  int colorInd = 1;
1684  string diffCorrX = "DiffX_mirror_tile_2_8", diffCorrY = "DiffY_mirror_tile_2_8";
1685 
1686  TCanvas* can1 = new TCanvas("Distance_Histos_Difference_X", "Distance_Histos_Difference_X", 1500, 400);
1687  can1->SetGrid(1,1);
1688  can1->Divide(3,1);
1689  can1->cd(1);
1690  fHM->H1("fhDifferenceXIdeal")->Draw();
1691  fHM->H1("fhDifferenceXIdeal")->SetTitle("Difference in X ideal");
1692  fHM->H1("fhDifferenceXIdeal")->SetLineColor(kBlue);
1693  fHM->H1("fhDifferenceXIdeal")->SetLineWidth(2);
1694  can1->cd(2);
1695  fDiffHistoMap[diffCorrX]->Draw();
1696  fDiffHistoMap[diffCorrX]->SetTitle("Difference in X corrected");
1697  fDiffHistoMap[diffCorrX]->SetLineColor(kRed);
1698  fDiffHistoMap[diffCorrX]->SetLineWidth(2);
1699  can1->cd(3);
1700  fHM->H1("fhDifferenceXUncorrected")->Draw();
1701  fHM->H1("fhDifferenceXUncorrected")->SetTitle("Difference in X uncorrected");
1702  fHM->H1("fhDifferenceXUncorrected")->SetLineColor(kGreen);
1703  fHM->H1("fhDifferenceXUncorrected")->SetLineWidth(2);
1704 
1705  TCanvas* can2 = new TCanvas("Distance_Histos_Difference_Y", "Distance_Histos_Difference_Y", 1500, 400);
1706  can2->SetGrid(1,1);
1707  can2->Divide(3,1);
1708  can2->cd(1);
1709  fHM->H1("fhDifferenceYIdeal")->Draw();
1710  fHM->H1("fhDifferenceYIdeal")->SetTitle("Difference in Y ideal");
1711  fHM->H1("fhDifferenceYIdeal")->SetLineColor(kBlue);
1712  fHM->H1("fhDifferenceYIdeal")->SetLineWidth(2);
1713  can2->cd(2);
1714  fDiffHistoMap[diffCorrY]->Draw();
1715  fDiffHistoMap[diffCorrY]->SetTitle("Difference in Y corrected");
1716  fDiffHistoMap[diffCorrY]->SetLineColor(kRed);
1717  fDiffHistoMap[diffCorrY]->SetLineWidth(2);
1718  can2->cd(3);
1719  fHM->H1("fhDifferenceYUncorrected")->Draw();
1720  fHM->H1("fhDifferenceYUncorrected")->SetTitle("Difference in Y uncorrected");
1721  fHM->H1("fhDifferenceYUncorrected")->SetLineColor(kGreen);
1722  fHM->H1("fhDifferenceYUncorrected")->SetLineWidth(2);
1723 
1724  /*can3->SetGrid(1,1);
1725  can3->Divide(2,1);
1726  can3->cd(1)->SetGrid(1,1);
1727  can3->cd(2)->SetGrid(1,1);
1728  can3->cd(1);
1729  TH1D* Clone1 = (TH1D*)fHM->H1("fhDifferenceXIdeal")->Clone();
1730  Clone1->GetXaxis()->SetTitleSize(0.04);
1731  Clone1->GetYaxis()->SetTitleSize(0.04);
1732  Clone1->GetXaxis()->SetLabelSize(0.03);
1733  Clone1->GetYaxis()->SetLabelSize(0.03);
1734  Clone1->GetXaxis()->CenterTitle();
1735  Clone1->GetYaxis()->CenterTitle();
1736  Clone1->SetTitle("Difference in X");
1737  Clone1->SetLineColor(kBlue);
1738  Clone1->SetLineWidth(2);
1739  Clone1->Rebin(2);
1740  Clone1->Draw();
1741  TH1D* Clone2 = (TH1D*)fHM->H1("fhDifferenceX")->Clone();
1742  Clone2->SetTitleSize(0.04);
1743  Clone2->SetLabelSize(0.03);
1744  Clone2->SetLineColor(kGreen);
1745  Clone2->SetLineWidth(2);
1746  Clone2->Rebin(2);
1747  Clone2->Draw("same");
1748  TH1D* Clone3 = (TH1D*)fHM->H1("fhDifferenceXUncorrected")->Clone();
1749  Clone3->SetTitleSize(0.04);
1750  Clone3->SetLabelSize(0.03);
1751  Clone3->SetLineColor(kRed);
1752  Clone3->SetLineWidth(2);
1753  Clone3->Rebin(2);
1754  Clone3->Draw("same");
1755  gStyle->Clear();
1756 
1757  TLegend* LEG = new TLegend(0.3,0.78,0.5,0.88); // Set legend position
1758  LEG->SetBorderSize(1);
1759  LEG->SetFillColor(0);
1760  LEG->SetMargin(0.2);
1761  LEG->SetTextSize(0.02);
1762  sprintf(leg, "X diff uncorr");
1763  LEG->AddEntry(Clone3, leg, "l");
1764  sprintf(leg, "X diff corr");
1765  LEG->AddEntry(Clone2, leg, "l");
1766  sprintf(leg, "X diff ideal");
1767  LEG->AddEntry(Clone1, leg, "l");
1768  LEG->Draw();
1769 
1770  can3->cd(2);
1771  can3->SetGrid(1,1);
1772  TH1D* Clone4 = (TH1D*)fHM->H1("fhDifferenceYIdeal")->Clone();
1773  Clone4->GetXaxis()->SetTitleSize(0.04);
1774  Clone4->GetYaxis()->SetTitleSize(0.04);
1775  Clone4->GetXaxis()->SetLabelSize(0.03);
1776  Clone4->GetYaxis()->SetLabelSize(0.03);
1777  Clone4->GetXaxis()->CenterTitle();
1778  Clone4->GetYaxis()->CenterTitle();
1779  Clone4->SetTitle("Difference in Y");
1780  Clone4->SetLineColor(kBlue);
1781  Clone4->SetLineWidth(2);
1782  Clone4->Rebin(2);
1783  Clone4->Draw();
1784  TH1D* Clone5 = (TH1D*)fHM->H1("fhDifferenceY")->Clone();
1785  Clone5->SetTitleSize(0.04);
1786  Clone5->SetLabelSize(0.03);
1787  Clone5->SetLineColor(kGreen);
1788  Clone5->SetLineWidth(2);
1789  Clone5->Rebin(2);
1790  Clone5->Draw("same");
1791  TH1D* Clone6 = (TH1D*)fHM->H1("fhDifferenceYUncorrected")->Clone();
1792  Clone6->SetTitleSize(0.04);
1793  Clone6->SetLabelSize(0.03);
1794  Clone6->SetLineColor(kRed);
1795  Clone6->SetLineWidth(2);
1796  Clone6->Rebin(2);
1797  Clone6->Draw("same");
1798 
1799  TLegend* LEG1 = new TLegend(0.3,0.78,0.5,0.88); // Set legend position
1800  LEG1->SetBorderSize(1);
1801  LEG1->SetFillColor(0);
1802  LEG1->SetMargin(0.2);
1803  LEG1->SetTextSize(0.02);
1804  sprintf(leg, "Y diff uncorr");
1805  LEG1->AddEntry(Clone6, leg, "l");
1806  sprintf(leg, "Y diff corr");
1807  LEG1->AddEntry(Clone5, leg, "l");
1808  sprintf(leg, "Y diff ideal");
1809  LEG1->AddEntry(Clone4, leg, "l");
1810  LEG1->Draw();
1811 
1812  /*can3->cd(3);
1813  //DrawH1(list_of(fHM->H1("fhDistanceCorrected"))(fHM->H1("fhDistanceUncorrected"))(fHM->H1("fhDistanceIdeal")), list_of("a corrected")("a uncorrected")("a ideal"), kLinear, kLog, true, 0.7, 0.7, 0.99, 0.99);
1814  TH1D* CloneDist1 = (TH1D*)fHM->H1("fhDistanceIdeal")->Clone();
1815  CloneDist1->GetXaxis()->SetTitleSize(0.04);
1816  CloneDist1->GetYaxis()->SetTitleSize(0.04);
1817  CloneDist1->GetXaxis()->SetLabelSize(0.03);
1818  CloneDist1->GetYaxis()->SetLabelSize(0.03);
1819  CloneDist1->GetXaxis()->CenterTitle();
1820  CloneDist1->GetYaxis()->CenterTitle();
1821  CloneDist1->SetTitle("Distance between extrapolated track center and fitted ring center");
1822  CloneDist1->SetLineColor(kBlue);
1823  CloneDist1->SetLineWidth(2);
1824  CloneDist1->Rebin(2);
1825  CloneDist1->Draw();
1826  TH1D* CloneDist2 = (TH1D*)fHM->H1("fhDistanceUncorrected")->Clone();
1827  CloneDist2->SetTitleSize(0.04);
1828  CloneDist2->SetTitleSize(0.04);
1829  CloneDist2->SetLineColor(kRed);
1830  CloneDist2->SetLineWidth(2);
1831  CloneDist2->Rebin(2);
1832  CloneDist2->Draw("same");
1833  TH1D* CloneDist3 = (TH1D*)fHM->H1("fhDistanceCorrected")->Clone();
1834  CloneDist3->SetTitleSize(0.04);
1835  CloneDist3->SetTitleSize(0.04);
1836  CloneDist3->SetLineColor(kGreen);
1837  CloneDist3->SetLineWidth(2);
1838  CloneDist3->Rebin(2);
1839  CloneDist3->Draw("same");
1840 
1841  TLegend* LEG2 = new TLegend(0.3,0.78,0.5,0.88); // Set legend position
1842  LEG2->SetBorderSize(1);
1843  LEG2->SetFillColor(0);
1844  LEG2->SetMargin(0.2);
1845  LEG2->SetTextSize(0.02);
1846  sprintf(leg, "Distance uncorr");
1847  LEG2->AddEntry(CloneDist2, leg, "l");
1848  sprintf(leg, "Distance corr");
1849  LEG2->AddEntry(CloneDist3, leg, "l");
1850  sprintf(leg, "Distance ideal");
1851  LEG2->AddEntry(CloneDist1, leg, "l");
1852  LEG2->Draw();*/
1853  /* gStyle->SetOptStat(000000);
1854 
1855  Cbm::SaveCanvasAsImage(can1, string(fOutputDir.Data()), "png");
1856  Cbm::SaveCanvasAsImage(can2, string(fOutputDir.Data()), "png");
1857 }
1858 */
CbmRichPoint.h
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMatch::GetMatchedLink
const CbmLink & GetMatchedLink() const
Definition: CbmMatch.h:37
CbmMCTrack::GetMomentum
void GetMomentum(TVector3 &momentum) const
Definition: CbmMCTrack.h:172
CbmTrackMatchNew::GetNofWrongHits
Int_t GetNofWrongHits() const
Definition: CbmTrackMatchNew.h:33
CbmRichMirrorSortingCorrection::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmRichMirrorSortingCorrection.cxx:1519
CbmRichMirrorSortingCorrection::GetPmtNormal
void GetPmtNormal(Int_t NofPMTPoints, vector< Double_t > &normalPMT, Double_t &normalCste)
Definition: CbmRichMirrorSortingCorrection.cxx:674
CbmHistManager::WriteToFile
void WriteToFile()
Write all histograms to current opened file.
Definition: core/base/CbmHistManager.cxx:103
CbmRichMirrorSortingCorrection::ComputeR2
void ComputeR2(vector< Double_t > &ptR2Center, vector< Double_t > &ptR2Mirr, vector< Double_t > ptM, vector< Double_t > ptC, vector< Double_t > ptR1, TGeoNavigator *navi, TString option, TString mirrorTileName)
Definition: CbmRichMirrorSortingCorrection.cxx:780
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichMirrorSortingCorrection::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmRichMirrorSortingCorrection.h:122
CbmRichRingFitterEllipseTau
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
Definition: CbmRichRingFitterEllipseTau.h:35
CbmRichMirrorSortingCorrection::fTrackCenterDistanceCorrected
Double_t fTrackCenterDistanceCorrected
Definition: CbmRichMirrorSortingCorrection.h:117
CbmHistManager::Create3
void Create3(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY, Int_t nofBinsZ, Double_t minBinZ, Double_t maxBinZ)
Helper function for creation of 3-dimensional histograms and profiles. Template argument is a real ob...
Definition: CbmHistManager.h:140
CbmRichRingFitterEllipseTau.h
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
DrawH3Profile
TH2D * DrawH3Profile(TH3 *h, Bool_t drawMean, Bool_t doGaussFit, Double_t zMin, Double_t zMax)
Definition: CbmDrawHist.cxx:369
CbmRichUtil.h
CbmHistManager::Create2
void Create2(const std::string &name, const std::string &title, Int_t nofBinsX, Double_t minBinX, Double_t maxBinX, Int_t nofBinsY, Double_t minBinY, Double_t maxBinY)
Helper function for creation of 2-dimensional histograms and profiles. Template argument is a real ob...
Definition: CbmHistManager.h:104
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
CbmRichMirrorSortingCorrection::fCopFit
CbmRichRingFitterCOP * fCopFit
Definition: CbmRichMirrorSortingCorrection.h:109
CbmRichMirrorSortingCorrection::fStudyName
TString fStudyName
Definition: CbmRichMirrorSortingCorrection.h:113
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmHistManager::H2
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
Definition: CbmHistManager.h:190
CbmGlobalTrack.h
CbmRichRing
Definition: CbmRichRing.h:17
CbmRichMirrorSortingCorrection::fHM
CbmHistManager * fHM
Definition: CbmRichMirrorSortingCorrection.h:114
CbmRichMirrorSortingCorrection::fRichRingMatches
TClonesArray * fRichRingMatches
Definition: CbmRichMirrorSortingCorrection.h:130
CbmRichMirrorSortingCorrection::fCorrectionMatching
TString fCorrectionMatching
Definition: CbmRichMirrorSortingCorrection.h:119
CbmDrawHist.h
Helper functions for drawing 1D and 2D histograms and graphs.
CbmRichMirrorSortingCorrection::InitHistProjection
void InitHistProjection()
Definition: CbmRichMirrorSortingCorrection.cxx:134
CbmRichMirrorSortingCorrection::fRichProjections
TClonesArray * fRichProjections
Definition: CbmRichMirrorSortingCorrection.h:128
CbmHistManager::H3
TH3 * H3(const std::string &name) const
Return pointer to TH3 histogram.
Definition: CbmHistManager.h:210
CbmRichRingFitterCOP
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
Definition: CbmRichRingFitterCOP.h:28
CbmRichGeoManager.h
CbmRichUtil::GetRingTrackDistance
static Double_t GetRingTrackDistance(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:20
CbmRichMirrorSortingCorrection::DrawMap
void DrawMap(Int_t strX, Int_t strY)
Definition: CbmRichMirrorSortingCorrection.cxx:1120
CbmRichMirrorSortingCorrection::fRichRings
TClonesArray * fRichRings
Definition: CbmRichMirrorSortingCorrection.h:123
CbmGlobalTrack::GetStsTrackIndex
Int_t GetStsTrackIndex() const
Definition: CbmGlobalTrack.h:38
CbmHistManager
Histogram manager.
Definition: CbmHistManager.h:41
z2
Double_t z2[nSects2]
Definition: pipe_v16a_mvdsts100.h:11
CbmRichMirrorSortingCorrection::CbmRichMirrorSortingCorrection
CbmRichMirrorSortingCorrection()
Definition: CbmRichMirrorSortingCorrection.cxx:39
CbmRichMirrorSortingCorrection::FillHistProjection
void FillHistProjection(TVector3 outPosIdeal, TVector3 outPosUnCorr, TVector3 outPos, CbmRichRingLight ringLight, vector< Double_t > normalPMT, Double_t constantePMT, string str)
Definition: CbmRichMirrorSortingCorrection.cxx:981
CbmRichMirrorSortingCorrection::FillRingTrackDistanceCorr
void FillRingTrackDistanceCorr(const CbmRichRing *richRing, const FairTrackParam *pTrack, const CbmMCTrack *mcTrack)
Definition: CbmRichMirrorSortingCorrection.cxx:1428
CbmRichConverter.h
Convert internal data classes to cbmroot common data classes.
CbmRichRingLight::GetCenterY
float GetCenterY() const
Definition: CbmRichRingLight.h:160
CbmRichMirrorSortingCorrection.h
CbmRichMirrorSortingCorrection::fTrackParams
TClonesArray * fTrackParams
Definition: CbmRichMirrorSortingCorrection.h:129
CbmTrackMatchNew.h
CbmRichMirrorSortingCorrection::ComputeP
void ComputeP(vector< Double_t > &ptPMirr, vector< Double_t > &ptPR2, vector< Double_t > normalPMT, vector< Double_t > ptM, vector< Double_t > ptR2Mirr, Double_t constantePMT)
Definition: CbmRichMirrorSortingCorrection.cxx:939
CbmRichMirrorSortingCorrection::fPmtPoints
TClonesArray * fPmtPoints
Definition: CbmRichMirrorSortingCorrection.h:127
DrawH2WithProfile
void DrawH2WithProfile(TH2 *hist, Bool_t doGaussFit, Bool_t drawOnlyMean, const string &drawOpt2D, Int_t profileColor, Int_t profileLineWidth)
Definition: CbmDrawHist.cxx:296
CbmHistManager::Create1
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
Definition: CbmHistManager.h:81
CbmRichGeoManager::RotatePoint
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
Definition: CbmRichGeoManager.cxx:407
CbmRichMirrorSortingCorrection::DrawRingTrackDistance
void DrawRingTrackDistance(Int_t k)
Definition: CbmRichMirrorSortingCorrection.cxx:1464
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMCTrack::GetGeantProcessId
UInt_t GetGeantProcessId() const
Definition: CbmMCTrack.h:69
CbmRichMirrorSortingCorrection::DrawHistProjection
void DrawHistProjection()
Definition: CbmRichMirrorSortingCorrection.cxx:1186
CbmRichMirrorSortingCorrection::fThreshold
Int_t fThreshold
Definition: CbmRichMirrorSortingCorrection.h:120
CbmRichMirrorSortingCorrection::fTrackCenterDistanceIdeal
Double_t fTrackCenterDistanceIdeal
Definition: CbmRichMirrorSortingCorrection.h:116
CbmHistManager::H1
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Definition: CbmHistManager.h:170
CbmRichMirrorSortingCorrection::fDiffHistoMap
std::map< string, TH1D * > fDiffHistoMap
Definition: CbmRichMirrorSortingCorrection.h:115
CbmRichMirrorSortingCorrection::fStsTrackMatches
TClonesArray * fStsTrackMatches
Definition: CbmRichMirrorSortingCorrection.h:131
CbmUtils.h
CbmRichRingFitterCOP.h
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
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
CbmRichMirrorSortingCorrection::fOutputDir
TString fOutputDir
Definition: CbmRichMirrorSortingCorrection.h:111
CbmHistManager::SaveCanvasToImage
void SaveCanvasToImage(const std::string &outputDir, const std::string &options="png,eps")
Save all stored canvases to images.
Definition: core/base/CbmHistManager.cxx:276
CbmRichConverter::Init
static void Init()
Initialize array of RICH hits.
Definition: CbmRichConverter.h:93
CbmRichUtil::GetRingTrackDistanceX
static Double_t GetRingTrackDistanceX(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:25
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
CbmRichRingFitterCOP::DoFit
virtual void DoFit(CbmRichRingLight *ring)
Inherited from CbmRichRingFitterBase.
Definition: CbmRichRingFitterCOP.cxx:19
CbmRichMirrorSortingCorrection::fRefPlanePoints
TClonesArray * fRefPlanePoints
Definition: CbmRichMirrorSortingCorrection.h:126
CbmRichMirrorSortingCorrection::DrawDistanceComp
void DrawDistanceComp()
Definition: CbmRichMirrorSortingCorrection.cxx:1513
CbmTrackMatchNew::GetNofTrueHits
Int_t GetNofTrueHits() const
Definition: CbmTrackMatchNew.h:32
CbmRichMirrorSortingCorrection::fMirrorPoints
TClonesArray * fMirrorPoints
Definition: CbmRichMirrorSortingCorrection.h:125
CbmMCTrack
Definition: CbmMCTrack.h:34
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmRichConverter::CopyHitsToRingLight
static void CopyHitsToRingLight(const CbmRichRing *ring1, CbmRichRingLight *ring2)
Copy hits from CbmRichRing to CbmRichRingLight.
Definition: CbmRichConverter.h:41
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmRichMirrorSortingCorrection::fCorrectionTableDir
TString fCorrectionTableDir
Definition: CbmRichMirrorSortingCorrection.h:112
CbmRichMirrorSortingCorrection::fTauFit
CbmRichRingFitterEllipseTau * fTauFit
Definition: CbmRichMirrorSortingCorrection.h:110
CbmRichRing::GetCenterY
Float_t GetCenterY() const
Definition: CbmRichRing.h:81
CbmTrackMatchNew
Definition: CbmTrackMatchNew.h:19
CbmRichMirrorSortingCorrection::fMCTracks
TClonesArray * fMCTracks
Definition: CbmRichMirrorSortingCorrection.h:124
Cbm::SaveCanvasAsImage
void SaveCanvasAsImage(TCanvas *c, const std::string &dir, const std::string &option)
Definition: CbmUtils.cxx:20
CbmRichMirrorSortingCorrection::InitHistoMap
void InitHistoMap()
Definition: CbmRichMirrorSortingCorrection.cxx:217
CbmRichMirrorSortingCorrection::IsMcPrimaryElectron
bool IsMcPrimaryElectron(const CbmMCTrack *mctrack)
Definition: CbmRichMirrorSortingCorrection.cxx:1456
CbmRichRingLight::GetCenterX
float GetCenterX() const
Definition: CbmRichRingLight.h:159
CbmRichPoint
Definition: CbmRichPoint.h:24
CbmRichMirrorSortingCorrection::fEventNb
UInt_t fEventNb
Definition: CbmRichMirrorSortingCorrection.h:108
CbmRichMirrorSortingCorrection::fTrackCenterDistanceUncorrected
Double_t fTrackCenterDistanceUncorrected
Definition: CbmRichMirrorSortingCorrection.h:118
CbmRichUtil::GetRingTrackDistanceY
static Double_t GetRingTrackDistanceY(Int_t globalTrackId)
Definition: alignment/CbmRichUtil.h:30
CbmRichMirror.h
CbmRichRingLight
Definition: CbmRichRingLight.h:39
CbmRichMirrorSortingCorrection::FillRingTrackDistance
void FillRingTrackDistance()
Definition: CbmRichMirrorSortingCorrection.cxx:1379
CbmRichRing::GetCenterX
Float_t GetCenterX() const
Definition: CbmRichRing.h:80
CbmRichMirrorSortingCorrection::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmRichMirrorSortingCorrection.cxx:68
DrawH1andFitGauss
void DrawH1andFitGauss(TH1 *hist, Bool_t drawResults, Bool_t doScale, Double_t userRangeMin, Double_t userRangeMax)
Definition: CbmDrawHist.cxx:266
CbmRichMirrorSortingCorrection::~CbmRichMirrorSortingCorrection
virtual ~CbmRichMirrorSortingCorrection()
Definition: CbmRichMirrorSortingCorrection.cxx:66
CbmRichMirrorSortingCorrection
Definition: CbmRichMirrorSortingCorrection.h:18
CbmRichMirrorSortingCorrection::Exec
virtual void Exec(Option_t *option)
Inherited from FairTask.
Definition: CbmRichMirrorSortingCorrection.cxx:440