er  dev
ERPoint.cxx
1 /********************************************************************************
2  * Copyright (C) Joint Institute for Nuclear Research *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #include "ERPoint.h"
10 
11 #include <cmath>
12 #include<iostream>
13 
14 #include "FairLogger.h"
15 
16 // ----- Default constructor -------------------------------------------
18  : FairMCPoint(),
19  fX_out(0.), fY_out(0.), fZ_out(0.),
20  fPx_out(0.), fPy_out(0.), fPz_out(0.)
21 {
22 }
23 // -------------------------------------------------------------------------
24 // ----- Standard constructor ------------------------------------------
25 ERPoint::ERPoint(Int_t eventID, Int_t trackID,
26  Int_t mot0trackID,
27  Int_t volNb,
28  Double_t mass,
29  TVector3 posIn, TVector3 posInLoc,
30  TVector3 posOut, TVector3 momIn, TVector3 momOut,
31  Double_t timeIn, Double_t timeOut, Double_t trackLength, Double_t eLoss, Double_t lightYield, Int_t pid, Double_t charge)
32  : FairMCPoint(trackID, -1., posIn, momIn, timeIn, 0., eLoss),
33  fEventID(eventID),
34  fVolNb(volNb),
35  fXlocal(posInLoc.X()),fYlocal(posInLoc.Y()), fZlocal(posInLoc.Z()),
36  fX_out(posOut.X()), fY_out(posOut.Y()), fZ_out(posOut.Z()),
37  fPx_out(momOut.X()), fPy_out(momOut.Y()), fPz_out(momOut.Z()),
38  fLightYield(lightYield), fPID(pid), fCharge(charge),fTimeIn(timeIn), fTimeOut(timeOut),
39  fTrackLength(trackLength)
40 {
41 }
42 // -------------------------------------------------------------------------
43 
44 
45 
46 // -------------------------------------------------------------------------
48  : FairMCPoint(right),
49  fVolNb(right.fVolNb),
50  fX_out(right.fX_out), fY_out(right.fY_out), fZ_out(right.fZ_out),
51  fPx_out(right.fPx_out), fPy_out(right.fPy_out), fPz_out(right.fPz_out),
52  fLightYield(right.fLightYield), fPID(right.fPID), fCharge(right.fCharge),
53  fTimeIn(right.fTimeIn),fTimeOut(right.fTimeOut), fTrackLength(right.fTrackLength)
54 {
55 }
56 // -------------------------------------------------------------------------
57 
58 
59 
60 // ----- Destructor ----------------------------------------------------
62 {
63 }
64 // -------------------------------------------------------------------------
65 
66 
67 
68 // ----- Public method Print -------------------------------------------
69 void ERPoint::Print(const Option_t* opt /* = 0*/) const
70 {
71  LOG(INFO) << "-I- ERPoint: track " << fTrackID << " mother track = " << fMot0TrackID << FairLogger::endl;
72  LOG(INFO) << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << FairLogger::endl;
73  LOG(INFO) << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << FairLogger::endl;
74  LOG(INFO) << " Time " << fTime << " ns, Length " << fLength << " cm" << FairLogger::endl;
75  LOG(INFO) << " Energy loss " << fELoss << " keV, Light yield " << fLightYield << " MeV "<< FairLogger::endl;
76  LOG(INFO) << " Vol number " << fVolNb << FairLogger::endl;
77 }
78 // -------------------------------------------------------------------------
79 
80 
81 
82 // ----- Point x coordinate from linear extrapolation ------------------
83 Double_t ERPoint::GetX(Double_t z) const
84 {
85  // cout << fZ << " " << z << " " << fZ_out << endl;
86  if ( (fZ_out-z)*(fZ-z) >= 0. ) return (fX_out+fX)/2.;
87  Double_t dz = fZ_out - fZ;
88  return ( fX + (z-fZ) / dz * (fX_out-fX) );
89 }
90 // -------------------------------------------------------------------------
91 
92 
93 
94 // ----- Point y coordinate from linear extrapolation ------------------
95 Double_t ERPoint::GetY(Double_t z) const
96 {
97  if ( (fZ_out-z)*(fZ-z) >= 0. ) return (fY_out+fY)/2.;
98  Double_t dz = fZ_out - fZ;
99  // if ( TMath::Abs(dz) < 1.e-3 ) return (fY_out+fY)/2.;
100  return ( fY + (z-fZ) / dz * (fY_out-fY) );
101 }
102 // -------------------------------------------------------------------------
103 
104 
105 
106 // ----- Public method IsUsable ----------------------------------------
107 Bool_t ERPoint::IsUsable() const
108 {
109  Double_t dz = fZ_out - fZ;
110  if ( TMath::Abs(dz) < 1.e-4 ) return kFALSE;
111  return kTRUE;
112 }
113 // -------------------------------------------------------------------------
114 
115 //-------------------------------------------------------------------------
116 Double_t ERPoint::GetPIn() const{
117  return sqrt(fPx*fPx + fPy*fPy + fPz*fPz);
118 }
119 //-------------------------------------------------------------------------
120 
121 //-------------------------------------------------------------------------
122 Double_t ERPoint::GetPOut() const{
123  return sqrt(fPx_out*fPx_out + fPy_out*fPy_out + fPz_out*fPz_out);
124 }
125 //-------------------------------------------------------------------------
126 Double_t ERPoint::GetP(Double_t pointLen) const{
127  return GetPIn() + (GetPOut() - GetPIn())*pointLen/GetLength();
128 }
129 //-------------------------------------------------------------------------
130 Double_t ERPoint::GetTime(Double_t pointLen) const{
131  return fTime + (fTimeOut - fTime)*pointLen/GetLength();
132 }
133 //-------------------------------------------------------------------------
134 Double_t ERPoint::GetLength() const{
135  return sqrt((fX_out-fX)*(fX_out-fX) + (fY_out-fY)*(fY_out-fY) + (fZ_out-fZ)*(fZ_out-fZ) );
136 }
137 //-------------------------------------------------------------------------
138 ClassImp(ERPoint)
Double_t GetX(Double_t z) const
Definition: ERPoint.cxx:83
virtual void Print(const Option_t *opt=0) const
Definition: ERPoint.cxx:69
virtual ~ERPoint()
Definition: ERPoint.cxx:61
Bool_t IsUsable() const
Definition: ERPoint.cxx:107
ERPoint()
Definition: ERPoint.cxx:17
The data class for storing pieces of charged tracks in sensitive volumes in NeuRad.
Definition: ERPoint.h:23