CbmRoot
Loading...
Searching...
No Matches
CbmRichProjectionProducerTGeo.cxx
Go to the documentation of this file.
1/* Copyright (C) 2005-2021 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Petr Stolpovsky, Andrey Lebedev [committer], Semen Lebedev */
4
13
14#include "CbmEvent.h"
15#include "CbmMCTrack.h"
16#include "CbmRichGeoManager.h"
17#include "FairGeoNode.h"
18#include "FairGeoTransform.h"
19#include "FairGeoVector.h"
20#include "FairRootManager.h"
21#include "FairRun.h"
22#include "FairRunAna.h"
23#include "FairRuntimeDb.h"
24#include "FairTrackParam.h"
25#include "TClonesArray.h"
26#include "TGeoManager.h"
27#include "TMatrixFSym.h"
28#include "TVector3.h"
30
31#include <Logger.h>
32
33#include <cmath>
34#include <iostream>
35
36using std::cout;
37using std::endl;
38
39
41
43
44
46{
47 FairRootManager* manager = FairRootManager::Instance();
48 if (nullptr == manager) LOG(fatal) << "CbmRichProjectionProducerTGeo::Init(): FairRootManager is nullptr.";
49
50 fTrackParams = (TClonesArray*) manager->GetObject("RichTrackParamZ");
51 if (fTrackParams == nullptr) LOG(fatal) << "CbmRichProjectionProducerTGeo::Init(): No RichTrackParamZ array.";
52}
53
55{
57 if (richProj == nullptr) {
58 LOG(error) << "CbmRichProjectionProducerTGeo::DoExtrapolation(): richProj is nullptr.";
59 return;
60 }
61
62 fEventNum++;
63
65 double mirrorX = gp->fMirrorX;
66 double mirrorY = gp->fMirrorY;
67 double mirrorZ = gp->fMirrorZ;
68
69 TMatrixFSym covMat(5);
70 for (Int_t i = 0; i < 5; i++) {
71 for (Int_t j = 0; j <= i; j++) {
72 covMat(i, j) = 0;
73 }
74 }
75 covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4;
76
77 Int_t nofTrackParams = event ? event->GetNofData(ECbmDataType::kRichTrackParamZ) : fTrackParams->GetEntriesFast();
78 for (Int_t iT0 = 0; iT0 < nofTrackParams; iT0++) {
79 Int_t iT = event ? event->GetIndex(ECbmDataType::kRichTrackParamZ, iT0) : iT0;
80 FairTrackParam* trackParam = static_cast<FairTrackParam*>(fTrackParams->At(iT));
81 new ((*richProj)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
82 if (event != nullptr) event->AddData(ECbmDataType::kRichTrackProjection, iT);
83
84 if (trackParam->GetX() == 0 && trackParam->GetY() == 0 && trackParam->GetZ() == 0 && trackParam->GetTx() == 0
85 && trackParam->GetTy() == 0)
86 continue;
87 if (trackParam->GetQp() == 0) continue;
88
89 TVector3 startP, crossP, centerP;
90 TVector3 dirCos;
91 Double_t nx, ny, nz;
92 CbmRichNavigationUtil::GetDirCos(trackParam, nx, ny, nz);
93 dirCos.SetXYZ(nx, ny, nz);
94
95 string volumeName = CbmRichNavigationUtil::FindIntersection(trackParam, crossP, "mirror_tile_type");
96 Bool_t mirrorIntersectionFound = (volumeName != string(""));
97 if (!mirrorIntersectionFound) continue;
98
99 // mirror center
100 if (crossP.Y() > 0) {
101 centerP.SetXYZ(mirrorX, mirrorY, mirrorZ);
102 }
103 else {
104 centerP.SetXYZ(mirrorX, -mirrorY, mirrorZ);
105 }
106
107 // calculate normal on crosspoint with mirror
108 TVector3 normP(crossP.x() - centerP.x(), crossP.y() - centerP.y(), crossP.z() - centerP.z());
109 normP = normP.Unit();
110 // check that normal has same z-direction as momentum
111 if ((normP.z() * dirCos.z()) < 0.) normP = TVector3(-1. * normP.x(), -1. * normP.y(), -1. * normP.z());
112
113 // reflect track
114 Double_t np = normP.x() * dirCos.x() + normP.y() * dirCos.y() + normP.z() * dirCos.z();
115 Double_t refX = 2 * np * normP.x() - dirCos.x();
116 Double_t refY = 2 * np * normP.y() - dirCos.y();
117 Double_t refZ = 2 * np * normP.z() - dirCos.z();
118 TVector3 refl;
119 refl.SetXYZ(-refX, -refY, -refZ);
120 refl.Unit();
121
122 TVector3 pmtIntersectionPoint;
123 volumeName = CbmRichNavigationUtil::FindIntersection(refl, crossP, pmtIntersectionPoint, "pmt");
124 Bool_t pmtIntersectionFound = (volumeName != string(""));
125 if (!pmtIntersectionFound) continue;
126
127
128 // Transform intersection point in same way as MCPoints were
129 // transformed in HitProducer before stored as Hit:
130 TVector3 outPos;
131 CbmRichGeoManager::GetInstance().RotatePoint(&pmtIntersectionPoint, &outPos);
132 Double_t xDet = outPos.X();
133 Double_t yDet = outPos.Y();
134 Double_t zDet = outPos.Z();
135
136 //check that crosspoint inside the plane
137 // if( xDet > (-fGP.fPmtXOrig-fGP.fPmtWidthX) && xDet < (fGP.fPmtXOrig+fGP.fPmtWidthX)){
138 // if(TMath::Abs(yDet) > (fGP.fPmtY-fGP.fPmtWidthY) && TMath::Abs(yDet) < (fGP.fPmtY+fGP.fPmtWidthY)){
139 FairTrackParam richtrack(xDet, yDet, zDet, 0., 0., 0., covMat);
140 *(FairTrackParam*) (richProj->At(iT)) = richtrack;
142 // }
143 // }
144 } // j
145}
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...
TClonesArray * richProj
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
CbmRichRecGeoPar * fGP
static CbmRichGeoManager & GetInstance()
static void GetDirCos(const FairTrackParam *par, Double_t &nx, Double_t &ny, Double_t &nz)
static string FindIntersection(const FairTrackParam *par, TVector3 &crossPoint, const string &volumeName)
virtual void DoProjection(CbmEvent *event, TClonesArray *richProj)
Execute task.
virtual void Init()
Initialization of the task.
PMT parameters for the RICH geometry.