7 #include "TEveVSDStructs.h"
9 #include "TEveStraightLineSet.h"
10 #include "TEveGeoNode.h"
32 std::vector<TEveVector> getRecoTrajectoryPoints(
const reco::Muon*
muon,
35 std::vector<TEveVector> points;
38 float localTrajectoryPoint[3];
39 float globalTrajectoryPoint[3];
41 const std::vector<reco::MuonChamberMatch>& matches = muon->
matches();
42 for( std::vector<reco::MuonChamberMatch>::const_iterator chamber = matches.begin(),
43 chamberEnd = matches.end();
44 chamber != chamberEnd; ++chamber )
47 localTrajectoryPoint[0] = chamber->x;
48 localTrajectoryPoint[1] = chamber->y;
49 localTrajectoryPoint[2] = 0;
51 unsigned int rawid = chamber->id.rawId();
54 geom->
localToGlobal( rawid, localTrajectoryPoint, globalTrajectoryPoint );
55 points.push_back( TEveVector(globalTrajectoryPoint[0],
56 globalTrajectoryPoint[1],
57 globalTrajectoryPoint[2] ));
65 void addMatchInformation(
const reco::Muon* muon,
67 TEveElement* parentList,
70 std::set<unsigned int> ids;
73 const std::vector<reco::MuonChamberMatch>& matches = muon->
matches();
76 std::auto_ptr<TEveStraightLineSet> segmentSet(
new TEveStraightLineSet );
78 segmentSet->SetLineWidth( 4 );
80 for( std::vector<reco::MuonChamberMatch>::const_iterator chamber = matches.begin(),
81 chambersEnd = matches.end();
82 chamber != chambersEnd; ++chamber )
84 unsigned int rawid = chamber->id.rawId();
85 float segmentLength = 0.0;
86 float segmentLimit = 0.0;
91 shape->SetElementName(
"Chamber" );
92 shape->RefMainTrans().Scale( 0.999, 0.999, 0.999 );
95 if( det->shape[0] == 1 )
97 segmentLength = det->shape[3];
98 segmentLimit = det->shape[4];
100 else if( det->shape[0] == 2 )
102 segmentLength = det->shape[3];
106 const double segmentLength = 15;
107 fwLog(
fwlog::kWarning ) << Form(
"FWMuonBuilder: unknown shape type in muon chamber with detId=%d. Setting segment length to %.0f cm.\n", rawid, segmentLength);
110 if( ids.insert( rawid ).second &&
116 for( std::vector<reco::MuonSegmentMatch>::const_iterator segment = chamber->segmentMatches.begin(),
117 segmentEnd = chamber->segmentMatches.end();
118 segment != segmentEnd; ++segment )
120 float segmentPosition[3] = { segment->x, segment->y, 0.0 };
121 float segmentDirection[3] = { segment->dXdZ, segment->dYdZ, 0.0 };
123 float localSegmentInnerPoint[3];
124 float localSegmentOuterPoint[3];
127 segmentLength, segmentLimit,
128 segmentPosition, segmentDirection,
129 localSegmentInnerPoint, localSegmentOuterPoint );
131 float globalSegmentInnerPoint[3];
132 float globalSegmentOuterPoint[3];
134 geom->
localToGlobal( *det, localSegmentInnerPoint, globalSegmentInnerPoint );
135 geom->
localToGlobal( *det, localSegmentOuterPoint, globalSegmentOuterPoint );
137 segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
138 globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
143 if( !matches.empty() )
157 float localTrajectoryPoint[3];
158 float globalTrajectoryPoint[3];
160 const std::vector<reco::MuonChamberMatch>& matches = muon->
matches();
161 for( std::vector<reco::MuonChamberMatch>::const_iterator chamber = matches.begin(),
162 chamberEnd = matches.end();
163 chamber != chamberEnd; ++chamber )
166 localTrajectoryPoint[0] = chamber->x;
167 localTrajectoryPoint[1] = chamber->y;
168 localTrajectoryPoint[2] = 0;
170 unsigned int rawid = chamber->id.rawId();
173 geom->
localToGlobal( rawid, localTrajectoryPoint, globalTrajectoryPoint );
174 double phi = atan2( globalTrajectoryPoint[1], globalTrajectoryPoint[0] );
207 if( fabs( iData.
eta() ) > 2.0 || iData.
pt() < 3 )
return;
211 if( estimate >= 0 ) field->
guessField( estimate );
232 TEveRecTrack recTrack;
251 getRecoTrajectoryPoints( muon, pb->
item()));
256 addMatchInformation( &(*muon), pb, tList, showEndcap );
263 std::vector<TEveVector> extraPoints;
266 extraPoints.push_back( TEveVector( muon->
innerTrack()->innerPosition().x(),
269 extraPoints.push_back( TEveVector( muon->
innerTrack()->outerPosition().x(),
275 extraPoints.push_back( TEveVector( muon->
outerTrack()->innerPosition().x(),
278 extraPoints.push_back( TEveVector( muon->
outerTrack()->outerPosition().x(),
const fireworks::Context & context() const
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
virtual TrackRef innerTrack() const
IdToInfoItr find(unsigned int) const
bool isTrackerMuon() const
const FWGeometry * getGeom() const
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
bool isGlobalMuon() const
bool isMatchesValid() const
void buildMuon(FWProxyBuilderBase *, const reco::Muon *muon, TEveElement *tList, bool showEndcap, bool onlyTracks=false)
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
const FWEventItem * item() const
double estimate_field(const reco::Track &track, bool highQuality=false)
void calculateField(const reco::Muon &iData, FWMagField *field)
void createSegment(int detector, bool matchedSegment, float segmentLength, float segmentLimit, float *segmentPosition, float *segmentDirection, float *segmentInnerPoint, float *segmentOuterPoint)
FWMagField * getField() const
TEveGeoShape * getEveShape(unsigned int id) const
void guessField(float estimate) const
Cos< T >::type cos(const T &t)
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
bool contains(unsigned int id) const
ESource getSource() const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
TEveTrackPropagator * getMuonTrackPropagator() const
std::vector< MuonChamberMatch > & matches()
get muon matching information
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
void guessFieldIsOn(bool guess) const
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
const FWGeometry * getGeom() const
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track