3 #include "StuDraw3DEvent.h"
5 #include "TVirtualPad.h"
7 #include "StEventHelper.h"
10 #include "StGlobalTrack.h"
13 #include "StFtpcHit.h"
14 #include "StEmcRawHit.h"
15 #include "StTrackNode.h"
16 #include "StTrackGeometry.h"
17 #include "StTpcHitCollection.h"
18 #include "StEmcCollection.h"
19 #include "StFtpcHitCollection.h"
20 #include "StFtpcSectorHitCollection.h"
21 #include "StFtpcPlaneHitCollection.h"
22 #include "StEmcDetector.h"
23 #include "StEmcModule.h"
24 #include "StMeasuredPoint.h"
26 #include "StTrackDetectorInfo.h"
27 #include "StEmcUtil/geometry/StEmcGeom.h"
28 #include "StEventHitIter.h"
29 #include "StMessMgr.h"
68 if (!gEventDisplay) gEventDisplay =
this;
79 if (gEventDisplay ==
this) gEventDisplay = 0;
95 StEmcGeom *emcGeom =StEmcGeom::getEmcGeom(detId);
97 Int_t softId=emcHitsSoftId;
100 emcGeom->getEtaPhi(softId,eta,phi);
101 Float_t etaStep = 1.0/emcGeom->NEta();
102 Float_t phiStep = TMath::Pi()/60;
103 static int entries = 0;
109 , col,sty+(strcmp(detId,
"bemc")?0:kBarrelStyle),siz);
111 LOG_ERROR << __FILE__ <<
": there is no geometry information for \"" << detId <<
"\"" << endm;
129 if (!detId || !detId[0]) detId =
"bemc";
130 StEmcGeom *emcGeom =StEmcGeom::getEmcGeom(detId);
134 emcHit.modEtaSub(m,e,s);
135 emcGeom->getId(m,e,s,softId);
136 EmcHit(softId, col,sty,siz,detId);
137 SetModel((TObject*)&emcHit);
139 LOG_ERROR << __FILE__ <<
": there is no geometry information for \"" << detId <<
"\"" << endm;
156 Color_t colorResponce = 0;
157 if (!detId || !detId[0]) detId =
"bemc";
160 StEmcDetector* det = emcC->detector( strcmp(detId,
"bemc") ? kEndcapEmcTowerId : kBarrelEmcTowerId);
162 for(
unsigned int md=1; md <=det->numberOfModules(); md++) {
164 StSPtrVecEmcRawHit&
hit= module->hits();
166 for(
unsigned int ih=0;ih < hit.size();ih++){
168 double rawAdc=h->adc()-5;
169 float energy = h->energy();
173 if ( rawAdc>0 && energy > 0 && energy < 30) {
176 colorResponce = kBlue;
179 }
else if ( energy < 1.0 ) colorResponce = kGreen;
181 else if ( energy < 4.0 ) colorResponce = kYellow;
183 else colorResponce = kRed;
187 static const double maxSize = 400.;
188 static const double scale = 200.;
189 double size =(energy > 0.3 ? scale : scale/30.)*energy;
190 if (size > maxSize) size = maxSize ;
191 EmcHit(*h,colorResponce,style, size,detId);
215 TObject *l =
Line(size,xyz,col,sty,siz);
216 SetModel((TObject*)&track);
227 return Track(track, style.Col(),style.Sty(),style.Siz() );
234 Float_t *xyz = trPnt.GetPoints(size);
235 TObject *l =
Line(size,xyz,col,sty,siz);
236 SetModel((TObject*)&track);
247 return Track(track, style.Col(),style.Sty(),style.Siz() );
262 , Color_t col, Style_t sty, Size_t siz)
266 TObject *p = Point(position.x(),position.y(),position.z(),col,sty,siz);
267 SetModel((TObject*)&hit);
279 return Hit(hit, style.Col(),style.Sty(),style.Siz() );
294 , Color_t col, Style_t sty, Size_t siz)
296 return Hit(vertex,col,sty,siz);
311 return Vertex(vtx, style.Col(),style.Sty(),style.Siz() );
322 void StuDraw3DEvent::Hits(
const StTrack &track)
326 if (track.flag() > 0 && track.detectorInfo()&& !track.bad() ) {
327 Style_t sty =
Style(kUsedHit).Sty();
328 Size_t siz =
Style(kUsedHit).Siz();
329 double pt = track.geometry()->momentum().perp();
344 void StuDraw3DEvent::Hits(
const StTrack &track
351 std::vector<float> hitPoints;
352 const StPtrVecHit& trackHits = track.detectorInfo()->hits(kTpcId);
355 for (m=0; m<trackHits.size(); m++) {
357 hitPoints.push_back( hit->position().x());
358 hitPoints.push_back( hit->position().y());
359 hitPoints.push_back( hit->position().z());
362 std::vector<float>::iterator xyz = hitPoints.begin();
363 Points(hitPoints.size()/3,&*xyz,col,sty,siz);
367 const StPtrVecHit& trackWestHits = track.detectorInfo()->hits(kFtpcWestId);
370 for (m=0; m<trackWestHits.size(); m++) {
371 hit = trackWestHits[m];
372 hitPoints.push_back( hit->position().x());
373 hitPoints.push_back( hit->position().y());
374 hitPoints.push_back( hit->position().z());
377 std::vector<float>::iterator xyz = hitPoints.begin();
378 Points(hitPoints.size()/3,&*xyz,col,sty,siz);
383 const StPtrVecHit& trackEastHits = track.detectorInfo()->hits(kFtpcEastId);
384 for (m=0; m<trackEastHits.size(); m++) {
385 hit = trackEastHits[m];
386 hitPoints.push_back( hit->position().x());
387 hitPoints.push_back( hit->position().y());
388 hitPoints.push_back( hit->position().z());
391 std::vector<float>::iterator xyz = hitPoints.begin();
392 Points(hitPoints.size()/3,&*xyz,col,sty,siz);
402 void StuDraw3DEvent::Hits(
const StTrack &track, EDraw3DStyle sty)
407 Hits(track, style.Col(),style.Sty(),style.Siz());
423 , Color_t col, Style_t sty, Size_t siz)
426 return Points(trInOut.Size(),trInOut.GetXYZ(0),col,sty,siz);
442 return TrackInOut(track, in, style.Col(),style.Sty(),style.Siz() );
459 Hits(event,kTracksOnly,type);
481 for (i=0; i<theNodes.size(); i++) {
482 track = (
StTrack *) theNodes[i]->track(type);
483 if (track && track->flag() > 0
487 double pt = track->geometry()->momentum().perp();
493 void StuDraw3DEvent::Hits(
const StEvent *event,EStuDraw3DEvent trackHitsOnly, StTrackType type)
498 unsigned int m, n, h;
499 if (trackHitsOnly != kUnusedHitsOnly) {
500 Style_t sty =
Style(kUsedHit).Sty();
501 Size_t siz =
Style(kUsedHit).Siz();
502 Style_t styPnt =
Style(kTrackBegin).Sty();
503 Size_t sizPnt =
Style(kTrackBegin).Siz();
505 const StSPtrVecTrackNode& theNodes =
event->trackNodes();
506 for (
unsigned int i=0; i<theNodes.size(); i++) {
508 if (track && track->flag() > 0
509 && track->detectorInfo()
514 double pt = track->geometry()->momentum().perp();
516 if ( trackHitsOnly != kUsedHits) {
517 Track(*track,trackColor);
518 TrackInOut(*track,
true, trackColor, styPnt, sizPnt);
519 TrackInOut(*track,
false, trackColor, styPnt, sizPnt);
521 if ( trackHitsOnly != kTracksOnly) {
522 Hits(*track,trackColor,sty,siz);
523 if (trackHitsOnly == kUsedHits) SetModel(track);
529 std::vector<float> hitPoints;
530 for (n=0; n<hits->numberOfSectors(); n++) {
531 for (m=0; m<hits->sector(n)->numberOfPadrows(); m++) {
532 for (h=0; h<hits->sector(n)->padrow(m)->hits().size(); h++) {
533 hit = hits->sector(n)->padrow(m)->hits()[h];
534 hitPoints.push_back( hit->position().x());
535 hitPoints.push_back( hit->position().y());
536 hitPoints.push_back( hit->position().z());
540 std::vector<float>::iterator xyz = hitPoints.begin();
541 Points(hitPoints.size()/3,&*xyz,kUnusedHit);
542 SetComment(
"Unused TPC hits");
547 void StuDraw3DEvent::FtpcHits(
const StEvent *event,EStuDraw3DEvent trackHitsOnly, StTrackType type)
550 unsigned int m, n, h;
551 if (trackHitsOnly != kUnusedHitsOnly) {
552 Style_t sty =
Style(kUsedHit).Sty();
553 Size_t siz =
Style(kUsedHit).Siz();
554 Style_t styPnt =
Style(kTrackBegin).Sty();
555 Size_t sizPnt =
Style(kTrackBegin).Siz();
556 int trackCounter = 0;
557 const StSPtrVecTrackNode& theNodes =
event->trackNodes();
558 for (
unsigned int i=0; i<theNodes.size(); i++) {
560 if (track && track->flag() > 0
561 && track->detectorInfo()
562 && ( track->detectorInfo()->numberOfPoints(kFtpcWestId) || track->detectorInfo()->numberOfPoints(kFtpcEastId) )
567 double pt = track->geometry()->momentum().perp();
569 if ( trackHitsOnly != kUsedHits) {
570 Track(*track,trackColor);
571 TrackInOut(*track,
true, trackColor, styPnt, sizPnt);
572 TrackInOut(*track,
false, trackColor, styPnt, sizPnt);
574 if ( trackHitsOnly != kTracksOnly) {
575 Hits(*track,trackColor,sty,siz);
576 if (trackHitsOnly == kUsedHits) SetModel(track);
580 printf(
" Ftpc tracks total : %d\n", trackCounter);
583 std::vector<float> hitPoints;
585 if (ftpHits->numberOfHits()>0) {
586 for (n=0;n<ftpHits-> numberOfPlanes();++n ) {
587 for (m=0; m<ftpHits->plane(n)->numberOfSectors(); m++) {
588 for (h=0; h<ftpHits->plane(n)->sector(m)->hits().size(); h++) {
589 hit = ftpHits->plane(n)->sector(m)->hits()[h];
590 hitPoints.push_back( hit->position().x());
591 hitPoints.push_back( hit->position().y());
592 hitPoints.push_back( hit->position().z());
594 std::vector<float>::iterator xyz = hitPoints.begin();
595 Points(hitPoints.size()/3,&*xyz,kUnusedHit);
596 SetComment(
"Unused FTPC hits");
597 printf(
" FTPC hits counter total : %d\n", hitPoints.size()/3);
611 std::vector<float> hitPoints;
612 for (
const StHit *sth=0;(sth = *(iter));++iter) {
613 const float *f = sth->position().xyz();
614 hitPoints.push_back(f[0]);
615 hitPoints.push_back(f[1]);
616 hitPoints.push_back(f[2]);
618 std::vector<float>::iterator xyz = hitPoints.begin();
619 Points(hitPoints.size()/3,&*xyz,kUsedHit);
623 void StuDraw3DEvent::Wait()
625 if (gEventDisplay) gEventDisplay->UpdateModified();
626 fprintf(stderr,
"StvDraw::Waiting...\n");
627 while(!gSystem->ProcessEvents()){gSystem->Sleep(200);};
StEventHitIter is the top level hook, providing hits to the Stv tracking code.
virtual const StDraw3DStyle & Style(EDraw3DStyle type) const
Return the reference to the predefined StDraw3DStyle object.
StDraw3DStyle maps "STAR event" EDraw3DStyle onto ROOT (color,style,size) attributes.
virtual ~StuDraw3DEvent()
~StuDraw3DEvent( ) dtor
virtual void Tracks(const StEvent *event, StTrackType type=global)
Add all tracks of the given type from the event to the display list.
virtual TObject * EmcHit(Int_t emcHitsSoftId, Color_t col, Style_t sty, Size_t siz, const char *det="bemc")
Add EMC hit defined emcHitsSoftId to the display list with the col color sty and size if provided...
static Color_t Pt2Color(double pt)
Maps the track pt to the STAR StTrack track color code.
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.
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.
Class StDraw3D - to draw the 3D primitives like 3D points and 3D lines decorated with the STAR detect...
virtual TObject * Track(const StTrack &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 and size if provided.
virtual TObject * Hit(const StMeasuredPoint &hit, Color_t col, Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
Add one hit to the display list with the col color sty and siz size if provided.
virtual TObject * Vertex(const StMeasuredPoint &hit, Color_t col, Style_t sty=Style_t(-1), Size_t siz=Size_t(-1))
This is an overloaded member function, provided for convenience.
static StuDraw3DEvent * Display()
virtual void EmcHits(const StEvent *event, const char *det="bemc")
Add all emcHits those can pass the internal filter from the given detector detId type from the event ...
virtual TObject * TrackInOut(const StTrack &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 and siz size if provid...
virtual Float_t * GetPoints(int &npoints) const
virtual TObject * Points(int n, const float *xyz, EDraw3DStyle sty)
This is an overloaded member function, provided for convenience.
Class StuDraw3DEvent - to draw the 3D StEvent primitives like StTrack, StHit, StVertex decorated with...