StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSstPoint.cc
1 //$Id: StSstPoint.cc,v 1.2 2016/06/10 19:29:58 bouchet Exp $
2 //
3 //$Log: StSstPoint.cc,v $
4 //Revision 1.2 2016/06/10 19:29:58 bouchet
5 //coverity : UNINIT_CTOR
6 //
7 //Revision 1.1 2015/06/23 16:26:20 jeromel
8 //First version created from the SSD code and reshaped
9 //
10 //Revision 1.1 2015/04/19 17:30:32 bouchet
11 //initial commit ; SST codes
12 //
13 
14 //fork from the SSD code, move along - see history therein
15 
16 #include <string.h>
17 #include "StSstUtil/StSstPoint.hh"
18 #include "TMath.h"
19 #include "TVector2.h"
20 #include "StMessMgr.h"
21 
22 StSstPoint::StSstPoint(Int_t rNPoint, Int_t rNWafer, Int_t rNumPackage, Int_t rKindPackage)
23 {
24  memset (first, 0, last - first);
25  mNPoint = rNPoint;
26  mNCluster = rNumPackage;
27  mNMatched = rKindPackage;
28  mIdClusterP = -1;
29  mIdClusterN = -1;
30  mFlag = 0;
31  mNId = 0;
32  mNWafer = 0;
33  mMcTrack = 0;
34  mPrevPoint = 0;
35  mNextPoint = 0;
36 }
37 StSstPoint::StSstPoint(Int_t rNId , Int_t rMcHit , Int_t rMcTrack , Float_t *rXg , Float_t rDe, Float_t *rAngle)
38 {
39  memset (first, 0, last - first);
40  mNId = rNId;
41  mMcHit[0] = rMcHit;
42  mMcTrack = rMcTrack;
43  for(Int_t k = 0; k < 3; k++) mXg[k] = rXg[k];
44  for(Int_t i = 0; i < 2; i++) mAngle[i] = rAngle[i];
45  mDe[0] = rDe;
46  mNPoint = 0;
47  mNCluster = 0;
48  mNMatched = 0;
49  mIdClusterP = -1;
50  mIdClusterN = -1;
51  mFlag = 0;
52  mNWafer = 0;
53  mPrevPoint = 0;
54  mNextPoint = 0;
55 }
56 
57 StSstPoint::StSstPoint(const StSstPoint & originalPoint)
58 {
59  memset (first, 0, last - first);
60  mNId = originalPoint.mNId;//jb 10/11 fill(NId) for the simulation
61  mFlag = originalPoint.mFlag;
62  mNPoint = originalPoint.mNPoint;
63  mNCluster = originalPoint.mNCluster;
64  mNMatched = originalPoint.mNMatched;
65  mIdClusterP = originalPoint.mIdClusterP;
66  mIdClusterN = originalPoint.mIdClusterN;
67  mNWafer = originalPoint.mNWafer;
68  mPrevPoint = originalPoint.mPrevPoint;
69  mNextPoint = originalPoint.mNextPoint;
70  mMcTrack = originalPoint.mMcTrack;
71  Int_t i = 0;
72  for (i = 0; i < 5; i++)
73  mMcHit[i] = originalPoint.mMcHit[i];
74 
75  for (i = 0; i < 3; i++)
76  {
77  mXg[i] = originalPoint.mXg[i];
78  mXl[i] = originalPoint.mXl[i];
79  }
80 
81  for (i = 0; i < 2; i++)
82  {
83  mPositionU[i] = originalPoint.mPositionU[i];
84  mDe[i] = originalPoint.mDe[i];
85  }
86 }
87 
88 StSstPoint& StSstPoint::operator=(const StSstPoint originalPoint)
89 {
90  memset (first, 0, last - first);
91  mNId = originalPoint.mNId;//jb 10/11 fill(NId) for the simulation
92  mFlag = originalPoint.mFlag;
93  mNPoint = originalPoint.mNPoint;
94  mNCluster = originalPoint.mNCluster;
95  mNMatched = originalPoint.mNMatched;
96  mIdClusterP = originalPoint.mIdClusterP;
97  mIdClusterN = originalPoint.mIdClusterN;
98  mNWafer = originalPoint.mNWafer;
99 
100  Int_t i = 0;
101  for (i = 0; i < 5; i++)
102  mMcHit[i] = originalPoint.mMcHit[i];
103 
104  for (i = 0; i < 3; i++)
105  {
106  mXg[i] = originalPoint.mXg[i];
107  mXl[i] = originalPoint.mXl[i];
108  }
109 
110  for (i = 0; i < 2; i++)
111  {
112  mPositionU[i] = originalPoint.mPositionU[i];
113  mDe[i] = originalPoint.mDe[i];
114  }
115  return *this;
116 }
117 
118 
119 StSstPoint* StSstPoint::giveCopy()
120 {
121  StSstPoint *ptrClone = new StSstPoint(mNPoint, mNWafer, mNCluster, mNMatched);
122  Int_t i = 0;
123  ptrClone->mNId = mNId;
124  ptrClone->mFlag = mFlag;
125  ptrClone->mIdClusterP = mIdClusterP;
126  ptrClone->mIdClusterN = mIdClusterN;
127  for (i = 0; i < 5; i++)
128  ptrClone->mMcHit[i] = mMcHit[i];
129 
130  for (i = 0; i < 3; i++)
131  { ptrClone->mXg[i] = mXg[i];
132  ptrClone->mXl[i] = mXl[i];
133  }
134  for (i = 0; i < 2; i++)
135  { ptrClone->mPositionU[i] = mPositionU[i];
136  ptrClone->mDe[i] = mDe[i];
137  }
138  return ptrClone;
139 }
140 
141 void StSstPoint::setEnergyLossCorrected(Float_t adcP, Float_t adcN, Float_t gain)
142 {
143  if (gain==0) gain = 1;
144  setDe((adcP*gain + adcN)/2.,0);
145  setDe((adcP*gain - adcN)/2.,1);
146 }