CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTrackProxyBuilderFF.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Tracks
4 // Class : FWTrackProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Nov 25 14:42:13 EST 2008
11 // $Id: FWTrackProxyBuilderFF.cc,v 1.4 2012/10/22 20:08:20 amraktad Exp $
12 //
13 
14 // system include files
15 #include "TEveManager.h"
16 #include "TEveBrowser.h"
17 #include "TEveTrack.h"
18 #include "TEvePointSet.h"
19 #include "TEveCompound.h"
20 
21 // user include files
25 
26 
34 
36 
37 public:
39  virtual ~FWTrackProxyBuilderFF();
40 
42 
43  virtual void setItem(const FWEventItem* iItem);
44  virtual bool visibilityModelChanges(const FWModelId&, TEveElement*, FWViewType::EType, const FWViewContext*);
45 
46 private:
47  FWTrackProxyBuilderFF(const FWTrackProxyBuilderFF&); // stop default
48  const FWTrackProxyBuilderFF& operator=(const FWTrackProxyBuilderFF&); // stop default
49 
50  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
52 
53 
54  TEveTrackPropagator* m_trackerPropagator;
56 };
57 
59 m_trackerPropagator(0),
60 m_trajToTrackMap(0)
61 {
62  m_trackerPropagator = new TEveTrackPropagator();
63  m_trackerPropagator->SetStepper( TEveTrackPropagator::kRungeKutta );
64  m_trackerPropagator->SetDelta(0.01);
65  m_trackerPropagator->SetMaxOrbs(0.7);
66  m_trackerPropagator->IncDenyDestroy();
67 }
68 
70 {
71  m_trackerPropagator->DecDenyDestroy();
72 }
73 
75 {
77  if (iItem)
78  {
79  m_trackerPropagator->SetMagFieldObj(context().getField(), false);
80  iItem->getConfig()->assertParam("Rnr TrajectoryMeasurement", false);
81  }
82 }
83 
84 void
85 FWTrackProxyBuilderFF::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
86 {
87  const reco::TrackCollection * tracks = 0;
88  iItem->get( tracks );
89  if( tracks == 0 ) return;
90 
91  try {
92  const edm::EventBase* event = item()->getEvent();
93  edm::InputTag tag(item()->moduleLabel(), item()->productInstanceLabel(), item()->processName());
94  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
95  event->getByLabel(tag, trajTrackAssociationHandle);
96  m_trajToTrackMap = &*trajTrackAssociationHandle;
97  }
98  catch (cms::Exception &exception)
99  {
100  m_trajToTrackMap =0;
101  std::cout << exception.what() << std::endl;
102  return;
103  }
104 
105 
106  bool rnrPathMarks = item()->getConfig()->value<bool>("Rnr TrajectoryMeasurement");
107  if (m_trackerPropagator->GetRnrReferences() != rnrPathMarks ) m_trackerPropagator->SetRnrReferences(rnrPathMarks);
108 
109  unsigned track_index = 0;
111  {
112  TEveCompound* comp = createCompound();
113  setupAddElement( comp, product );
114 
115  if (item()->modelInfo(track_index).displayProperties().isVisible())
116  buildTrack(it, comp);
117  }
118 
119  gEve->GetBrowser()->MapWindow();
120 }
121 
123 {
124  const reco::Track track = *it->val;
125  const Trajectory traj = *it->key;
126 
127  TEveRecTrack ts;
128  ts.fBeta = 1.;
129  ts.fSign = track.charge();
130  ts.fP.Set(track.px(), track.py(), track.pz());
131  ts.fV.Set(track.vx(), track.vy(), track.vz());
132  TEveTrack* eveTrack = new TEveTrack( &ts, m_trackerPropagator);
133 
134  // path-marks from a trajectory
135  std::vector<TrajectoryMeasurement> measurements = traj.measurements();
136  std::vector<TrajectoryMeasurement>::iterator measurements_it = measurements.begin();
137  std::vector<TrajectoryMeasurement>::reverse_iterator measurements_rit = measurements.rbegin();
138  for (size_t t=0; t != measurements.size(); ++t, ++measurements_it, ++measurements_rit)
139  {
140  TrajectoryStateOnSurface trajState = (traj.direction() == alongMomentum) ? measurements_it->updatedState() : measurements_rit->updatedState() ;
141 
142  if( !trajState.isValid() ) continue;
143 
144  eveTrack->AddPathMark( TEvePathMark( TEvePathMark::kReference,
145  TEveVector(trajState.globalPosition().x(),trajState.globalPosition().y(), trajState.globalPosition().z()),
146  TEveVector(trajState.globalMomentum().x(),trajState.globalMomentum().y(), trajState.globalMomentum().z())));
147  }
148 
149  eveTrack->MakeTrack();
150  setupAddElement(eveTrack, comp);
151 }
152 
153 bool FWTrackProxyBuilderFF::visibilityModelChanges(const FWModelId& iId, TEveElement* iCompound,
154  FWViewType::EType viewType, const FWViewContext* vc)
155 {
156  const FWEventItem::ModelInfo& info = iId.item()->modelInfo(iId.index());
157  bool returnValue = false;
158  if (info.displayProperties().isVisible() && iCompound->NumChildren()==0 && m_trajToTrackMap)
159  {
161  std::advance(it, iId.index());
162  buildTrack(it, (TEveCompound*)iCompound);
163  returnValue=true;
164  }
165  return returnValue;
166 }
167 
169 
170 
virtual char const * what() const
Definition: Exception.cc:141
virtual void setItem(const FWEventItem *iItem)
const fireworks::Context & context() const
const TrajTrackAssociationCollection * m_trajToTrackMap
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:166
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
const_iterator end() const
last iterator over the map (read only)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
TEveTrackPropagator * m_trackerPropagator
void get(const T *&oData) const
Definition: FWEventItem.h:85
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:60
PropagationDirection const & direction() const
Definition: Trajectory.cc:196
DataContainer const & measurements() const
Definition: Trajectory.h:215
const FWTrackProxyBuilderFF & operator=(const FWTrackProxyBuilderFF &)
int index() const
Definition: FWModelId.h:50
virtual void setItem(const FWEventItem *iItem)
T z() const
Definition: PV3DBase.h:64
void buildTrack(TrajTrackAssociationCollection::const_iterator it, TEveCompound *comp)
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
FWGenericParameter< T > * assertParam(const std::string &name, T def)
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:147
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:147
tuple tracks
Definition: testEve_cfg.py:39
virtual bool visibilityModelChanges(const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *)
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
GlobalVector globalMomentum() const
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
tuple cout
Definition: gather_cfg.py:121
int charge() const
track electric charge
Definition: TrackBase.h:113
const_iterator begin() const
first iterator over the map (read only)
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:536
T x() const
Definition: PV3DBase.h:62
const FWEventItem * item() const
Definition: FWModelId.h:45
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:143