CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTrackingParticleProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWTrackingParticleProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Ianna Osborne on 9/9/10.
6  *
7  */
8 
14 
15 #include "TEveTrack.h"
16 
18 {
19 public:
22 
24 
25 private:
26  // Disable default copy constructor
28  // Disable default assignment operator
30 
31  void build( const TrackingParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
32 };
33 
34 void
35 FWTrackingParticleProxyBuilder::build( const TrackingParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
36 {
37  TEveRecTrack t;
38  t.fBeta = 1.0;
39  t.fP = TEveVector( iData.px(), iData.py(), iData.pz() );
40  t.fV = TEveVector( iData.vx(), iData.vy(), iData.vz() );
41  t.fSign = iData.charge();
42 
43  TEveTrack* track = new TEveTrack(&t, context().getTrackPropagator());
44  if( t.fSign == 0 )
45  track->SetLineStyle( 7 );
46 
47  TEvePointSet* pointSet = new TEvePointSet;
48  setupAddElement( pointSet, track );
49  const FWGeometry *geom = item()->getGeom();
50  const std::vector<PSimHit>& hits = iData.trackPSimHit();
51 
52  float local[3];
53  float localDir[3];
54  float global[3] = { 0.0, 0.0, 0.0 };
55  float globalDir[3] = { 0.0, 0.0, 0.0 };
56  std::vector<PSimHit>::const_iterator it = hits.begin();
57  std::vector<PSimHit>::const_iterator end = hits.end();
58  if( it != end )
59  {
60  unsigned int trackid = hits.begin()->trackId();
61 
62  for( ; it != end; ++it )
63  {
64  const PSimHit& phit = (*it);
65  if( phit.trackId() != trackid )
66  {
67  trackid = phit.trackId();
68  track->AddPathMark( TEvePathMark( TEvePathMark::kDecay, TEveVector( global[0], global[1], global[2] ),
69  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
70  }
71  local[0] = phit.localPosition().x();
72  local[1] = phit.localPosition().y();
73  local[2] = phit.localPosition().z();
74  localDir[0] = phit.momentumAtEntry().x();
75  localDir[1] = phit.momentumAtEntry().y();
76  localDir[2] = phit.momentumAtEntry().z();
77  geom->localToGlobal( phit.detUnitId(), local, global );
78  geom->localToGlobal( phit.detUnitId(), localDir, globalDir );
79  pointSet->SetNextPoint( global[0], global[1], global[2] );
80  track->AddPathMark( TEvePathMark( TEvePathMark::kReference/*kDaughter*/, TEveVector( global[0], global[1], global[2] ),
81  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
82  }
83  if( hits.size() > 1 )
84  track->AddPathMark( TEvePathMark( TEvePathMark::kDecay, TEveVector( global[0], global[1], global[2] ),
85  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
86  }
87 
88  track->MakeTrack();
89  setupAddElement( track, &oItemHolder );
90 }
91 
const fireworks::Context & context() const
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:56
int charge() const
electric charge
Definition: ParticleBase.h:55
LocalVector momentumAtEntry() const
The momentum of the track that produced the hit, at entry point.
Definition: PSimHit.h:47
const std::vector< PSimHit > & trackPSimHit() const
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
T y() const
Definition: PV3DBase.h:57
void localToGlobal(unsigned int id, const float *local, float *global) const
Definition: FWGeometry.cc:326
double pz() const
z coordinate of momentum vector
Definition: ParticleBase.h:152
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:57
double px() const
x coordinate of momentum vector
Definition: ParticleBase.h:140
Local3DPoint localPosition() const
Definition: PSimHit.h:44
T z() const
Definition: PV3DBase.h:58
double vz() const
z coordinate of vertex position
Definition: ParticleBase.h:244
#define end
Definition: vmac.h:38
const FWTrackingParticleProxyBuilder & operator=(const FWTrackingParticleProxyBuilder &)
double vx() const
x coordinate of vertex position
Definition: ParticleBase.h:234
unsigned int trackId() const
Definition: PSimHit.h:102
double py() const
y coordinate of momentum vector
Definition: ParticleBase.h:146
T x() const
Definition: PV3DBase.h:56
double vy() const
y coordinate of vertex position
Definition: ParticleBase.h:239
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:688
unsigned int detUnitId() const
Definition: PSimHit.h:93