CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Calibration/IsolatedParticles/interface/CaloPropagateTrack.h

Go to the documentation of this file.
00001 #ifndef CalibrationIsolatedParticlesCaloPropagateTrack_h
00002 #define CalibrationIsolatedParticlesCaloPropagateTrack_h
00003 
00004 #include <cmath>
00005 #include <vector>
00006 #include <string>
00007 
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "DataFormats/DetId/interface/DetId.h"
00010 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00011 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00012 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00013 #include "DataFormats/TrackReco/interface/Track.h"
00014 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00015 
00016 //sim track
00017 #include "SimDataFormats/Track/interface/SimTrack.h"
00018 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00019 #include "SimDataFormats/Vertex/interface/SimVertex.h"
00020 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00021 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00022 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00023 
00024 #include "MagneticField/Engine/interface/MagneticField.h"
00025 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00026 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00027 
00028 #include "FWCore/Framework/interface/ESHandle.h"
00029 
00030 namespace spr{
00031 
00032   struct propagatedTrack {
00033     propagatedTrack() {ok=false;}
00034     bool                ok;
00035     math::XYZPoint      point;
00036     GlobalVector        direction;
00037   };
00038 
00039   struct propagatedTrackID {
00040     propagatedTrackID() {ok=false; okECAL=false; okHCAL=false;}
00041     bool                                  ok, okECAL, okHCAL;
00042     DetId                                 detIdECAL, detIdHCAL, detIdEHCAL;
00043     double                                etaECAL, etaHCAL;
00044     double                                phiECAL, phiHCAL;
00045     reco::TrackCollection::const_iterator trkItr;
00046   };
00047 
00048   struct propagatedTrackDirection {
00049     propagatedTrackDirection() {ok=false; okECAL=false; okHCAL=false;}
00050     bool                                  ok, okECAL, okHCAL;
00051     DetId                                 detIdECAL, detIdHCAL, detIdEHCAL;
00052     GlobalPoint                           pointECAL, pointHCAL;
00053     GlobalVector                          directionECAL, directionHCAL;
00054     reco::TrackCollection::const_iterator trkItr;
00055   };
00056 
00057   struct propagatedGenTrackID {
00058     propagatedGenTrackID() {
00059       ok=okECAL=okHCAL=false;
00060       charge=pdgId=0;
00061     }
00062     bool                                  ok, okECAL, okHCAL;
00063     DetId                                 detIdECAL, detIdHCAL, detIdEHCAL;
00064     GlobalPoint                           pointECAL, pointHCAL;
00065     GlobalVector                          directionECAL, directionHCAL;
00066     int                                   charge, pdgId;
00067     HepMC::GenEvent::particle_const_iterator trkItr;
00068   };
00069 
00070   struct propagatedGenParticleID {
00071     propagatedGenParticleID() {
00072       ok=okECAL=okHCAL=false;
00073       charge=pdgId=0;
00074     }
00075     bool                                  ok, okECAL, okHCAL;
00076     DetId                                 detIdECAL, detIdHCAL, detIdEHCAL;
00077     GlobalPoint                           pointECAL, pointHCAL;
00078     GlobalVector                          directionECAL, directionHCAL;
00079     int                                   charge, pdgId;
00080     reco::GenParticleCollection::const_iterator trkItr;
00081   };
00082 
00083   struct trackAtOrigin {
00084     trackAtOrigin() {ok=false;}
00085     bool                                  ok;
00086     int                                   charge;
00087     GlobalPoint                           position;
00088     GlobalVector                          momentum;
00089   };
00090 
00091   // Returns a vector of DetID's of closest cell on the ECAL/HCAL surface of
00092   // all the tracks in the collection. Also saves a boolean if extrapolation
00093   // is satisfactory
00094   std::vector<spr::propagatedTrackID> propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection, const CaloGeometry* geo, const MagneticField* bField, std::string & theTrackQuality, bool debug=false);
00095   void propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection, const CaloGeometry* geo, const MagneticField* bField, std::string & theTrackQuality, std::vector<spr::propagatedTrackID>& vdets, bool debug=false);
00096   void propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection, const CaloGeometry* geo, const MagneticField* bField, std::string & theTrackQuality, std::vector<spr::propagatedTrackDirection>& trkDir, bool debug=false);
00097   std::vector<spr::propagatedGenTrackID> propagateCALO(const HepMC::GenEvent * genEvent, edm::ESHandle<ParticleDataTable>& pdt, const CaloGeometry* geo, const MagneticField* bField, double etaMax=3.0, bool debug=false);
00098   std::vector<spr::propagatedGenParticleID> propagateCALO(edm::Handle<reco::GenParticleCollection>& genParticles, edm::ESHandle<ParticleDataTable>& pdt, const CaloGeometry* geo, const MagneticField* bField, double etaMax=3.0, bool debug=false);
00099   spr::propagatedTrackDirection propagateCALO(unsigned int thisTrk, edm::Handle<edm::SimTrackContainer>& SimTk, edm::Handle<edm::SimVertexContainer>& SimVtx, const CaloGeometry* geo, const MagneticField* bField, bool debug=false);
00100 
00101   // Propagate tracks to the ECAL surface and optionally returns the 
00102   // extrapolated point (and the track direction at point of extrapolation)
00103   spr::propagatedTrack propagateTrackToECAL(const reco::Track*, const MagneticField*, bool debug=false);
00104   spr::propagatedTrack propagateTrackToECAL(unsigned int thisTrk, edm::Handle<edm::SimTrackContainer>& SimTk, edm::Handle<edm::SimVertexContainer>& SimVtx, const MagneticField*, bool debug=false);
00105   std::pair<math::XYZPoint,bool> propagateECAL(const reco::Track*, const MagneticField*, bool debug=false);
00106   std::pair<math::XYZPoint,bool> propagateECAL(const GlobalPoint& vertex, const GlobalVector& momentum, int charge, const MagneticField*, bool debug=false);
00107 
00108   // Propagate tracks to the HCAL surface and optionally returns the 
00109   // extrapolated point (and the track direction at point of extrapolation)
00110   spr::propagatedTrack propagateTrackToHCAL(const reco::Track*, const MagneticField*, bool debug=false);
00111   spr::propagatedTrack propagateTrackToHCAL(unsigned int thisTrk, edm::Handle<edm::SimTrackContainer>& SimTk, edm::Handle<edm::SimVertexContainer>& SimVtx, const MagneticField*, bool debug=false);
00112   std::pair<math::XYZPoint,bool> propagateHCAL(const reco::Track*, const MagneticField*, bool debug=false);
00113   std::pair<math::XYZPoint,bool> propagateHCAL(const GlobalPoint& vertex, const GlobalVector& momentum, int charge, const MagneticField*, bool debug=false);
00114 
00115   // Propagate the track to the end of the tracker and returns the extrapolated
00116   // point and optionally the length of the track upto the end
00117   std::pair<math::XYZPoint,bool> propagateTracker(const reco::Track*, const MagneticField*, bool debug=false);
00118   std::pair<math::XYZPoint,double> propagateTrackerEnd(const reco::Track*, const MagneticField*, bool debug=false);
00119 
00120   spr::propagatedTrack propagateCalo(const GlobalPoint& vertex, const GlobalVector& momentum, int charge, const MagneticField*, float zdist, float radius, float corner, bool debug=false);
00121 
00122   // Gives the vertex and momentum of a SimTrack
00123   spr::trackAtOrigin simTrackAtOrigin(unsigned int thisTrk, edm::Handle<edm::SimTrackContainer>& SimTk, edm::Handle<edm::SimVertexContainer>& SimVtx, bool debug=false);
00124 
00125 }
00126 #endif