CMS 3D CMS Logo

Public Member Functions | Private Member Functions

FWMuonBuilder Class Reference

#include <FWMuonBuilder.h>

List of all members.

Public Member Functions

void buildMuon (FWProxyBuilderBase *, const reco::Muon *muon, TEveElement *tList, bool showEndcap, bool onlyTracks=false)
 FWMuonBuilder ()
virtual ~FWMuonBuilder ()

Private Member Functions

void calculateField (const reco::Muon &iData, FWMagField *field)
 FWMuonBuilder (const FWMuonBuilder &)
const FWMuonBuilderoperator= (const FWMuonBuilder &)

Detailed Description

Definition at line 23 of file FWMuonBuilder.h.


Constructor & Destructor Documentation

FWMuonBuilder::FWMuonBuilder ( )

Definition at line 188 of file FWMuonBuilder.cc.

{
}
FWMuonBuilder::~FWMuonBuilder ( ) [virtual]

Definition at line 192 of file FWMuonBuilder.cc.

{
}
FWMuonBuilder::FWMuonBuilder ( const FWMuonBuilder ) [private]

Member Function Documentation

void FWMuonBuilder::buildMuon ( FWProxyBuilderBase pb,
const reco::Muon muon,
TEveElement *  tList,
bool  showEndcap,
bool  onlyTracks = false 
)

Definition at line 225 of file FWMuonBuilder.cc.

References calculateField(), FWProxyBuilderBase::context(), fireworks::Context::getField(), fireworks::Context::getGeom(), fireworks::Context::getMuonTrackPropagator(), reco::Muon::globalTrack(), reco::Muon::innerTrack(), reco::Muon::isGlobalMuon(), reco::Muon::isMatchesValid(), reco::Muon::isTrackerMuon(), FWProxyBuilderBase::item(), reco::Muon::outerTrack(), fireworks::prepareCandidate(), fireworks::prepareTrack(), and FWProxyBuilderBase::setupAddElement().

Referenced by FWMuonRhoPhiProxyBuilder::build(), and FWMuonProxyBuilder::build().

{
   calculateField( *muon, pb->context().getField());
  
   TEveRecTrack recTrack;
   recTrack.fBeta = 1.;

   // If we deal with a tracker muon we use the inner track and guide it
   // through the trajectory points from the reconstruction. Segments
   // represent hits. Matching between hits and the trajectory shows
   // how well the inner track matches with the muon hypothesis.
   //
   // In other cases we use a global muon track with a few states from 
   // the inner and outer tracks or just the outer track if it's the
   // only option

   if( muon->isTrackerMuon() && 
       muon->innerTrack().isAvailable() &&
       muon->isMatchesValid() &&
       !buggyMuon( &*muon, pb->context().getGeom()))
   {
      TEveTrack* trk = fireworks::prepareTrack( *(muon->innerTrack()),
                                                pb->context().getMuonTrackPropagator(),
                                                getRecoTrajectoryPoints( muon, pb->item()));
      trk->MakeTrack();
      pb->setupAddElement( trk, tList );
      if( ! tracksOnly )
         addMatchInformation( &(*muon), pb, tList, showEndcap );
      return;
   } 

   if( muon->isGlobalMuon() &&
       muon->globalTrack().isAvailable())
   {
      std::vector<TEveVector> extraPoints;
      if( muon->innerTrack().isAvailable() &&  muon->innerTrack()->extra().isAvailable())
      {
         extraPoints.push_back( TEveVector( muon->innerTrack()->innerPosition().x(),
                                            muon->innerTrack()->innerPosition().y(),
                                            muon->innerTrack()->innerPosition().z()));
         extraPoints.push_back( TEveVector( muon->innerTrack()->outerPosition().x(),
                                            muon->innerTrack()->outerPosition().y(),
                                            muon->innerTrack()->outerPosition().z()));
      }
      if( muon->outerTrack().isAvailable() &&  muon->outerTrack()->extra().isAvailable())
      {
         extraPoints.push_back( TEveVector( muon->outerTrack()->innerPosition().x(),
                                            muon->outerTrack()->innerPosition().y(),
                                            muon->outerTrack()->innerPosition().z()));
         extraPoints.push_back( TEveVector( muon->outerTrack()->outerPosition().x(),
                                            muon->outerTrack()->outerPosition().y(),
                                            muon->outerTrack()->outerPosition().z()));
      }
      TEveTrack* trk = fireworks::prepareTrack( *( muon->globalTrack()),
                                                pb->context().getMuonTrackPropagator(),
                                                extraPoints );
      trk->MakeTrack();
      pb->setupAddElement( trk, tList );
      return;
   }

   if( muon->innerTrack().isAvailable())
   {
      TEveTrack* trk = fireworks::prepareTrack( *( muon->innerTrack()), pb->context().getMuonTrackPropagator());
      trk->MakeTrack();
      pb->setupAddElement( trk, tList );
      return;
   }

   if( muon->outerTrack().isAvailable())
   {
      TEveTrack* trk = fireworks::prepareTrack( *( muon->outerTrack()), pb->context().getMuonTrackPropagator());
      trk->MakeTrack();
      pb->setupAddElement( trk, tList );
      return;
   }
   
   // if got that far it means we have nothing but a candidate
   // show it anyway.
   TEveTrack* trk = fireworks::prepareCandidate( *muon, pb->context().getMuonTrackPropagator());
   trk->MakeTrack();
   pb->setupAddElement( trk, tList );
}
void FWMuonBuilder::calculateField ( const reco::Muon iData,
FWMagField field 
) [private]

Definition at line 202 of file FWMuonBuilder.cc.

References fw::estimate_field(), reco::LeafCandidate::eta(), FWMagField::getSource(), FWMagField::guessField(), FWMagField::guessFieldIsOn(), reco::Muon::innerTrack(), WDecay::kNone, reco::Muon::outerTrack(), and reco::LeafCandidate::pt().

Referenced by buildMuon().

{
   // if auto field estimation mode, do extra loop over muons.
   // use both inner and outer track if available
   if( field->getSource() == FWMagField::kNone )
   {
      if( fabs( iData.eta() ) > 2.0 || iData.pt() < 3 ) return;
      if( iData.innerTrack().isAvailable())
      {
         double estimate = fw::estimate_field( *( iData.innerTrack()), true );
         if( estimate >= 0 ) field->guessField( estimate );      
      }
      if( iData.outerTrack().isAvailable() )
      {
         double estimate = fw::estimate_field( *( iData.outerTrack()));
         if( estimate >= 0 ) field->guessFieldIsOn( estimate > 0.5 );
      }
   }
}
const FWMuonBuilder& FWMuonBuilder::operator= ( const FWMuonBuilder ) [private]