CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h

Go to the documentation of this file.
00001 #ifndef TrackAssociator_TrackDetectorAssociator_h
00002 #define TrackAssociator_TrackDetectorAssociator_h 1
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:    TrackAssociator
00007 // Class:      TrackDetectorAssociator
00008 // 
00009 /*
00010 
00011  Description: main class of tools to associate a track to calorimeter and muon detectors
00012 
00013 */
00014 //
00015 // Original Author:  Dmytro Kovalskyi
00016 //         Created:  Fri Apr 21 10:59:41 PDT 2006
00017 // $Id: TrackDetectorAssociator.h,v 1.21 2011/04/07 09:02:44 innocent Exp $
00018 //
00019 //
00020 
00021 #include "FWCore/Framework/interface/Event.h"
00022 #include "FWCore/Framework/interface/EventSetup.h"
00023 #include "DataFormats/Common/interface/Handle.h"
00024 #include "FWCore/Framework/interface/ESHandle.h"
00025 #include "FWCore/Framework/interface/ESWatcher.h"
00026 #include "DataFormats/Common/interface/OrphanHandle.h"
00027 
00028 #include "DataFormats/TrackReco/interface/TrackBase.h"
00029 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00030 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00031 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00032 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00033 
00034 #include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
00035 #include "TrackingTools/TrackAssociator/interface/TrackDetMatchInfo.h"
00036 #include "TrackingTools/TrackAssociator/interface/CachedTrajectory.h"
00037 
00038 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00039 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00040 #include "DataFormats/TrackReco/interface/Track.h"
00041 #include "DataFormats/TrackingRecHit/interface/RecSegment.h"
00042 
00043 #include "SimDataFormats/Track/interface/SimTrack.h"
00044 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00045 
00046 #include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
00047 
00048 #include "FWCore/Utilities/interface/Visibility.h"
00049 
00050 
00051 class TrackDetectorAssociator {
00052  public:
00053    TrackDetectorAssociator();
00054    ~TrackDetectorAssociator();
00055    
00056    typedef TrackAssociatorParameters AssociatorParameters;
00057    enum Direction { Any, InsideOut, OutsideIn };
00058    
00072    TrackDetMatchInfo            associate( const edm::Event&,
00073                                            const edm::EventSetup&,
00074                                            const FreeTrajectoryState&,
00075                                            const AssociatorParameters& );
00078    TrackDetMatchInfo            associate( const edm::Event& iEvent,
00079                                            const edm::EventSetup& iSetup,
00080                                            const AssociatorParameters& parameters,
00081                                            const FreeTrajectoryState* innerState,
00082                                            const FreeTrajectoryState* outerState=0);
00084    TrackDetMatchInfo            associate( const edm::Event&,
00085                                            const edm::EventSetup&,
00086                                            const reco::Track&,
00087                                            const AssociatorParameters&,
00088                                            Direction direction = Any );
00090    TrackDetMatchInfo            associate( const edm::Event&,
00091                                            const edm::EventSetup&,
00092                                            const SimTrack&,
00093                                            const SimVertex&,
00094                                            const AssociatorParameters& );
00096    TrackDetMatchInfo            associate( const edm::Event&,
00097                                            const edm::EventSetup&,
00098                                            const GlobalVector&,
00099                                            const GlobalPoint&,
00100                                            const int,
00101                                            const AssociatorParameters& );
00102    
00104    void setPropagator( const Propagator* );
00105    
00107    void useDefaultPropagator();
00108    
00110    static FreeTrajectoryState getFreeTrajectoryState( const edm::EventSetup&, 
00111                                                       const reco::Track& );
00112    static FreeTrajectoryState getFreeTrajectoryState( const edm::EventSetup&, 
00113                                                       const SimTrack&, 
00114                                                       const SimVertex& );
00115    static FreeTrajectoryState getFreeTrajectoryState( const edm::EventSetup&,
00116                                                       const GlobalVector&,
00117                                                       const GlobalPoint&,
00118                                                       const int);
00119         
00120    static bool                crossedIP(const reco::Track& track);
00121 
00122  private:
00123    DetIdAssociator::MapRange getMapRange( const std::pair<float,float>& delta,
00124                                           const float dR ) dso_internal;
00125 
00126    void fillEcal(       const edm::Event&,
00127                         TrackDetMatchInfo&, 
00128                         const AssociatorParameters&) dso_internal;
00129    
00130    void fillCaloTowers( const edm::Event&,
00131                         TrackDetMatchInfo&,
00132                         const AssociatorParameters&) dso_internal;
00133    
00134    void fillHcal(       const edm::Event&,
00135                         TrackDetMatchInfo&,
00136                         const AssociatorParameters&) dso_internal;
00137    
00138    void fillHO(         const edm::Event&,
00139                         TrackDetMatchInfo&,
00140                         const AssociatorParameters&) dso_internal;
00141   
00142    void fillPreshower(  const edm::Event& iEvent,
00143                         TrackDetMatchInfo& info,
00144                         const AssociatorParameters&) dso_internal;
00145    
00146    void fillMuon(       const edm::Event&,
00147                         TrackDetMatchInfo&,
00148                         const AssociatorParameters&) dso_internal;
00149    
00150    void fillCaloTruth(  const edm::Event&,
00151                         TrackDetMatchInfo&,
00152                         const AssociatorParameters&) dso_internal;
00153    
00154    bool addTAMuonSegmentMatch(TAMuonChamberMatch&,
00155                             const RecSegment*,
00156                             const AssociatorParameters&) dso_internal;
00157    
00158    void getTAMuonChamberMatches(std::vector<TAMuonChamberMatch>& matches,
00159                               const AssociatorParameters& parameters) dso_internal;
00160   
00161    void           init( const edm::EventSetup&) dso_internal;
00162    
00163    math::XYZPoint getPoint( const GlobalPoint& point)  dso_internal
00164      {
00165         return math::XYZPoint(point.x(),point.y(),point.z());
00166      }
00167    
00168    math::XYZPoint getPoint( const LocalPoint& point)  dso_internal
00169      {
00170         return math::XYZPoint(point.x(),point.y(),point.z());
00171      }
00172    
00173    math::XYZVector getVector( const GlobalVector& vec)  dso_internal
00174      {
00175         return math::XYZVector(vec.x(),vec.y(),vec.z());
00176      }
00177    
00178    math::XYZVector getVector( const LocalVector& vec)  dso_internal
00179      {
00180         return math::XYZVector(vec.x(),vec.y(),vec.z());
00181      }
00182    
00183    const Propagator* ivProp_;
00184    Propagator* defProp_;
00185    CachedTrajectory cachedTrajectory_;
00186    bool useDefaultPropagator_;
00187    
00188    edm::ESHandle<DetIdAssociator> ecalDetIdAssociator_;
00189    edm::ESHandle<DetIdAssociator> hcalDetIdAssociator_;
00190    edm::ESHandle<DetIdAssociator>   hoDetIdAssociator_;
00191    edm::ESHandle<DetIdAssociator> caloDetIdAssociator_;
00192    edm::ESHandle<DetIdAssociator> muonDetIdAssociator_;
00193    edm::ESHandle<DetIdAssociator> preshowerDetIdAssociator_;
00194    
00195    edm::ESHandle<CaloGeometry> theCaloGeometry_;
00196    edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry_;
00197    
00198    edm::ESWatcher<IdealMagneticFieldRecord>     theMagneticFeildWatcher_;
00199 };
00200 #endif