er  dev
ERBeamDetTargetPoint.cxx
1 // -------------------------------------------------------------------------
2 // ----- ERBeamDetTargetPoint source file -----
3 // -------------------------------------------------------------------------
4 
5 #include "ERBeamDetTargetPoint.h"
6 #include <iostream>
7 using namespace std;
8 // ----- Default constructor -------------------------------------------
10  : FairMCPoint(),
11  fX_out(0.), fY_out(0.), fZ_out(0.),
12  fPx_out(0.), fPy_out(0.), fPz_out(0.),
13  fLightYield(0.)
14 {
15 }
16 // -------------------------------------------------------------------------
17 ERBeamDetTargetPoint::ERBeamDetTargetPoint(Int_t eventID, Int_t trackID,
18  Int_t mot0trackID,
19  Int_t pid,
20  TVector3 posIn,
21  TVector3 posOut, TVector3 momIn, TVector3 momOut,
22  Double_t tof, Double_t length, Double_t eLoss, Double_t lightYield)
23  : FairMCPoint(trackID, -1., posIn, momIn, tof, length, eLoss),
24  fEventID(eventID),
25  fPid(pid),
26  fX_in(posIn.X()), fY_in(posIn.Y()), fZ_in(posIn.Z()),
27  fPx_in(momIn.X()), fPy_in(momIn.Y()), fPz_in(momIn.Z()),
28  fX_out(posOut.X()), fY_out(posOut.Y()), fZ_out(posOut.Z()),
29  fPx_out(momOut.X()), fPy_out(momOut.Y()), fPz_out(momOut.Z()),
30  fLightYield(lightYield)
31 {
32 }
33 // -------------------------------------------------------------------------
35 {
36 }
37 // -------------------------------------------------------------------------
38 void ERBeamDetTargetPoint::Print(const Option_t* opt /* = 0*/) const
39 {
40  cout << "-I- ERBeamDetTargetPoint: track " << fTrackID << " mother track = " << fMot0TrackID << endl;
41  cout << " particle ID " << fPid << endl;
42  cout << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl;
43  cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") MeV" << endl;
44  cout << " Time " << fTime << " ns, Length " << fLength << " cm" << endl;
45  cout << " Energy loss " << fELoss << " MeV "<< endl;
46 }
47 // -------------------------------------------------------------------------
48 // ----- Point x coordinate from linear extrapolation ------------------
49 Double_t ERBeamDetTargetPoint::GetX(Double_t z) const
50 {
51  if ( (fZ_out-z)*(fZ-z) >= 0. ) return (fX_out+fX)/2.;
52  Double_t dz = fZ_out - fZ;
53  return ( fX + (z-fZ) / dz * (fX_out-fX) );
54 }
55 // -------------------------------------------------------------------------
56 // ----- Point y coordinate from linear extrapolation ------------------
57 Double_t ERBeamDetTargetPoint::GetY(Double_t z) const
58 {
59  if ( (fZ_out-z)*(fZ-z) >= 0. ) return (fY_out+fY)/2.;
60  Double_t dz = fZ_out - fZ;
61  // if ( TMath::Abs(dz) < 1.e-3 ) return (fY_out+fY)/2.;
62  return ( fY + (z-fZ) / dz * (fY_out-fY) );
63 }
64 // -------------------------------------------------------------------------
65 // ----- Public method IsUsable ----------------------------------------
67 {
68  Double_t dz = fZ_out - fZ;
69  if ( TMath::Abs(dz) < 1.e-4 ) return kFALSE;
70  return kTRUE;
71 }
72 // -------------------------------------------------------------------------
73 ClassImp(ERBeamDetTargetPoint)
Double_t GetX(Double_t z) const
virtual void Print(const Option_t *opt=0) const