StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEmcTTDisplay.cxx
1 // $Id: EEmcTTDisplay.cxx,v 1.13 2009/01/26 14:37:43 fisyak Exp $
4 // doxygen info here
31 #include <Stiostream.h>
32 #include <Stsstream.h>
33 
34 #include "TList.h"
35 #include "TMath.h"
36 #include "TGeoVolume.h"
37 #include "TGeoCone.h"
38 #include "TGeoManager.h"
39 #include "TGeoMedium.h"
40 #include "TGeoMatrix.h"
41 #include "THelix.h"
42 
43 #include "StarClassLibrary/StPhysicalHelixD.hh"
44 #include "StMuDSTMaker/COMMON/StMuTrack.h"
45 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
46 
47 #include "EEmcTower.h"
48 #include "EEmcTTMatch.h"
49 #include "EEmcTTMMaker.h"
50 #include "EEmcTTDisplay.h"
51 
52 
53 static const double cLight = 3e10*centimeter/second;
54 
55 // FIXME sector color assignement
56 static const int kSectorColors[] = {
57  kBlack, // SEC01
58  kBlack, // SEC02
59  kGreen, // SEC03
60  kBlack, // SEC04
61  kBlack, // SEC05
62  kBlue , // SEC06
63  kBlack, // SEC07
64  kBlack, // SEC08
65  kYellow, // SEC09
66  kBlack, // SEC10
67  kBlack, // SEC11
68  kRed , // SEC12
69  kWhite,
70  kWhite,
71 };
72 
73 
75 {
76  mEEmc=NULL;
77 
78  mTrackHits=new TList;
79  mTowerHits=new TList;
80  mBField =0.5; // in Tesla
81  mShowExtrapolatedTracks = false;
82  initGeometry(name);
83 
84 };
85 
87 {
88  if(mEEmc) delete mEEmc;
89  if(mTrackHits) delete mTrackHits;
90  if(mTowerHits) delete mTowerHits;
91 }
92 
93 
94 void
95 EEmcTTDisplay::initGeometry(const char *topName)
96 {
97  const double kDPhi = -15.0/180.0*M_PI; // FIXME hard coded offset
98  char rotName[256];
99  if(mEEmc!=NULL) return; // already initialized;
100 
101  double eta1 = mEtaBin[0];
102  double eta2 = mEtaBin[mNumEta];
103 
104  double rmin1 = mZ1/TMath::SinH(eta1);
105  double rmax1 = mZ1/TMath::SinH(eta2);
106 
107  double rmin2 = mZ2/TMath::SinH(eta1);
108  double rmax2 = mZ2/TMath::SinH(eta2);
109 
110  double dz = TMath::Abs(mZ2-mZ1)/2.0;
111 
112  int numSSec = mNumSec*mNumSSec;
113 
114  TGeoMedium *medVac = new TGeoMedium ("Vacuum",1, new TGeoMaterial("Vacuum") );
115  TGeoCone *econe = new TGeoCone(dz,rmin1,rmax1,rmin2,rmax2);
116  mEEmc = new TGeoVolume(topName,econe,medVac);
117  mEEmc->SetLineColor(kWhite);
118  TGeoConeSeg *geosector = new TGeoConeSeg(dz,rmin1,rmax1,rmin2,rmax2,0.0,360.0/mNumSec);
119  TGeoConeSeg *geosubsec = new TGeoConeSeg(dz,rmin1,rmax1,rmin2,rmax2,0.0,360.0/numSSec);
120  for(unsigned s=0;s<mNumSec;s++) {
121  double phi = getPhiMean(s)+kDPhi;
122  sprintf(rotName,"RotSec%02d",s+1);
123  TGeoRotation *rots = new TGeoRotation(rotName,phi/M_PI*180.0,0.0,0.0);
124  TGeoVolume *sector = new TGeoVolume(volumeName(s),geosector,medVac);
125  sector->SetVisibility(kTRUE);
126  sector->SetLineColor (kSectorColors[s]);
127  mEEmc->AddNode(sector,1,rots);
128  //
129  for(unsigned ss=0;ss<mNumSSec;ss++) {
130  double phi = getPhiMean(0,ss)-getPhiMean(0,mNumSSec-1); // FIXME: assumed counter-clockwise
131  sprintf(rotName,"Rot%02dT%1c",s+1,ss+'A');
132  TGeoRotation *rotss = new TGeoRotation(rotName,phi/M_PI*180.0,0.0,0.0);
133  TGeoVolume *subsector = new TGeoVolume(volumeName(s,ss),geosubsec,medVac);
134  subsector->SetVisibility(kFALSE);
135  sector->AddNode(subsector,1,rotss);
136  //
137  for(unsigned e=0;e<mNumEta;e++) {
138  eta1 = mEtaBin[e];
139  eta2 = mEtaBin[e+1];
140  rmin1 = mZ1/TMath::SinH(eta1);
141  rmax1 = mZ1/TMath::SinH(eta2);
142  rmin2 = mZ2/TMath::SinH(eta1);
143  rmax2 = mZ2/TMath::SinH(eta2);
144 
145  TGeoConeSeg *geotile = new TGeoConeSeg(dz,rmin1,rmax1,rmin2,rmax2,0.0,360.0/numSSec);
146  TGeoVolume *tile = new TGeoVolume(volumeName(s,ss,e),geotile,medVac);
147  tile->SetVisibility(kFALSE);
148  subsector->AddNode(tile,1);
149  }
150  }
151  }
152 }
153 
154 
155 void
156 EEmcTTDisplay::Draw(const Option_t* option)
157 {
158  TIter nextTower(mTowerHits);
159  TIter nextTrack(mTrackHits);
160  TGeoNode *gnode;
161  TGeoVolume *vol;
162  THelix *helix;
163 
164  while( (gnode=(TGeoNode *)nextTower())!=NULL ) {
165  vol=gnode->GetVolume();
166  vol->SetLineColor(kRed);
167  vol->SetVisibility(kTRUE);
168  }
169  while( (helix=(THelix *)nextTrack())!=NULL ) {
170  helix->Draw();
171  }
172 }
173 
174 
175 void
176 EEmcTTDisplay::Clear(const Option_t* option)
177 {
178  TIter nextTower(mTowerHits);
179  TGeoNode *gnode;
180  while( (gnode=(TGeoNode *)nextTower())!=NULL ) {
181  //printf("clearing node %s\n",gnode->GetVolume()->GetName());
182  gnode->GetVolume()->SetLineColor(kBlack);
183  gnode->GetVolume()->SetVisibility(kFALSE);
184  }
185 
186  mTrackHits->Delete();
187  mTowerHits->Clear();
188 }
189 
190 
191 
192 
193 Bool_t
194 EEmcTTDisplay::AddTower(const char *vname)
195 {
196  const int kSecLen=2;
197  const int kSubLen=4;
198  const int kEtaLen=6;
199  TGeoNode *node;
200  TIter sector(mEEmc->GetNodes());
201  while( (node=(TGeoNode *)sector())!=NULL ) {
202  if(strncmp(vname,node->GetVolume()->GetName(),kSecLen)!=0) continue;
203  TIter subsector(node->GetVolume()->GetNodes());
204  while( (node=(TGeoNode *)subsector())!=NULL ) {
205  if(strncmp(vname,node->GetVolume()->GetName(),kSubLen)!=0) continue;
206  TIter tile(node->GetVolume()->GetNodes());
207  while( (node=(TGeoNode *)tile())!=NULL ) {
208  if(strncmp(vname,node->GetVolume()->GetName(),kEtaLen)!=0) continue;
209  //printf("towerHit: node %s found\n",vname);
210  mTowerHits->Add(node);
211  return kTRUE;
212  }
213  }
214  }
215  return kFALSE;
216 }
217 
218 Bool_t
220 {
221  return AddTower(volumeName(tower.Sec(),tower.SubSec(),tower.Eta()));
222 }
223 
224 
225 Bool_t
226 EEmcTTDisplay::AddTrack(Double_t x, Double_t y, Double_t z,
227  Double_t px, Double_t py, Double_t pz,
228  Double_t qB, Double_t zMin, Double_t zMax)
229 {
230  THelix *helix = new THelix(x,y,z,px,py,pz,cLight*qB);
231 
232  if(zMin<=0.0) zMin=z;
233  if(zMax<=0.0) zMax=mZ2;
234 
235  helix->SetRange(zMin,zMax);
236  helix->SetLineColor(102); // the beauty of root :)
237  helix->SetLineWidth(2);
238 
239  if(mShowExtrapolatedTracks) {
240  THelix *helixExt = new THelix(x,y,z,px,py,pz,cLight*qB);
241  helixExt->SetRange(z ,mZ2);
242  helixExt->SetLineColor(20);
243  helixExt->SetLineWidth(1);
244  mTrackHits->Add(helixExt);
245  }
246  mTrackHits->Add(helix);
247  return kTRUE;
248 }
249 
250 Bool_t
252 {
253  StPhysicalHelixD h = track.helix();
254  StThreeVectorD o = h.origin();
255  StThreeVectorD p = h.momentum(mBField*tesla);
256  double q = h.charge(mBField*tesla);
257  double zMin= track.firstPoint().z();
258  double zMax= track.lastPoint().z();
259  return AddTrack(o.x(),o.y(),o.z(),
260  p.x(),p.y(),p.z(),
261  q*mBField*tesla,zMin,zMax);
262 }
263 
264 
265 Bool_t
267 {
268  EEmcTower *tower =tmatch.Tower();
269  StMuTrack *track =NULL;
270  if(!AddTower(*tower)) return kFALSE;
271  TIter nextTrack(tmatch.Tracks());
272  while((track=(StMuTrack *)nextTrack())) AddTrack(*track);
273  return kTRUE;
274 }
275 
276 
277 void
278 EEmcTTDisplay::Out(ostream &out, EEmcTTMatch &tmatch)
279 {
280  EEmcTower *tower =tmatch.Tower();
281  StMuTrack *track =NULL;
282  out << *tower;
283  TIter nextTrack(tmatch.Tracks());
284  while((track=(StMuTrack *)nextTrack()))
285  out << *track;
286 }
287 
288 void
289 EEmcTTDisplay::Out(TString &out, EEmcTTMatch &tmatch)
290 {
291  const int bufLen=1024; // FIXME buffer length
292  static char buff[bufLen];
293 
294 
295  EEmcTower *tower =tmatch.Tower();
296  StMuTrack *track =NULL;
297  TIter nextTrack(tmatch.Tracks());
298  while((track=(StMuTrack *)nextTrack())) {
299  sprintf(buff,"ADC(%s)=%4.1f pT=%.2f GeV/c\n",volumeName(*tower),tower->ADC(),track->pt());
300  out.Append(buff);
301  }
302 }
303 
304 
305 
306 
307 
308 // a lousy ..... lousy
309 // sec [0,mNumSec) sub [0,mNumSSec) eta [0,mNumEta)
310 char *
311 EEmcTTDisplay::volumeName (int sec, int sub, int eta)
312 {
313  const int vnameLen=1024;
314  static char vname[vnameLen];
315  int kCase=0x00;
316 
317  memset(vname,0x00,vnameLen);
318  if( 0<=sec && sec<int(mNumSec ) ) kCase |=0x4; else kCase &=0x3;
319  if( 0<=sub && sub<int(mNumSSec) ) kCase |=0x2; else kCase &=0x5;
320  if( 0<=eta && eta<int(mNumEta ) ) kCase |=0x1; else kCase &=0x6;
321 
322  switch(kCase) {
323  case 0x07: sprintf(vname,"%02dT%1c%02d",sec+1,sub+'A',eta+1); break;
324  case 0x06: sprintf(vname,"%02dT%1c" ,sec+1,sub+'A'); break;
325  case 0x04: sprintf(vname,"%02d" ,sec+1) ; break;
326  default: break;
327  }
328  return vname;
329 }
330 
331 char *
332 EEmcTTDisplay::volumeName(const EEmcTower& tower)
333 {
334  return volumeName(tower.Sec(),tower.SubSec(),tower.Eta());
335 }
336 
337 
338 // $Log: EEmcTTDisplay.cxx,v $
339 // Revision 1.13 2009/01/26 14:37:43 fisyak
340 // Add missing (in ROOT 5.22) includes
341 //
342 // Revision 1.12 2007/07/12 19:27:22 fisyak
343 // Add includes for TMath for ROOT 5.16
344 //
345 // Revision 1.11 2005/02/05 00:53:01 perev
346 // Bacward compatibility to redhead7
347 //
348 // Revision 1.10 2004/05/06 16:02:48 zolnie
349 // more docs
350 //
351 // Revision 1.9 2004/05/05 21:37:36 zolnie
352 // ver 2.0 released
353 //
354 // Revision 1.8 2004/05/04 18:28:55 zolnie
355 // version after split
356 //
357 // Revision 1.7 2004/04/13 14:53:38 zolnie
358 // *** empty log message ***
359 //
360 // Revision 1.6 2004/01/27 20:38:41 zolnie
361 // more docs
362 //
363 // Revision 1.5 2004/01/27 16:26:14 zolnie
364 // polished doxygen documentation
365 //
366 // Revision 1.4 2004/01/26 22:54:14 zolnie
367 // after name cleanup
368 //
369 // Revision 1.3 2004/01/26 21:51:53 zolnie
370 // shorter names
371 //
372 // Revision 1.2 2004/01/26 21:08:31 zolnie
373 // working track/tower display (before big farewell cleanup)
374 //
375 // Revision 1.1 2004/01/19 22:07:49 zolnie
376 // toward track/tower display
377 //
378 //
379 
380 
381 
382 
383 
384 
385 
float ADC() const
gets adc value associated with the tower (pedestal adjusted)
Definition: EEmcTower.h:47
Bool_t AddMatch(EEmcTTMatch &tmatch)
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
void Out(ostream &out, EEmcTTMatch &tmatch)
TList * Tracks()
returns a list of matched tracks
Definition: EEmcTTMatch.h:39
Float_t getPhiMean(UInt_t sec) const
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
Definition: StMuTrack.cxx:407
Bool_t AddTower(const char *tile)
EEmcTTDisplay(const char *name="eemc")
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
Definition: StMuTrack.h:261
EEmcTower * Tower()
returns a tower data
Definition: EEmcTTMatch.h:37
int SubSec() const
gets tower subsector index, computer offset [0,....)
Definition: EEmcTower.h:62
void Draw(const Option_t *option="")
void Clear(const Option_t *option="")
const StThreeVector< double > & origin() const
-sign(q*B);
Definition: StHelix.hh:224
int Sec() const
gets tower sector index, computer offset [0,....)
Definition: EEmcTower.h:57
EEMC simple geometry.
~EEmcTTDisplay()
the destructor
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
Definition: StMuTrack.h:262
EEmcTTMatch class contains results of TPC track to EEMC tower matching.
Definition: EEmcTTMatch.h:22
Bool_t AddTrack(Double_t x, Double_t y, Double_t z, Double_t px, Double_t py, Double_t pz, Double_t qB, Double_t zMin=0.0, Double_t zMax=0.0)
int Eta() const
gets tower eta index, computer offset [0,....)
Definition: EEmcTower.h:67
EEmcTower holds information about an EEMC tower &#39;hit&#39;.
Definition: EEmcTower.h:17