StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHybridPixelsD.cc
1  /***************************************************************************
2  *
3  * $Id: StSvtHybridPixelsD.cc,v 1.5 2009/11/10 21:00:17 fisyak Exp $
4  *
5  * Author: Petr Chaloupka
6  ***************************************************************************
7  *
8  * Description: SVT Hybrid PixelsD class
9  *
10  ***************************************************************************
11  */
12 
14 // //
15 // It is an array of 240 X 128 doubles. //
16 // It can be used to store any pixel data from one hybrid. //
17 // //
19 
20 #include "Stiostream.h"
21 #include "StSvtHybridPixelsD.hh"
22 #include "TMath.h"
23 
24 ClassImp(StSvtHybridPixelsD)
25 
26 //_____________________________________________________________________________
28  StSvtHybridObject(), TArrayD()
29 {
30  // Default Constructor
31 
32  mNumberOfAnodes = 0;
33  mNumberOfTimeBins = 0;
34 
35  mTotalNumberOfPixels = 0;
36 
37  mPedOffset = 0;
38 }
39 
40 //_____________________________________________________________________________
41 StSvtHybridPixelsD::StSvtHybridPixelsD(int barrel, int ladder, int wafer, int hybrid, int size, double* x) :
42  StSvtHybridObject(barrel, ladder, wafer, hybrid), TArrayD()
43 {
44  // The same as StSvtHybridObject.
45 
46  mNumberOfAnodes = 240;
47  mNumberOfTimeBins = 128;
48 
49  mTotalNumberOfPixels = mNumberOfAnodes*mNumberOfTimeBins;
50 
51  mPedOffset = 0;
52 
53  if (size)
54  if (x)
55  Set(mTotalNumberOfPixels,x);
56  else
57  Set(size);
58  else
59  Set(mTotalNumberOfPixels);
60  mTrackId.Set(GetSize());
61  mTrackId.Reset(0);
62 
63  mTruthTmp=0;
64 }
65 
66 //_____________________________________________________________________________
67 StSvtHybridPixelsD::~StSvtHybridPixelsD()
68 {delete mTruthTmp;}
69 
70 StSvtHybridPixelsD& StSvtHybridPixelsD::operator = (StSvtHybridPixelsD& h)
71 {
72  double x;
73 
74  for (int i=0;i<mTotalNumberOfPixels;i++) {
75  x = h.At(i);
76  AddAt((double)x,i);
77  }
78  return *this;
79 }
80 
81 //_____________________________________________________________________________
82 StSvtHybridPixelsD& StSvtHybridPixelsD::operator + (StSvtHybridPixelsD& h)
83 {
84  double x1, x2;
85 
86  for (int i=0;i<mTotalNumberOfPixels;i++) {
87  x1 = (double)At(i);
88  x2 = (double)h.At(i);
89 
90  if ((x1+x2) < 255)
91  AddAt((double)(x1+x2),i);
92  else
93  AddAt(255,i);
94  }
95  return *this;
96 }
97 
98 //_____________________________________________________________________________
99 double StSvtHybridPixelsD::getPixelContent(int anode, int time)
100 {
101  // Returns the pixel content based on the anode and time bin numbers
102  int index = getPixelIndex(anode, time);
103 
104  return (double)At(index);
105 }
106 
107 //_____________________________________________________________________________
108 void StSvtHybridPixelsD::addToPixel(int anode, int time, double x,int trackId)
109 {
110  int index = getPixelIndex(anode, time);
111  addToPixel(index, x,trackId);
112 }
113 
114 //_____________________________________________________________________________
115 void StSvtHybridPixelsD::addToPixel(int index, double x, int trackId)
116 {
117  double x1, sum;
118 
119  x1 = At(index);
120  sum = x1 + x;
121  AddAt(sum,index);
122 
123  if (TMath::Abs(x)<=0) return;
124  if (!mTruthTmp) mTruthTmp = new StMCPivotTruthMap;
125  mTruthTmp->Add(index,trackId,TMath::Abs(x));
126 }
127 
128 //_____________________________________________________________________________
129 int StSvtHybridPixelsD::getPixelIndex(int anode, int time)
130 {
131  // Returns an internal index for pixel (anode,time).
132  // It should be used to store or retrieve a pixel value from this object.
133 
134  int index;
135 
136  index = mNumberOfTimeBins*(anode-1) + time;
137 
138  return index;
139 }
140 
141 //_____________________________________________________________________________
142 void StSvtHybridPixelsD::reset()
143 {
144  for (int i=0;i<mTotalNumberOfPixels;i++)
145  AddAt(mPedOffset,i);
146 }
147 
148 //_____________________________________________________________________________
149 StMCTruth StSvtHybridPixelsD::getTrackId(int index)
150 {
151  return mTrackId[index];
152 }
153 //_____________________________________________________________________________
154 void StSvtHybridPixelsD::updateTruth()
155 {
156 
157  if (!mTruthTmp) return;
158 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,22,0)
159  Long_t index=-1;
160 #else
161  Long64_t index=-1;
162 #endif
163  while(1) {
164  StMCTruth tru = mTruthTmp->Iter(index);
165  if (index==-1) break;
166  mTrackId.AddAt(tru,(int)index);
167  }
168  delete mTruthTmp; mTruthTmp=0;
169 }
170 
171 
172 
173 
174 
175