00001
00002
00003 #include "StuDraw3DMuEvent.h"
00004 #include "Gtypes.h"
00005 #include "StHelixHelper.h"
00006 #include "StMuDSTMaker/COMMON/StMuTrack.h"
00007 #include "StThreeVector.hh"
00008 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
00009 #include "StEmcUtil/geometry/StEmcGeom.h"
00010
00011
00013
00039
00040 StuDraw3DMuEvent::StuDraw3DMuEvent( const char *detectorName,TVirtualPad *pad):
00041 StDraw3D(detectorName,pad),fEndcapGeom(0)
00042 {
00043
00044
00045
00046 if (!gMuEventDisplay) gMuEventDisplay = this;
00047 }
00048
00050
00053
00054 StuDraw3DMuEvent::~StuDraw3DMuEvent()
00055 {
00056 if (gMuEventDisplay == this) gMuEventDisplay = 0;
00057 delete fEndcapGeom; fEndcapGeom=0;
00058 }
00059
00061
00066
00067 void StuDraw3DMuEvent::Tracks(StTrackType type)
00068 {
00069 Int_t n_prim=0;
00070 Int_t n_glob=0;
00071 TObjArray *globTracks = 0;
00072 TObjArray *primTracks = 0;
00073 if (type == global && ( globTracks= StMuDst::globalTracks() ) ){
00074 n_glob=StMuDst::GetNGlobalTrack();
00075 } else if ( (primTracks = StMuDst::primaryTracks()) ) {
00076 n_prim=StMuDst::GetNPrimaryTrack();
00077 }
00078
00079 Int_t i_track=0;
00080 while (i_track < n_prim) {
00081 StMuTrack &track = *(StMuTrack *)primTracks->UncheckedAt(i_track++);
00082 double pt =track.pt();
00083 Style_t sty = Style(kPrimaryTrack).Sty();
00084 Size_t siz = Style(kPrimaryTrack).Siz();
00085 Track(track,StDraw3DStyle::Pt2Color(pt),sty,siz);
00086 cout << ".";
00087 }
00088 i_track=0;
00089 while (i_track < n_glob) {
00090 StMuTrack &track = *(StMuTrack *)globTracks->UncheckedAt(i_track++);
00091 double pt =track.pt();
00092 Style_t sty = Style(kGlobalTrack).Sty();
00093 Size_t siz = Style(kGlobalTrack).Siz();
00094 Track(track,StDraw3DStyle::Pt2Color(pt),sty,siz);
00095 cout << "+";
00096 }
00097 cout << endl << n_prim << " primary and " << n_glob << " global tracks have been rendered" << endl;
00098
00099 }
00100
00101
00103
00110
00111 TObject *StuDraw3DMuEvent::Track(const StMuTrack &track, Color_t col,Style_t sty,Size_t siz)
00112 {
00113
00114 StHelixHelper trPnt(track.helix(),track.outerHelix(),track.length());
00115 Int_t size;
00116 Float_t *xyz = trPnt.GetPoints(size);
00117 TObject *l = Line(size,xyz,col,sty,siz);
00118 SetModel((TObject*)&track);
00119 return l;
00120 }
00121
00123
00125
00126 TObject *StuDraw3DMuEvent::Track(const StMuTrack &track, EDraw3DStyle sty)
00127 {
00128 TObject *view = 0;
00129 const StDraw3DStyle &style = Style(sty);
00130 const StMuTrack *thisTrack = 0;
00131 if (sty == kPrimaryTrack)
00132 thisTrack = track.primaryTrack();
00133 else
00134 thisTrack = track.globalTrack();
00135 if (thisTrack)
00136 view = Track(*thisTrack, style.Col(),style.Sty(),style.Siz() );
00137 return view;
00138
00139 }
00140
00142
00151
00152 TObject *StuDraw3DMuEvent::TrackInOut(const StMuTrack &track, Bool_t in
00153 , Color_t col, Style_t sty, Size_t siz)
00154 {
00155
00156 const StThreeVectorF &pnt = in ? track.firstPoint() : track.lastPoint();
00157
00158 return Point(pnt.x(),pnt.y(),pnt.z(), col,sty,siz);
00159 }
00160
00162
00169
00170 TObject *StuDraw3DMuEvent::TrackInOut(const StMuTrack &track, EDraw3DStyle sty,Bool_t in)
00171 {
00172 const StDraw3DStyle &style = Style(sty);
00173 return TrackInOut(track, in, style.Col(),style.Sty(),style.Siz() );
00174 }
00175
00176
00177 EEmcGeomSimple *StuDraw3DMuEvent::EndcapGeom()
00178 {
00179
00180
00181 if (!fEndcapGeom) fEndcapGeom = new EEmcGeomSimple();
00182 return fEndcapGeom;
00183 }
00184
00186
00193
00194 void StuDraw3DMuEvent::Endcaps(Style_t sty)
00195 {
00196 StMuEmcCollection *emc= StMuDst::muEmcCollection();
00197 if (emc) Endcaps(*emc,sty);
00198 }
00199
00200
00202
00233
00234 void StuDraw3DMuEvent::Endcaps(const StMuEmcCollection &emc,Style_t sty)
00235 {
00236 Color_t colorResponce = 0;
00237 int nTowers = emc.getNEndcapTowerADC();
00238 for (int i=0; i< nTowers; i++) {
00239 int adc, isec, isub, ieta;
00240 emc.getEndcapTowerADC(i,adc,isec,isub,ieta);
00241 isec--; ieta--; isub--;
00242 if (adc<=0) continue;
00243
00244 float etaCenter =EndcapGeom()->getEtaMean(ieta);
00245 if (etaCenter <= 0) continue;
00246 float phiCenter =EndcapGeom()->getPhiMean(isec,isub);
00247 if (phiCenter <= 0) continue;
00248 static const float dPhi = 2*EndcapGeom()->getPhiHalfWidth(isec,isub);
00249 static const float deta = 2*EndcapGeom()->getEtaHalfWidth(ieta);
00250 static const float radius = 270.;
00251 float energy = adc*60./4096-0.15;
00252 if ( energy > 0.15 ) {
00253
00254
00255 if ( energy < 0.3) { colorResponce = kBlue;
00256
00257 } else if ( energy < 1.0 ) { colorResponce = kGreen;
00258
00259 } else if ( energy < 4.0 ) { colorResponce = kYellow;
00260
00261 } else colorResponce = kRed;
00262
00263 static const double maxSize = 400.;
00264 static const double scale = 15;
00265 double size =(energy > 0.3 ? scale : scale/30.)*energy;
00266 if (size > maxSize) size = maxSize ;
00267 Tower( radius
00268 , StarRoot::StEta(etaCenter,deta)
00269 , phiCenter, dPhi
00270 , colorResponce
00271 , sty
00272 , size);
00273 SetComment(Form("Endcap eta=%f, phi=%f, energy=%f",etaCenter,phiCenter,energy));
00274 }
00275 }
00276 }
00277
00279
00287
00288 TObject *StuDraw3DMuEvent::EmcHit(Int_t emcHitsSoftId, Color_t col,Style_t sty,Size_t siz, const char *detId)
00289 {
00290 TObject *model = 0;
00291 StEmcGeom *emcGeom =StEmcGeom::getEmcGeom(detId);
00292 if (emcGeom) {
00293 Int_t softId=emcHitsSoftId;
00294 Float_t eta;
00295 Float_t phi;
00296 emcGeom->getEtaPhi(softId,eta,phi);
00297 Float_t etaStep = 1.0/emcGeom->NEta();
00298 Float_t phiStep = TMath::Pi()/60;
00299 static int entries = 0;
00300
00301
00302 entries++;
00303 model = Tower(emcGeom->Radius(), StarRoot::StEta(eta,etaStep)
00304 , phi, phiStep
00305 , col,sty+(strcmp(detId,"bemc")?0:kBarrelStyle),siz);
00306 } else {
00307 LOG_ERROR << __FILE__ << ": there is no geometry information for \"" << detId << "\"" << endm;
00308 }
00309 return model;
00310 }
00311
00312
00313 TObject *StuDraw3DMuEvent::EmcHit(Int_t emcHitsSoftId, float energy, const char *detIdt)
00314 {
00315 return EmcHit<StEmcTowerColor>(emcHitsSoftId, energy, detIdt);
00316 }
00317
00318
00322
00323 StuDraw3DMuEvent *StuDraw3DMuEvent::Display(){ return gMuEventDisplay;}
00324
00325
00326 StEmcTowerColor::StEmcTowerColor(float energy)
00327 {
00328 Color_t colorResponce=0;
00329 Size_t size=0;
00330 if (energy > 0 && energy < 30) {
00331
00332 if ( energy < 0.3) {
00333 colorResponce = kBlue;
00334
00335
00336 } else if ( energy < 1.0 ) colorResponce = kGreen;
00337
00338 else if ( energy < 4.0 ) colorResponce = kYellow;
00339
00340 else colorResponce = kRed;
00341
00342 static const double maxSize = 400.;
00343 static const double scale = 200.;
00344 size =(energy > 0.3 ? scale : scale/30.)*energy;
00345 if (size > maxSize) size = maxSize ;
00346 fStyle.SetCol(colorResponce);
00347 fStyle.SetSiz(size);
00348 }
00349 }
00350
00351 StuDraw3DMuEvent *StuDraw3DMuEvent::gMuEventDisplay = new StuDraw3DMuEvent();
00352
00353 ClassImp(StuDraw3DMuEvent)
00354
00355
00356