17#include "FairGeoNode.h"
18#include "FairGeoTransform.h"
19#include "FairGeoVector.h"
20#include "FairRootManager.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"
46 FairRootManager* manager = FairRootManager::Instance();
47 if (
nullptr == manager) LOG(fatal) <<
"CbmRichProjectionProducerAnalytical::Init(): FairRootManager is nullptr.";
49 fTrackParams = (TClonesArray*) manager->GetObject(
"RichTrackParamZ");
50 if (
fTrackParams ==
nullptr) LOG(fatal) <<
"CbmRichProjectionProducerAnalytical::Init(): No RichTrackParamZ array.";
57 LOG(error) <<
"CbmRichProjectionProducerAnalytical::DoExtrapolation(): richProj is nullptr.";
69 TMatrixFSym covMat(5);
70 for (Int_t i = 0; i < 5; i++) {
71 for (Int_t j = 0; j <= i; j++) {
75 covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) = 1.e-4;
78 for (Int_t iT0 = 0; iT0 < nofTrackParams; iT0++) {
80 FairTrackParam* trPar =
static_cast<FairTrackParam*
>(
fTrackParams->At(iT));
81 new ((*richProj)[iT]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
85 if (trPar->GetX() == 0 && trPar->GetY() == 0 && trPar->GetZ() == 0 && trPar->GetTx() == 0 && trPar->GetTy() == 0)
87 if (trPar->GetQp() == 0)
continue;
88 if (TMath::IsNaN(trPar->GetX()) || TMath::IsNaN(trPar->GetY()) || TMath::IsNaN(trPar->GetZ())
89 || TMath::IsNaN(trPar->GetTx()) || TMath::IsNaN(trPar->GetTy()) || TMath::IsNaN(trPar->GetQp()))
93 TVector3 startP, momP, crossP, centerP;
96 Double_t p = 1. / TMath::Abs(trPar->GetQp());
98 Double_t pz2 = 1 + trPar->GetTx() * trPar->GetTx() + trPar->GetTy() * trPar->GetTy();
100 pz = p / TMath::Sqrt(pz2);
103 LOG(error) <<
"CbmRichProjectionProducerAnalytical::DoProjection(): strange value for calculating pz: " << pz2;
106 Double_t px = pz * trPar->GetTx();
107 Double_t py = pz * trPar->GetTy();
108 momP.SetXYZ(px, py, pz);
109 trPar->Position(startP);
110 if ((mirY * startP.y()) < 0) mirY = -mirY;
120 Double_t RxP = (momP.x() * (startP.x() - mirX) + momP.y() * (startP.y() - mirY) + momP.z() * (startP.z() - mirZ));
121 Double_t normP2 = (momP.x() * momP.x() + momP.y() * momP.y() + momP.z() * momP.z());
123 (startP.x() * startP.x() + mirX * mirX + startP.y() * startP.y() + mirY * mirY + startP.z() * startP.z()
124 + mirZ * mirZ - 2 * startP.x() * mirX - 2 * startP.y() * mirY - 2 * startP.z() * mirZ - mirR * mirR);
126 if ((RxP * RxP - normP2 * dist) > 0.) {
127 if (normP2 != 0.) rho1 = (-RxP + TMath::Sqrt(RxP * RxP - normP2 * dist)) / normP2;
128 if (normP2 == 0) LOG(error) <<
"CbmRichProjectionProducerAnalytical::DoProjection(): normP2 == 0";
134 Double_t crossPx = startP.x() + rho1 * momP.x();
135 Double_t crossPy = startP.y() + rho1 * momP.y();
136 Double_t crossPz = startP.z() + rho1 * momP.z();
137 crossP.SetXYZ(crossPx, crossPy, crossPz);
141 if ((mirY * crossP.y()) < 0) {
143 RxP = (momP.x() * (startP.x() - mirX) + momP.y() * (startP.y() - mirY) + momP.z() * (startP.z() - mirZ));
144 normP2 = (momP.x() * momP.x() + momP.y() * momP.y() + momP.z() * momP.z());
145 dist = (startP.x() * startP.x() + mirX * mirX + startP.y() * startP.y() + mirY * mirY + startP.z() * startP.z()
146 + mirZ * mirZ - 2 * startP.x() * mirX - 2 * startP.y() * mirY - 2 * startP.z() * mirZ - mirR * mirR);
148 if ((RxP * RxP - normP2 * dist) > 0.) {
149 if (normP2 != 0.) rho1 = (-RxP + TMath::Sqrt(RxP * RxP - normP2 * dist)) / normP2;
150 if (normP2 == 0) LOG(error) <<
"CbmRichProjectionProducerAnalytical::DoProjection(): normP2 == 0";
156 crossPx = startP.x() + rho1 * momP.x();
157 crossPy = startP.y() + rho1 * momP.y();
158 crossPz = startP.z() + rho1 * momP.z();
159 crossP.SetXYZ(crossPx, crossPy, crossPz);
162 centerP.SetXYZ(mirX, mirY, mirZ);
166 TVector3 normP(crossP.x() - centerP.x(), crossP.y() - centerP.y(), crossP.z() - centerP.z());
167 normP = normP.Unit();
169 if ((normP.z() * momP.z()) < 0.) normP = TVector3(-1. * normP.x(), -1. * normP.y(), -1. * normP.z());
172 Double_t np = normP.x() * momP.x() + normP.y() * momP.y() + normP.z() * momP.z();
175 ref.SetXYZ(2 * np * normP.x() - momP.x(), 2 * np * normP.y() - momP.y(), 2 * np * normP.z() - momP.z());
179 TVector3 inPos(0., 0., 0.), outPos(0., 0., 0.);
196 LOG(fatal) <<
"CbmRichProjectionProducerAnalytical::DoProjection(): unknown geometry type";
202 FairTrackParam richtrack(outPos.x(), outPos.y(), outPos.z(), 0., 0., 0., covMat);
203 *(FairTrackParam*) (
richProj->At(iT)) = richtrack;
211 const TVector3* crossP,
const TVector3* ref,
229 LOG(fatal) <<
"CbmRichProjectionProducerAnalytical::GetPmtIntersectionPointTwoWings(): Wrong geometry, this method "
230 "could be used only for CbmRichGeometryTypeTwoWings";
240 if (centerP->y() > 0) {
241 rho2 = (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
242 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneY - crossP->y())
243 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
244 / (-TMath::Sin(pmtPhi) * ref->x() - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
245 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
247 if (centerP->y() < 0) {
248 rho2 = (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
249 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * (-pmtPlaneY - crossP->y())
250 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
251 / (-TMath::Sin(pmtPhi) * ref->x() - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
252 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
256 Double_t xX = crossP->x() + ref->x() * rho2;
257 Double_t yY = crossP->y() + ref->y() * rho2;
258 Double_t zZ = crossP->z() + ref->z() * rho2;
261 if (centerP->y() > 0) {
262 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
263 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneY - crossP->y())
264 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneZ - crossP->z()))
265 / (-TMath::Sin(-pmtPhi) * ref->x() - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
266 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
268 if (centerP->y() < 0) {
269 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
270 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * (-pmtPlaneY - crossP->y())
271 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneZ - crossP->z()))
272 / (-TMath::Sin(-pmtPhi) * ref->x() - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
273 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
276 xX = crossP->x() + ref->x() * rho2;
277 yY = crossP->y() + ref->y() * rho2;
278 zZ = crossP->z() + ref->z() * rho2;
281 outPoint->SetXYZ(xX, yY, zZ);
286 const TVector3* ref, TVector3* outPoint)
290 LOG(fatal) <<
"CbmRichProjectionProducerAnalytical::GetPmtIntersectionPointCyl(): Wrong geometry, this method "
291 "could be used only for CbmRichGeometryTypeCylindrical";
296 Double_t maxDist = 0.;
298 for (map<string, CbmRichRecGeoParPmt>::iterator it = gp->
fPmtMap.begin(); it != gp->
fPmtMap.end(); it++) {
299 Double_t pmtPlaneX = it->second.fPlaneX;
300 Double_t pmtPlaneY = it->second.fPlaneY;
301 Double_t pmtPlaneZ = it->second.fPlaneZ;
302 Double_t pmtPhi = it->second.fPhi;
303 Double_t pmtTheta = it->second.fTheta;
305 if (!(pmtPlaneX >= 0 && pmtPlaneY >= 0))
continue;
309 if (centerP->y() > 0) {
310 rho2 = (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
311 - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneY - crossP->y())
312 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
313 / (-TMath::Sin(pmtPhi) * ref->x() - TMath::Sin(pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
314 + TMath::Cos(pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
316 if (centerP->y() < 0) {
317 rho2 = (-TMath::Sin(pmtPhi) * (pmtPlaneX - crossP->x())
318 - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * (-pmtPlaneY - crossP->y())
319 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * (pmtPlaneZ - crossP->z()))
320 / (-TMath::Sin(pmtPhi) * ref->x() - TMath::Sin(-pmtTheta) * TMath::Cos(pmtPhi) * ref->y()
321 + TMath::Cos(-pmtTheta) * TMath::Cos(pmtPhi) * ref->z());
324 Double_t cxX = crossP->x() + ref->x() * rho2;
325 Double_t cyY = crossP->y() + ref->y() * rho2;
326 Double_t czZ = crossP->z() + ref->z() * rho2;
329 if (centerP->y() > 0) {
330 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
331 - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneY - crossP->y())
332 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneZ - crossP->z()))
333 / (-TMath::Sin(-pmtPhi) * ref->x() - TMath::Sin(pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
334 + TMath::Cos(pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
336 if (centerP->y() < 0) {
337 rho2 = (-TMath::Sin(-pmtPhi) * (-pmtPlaneX - crossP->x())
338 - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * (-pmtPlaneY - crossP->y())
339 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * (pmtPlaneZ - crossP->z()))
340 / (-TMath::Sin(-pmtPhi) * ref->x() - TMath::Sin(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->y()
341 + TMath::Cos(-pmtTheta) * TMath::Cos(-pmtPhi) * ref->z());
344 cxX = crossP->x() + ref->x() * rho2;
345 cyY = crossP->y() + ref->y() * rho2;
346 czZ = crossP->z() + ref->z() * rho2;
349 Double_t dP = TMath::Sqrt((crossP->x() - cxX) * (crossP->X() - cxX) + (crossP->y() - cyY) * (crossP->y() - cyY)
350 + (crossP->z() - czZ) * (crossP->Z() - czZ));
360 outPoint->SetXYZ(xX, yY, zZ);
@ CbmRichGeometryTypeTwoWings
@ CbmRichGeometryTypeCylindrical
Class characterising one event by a collection of links (indices) to data objects,...
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
Bool_t IsPointInsidePmt(const TVector3 *rotatedPoint)
static CbmRichGeoManager & GetInstance()
void GetPmtIntersectionPointCyl(const TVector3 *centerP, const TVector3 *crossP, const TVector3 *ref, TVector3 *outPoint)
TClonesArray * fTrackParams
virtual void Init()
Initialization of the task.
virtual ~CbmRichProjectionProducerAnalytical()
Destructor.
virtual void DoProjection(TClonesArray *richProj)
Execute task.
void GetPmtIntersectionPointTwoWings(const TVector3 *centerP, const TVector3 *crossP, const TVector3 *ref, TVector3 *outPoint)
CbmRichProjectionProducerAnalytical()
Standard constructor.
PMT parameters for the RICH geometry.
CbmRichGeometryType fGeometryType
std::map< std::string, CbmRichRecGeoParPmt > fPmtMap
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...