CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FWPFTrackUtils Class Reference

#include <FWPFTrackUtils.h>

Public Member Functions

 FWPFTrackUtils ()
 
TEvePointSet * getCollisionMarkers (const TEveTrack *)
 
TEveStraightLineSet * setupLegoTrack (const reco::Track &)
 
TEveTrack * setupTrack (const reco::Track &)
 
virtual ~FWPFTrackUtils ()
 

Private Member Functions

 FWPFTrackUtils (const FWPFTrackUtils &)
 
TEveTrack * getTrack (const reco::Track &)
 
const FWPFTrackUtilsoperator= (const FWPFTrackUtils &)
 

Private Attributes

FWPFTrackSingletonm_singleton
 

Detailed Description

Definition at line 70 of file FWPFTrackUtils.h.

Constructor & Destructor Documentation

FWPFTrackUtils::FWPFTrackUtils ( )

Definition at line 48 of file FWPFTrackUtils.cc.

References FWPFTrackSingleton::Instance(), and m_singleton.

49 {
51 }
FWPFTrackSingleton * m_singleton
static FWPFTrackSingleton * Instance()
virtual FWPFTrackUtils::~FWPFTrackUtils ( )
inlinevirtual

Definition at line 75 of file FWPFTrackUtils.h.

75 {}
FWPFTrackUtils::FWPFTrackUtils ( const FWPFTrackUtils )
private

Member Function Documentation

TEvePointSet * FWPFTrackUtils::getCollisionMarkers ( const TEveTrack *  trk)

Definition at line 271 of file FWPFTrackUtils.cc.

References FWPFGeom::caloR1(), FWPFGeom::caloR2(), FWPFGeom::caloR3(), FWPFGeom::caloZ1(), FWPFGeom::caloZ2(), FWPFMaths::checkIntersect(), ECAL, i, j, FWPFMaths::linearInterpolation(), FWPFMaths::lineCircleIntersect(), FWPFMaths::lineLineIntersect(), p1, p2, y, and z.

Referenced by FWPFTrackRPZProxyBuilder::build(), FWPFTrack3DProxyBuilder::build(), and FWPFBlockProxyBuilder::setupTrackElement().

272 {
273  using namespace FWPFGeom;
274 
275  bool ECAL = false;
276  const Float_t *points = trk->GetP();
277  TEvePointSet *ps = new TEvePointSet();
278 
279  for( Int_t i = 1; i < trk->GetN(); ++i )
280  {
281  int j = i * 3;
282  TEveVector v1 = TEveVector( points[j], points[j+1], points[j+2] );
283 
284  if( !ECAL )
285  {
286  if( FWPFMaths::checkIntersect( v1, caloR1() ) )
287  {
288  TEveVector v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
289  TEveVector xyPoint = FWPFMaths::lineCircleIntersect( v1, v2, caloR1() );
290  TEveVector zPoint;
291  if( v1.fZ < 0 )
292  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ - 50.f );
293  else
294  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ + 50.f );
295 
296  TEveVector vec = FWPFMaths::lineLineIntersect( v1, v2, xyPoint, zPoint );
297  ps->SetNextPoint( vec.fX, vec.fY, vec.fZ );
298 
299  ECAL = true;
300  }
301  else if( fabs( v1.fZ ) >= caloZ1() )
302  {
303  TEveVector p1, p2;
304  TEveVector vec, v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
305  float z, y = FWPFMaths::linearInterpolation( v2, v1, caloZ1() );
306 
307  if( v2.fZ > 0 )
308  z = caloZ1();
309  else
310  z = caloZ1() * -1;
311 
312  p1 = TEveVector( v2.fX + 50, y, z );
313  p2 = TEveVector( v2.fX - 50, y, z );
314  vec = FWPFMaths::lineLineIntersect( v1, v2, p1, p2 );
315 
316  ps->SetNextPoint( vec.fX, vec.fY, vec.fZ );
317  ECAL = true;
318  }
319  }
320  else if ( FWPFMaths::checkIntersect( v1, caloR2() ) )
321  {
322  TEveVector v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
323  TEveVector xyPoint = FWPFMaths::lineCircleIntersect( v1, v2, caloR2() );
324  TEveVector zPoint;
325  if( v1.fZ < 0 )
326  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ - 50.f );
327  else
328  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ + 50.f );
329 
330  TEveVector vec = FWPFMaths::lineLineIntersect( v1, v2, xyPoint, zPoint );
331  ps->SetNextPoint( vec.fX, vec.fY, vec.fZ );
332  break; // ECAL and HCAL collisions found so stop looping
333  }
334  }
335 
336  // HCAL collisions (outer radius and endcap)
337  int i = ( trk->GetN() - 1 ) * 3;
338  TEveVector vec = TEveVector( points[i], points[i+1], points[i+2] );
339 
340  if( FWPFMaths::checkIntersect( vec, caloR3() - 1 ) )
341  ps->SetNextPoint( vec.fX, vec.fY, vec.fZ );
342  else if( fabs( vec.fZ ) >= caloZ2() )
343  ps->SetNextPoint( vec.fX, vec.fY, vec.fZ );
344 
345  return ps;
346 }
int i
Definition: DBlmapReader.cc:9
float linearInterpolation(const TEveVector &p1, const TEveVector &p2, float r)
Definition: FWPFMaths.cc:91
float caloZ2()
Definition: FWPFGeom.h:27
bool checkIntersect(const TEveVector &vec, float r)
Definition: FWPFMaths.cc:103
float caloR1()
Definition: FWPFGeom.h:21
int j
Definition: DBlmapReader.cc:9
float caloR2()
Definition: FWPFGeom.h:25
double p2[4]
Definition: TauolaWrapper.h:90
float caloZ1()
Definition: FWPFGeom.h:22
double p1[4]
Definition: TauolaWrapper.h:89
TEveVector lineCircleIntersect(const TEveVector &v1, const TEveVector &v2, float r)
Definition: FWPFMaths.cc:38
TEveVector lineLineIntersect(const TEveVector &v1, const TEveVector &v2, const TEveVector &v3, const TEveVector &v4)
Definition: FWPFMaths.cc:73
float caloR3()
Definition: FWPFGeom.h:26
TEveTrack * FWPFTrackUtils::getTrack ( const reco::Track iData)
private

Definition at line 56 of file FWPFTrackUtils.cc.

References reco::TrackBase::charge(), reco::Track::extra(), FWPFTrackSingleton::getTrackerTrackPropagator(), FWPFTrackSingleton::getTrackPropagator(), edm::Ref< C, T, F >::isAvailable(), m_singleton, HLT_FULL_cff::propagator, reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), lumiQTWidget::t, and reco::TrackBase::vertex().

Referenced by setupLegoTrack(), and setupTrack().

57 {
58  TEveTrackPropagator *propagator = ( !iData.extra().isAvailable() ) ?
60 
61  TEveRecTrack t;
62  t.fBeta = 1;
63  t.fP = TEveVector( iData.px(), iData.py(), iData.pz() );
64  t.fV = TEveVector( iData.vertex().x(), iData.vertex().y(), iData.vertex().z() );
65  t.fSign = iData.charge();
66  TEveTrack *trk = new TEveTrack( &t, propagator );
67  trk->MakeTrack();
68 
69  return trk;
70 }
bool isAvailable() const
Definition: Ref.h:576
tuple propagator
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
FWPFTrackSingleton * m_singleton
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:622
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:682
TEveTrackPropagator * getTrackPropagator()
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:634
int charge() const
track electric charge
Definition: TrackBase.h:562
TEveTrackPropagator * getTrackerTrackPropagator()
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:628
const FWPFTrackUtils& FWPFTrackUtils::operator= ( const FWPFTrackUtils )
private
TEveStraightLineSet * FWPFTrackUtils::setupLegoTrack ( const reco::Track iData)

Definition at line 74 of file FWPFTrackUtils.cc.

References FWPFGeom::caloR1(), FWPFGeom::caloR2(), FWPFGeom::caloR3(), FWPFGeom::caloZ1(), FWPFGeom::caloZ2(), FWPFMaths::checkIntersect(), ECAL, end, fw::estimate_field(), reco::TrackBase::eta(), FWPFTrackSingleton::getField(), FWMagField::getSource(), getTrack(), FWMagField::guessField(), i, j, FWMagField::kNone, FWPFMaths::linearInterpolation(), FWPFMaths::lineCircleIntersect(), FWPFMaths::lineLineIntersect(), visualization-live-secondInstance_cfg::m, m_singleton, p1, p2, reco::TrackBase::pt(), groupFilesInBlocks::temp, TwoPi, y, and z.

Referenced by FWPFTrackLegoProxyBuilder::build(), and FWPFBlockProxyBuilder::setupTrackElement().

75 {
76  using namespace FWPFGeom;
77 
78  // Declarations
79  int wraps[3] = { -1, -1, -1 };
80  bool ECAL = false;
81  TEveTrack *trk = getTrack( iData );
82  std::vector<TEveVector> trackPoints( trk->GetN() - 1 );
83  const Float_t *points = trk->GetP();
84  TEveStraightLineSet *legoTrack = new TEveStraightLineSet();
85 
87  {
88  if( fabs( iData.eta() ) < 2.0 && iData.pt() > 0.5 && iData.pt() < 30 )
89  {
90  double estimate = fw::estimate_field( iData, true );
91  if( estimate >= 0 ) m_singleton->getField()->guessField( estimate );
92  }
93  }
94 
95  // Convert to Eta/Phi and store in vector
96  for( Int_t i = 1; i < trk->GetN(); ++i )
97  {
98  int j = i * 3;
99  TEveVector temp = TEveVector( points[j], points[j+1], points[j+2] );
100  TEveVector vec = TEveVector( temp.Eta(), temp.Phi(), 0.001 );
101 
102  trackPoints[i-1] = vec;
103  }
104 
105  // Add first point to ps if necessary
106  for( Int_t i = 1; i < trk->GetN(); ++i )
107  {
108  int j = i * 3;
109  TEveVector v1 = TEveVector( points[j], points[j+1], points[j+2] );
110 
111  if( !ECAL )
112  {
113  if( FWPFMaths::checkIntersect( v1, caloR1() ) )
114  {
115  TEveVector v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
116  TEveVector xyPoint = FWPFMaths::lineCircleIntersect( v1, v2, caloR1() );
117  TEveVector zPoint;
118  if( v1.fZ < 0 )
119  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ - 50.f );
120  else
121  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ + 50.f );
122 
123  TEveVector vec = FWPFMaths::lineLineIntersect( v1, v2, xyPoint, zPoint );
124  legoTrack->AddMarker( vec.Eta(), vec.Phi(), 0.001, 0 );
125 
126  wraps[0] = i; // There is now a chance that the track will also reach the HCAL radius
127  ECAL = true;
128  }
129  else if( fabs( v1.fZ ) >= caloZ1() )
130  {
131  TEveVector p1, p2;
132  TEveVector vec, v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
133  float z, y = FWPFMaths::linearInterpolation( v2, v1, caloZ1() );
134 
135  if( v2.fZ > 0 )
136  z = caloZ1();
137  else
138  z = caloZ1() * -1;
139 
140  p1 = TEveVector( v2.fX + 50, y, z );
141  p2 = TEveVector( v2.fX - 50, y, z );
142  vec = FWPFMaths::lineLineIntersect( v1, v2, p1, p2 );
143 
144  legoTrack->AddMarker( vec.Eta(), vec.Phi(), 0.001, 0 );
145  wraps[0] = i;
146  ECAL = true;
147  }
148  }
149  else if( FWPFMaths::checkIntersect( v1, caloR2() ) )
150  {
151  TEveVector v2 = TEveVector( points[j-3], points[j-2], points[j-1] );
152  TEveVector xyPoint = FWPFMaths::lineCircleIntersect( v1, v2, caloR2() );
153  TEveVector zPoint;
154  if( v1.fZ < 0 )
155  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ - 50.f );
156  else
157  zPoint = TEveVector( xyPoint.fX, xyPoint.fY, v1.fZ + 50.f );
158 
159  TEveVector vec = FWPFMaths::lineLineIntersect( v1, v2, xyPoint, zPoint );
160  legoTrack->AddMarker( vec.Eta(), vec.Phi(), 0.001, 1 );
161 
162  wraps[1] = i; // There is now a chance that the track will also reach the HCAL radius
163  break;
164  }
165  }
166 
167  if( wraps[0] != -1 ) //if( ECAL )
168  {
169  int i = ( trk->GetN() - 1 ) * 3;
170  int j = trk->GetN() - 2; // This is equal to the last index in trackPoints vector
171  TEveVector vec = TEveVector( points[i], points[i+1], points[i+2] );
172 
173  if( FWPFMaths::checkIntersect( vec, caloR3() - 1 ) )
174  {
175  legoTrack->AddMarker( vec.Eta(), vec.Phi(), 0.001, 2 );
176  wraps[2] = j;
177  }
178  else if( fabs( vec.fZ ) >= caloZ2() )
179  {
180  legoTrack->AddMarker( vec.Eta(), vec.Phi(), 0.001, 2 );
181  wraps[2] = j;
182  }
183  }
184 
185  /* Handle phi wrapping */
186  for( int i = 0; i < static_cast<int>( trackPoints.size() - 1 ); ++i )
187  {
188  if( ( trackPoints[i+1].fY - trackPoints[i].fY ) > 1 )
189  {
190  trackPoints[i+1].fY -= TMath::TwoPi();
191  if( i == wraps[0] )
192  {
193  TEveChunkManager::iterator mi( legoTrack->GetMarkerPlex() );
194  mi.next(); // First point
195  TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
196  m.fV[0] = trackPoints[i+1].fX; m.fV[1] = trackPoints[i+1].fY; m.fV[2] = 0.001;
197  }
198  else if( i == wraps[1] )
199  {
200  TEveChunkManager::iterator mi( legoTrack->GetMarkerPlex() );
201  mi.next(); mi.next(); // Second point
202  TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
203  m.fV[0] = trackPoints[i+1].fX; m.fV[1] = trackPoints[i+1].fY; m.fV[2] = 0.001;
204  }
205  }
206 
207  if( ( trackPoints[i].fY - trackPoints[i+1].fY ) > 1 )
208  {
209  trackPoints[i+1].fY += TMath::TwoPi();
210  if( i == wraps[0] )
211  {
212  TEveChunkManager::iterator mi( legoTrack->GetMarkerPlex() );
213  mi.next(); // First point
214  TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
215  m.fV[0] = trackPoints[i+1].fX; m.fV[1] = trackPoints[i+1].fY; m.fV[2] = 0.001;
216  }
217  else if( i == wraps[1] )
218  {
219  TEveChunkManager::iterator mi( legoTrack->GetMarkerPlex() );
220  mi.next(); mi.next(); // Second point
221  TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
222  m.fV[0] = trackPoints[i+1].fX; m.fV[1] = trackPoints[i+1].fY; m.fV[2] = 0.001;
223  }
224  }
225  }
226 
227  int end = static_cast<int>( trackPoints.size() - 1 );
228  if( wraps[2] == end )
229  {
230  TEveChunkManager::iterator mi( legoTrack->GetMarkerPlex() );
231  mi.next(); mi.next(); mi.next(); // Third point
232  TEveStraightLineSet::Marker_t &m = * ( TEveStraightLineSet::Marker_t* ) mi();
233  m.fV[0] = trackPoints[end].fX; m.fV[1] = trackPoints[end].fY; m.fV[2] = 0.001;
234  }
235 
236  // Set points on TEveLineSet object ready for displaying
237  for( unsigned int i = 0;i < trackPoints.size() - 1; ++i )
238  legoTrack->AddLine( trackPoints[i], trackPoints[i+1] );
239 
240  legoTrack->SetDepthTest( false );
241  legoTrack->SetMarkerStyle( 4 );
242  legoTrack->SetMarkerSize( 1 );
243  legoTrack->SetRnrMarkers( true );
244 
245  delete trk; // Release memory that is no longer required
246 
247  return legoTrack;
248 }
const double TwoPi
int i
Definition: DBlmapReader.cc:9
FWPFTrackSingleton * m_singleton
float linearInterpolation(const TEveVector &p1, const TEveVector &p2, float r)
Definition: FWPFMaths.cc:91
float caloZ2()
Definition: FWPFGeom.h:27
double estimate_field(const reco::Track &track, bool highQuality=false)
bool checkIntersect(const TEveVector &vec, float r)
Definition: FWPFMaths.cc:103
float caloR1()
Definition: FWPFGeom.h:21
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
void guessField(float estimate) const
Definition: FWMagField.cc:155
double pt() const
track transverse momentum
Definition: TrackBase.h:616
int j
Definition: DBlmapReader.cc:9
float caloR2()
Definition: FWPFGeom.h:25
#define end
Definition: vmac.h:37
ESource getSource() const
Definition: FWMagField.h:33
double p2[4]
Definition: TauolaWrapper.h:90
FWMagField * getField()
TEveTrack * getTrack(const reco::Track &)
float caloZ1()
Definition: FWPFGeom.h:22
double p1[4]
Definition: TauolaWrapper.h:89
TEveVector lineCircleIntersect(const TEveVector &v1, const TEveVector &v2, float r)
Definition: FWPFMaths.cc:38
TEveVector lineLineIntersect(const TEveVector &v1, const TEveVector &v2, const TEveVector &v3, const TEveVector &v4)
Definition: FWPFMaths.cc:73
float caloR3()
Definition: FWPFGeom.h:26
TEveTrack * FWPFTrackUtils::setupTrack ( const reco::Track iData)

Definition at line 252 of file FWPFTrackUtils.cc.

References fw::estimate_field(), reco::TrackBase::eta(), FWPFTrackSingleton::getField(), FWMagField::getSource(), getTrack(), FWMagField::guessField(), FWMagField::kNone, m_singleton, and reco::TrackBase::pt().

Referenced by FWPFTrackRPZProxyBuilder::build(), FWPFTrack3DProxyBuilder::build(), and FWPFBlockProxyBuilder::setupTrackElement().

253 {
255  {
256  if( fabs( iData.eta() ) < 2.0 && iData.pt() > 0.5 && iData.pt() < 30 )
257  {
258  double estimate = fw::estimate_field( iData, true );
259  if( estimate >= 0 ) m_singleton->getField()->guessField( estimate );
260  }
261  }
262 
263  TEveTrack *trk = getTrack( iData );
264 
265  return trk;
266 }
FWPFTrackSingleton * m_singleton
double estimate_field(const reco::Track &track, bool highQuality=false)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
void guessField(float estimate) const
Definition: FWMagField.cc:155
double pt() const
track transverse momentum
Definition: TrackBase.h:616
ESource getSource() const
Definition: FWMagField.h:33
FWMagField * getField()
TEveTrack * getTrack(const reco::Track &)

Member Data Documentation

FWPFTrackSingleton* FWPFTrackUtils::m_singleton
private

Definition at line 88 of file FWPFTrackUtils.h.

Referenced by FWPFTrackUtils(), getTrack(), setupLegoTrack(), and setupTrack().