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 
17 
18 #include "TEveTrack.h"
19 
21 {
22 public:
25 
26  virtual void setItem(const FWEventItem* iItem) {
28  iItem->getConfig()->assertParam("Point Size", 1l, 3l, 1l);
29  }
30 
32 
33 private:
34  // Disable default copy constructor
36  // Disable default assignment operator
38 
39  void build( const TrackingParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
40 };
41 
42 void
43 FWTrackingParticleProxyBuilder::build( const TrackingParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
44 {
45  TEveRecTrack t;
46  t.fBeta = 1.0;
47  t.fP = TEveVector( iData.px(), iData.py(), iData.pz() );
48  t.fV = TEveVector( iData.vx(), iData.vy(), iData.vz() );
49  t.fSign = iData.charge();
50 
51  TEveTrack* track = new TEveTrack(&t, context().getTrackPropagator());
52  if( t.fSign == 0 )
53  track->SetLineStyle( 7 );
54 
55  TEvePointSet* pointSet = new TEvePointSet;
56  setupAddElement( pointSet, track );
57  pointSet->SetMarkerSize(item()->getConfig()->value<long>("Point Size"));
58 
59  const FWGeometry *geom = item()->getGeom();
60  const std::vector<PSimHit>& hits = iData.trackPSimHit();
61 
62  float local[3];
63  float localDir[3];
64  float global[3] = { 0.0, 0.0, 0.0 };
65  float globalDir[3] = { 0.0, 0.0, 0.0 };
66  std::vector<PSimHit>::const_iterator it = hits.begin();
67  std::vector<PSimHit>::const_iterator end = hits.end();
68  if( it != end )
69  {
70  unsigned int trackid = hits.begin()->trackId();
71 
72  for( ; it != end; ++it )
73  {
74  const PSimHit& phit = (*it);
75  if( phit.trackId() != trackid )
76  {
77  trackid = phit.trackId();
78  track->AddPathMark( TEvePathMark( TEvePathMark::kDecay, TEveVector( global[0], global[1], global[2] ),
79  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
80  }
81  local[0] = phit.localPosition().x();
82  local[1] = phit.localPosition().y();
83  local[2] = phit.localPosition().z();
84  localDir[0] = phit.momentumAtEntry().x();
85  localDir[1] = phit.momentumAtEntry().y();
86  localDir[2] = phit.momentumAtEntry().z();
87  geom->localToGlobal( phit.detUnitId(), local, global );
88  geom->localToGlobal( phit.detUnitId(), localDir, globalDir );
89  pointSet->SetNextPoint( global[0], global[1], global[2] );
90  track->AddPathMark( TEvePathMark( TEvePathMark::kReference/*kDaughter*/, TEveVector( global[0], global[1], global[2] ),
91  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
92  }
93  if( hits.size() > 1 )
94  track->AddPathMark( TEvePathMark( TEvePathMark::kDecay, TEveVector( global[0], global[1], global[2] ),
95  TEveVector( globalDir[0], globalDir[1], globalDir[2] )));
96  }
97 
98  track->MakeTrack();
99  setupAddElement( track, &oItemHolder );
100 }
101 
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:166
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
int charge() const
electric charge
Definition: ParticleBase.h:54
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:62
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:151
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:60
double px() const
x coordinate of momentum vector
Definition: ParticleBase.h:139
Local3DPoint localPosition() const
Definition: PSimHit.h:44
virtual void setItem(const FWEventItem *iItem)
T z() const
Definition: PV3DBase.h:63
double vz() const
z coordinate of vertex position
Definition: ParticleBase.h:243
#define end
Definition: vmac.h:38
const FWTrackingParticleProxyBuilder & operator=(const FWTrackingParticleProxyBuilder &)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
double vx() const
x coordinate of vertex position
Definition: ParticleBase.h:233
unsigned int trackId() const
Definition: PSimHit.h:102
double py() const
y coordinate of momentum vector
Definition: ParticleBase.h:145
T x() const
Definition: PV3DBase.h:61
double vy() const
y coordinate of vertex position
Definition: ParticleBase.h:238
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
unsigned int detUnitId() const
Definition: PSimHit.h:93
virtual void setItem(const FWEventItem *iItem)