StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtAnalysedHybridClusters.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtAnalysedHybridClusters.cc,v 1.16 2009/11/23 16:44:55 fisyak Exp $
4  *
5  * Author: Selemon Bekele
6  ***************************************************************************
7  *
8  * Description: SVT Analysis Object BASE class
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtAnalysedHybridClusters.cc,v $
13  * Revision 1.16 2009/11/23 16:44:55 fisyak
14  * Remove references to tables
15  *
16  * Revision 1.15 2005/11/09 22:08:36 fisyak
17  * Use for IdTruth id_mctrack (instead of id_mchit)
18  *
19  * Revision 1.14 2005/07/23 03:37:33 perev
20  * IdTruth + Cleanup
21  *
22  * Revision 1.13 2004/11/24 02:41:35 jeromel
23  * Minor protection issue on delete
24  *
25  * Revision 1.12 2004/01/27 02:30:29 perev
26  * LeakOff
27  *
28  * Revision 1.11 2003/09/02 17:59:06 perev
29  * gcc 3.2 updates + WarnOff
30  *
31  * Revision 1.10 2003/07/17 22:49:31 caines
32  * Change errors to 300 microns
33  *
34  * Revision 1.9 2003/04/05 22:36:10 caines
35  * Fix filling on local coords so its time and anode not cm
36  *
37  * Revision 1.8 2002/05/08 23:07:54 caines
38  * T0 jitter stuff
39  *
40  * Revision 1.7 2002/05/08 16:03:52 caines
41  * Fix again memory leak - accidentally pput back in data has to be a const() not data()
42  *
43  * Revision 1.6 2002/01/05 21:45:56 caines
44  * Include t0 correction in hit
45  *
46  * Revision 1.5 2001/11/21 19:02:43 caines
47  * Set mNumOfHits properly as for real data I was setting arrays to size 0 then filling
48  *
49  * Revision 1.4 2001/11/12 22:58:06 caines
50  * Add functions for filling hits from srs data
51  *
52  * Revision 1.3 2001/08/07 20:52:15 caines
53  * Implement better packing of svt hardware and charge values
54  *
55  * Revision 1.2 2000/08/24 04:27:56 caines
56  * Fixed casting warnings so compiles without errors on linux
57  *
58  * Revision 1.1 2000/08/21 13:04:29 caines
59  * First version of hit fitting routines
60  *
61  * Revision
62  *
63  **************************************************************************/
64 #include <Stiostream.h>
65 #include <math.h>
66 #include <assert.h>
67 
68 #include "StSvtAnalysis.hh"
69 #include "StSvtAnalysedHybridClusters.hh"
70 #include "StDbUtilities/StSvtWaferCoordinate.hh"
71 #include "tables/St_scs_spt_Table.h"
72 
73 StSvtAnalysedHybridClusters::StSvtAnalysedHybridClusters(int barrel, int ladder, int wafer, int hybrid):StSvtHybridObject(barrel,ladder,wafer,hybrid)
74 {
75  mNumOfHits = 0;
76  mHardWarePosition = 0;
77  mSvtHitData = 0;
78  mSvtHit = 0;
79  mPos = 0;
80 }
81 
82 StSvtAnalysedHybridClusters::~StSvtAnalysedHybridClusters()
83 {
84  if (mSvtHitData) delete [] mSvtHitData;
85  if (mSvtHit) delete [] mSvtHit;
86  if (mPos) delete [] mPos;
87 }
88 
89 void StSvtAnalysedHybridClusters::setMembers(int numOfClu, int index)
90 {
91 
92  int HitSize;
93 
94  // If numOfClu small default to making arrays of size 10
95  // But remember how many you really have
96  mNumOfHits = numOfClu;
97 
98  HitSize = ( numOfClu < 10) ? 10 : mNumOfHits;
99  mHardWarePosition = index;
100  assert( !mSvtHitData && !mSvtHit && !mPos);
101 
102  //cout << "DEBUG:: mSvtHitData" << (int *) mSvtHitData << endl;
103  //cout << "DEBUG:: mSvtHit " << (int *) mSvtHit << endl;
104  //cout << "DEBUG:: mPos " << (int *) mPos << endl;
105 
106  mSvtHitData = new StSvtHitData[HitSize];
107  mSvtHit = new StSvtHit[HitSize];
108  mPos = new StThreeVector<double>[HitSize];
109 
110 }
111 
112 void StSvtAnalysedHybridClusters::ReSize(){
113 
114  int hitSize = mNumOfHits+10;
115  StSvtHitData *tmp = new StSvtHitData[hitSize];
116  for (int i=0; i<(mNumOfHits); i++) tmp[i] = mSvtHitData[i];
117  delete [] mSvtHitData;
118  mSvtHitData = tmp;
119 
120  StSvtHit *tmp2 = new StSvtHit[hitSize];
121  for (int i=0; i<(mNumOfHits); i++) tmp2[i] = mSvtHit[i];
122  delete [] mSvtHit;
123  mSvtHit = tmp2;
124 
125  StThreeVector<double> *tmp3 = new StThreeVector<double>[hitSize];
126  for (int i=0; i<(mNumOfHits-1); i++) tmp3[i] = mPos[i];
127  delete [] mPos;
128  mPos = tmp3;
129 }
130 
131 int StSvtAnalysedHybridClusters::setSvtHit(StSvtAnalysis* mSvtAnalysis,
132  float T0Jitter)
133 {
134 
135  StThreeVectorF mGlobalPos;
136 
137  for(int hit = 0; hit < mNumOfHits; hit++)
138  {
139  mSvtHitData[hit].id = mSvtAnalysis->GetCluID(hit);
140  mSvtHitData[hit].id_cluster = mSvtAnalysis->GetCluDeconvID(hit);
141  mSvtHitData[hit].id_globtrk = 0;
142  mSvtHitData[hit].id_track = 0;
143  mSvtHitData[hit].id_match = 0;
144 
145 
146  mSvtHit[hit].setFlag((unsigned char)(mSvtAnalysis->GetCluFlag(hit)));
147  mSvtHit[hit].setHardwarePosition((long)mHardWarePosition<<4);
148  mSvtHit[hit].setCharge(mSvtAnalysis->GetCluCharge(hit));
149  mSvtHit[hit].setIdTruth(mSvtAnalysis->GetTruth(hit));
150 
151  // Take jitter out of t0 caused by SVT clock being 8 3rds of RHIC clock
152  mPos[hit].setX((float)mSvtAnalysis->GetMeanClusterTimeBin(hit)+T0Jitter);
153  mPos[hit].setY((float)mSvtAnalysis->GetMeanClusterAnode(hit));
154  mPos[hit].setZ(0.0);
155 
156  mGlobalPos.setX(::sqrt(mSvtAnalysis->GetCluXCov(hit)));
157  mGlobalPos.setY(::sqrt(mSvtAnalysis->GetCluYCov(hit)));
158  mGlobalPos.setZ(0.0042);
159 
160  mGlobalPos.setX(-9999.0);
161  mGlobalPos.setY(-9999.0);
162  mGlobalPos.setZ(-9999.0);
163  mSvtHit[hit].setPosition(mGlobalPos); //invokes StMeasuredPoint::setPosition(StThreeVectorF&)
164 
165 
166  mSvtHitData[hit].peakAdc = mSvtAnalysis->GetCluPeakAdc(hit);
167  mSvtHitData[hit].numOfAnodesInClu = mSvtAnalysis->GetCluNumAnodes(hit);
168  mSvtHitData[hit].numOfPixelsInClu = mSvtAnalysis->GetCluNumPixels(hit);
169  mSvtHitData[hit].mom2[0] = mSvtAnalysis->GetSecondMomClusterTimeBin(hit);
170  mSvtHitData[hit].mom2[1] = mSvtAnalysis->GetSecondMomClusterAnode(hit);
171 
172  }
173 
174 
175 return 0;
176 }
177 
178 int StSvtAnalysedHybridClusters::setSvtHit(scs_spt_st* mSrsHit,
179  StSvtWaferCoordinate *WaferCoord)
180 {
181 
182  StThreeVectorF mGlobalPos;
183 
184  mSvtHitData[mNumOfHits].id = mSrsHit->id;
185  mSvtHitData[mNumOfHits].id_cluster = 0;
186  mSvtHitData[mNumOfHits].id_globtrk = 0;
187  mSvtHitData[mNumOfHits].id_track = 0;
188  mSvtHitData[mNumOfHits].id_match = 0;
189 
190 
191  mSvtHit[mNumOfHits].setFlag((unsigned char)(mSrsHit->flag));
192  mSvtHit[mNumOfHits].setHardwarePosition(mHardWarePosition<<4);
193  mSvtHit[mNumOfHits].setCharge(mSrsHit->de[0]*300000); // put GEANT dE roughly into ADC counts
194  mSvtHit[mNumOfHits].setIdTruth(mSrsHit->id_mctrack,100); // put truth
195 
196  mPos[mNumOfHits].setX(WaferCoord->timebucket());
197  mPos[mNumOfHits].setY(WaferCoord->anode());
198  mPos[mNumOfHits].setZ(0.0);
199 
200  mGlobalPos.setX(mSrsHit->x[0]);
201  mGlobalPos.setY(mSrsHit->x[1]);
202  mGlobalPos.setZ(mSrsHit->x[2]);
203  mSvtHit[mNumOfHits].setPosition(mGlobalPos); //invokes StMeasuredPoint::setPosition(StThreeVectorF&)
204 
205 
206  mSvtHitData[mNumOfHits].peakAdc =(int) (mSvtHit[mNumOfHits].charge()/4.); //Put in a PEAK ADC value of quarter of charge
207  mSvtHitData[mNumOfHits].numOfAnodesInClu = 0;
208  mSvtHitData[mNumOfHits].numOfPixelsInClu = 0;
209  mSvtHitData[mNumOfHits].mom2[0] = mSrsHit->mom2[0];
210  mSvtHitData[mNumOfHits].mom2[1] = mSrsHit->mom2[1];
211 
212  mNumOfHits++;
213  return 0;
214 }