CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTrackProxyBuilderFullFramework.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 //
12 
13 // system include files
14 #include "TEveManager.h"
15 #include "TEveBrowser.h"
16 #include "TEveTrack.h"
17 #include "TEvePointSet.h"
18 #include "TEveCompound.h"
19 
20 // user include files
24 
25 
33 
35 
36 public:
39 
41 
42  virtual void setItem(const FWEventItem* iItem) override;
43  virtual bool visibilityModelChanges(const FWModelId&, TEveElement*, FWViewType::EType, const FWViewContext*) override;
44 
45 private:
48 
49  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
51 
52 
53  TEveTrackPropagator* m_trackerPropagator;
55 };
56 
58 m_trackerPropagator(0),
59 m_trajToTrackMap(0)
60 {
61  m_trackerPropagator = new TEveTrackPropagator();
62  m_trackerPropagator->SetStepper( TEveTrackPropagator::kRungeKutta );
63  m_trackerPropagator->SetDelta(0.01);
64  m_trackerPropagator->SetMaxOrbs(0.7);
65  m_trackerPropagator->IncDenyDestroy();
66 }
67 
69 {
70  m_trackerPropagator->DecDenyDestroy();
71 }
72 
74 {
76  if (iItem)
77  {
78  m_trackerPropagator->SetMagFieldObj(context().getField(), false);
79  iItem->getConfig()->assertParam("Rnr TrajectoryMeasurement", false);
80  }
81 }
82 
83 void
84 FWTrackProxyBuilderFullFramework::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
85 {
86  const reco::TrackCollection * tracks = 0;
87  iItem->get( tracks );
88  if( tracks == 0 ) return;
89 
90  try {
91  const edm::EventBase* event = item()->getEvent();
92  edm::InputTag tag(item()->moduleLabel(), item()->productInstanceLabel(), item()->processName());
93  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
94  event->getByLabel(tag, trajTrackAssociationHandle);
95  m_trajToTrackMap = &*trajTrackAssociationHandle;
96  }
97  catch (cms::Exception &exception)
98  {
100  std::cout << exception.what() << std::endl;
101  }
102 
103  if (m_trajToTrackMap) {
104  bool rnrPathMarks = item()->getConfig()->value<bool>("Rnr TrajectoryMeasurement");
105  if (m_trackerPropagator->GetRnrReferences() != rnrPathMarks ) m_trackerPropagator->SetRnrReferences(rnrPathMarks);
106 
107  unsigned track_index = 0;
109  {
110  TEveCompound* comp = createCompound();
111  setupAddElement( comp, product );
112 
113  if (item()->modelInfo(track_index).displayProperties().isVisible())
114  buildTrack(it, comp);
115  }
116  }
117  else {
118  for (reco::TrackCollection::const_iterator i = tracks->begin(); i != tracks->end(); ++i)
119  {
120  const reco::Track& track = *i;
121  TEveRecTrack ts;
122  ts.fBeta = 1.;
123  ts.fSign = track.charge();
124  ts.fP.Set(track.px(), track.py(), track.pz());
125  ts.fV.Set(track.vx(), track.vy(), track.vz());
126  TEveTrack* eveTrack = new TEveTrack( &ts, m_trackerPropagator);
127  eveTrack->MakeTrack();
128  TEveCompound* comp = createCompound();
129  setupAddElement(comp, product );
130  setupAddElement(eveTrack, comp);
131  }
132  }
133 
134 
135 
136  gEve->GetBrowser()->MapWindow();
137 }
138 
140 {
141  const reco::Track& track = *it->val;
142  const Trajectory& traj = *it->key;
143 
144  TEveRecTrack ts;
145  ts.fBeta = 1.;
146  ts.fSign = track.charge();
147  ts.fP.Set(track.px(), track.py(), track.pz());
148  ts.fV.Set(track.vx(), track.vy(), track.vz());
149  TEveTrack* eveTrack = new TEveTrack( &ts, m_trackerPropagator);
150 
151  // path-marks from a trajectory
152  std::vector<TrajectoryMeasurement> measurements = traj.measurements();
153  std::vector<TrajectoryMeasurement>::iterator measurements_it = measurements.begin();
154  std::vector<TrajectoryMeasurement>::reverse_iterator measurements_rit = measurements.rbegin();
155  for (size_t t=0; t != measurements.size(); ++t, ++measurements_it, ++measurements_rit)
156  {
157  TrajectoryStateOnSurface trajState = (traj.direction() == alongMomentum) ? measurements_it->updatedState() : measurements_rit->updatedState() ;
158 
159  if( !trajState.isValid() ) continue;
160 
161  eveTrack->AddPathMark( TEvePathMark( TEvePathMark::kReference,
162  TEveVector(trajState.globalPosition().x(),trajState.globalPosition().y(), trajState.globalPosition().z()),
163  TEveVector(trajState.globalMomentum().x(),trajState.globalMomentum().y(), trajState.globalMomentum().z())));
164  }
165 
166  eveTrack->MakeTrack();
167  setupAddElement(eveTrack, comp);
168 }
169 
171  FWViewType::EType viewType, const FWViewContext* vc)
172 {
173  const FWEventItem::ModelInfo& info = iId.item()->modelInfo(iId.index());
174  bool returnValue = false;
175  if (info.displayProperties().isVisible() && iCompound->NumChildren()==0 && m_trajToTrackMap)
176  {
178  std::advance(it, iId.index());
179  buildTrack(it, (TEveCompound*)iCompound);
180  returnValue=true;
181  }
182  return returnValue;
183 }
184 
186 
187 
virtual char const * what() const
Definition: Exception.cc:141
const fireworks::Context & context() const
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:165
int i
Definition: DBlmapReader.cc:9
#define REGISTER_PROXYBUILDER_METHODS()
static const TGPicture * info(bool iBackgroundIsBlack)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:67
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
virtual void setItem(const FWEventItem *iItem) override
static const int kAllRPZBits
Definition: FWViewType.h:58
const_iterator end() const
last iterator over the map (read only)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
void buildTrack(TrajTrackAssociationCollection::const_iterator it, TEveCompound *comp)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:675
virtual bool visibilityModelChanges(const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *) override
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
const TrajTrackAssociationCollection * m_trajToTrackMap
DataContainer const & measurements() const
Definition: Trajectory.h:203
const FWTrackProxyBuilderFullFramework & operator=(const FWTrackProxyBuilderFullFramework &)
int index() const
Definition: FWModelId.h:49
virtual void setItem(const FWEventItem *iItem)
T z() const
Definition: PV3DBase.h:64
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:687
FWGenericParameter< T > * assertParam(const std::string &name, T def)
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:717
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:146
tuple tracks
Definition: testEve_cfg.py:39
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:711
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:615
const_iterator begin() const
first iterator over the map (read only)
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
T x() const
Definition: PV3DBase.h:62
const FWEventItem * item() const
Definition: FWModelId.h:44
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:681
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:705