StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSsdPoint.cc
1 // $Id: StSsdPoint.cc,v 1.3 2007/07/31 14:51:51 bouchet Exp $
2 //
3 // $Log: StSsdPoint.cc,v $
4 // Revision 1.3 2007/07/31 14:51:51 bouchet
5 // Gain calibration using the mapping method instead of the rotating vector
6 //
7 // Revision 1.2 2007/03/27 23:11:48 bouchet
8 // Add a method to use the gain calibration for the Charge Matching between pulse of p and n sides
9 //
10 // Revision 1.1 2006/10/16 16:43:29 bouchet
11 // StSsdUtil regroups now methods for the classes StSsdStrip, StSsdCluster and StSsdPoint
12 //
13 // Revision 1.3 2005/03/18 16:29:08 lmartin
14 // new members mIdClusterP and mIdClusterN and associated methods
15 //
16 // Revision 1.2 2005/03/18 14:19:44 lmartin
17 // missing CVS header added
18 //
19 
20 #include <string.h>
21 #include "StSsdUtil/StSsdPoint.hh"
22 #include "TMath.h"
23 #include "TVector2.h"
24 #include "StMessMgr.h"
25 
26 StSsdPoint::StSsdPoint(Int_t rNPoint, Int_t rNWafer, Int_t rNumPackage, Int_t rKindPackage)
27 {
28  memset (first, 0, last - first);
29  mNPoint = rNPoint;
30  mNCluster = rNumPackage;
31  mNMatched = rKindPackage;
32  mIdClusterP = -1;
33  mIdClusterN = -1;
34 }
35 StSsdPoint::StSsdPoint(Int_t rNId , Int_t rMcHit , Int_t rMcTrack , Float_t *rXg , Float_t rDe, Float_t *rAngle)
36 {
37  memset (first, 0, last - first);
38  mNId = rNId;
39  mMcHit[0] = rMcHit;
40  mMcTrack = rMcTrack;
41  for(Int_t k = 0; k < 3; k++) mXg[k] = rXg[k];
42  for(Int_t i = 0; i < 2; i++) mAngle[i] = rAngle[i];
43  mDe[0] = rDe;
44 }
45 
46 StSsdPoint::StSsdPoint(const StSsdPoint & originalPoint)
47 {
48  memset (first, 0, last - first);
49  mNId = originalPoint.mNId;//jb 10/11 fill(NId) for the simulation
50  mFlag = originalPoint.mFlag;
51  mNPoint = originalPoint.mNPoint;
52  mNCluster = originalPoint.mNCluster;
53  mNMatched = originalPoint.mNMatched;
54  mIdClusterP = originalPoint.mIdClusterP;
55  mIdClusterN = originalPoint.mIdClusterN;
56  mNWafer = originalPoint.mNWafer;
57 
58  Int_t i = 0;
59  for (i = 0; i < 5; i++)
60  mMcHit[i] = originalPoint.mMcHit[i];
61 
62  for (i = 0; i < 3; i++)
63  {
64  mXg[i] = originalPoint.mXg[i];
65  mXl[i] = originalPoint.mXl[i];
66  }
67 
68  for (i = 0; i < 2; i++)
69  {
70  mPositionU[i] = originalPoint.mPositionU[i];
71  mDe[i] = originalPoint.mDe[i];
72  }
73 }
74 
75 StSsdPoint& StSsdPoint::operator=(const StSsdPoint originalPoint)
76 {
77  memset (first, 0, last - first);
78  mNId = originalPoint.mNId;//jb 10/11 fill(NId) for the simulation
79  mFlag = originalPoint.mFlag;
80  mNPoint = originalPoint.mNPoint;
81  mNCluster = originalPoint.mNCluster;
82  mNMatched = originalPoint.mNMatched;
83  mIdClusterP = originalPoint.mIdClusterP;
84  mIdClusterN = originalPoint.mIdClusterN;
85  mNWafer = originalPoint.mNWafer;
86 
87  Int_t i = 0;
88  for (i = 0; i < 5; i++)
89  mMcHit[i] = originalPoint.mMcHit[i];
90 
91  for (i = 0; i < 3; i++)
92  {
93  mXg[i] = originalPoint.mXg[i];
94  mXl[i] = originalPoint.mXl[i];
95  }
96 
97  for (i = 0; i < 2; i++)
98  {
99  mPositionU[i] = originalPoint.mPositionU[i];
100  mDe[i] = originalPoint.mDe[i];
101  }
102  return *this;
103 }
104 
105 
106 StSsdPoint* StSsdPoint::giveCopy()
107 {
108  StSsdPoint *ptrClone = new StSsdPoint(mNPoint, mNWafer, mNCluster, mNMatched);
109  Int_t i = 0;
110  ptrClone->mNId = mNId;
111  ptrClone->mFlag = mFlag;
112  ptrClone->mIdClusterP = mIdClusterP;
113  ptrClone->mIdClusterN = mIdClusterN;
114  for (i = 0; i < 5; i++)
115  ptrClone->mMcHit[i] = mMcHit[i];
116 
117  for (i = 0; i < 3; i++)
118  { ptrClone->mXg[i] = mXg[i];
119  ptrClone->mXl[i] = mXl[i];
120  }
121  for (i = 0; i < 2; i++)
122  { ptrClone->mPositionU[i] = mPositionU[i];
123  ptrClone->mDe[i] = mDe[i];
124  }
125  return ptrClone;
126 }
127 
128 void StSsdPoint::setEnergyLossCorrected(Float_t adcP, Float_t adcN, Float_t gain)
129 {
130  // the gain is the ratio adcN/adcP
131  // in the frame {pulseP,pulseN}, we have the relation adcN = ATan(gain)*adcP (+offset)
132  // the correction consists in a rotation of the hit of coordinates {pulseP,pulseN} by an angle = ratio
133  // opposite sign is the gain > 1
134  //Double_t angle = 0;
135  if (gain==0) gain = 1;
136  //printf("for this wafer, the gain is %f\n",gain);
137  // gain=0 means we don't have any value forthis wafer then we don't do any rotation
138  // newAdcp=adcP and newAdcN=adcN since the sin gives 0
139  /*
140  angle = TMath::ATan(gain);
141  angle = TMath::Abs(45 - (angle*360)/(TMath::Pi()*2));
142  //angle = TMath::Abs(TMath::Pi()/4 - angle) ;//radians
143  angle = TMath::Pi()/4 - angle;
144  TVector2 pulse;
145  TVector2 newpulse;
146  pulse.Set(adcP,adcN);
147  newpulse = pulse.Rotate(angle);
148  printf("old adcP =%f old adcN=%f\n",pulse.X(),pulse.Y());
149  printf("new adcP =%f new adcN=%f\n",newpulse.X(),newpulse.Y());
150  setDe((newpulse.X() + newpulse.Y())/2.,0);
151  setDe((newpulse.X() - newpulse.Y())/2.,1);
152  */
153  setDe((adcP*gain + adcN)/2.,0);
154  setDe((adcP*gain - adcN)/2.,1);
155 
156 
157 }