EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterv3.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterv3.cc
1 
7 #include "TrkrClusterv3.h"
8 
9 #include <cmath>
10 #include <utility> // for swap
11 
12 namespace
13 {
14  // square convenience function
15  template<class T> inline constexpr T square( const T& x )
16  { return x*x; }
17 }
18 
20  : m_cluskey(TrkrDefs::CLUSKEYMAX)
21  , m_subsurfkey(TrkrDefs::SUBSURFKEYMAX)
22  , m_adc(0xFFFFFFFF)
23 {
24  for (int i = 0; i < 2; i++)
25  {
26  m_local[i] = NAN;
27  for(int j = 0; j < 2; j ++)
28  {
29  m_actsLocalErr[i][j] = NAN;
30  }
31  }
32 }
33 
34 void TrkrClusterv3::identify(std::ostream& os) const
35 {
36  os << "---TrkrClusterv3--------------------" << std::endl;
37  os << "clusid: " << getClusKey() << std::dec << std::endl;
38 
39  os << " (rphi,z) = (" << getLocalX();
40  os << ", " << getLocalY() << ") cm ";
41 
42  os << " adc = " << getAdc() << std::endl;
43 
44  os << "Error " << std::endl;
45  os << " ( ";
46  os << getActsLocalError(0, 0) << " , ";
47  os << getActsLocalError(0, 1) << " ) " << std::endl;
48  os << " ( ";
49  os << getActsLocalError(1, 0) << ", ";
50  os << getActsLocalError(1, 1) << " ) " << std::endl;
51 
52  os << std::endl;
53  os << "-----------------------------------------------" << std::endl;
54 
55  return;
56 }
57 
59 {
60  if (m_cluskey == TrkrDefs::CLUSKEYMAX) { return 0; }
61  for (int i = 0; i < 2; ++i)
62  {
63  if (std::isnan(getPosition(i))) { return 0; }
64  for (int j = 0; j < 2; ++j)
65  { if (std::isnan(getActsLocalError(i,j))) { return 0; }}
66  }
67  if (m_adc == 0xFFFFFFFF) { return 0; }
68 
69  return 1;
70 }
71 
72 void TrkrClusterv3::CopyFrom( const TrkrCluster& source )
73 {
74  // do nothing if copying onto oneself
75  if( this == &source ) return;
76 
77  // parent class method
78  TrkrCluster::CopyFrom( source );
79 
80  setClusKey( source.getClusKey() );
81  setLocalX( source.getLocalX() );
82  setLocalY( source.getLocalY() );
83 
84  for (int j = 0; j < 2; ++j)
85  for (int i = 0; i < 2; ++i)
86  { setActsLocalError(i, j, source.getActsLocalError(i, j)); }
87 
88  setSubSurfKey( source.getSubSurfKey() );
89  setAdc( source.getAdc() );
90 }
91 
93 { return std::sqrt(m_actsLocalErr[0][0]); }
94 
96 { return std::sqrt(m_actsLocalErr[1][1]); }
97 
98 void TrkrClusterv3::setActsLocalError(unsigned int i, unsigned int j,
99  float value)
100 {
101  m_actsLocalErr[i][j] = value;
102 }