StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StuDraw3DMuEvent.cxx
1 // $Id: StuDraw3DMuEvent.cxx,v 1.17 2010/04/02 22:34:09 fine Exp $
2 // *-- Author : Valery Fine(fine@bnl.gov) 27/04/2008
3 #include "StuDraw3DMuEvent.h"
4 #include "Gtypes.h"
5 #include "StHelixHelper.h"
6 #include "StMuDSTMaker/COMMON/StMuTrack.h"
7 #include "StThreeVector.hh"
8 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
9 #include "StEmcUtil/geometry/StEmcGeom.h"
10 
11 
13 
39 //___________________________________________________
40 StuDraw3DMuEvent::StuDraw3DMuEvent( const char *detectorName,TVirtualPad *pad):
41 StDraw3D(detectorName,pad),fEndcapGeom(0)
42 {
43  // The detectorName is a comma separated list of the OpenInventor files with no extension
44  // For all names on the list one should provide the iv file with the "iv extension:
45  // <name>.iv
46  if (!gMuEventDisplay) gMuEventDisplay = this;
47 }
48 
50 
53 //___________________________________________________
55 {
56  if (gMuEventDisplay == this) gMuEventDisplay = 0;
57  delete fEndcapGeom; fEndcapGeom=0;
58 }
59 
61 
66 //___________________________________________________
67 void StuDraw3DMuEvent::Tracks(StTrackType type)
68 {
69  Int_t n_prim=0;
70  Int_t n_glob=0;
71  TObjArray *globTracks = 0;
72  TObjArray *primTracks = 0;
73  if (type == global && ( globTracks= StMuDst::globalTracks() ) ){
74  n_glob=StMuDst::GetNGlobalTrack();
75  } else if ( (primTracks = StMuDst::primaryTracks()) ) {
76  n_prim=StMuDst::GetNPrimaryTrack();
77  }
78 
79  Int_t i_track=0;
80  while (i_track < n_prim) {
81  StMuTrack &track = *(StMuTrack *)primTracks->UncheckedAt(i_track++);
82  double pt =track.pt();
83  Style_t sty = Style(kPrimaryTrack).Sty();
84  Size_t siz = Style(kPrimaryTrack).Siz();
85  Track(track,StDraw3DStyle::Pt2Color(pt),sty,siz);
86  cout << ".";
87  }
88  i_track=0;
89  while (i_track < n_glob) {
90  StMuTrack &track = *(StMuTrack *)globTracks->UncheckedAt(i_track++);
91  double pt =track.pt();
92  Style_t sty = Style(kGlobalTrack).Sty();
93  Size_t siz = Style(kGlobalTrack).Siz();
94  Track(track,StDraw3DStyle::Pt2Color(pt),sty,siz);
95  cout << "+";
96  }
97  cout << endl << n_prim << " primary and " << n_glob << " global tracks have been rendered" << endl;
98 
99 }
100 
101 
103 
110 //___________________________________________________
111 TObject *StuDraw3DMuEvent::Track(const StMuTrack &track, Color_t col,Style_t sty,Size_t siz)
112 {
113 
114  StHelixHelper trPnt(track.helix(),track.outerHelix(),track.length());
115  Int_t size;
116  Float_t *xyz = trPnt.GetPoints(size);
117  TObject *l = Line(size,xyz,col,sty,siz);
118  SetModel((TObject*)&track);
119  return l;
120 }
121 
123 
125 //___________________________________________________
126 TObject *StuDraw3DMuEvent::Track(const StMuTrack &track, EDraw3DStyle sty)
127 {
128  TObject *view = 0;
129  const StDraw3DStyle &style = Style(sty);
130  const StMuTrack *thisTrack = 0;
131  if (sty == kPrimaryTrack)
132  thisTrack = track.primaryTrack();
133  else
134  thisTrack = track.globalTrack();
135  if (thisTrack)
136  view = Track(*thisTrack, style.Col(),style.Sty(),style.Siz() );
137  return view;
138 
139 }
140 
142 
151 //___________________________________________________
152 TObject *StuDraw3DMuEvent::TrackInOut(const StMuTrack &track, Bool_t in
153  , Color_t col, Style_t sty, Size_t siz)
154 {
155  // to be completed yet
156  const StThreeVectorF &pnt = in ? track.firstPoint() : track.lastPoint();
157 
158  return Point(pnt.x(),pnt.y(),pnt.z(), col,sty,siz);
159 }
160 
162 
169 //___________________________________________________
170 TObject *StuDraw3DMuEvent::TrackInOut(const StMuTrack &track, EDraw3DStyle sty,Bool_t in)
171 {
172  const StDraw3DStyle &style = Style(sty);
173  return TrackInOut(track, in, style.Col(),style.Sty(),style.Siz() );
174 }
175 
176 //___________________________________________________
177 EEmcGeomSimple *StuDraw3DMuEvent::EndcapGeom()
178 {
179  // endcap tower geometry:
180  // see http://drupal.star.bnl.gov/STAR/subsys/eemc/endcap-calorimeter/db-usage
181  if (!fEndcapGeom) fEndcapGeom = new EEmcGeomSimple();
182  return fEndcapGeom;
183 }
184 //___________________________________________________
186 
193 //___________________________________________________
194 void StuDraw3DMuEvent::Endcaps(Style_t sty)
195 {
197  if (emc) Endcaps(*emc,sty);
198 }
199 
200 
202 
233 //___________________________________________________
234 void StuDraw3DMuEvent::Endcaps(const StMuEmcCollection &emc,Style_t sty)
235 {
236  Color_t colorResponce = 0;
237  int nTowers = emc.getNEndcapTowerADC();
238  for (int i=0; i< nTowers; i++) {
239  int adc, isec, isub, ieta;
240  emc.getEndcapTowerADC(i,adc,isec,isub,ieta);
241  isec--; ieta--; isub--;
242  if (adc<=0) continue; // print only non-zero values
243  // access geometry info
244  float etaCenter =EndcapGeom()->getEtaMean(ieta);
245  if (etaCenter <= 0) continue;
246  float phiCenter =EndcapGeom()->getPhiMean(isec,isub);
247  if (phiCenter <= 0) continue;
248  static const float dPhi = 2*EndcapGeom()->getPhiHalfWidth(isec,isub);
249  static const float deta = 2*EndcapGeom()->getEtaHalfWidth(ieta);
250  static const float radius = 270.; // no idea where I should pick it from.
251  float energy = adc*60./4096-0.15;
252  if ( energy > 0.15 ) {
253 
254  // If edep less then MIP (~300 MeV), 60GeV <-> 4096 ADC counts
255  if ( energy < 0.3) { colorResponce = kBlue;
256  // If edep large then MIP but less then 1 GeV
257  } else if ( energy < 1.0 ) { colorResponce = kGreen;
258  // If between 1 GeV and lowest HT threshold (4 GeV for Run7)
259  } else if ( energy < 4.0 ) { colorResponce = kYellow;
260  // If above lowest HT thershold
261  } else colorResponce = kRed;
262 
263  static const double maxSize = 400.; // (cm)
264  static const double scale = 15; // 120.; // (cm/Gev)
265  double size =(energy > 0.3 ? scale : scale/30.)*energy;
266  if (size > maxSize) size = maxSize ;
267  Tower( radius
268  , StarRoot::StEta(etaCenter,deta)
269  , phiCenter, dPhi
270  , colorResponce
271  , sty
272  , size);
273  SetComment(Form("Endcap eta=%f, phi=%f, energy=%f",etaCenter,phiCenter,energy));
274  }
275  }
276 }
277 //____________________________________________________________________________________
279 
287 //____________________________________________________________________________________
288 TObject *StuDraw3DMuEvent::EmcHit(Int_t emcHitsSoftId, Color_t col,Style_t sty,Size_t siz, const char *detId)
289 {
290  TObject *model = 0;
291  StEmcGeom *emcGeom =StEmcGeom::getEmcGeom(detId);
292  if (emcGeom) {
293  Int_t softId=emcHitsSoftId;
294  Float_t eta;
295  Float_t phi;
296  emcGeom->getEtaPhi(softId,eta,phi);
297  Float_t etaStep = 1.0/emcGeom->NEta();
298  Float_t phiStep = TMath::Pi()/60;
299  static int entries = 0;
300  //if (entries) return 0;
301  // printf(" m=%d, e=%d, s=%d; eta=%e deta=%e phi=%e dphi=%e id %d\n",m, e, s,eta,etaStep ,phi, phiStep, softId);
302  entries++;
303  model = Tower(emcGeom->Radius(), StarRoot::StEta(eta,etaStep)
304  , phi, phiStep
305  , col,sty+(strcmp(detId,"bemc")?0:kBarrelStyle),siz);
306  } else {
307  LOG_ERROR << __FILE__ << ": there is no geometry information for \"" << detId << "\"" << endm;
308  }
309  return model;
310 }
311 
312 //____________________________________________________________________________________
313 TObject *StuDraw3DMuEvent::EmcHit(Int_t emcHitsSoftId, float energy, const char *detIdt)
314 {
315  return EmcHit<StEmcTowerColor>(emcHitsSoftId, energy, detIdt);
316 }
317 
318 
322 //___________________________________________________
323 StuDraw3DMuEvent *StuDraw3DMuEvent::Display(){ return gMuEventDisplay;}
324 
325 //___________________________________________________
326 StEmcTowerColor::StEmcTowerColor(float energy)
327 {
328  Color_t colorResponce=0;
329  Size_t size=0;
330  if (energy > 0 && energy < 30) {
331  // If edep less then MIP (~300 MeV), 60GeV <-> 4096 ADC counts
332  if ( energy < 0.3) {
333  colorResponce = kBlue;
334  // style = 4001; //wireframe
335  // If edep large then MIP but less then 1 GeV
336  } else if ( energy < 1.0 ) colorResponce = kGreen;
337  // If between 1 GeV and lowest HT threshold (4 GeV for Run7)
338  else if ( energy < 4.0 ) colorResponce = kYellow;
339  // If above lowest HT thershold
340  else colorResponce = kRed;
341 
342  static const double maxSize = 400.; // (cm)
343  static const double scale = 200.; // (cm/Gev)
344  size =(energy > 0.3 ? scale : scale/30.)*energy;
345  if (size > maxSize) size = maxSize ;
346  fStyle.SetCol(colorResponce);
347  fStyle.SetSiz(size);
348  }
349 }
350 
351 StuDraw3DMuEvent *StuDraw3DMuEvent::gMuEventDisplay = new StuDraw3DMuEvent();
352 
353 ClassImp(StuDraw3DMuEvent)
354 
355 
356 
static TObjArray * globalTracks()
returns pointer to the global tracks list
Definition: StMuDst.h:303
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
virtual ~StuDraw3DMuEvent()
~StuDraw3DMuEvent( ) dtor
virtual const StDraw3DStyle & Style(EDraw3DStyle type) const
Return the reference to the predefined StDraw3DStyle object.
Definition: StDraw3D.cxx:482
Double_t length() const
Returns length of track (cm) from primary vertex to last measured point.
Definition: StMuTrack.cxx:416
Float_t getEtaHalfWidth(UInt_t eta) const
StDraw3DStyle maps &quot;STAR event&quot; EDraw3DStyle onto ROOT (color,style,size) attributes.
Definition: StDraw3D.h:29
Class StuDraw3DMuEvent - to draw the StMuDst primitives like StMuTrack as 3D points and 3D lines deco...
static Color_t Pt2Color(double pt)
Maps the track pt to the STAR StTrack track color code.
Definition: StDraw3D.cxx:78
virtual TObject * Tower(float radius, float lambda, float lambda1, float lambda2, float phi, float dphi, Color_t col, Style_t sty, Size_t siz)
This is an overloaded member function, provided for convenience.
Definition: StDraw3D.cxx:1425
virtual TObject * Line(int n, const double *xyz, Color_t col=Color_t(-1), Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
This is an overloaded member function, provided for convenience.
Definition: StDraw3D.cxx:807
Class StDraw3D - to draw the 3D primitives like 3D points and 3D lines decorated with the STAR detect...
Definition: StDraw3D.h:165
Float_t getPhiMean(UInt_t sec) const
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
Definition: StMuTrack.cxx:407
virtual TObject * TrackInOut(const StMuTrack &track, Bool_t in, Color_t col=Color_t(-1), Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add the in point of the given track to the display list with the col color, sty style, and siz size if provided.
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
Definition: StMuTrack.h:261
virtual TObject * Track(const StMuTrack &track, Color_t col, Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add track to the display list with the col color, sty style, and siz size if provided.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
virtual void Tracks(StTrackType type=global)
Add all tracks of the given type from the current event to the display list.
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
Float_t getPhiHalfWidth(UInt_t sec=0, UInt_t ssec=0) const
EEMC simple geometry.
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
Definition: StMuTrack.h:262
const StMuTrack * primaryTrack() const
Returns pointer to associated primary track. Null pointer if no global track available.
Definition: StMuTrack.cxx:578
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
Definition: StMuTrack.h:272
virtual TObject * EmcHit(Int_t emcHitsSoftId, Color_t col, Style_t sty, Size_t siz, const char *detIdt="bemc")
Add EMC hit defined emcHitsSoftId to the display list with the col color sty and size if provided...
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
Definition: StMuTrack.cxx:412
static StuDraw3DMuEvent * Display()
virtual void Endcaps(Style_t sty=0)
Add the endcap towers to the list to display.
Float_t getEtaMean(UInt_t eta) const