FairShip
Loading...
Searching...
No Matches
splitcalCluster Class Reference

#include <splitcalCluster.h>

Inheritance diagram for splitcalCluster:
Collaboration diagram for splitcalCluster:

Public Member Functions

 splitcalCluster ()
 
virtual ~splitcalCluster ()
 
virtual void Print () const
 
void SetEtaPhiE (double &eta, double &phi, double &e)
 
void SetEta (double &eta)
 
void SetPhi (double &phi)
 
void SetEnergy (double &e)
 
void SetIndex (int i)
 
void SetStartPoint (const double &x, const double &y, const double &z)
 
void SetEndPoint (const double &x, const double &y, const double &z)
 
void SetHitIndices (const std::vector< int > &v)
 
void AddHit (int hitIndex, double weight=1.0)
 
int GetIndex ()
 
double GetEta ()
 
double GetPhi ()
 
double GetEnergy ()
 
double GetPx ()
 
double GetPy ()
 
double GetPz ()
 
double GetEx ()
 
double GetEy ()
 
double GetEz ()
 
TVector3 GetStartPoint () const
 
TVector3 GetEndPoint () const
 
const std::vector< int > & GetHitIndices () const
 
const std::vector< double > & GetHitWeights () const
 
void ComputeEtaPhiE (const std::vector< splitcalHit > &hits)
 
 splitcalCluster (const splitcalCluster &cluster)=default
 
splitcalClusteroperator= (const splitcalCluster &cluster)=default
 

Private Member Functions

 ClassDef (splitcalCluster, 4)
 

Private Attributes

int _index
 
double _eta
 
double _phi
 
double _energy
 
std::array< double, 3 > _start
 
std::array< double, 3 > _end
 
std::vector< int > _hitIndices
 
std::vector< double > _hitWeights
 

Detailed Description

Definition at line 16 of file splitcalCluster.h.

Constructor & Destructor Documentation

◆ splitcalCluster() [1/2]

splitcalCluster::splitcalCluster ( )

Constructors

Definition at line 12 of file splitcalCluster.cxx.

12{}

◆ ~splitcalCluster()

splitcalCluster::~splitcalCluster ( )
virtual

Destructor

Definition at line 93 of file splitcalCluster.cxx.

93{}

◆ splitcalCluster() [2/2]

splitcalCluster::splitcalCluster ( const splitcalCluster cluster)
default

Copy constructor

Member Function Documentation

◆ AddHit()

void splitcalCluster::AddHit ( int  hitIndex,
double  weight = 1.0 
)
inline

Definition at line 47 of file splitcalCluster.h.

47 {
48 _hitIndices.push_back(hitIndex);
49 _hitWeights.push_back(weight);
50 }
std::vector< double > _hitWeights
std::vector< int > _hitIndices

◆ ClassDef()

splitcalCluster::ClassDef ( splitcalCluster  ,
 
)
private

◆ ComputeEtaPhiE()

void splitcalCluster::ComputeEtaPhiE ( const std::vector< splitcalHit > &  hits)

Definition at line 14 of file splitcalCluster.cxx.

14 {
15 // Compute energy weighted average for hits in the same layer
16 // This is in preparation of the linear fit to get the cluster eta and phi
17
18 // maps to compute the weighted average of all the hits in the same layer
19 std::map<int, double> mapLayerWeigthedX;
20 std::map<int, double> mapLayerWeigthedY;
21 std::map<int, double> mapLayerZ1;
22 std::map<int, double> mapLayerZ2;
23 std::map<int, double> mapLayerSumWeigthsX;
24 std::map<int, double> mapLayerSumWeigthsY;
25
26 // loop over hits to compute cluster energy sum and to compute the coordinates
27 // weighted average per layer
28 double energy = 0.;
29 for (size_t i = 0; i < _hitIndices.size(); ++i) {
30 const auto& hit = hits[_hitIndices[i]];
31 double hitEnergy =
32 hit.GetEnergy() * _hitWeights[i]; // Use weight from cluster
33 energy += hitEnergy;
34 int layer = hit.GetLayerNumber();
35 // hits from high precision layers give both x and y coordinates --> use
36 // if-if instead of if-else
37 if (hit.IsX()) {
38 if (!mapLayerWeigthedX.contains(layer)) {
39 mapLayerWeigthedX[layer] = 0.;
40 mapLayerSumWeigthsX[layer] = 0.;
41 }
42 mapLayerWeigthedX[layer] += hit.GetX() * hitEnergy;
43 mapLayerSumWeigthsX[layer] += hitEnergy;
44 mapLayerZ1[layer] = hit.GetZ();
45 }
46 if (hit.IsY()) {
47 if (!mapLayerWeigthedY.contains(layer)) {
48 mapLayerWeigthedY[layer] = 0.;
49 mapLayerSumWeigthsY[layer] = 0.;
50 }
51 mapLayerWeigthedY[layer] += hit.GetY() * hitEnergy;
52 mapLayerSumWeigthsY[layer] += hitEnergy;
53 mapLayerZ2[layer] = hit.GetZ();
54 }
55 } // end loop on hit
56
57 auto const& [minLayerX, weightedMinX] = *mapLayerWeigthedX.begin();
58 double minX = weightedMinX / mapLayerSumWeigthsX[minLayerX];
59 double minZ1 = mapLayerZ1[minLayerX];
60
61 auto const& [minLayerY, weightedMinY] = *mapLayerWeigthedY.begin();
62 double minY = weightedMinY / mapLayerSumWeigthsY[minLayerY];
63 double minZ2 = mapLayerZ1[minLayerY];
64
65 double minZ = (minZ1 + minZ2) / 2.;
66
67 SetStartPoint(minX, minY, minZ);
68
69 auto const& [maxLayerX, weightedMaxX] = *mapLayerWeigthedX.rbegin();
70 double maxX = weightedMaxX / mapLayerSumWeigthsX[maxLayerX];
71 double maxZ1 = mapLayerZ1[maxLayerX];
72
73 auto const& [maxLayerY, weightedMaxY] = *mapLayerWeigthedY.rbegin();
74 double maxY = weightedMaxY / mapLayerSumWeigthsY[maxLayerY];
75 double maxZ2 = mapLayerZ1[maxLayerY];
76
77 double maxZ = (maxZ1 + maxZ2) / 2.;
78
79 SetEndPoint(maxX, maxY, maxZ);
80
81 // get direction vector from end-start vector difference
82 TVector3 start(_start[0], _start[1], _start[2]);
83 TVector3 end(_end[0], _end[1], _end[2]);
84 TVector3 direction = end - start;
85 double eta = direction.Eta();
86 double phi = direction.Phi();
87 SetEtaPhiE(eta, phi, energy);
88}
void SetStartPoint(const double &x, const double &y, const double &z)
void SetEndPoint(const double &x, const double &y, const double &z)
std::array< double, 3 > _end
void SetEtaPhiE(double &eta, double &phi, double &e)
std::array< double, 3 > _start
int i
Definition: ShipAna.py:97

◆ GetEndPoint()

TVector3 splitcalCluster::GetEndPoint ( ) const
inline

Definition at line 65 of file splitcalCluster.h.

65{ return TVector3(_end[0], _end[1], _end[2]); }

◆ GetEnergy()

double splitcalCluster::GetEnergy ( )
inline

Definition at line 55 of file splitcalCluster.h.

55{ return _energy; }

◆ GetEta()

double splitcalCluster::GetEta ( )
inline

Definition at line 53 of file splitcalCluster.h.

53{ return _eta; }

◆ GetEx()

double splitcalCluster::GetEx ( )
inline

Definition at line 59 of file splitcalCluster.h.

59{ return GetPx(); }

◆ GetEy()

double splitcalCluster::GetEy ( )
inline

Definition at line 60 of file splitcalCluster.h.

60{ return GetPy(); }

◆ GetEz()

double splitcalCluster::GetEz ( )
inline

Definition at line 61 of file splitcalCluster.h.

61{ return GetPz(); }

◆ GetHitIndices()

const std::vector< int > & splitcalCluster::GetHitIndices ( ) const
inline

Definition at line 66 of file splitcalCluster.h.

66{ return _hitIndices; }

◆ GetHitWeights()

const std::vector< double > & splitcalCluster::GetHitWeights ( ) const
inline

Definition at line 67 of file splitcalCluster.h.

67{ return _hitWeights; }

◆ GetIndex()

int splitcalCluster::GetIndex ( )
inline

Definition at line 52 of file splitcalCluster.h.

52{ return _index; }

◆ GetPhi()

double splitcalCluster::GetPhi ( )
inline

Definition at line 54 of file splitcalCluster.h.

54{ return _phi; }

◆ GetPx()

double splitcalCluster::GetPx ( )
inline

Definition at line 56 of file splitcalCluster.h.

56{ return _energy * sin(_eta) * cos(_phi); }

◆ GetPy()

double splitcalCluster::GetPy ( )
inline

Definition at line 57 of file splitcalCluster.h.

57{ return _energy * sin(_eta) * sin(_phi); }

◆ GetPz()

double splitcalCluster::GetPz ( )
inline

Definition at line 58 of file splitcalCluster.h.

58{ return _energy * cos(_eta); }

◆ GetStartPoint()

TVector3 splitcalCluster::GetStartPoint ( ) const
inline

Definition at line 62 of file splitcalCluster.h.

62 {
63 return TVector3(_start[0], _start[1], _start[2]);
64 }

◆ operator=()

splitcalCluster & splitcalCluster::operator= ( const splitcalCluster cluster)
default

◆ Print()

void splitcalCluster::Print ( ) const
virtual

Methods

Definition at line 97 of file splitcalCluster.cxx.

97 {
98 std::cout << "-I- splitcalCluster: " << std::endl;
99 std::cout << " (eta,phi,energy) = " << _eta << " , " << _phi << " , "
100 << _energy << std::endl;
101 std::cout << " start(x,y,z) = " << _start[0] << " , " << _start[1]
102 << " , " << _start[2] << std::endl;
103 std::cout << " end(x,y,z) = " << _end[0] << " , " << _end[1] << " , "
104 << _end[2] << std::endl;
105 std::cout << "------- " << std::endl;
106}

◆ SetEndPoint()

void splitcalCluster::SetEndPoint ( const double &  x,
const double &  y,
const double &  z 
)
inline

Definition at line 41 of file splitcalCluster.h.

41 {
42 _end[0] = x;
43 _end[1] = y;
44 _end[2] = z;
45 }

◆ SetEnergy()

void splitcalCluster::SetEnergy ( double &  e)
inline

Definition at line 34 of file splitcalCluster.h.

34{ _energy = e; }

◆ SetEta()

void splitcalCluster::SetEta ( double &  eta)
inline

Definition at line 32 of file splitcalCluster.h.

32{ _eta = eta; }

◆ SetEtaPhiE()

void splitcalCluster::SetEtaPhiE ( double &  eta,
double &  phi,
double &  e 
)
inline

Definition at line 27 of file splitcalCluster.h.

27 {
28 _eta = eta;
29 _phi = phi;
30 _energy = e;
31 }

◆ SetHitIndices()

void splitcalCluster::SetHitIndices ( const std::vector< int > &  v)
inline

Definition at line 46 of file splitcalCluster.h.

◆ SetIndex()

void splitcalCluster::SetIndex ( int  i)
inline

Definition at line 35 of file splitcalCluster.h.

35{ _index = i; }

◆ SetPhi()

void splitcalCluster::SetPhi ( double &  phi)
inline

Definition at line 33 of file splitcalCluster.h.

33{ _phi = phi; }

◆ SetStartPoint()

void splitcalCluster::SetStartPoint ( const double &  x,
const double &  y,
const double &  z 
)
inline

Definition at line 36 of file splitcalCluster.h.

36 {
37 _start[0] = x;
38 _start[1] = y;
39 _start[2] = z;
40 }

Member Data Documentation

◆ _end

std::array<double, 3> splitcalCluster::_end
private

Definition at line 79 of file splitcalCluster.h.

◆ _energy

double splitcalCluster::_energy
private

Definition at line 77 of file splitcalCluster.h.

◆ _eta

double splitcalCluster::_eta
private

Definition at line 77 of file splitcalCluster.h.

◆ _hitIndices

std::vector<int> splitcalCluster::_hitIndices
private

Definition at line 80 of file splitcalCluster.h.

◆ _hitWeights

std::vector<double> splitcalCluster::_hitWeights
private

Definition at line 81 of file splitcalCluster.h.

◆ _index

int splitcalCluster::_index
private

Definition at line 76 of file splitcalCluster.h.

◆ _phi

double splitcalCluster::_phi
private

Definition at line 77 of file splitcalCluster.h.

◆ _start

std::array<double, 3> splitcalCluster::_start
private

Definition at line 78 of file splitcalCluster.h.


The documentation for this class was generated from the following files: