CbmRoot
CbmRichProjectionProducerTGeo.cxx
Go to the documentation of this file.
1 
9 
10 #include "CbmMCTrack.h"
11 #include "FairGeoNode.h"
12 #include "FairGeoTransform.h"
13 #include "FairGeoVector.h"
14 #include "FairRootManager.h"
15 #include "FairRun.h"
16 #include "FairRunAna.h"
17 #include "FairRuntimeDb.h"
18 #include "FairTrackParam.h"
19 #include "TGeoManager.h"
20 
21 #include "CbmRichGeoManager.h"
22 #include "TClonesArray.h"
23 #include "TMatrixFSym.h"
24 #include "TVector3.h"
26 
27 #include "FairLogger.h"
28 
29 #include <cmath>
30 #include <iostream>
31 
32 using std::cout;
33 using std::endl;
34 
35 
37  : fTrackParams(NULL), fNHits(0), fEventNum(0) {}
38 
40  FairRootManager* fManager = FairRootManager::Instance();
41  fManager->Write();
42 }
43 
44 
46  LOG(info) << "CbmRichProjectionProducerTGeo::Init()";
47  FairRootManager* manager = FairRootManager::Instance();
48 
49  fTrackParams = (TClonesArray*) manager->GetObject("RichTrackParamZ");
50  if (NULL == fTrackParams) { LOG(fatal) << "No RichTrackParamZ array!"; }
51 }
52 
54  fEventNum++;
55  LOG(info) << "CbmRichProjectionProducer: event " << fEventNum;
56 
58  double mirrorX = gp->fMirrorX;
59  double mirrorY = gp->fMirrorY;
60  double mirrorZ = gp->fMirrorZ;
61 
62  richProj->Delete();
63  TMatrixFSym covMat(5);
64  for (Int_t i = 0; i < 5; i++) {
65  for (Int_t j = 0; j <= i; j++) {
66  covMat(i, j) = 0;
67  }
68  }
69  covMat(0, 0) = covMat(1, 1) = covMat(2, 2) = covMat(3, 3) = covMat(4, 4) =
70  1.e-4;
71 
72  for (Int_t j = 0; j < fTrackParams->GetEntriesFast(); j++) {
73  FairTrackParam* trackParam = (FairTrackParam*) fTrackParams->At(j);
74  new ((*richProj)[j]) FairTrackParam(0., 0., 0., 0., 0., 0., covMat);
75 
76  if (trackParam->GetX() == 0 && trackParam->GetY() == 0
77  && trackParam->GetZ() == 0 && trackParam->GetTx() == 0
78  && trackParam->GetTy() == 0)
79  continue;
80  if (trackParam->GetQp() == 0) continue;
81 
82  TVector3 startP, crossP, centerP;
83  TVector3 dirCos;
84  Double_t nx, ny, nz;
85  CbmRichNavigationUtil::GetDirCos(trackParam, nx, ny, nz);
86  dirCos.SetXYZ(nx, ny, nz);
87 
88  string volumeName = CbmRichNavigationUtil::FindIntersection(
89  trackParam, crossP, "mirror_tile_type");
90  Bool_t mirrorIntersectionFound = (volumeName != string(""));
91  if (!mirrorIntersectionFound) continue;
92 
93  // mirror center
94  if (crossP.Y() > 0) {
95  centerP.SetXYZ(mirrorX, mirrorY, mirrorZ);
96  } else {
97  centerP.SetXYZ(mirrorX, -mirrorY, mirrorZ);
98  }
99 
100  // calculate normal on crosspoint with mirror
101  TVector3 normP(crossP.x() - centerP.x(),
102  crossP.y() - centerP.y(),
103  crossP.z() - centerP.z());
104  normP = normP.Unit();
105  // check that normal has same z-direction as momentum
106  if ((normP.z() * dirCos.z()) < 0.)
107  normP = TVector3(-1. * normP.x(), -1. * normP.y(), -1. * normP.z());
108 
109  // reflect track
110  Double_t np =
111  normP.x() * dirCos.x() + normP.y() * dirCos.y() + normP.z() * dirCos.z();
112  Double_t refX = 2 * np * normP.x() - dirCos.x();
113  Double_t refY = 2 * np * normP.y() - dirCos.y();
114  Double_t refZ = 2 * np * normP.z() - dirCos.z();
115  TVector3 refl;
116  refl.SetXYZ(-refX, -refY, -refZ);
117  refl.Unit();
118 
119  TVector3 pmtIntersectionPoint;
121  refl, crossP, pmtIntersectionPoint, "pmt");
122  Bool_t pmtIntersectionFound = (volumeName != string(""));
123  if (!pmtIntersectionFound) continue;
124 
125 
126  // Transform intersection point in same way as MCPoints were
127  // transformed in HitProducer before stored as Hit:
128  TVector3 outPos;
129  CbmRichGeoManager::GetInstance().RotatePoint(&pmtIntersectionPoint,
130  &outPos);
131  Double_t xDet = outPos.X();
132  Double_t yDet = outPos.Y();
133  Double_t zDet = outPos.Z();
134 
135  //check that crosspoint inside the plane
136  // if( xDet > (-fGP.fPmtXOrig-fGP.fPmtWidthX) && xDet < (fGP.fPmtXOrig+fGP.fPmtWidthX)){
137  // if(TMath::Abs(yDet) > (fGP.fPmtY-fGP.fPmtWidthY) && TMath::Abs(yDet) < (fGP.fPmtY+fGP.fPmtWidthY)){
138  FairTrackParam richtrack(xDet, yDet, zDet, 0., 0., 0., covMat);
139  *(FairTrackParam*) (richProj->At(j)) = richtrack;
140  // }
141  // }
142  } // j
143 
144  cout << "nofRichProjections:" << richProj->GetEntriesFast() << endl;
145 }
CbmRichRecGeoPar::fMirrorZ
Double_t fMirrorZ
Definition: CbmRichRecGeoPar.h:232
CbmRichProjectionProducerTGeo::Init
virtual void Init()
Initialization of the task.
Definition: CbmRichProjectionProducerTGeo.cxx:45
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichRecGeoPar::fMirrorY
Double_t fMirrorY
Definition: CbmRichRecGeoPar.h:231
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichRecGeoPar::fMirrorX
Double_t fMirrorX
Definition: CbmRichRecGeoPar.h:230
CbmRichProjectionProducerTGeo::fTrackParams
TClonesArray * fTrackParams
Definition: CbmRichProjectionProducerTGeo.h:59
CbmRichProjectionProducerTGeo::CbmRichProjectionProducerTGeo
CbmRichProjectionProducerTGeo()
Standard constructor.
Definition: CbmRichProjectionProducerTGeo.cxx:36
CbmRichProjectionProducerTGeo::fEventNum
int fEventNum
Definition: CbmRichProjectionProducerTGeo.h:62
CbmRichProjectionProducerTGeo::DoProjection
virtual void DoProjection(TClonesArray *richProj)
Execute task.
Definition: CbmRichProjectionProducerTGeo.cxx:53
CbmRichNavigationUtil::FindIntersection
static string FindIntersection(const FairTrackParam *par, TVector3 &crossPoint, const string &volumeName)
Definition: CbmRichNavigationUtil.h:14
CbmRichGeoManager.h
CbmRichRecGeoPar
PMT parameters for the RICH geometry.
Definition: CbmRichRecGeoPar.h:87
CbmRichNavigationUtil::GetDirCos
static void GetDirCos(const FairTrackParam *par, Double_t &nx, Double_t &ny, Double_t &nz)
Definition: CbmRichNavigationUtil.h:77
CbmRichGeoManager::RotatePoint
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
Definition: CbmRichGeoManager.cxx:407
richProj
TClonesArray * richProj
Definition: Compute_distance.h:18
CbmMCTrack.h
CbmRichProjectionProducerTGeo.h
Project track by straight line from imaginary plane to the mirror and reflect it to the photodetector...
CbmRichGeoManager::fGP
CbmRichRecGeoPar * fGP
Definition: CbmRichGeoManager.h:23
CbmRichNavigationUtil.h
CbmRichProjectionProducerTGeo::~CbmRichProjectionProducerTGeo
virtual ~CbmRichProjectionProducerTGeo()
Destructor.
Definition: CbmRichProjectionProducerTGeo.cxx:39