Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:43:23

0001 /* 
0002 Functions to give the details of parent track of SimHits.
0003 
0004 Authors:  Seema Sharma, Sunanda Banerjee
0005 Created: August 2009
0006 */
0007 
0008 #ifndef CalibrationIsolatedParticlesCaloSimInfo_h
0009 #define CalibrationIsolatedParticlesCaloSimInfo_h
0010 
0011 // system include files
0012 #include <memory>
0013 #include <map>
0014 #include <vector>
0015 #include <string>
0016 
0017 // user include files
0018 #include "FWCore/Framework/interface/Frameworkfwd.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 
0021 #include "DataFormats/Common/interface/Handle.h"
0022 #include "DataFormats/TrackReco/interface/Track.h"
0023 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0024 #include "DataFormats/DetId/interface/DetId.h"
0025 #include "DataFormats/Candidate/interface/Candidate.h"
0026 
0027 #include "SimDataFormats/Track/interface/SimTrack.h"
0028 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0029 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0030 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0031 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
0032 
0033 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0034 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0035 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0036 #include "RecoCaloTools/Navigation/interface/CaloTowerNavigator.h"
0037 #include "Calibration/IsolatedParticles/interface/MatrixECALDetIds.h"
0038 
0039 namespace spr {
0040 
0041   struct caloSimInfo {
0042     caloSimInfo() { eMatched = eGamma = eNeutralHad = eChargedHad = eRest = eTotal = pdgMatched = 0; }
0043     double pdgMatched;
0044     double eMatched;
0045     double eGamma;
0046     double eNeutralHad;
0047     double eChargedHad;
0048     double eRest;
0049     double eTotal;
0050   };
0051 
0052   struct energyMap {
0053     energyMap() { pdgId = 0; }
0054     int pdgId;
0055     std::vector<std::pair<DetId, double> > matched;
0056     std::vector<std::pair<DetId, double> > gamma;
0057     std::vector<std::pair<DetId, double> > charged;
0058     std::vector<std::pair<DetId, double> > neutral;
0059     std::vector<std::pair<DetId, double> > rest;
0060     std::vector<std::pair<DetId, double> > all;
0061   };
0062 
0063   // takes the EcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc. in a symmetric matrix (2*ieta+1)*(2*iphi+1)
0064   template <typename T>
0065   void eECALSimInfo(const edm::Event&,
0066                     const DetId& det,
0067                     const CaloGeometry* geo,
0068                     const CaloTopology* caloTopology,
0069                     edm::Handle<T>& hitsEB,
0070                     edm::Handle<T>& hitsEE,
0071                     edm::Handle<edm::SimTrackContainer>& SimTk,
0072                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0073                     const reco::Track* pTrack,
0074                     TrackerHitAssociator& associate,
0075                     int ieta,
0076                     int iphi,
0077                     caloSimInfo& info,
0078                     double timeCut = 150,
0079                     bool debug = false);
0080 
0081   template <typename T>
0082   std::map<std::string, double> eECALSimInfo(const edm::Event&,
0083                                              const DetId& det,
0084                                              const CaloGeometry* geo,
0085                                              const CaloTopology* caloTopology,
0086                                              edm::Handle<T>& hitsEB,
0087                                              edm::Handle<T>& hitsEE,
0088                                              edm::Handle<edm::SimTrackContainer>& SimTk,
0089                                              edm::Handle<edm::SimVertexContainer>& SimVtx,
0090                                              const reco::Track* pTrack,
0091                                              TrackerHitAssociator& associate,
0092                                              int ieta,
0093                                              int iphi,
0094                                              double timeCut = 150,
0095                                              bool debug = false);
0096 
0097   // takes the EcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc. in an symmetric matrix (ietaE+ietaW+1)*(iphiN+iphiS+1)
0098   template <typename T>
0099   void eECALSimInfo(const edm::Event&,
0100                     const DetId& det,
0101                     const CaloGeometry* geo,
0102                     const CaloTopology* caloTopology,
0103                     edm::Handle<T>& hitsEB,
0104                     edm::Handle<T>& hitsEE,
0105                     edm::Handle<edm::SimTrackContainer>& SimTk,
0106                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0107                     const reco::Track* pTrack,
0108                     TrackerHitAssociator& associate,
0109                     int ietaE,
0110                     int ietaW,
0111                     int iphiN,
0112                     int iphiS,
0113                     caloSimInfo& info,
0114                     double timeCut = 150,
0115                     bool debug = false);
0116 
0117   // takes the HcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc. in a symmetric matrix (2*ieta+1)*(2*iphi+1)
0118   template <typename T>
0119   std::map<std::string, double> eHCALSimInfo(const edm::Event&,
0120                                              const HcalTopology* topology,
0121                                              const DetId& det,
0122                                              const CaloGeometry* geo,
0123                                              edm::Handle<T>& hits,
0124                                              edm::Handle<edm::SimTrackContainer>& SimTk,
0125                                              edm::Handle<edm::SimVertexContainer>& SimVtx,
0126                                              const reco::Track* pTrack,
0127                                              TrackerHitAssociator& associate,
0128                                              int ieta,
0129                                              int iphi,
0130                                              double timeCut = 150,
0131                                              bool includeHO = false,
0132                                              bool debug = false);
0133   template <typename T>
0134   void eHCALSimInfo(const edm::Event&,
0135                     const HcalTopology* topology,
0136                     const DetId& det,
0137                     const CaloGeometry* geo,
0138                     edm::Handle<T>& hits,
0139                     edm::Handle<edm::SimTrackContainer>& SimTk,
0140                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0141                     const reco::Track* pTrack,
0142                     TrackerHitAssociator& associate,
0143                     int ieta,
0144                     int iphi,
0145                     caloSimInfo& info,
0146                     double timeCut = 150,
0147                     bool includeHO = false,
0148                     bool debug = false);
0149 
0150   //takes the HcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc. in an symmetric matrix (ietaE+ietaW+1)*(iphiN+iphiS+1)
0151   template <typename T>
0152   void eHCALSimInfo(const edm::Event&,
0153                     const HcalTopology* topology,
0154                     const DetId& det,
0155                     const CaloGeometry* geo,
0156                     edm::Handle<T>& hits,
0157                     edm::Handle<edm::SimTrackContainer>& SimTk,
0158                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0159                     const reco::Track* pTrack,
0160                     TrackerHitAssociator& associate,
0161                     int ietaE,
0162                     int ietaW,
0163                     int iphiN,
0164                     int iphiS,
0165                     caloSimInfo& info,
0166                     double timeCut = 150,
0167                     bool includeHO = false,
0168                     bool debug = false);
0169 
0170   // takes the HcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc. in a symmetric matrix (2*ieta+1)*(2*iphi+1) and also a multiplicity vector
0171   template <typename T>
0172   std::map<std::string, double> eHCALSimInfo(const edm::Event& iEvent,
0173                                              const HcalTopology* topology,
0174                                              const DetId& det,
0175                                              edm::Handle<T>& hits,
0176                                              edm::Handle<edm::SimTrackContainer>& SimTk,
0177                                              edm::Handle<edm::SimVertexContainer>& SimVtx,
0178                                              const reco::Track* pTrack,
0179                                              TrackerHitAssociator& associate,
0180                                              int ieta,
0181                                              int iphi,
0182                                              std::vector<int>& multiplicityVector,
0183                                              bool debug = false);
0184 
0185   // Actual function which does the matching of SimHits to SimTracks using geantTrackId
0186   template <typename T>
0187   void eCaloSimInfo(std::vector<DetId> vdets,
0188                     const CaloGeometry* geo,
0189                     edm::Handle<T>& hitsEB,
0190                     edm::Handle<T>& hitsEE,
0191                     edm::Handle<edm::SimTrackContainer>& SimTk,
0192                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0193                     edm::SimTrackContainer::const_iterator trkInfo,
0194                     caloSimInfo& info,
0195                     double timeCut = 150,
0196                     bool debug = false);
0197   template <typename T>
0198   void eCaloSimInfo(const CaloGeometry* geo,
0199                     edm::Handle<T>& hits,
0200                     edm::Handle<edm::SimTrackContainer>& SimTk,
0201                     edm::Handle<edm::SimVertexContainer>& SimVtx,
0202                     std::vector<typename T::const_iterator> hit,
0203                     edm::SimTrackContainer::const_iterator trkInfo,
0204                     caloSimInfo& info,
0205                     double timeCut = 150,
0206                     bool includeHO = false,
0207                     bool debug = false);
0208   std::map<std::string, double> eCaloSimInfo(caloSimInfo& info);
0209 
0210   // Returns total energy of CaloSimHits which originate from the matching SimTrack
0211   template <typename T>
0212   double eCaloSimInfo(const edm::Event&,
0213                       const CaloGeometry* geo,
0214                       edm::Handle<T>& hits,
0215                       edm::Handle<edm::SimTrackContainer>& SimTk,
0216                       edm::Handle<edm::SimVertexContainer>& SimVtx,
0217                       const reco::Track* pTrack,
0218                       TrackerHitAssociator& associate,
0219                       double timeCut = 150,
0220                       bool includeHO = false,
0221                       bool debug = false);
0222 
0223   template <typename T>
0224   double eCaloSimInfo(const edm::Event&,
0225                       const CaloGeometry* geo,
0226                       edm::Handle<T>& hitsEB,
0227                       edm::Handle<T>& hitsEE,
0228                       edm::Handle<edm::SimTrackContainer>& SimTk,
0229                       edm::Handle<edm::SimVertexContainer>& SimVtx,
0230                       const reco::Track* pTrack,
0231                       TrackerHitAssociator& associate,
0232                       double timeCut = 150,
0233                       bool debug = false);
0234 
0235   template <typename T>
0236   std::map<std::string, double> eCaloSimInfo(edm::Handle<T>& hits,
0237                                              edm::Handle<edm::SimTrackContainer>& SimTk,
0238                                              edm::Handle<edm::SimVertexContainer>& SimVtx,
0239                                              std::vector<typename T::const_iterator> hit,
0240                                              edm::SimTrackContainer::const_iterator trkInfo,
0241                                              std::vector<int>& multiplicityVector,
0242                                              bool debug = false);
0243 
0244   double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug = false);
0245 
0246   // takes the EcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc.
0247   template <typename T>
0248   std::map<std::string, double> eECALSimInfo(const edm::Event&,
0249                                              CaloNavigator<DetId>& navigator,
0250                                              const CaloGeometry* geo,
0251                                              edm::Handle<T>& hits,
0252                                              edm::Handle<edm::SimTrackContainer>& SimTk,
0253                                              edm::Handle<edm::SimVertexContainer>& SimVtx,
0254                                              const reco::Track* pTrack,
0255                                              TrackerHitAssociator& associate,
0256                                              int ieta,
0257                                              int iphi,
0258                                              double timeCut = 150,
0259                                              bool debug = false);
0260 
0261   template <typename T>
0262   std::map<std::string, double> eECALSimInfoTotal(const edm::Event&,
0263                                                   const DetId& det,
0264                                                   const CaloGeometry* geo,
0265                                                   const CaloTopology* caloTopology,
0266                                                   edm::Handle<T>& hitsEB,
0267                                                   edm::Handle<T>& hitsEE,
0268                                                   edm::Handle<edm::SimTrackContainer>& SimTk,
0269                                                   edm::Handle<edm::SimVertexContainer>& SimVtx,
0270                                                   const reco::Track* pTrack,
0271                                                   TrackerHitAssociator& associate,
0272                                                   int ieta,
0273                                                   int iphi,
0274                                                   int itry = -1,
0275                                                   double timeCut = 150,
0276                                                   bool debug = false);
0277 
0278   template <typename T>
0279   energyMap eECALSimInfoMatrix(const edm::Event&,
0280                                const DetId& det,
0281                                const CaloGeometry* geo,
0282                                const CaloTopology* caloTopology,
0283                                edm::Handle<T>& hitsEB,
0284                                edm::Handle<T>& hitsEE,
0285                                edm::Handle<edm::SimTrackContainer>& SimTk,
0286                                edm::Handle<edm::SimVertexContainer>& SimVtx,
0287                                const reco::Track* pTrack,
0288                                TrackerHitAssociator& associate,
0289                                int ieta,
0290                                int iphi,
0291                                double timeCut = 150,
0292                                bool debug = false);
0293 
0294   // takes the HcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc.
0295   template <typename T>
0296   std::map<std::string, double> eHCALSimInfoTotal(const edm::Event&,
0297                                                   const HcalTopology* topology,
0298                                                   const DetId& det,
0299                                                   const CaloGeometry* geo,
0300                                                   edm::Handle<T>& hits,
0301                                                   edm::Handle<edm::SimTrackContainer>& SimTk,
0302                                                   edm::Handle<edm::SimVertexContainer>& SimVtx,
0303                                                   const reco::Track* pTrack,
0304                                                   TrackerHitAssociator& associate,
0305                                                   int ieta,
0306                                                   int iphi,
0307                                                   int itry = -1,
0308                                                   double timeCut = 150,
0309                                                   bool includeHO = false,
0310                                                   bool debug = false);
0311 
0312   template <typename T>
0313   energyMap eHCALSimInfoMatrix(const edm::Event&,
0314                                const HcalTopology* topology,
0315                                const DetId& det,
0316                                const CaloGeometry* geo,
0317                                edm::Handle<T>& hits,
0318                                edm::Handle<edm::SimTrackContainer>& SimTk,
0319                                edm::Handle<edm::SimVertexContainer>& SimVtx,
0320                                const reco::Track* pTrack,
0321                                TrackerHitAssociator& associate,
0322                                int ieta,
0323                                int iphi,
0324                                double timeCut = 150,
0325                                bool includeHO = false,
0326                                bool debug = false);
0327 
0328   // Actual function which does the matching of SimHits to SimTracks using geantTrackId
0329   template <typename T>
0330   energyMap caloSimInfoMatrix(const CaloGeometry* geo,
0331                               edm::Handle<T>& hits,
0332                               edm::Handle<edm::SimTrackContainer>& SimTk,
0333                               edm::Handle<edm::SimVertexContainer>& SimVtx,
0334                               std::vector<typename T::const_iterator> hit,
0335                               edm::SimTrackContainer::const_iterator trkInfo,
0336                               double timeCut = 150,
0337                               bool includeHO = false,
0338                               bool debug = false);
0339 
0340   // Functions to study the Hits for which history cannot be traced back
0341   template <typename T>
0342   std::vector<typename T::const_iterator> missedECALHits(const edm::Event&,
0343                                                          CaloNavigator<DetId>& navigator,
0344                                                          edm::Handle<T>& hits,
0345                                                          edm::Handle<edm::SimTrackContainer>& SimTk,
0346                                                          edm::Handle<edm::SimVertexContainer>& SimVtx,
0347                                                          const reco::Track* pTrack,
0348                                                          TrackerHitAssociator& associate,
0349                                                          int ieta,
0350                                                          int iphi,
0351                                                          bool flag,
0352                                                          bool debug = false);
0353 
0354   template <typename T>
0355   std::vector<typename T::const_iterator> missedHCALHits(const edm::Event&,
0356                                                          const HcalTopology* topology,
0357                                                          const DetId& det,
0358                                                          edm::Handle<T>& hits,
0359                                                          edm::Handle<edm::SimTrackContainer>& SimTk,
0360                                                          edm::Handle<edm::SimVertexContainer>& SimVtx,
0361                                                          const reco::Track* pTrack,
0362                                                          TrackerHitAssociator& associate,
0363                                                          int ieta,
0364                                                          int iphi,
0365                                                          bool flag,
0366                                                          bool includeHO = false,
0367                                                          bool debug = false);
0368 
0369   template <typename T>
0370   std::vector<typename T::const_iterator> missedCaloHits(edm::Handle<T>& hits,
0371                                                          std::vector<int> matchedId,
0372                                                          std::vector<typename T::const_iterator> caloHits,
0373                                                          bool flag,
0374                                                          bool includeHO = false,
0375                                                          bool debug = false);
0376 }  // namespace spr
0377 
0378 #include "Calibration/IsolatedParticles/interface/CaloSimInfo.icc"
0379 #endif