Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:29:24

0001 #ifndef CalibrationIsolatedParticlesCaloPropagateTrack_h
0002 #define CalibrationIsolatedParticlesCaloPropagateTrack_h
0003 
0004 #include <cmath>
0005 #include <vector>
0006 #include <string>
0007 
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0013 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0014 #include "DataFormats/TrackReco/interface/Track.h"
0015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0016 
0017 //sim track
0018 #include "SimDataFormats/Track/interface/SimTrack.h"
0019 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0020 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0021 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0022 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0023 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
0024 
0025 #include "MagneticField/Engine/interface/MagneticField.h"
0026 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0027 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0028 
0029 namespace spr {
0030 
0031   struct propagatedTrack {
0032     propagatedTrack() { ok = false; }
0033     bool ok;
0034     math::XYZPoint point;
0035     GlobalVector direction;
0036   };
0037 
0038   struct propagatedTrackID {
0039     propagatedTrackID() {
0040       ok = false;
0041       okECAL = false;
0042       okHCAL = false;
0043     }
0044     bool ok, okECAL, okHCAL;
0045     DetId detIdECAL, detIdHCAL, detIdEHCAL;
0046     double etaECAL, etaHCAL;
0047     double phiECAL, phiHCAL;
0048     reco::TrackCollection::const_iterator trkItr;
0049   };
0050 
0051   struct propagatedTrackDirection {
0052     propagatedTrackDirection() {
0053       ok = false;
0054       okECAL = false;
0055       okHCAL = false;
0056     }
0057     bool ok, okECAL, okHCAL;
0058     DetId detIdECAL, detIdHCAL, detIdEHCAL;
0059     GlobalPoint pointECAL, pointHCAL;
0060     GlobalVector directionECAL, directionHCAL;
0061     reco::TrackCollection::const_iterator trkItr;
0062   };
0063 
0064   struct propagatedGenTrackID {
0065     propagatedGenTrackID() {
0066       ok = okECAL = okHCAL = false;
0067       charge = pdgId = 0;
0068     }
0069     bool ok, okECAL, okHCAL;
0070     DetId detIdECAL, detIdHCAL, detIdEHCAL;
0071     GlobalPoint pointECAL, pointHCAL;
0072     GlobalVector directionECAL, directionHCAL;
0073     int charge, pdgId;
0074     HepMC::GenEvent::particle_const_iterator trkItr;
0075   };
0076 
0077   struct propagatedGenParticleID {
0078     propagatedGenParticleID() {
0079       ok = okECAL = okHCAL = false;
0080       charge = pdgId = 0;
0081     }
0082     bool ok, okECAL, okHCAL;
0083     DetId detIdECAL, detIdHCAL, detIdEHCAL;
0084     GlobalPoint pointECAL, pointHCAL;
0085     GlobalVector directionECAL, directionHCAL;
0086     int charge, pdgId;
0087     reco::GenParticleCollection::const_iterator trkItr;
0088   };
0089 
0090   struct trackAtOrigin {
0091     trackAtOrigin() { ok = false; }
0092     bool ok;
0093     int charge;
0094     GlobalPoint position;
0095     GlobalVector momentum;
0096   };
0097 
0098   // Returns a vector of DetID's of closest cell on the ECAL/HCAL surface of
0099   // all the tracks in the collection. Also saves a boolean if extrapolation
0100   // is satisfactory
0101   std::vector<spr::propagatedTrackID> propagateCosmicCALO(edm::Handle<reco::TrackCollection>& trkCollection,
0102                                                           const CaloGeometry* geo,
0103                                                           const MagneticField* bField,
0104                                                           const std::string& theTrackQuality,
0105                                                           bool debug = false);
0106   std::vector<spr::propagatedTrackID> propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection,
0107                                                     const CaloGeometry* geo,
0108                                                     const MagneticField* bField,
0109                                                     const std::string& theTrackQuality,
0110                                                     bool debug = false);
0111   void propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection,
0112                      const CaloGeometry* geo,
0113                      const MagneticField* bField,
0114                      const std::string& theTrackQuality,
0115                      std::vector<spr::propagatedTrackID>& vdets,
0116                      bool debug = false);
0117   void propagateCALO(edm::Handle<reco::TrackCollection>& trkCollection,
0118                      const CaloGeometry* geo,
0119                      const MagneticField* bField,
0120                      const std::string& theTrackQuality,
0121                      std::vector<spr::propagatedTrackDirection>& trkDir,
0122                      bool debug = false);
0123   spr::propagatedTrackID propagateCALO(const reco::Track*,
0124                                        const CaloGeometry* geo,
0125                                        const MagneticField* bField,
0126                                        bool debug = false);
0127   std::vector<spr::propagatedGenTrackID> propagateCALO(const HepMC::GenEvent* genEvent,
0128                                                        const ParticleDataTable* pdt,
0129                                                        const CaloGeometry* geo,
0130                                                        const MagneticField* bField,
0131                                                        double etaMax = 3.0,
0132                                                        bool debug = false);
0133   std::vector<spr::propagatedGenParticleID> propagateCALO(edm::Handle<reco::GenParticleCollection>& genParticles,
0134                                                           const ParticleDataTable* pdt,
0135                                                           const CaloGeometry* geo,
0136                                                           const MagneticField* bField,
0137                                                           double etaMax = 3.0,
0138                                                           bool debug = false);
0139   spr::propagatedTrackDirection propagateCALO(unsigned int thisTrk,
0140                                               edm::Handle<edm::SimTrackContainer>& SimTk,
0141                                               edm::Handle<edm::SimVertexContainer>& SimVtx,
0142                                               const CaloGeometry* geo,
0143                                               const MagneticField* bField,
0144                                               bool debug = false);
0145   spr::propagatedTrackDirection propagateHCALBack(unsigned int thisTrk,
0146                                                   edm::Handle<edm::SimTrackContainer>& SimTk,
0147                                                   edm::Handle<edm::SimVertexContainer>& SimVtx,
0148                                                   const CaloGeometry* geo,
0149                                                   const MagneticField* bField,
0150                                                   bool debug = false);
0151   std::pair<bool, HcalDetId> propagateHCALBack(const reco::Track*,
0152                                                const CaloGeometry* geo,
0153                                                const MagneticField* bField,
0154                                                bool debug = false);
0155 
0156   // Propagate tracks to the ECAL surface and optionally returns the
0157   // extrapolated point (and the track direction at point of extrapolation)
0158   spr::propagatedTrack propagateTrackToECAL(const reco::Track*, const MagneticField*, bool debug = false);
0159   spr::propagatedTrack propagateTrackToECAL(unsigned int thisTrk,
0160                                             edm::Handle<edm::SimTrackContainer>& SimTk,
0161                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
0162                                             const MagneticField*,
0163                                             bool debug = false);
0164   std::pair<math::XYZPoint, bool> propagateECAL(const reco::Track*, const MagneticField*, bool debug = false);
0165   std::pair<DetId, bool> propagateIdECAL(const HcalDetId& id,
0166                                          const CaloGeometry* geo,
0167                                          const MagneticField*,
0168                                          bool debug = false);
0169   std::pair<math::XYZPoint, bool> propagateECAL(
0170       const GlobalPoint& vertex, const GlobalVector& momentum, int charge, const MagneticField*, bool debug = false);
0171 
0172   // Propagate tracks to the HCAL surface and optionally returns the
0173   // extrapolated point (and the track direction at point of extrapolation)
0174   spr::propagatedTrack propagateTrackToHCAL(const reco::Track*, const MagneticField*, bool debug = false);
0175   spr::propagatedTrack propagateTrackToHCAL(unsigned int thisTrk,
0176                                             edm::Handle<edm::SimTrackContainer>& SimTk,
0177                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
0178                                             const MagneticField*,
0179                                             bool debug = false);
0180   std::pair<math::XYZPoint, bool> propagateHCAL(const reco::Track*, const MagneticField*, bool debug = false);
0181   std::pair<math::XYZPoint, bool> propagateHCAL(
0182       const GlobalPoint& vertex, const GlobalVector& momentum, int charge, const MagneticField*, bool debug = false);
0183 
0184   // Propagate the track to the end of the tracker and returns the extrapolated
0185   // point and optionally the length of the track upto the end
0186   std::pair<math::XYZPoint, bool> propagateTracker(const reco::Track*, const MagneticField*, bool debug = false);
0187   std::pair<math::XYZPoint, double> propagateTrackerEnd(const reco::Track*, const MagneticField*, bool debug = false);
0188 
0189   spr::propagatedTrack propagateCalo(const GlobalPoint& vertex,
0190                                      const GlobalVector& momentum,
0191                                      int charge,
0192                                      const MagneticField*,
0193                                      float zdist,
0194                                      float radius,
0195                                      float corner,
0196                                      bool debug = false);
0197 
0198   // Gives the vertex and momentum of a SimTrack
0199   spr::trackAtOrigin simTrackAtOrigin(unsigned int thisTrk,
0200                                       edm::Handle<edm::SimTrackContainer>& SimTk,
0201                                       edm::Handle<edm::SimVertexContainer>& SimVtx,
0202                                       bool debug = false);
0203 
0204   //Get HcalDetID's for two values of r/z
0205   bool propagateHCAL(const reco::Track* track,
0206                      const CaloGeometry* geo,
0207                      const MagneticField* bField,
0208                      bool typeRZ,
0209                      const std::pair<double, double> rz,
0210                      bool debug);
0211   bool propagateHCAL(unsigned int thisTrk,
0212                      edm::Handle<edm::SimTrackContainer>& SimTk,
0213                      edm::Handle<edm::SimVertexContainer>& SimVtx,
0214                      const CaloGeometry* geo,
0215                      const MagneticField* bField,
0216                      bool typeRZ,
0217                      const std::pair<double, double> rz,
0218                      bool debug);
0219   std::pair<HcalDetId, HcalDetId> propagateHCAL(const CaloGeometry* geo,
0220                                                 const MagneticField* bField,
0221                                                 const GlobalPoint& vertex,
0222                                                 const GlobalVector& momentum,
0223                                                 int charge,
0224                                                 bool typeRZ,
0225                                                 const std::pair<double, double> rz,
0226                                                 bool debug);
0227 
0228 }  // namespace spr
0229 #endif