StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcPoint.cxx
1 /***************************************************************************
2  *
3  * $Id: StEmcPoint.cxx,v 2.12 2013/01/15 23:21:05 fisyak Exp $
4  *
5  * Author: Akio Ogawa, Jan 2000
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEmcPoint.cxx,v $
13  * Revision 2.12 2013/01/15 23:21:05 fisyak
14  * improve printouts
15  *
16  * Revision 2.11 2012/10/23 20:18:33 fisyak
17  * Add/modify print outs
18  *
19  * Revision 2.10 2005/07/19 21:31:45 perev
20  * IdTruth
21  *
22  * Revision 2.9 2004/07/20 17:07:49 perev
23  * Pavlinov corrs for TBrowser
24  *
25  * Revision 2.8 2004/07/15 16:36:24 ullrich
26  * Removed all clone() declerations and definitions. Use StObject::clone() only.
27  *
28  * Revision 2.7 2004/02/17 21:43:41 ullrich
29  * Added code to the constructor (was empty).
30  *
31  * Revision 2.6 2003/09/02 17:58:05 perev
32  * gcc 3.2 updates + WarnOff
33  *
34  * Revision 2.5 2001/04/05 04:00:48 ullrich
35  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
36  *
37  * Revision 2.4 2001/03/24 03:34:45 perev
38  * clone() -> clone() const
39  *
40  * Revision 2.3 2000/07/28 19:49:27 akio
41  * Change in Detector Id for Endcap SMD
42  *
43  * Revision 2.2 2000/05/22 19:21:53 akio
44  * Bug fix, add delta into EMcPoint, wider bits for Eta in RawHit
45  *
46  * Revision 2.1 2000/03/23 22:24:07 akio
47  * Initial version of Emc Point, and Inclusion of track pointers
48  *
49  *
50  **************************************************************************/
51 #include <Stiostream.h>
52 #include "StEmcPoint.h"
53 #include "StEmcCluster.h"
54 static const char rcsid[] = "$Id: StEmcPoint.cxx,v 2.12 2013/01/15 23:21:05 fisyak Exp $";
55 
56 ClassImp(StEmcPoint)
57 
59 
60  mEnergy = 0;
61  mChiSquare = 0;
62  for(int i=0;i<4;i++) {
63  mEnergyInDetector[i]=0;
64  mSizeAtDetector[i]=0;
65  }
66  mDelta[0]=0;
67  mDelta[1]=0;
68  myQuality =0;
69 }
70 
71 StEmcPoint::StEmcPoint(const StThreeVectorF& p,
72  const StThreeVectorF& e,
73  const StThreeVectorF& s,
74  unsigned int hp, float q,
75  float energy, float csq,
76  unsigned char c)
77  : StHit(p,e,hp,q,c),mEnergy(energy), mChiSquare(csq), mSize(s)
78 {
79  myQuality =0;
80 }
81 
82 StEmcPoint::~StEmcPoint() {/* noop */}
83 
84 float
85 StEmcPoint::energy() const {return mEnergy;};
86 
87 void
88 StEmcPoint::setEnergy(const float e) {mEnergy = e;};
89 
90 float
91 StEmcPoint::chiSquare() const {return mChiSquare;};
92 
93 void
94 StEmcPoint::setChiSquare(const float c) {mChiSquare = c;};
95 
97 StEmcPoint::size() const {return mSize;};
98 
99 void
100 StEmcPoint::setSize(const StThreeVectorF& s) {mSize = s;};
101 
102 int
103 StEmcPoint::getDetId(const StDetectorId id) const{
104  if(id>=kBarrelEmcTowerId && id<=kBarrelSmdPhiStripId){
105  return id-kBarrelEmcTowerId;
106  }else if(id>=kEndcapEmcTowerId && id<=kEndcapSmdVStripId){
107  return id-kEndcapEmcTowerId;
108  }else{
109  cout<<"***Error at StEmcPoint:::getDetId, Invalid StDetectorId"<<endl;
110  return 0;
111  }
112 }
113 int
114 StEmcPoint::getDetId(Int_t id) const{
115  if(id>=kBarrelEmcTowerId && id<=kBarrelSmdPhiStripId){
116  return id-kBarrelEmcTowerId;
117  }else if(id>=kEndcapEmcTowerId && id<=kEndcapSmdVStripId){
118  return id-kEndcapEmcTowerId;
119  }else{
120  cout<<"***Error at StEmcPoint:::getDetId, Invalid StDetectorId"<<endl;
121  return 0;
122  }
123 }
124 
125 float
126 StEmcPoint::energyInDetector(const StDetectorId id) const{
127  int i = getDetId(id);
128  if(i==-1) return 0.0;
129  return mEnergyInDetector[i];
130 }
131 
132 void
133 StEmcPoint::setEnergyInDetector(const StDetectorId id, const float e){
134  int i = getDetId(id);
135  if(i>=0) mEnergyInDetector[i]=e;
136 }
137 
138 float
139 StEmcPoint::sizeAtDetector(const StDetectorId id) const{
140  int i = getDetId(id);
141  if(i==-1) return 0.0;
142  return mSizeAtDetector[i];
143 }
144 
145 void
146 StEmcPoint::setSizeAtDetector(const StDetectorId id, const float s){
147  int i = getDetId(id);
148  if(i>=0) mSizeAtDetector[i]=s;
149 }
150 
151 float StEmcPoint::deltaEta() const{return mDelta[0];}
152 float StEmcPoint::deltaPhi() const{return mDelta[1];}
153 float StEmcPoint::deltaU() const{return mDelta[0];}
154 float StEmcPoint::deltaV() const{return mDelta[1];}
155 void StEmcPoint::setDeltaEta(const float d){mDelta[0]=d;}
156 void StEmcPoint::setDeltaPhi(const float d){mDelta[1]=d;}
157 void StEmcPoint::setDeltaU(const float d){mDelta[0]=d;}
158 void StEmcPoint::setDeltaV(const float d){mDelta[1]=d;}
159 
160 StPtrVecEmcCluster&
161 StEmcPoint::cluster(const StDetectorId id){
162  int i = getDetId(id);
163  return mCluster[i];
164 }
165 
166 const StPtrVecEmcCluster&
167 StEmcPoint::cluster(const StDetectorId id) const{
168  int i = getDetId(id);
169  return mCluster[i];
170 }
171 
172 StPtrVecEmcCluster&
173 StEmcPoint::cluster(Int_t id){
174  int i = getDetId(id);
175  return mCluster[i];
176 }
177 
178 const StPtrVecEmcCluster&
179 StEmcPoint::cluster(Int_t id) const{
180  int i = getDetId(id);
181  return mCluster[i];
182 }
183 
184 void
185 StEmcPoint::addCluster(const StDetectorId id, const StEmcCluster* c){
186  if(!c) return; // 29-oct-2003
187  int i = getDetId(id);
188  if(i>=0) mCluster[i].push_back(c);
189 }
190 
191 StPtrVecEmcPoint&
192 StEmcPoint::neighbor(){
193  return mNeighbors;
194 }
195 
196 const StPtrVecEmcPoint&
197 StEmcPoint::neighbor()const {
198  return mNeighbors;
199 }
200 
201 void
202 StEmcPoint::addNeighbor(const StEmcPoint* p){
203  mNeighbors.push_back(p);
204 }
205 
206 int
207 StEmcPoint::nTracks() const {return mTracks.size();}
208 
209 StPtrVecTrack&
210 StEmcPoint::track() {return mTracks;}
211 
212 const StPtrVecTrack&
213 StEmcPoint::track() const {return mTracks;}
214 
215 void
216 StEmcPoint::addTrack(StTrack* track)
217 {
218  if(track) mTracks.push_back(track); // 29-oct-03 - eliminate zero pointer
219 }
220 
221 // 11-nov-03 by PAI
222 void StEmcPoint::print()
223 { // for debugging
224  cout << "Point energy " << mEnergy << endl;
225  cout << "size " << mSize << endl;
226  cout << "#tracks " << mTracks.size() << endl;
227  for(int det=0; det<4; det++){
228  cout << " det " << det << " #clusters " << mCluster[det].size()<<endl;
229  }
230 }
231 
232 ostream&
233 operator<<(ostream &os, const StEmcPoint& pnt)
234 {
235  os << "Point Energy " << pnt.energy()
236  << " size " << pnt.size() << " #tracks " << pnt.nTracks() << endl;
237  Int_t Ids[4] = {kBarrelEmcTowerId, kBarrelEmcPreShowerId, kEndcapEmcTowerId, kEndcapEmcPreShowerId};
238  for (Int_t k = 0; k < 4; k++) {
239  const StPtrVecEmcCluster &cl = pnt.cluster(Ids[k]);
240  Int_t ncl = (Int_t) cl.size();
241  for (Int_t i = 0; i < ncl; i++) {
242  cout << *cl[i] << endl;
243  }
244  }
245  os << *((StHit *)&pnt);
246  return os;
247 }
248 void StEmcPoint::Print(Option_t *option) const {cout << *this << endl;}
249 
Definition: StHit.h:125