CbmRoot
CbmRichCorrection.cxx
Go to the documentation of this file.
1 // ---------- Original Headers ---------- //
2 #include "CbmRichCorrection.h"
3 #include "FairLogger.h"
4 #include "FairRootManager.h"
5 
6 #include "TClonesArray.h"
7 
8 #include "CbmDrawHist.h"
9 #include "CbmRichHit.h"
10 #include "TCanvas.h"
11 #include "TF1.h"
12 #include "TH1D.h"
13 #include "TH2D.h"
14 
15 #include <iostream>
16 #include <vector>
17 
18 // ---------- Included Headers ---------- //
19 #include "CbmMCTrack.h"
20 #include "CbmRichConverter.h"
21 #include "CbmRichPoint.h"
22 #include "CbmRichRingFitterCOP.h"
24 #include "CbmRichRingLight.h"
25 #include "CbmTrackMatchNew.h"
26 #include "CbmUtils.h"
27 #include "FairTrackParam.h"
28 #include "FairVolume.h"
29 #include "TEllipse.h"
30 #include "TGeoManager.h"
31 #include <algorithm>
32 #include <fstream>
33 #include <iomanip>
34 #include <stdlib.h>
35 //#include <stdio.h>
36 #include "CbmGlobalTrack.h"
37 #include "CbmRichGeoManager.h"
38 #include "CbmRichHitProducer.h"
39 
40 //#include "TLorentzVector.h"
41 #include "TGeoSphere.h"
42 #include "TVirtualMC.h"
43 class TGeoNode;
44 class TGeoVolume;
45 class TGeoShape;
46 class TGeoMatrix;
47 
48 #include <boost/assign/list_of.hpp>
49 using boost::assign::list_of;
50 #include "TStyle.h"
51 #include <sstream>
52 
54  : FairTask()
55  , fRichHits(NULL)
56  , fRichRings(NULL)
57  , fRichProjections(NULL)
58  , fRichMirrorPoints(NULL)
59  , fRichMCPoints(NULL)
60  , fMCTracks(NULL)
61  , fRichRingMatches(NULL)
62  , fRichRefPlanePoints(NULL)
63  , fRichPoints(NULL)
64  , fGlobalTracks(NULL)
65  , fHM(NULL)
66  ,
67  //fGP(),
68  fNumbAxis(0)
69  , fTile(0)
70  , fEventNum(0)
71  , fOutputDir("")
72  , fRunTitle("")
73  , fAxisRotTitle("")
74  , fDrawProjection(kTRUE)
75  , fIsMeanCenter(kFALSE)
76  , fIsReconstruction(kFALSE)
77  , fCopFit(NULL)
78  , fTauFit(NULL)
79  , fPhi() {}
80 
82 
84  FairRootManager* manager = FairRootManager::Instance();
85 
86  fRichHits = (TClonesArray*) manager->GetObject("RichHit");
87  if (NULL == fRichHits) {
88  Fatal("CbmRichCorrection::Init", "No RichHit array !");
89  }
90 
91  fRichRings = (TClonesArray*) manager->GetObject("RichRing");
92  if (NULL == fRichRings) {
93  Fatal("CbmRichCorrection::Init", "No RichRing array !");
94  }
95 
96  fRichProjections = (TClonesArray*) manager->GetObject("RichProjection");
97  if (NULL == fRichProjections) {
98  Fatal("CbmRichCorrection::Init", "No RichProjection array !");
99  }
100 
101  fRichMirrorPoints = (TClonesArray*) manager->GetObject("RichMirrorPoint");
102  if (NULL == fRichMirrorPoints) {
103  Fatal("CbmRichCorrection::Init", "No RichMirrorPoints array !");
104  }
105 
106  fRichMCPoints = (TClonesArray*) manager->GetObject("RichPoint");
107  if (NULL == fRichMCPoints) {
108  Fatal("CbmRichCorrection::Init", "No RichMCPoints array !");
109  }
110 
111  fMCTracks = (TClonesArray*) manager->GetObject("MCTrack");
112  if (NULL == fMCTracks) {
113  Fatal("CbmRichCorrection::Init", "No MCTracks array !");
114  }
115 
116  fRichRingMatches = (TClonesArray*) manager->GetObject("RichRingMatch");
117  if (NULL == fRichRingMatches) {
118  Fatal("CbmRichCorrection::Init", "No RichRingMatches array !");
119  }
120 
121  fRichRefPlanePoints = (TClonesArray*) manager->GetObject("RefPlanePoint");
122  if (NULL == fRichRefPlanePoints) {
123  Fatal("CbmRichCorrection::Init", "No RichRefPlanePoint array !");
124  }
125 
126  fRichPoints = (TClonesArray*) manager->GetObject("RichPoint");
127  if (NULL == fRichPoints) {
128  Fatal("CbmRichCorrection::Init", "No RichPoint array !");
129  }
130 
131  fGlobalTracks = (TClonesArray*) manager->GetObject("GlobalTrack");
132  if (NULL == fGlobalTracks) {
133  Fatal("CbmRichCorrection::Init", "No GlobalTrack array!");
134  }
135 
139 
141 
142  return kSUCCESS;
143 }
144 
146  fHM = new CbmHistManager();
147  /* for (std::map<string,string>::iterator it=fPathsMap.begin(); it!=fPathsMap.end(); ++it) { // Initialize all the histograms, using map IDs as inputs.
148  string name = "fHMCPoints_" + it->second; // it->first gives the paths; it->second gives the ID.
149  fHM->Create2<TH2D>(name, name + ";X_Axis [];Y_Axis [];Entries", 2001, -100., 100.,2001, 60., 210.);
150  }
151 */
152  Double_t upperScaleLimit = 3.5, bin = 400.;
153  // fhDistance => fhDistanceCenterToExtrapolatedTrack.
154  fHM->Create1<TH1D>("fhDistanceCenterToExtrapolatedTrack",
155  "fhDistanceCenterToExtrapolatedTrack;Distance fitted "
156  "center to extrapolated track;Number of entries",
157  bin,
158  0.,
159  2.);
160  fHM->Create1<TH1D>("fhDistanceCorrected",
161  "fhDistanceCorrected;Distance a [cm];A.U.",
162  bin,
163  0.,
164  upperScaleLimit);
165  fHM->Create1<TH1D>(
166  "fhDifferenceX",
167  "fhDifferenceX;Difference in X (fitted center - extrapolated track);A.U.",
168  bin,
169  0.,
170  upperScaleLimit);
171  fHM->Create1<TH1D>(
172  "fhDifferenceY",
173  "fhDifferenceY;Difference in Y (fitted center - extrapolated track);A.U.",
174  bin,
175  0.,
176  upperScaleLimit);
177 
178  fHM->Create1<TH1D>("fhDistanceUncorrected",
179  "fhDistanceUncorrected;Distance a [cm];A.U.",
180  bin,
181  0.,
182  upperScaleLimit);
183  fHM->Create1<TH1D>(
184  "fhDifferenceXUncorrected",
185  "fhDifferenceXUncorrected;Difference in X uncorrected [cm];A.U.",
186  bin,
187  0.,
188  upperScaleLimit);
189  fHM->Create1<TH1D>(
190  "fhDifferenceYUncorrected",
191  "fhDifferenceYUncorrected;Difference in Y uncorrected [cm];A.U.",
192  bin,
193  0.,
194  upperScaleLimit);
195 
196  fHM->Create1<TH1D>("fhDistanceIdeal",
197  "fhDistanceIdeal;Distance a [cm];A.U.",
198  bin,
199  0.,
200  upperScaleLimit);
201  fHM->Create1<TH1D>("fhDifferenceXIdeal",
202  "fhDifferenceXIdeal;Difference in X ideal [cm];A.U.",
203  bin,
204  0.,
205  upperScaleLimit);
206  fHM->Create1<TH1D>("fhDifferenceYIdeal",
207  "fhDifferenceYIdeal;Difference in Y ideal [cm];A.U.",
208  bin,
209  0.,
210  upperScaleLimit);
211 
212  fHM->Create1<TH1D>("fHistoDiffX",
213  "fHistoDiffX;Histogram difference between corrected and "
214  "ideal X positions;A.U.",
215  bin,
216  0.,
217  upperScaleLimit);
218  fHM->Create1<TH1D>("fHistoDiffY",
219  "fHistoDiffY;Histogram difference between corrected and "
220  "ideal Y positions;A.U.",
221  bin,
222  0.,
223  upperScaleLimit);
224 
225  fHM->Create1<TH1D>("fHistoBoA",
226  "fHistoBoA;Histogram B axis over A axis;A.U.",
227  bin,
228  0.,
229  upperScaleLimit);
230 }
231 
232 void CbmRichCorrection::Exec(Option_t* /*option*/) {
233  cout << endl
234  << "//"
235  "--------------------------------------------------------------------"
236  "------------------------------------------//"
237  << endl;
238  cout << "//---------------------------------------- CbmRichCorrection - EXEC "
239  "Function ----------------------------------------//"
240  << endl;
241  cout << "//"
242  "--------------------------------------------------------------------"
243  "--------------------------------------------------//"
244  << endl;
245  fEventNum++;
246  //LOG(debug2) << "CbmRichCorrection : Event #" << fEventNum;
247  cout << "CbmRichCorrection : Event #" << fEventNum << endl;
248 
249  Int_t nofRingsInEvent = fRichRings->GetEntries();
250  Int_t nofMirrorPoints = fRichMirrorPoints->GetEntries();
251  Int_t nofHitsInEvent = fRichHits->GetEntries();
252  Int_t NofMCPoints = fRichMCPoints->GetEntriesFast();
253  Int_t NofMCTracks = fMCTracks->GetEntriesFast();
254  cout << "Nb of rings in evt = " << nofRingsInEvent
255  << ", nb of mirror points = " << nofMirrorPoints
256  << ", nb of hits in evt = " << nofHitsInEvent
257  << ", nb of Monte-Carlo points = " << NofMCPoints
258  << " and nb of Monte-Carlo tracks = " << NofMCTracks << endl
259  << endl;
260 
261  TClonesArray* projectedPoint;
262 
263  if (nofRingsInEvent == 0) {
264  cout << "Error no rings registered in event." << endl << endl;
265  } else {
267  }
268 }
269 
271  cout << "//------------------------------ CbmRichCorrection: Projection "
272  "Producer ------------------------------//"
273  << endl
274  << endl;
275 
276  Int_t NofMirrorPoints = fRichMirrorPoints->GetEntriesFast();
277  Int_t NofRingsInEvent = fRichRings->GetEntries();
278  Int_t NofGTracks = fGlobalTracks->GetEntriesFast();
279  Int_t NofRefPlanePoints = fRichRefPlanePoints->GetEntriesFast();
280  Int_t NofPMTPoints = fRichPoints->GetEntriesFast();
281 
282  // Declaration of points coordinates.
283  Double_t sphereRadius = 300., constantePMT = 0.;
284  vector<Double_t> ptM(3), ptMNew(3), ptC(3), ptCNew(3), ptR1(3), momR1(3),
285  normalPMT(3), ptR2Mirr(3), ptR2Center(3), ptPMirr(3), ptPR2(3),
286  ptTileCenter(3);
287  vector<Double_t> ptCIdeal(3), ptR2CenterUnCorr(3), ptR2CenterIdeal(3),
288  ptR2MirrUnCorr(3), ptR2MirrIdeal(3), ptPMirrUnCorr(3), ptPMirrIdeal(3),
289  ptPR2UnCorr(3), ptPR2Ideal(3);
290  Double_t reflectedPtCooVectSphereUnity[] = {0., 0., 0.};
291  TVector3 outPos, outPosUnCorr, outPosIdeal;
292  // Declaration of ring parameters.
293  Double_t ringCenter[] = {0., 0., 0.}, distToExtrapTrackHit = 0.,
294  distToExtrapTrackHitInPlane = 0.;
295  //Declarations related to geometry.
296  Int_t mirrTrackID = -1, pmtTrackID = -1, refPlaneTrackID = -1,
297  motherID = -100, pmtMotherID = -100;
298  CbmMCTrack* track = NULL;
299  TGeoNavigator* navi;
300  TGeoNode* mirrNode;
301  TGeoMatrix *mirrMatrix, *pmtMatrix, *richMatrix;
302 
304  Double_t pmtPlaneX = gp->fPmt.fPlaneX;
305  Double_t pmtPlaneY = gp->fPmt.fPlaneY;
306  Double_t pmtWidth = gp->fPmt.fWidth;
307  Double_t pmtHeight = gp->fPmt.fHeight;
308 
309  GetPmtNormal(NofPMTPoints, normalPMT, constantePMT);
310  cout << "Calculated normal vector to PMT plane = {" << normalPMT.at(0) << ", "
311  << normalPMT.at(1) << ", " << normalPMT.at(2)
312  << "} and constante d = " << constantePMT << endl
313  << endl;
314 
315  for (Int_t iMirr = 0; iMirr < NofMirrorPoints; iMirr++) {
316  //cout << "NofMirrorPoints = " << NofMirrorPoints << " and iMirr = " << iMirr << endl;
317  CbmRichPoint* mirrPoint = (CbmRichPoint*) fRichMirrorPoints->At(iMirr);
318  mirrTrackID = mirrPoint->GetTrackID();
319  //cout << "Mirror track ID = " << mirrTrackID << endl;
320  if (mirrTrackID <= -1) {
321  cout << "Mirror track ID <= 1 !!!" << endl;
322  cout << "----------------------------------- End of loop N°" << iMirr + 1
323  << " on the mirror points. -----------------------------------"
324  << endl
325  << endl;
326  continue;
327  }
328  track = (CbmMCTrack*) fMCTracks->At(mirrTrackID);
329  motherID = track->GetMotherId();
330  if (motherID == -1) {
331  //cout << "Mirror motherID == -1 !!!" << endl << endl;
332  ptM.at(0) = mirrPoint->GetX(), ptM.at(1) = mirrPoint->GetY(),
333  ptM.at(2) = mirrPoint->GetZ();
334  //cout << "Mirror Point coordinates; x = " << ptM.at(0) << ", y = " << ptM.at(1) << " and z = " << ptM.at(2) << endl;
335  mirrNode = gGeoManager->FindNode(ptM.at(0), ptM.at(1), ptM.at(2));
336  if (mirrNode) {
337  //cout << "Mirror node found! Mirror node name = " << mirrNode->GetName() << endl;
338  navi = gGeoManager->GetCurrentNavigator();
339  cout << "Navigator path: " << navi->GetPath() << endl;
340  cout << "Coordinates of sphere center: " << endl;
341  navi->GetCurrentMatrix()->Print();
342  if (fIsMeanCenter)
344  navi,
345  ptC); //IF NO INFORMATION ON MIRRORS ARE KNOWN (TO BE USED IN RECONSTRUCTION STEP) !!!
346  else {
347  ptCIdeal.at(0) = navi->GetCurrentMatrix()->GetTranslation()[0];
348  ptCIdeal.at(1) = navi->GetCurrentMatrix()->GetTranslation()[1];
349  ptCIdeal.at(2) = navi->GetCurrentMatrix()->GetTranslation()[2];
350  }
351  cout << "Coordinates of tile center: " << endl;
352  navi->GetMotherMatrix()->Print();
353  ptC.at(0) = 0., ptC.at(1) = 132.594000, ptC.at(2) = 54.267226;
354  cout
355  << "Sphere center coordinates of the aligned mirror tile, ideal = {"
356  << ptCIdeal.at(0) << ", " << ptCIdeal.at(1) << ", " << ptCIdeal.at(2)
357  << "}" << endl;
358  cout << "Sphere center coordinates of the rotated mirror tile, w/ "
359  "GeoManager, = {"
360  << ptC.at(0) << ", " << ptC.at(1) << ", " << ptC.at(2)
361  << "} and sphere inner radius = " << sphereRadius << endl
362  << endl;
363  //ptCNew = RotateSphereCenter(ptTileCenter, ptC, navi);
364 
365  for (Int_t iRefl = 0; iRefl < NofRefPlanePoints; iRefl++) {
366  //new((*projectedPoint)[iRefl]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
367  CbmRichPoint* refPlanePoint =
368  (CbmRichPoint*) fRichRefPlanePoints->At(iRefl);
369  refPlaneTrackID = refPlanePoint->GetTrackID();
370  //cout << "Reflective plane track ID = " << refPlaneTrackID << endl;
371  if (mirrTrackID == refPlaneTrackID) {
372  //cout << "IDENTICAL TRACK ID FOUND !!!" << endl << endl;
373  ptR1.at(0) = refPlanePoint->GetX(),
374  ptR1.at(1) = refPlanePoint->GetY(),
375  ptR1.at(2) = refPlanePoint->GetZ();
376  momR1.at(0) = refPlanePoint->GetPx(),
377  momR1.at(1) = refPlanePoint->GetPy(),
378  momR1.at(2) = refPlanePoint->GetPz();
379  cout << "Reflective Plane Point coordinates = {" << ptR1.at(0)
380  << ", " << ptR1.at(1) << ", " << ptR1.at(2) << "}" << endl;
381  cout << "And reflective Plane Point momenta = {" << momR1.at(0)
382  << ", " << momR1.at(1) << ", " << momR1.at(2) << "}" << endl;
383  cout << "Mirror Point coordinates = {" << ptM.at(0) << ", "
384  << ptM.at(1) << ", " << ptM.at(2) << "}" << endl;
385  CalculateMirrorIntersection(ptM, ptCIdeal, ptMNew);
386 
387  if (fIsMeanCenter) {
388  GetMirrorIntersection(ptM, ptR1, momR1, ptC, sphereRadius);
389  // From ptM: how to retrieve tile ID ???
390  // => Compare distance of ptM to tile centers
391  }
392 
393  ComputeR2(ptR2CenterUnCorr,
394  ptR2MirrUnCorr,
395  ptM,
396  ptC,
397  ptR1,
398  navi,
399  "Uncorrected");
400  ComputeR2(ptR2Center, ptR2Mirr, ptM, ptC, ptR1, navi, "Corrected");
401  ComputeR2(ptR2CenterIdeal,
402  ptR2MirrIdeal,
403  ptM,
404  ptCIdeal,
405  ptR1,
406  navi,
407  "Uncorrected");
408 
409  ComputeP(ptPMirrUnCorr,
410  ptPR2UnCorr,
411  normalPMT,
412  ptM,
413  ptR2MirrUnCorr,
414  constantePMT);
415  ComputeP(ptPMirr, ptPR2, normalPMT, ptM, ptR2Mirr, constantePMT);
416  ComputeP(ptPMirrIdeal,
417  ptPR2Ideal,
418  normalPMT,
419  ptM,
420  ptR2MirrIdeal,
421  constantePMT);
422 
423  TVector3 inPosUnCorr(
424  ptPMirrUnCorr.at(0), ptPMirrUnCorr.at(1), ptPMirrUnCorr.at(2));
426  &outPosUnCorr);
427  cout << endl
428  << "New mirror points coordinates = {" << outPosUnCorr.x()
429  << ", " << outPosUnCorr.y() << ", " << outPosUnCorr.z() << "}"
430  << endl;
431  TVector3 inPos(ptPMirr.at(0), ptPMirr.at(1), ptPMirr.at(2));
432  CbmRichGeoManager::GetInstance().RotatePoint(&inPos, &outPos);
433  cout << "New mirror points coordinates = {" << outPos.x() << ", "
434  << outPos.y() << ", " << outPos.z() << "}" << endl;
435  TVector3 inPosIdeal(
436  ptPMirrIdeal.at(0), ptPMirrIdeal.at(1), ptPMirrIdeal.at(2));
438  &outPosIdeal);
439  cout << "New mirror points coordinates = {" << outPosIdeal.x()
440  << ", " << outPosIdeal.y() << ", " << outPosIdeal.z() << "}"
441  << endl
442  << endl;
443 
444  /*for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
445  CbmRichPoint *pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
446  pmtTrackID = pmtPoint->GetTrackID();
447  CbmMCTrack* track3 = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
448  pmtMotherID = track3->GetMotherId();
449  //cout << "pmt mother ID = " << pmtMotherID << endl;
450  if (pmtMotherID == mirrTrackID) {
451  ptP[0] = pmtPoint->GetX(), ptP[1] = pmtPoint->GetY(), ptP[2] = pmtPoint->GetZ();
452  //cout << "Identical mirror track ID and PMT mother ID !!!" << endl;
453  //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
454  }
455  }
456  cout << "Looking for PMT hits: end." << endl << endl;*/
457  }
458  //else { cout << "No identical track ID between mirror point and reflective plane point found ..." << endl << endl; }
459  }
460 
461  /*for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
462  CbmRichPoint *pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
463  cout << "PMT points = {" << pmtPoint->GetX() << ", " << pmtPoint->GetY() << ", " << pmtPoint->GetZ() << "}" << endl;
464  TVector3 inputPoint(pmtPoint->GetX(), pmtPoint->GetY(), pmtPoint->GetZ());
465  TVector3 outputPoint;
466  CbmRichHitProducer::TiltPoint(&inputPoint, &outputPoint, fGP.fPmtPhi, fGP.fPmtTheta, fGP.fPmtZOrig);
467  cout << "New PMT points after rotation of the PMT plane: " << endl;
468  cout << outputPoint.X() << "\t" << outputPoint.Y() << "\t" << outputPoint.Z() << endl;
469  }*/
470 
471  FillHistProjection(outPosIdeal,
472  outPosUnCorr,
473  outPos,
474  NofGTracks,
475  normalPMT,
476  constantePMT);
477  } else {
478  cout << "Not a mother particle ..." << endl;
479  }
480  cout << "----------------------------------- "
481  << "End of loop N°" << iMirr + 1 << " on the mirror points."
482  << " -----------------------------------" << endl
483  << endl;
484  }
485  }
486 }
487 
488 void CbmRichCorrection::GetPmtNormal(Int_t NofPMTPoints,
489  vector<Double_t>& normalPMT,
490  Double_t& normalCste) {
491  //cout << endl << "//------------------------------ CbmRichCorrection: Calculate PMT Normal ------------------------------//" << endl << endl;
492 
493  Int_t pmtTrackID, pmtMotherID;
494  Double_t buffNormX = 0., buffNormY = 0., buffNormZ = 0., k = 0.,
495  scalarProd = 0.;
496  Double_t pmtPt[] = {0., 0., 0.};
497  Double_t a[] = {0., 0., 0.}, b[] = {0., 0., 0.}, c[] = {0., 0., 0.};
498  CbmMCTrack* track;
499 
500  /*
501  * 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.
502  * Formula used is: vect(AB) x vect(AC) = normal.
503  * Normalize the normal vector obtained and check with three random points from the PMT plane, whether the scalar product is equal to zero.
504  */
505  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
506  CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
507  pmtTrackID = pmtPoint->GetTrackID();
508  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
509  pmtMotherID = track->GetMotherId();
510  a[0] = pmtPoint->GetX(), a[1] = pmtPoint->GetY(), a[2] = pmtPoint->GetZ();
511  //cout << "a[0] = " << a[0] << ", a[1] = " << a[1] << " et a[2] = " << a[2] << endl;
512  break;
513  }
514  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
515  CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
516  pmtTrackID = pmtPoint->GetTrackID();
517  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
518  pmtMotherID = track->GetMotherId();
519  //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
520  if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2)
521  + TMath::Power(a[1] - pmtPoint->GetY(), 2)
522  + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
523  > 7) {
524  b[0] = pmtPoint->GetX(), b[1] = pmtPoint->GetY(), b[2] = pmtPoint->GetZ();
525  //cout << "b[0] = " << b[0] << ", b[1] = " << b[1] << " et b[2] = " << b[2] << endl;
526  break;
527  }
528  }
529  for (Int_t iPmt = 0; iPmt < NofPMTPoints; iPmt++) {
530  CbmRichPoint* pmtPoint = (CbmRichPoint*) fRichPoints->At(iPmt);
531  pmtTrackID = pmtPoint->GetTrackID();
532  track = (CbmMCTrack*) fMCTracks->At(pmtTrackID);
533  pmtMotherID = track->GetMotherId();
534  //cout << "PMT Point coordinates; x = " << pmtPoint->GetX() << ", y = " << pmtPoint->GetY() << " and z = " << pmtPoint->GetZ() << endl;
535  if (TMath::Sqrt(TMath::Power(a[0] - pmtPoint->GetX(), 2)
536  + TMath::Power(a[1] - pmtPoint->GetY(), 2)
537  + TMath::Power(a[2] - pmtPoint->GetZ(), 2))
538  > 7
539  && TMath::Sqrt(TMath::Power(b[0] - pmtPoint->GetX(), 2)
540  + TMath::Power(b[1] - pmtPoint->GetY(), 2)
541  + TMath::Power(b[2] - pmtPoint->GetZ(), 2))
542  > 7) {
543  c[0] = pmtPoint->GetX(), c[1] = pmtPoint->GetY(), c[2] = pmtPoint->GetZ();
544  //cout << "c[0] = " << c[0] << ", c[1] = " << c[1] << " et c[2] = " << c[2] << endl;
545  break;
546  }
547  }
548 
549  k = (b[0] - a[0]) / (c[0] - a[0]);
550  if ((b[1] - a[1]) - (k * (c[1] - a[1])) == 0
551  || (b[2] - a[2]) - (k * (c[2] - a[2])) == 0) {
552  cout << "Error in normal calculation, vect_AB and vect_AC are collinear."
553  << endl;
554  } else {
555  buffNormX = (b[1] - a[1]) * (c[2] - a[2]) - (b[2] - a[2]) * (c[1] - a[1]);
556  buffNormY = (b[2] - a[2]) * (c[0] - a[0]) - (b[0] - a[0]) * (c[2] - a[2]);
557  buffNormZ = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
558  normalPMT.at(0) =
559  buffNormX
560  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
561  + TMath::Power(buffNormZ, 2));
562  normalPMT.at(1) =
563  buffNormY
564  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
565  + TMath::Power(buffNormZ, 2));
566  normalPMT.at(2) =
567  buffNormZ
568  / TMath::Sqrt(TMath::Power(buffNormX, 2) + TMath::Power(buffNormY, 2)
569  + TMath::Power(buffNormZ, 2));
570  }
571 
572  CbmRichPoint* pmtPoint1 = (CbmRichPoint*) fRichPoints->At(20);
573  scalarProd = normalPMT.at(0) * (pmtPoint1->GetX() - a[0])
574  + normalPMT.at(1) * (pmtPoint1->GetY() - a[1])
575  + normalPMT.at(2) * (pmtPoint1->GetZ() - a[2]);
576  //cout << "1st scalar product between vectAM and normale = " << scalarProd << endl;
577  // 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.
578  normalCste =
579  -1
580  * (normalPMT.at(0) * pmtPoint1->GetX() + normalPMT.at(1) * pmtPoint1->GetY()
581  + normalPMT.at(2) * pmtPoint1->GetZ());
582  CbmRichPoint* pmtPoint2 = (CbmRichPoint*) fRichPoints->At(15);
583  scalarProd = normalPMT.at(0) * (pmtPoint2->GetX() - a[0])
584  + normalPMT.at(1) * (pmtPoint2->GetY() - a[1])
585  + normalPMT.at(2) * (pmtPoint2->GetZ() - a[2]);
586  //cout << "2nd scalar product between vectAM and normale = " << scalarProd << endl;
587  CbmRichPoint* pmtPoint3 = (CbmRichPoint*) fRichPoints->At(25);
588  scalarProd = normalPMT.at(0) * (pmtPoint3->GetX() - a[0])
589  + normalPMT.at(1) * (pmtPoint3->GetY() - a[1])
590  + normalPMT.at(2) * (pmtPoint3->GetZ() - a[2]);
591  //cout << "3nd scalar product between vectAM and normale = " << scalarProd << endl;
592 }
593 
594 void CbmRichCorrection::GetMeanSphereCenter(TGeoNavigator* navi,
595  vector<Double_t>& ptC) {
596  const Char_t* topNodePath;
597  topNodePath = gGeoManager->GetTopNode()->GetName();
598  cout << "Top node path: " << topNodePath << endl;
599  TGeoVolume* rootTop;
600  rootTop = gGeoManager->GetTopVolume();
601  rootTop->Print();
602 
603  TGeoIterator nextNode(rootTop);
604  TGeoNode* curNode;
605  const TGeoMatrix* curMatrix;
606  const Double_t*
607  curNodeTranslation; // 3 components - pointers to some memory which is provided by ROOT
608  const Double_t*
609  curNodeRotationM; // 9 components - pointers to some memory which is provided by ROOT
610  TString filterName0("mirror_tile_type0");
611  TString filterName1("mirror_tile_type1");
612  TString filterName2("mirror_tile_type2");
613  TString filterName3("mirror_tile_type3");
614  TString filterName4("mirror_tile_type4");
615  TString filterName5("mirror_tile_type5");
616  Int_t counter = 0;
617  Double_t sphereXTot = 0., sphereYTot = 0., sphereZTot = 0.;
618 
619  while ((curNode = nextNode())) {
620  TString nodeName(curNode->GetName());
621  TString nodePath;
622 
623  // Filter using volume name, not node name
624  // But you can do 'if (nodeName.Contains("filter"))'
625  if (curNode->GetVolume()->GetName() == filterName0
626  || curNode->GetVolume()->GetName() == filterName1
627  || curNode->GetVolume()->GetName() == filterName2
628  || curNode->GetVolume()->GetName() == filterName3
629  || curNode->GetVolume()->GetName() == filterName4
630  || curNode->GetVolume()->GetName() == filterName5) {
631  if (curNode->GetNdaughters() == 0) {
632  // All deepest nodes of mirror tiles here (leaves)
633  // Thus we get spherical surface centers
634  nextNode.GetPath(nodePath);
635  curMatrix = nextNode.GetCurrentMatrix();
636  curNodeTranslation = curMatrix->GetTranslation();
637  curNodeRotationM = curMatrix->GetRotationMatrix();
638  printf("%s tr:\t", nodePath.Data());
639  printf("%08f\t%08f\t%08f\t\n",
640  curNodeTranslation[0],
641  curNodeTranslation[1],
642  curNodeTranslation[2]);
643  if (curNodeTranslation[1]
644  > 0) { // CONDITION FOR UPPER MIRROR WALL STUDY
645  sphereXTot += curNodeTranslation[0];
646  sphereYTot += curNodeTranslation[1];
647  sphereZTot += curNodeTranslation[2];
648  counter++;
649  }
650  }
651  }
652  }
653  ptC.at(0) = sphereXTot / counter;
654  ptC.at(1) = sphereYTot / counter;
655  ptC.at(2) = sphereZTot / counter;
656 
657  counter = 0;
658  nextNode.Reset();
659 }
660 
661 void CbmRichCorrection::GetMirrorIntersection(vector<Double_t>& ptM,
662  vector<Double_t> ptR1,
663  vector<Double_t> momR1,
664  vector<Double_t> ptC,
665  Double_t sphereRadius) {
666  Double_t a = 0., b = 0., c = 0., d = 0., k0 = 0., k1 = 0., k2 = 0.;
667 
668  a = TMath::Power(momR1.at(0), 2) + TMath::Power(momR1.at(1), 2)
669  + TMath::Power(momR1.at(2), 2);
670  b = 2
671  * (momR1.at(0) * (ptR1.at(0) - ptC.at(0))
672  + momR1.at(1) * (ptR1.at(1) - ptC.at(1))
673  + momR1.at(2) * (ptR1.at(2) - ptC.at(2)));
674  c = TMath::Power(ptR1.at(0) - ptC.at(0), 2)
675  + TMath::Power(ptR1.at(1) - ptC.at(1), 2)
676  + TMath::Power(ptR1.at(2) - ptC.at(2), 2) - TMath::Power(sphereRadius, 2);
677  d = b * b - 4 * a * c;
678  cout << "d = " << d << endl;
679 
680  if (d < 0) {
681  cout
682  << "Error no solution to degree 2 equation found ; discriminant below 0."
683  << endl;
684  ptM.at(0) = 0., ptM.at(1) = 0., ptM.at(2) = 0.;
685  } else if (d == 0) {
686  cout << "One solution to degree 2 equation found." << endl;
687  k0 = -b / (2 * a);
688  ptM.at(0) = ptR1.at(0) + k0 * momR1.at(0);
689  ptM.at(1) = ptR1.at(1) + k0 * momR1.at(1);
690  ptM.at(2) = ptR1.at(2) + k0 * momR1.at(2);
691  } else if (d > 0) {
692  cout << "Two solutions to degree 2 equation found." << endl;
693  k1 = ((-b - TMath::Sqrt(d)) / (2 * a));
694  k2 = ((-b + TMath::Sqrt(d)) / (2 * a));
695 
696  if (ptR1.at(2) + k1 * momR1.at(2) > ptR1.at(2) + k2 * momR1.at(2)) {
697  ptM.at(0) = ptR1.at(0) + k1 * momR1.at(0);
698  ptM.at(1) = ptR1.at(1) + k1 * momR1.at(1);
699  ptM.at(2) = ptR1.at(2) + k1 * momR1.at(2);
700  } else if (ptR1.at(2) + k1 * momR1.at(2) < ptR1.at(2) + k2 * momR1.at(2)) {
701  ptM.at(0) = ptR1.at(0) + k2 * momR1.at(0);
702  ptM.at(1) = ptR1.at(1) + k2 * momR1.at(1);
703  ptM.at(2) = ptR1.at(2) + k2 * momR1.at(2);
704  }
705  }
706 }
707 
708 vector<Double_t> CbmRichCorrection::RotateSphereCenter(vector<Double_t> ptM,
709  vector<Double_t> ptC,
710  TGeoNavigator* navi) {
711  vector<Double_t> ptCNew(3), ptCNew2(3), ptCNew3(3);
712  Double_t cosPhi = 0., sinPhi = 0., cosTheta = 0., sinTheta = 0., phi2 = 0.,
713  theta2 = 0.;
714  Double_t diff[3], transfoMat[3][3], invMat[3][3], corrMat[3][3], buff1[3][3],
715  buff2[3][3], buff3[3][3], buff4[3][3], buff5[3][3], RotX[3][3], RotY[3][3];
716  Double_t corrMat2[3][3], RotX2[3][3], RotY2[3][3];
717  InvertMatrix(transfoMat, invMat, navi);
718  /*for (Int_t i=0; i<3; i++) {
719  for (Int_t j=0; j<3; j++) {
720  cout << invMat[i][j] << "\t";
721  }
722  cout << endl;
723  }*/
724 
725  // Reading misalignment information from correction_param.txt text file.
726  vector<Double_t> outputFit(4);
727  ifstream corr_file;
728  corr_file.open("correction_param.txt");
729  if (corr_file.is_open()) {
730  for (Int_t i = 0; i < 4; i++) {
731  corr_file >> outputFit.at(i);
732  }
733  corr_file.close();
734  } else {
735  cout << "Error in CbmRichCorrection: unable to open parameter file!" << endl
736  << endl;
737  sleep(5);
738  }
739  cout << "Misalignment parameters read from file = [" << outputFit.at(0)
740  << " ; " << outputFit.at(1) << " ; " << outputFit.at(2) << " ; "
741  << outputFit.at(3) << "]" << endl;
742 
743  // Initializing the matrices used for further calculations.
744  for (Int_t i = 0; i < 3; i++) {
745  for (Int_t j = 0; j < 3; j++) {
746  corrMat[i][j] = 0.;
747  corrMat2[i][j] = 0.;
748  buff1[i][j] = 0.;
749  buff2[i][j] = 0.;
750  buff3[i][j] = 0.;
751  buff4[i][j] = 0.;
752  buff5[i][j] = 0.;
753  RotX[i][j] = 0.;
754  RotX2[i][j] = 0.;
755  RotY[i][j] = 0.;
756  RotY2[i][j] = 0.;
757  }
758  ptCNew.at(i) = 0.;
759  ptCNew2.at(i) = 0.;
760  ptCNew3.at(i) = 0.;
761  }
762 
763  //Initializing the cosine and sine functions, using inputs from text file. Phi (resp. Theta) angle corresponds to calculated rotation around X (resp. Y) axis.
764  cosPhi = TMath::Cos(outputFit.at(0));
765  sinPhi = TMath::Sin(outputFit.at(0));
766  cosTheta = TMath::Cos(outputFit.at(1));
767  sinTheta = TMath::Sin(outputFit.at(1));
768 
769  //Initializing the rotation matrices for rotations around X and Y axes.
770  // Y towards Z is the rotation direction defined in the tile frame, which is the same definition as for the global
771  // frame. But as the X axis direction is opposite in the two frames, to correct for misalignment, the rotation
772  // direction remains unchanged in the global frame.
773  // So define rotation around X axis, with Y towards Z, in the global frame:
774  RotX[0][0] = 1;
775  RotX[0][1] = 0;
776  RotX[0][2] = 0;
777  RotX[1][0] = 0;
778  RotX[1][1] = cosPhi;
779  RotX[1][2] = -1 * sinPhi;
780  RotX[2][0] = 0;
781  RotX[2][1] = sinPhi;
782  RotX[2][2] = cosPhi;
783  // X towards Z is the rotation direction defined in the tile frame, which is the same definition as for the global
784  // frame. And as the Y axes direction in the tile and global frames are identical, the rotation direction for the
785  // correction is the opposite in the global frame - in order to correct for the misalignment.
786  // So define rotation around Y axis, with Z towards X, in the global frame:
787  RotY[0][0] = cosTheta;
788  RotY[0][1] = 0;
789  RotY[0][2] = sinTheta;
790  RotY[1][0] = 0;
791  RotY[1][1] = 1;
792  RotY[1][2] = 0;
793  RotY[2][0] = -1 * sinTheta;
794  RotY[2][1] = 0;
795  RotY[2][2] = cosTheta;
796 
797  // Translation of the sphere center of the tile: S.
798  for (Int_t i = 0; i < 3; i++) {
799  diff[i] = ptC.at(i) - ptM.at(i);
800  }
801 
802  // Calculation of the correction matrix, from rotation matrices.
803  for (Int_t i = 0; i < 3; i++) {
804  for (Int_t j = 0; j < 3; j++) {
805  //corrMat[i][j] = RotZ[i][j];
806  for (Int_t k = 0; k < 3; k++) {
807  corrMat[i][j] = RotY[i][k] * RotX[k][j] + corrMat[i][j];
808  }
809  }
810  }
811  // Calculation of the new coordinates of the translated point S: newS = transfoMat*corrMat*invMat*diff.
812  for (Int_t i = 0; i < 3; i++) {
813  for (Int_t j = 0; j < 3; j++) {
814  for (Int_t k = 0; k < 3; k++) {
815  buff1[i][j] = corrMat[i][k] * invMat[k][j] + buff1[i][j];
816  }
817  }
818  }
819  for (Int_t i = 0; i < 3; i++) {
820  for (Int_t j = 0; j < 3; j++) {
821  for (Int_t k = 0; k < 3; k++) {
822  buff2[i][j] = transfoMat[i][k] * buff1[k][j] + buff2[i][j];
823  }
824  }
825  }
826  for (Int_t i = 0; i < 3; i++) {
827  for (Int_t j = 0; j < 3; j++) {
828  ptCNew.at(i) = buff2[i][j] * diff[j] + ptCNew.at(i);
829  //ptCNew.at(i) = invMat[i][j]*diff[j] + ptCNew.at(i);
830  }
831  }
832 
833  // Calculating the theoretical rotation angles to be applied to the translated point S, to get the point along the Z axis (should obtain a {0; 0; -300} coo).
834  phi2 = TMath::ATan2(diff[1], -1 * diff[2]);
835  theta2 = TMath::ATan2(diff[0], -1 * diff[2]);
836  cout << "Calculated Phi (= arctan(y/-z)), in degrees: "
837  << TMath::RadToDeg() * phi2
838  << " and calculated Theta (= arctan(x/-z)), in degrees: "
839  << TMath::RadToDeg() * theta2 << endl;
840  // Defining the rotation matrices accordingly:
841  // Rotation around X axis, with Z towards Y.
842  RotX2[0][0] = 1;
843  RotX2[0][1] = 0;
844  RotX2[0][2] = 0;
845  RotX2[1][0] = 0;
846  RotX2[1][1] = TMath::Cos(phi2);
847  RotX2[1][2] = TMath::Sin(phi2);
848  RotX2[2][0] = 0;
849  RotX2[2][1] = -1 * TMath::Sin(phi2);
850  RotX2[2][2] = TMath::Cos(phi2);
851  // Rotation around Y axis, with Z towards X.
852  RotY2[0][0] = TMath::Cos(theta2);
853  RotY2[0][1] = 0;
854  RotY2[0][2] = TMath::Sin(theta2);
855  RotY2[1][0] = 0;
856  RotY2[1][1] = 1;
857  RotY2[1][2] = 0;
858  RotY2[2][0] = -1 * TMath::Sin(theta2);
859  RotY2[2][1] = 0;
860  RotY2[2][2] = TMath::Cos(theta2);
861 
862  // Calculation of the correction matrix, from new rotation matrices.
863  for (Int_t i = 0; i < 3; i++) {
864  for (Int_t j = 0; j < 3; j++) {
865  for (Int_t k = 0; k < 3; k++) {
866  corrMat2[i][j] = RotY2[i][k] * RotX2[k][j] + corrMat2[i][j];
867  }
868  }
869  }
870  // Calculation of the new coordinates of the translated point S: newS = transfoMat*corrMat2*invMat*diff.
871  for (Int_t i = 0; i < 3; i++) {
872  for (Int_t j = 0; j < 3; j++) {
873  for (Int_t k = 0; k < 3; k++) {
874  buff3[i][j] = corrMat2[i][k] * invMat[k][j] + buff3[i][j];
875  }
876  }
877  }
878  for (Int_t i = 0; i < 3; i++) {
879  for (Int_t j = 0; j < 3; j++) {
880  for (Int_t k = 0; k < 3; k++) {
881  buff4[i][j] = transfoMat[i][k] * buff3[k][j] + buff4[i][j];
882  }
883  }
884  }
885  for (Int_t i = 0; i < 3; i++) {
886  for (Int_t j = 0; j < 3; j++) {
887  for (Int_t k = 0; k < 3; k++) {
888  buff5[i][j] = RotX[i][k] * invMat[k][j] + buff5[i][j];
889  //buff5[i][j] = RotY[i][k]*invMat[k][j] + buff5[i][j];
890  }
891  }
892  }
893  for (Int_t i = 0; i < 3; i++) {
894  for (Int_t j = 0; j < 3; j++) {
895  ptCNew2.at(i) = buff4[i][j] * diff[j] + ptCNew2.at(i);
896  //ptCNew3.at(i) = buff3[i][j]*diff[j] + ptCNew3.at(i);
897  ptCNew3.at(i) = buff5[i][j] * diff[j] + ptCNew3.at(i);
898  }
899  }
900 
901  for (Int_t i = 0; i < 3; i++) {
902  ptCNew.at(i) += ptM.at(i);
903  ptCNew2.at(i) += ptM.at(i);
904  ptCNew3.at(i) += ptM.at(i);
905  }
906  cout << "diff = {" << diff[0] << ", " << diff[1] << ", " << diff[2] << "}"
907  << endl;
908  cout << "New coordinates of the rotated tile sphere center (using angles "
909  "from text file) = {"
910  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
911  << endl;
912  cout << "New coordinates of the rotated tile sphere center (using calculated "
913  "angles) = {"
914  << ptCNew2.at(0) << ", " << ptCNew2.at(1) << ", " << ptCNew2.at(2) << "}"
915  << endl;
916  cout << "Tile coordinates after translation, invMat and rotations around X "
917  "and Y axes = {"
918  << ptCNew3.at(0) << ", " << ptCNew3.at(1) << ", " << ptCNew3.at(2) << "}"
919  << endl
920  << endl;
921 
922  return ptCNew;
923 }
924 
925 void CbmRichCorrection::InvertMatrix(Double_t mat[3][3],
926  Double_t invMat[3][3],
927  TGeoNavigator* navi) {
928  Double_t deter = 0., det11 = 0., det12 = 0., det13 = 0., det21 = 0.,
929  det22 = 0., det23 = 0., det31 = 0., det32 = 0., det33 = 0.,
930  buff[3][3], prodMat[3][3];
931 
932  //Filling the transformation matrix of the tile.
933  // STANDARD FILL:
934  mat[0][0] = navi->GetMotherMatrix()->GetRotationMatrix()[0];
935  mat[0][1] = navi->GetMotherMatrix()->GetRotationMatrix()[1];
936  mat[0][2] = navi->GetMotherMatrix()->GetRotationMatrix()[2];
937  mat[1][0] = navi->GetMotherMatrix()->GetRotationMatrix()[3];
938  mat[1][1] = navi->GetMotherMatrix()->GetRotationMatrix()[4];
939  mat[1][2] = navi->GetMotherMatrix()->GetRotationMatrix()[5];
940  mat[2][0] = navi->GetMotherMatrix()->GetRotationMatrix()[6];
941  mat[2][1] = navi->GetMotherMatrix()->GetRotationMatrix()[7];
942  mat[2][2] = navi->GetMotherMatrix()->GetRotationMatrix()[8];
943 
944  /* // TEST FILL:
945  mat[0][0] = navi->GetMotherMatrix()->GetRotationMatrix()[2];
946  mat[0][1] = navi->GetMotherMatrix()->GetRotationMatrix()[1];
947  mat[0][2] = navi->GetMotherMatrix()->GetRotationMatrix()[0];
948  mat[1][0] = navi->GetMotherMatrix()->GetRotationMatrix()[5];
949  mat[1][1] = navi->GetMotherMatrix()->GetRotationMatrix()[4];
950  mat[1][2] = navi->GetMotherMatrix()->GetRotationMatrix()[3];
951  mat[2][0] = navi->GetMotherMatrix()->GetRotationMatrix()[8];
952  mat[2][1] = navi->GetMotherMatrix()->GetRotationMatrix()[7];
953  mat[2][2] = navi->GetMotherMatrix()->GetRotationMatrix()[6];
954 */
955  /*for (Int_t i=0; i<3; i++) {
956  for (Int_t j=0; j<3; j++) {
957  mat[i][j] = navi->GetMotherMatrix()->GetRotationMatrix()[i*3+j];
958  }
959  }
960  cout << "Matrix index [2][0] = " << mat[2][0] << endl;*/
961 
962  //Computing the inverse of the matrix: inv = (1/det)*adjugate(mat) = (1/det)*transpose(cofactor_matrix(mat)).
963  deter = mat[0][0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1])
964  - mat[0][1] * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0])
965  + mat[0][2] * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
966  if (deter == 0) {
967  cout << "Error in CbmRichCorrection::InvertMatrix; determinant of input "
968  "matrix equals to zero !!!"
969  << endl;
970  sleep(5);
971  for (Int_t i = 0; i < 3; i++) {
972  for (Int_t j = 0; j < 3; j++) {
973  invMat[i][j] = 0;
974  }
975  }
976  } else {
977  buff[0][0] =
978  TMath::Power(-1, 2) * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]);
979  buff[0][1] =
980  TMath::Power(-1, 3) * (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]);
981  buff[0][2] =
982  TMath::Power(-1, 4) * (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]);
983  buff[1][0] =
984  TMath::Power(-1, 3) * (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]);
985  buff[1][1] =
986  TMath::Power(-1, 4) * (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]);
987  buff[1][2] =
988  TMath::Power(-1, 5) * (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]);
989  buff[2][0] =
990  TMath::Power(-1, 4) * (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]);
991  buff[2][1] =
992  TMath::Power(-1, 5) * (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]);
993  buff[2][2] =
994  TMath::Power(-1, 6) * (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]);
995 
996  for (Int_t i = 0; i < 3; i++) {
997  for (Int_t j = 0; j < 3; j++) {
998  invMat[i][j] = buff[i][j] / deter;
999  prodMat[i][j] = 0;
1000  }
1001  }
1002 
1003  /* for (Int_t i=0; i<3; i++) {
1004  for (Int_t j=0; j<3; j++) {
1005  for (Int_t k=0; k<3; k++) {
1006  prodMat[i][j] = mat[i][k]*invMat[k][j] + prodMat[i][j];
1007  }
1008  }
1009  }
1010 
1011  cout << "Matrix calculation to check whether inverse matrix is correct:" << endl;
1012  for (Int_t i=0; i<3; i++) {
1013  for (Int_t j=0; j<3; j++) {
1014  cout << "Resulting matrix = [" << prodMat[i][j] << "] \t";
1015  }
1016  cout << endl;
1017  }*/
1018  }
1019 }
1020 
1022  vector<Double_t> ptCIdeal,
1023  vector<Double_t>& ptMNew) {
1024  Double_t t = 0., diffX = 0., diffY = 0., diffZ = 0.;
1025  diffX = ptM.at(0) - ptCIdeal.at(0);
1026  diffY = ptM.at(1) - ptCIdeal.at(1);
1027  diffZ = ptM.at(2) - ptCIdeal.at(2);
1028  t = TMath::Sqrt(300 * 300 / (diffX * diffX + diffY * diffY + diffZ * diffZ));
1029 
1030  ptMNew.at(0) = t * diffX + ptCIdeal.at(0);
1031  ptMNew.at(1) = t * diffY + ptCIdeal.at(1);
1032  ptMNew.at(2) = t * diffZ + ptCIdeal.at(2);
1033  cout << "New coordinates of point M = {" << ptMNew.at(0) << ", "
1034  << ptMNew.at(1) << ", " << ptMNew.at(2) << "}" << endl;
1035 }
1036 
1037 void CbmRichCorrection::ComputeR2(vector<Double_t>& ptR2Center,
1038  vector<Double_t>& ptR2Mirr,
1039  vector<Double_t> ptM,
1040  vector<Double_t> ptC,
1041  vector<Double_t> ptR1,
1042  TGeoNavigator* navi,
1043  TString s) {
1044  cout << endl
1045  << "//------------------------------ CbmRichCorrection: ComputeR2 "
1046  "------------------------------//"
1047  << endl
1048  << endl;
1049 
1050  vector<Double_t> normalMirr(3), ptCNew(3), ptTileCenter(3);
1051  Double_t t1 = 0., t2 = 0., t3 = 0.;
1052 
1053  if (s == "Corrected") {
1054  // Use the correction information from text file, to the tile sphere center:
1055  // Reading misalignment information from correction_param.txt text file.
1056  vector<Double_t> outputFit(4);
1057  ifstream corr_file;
1058  TString str =
1059  fOutputDir + "correction_param_array___" + fNumbAxis + fTile + ".txt";
1060  corr_file.open(str);
1061  if (corr_file.is_open()) {
1062  for (Int_t i = 0; i < 4; i++) {
1063  corr_file >> outputFit.at(i);
1064  }
1065  //for (Int_t i=0; i<2; i++) {corr_file >> outputFit.at(i);}
1066  corr_file.close();
1067  } else {
1068  cout << "Error in CbmRichCorrection: unable to open parameter file!"
1069  << endl;
1070  cout << "Parameter file path = " << str << endl << endl;
1071  sleep(5);
1072  }
1073  cout << "Misalignment parameters read from file = [" << outputFit.at(0)
1074  << " ; " << outputFit.at(1) << " ; " << outputFit.at(2) << " ; "
1075  << outputFit.at(3) << "]" << endl;
1076 
1077  //ptCNew.at(0) = TMath::Abs(ptC.at(0) - TMath::Abs(outputFit.at(3)));
1078  //ptCNew.at(1) = TMath::Abs(ptC.at(1) - TMath::Abs(outputFit.at(2)));
1079  ptCNew.at(0) = ptC.at(0) + outputFit.at(3);
1080  ptCNew.at(1) = ptC.at(1) + outputFit.at(2);
1081  ptCNew.at(2) = ptC.at(2);
1082  ptTileCenter.at(0) = navi->GetMotherMatrix()->GetTranslation()[0];
1083  ptTileCenter.at(1) = navi->GetMotherMatrix()->GetTranslation()[1];
1084  ptTileCenter.at(2) = navi->GetMotherMatrix()->GetTranslation()[2];
1085  cout << "Mirror tile center coordinates = {" << ptTileCenter.at(0) << ", "
1086  << ptTileCenter.at(1) << ", " << ptTileCenter.at(2) << "}" << endl;
1087  Double_t x = 0., y = 0., z = 0., dist = 0., dist2 = 0., z2 = 0.;
1088  x = TMath::Power(ptCNew.at(0) - ptTileCenter.at(0), 2);
1089  y = TMath::Power(ptCNew.at(1) - ptTileCenter.at(1), 2);
1090  z = TMath::Power(ptCNew.at(2) - ptTileCenter.at(2), 2);
1091  dist = TMath::Sqrt(x + y + z);
1092  z2 = ptTileCenter.at(2) - TMath::Sqrt(TMath::Power(300, 2) - x - y)
1093  - ptCNew.at(2);
1094  cout << "{x, y, z} = {" << x << ", " << y << ", " << z
1095  << "}, dist = " << dist << " and z2 = " << z2 << endl;
1096  dist2 = TMath::Sqrt(x + y + TMath::Power(z2 - ptTileCenter.at(2), 2));
1097  cout << "dist2 = " << dist2 << endl;
1098  ptCNew.at(2) += z2;
1099  cout << "Sphere center coordinates of the rotated mirror tile, after "
1100  "correction, = {"
1101  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
1102  << endl;
1103  } else if (s == "Uncorrected") {
1104  // Keep the same tile sphere center, with no correction information.
1105  ptCNew = ptC;
1106  cout << "Sphere center coordinates of the rotated mirror tile, without "
1107  "correction = {"
1108  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
1109  << endl;
1110  } else {
1111  cout << "No input given in function ComputeR2! Uncorrected parameters for "
1112  "the sphere center of the tile will be used!"
1113  << endl;
1114  ptCNew = ptC;
1115  cout << "Sphere center coordinates of the rotated mirror tile, without "
1116  "correction = {"
1117  << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}"
1118  << endl;
1119  }
1120 
1121  normalMirr.at(0) = (ptCNew.at(0) - ptM.at(0))
1122  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
1123  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1124  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1125  normalMirr.at(1) = (ptCNew.at(1) - ptM.at(1))
1126  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
1127  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1128  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1129  normalMirr.at(2) = (ptCNew.at(2) - ptM.at(2))
1130  / TMath::Sqrt(TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
1131  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1132  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1133  //cout << "Calculated and normalized normal of mirror tile = {" << normalMirr.at(0) << ", " << normalMirr.at(1) << ", " << normalMirr.at(2) << "}" << endl;
1134 
1135  t1 = ((ptR1.at(0) - ptM.at(0)) * (ptCNew.at(0) - ptM.at(0))
1136  + (ptR1.at(1) - ptM.at(1)) * (ptCNew.at(1) - ptM.at(1))
1137  + (ptR1.at(2) - ptM.at(2)) * (ptCNew.at(2) - ptM.at(2)))
1138  / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
1139  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1140  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1141  ptR2Center.at(0) =
1142  2 * (ptM.at(0) + t1 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
1143  ptR2Center.at(1) =
1144  2 * (ptM.at(1) + t1 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
1145  ptR2Center.at(2) =
1146  2 * (ptM.at(2) + t1 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
1147  t2 = ((ptR1.at(0) - ptCNew.at(0)) * (ptCNew.at(0) - ptM.at(0))
1148  + (ptR1.at(1) - ptCNew.at(1)) * (ptCNew.at(1) - ptM.at(1))
1149  + (ptR1.at(2) - ptCNew.at(2)) * (ptCNew.at(2) - ptM.at(2)))
1150  / (TMath::Power(ptCNew.at(0) - ptM.at(0), 2)
1151  + TMath::Power(ptCNew.at(1) - ptM.at(1), 2)
1152  + TMath::Power(ptCNew.at(2) - ptM.at(2), 2));
1153  ptR2Mirr.at(0) =
1154  2 * (ptCNew.at(0) + t2 * (ptCNew.at(0) - ptM.at(0))) - ptR1.at(0);
1155  ptR2Mirr.at(1) =
1156  2 * (ptCNew.at(1) + t2 * (ptCNew.at(1) - ptM.at(1))) - ptR1.at(1);
1157  ptR2Mirr.at(2) =
1158  2 * (ptCNew.at(2) + t2 * (ptCNew.at(2) - ptM.at(2))) - ptR1.at(2);
1159  /*//SAME AS calculation of t2 above
1160  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));
1161  reflectedPtCooVectSphereUnity[0] = 2*(ptCNew.at(0)+t3*(normalMirr.at(0)))-ptR1.at(0);
1162  reflectedPtCooVectSphereUnity[1] = 2*(ptCNew.at(1)+t3*(normalMirr.at(1)))-ptR1.at(1);
1163  reflectedPtCooVectSphereUnity[2] = 2*(ptCNew.at(2)+t3*(normalMirr.at(2)))-ptR1.at(2);*/
1164  cout << "Coordinates of point R2 on reflective plane after reflection on the "
1165  "mirror tile:"
1166  << endl;
1167  //cout << "* using mirror point M to define \U00000394: {" << ptR2Center.at(0) << ", " << ptR2Center.at(1) << ", " << ptR2Center.at(2) << "}" << endl;
1168  cout << "* using sphere center C to define \U00000394: {" << ptR2Mirr.at(0)
1169  << ", " << ptR2Mirr.at(1) << ", " << ptR2Mirr.at(2) << "}" << endl;
1170  //cout << "Ref Pt Coo using unity Mirror-Sphere vector & sphere pt = {" << reflectedPtCooVectSphereUnity[0] << ", " << reflectedPtCooVectSphereUnity[1] << ", " << reflectedPtCooVectSphereUnity[2] << "}" << endl << endl;
1171  //cout << "NofPMTPoints = " << NofPMTPoints << endl;
1172 }
1173 
1174 void CbmRichCorrection::ComputeP(vector<Double_t>& ptPMirr,
1175  vector<Double_t>& ptPR2,
1176  vector<Double_t> normalPMT,
1177  vector<Double_t> ptM,
1178  vector<Double_t> ptR2Mirr,
1179  Double_t constantePMT) {
1180  cout << endl
1181  << "//------------------------------ CbmRichCorrection: ComputeP "
1182  "------------------------------//"
1183  << endl
1184  << endl;
1185 
1186  Double_t k1 = 0., k2 = 0., checkCalc1 = 0., checkCalc2 = 0.;
1187 
1188  k1 = -1
1189  * ((normalPMT.at(0) * ptM.at(0) + normalPMT.at(1) * ptM.at(1)
1190  + normalPMT.at(2) * ptM.at(2) + constantePMT)
1191  / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0))
1192  + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
1193  + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
1194  ptPMirr.at(0) = ptM.at(0) + k1 * (ptR2Mirr.at(0) - ptM.at(0));
1195  ptPMirr.at(1) = ptM.at(1) + k1 * (ptR2Mirr.at(1) - ptM.at(1));
1196  ptPMirr.at(2) = ptM.at(2) + k1 * (ptR2Mirr.at(2) - ptM.at(2));
1197  k2 = -1
1198  * ((normalPMT.at(0) * ptR2Mirr.at(0) + normalPMT.at(1) * ptR2Mirr.at(1)
1199  + normalPMT.at(2) * ptR2Mirr.at(2) + constantePMT)
1200  / (normalPMT.at(0) * (ptR2Mirr.at(0) - ptM.at(0))
1201  + normalPMT.at(1) * (ptR2Mirr.at(1) - ptM.at(1))
1202  + normalPMT.at(2) * (ptR2Mirr.at(2) - ptM.at(2))));
1203  ptPR2.at(0) = ptR2Mirr.at(0) + k2 * (ptR2Mirr.at(0) - ptM.at(0));
1204  ptPR2.at(1) = ptR2Mirr.at(1) + k2 * (ptR2Mirr.at(1) - ptM.at(1));
1205  ptPR2.at(2) = ptR2Mirr.at(2) + k2 * (ptR2Mirr.at(2) - ptM.at(2));
1206  cout << "Coordinates of point P on PMT plane, after reflection on the mirror "
1207  "tile and extrapolation to the PMT plane:"
1208  << endl;
1209  cout << "* using mirror point M to define \U0001D49F ': {" << ptPMirr.at(0)
1210  << ", " << ptPMirr.at(1) << ", " << ptPMirr.at(2) << "}" << endl;
1211  //cout << "* using reflected point R2 to define \U0001D49F ': {" << ptPR2.at(0) << ", " << ptPR2.at(1) << ", " << ptPR2.at(2) << "}" << endl;
1212  checkCalc1 = ptPMirr.at(0) * normalPMT.at(0) + ptPMirr.at(1) * normalPMT.at(1)
1213  + ptPMirr.at(2) * normalPMT.at(2) + constantePMT;
1214  cout << "Check whether extrapolated track point on PMT plane verifies its "
1215  "equation (value should be 0.):"
1216  << endl;
1217  cout << "* using mirror point M, checkCalc = " << checkCalc1 << endl;
1218  checkCalc2 = ptPR2.at(0) * normalPMT.at(0) + ptPR2.at(1) * normalPMT.at(1)
1219  + ptPR2.at(2) * normalPMT.at(2) + constantePMT;
1220  //cout << "* using reflected point R2, checkCalc = " << checkCalc2 << endl;
1221 }
1222 
1223 void CbmRichCorrection::FillHistProjection(TVector3 outPosIdeal,
1224  TVector3 outPosUnCorr,
1225  TVector3 outPos,
1226  Int_t NofGTracks,
1227  vector<Double_t> normalPMT,
1228  Double_t constantePMT) {
1229  CbmMCTrack* track2 = NULL;
1230  Double_t ringCenter[] = {0, 0, 0}, distToExtrapTrackHit = 0,
1231  distToExtrapTrackHitInPlane = 0,
1232  distToExtrapTrackHitInPlaneUnCorr = 0,
1233  distToExtrapTrackHitInPlaneIdeal = 0;
1234 
1235  for (Int_t iGlobalTrack = 0; iGlobalTrack < NofGTracks; iGlobalTrack++) {
1236  //cout << "Nb of global tracks = " << NofGTracks << " and iGlobalTrack = " << iGlobalTrack << endl;
1237  CbmGlobalTrack* gTrack = (CbmGlobalTrack*) fGlobalTracks->At(iGlobalTrack);
1238  if (NULL == gTrack) continue;
1239  Int_t richInd = gTrack->GetRichRingIndex();
1240  //cout << "Rich index = " << richInd << endl;
1241  if (richInd < 0) { continue; }
1242  CbmRichRing* ring = static_cast<CbmRichRing*>(fRichRings->At(richInd));
1243  if (NULL == ring) { continue; }
1244  Int_t ringTrackID = ring->GetTrackID();
1245  track2 = (CbmMCTrack*) fMCTracks->At(ringTrackID);
1246  Int_t ringMotherID = track2->GetMotherId();
1247  //cout << "Ring mother ID = " << ringMotherID << ", ring track ID = " << ringTrackID << " and track2 pdg = " << track2->GetPdgCode() << endl;
1248  CbmRichRingLight ringL;
1250  fCopFit->DoFit(&ringL);
1251  //fTauFit->DoFit(&ringL);
1252  ringCenter[0] = ringL.GetCenterX();
1253  ringCenter[1] = ringL.GetCenterY();
1254  ringCenter[2] = -1
1255  * ((normalPMT.at(0) * ringCenter[0]
1256  + normalPMT.at(1) * ringCenter[1] + constantePMT)
1257  / normalPMT.at(2));
1258 
1259  vector<Double_t> r(3),
1260  p(3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1261  r.at(0) = TMath::Abs(ringCenter[0]), r.at(1) = TMath::Abs(ringCenter[1]),
1262  r.at(2) = TMath::Abs(ringCenter[2]);
1263  p.at(0) = TMath::Abs(outPos.x()), p.at(1) = TMath::Abs(outPos.y()),
1264  p.at(2) = TMath::Abs(outPos.z());
1265  cout << "Ring center coordinates = {" << ringCenter[0] << ", "
1266  << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1267  cout << "Difference in X = " << TMath::Abs(r.at(0) - p.at(0)) << "; \t"
1268  << "Difference in Y = " << TMath::Abs(r.at(1) - p.at(1)) << "; \t"
1269  << "Difference in Z = " << TMath::Abs(r.at(2) - p.at(2)) << endl;
1270  fHM->H1("fhDifferenceX")->Fill(TMath::Abs(r.at(0) - p.at(0)));
1271  fHM->H1("fhDifferenceY")->Fill(TMath::Abs(r.at(1) - p.at(1)));
1272  distToExtrapTrackHit = TMath::Sqrt(TMath::Power(r.at(0) - p.at(0), 2)
1273  + TMath::Power(r.at(1) - p.at(1), 2)
1274  + TMath::Power(r.at(2) - p.at(2), 2));
1275  distToExtrapTrackHitInPlane = TMath::Sqrt(
1276  TMath::Power(r.at(0) - p.at(0), 2) + TMath::Power(r.at(1) - p.at(1), 2));
1277  fHM->H1("fhDistanceCenterToExtrapolatedTrack")->Fill(distToExtrapTrackHit);
1278  fHM->H1("fhDistanceCorrected")->Fill(distToExtrapTrackHitInPlane);
1279  //cout << "Distance between fitted ring center and extrapolated track hit = " << distToExtrapTrackHit << endl;
1280  cout << "Distance between fitted ring center and extrapolated track hit in "
1281  "plane = "
1282  << distToExtrapTrackHitInPlane << endl;
1283 
1284  vector<Double_t> pUnCorr(
1285  3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1286  pUnCorr.at(0) = TMath::Abs(outPosUnCorr.x()),
1287  pUnCorr.at(1) = TMath::Abs(outPosUnCorr.y()),
1288  pUnCorr.at(2) = TMath::Abs(outPosUnCorr.z());
1289  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1290  cout << "Difference in X = " << TMath::Abs(r.at(0) - pUnCorr.at(0))
1291  << "; \t"
1292  << "Difference in Y = " << TMath::Abs(r.at(1) - pUnCorr.at(1))
1293  << "; \t"
1294  << "Difference in Z = " << TMath::Abs(r.at(2) - pUnCorr.at(2)) << endl;
1295  fHM->H1("fhDifferenceXUncorrected")
1296  ->Fill(TMath::Abs(r.at(0) - pUnCorr.at(0)));
1297  fHM->H1("fhDifferenceYUncorrected")
1298  ->Fill(TMath::Abs(r.at(1) - pUnCorr.at(1)));
1299  distToExtrapTrackHitInPlaneUnCorr =
1300  TMath::Sqrt(TMath::Power(r.at(0) - pUnCorr.at(0), 2)
1301  + TMath::Power(r.at(1) - pUnCorr.at(1), 2));
1302  fHM->H1("fhDistanceUncorrected")->Fill(distToExtrapTrackHitInPlaneUnCorr);
1303  cout << "Distance between fitted ring center and extrapolated track hit in "
1304  "plane = "
1305  << distToExtrapTrackHitInPlaneUnCorr << endl;
1306 
1307  vector<Double_t> pIdeal(
1308  3); // Absolute coordinates of fitted ring Center r and PMT extrapolated point p
1309  pIdeal.at(0) = TMath::Abs(outPosIdeal.x()),
1310  pIdeal.at(1) = TMath::Abs(outPosIdeal.y()),
1311  pIdeal.at(2) = TMath::Abs(outPosIdeal.z());
1312  //cout << "Ring center coordinates = {" << ringCenter[0] << ", " << ringCenter[1] << ", " << ringCenter[2] << "}" << endl;
1313  cout << "Difference in X = " << TMath::Abs(r.at(0) - pIdeal.at(0)) << "; \t"
1314  << "Difference in Y = " << TMath::Abs(r.at(1) - pIdeal.at(1)) << "; \t"
1315  << "Difference in Z = " << TMath::Abs(r.at(2) - pIdeal.at(2)) << endl;
1316  fHM->H1("fhDifferenceXIdeal")->Fill(TMath::Abs(r.at(0) - pIdeal.at(0)));
1317  fHM->H1("fhDifferenceYIdeal")->Fill(TMath::Abs(r.at(1) - pIdeal.at(1)));
1318  distToExtrapTrackHitInPlaneIdeal =
1319  TMath::Sqrt(TMath::Power(r.at(0) - pIdeal.at(0), 2)
1320  + TMath::Power(r.at(1) - pIdeal.at(1), 2));
1321  fHM->H1("fhDistanceIdeal")->Fill(distToExtrapTrackHitInPlaneIdeal);
1322  cout << "Distance between fitted ring center and extrapolated track hit in "
1323  "plane = "
1324  << distToExtrapTrackHitInPlaneIdeal << endl
1325  << endl;
1326  //}
1327  //else { cout << "No identical ring mother ID and mirror track ID ..." << endl;}
1328  }
1329  cout << "End of loop on global tracks;" << endl;
1330 }
1331 
1333  char leg[128];
1334  int colorInd = 1;
1335 
1336  TCanvas* can3 = new TCanvas(fRunTitle + "_Distance_Histos_" + fAxisRotTitle,
1337  fRunTitle + "_Distance_Histos_" + fAxisRotTitle,
1338  1500,
1339  400);
1340  can3->SetGrid(1, 1);
1341  can3->Divide(2, 1);
1342  can3->cd(1)->SetGrid(1, 1);
1343  can3->cd(2)->SetGrid(1, 1);
1344  can3->cd(1);
1345  TH1D* Clone1 = (TH1D*) fHM->H1("fhDifferenceXIdeal")->Clone();
1346  Clone1->GetXaxis()->SetTitleSize(0.04);
1347  Clone1->GetYaxis()->SetTitleSize(0.04);
1348  Clone1->GetXaxis()->SetLabelSize(0.03);
1349  Clone1->GetYaxis()->SetLabelSize(0.03);
1350  Clone1->GetXaxis()->CenterTitle();
1351  Clone1->GetYaxis()->CenterTitle();
1352  Clone1->SetTitle("Difference in X");
1353  Clone1->SetLineColor(kBlue);
1354  Clone1->SetLineWidth(2);
1355  Clone1->Rebin(2);
1356  Clone1->Draw();
1357  TH1D* Clone2 = (TH1D*) fHM->H1("fhDifferenceX")->Clone();
1358  Clone2->SetTitleSize(0.04);
1359  Clone2->SetLabelSize(0.03);
1360  Clone2->SetLineColor(kGreen);
1361  Clone2->SetLineWidth(2);
1362  Clone2->Rebin(2);
1363  Clone2->Draw("same");
1364  TH1D* Clone3 = (TH1D*) fHM->H1("fhDifferenceXUncorrected")->Clone();
1365  Clone3->SetTitleSize(0.04);
1366  Clone3->SetLabelSize(0.03);
1367  Clone3->SetLineColor(kRed);
1368  Clone3->SetLineWidth(2);
1369  Clone3->Rebin(2);
1370  Clone3->Draw("same");
1371  gStyle->Clear();
1372 
1373  TLegend* LEG = new TLegend(0.3, 0.78, 0.5, 0.88); // Set legend position
1374  LEG->SetBorderSize(1);
1375  LEG->SetFillColor(0);
1376  LEG->SetMargin(0.2);
1377  LEG->SetTextSize(0.02);
1378  sprintf(leg, "X diff uncorr");
1379  LEG->AddEntry(Clone3, leg, "l");
1380  sprintf(leg, "X diff corr");
1381  LEG->AddEntry(Clone2, leg, "l");
1382  sprintf(leg, "X diff ideal");
1383  LEG->AddEntry(Clone1, leg, "l");
1384  LEG->Draw();
1385 
1386  can3->cd(2);
1387  can3->SetGrid(1, 1);
1388  TH1D* Clone4 = (TH1D*) fHM->H1("fhDifferenceYIdeal")->Clone();
1389  Clone4->GetXaxis()->SetTitleSize(0.04);
1390  Clone4->GetYaxis()->SetTitleSize(0.04);
1391  Clone4->GetXaxis()->SetLabelSize(0.03);
1392  Clone4->GetYaxis()->SetLabelSize(0.03);
1393  Clone4->GetXaxis()->CenterTitle();
1394  Clone4->GetYaxis()->CenterTitle();
1395  Clone4->SetTitle("Difference in Y");
1396  Clone4->SetLineColor(kBlue);
1397  Clone4->SetLineWidth(2);
1398  Clone4->Rebin(2);
1399  Clone4->Draw();
1400  TH1D* Clone5 = (TH1D*) fHM->H1("fhDifferenceY")->Clone();
1401  Clone5->SetTitleSize(0.04);
1402  Clone5->SetLabelSize(0.03);
1403  Clone5->SetLineColor(kGreen);
1404  Clone5->SetLineWidth(2);
1405  Clone5->Rebin(2);
1406  Clone5->Draw("same");
1407  TH1D* Clone6 = (TH1D*) fHM->H1("fhDifferenceYUncorrected")->Clone();
1408  Clone6->SetTitleSize(0.04);
1409  Clone6->SetLabelSize(0.03);
1410  Clone6->SetLineColor(kRed);
1411  Clone6->SetLineWidth(2);
1412  Clone6->Rebin(2);
1413  Clone6->Draw("same");
1414 
1415  TLegend* LEG1 = new TLegend(0.3, 0.78, 0.5, 0.88); // Set legend position
1416  LEG1->SetBorderSize(1);
1417  LEG1->SetFillColor(0);
1418  LEG1->SetMargin(0.2);
1419  LEG1->SetTextSize(0.02);
1420  sprintf(leg, "Y diff uncorr");
1421  LEG1->AddEntry(Clone6, leg, "l");
1422  sprintf(leg, "Y diff corr");
1423  LEG1->AddEntry(Clone5, leg, "l");
1424  sprintf(leg, "Y diff ideal");
1425  LEG1->AddEntry(Clone4, leg, "l");
1426  LEG1->Draw();
1427 
1428  /*can3->cd(3);
1429  //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);
1430  TH1D* CloneDist1 = (TH1D*)fHM->H1("fhDistanceIdeal")->Clone();
1431  CloneDist1->GetXaxis()->SetTitleSize(0.04);
1432  CloneDist1->GetYaxis()->SetTitleSize(0.04);
1433  CloneDist1->GetXaxis()->SetLabelSize(0.03);
1434  CloneDist1->GetYaxis()->SetLabelSize(0.03);
1435  CloneDist1->GetXaxis()->CenterTitle();
1436  CloneDist1->GetYaxis()->CenterTitle();
1437  CloneDist1->SetTitle("Distance between extrapolated track center and fitted ring center");
1438  CloneDist1->SetLineColor(kBlue);
1439  CloneDist1->SetLineWidth(2);
1440  CloneDist1->Rebin(2);
1441  CloneDist1->Draw();
1442  TH1D* CloneDist2 = (TH1D*)fHM->H1("fhDistanceUncorrected")->Clone();
1443  CloneDist2->SetTitleSize(0.04);
1444  CloneDist2->SetTitleSize(0.04);
1445  CloneDist2->SetLineColor(kRed);
1446  CloneDist2->SetLineWidth(2);
1447  CloneDist2->Rebin(2);
1448  CloneDist2->Draw("same");
1449  TH1D* CloneDist3 = (TH1D*)fHM->H1("fhDistanceCorrected")->Clone();
1450  CloneDist3->SetTitleSize(0.04);
1451  CloneDist3->SetTitleSize(0.04);
1452  CloneDist3->SetLineColor(kGreen);
1453  CloneDist3->SetLineWidth(2);
1454  CloneDist3->Rebin(2);
1455  CloneDist3->Draw("same");
1456 
1457  TLegend* LEG2 = new TLegend(0.3,0.78,0.5,0.88); // Set legend position
1458  LEG2->SetBorderSize(1);
1459  LEG2->SetFillColor(0);
1460  LEG2->SetMargin(0.2);
1461  LEG2->SetTextSize(0.02);
1462  sprintf(leg, "Distance uncorr");
1463  LEG2->AddEntry(CloneDist2, leg, "l");
1464  sprintf(leg, "Distance corr");
1465  LEG2->AddEntry(CloneDist3, leg, "l");
1466  sprintf(leg, "Distance ideal");
1467  LEG2->AddEntry(CloneDist1, leg, "l");
1468  LEG2->Draw();*/
1469  gStyle->SetOptStat(000000);
1470 
1471  Cbm::SaveCanvasAsImage(can3, string(fOutputDir.Data()), "png");
1472 
1473  /*TCanvas* can4 = new TCanvas(fRunTitle + "_Difference_Fits_" + fAxisRotTitle, fRunTitle + "_Difference_Fits_" + fAxisRotTitle, 800, 800);
1474  int colorInd3 = 1;
1475  can4->Divide(2,2);
1476  can4->cd(1);
1477  //fHM->H1("fHistoDiffX")->Add(fHM->H1("fhDifferenceX"), fHM->H1("fhDifferenceXIdeal"), -1, 1);
1478  Clone2->GetXaxis()->SetTitleSize(0.04);
1479  Clone2->GetYaxis()->SetTitleSize(0.04);
1480  Clone2->GetXaxis()->SetLabelSize(0.03);
1481  Clone2->GetYaxis()->SetLabelSize(0.03);
1482  Clone2->GetXaxis()->CenterTitle();
1483  Clone2->GetYaxis()->CenterTitle();
1484  Clone2->SetTitle("Corrected difference in X");
1485  //Clone2->SetAxisRange(0., 0.6);
1486  Clone2->SetLineColor(kGreen);
1487  //Clone2->SetLineColor(colorInd3);
1488  //colorInd3++;
1489  Clone2->Draw();
1490  Clone2->Fit("gaus", "0", "", 0., 1.5);
1491  gStyle->SetOptFit(1111);
1492  TF1 *fit1 = Clone2->GetFunction("gaus");
1493  can4->cd(2);
1494  //Clone3->SetLineColor(colorInd3);
1495  //colorInd3++;
1496  //Clone1->SetAxisRange(0., 0.6);
1497  Clone1->SetTitle("Difference in X ideal");
1498  Clone1->Draw();
1499  Clone1->Fit("gaus", "0", "", 0., 1.5);
1500  gStyle->SetOptFit(1111);
1501  TF1 *fit2 = Clone1->GetFunction("gaus");
1502 
1503  can4->cd(3);
1504  Clone5->GetXaxis()->SetTitleSize(0.04);
1505  Clone5->GetYaxis()->SetTitleSize(0.04);
1506  Clone5->GetXaxis()->SetLabelSize(0.03);
1507  Clone5->GetYaxis()->SetLabelSize(0.03);
1508  Clone5->GetXaxis()->CenterTitle();
1509  Clone5->GetYaxis()->CenterTitle();
1510  Clone5->SetTitle("Corrected difference in Y");
1511  //Clone5->SetAxisRange(0., 0.6);
1512  //Clone5->SetLineColor(colorInd3);
1513  //colorInd3++;
1514  Clone5->Draw();
1515  Clone5->Fit("gaus", "0", "", 0., 1.5);
1516  gStyle->SetOptFit(1111);
1517  TF1 *fit3 = Clone5->GetFunction("gaus");
1518  can4->cd(4);
1519  //Clone4->SetAxisRange(0., 0.6);
1520  //Clone6->SetLineColor(colorInd3);
1521  //colorInd3++;
1522  Clone4->SetTitle("Difference in Y ideal");
1523  Clone4->Draw();
1524  Clone4->Fit("gaus", "0", "", 0., 1.5);
1525  gStyle->SetOptFit(1111);
1526  TF1 *fit4 = Clone4->GetFunction("gaus");
1527 
1528  //Cbm::SaveCanvasAsImage(can4, string(fOutputDir.Data()), "png");
1529 
1530  Double_t meanX_corr = fit1->GetParameter(1);
1531  Double_t meanX_ideal = fit2->GetParameter(1);
1532  cout << endl;
1533  cout << "Mean X corrected = " << meanX_corr << " and mean X ideal = " << meanX_ideal << endl;
1534  cout << "Fitted parameters of differenceX histo = " << fit1->GetParameter(0) << ", " << fit1->GetParameter(1) << " and " << fit1->GetParameter(2) << endl;
1535  cout << "Fitted parameters of differenceXIdeal histo = " << fit2->GetParameter(0) << ", " << fit2->GetParameter(1) << " and " << fit2->GetParameter(2) << endl;
1536  Double_t meanY_corr = fit3->GetParameter(1);
1537  Double_t meanY_ideal = fit4->GetParameter(1);
1538  cout << "Fitted parameters of differenceY histo = " << fit3->GetParameter(0) << ", " << fit3->GetParameter(1) << " and " << fit3->GetParameter(2) << endl;
1539  cout << "Fitted parameters of differenceYIdeal histo = " << fit4->GetParameter(0) << ", " << fit4->GetParameter(1) << " and " << fit4->GetParameter(2) << endl;
1540  cout << "Mean Y corrected = " << meanY_corr << " and mean Y ideal = " << meanY_ideal << endl;*/
1541 }
1542 
1543 void CbmRichCorrection::DrawHistFromFile(TString fileName) {
1544  fHM = new CbmHistManager();
1545  TFile* file = new TFile(fileName, "READ");
1546  fHM->ReadFromFile(file);
1548 }
1549 
1551  // ---------------------------------------------------------------------------------------------------------------------------------------- //
1552  // -------------------------------------------------- Mapping for mirror - PMT relations -------------------------------------------------- //
1553  // ---------------------------------------------------------------------------------------------------------------------------------------- //
1554 
1555  if (fDrawProjection) {
1557  fHM->H1("fhDifferenceXUncorrected")->Write();
1558  fHM->H1("fhDifferenceYUncorrected")->Write();
1559  fHM->H1("fhDistanceUncorrected")->Write();
1560  fHM->H1("fhDifferenceX")->Write();
1561  fHM->H1("fhDifferenceY")->Write();
1562  fHM->H1("fhDistanceCorrected")->Write();
1563  fHM->H1("fhDifferenceXIdeal")->Write();
1564  fHM->H1("fhDifferenceYIdeal")->Write();
1565  fHM->H1("fhDistanceIdeal")->Write();
1566  }
1567 
1568  //cout << setprecision(6) << endl;
1569 }
1571 
1572  /*
1573 vector<Double_t> CbmRichCorrection::RotateSphereCenter(vector<Double_t> ptM, vector<Double_t> ptC, TGeoNavigator* navi)
1574 {
1575  vector<Double_t> ptCNew(3);
1576  Double_t cosPhi=0., sinPhi=0., cosTheta=0., sinTheta=0., diff[3], mat[3][3], invMat[3][3], corrMat[3][3], buff1[3][3], buff2[3][3];
1577 
1578  InvertMatrix(mat, invMat, navi);
1579  /*for (Int_t i=0; i<3; i++) {
1580  for (Int_t j=0; j<3; j++) {
1581  cout << invMat[i][j] << "\t";
1582  }
1583  cout << endl;
1584  }*/
1585  /*
1586  // Reading misalignment information from correction_param.txt text file.
1587  vector<Float_t> outputFit(4);
1588  ifstream corr_file;
1589  corr_file.open("correction_param.txt");
1590  if (corr_file.is_open())
1591  {
1592  for (Int_t i=0; i<4; i++) {corr_file >> outputFit.at(i);}
1593  corr_file.close();
1594  }
1595  else {
1596  cout << "Error in CbmRichCorrection: unable to open parameter file!" << endl << endl;
1597  sleep(5);
1598  }
1599  cout << "Misalignment parameters read from file = [" << outputFit.at(0) << " ; " << outputFit.at(1) << " ; " << outputFit.at(2) << " ; " << outputFit.at(3) << "]" << endl;
1600 
1601  // Calculating the new coordinates of sphere center C, according to the correction parameters.
1602  for (Int_t i=0; i<3; i++) {
1603  for (Int_t j=0; j<3; j++) {
1604  corrMat[i][j] = 0.;
1605  buff1[i][j] = 0.;
1606  buff2[i][j] = 0.;
1607  }
1608  }
1609 
1610  // Correction Matrix = Id(3).
1611  //corrMat[0][0] = corrMat[1][1] = corrMat[2][2] = 1;
1612 
1613  cosPhi = TMath::Cos(outputFit.at(0));
1614  sinPhi = TMath::Sin(outputFit.at(0)); // BEWARE !!! the horizontal rotation axis of the tile is opposite to the global horizontal rotation axis !!!
1615  cosTheta = TMath::Cos(outputFit.at(1));
1616  sinTheta = -1*TMath::Sin(outputFit.at(1));
1617 
1618  Double_t RotX[3][3], RotY[3][3], RotZ[3][3];
1619  // Define rotation around X axis, with y towards z.
1620  // y towards z is the rotation direction defined in the tile frame, which is the same definition as for the global
1621  // frame. But as the X axis direction is opposite in the two frames, to correct for misalignment, the rotation
1622  // direction remains unchanged in the global frame.
1623  RotX[0][0] = 1;
1624  RotX[0][1] = 0;
1625  RotX[0][2] = 0;
1626  RotX[1][0] = 0;
1627  RotX[1][1] = cosPhi;
1628  RotX[1][2] = -1*sinPhi;
1629  RotX[2][0] = 0;
1630  RotX[2][1] = sinPhi;
1631  RotX[2][2] = cosPhi;
1632  // Define rotation around Y axis, with z towards x.
1633  // x towards z is the rotation direction defined in the tile frame, which is the same definition as for the global
1634  // frame. And as the tile and global frames are identical, the rotation direction for the correction is the opposite
1635  // in the global frame - in order to correct for the mibuff3[i][j] = 0.;salignment.
1636  RotY[0][0] = cosTheta;
1637  RotY[0][1] = 0;
1638  RotY[0][2] = sinTheta;
1639  RotY[1][0] = 0;
1640  RotY[1][1] = 1;
1641  RotY[1][2] = 0;
1642  RotY[2][0] = -1*sinTheta;
1643  RotY[2][1] = 0;
1644  RotY[2][2] = cosTheta;
1645  // Define rotation around Z axis.
1646  RotZ[0][0] = cosTheta;
1647  RotZ[0][1] = -1*sinTheta;
1648  RotZ[0][2] = 0;
1649  RotZ[1][0] = sinTheta;
1650  RotZ[1][1] = cosTheta;
1651  RotZ[1][2] = 0;
1652  RotZ[2][0] = 0;
1653  RotZ[2][1] = 0;
1654  RotZ[2][2] = 1;
1655  cout << "RotY[0][0] = " << RotY[0][0] << " and RotY[0][2] = " << RotY[0][2] << endl;
1656 
1657  for (Int_t i=0; i<3; i++) {
1658  for (Int_t j=0; j<3; j++) {
1659  //corrMat[i][j] = RotZ[i][j];
1660  for (Int_t k=0; k<3; k++) {
1661  corrMat[i][j] = RotY[i][k]*RotX[k][j] + corrMat[i][j];
1662  }
1663  }
1664  }
1665 
1666 /* corrMat[0][0] = cosTheta;
1667  corrMat[0][1] = -1*sinTheta*sinPhi;
1668  corrMat[0][2] = -1*sinTheta*cosPhi;
1669  corrMat[1][0] = 0;
1670  corrMat[1][1] = cosPhi;
1671  corrMat[1][2] = -1*sinPhi;
1672  corrMat[2][0] = sinTheta;
1673  corrMat[2][1] = cosPhi;
1674  corrMat[2][2] = cosTheta*cosPhi;
1675  corrMat[0][0] = 1;
1676  corrMat[0][1] = 0;
1677  corrMat[0][2] = 0;
1678  corrMat[1][0] = 0;
1679  corrMat[1][1] = cosPhi;
1680  corrMat[1][2] = -1*sinPhi;
1681  corrMat[2][0] = 0;
1682  corrMat[2][1] = sinPhi;
1683  corrMat[2][2] = cosPhi;
1684  corrMat[0][0] = cosTheta;
1685  corrMat[0][1] = 0;
1686  corrMat[0][2] = -1*sinTheta;
1687  corrMat[1][0] = -1*sinTheta*sinPhi;
1688  corrMat[1][1] = cosPhi;
1689  corrMat[1][2] = -1*sinPhi*cosTheta;
1690  corrMat[2][0] = cosPhi*sinTheta;
1691  corrMat[2][1] = sinPhi;
1692  corrMat[2][2] = cosTheta*cosPhi;
1693 
1694  for (Int_t i=0; i<3; i++) {
1695  for (Int_t j=0; j<3; j++) {
1696  for (Int_t k=0; k<3; k++) {
1697  buff1[i][j] = corrMat[i][k]*invMat[k][j] + buff1[i][j];
1698  }
1699  }
1700  }
1701  for (Int_t i=0; i<3; i++) {
1702  for (Int_t j=0; j<3; j++) {
1703  for (Int_t k=0; k<3; k++) {
1704  buff2[i][j] = mat[i][k]*buff1[k][j] + buff2[i][j];
1705  }
1706  }
1707  }
1708 
1709  diff[0] = ptC.at(0) - ptM.at(0);
1710  diff[1] = ptC.at(1) - ptM.at(1);
1711  diff[2] = ptC.at(2) - ptM.at(2);
1712  cout << "diff = {" << diff[0] << ", " << diff[1] << ", " << diff[2] << "}" << endl;
1713  Double_t phi2 =TMath::ATan2(diff[1], -1*diff[2]), theta2 =TMath::ATan2(diff[0], -1*diff[2]);
1714  cout << "Calculated phi (= arctan(y/-z)): " << TMath::RadToDeg()*phi2 << " and calculated theta (= arctan(x/-z)): " << TMath::RadToDeg()*theta2 << endl;
1715  cout << "cosPhi = " << TMath::Cos(phi2) << ", sinPhi = " << TMath::Sin(phi2) << " and cosTheta = " << TMath::Cos(theta2) << ", sinTheta = " << TMath::Sin(theta2) << endl;
1716  Double_t RotX2[3][3], RotY2[3][3], corrMat2[3][3];
1717  RotX2[0][0] = 1;
1718  RotX2[0][1] = 0;
1719  RotX2[0][2] = 0;
1720  RotX2[1][0] = 0;
1721  RotX2[1][1] = TMath::Cos(phi2);
1722  RotX2[1][2] = TMath::Sin(phi2);
1723  RotX2[2][0] = 0;
1724  RotX2[2][1] = -1*TMath::Sin(phi2);
1725  RotX2[2][2] = TMath::Cos(phi2);
1726  RotY2[0][0] = TMath::Cos(theta2);
1727  RotY2[0][1] = 0;
1728  RotY2[0][2] = TMath::Sin(theta2);
1729  RotY2[1][0] = 0;
1730  RotY2[1][1] = 1;
1731  RotY2[1][2] = 0;
1732  RotY2[2][0] = -1*TMath::Sin(theta2);
1733  RotY2[2][1] = 0;
1734  RotY2[2][2] = TMath::Cos(theta2);
1735 
1736  for (Int_t i=0; i<3; i++) {
1737  for (Int_t j=0; j<3; j++) {
1738  for (Int_t k=0; k<3; k++) {
1739  corrMat2[i][j] = RotX2[i][k]*RotY2[k][j] + corrMat2[i][j];
1740  }
1741  }
1742  }
1743 
1744  vector<Double_t> ptCNew2(3), ptCNew3(3);
1745  for (Int_t i=0; i<3; i++) {
1746  for (Int_t j=0; j<3; j++) {
1747  //ptCNew.at(i) = buff2[i][j]*diff[j] + ptCNew.at(i);
1748  //ptCNew.at(i) = invMat[i][j]*diff[j] + ptCNew.at(i);
1749  ptCNew.at(i) = corrMat2[i][j]*diff[j] + ptCNew.at(i);
1750  ptCNew2.at(i) = RotY[i][j]*diff[j] + ptCNew2.at(i);
1751  }
1752  }
1753 
1754  phi2 = TMath::ATan2(ptCNew2.at(1), -ptCNew2.at(2));
1755  cout << "New phi2 = " << TMath::RadToDeg()*phi2 << endl;
1756  RotX2[0][0] = 1;
1757  RotX2[0][1] = 0;
1758  RotX2[0][2] = 0;
1759  RotX2[1][0] = 0;
1760  RotX2[1][1] = TMath::Cos(phi2);
1761  RotX2[1][2] = TMath::Sin(phi2);
1762  RotX2[2][0] = 0;
1763  RotX2[2][1] = -1*TMath::Sin(phi2);
1764  RotX2[2][2] = TMath::Cos(phi2);
1765  for (Int_t i=0; i<3; i++) {
1766  for (Int_t j=0; j<3; j++) {
1767  ptCNew3.at(i) = RotX[i][j]*diff[j] + ptCNew3.at(i);
1768  }
1769  }
1770 
1771  //ptCNew.at(0) += ptM.at(0);
1772  //ptCNew.at(1) += ptM.at(1);
1773  //ptCNew.at(2) += ptM.at(2);
1774 
1775  /*ptCNew.at(0) = ptM.at(0) + diffX*cosTheta - diffY*sinTheta*sinPhi - diffZ*sinTheta*cosPhi;
1776  ptCNew.at(1) = ptM.at(1) + diffY*cosPhi - diffZ*sinPhi;
1777  ptCNew.at(2) = ptM.at(2) + diffX*sinTheta + diffY*cosPhi + diffZ*cosTheta*cosPhi;*/
1778  /* cout << "Sphere center coordinates of the rotated mirror tile, w/ calculation, = {" << ptCNew.at(0) << ", " << ptCNew.at(1) << ", " << ptCNew.at(2) << "}" << endl;
1779  cout << "Sphere center coordinates of the rotated mirror tile (after rotation around Y), w/ calculation, = {" << ptCNew2.at(0) << ", " << ptCNew2.at(1) << ", " << ptCNew2.at(2) << "}" << endl;
1780  cout << "Sphere center coordinates of the rotated mirror tile (around unrotated axes), w/ calculation, = {" << ptCNew3.at(0) << ", " << ptCNew3.at(1) << ", " << ptCNew3.at(2) << "}" << endl << endl;
1781 
1782  return ptCNew;
1783 }
1784 */
CbmRichCorrection::fTile
TString fTile
Definition: CbmRichCorrection.h:200
CbmRichPoint.h
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmRichCorrection::fRichRingMatches
TClonesArray * fRichRingMatches
Definition: CbmRichCorrection.h:191
CbmRichCorrection::InvertMatrix
void InvertMatrix(Double_t mat[3][3], Double_t invMat[3][3], TGeoNavigator *navi)
Definition: CbmRichCorrection.cxx:925
CbmRichRecGeoParPmt::fHeight
Double_t fHeight
Definition: CbmRichRecGeoPar.h:71
CbmRichCorrection::GetMeanSphereCenter
void GetMeanSphereCenter(TGeoNavigator *navi, vector< Double_t > &ptC)
Definition: CbmRichCorrection.cxx:594
CbmRichCorrection::fRunTitle
TString fRunTitle
Definition: CbmRichCorrection.h:207
CbmRichCorrection::fAxisRotTitle
TString fAxisRotTitle
Definition: CbmRichCorrection.h:208
CbmRichCorrection::fOutputDir
TString fOutputDir
Definition: CbmRichCorrection.h:206
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichRingFitterEllipseTau
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
Definition: CbmRichRingFitterEllipseTau.h:35
CbmRichRecGeoParPmt::fPlaneY
Double_t fPlaneY
Definition: CbmRichRecGeoPar.h:67
CbmRichCorrection::GetMirrorIntersection
void GetMirrorIntersection(vector< Double_t > &ptM, vector< Double_t > ptR1, vector< Double_t > momR1, vector< Double_t > ptC, Double_t sphereRadius)
Definition: CbmRichCorrection.cxx:661
CbmRichRingFitterEllipseTau.h
Here the ring is fitted with Taubin algorithm from A. Ayriyan, G. Ososkov, N. Chernov.
CbmHistManager::ReadFromFile
void ReadFromFile(TFile *file)
Read histograms from file.
Definition: core/base/CbmHistManager.cxx:110
CbmRichRecGeoPar::fPmt
CbmRichRecGeoParPmt fPmt
Definition: CbmRichRecGeoPar.h:218
CbmGlobalTrack::GetRichRingIndex
Int_t GetRichRingIndex() const
Definition: CbmGlobalTrack.h:41
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichCorrection::Exec
virtual void Exec(Option_t *option)
Inherited from FairTask.
Definition: CbmRichCorrection.cxx:232
CbmRichCorrection::fRichPoints
TClonesArray * fRichPoints
Definition: CbmRichCorrection.h:193
CbmGlobalTrack.h
CbmRichPoint::Print
virtual void Print(const Option_t *opt) const
Definition: CbmRichPoint.cxx:37
CbmRichCorrection::fRichMirrorPoints
TClonesArray * fRichMirrorPoints
Definition: CbmRichCorrection.h:187
CbmRichCorrection::fTauFit
CbmRichRingFitterEllipseTau * fTauFit
Definition: CbmRichCorrection.h:211
CbmRichCorrection::fNumbAxis
TString fNumbAxis
Definition: CbmRichCorrection.h:199
CbmRichRing
Definition: CbmRichRing.h:17
CbmDrawHist.h
Helper functions for drawing 1D and 2D histograms and graphs.
CbmRichCorrection::fRichMCPoints
TClonesArray * fRichMCPoints
Definition: CbmRichCorrection.h:189
CbmRichCorrection::RotateSphereCenter
vector< Double_t > RotateSphereCenter(vector< Double_t > ptM, vector< Double_t > ptC, TGeoNavigator *navi)
Definition: CbmRichCorrection.cxx:708
CbmRichCorrection::fRichProjections
TClonesArray * fRichProjections
Definition: CbmRichCorrection.h:188
CbmRichCorrection.h
CbmRichRingFitterCOP
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
Definition: CbmRichRingFitterCOP.h:28
CbmRichCorrection
Definition: CbmRichCorrection.h:27
CbmRichGeoManager.h
CbmRichCorrection::fEventNum
UInt_t fEventNum
Definition: CbmRichCorrection.h:201
CbmHistManager
Histogram manager.
Definition: CbmHistManager.h:41
CbmRichRecGeoParPmt::fPlaneX
Double_t fPlaneX
Definition: CbmRichRecGeoPar.h:66
z2
Double_t z2[nSects2]
Definition: pipe_v16a_mvdsts100.h:11
CbmRichCorrection::FillHistProjection
void FillHistProjection(TVector3 outPosIdeal, TVector3 outPosUnCorr, TVector3 outPos, Int_t NofGlobalTracks, vector< Double_t > normalPMT, Double_t constantePMT)
Definition: CbmRichCorrection.cxx:1223
CbmRichCorrection::fRichHits
TClonesArray * fRichHits
Definition: CbmRichCorrection.h:185
CbmRichRecGeoPar
PMT parameters for the RICH geometry.
Definition: CbmRichRecGeoPar.h:87
d
double d
Definition: P4_F64vec2.h:24
CbmRichCorrection::CbmRichCorrection
CbmRichCorrection()
Definition: CbmRichCorrection.cxx:53
CbmRichCorrection::CalculateMirrorIntersection
void CalculateMirrorIntersection(vector< Double_t > ptM, vector< Double_t > ptCUnCorr, vector< Double_t > &ptMNew)
Definition: CbmRichCorrection.cxx:1021
CbmRichCorrection::fRichRings
TClonesArray * fRichRings
Definition: CbmRichCorrection.h:186
CbmRichConverter.h
Convert internal data classes to cbmroot common data classes.
CbmRichRingLight::GetCenterY
float GetCenterY() const
Definition: CbmRichRingLight.h:160
CbmRichRingLight.h
CbmTrackMatchNew.h
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
CbmRichCorrection::fCopFit
CbmRichRingFitterCOP * fCopFit
Definition: CbmRichCorrection.h:210
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmRichCorrection::InitHistProjection
void InitHistProjection()
Definition: CbmRichCorrection.cxx:145
CbmHistManager::H1
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
Definition: CbmHistManager.h:170
CbmRichCorrection::fMCTracks
TClonesArray * fMCTracks
Definition: CbmRichCorrection.h:190
CbmUtils.h
CbmRichRingFitterCOP.h
Here the ring is fitted with the COP algorithm from A. Ayriyan/G. Ososkov.
CbmRichConverter::Init
static void Init()
Initialize array of RICH hits.
Definition: CbmRichConverter.h:93
CbmGlobalTrack
Definition: CbmGlobalTrack.h:26
counter
int counter
Definition: CbmMvdSensorDigiToHitTask.cxx:72
CbmRichCorrection::fRichRefPlanePoints
TClonesArray * fRichRefPlanePoints
Definition: CbmRichCorrection.h:192
CbmRichRingFitterCOP::DoFit
virtual void DoFit(CbmRichRingLight *ring)
Inherited from CbmRichRingFitterBase.
Definition: CbmRichRingFitterCOP.cxx:19
CbmMCTrack.h
CbmMCTrack
Definition: CbmMCTrack.h:34
CbmRichCorrection::fDrawProjection
Bool_t fDrawProjection
Definition: CbmRichCorrection.h:202
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmRichHitProducer.h
Class for producing RICH hits directly from MCPoints.
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
CbmRichRecGeoParPmt::fWidth
Double_t fWidth
Definition: CbmRichRecGeoPar.h:70
CbmRichCorrection::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 normalCste)
Definition: CbmRichCorrection.cxx:1174
CbmRichCorrection::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmRichCorrection.cxx:1550
Cbm::SaveCanvasAsImage
void SaveCanvasAsImage(TCanvas *c, const std::string &dir, const std::string &option)
Definition: CbmUtils.cxx:20
CbmRichCorrection::~CbmRichCorrection
virtual ~CbmRichCorrection()
Definition: CbmRichCorrection.cxx:81
CbmRichHit.h
CbmRichRingLight::GetCenterX
float GetCenterX() const
Definition: CbmRichRingLight.h:159
CbmRichCorrection::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 s)
Definition: CbmRichCorrection.cxx:1037
CbmRichCorrection::fGlobalTracks
TClonesArray * fGlobalTracks
Definition: CbmRichCorrection.h:194
CbmRichCorrection::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmRichCorrection.cxx:83
CbmRichPoint
Definition: CbmRichPoint.h:24
CbmRichGeoManager::fGP
CbmRichRecGeoPar * fGP
Definition: CbmRichGeoManager.h:23
CbmRichCorrection::fHM
CbmHistManager * fHM
Definition: CbmRichCorrection.h:195
CbmRichCorrection::fIsMeanCenter
Bool_t fIsMeanCenter
Definition: CbmRichCorrection.h:203
CbmRichCorrection::ProjectionProducer
void ProjectionProducer()
Definition: CbmRichCorrection.cxx:270
CbmRichRingLight
Definition: CbmRichRingLight.h:39
CbmRichCorrection::DrawHistProjection
void DrawHistProjection()
Definition: CbmRichCorrection.cxx:1332
CbmRichCorrection::DrawHistFromFile
void DrawHistFromFile(TString fileName)
Definition: CbmRichCorrection.cxx:1543
CbmRichCorrection::GetPmtNormal
void GetPmtNormal(Int_t NofPMTPoints, vector< Double_t > &normalPMT, Double_t &normalCste)
Definition: CbmRichCorrection.cxx:488