caloSimInfo

energyMap

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
/* 
Functions to give the details of parent track of SimHits.

Authors:  Seema Sharma, Sunanda Banerjee
Created: August 2009
*/

#ifndef CalibrationIsolatedParticlesCaloSimInfo_h
#define CalibrationIsolatedParticlesCaloSimInfo_h

// system include files
#include <memory>
#include <map>
#include <vector>
#include <string>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/Candidate/interface/Candidate.h"

#include "SimDataFormats/Track/interface/SimTrack.h"
#include "SimDataFormats/Track/interface/SimTrackContainer.h"
#include "SimDataFormats/Vertex/interface/SimVertex.h"
#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"

#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "RecoCaloTools/Navigation/interface/CaloTowerNavigator.h"
#include "Calibration/IsolatedParticles/interface/MatrixECALDetIds.h"

namespace spr {

  struct caloSimInfo {
    caloSimInfo() { eMatched = eGamma = eNeutralHad = eChargedHad = eRest = eTotal = pdgMatched = 0; }
    double pdgMatched;
    double eMatched;
    double eGamma;
    double eNeutralHad;
    double eChargedHad;
    double eRest;
    double eTotal;
  };

  struct energyMap {
    energyMap() { pdgId = 0; }
    int pdgId;
    std::vector<std::pair<DetId, double> > matched;
    std::vector<std::pair<DetId, double> > gamma;
    std::vector<std::pair<DetId, double> > charged;
    std::vector<std::pair<DetId, double> > neutral;
    std::vector<std::pair<DetId, double> > rest;
    std::vector<std::pair<DetId, double> > all;
  };

  // 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)
  template <typename T>
  void eECALSimInfo(const edm::Event&,
                    const DetId& det,
                    const CaloGeometry* geo,
                    const CaloTopology* caloTopology,
                    edm::Handle<T>& hitsEB,
                    edm::Handle<T>& hitsEE,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    const reco::Track* pTrack,
                    TrackerHitAssociator& associate,
                    int ieta,
                    int iphi,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool debug = false);

  template <typename T>
  std::map<std::string, double> eECALSimInfo(const edm::Event&,
                                             const DetId& det,
                                             const CaloGeometry* geo,
                                             const CaloTopology* caloTopology,
                                             edm::Handle<T>& hitsEB,
                                             edm::Handle<T>& hitsEE,
                                             edm::Handle<edm::SimTrackContainer>& SimTk,
                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
                                             const reco::Track* pTrack,
                                             TrackerHitAssociator& associate,
                                             int ieta,
                                             int iphi,
                                             double timeCut = 150,
                                             bool debug = false);

  // 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)
  template <typename T>
  void eECALSimInfo(const edm::Event&,
                    const DetId& det,
                    const CaloGeometry* geo,
                    const CaloTopology* caloTopology,
                    edm::Handle<T>& hitsEB,
                    edm::Handle<T>& hitsEE,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    const reco::Track* pTrack,
                    TrackerHitAssociator& associate,
                    int ietaE,
                    int ietaW,
                    int iphiN,
                    int iphiS,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool debug = false);

  // 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)
  template <typename T>
  std::map<std::string, double> eHCALSimInfo(const edm::Event&,
                                             const HcalTopology* topology,
                                             const DetId& det,
                                             const CaloGeometry* geo,
                                             edm::Handle<T>& hits,
                                             edm::Handle<edm::SimTrackContainer>& SimTk,
                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
                                             const reco::Track* pTrack,
                                             TrackerHitAssociator& associate,
                                             int ieta,
                                             int iphi,
                                             double timeCut = 150,
                                             bool includeHO = false,
                                             bool debug = false);
  template <typename T>
  void eHCALSimInfo(const edm::Event&,
                    const HcalTopology* topology,
                    const DetId& det,
                    const CaloGeometry* geo,
                    edm::Handle<T>& hits,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    const reco::Track* pTrack,
                    TrackerHitAssociator& associate,
                    int ieta,
                    int iphi,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool includeHO = false,
                    bool debug = false);

  //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)
  template <typename T>
  void eHCALSimInfo(const edm::Event&,
                    const HcalTopology* topology,
                    const DetId& det,
                    const CaloGeometry* geo,
                    edm::Handle<T>& hits,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    const reco::Track* pTrack,
                    TrackerHitAssociator& associate,
                    int ietaE,
                    int ietaW,
                    int iphiN,
                    int iphiS,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool includeHO = false,
                    bool debug = false);

  // 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
  template <typename T>
  std::map<std::string, double> eHCALSimInfo(const edm::Event& iEvent,
                                             const HcalTopology* topology,
                                             const DetId& det,
                                             edm::Handle<T>& hits,
                                             edm::Handle<edm::SimTrackContainer>& SimTk,
                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
                                             const reco::Track* pTrack,
                                             TrackerHitAssociator& associate,
                                             int ieta,
                                             int iphi,
                                             std::vector<int>& multiplicityVector,
                                             bool debug = false);

  // Actual function which does the matching of SimHits to SimTracks using geantTrackId
  template <typename T>
  void eCaloSimInfo(std::vector<DetId> vdets,
                    const CaloGeometry* geo,
                    edm::Handle<T>& hitsEB,
                    edm::Handle<T>& hitsEE,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    edm::SimTrackContainer::const_iterator trkInfo,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool debug = false);
  template <typename T>
  void eCaloSimInfo(const CaloGeometry* geo,
                    edm::Handle<T>& hits,
                    edm::Handle<edm::SimTrackContainer>& SimTk,
                    edm::Handle<edm::SimVertexContainer>& SimVtx,
                    std::vector<typename T::const_iterator> hit,
                    edm::SimTrackContainer::const_iterator trkInfo,
                    caloSimInfo& info,
                    double timeCut = 150,
                    bool includeHO = false,
                    bool debug = false);
  std::map<std::string, double> eCaloSimInfo(caloSimInfo& info);

  // Returns total energy of CaloSimHits which originate from the matching SimTrack
  template <typename T>
  double eCaloSimInfo(const edm::Event&,
                      const CaloGeometry* geo,
                      edm::Handle<T>& hits,
                      edm::Handle<edm::SimTrackContainer>& SimTk,
                      edm::Handle<edm::SimVertexContainer>& SimVtx,
                      const reco::Track* pTrack,
                      TrackerHitAssociator& associate,
                      double timeCut = 150,
                      bool includeHO = false,
                      bool debug = false);

  template <typename T>
  double eCaloSimInfo(const edm::Event&,
                      const CaloGeometry* geo,
                      edm::Handle<T>& hitsEB,
                      edm::Handle<T>& hitsEE,
                      edm::Handle<edm::SimTrackContainer>& SimTk,
                      edm::Handle<edm::SimVertexContainer>& SimVtx,
                      const reco::Track* pTrack,
                      TrackerHitAssociator& associate,
                      double timeCut = 150,
                      bool debug = false);

  template <typename T>
  std::map<std::string, double> eCaloSimInfo(edm::Handle<T>& hits,
                                             edm::Handle<edm::SimTrackContainer>& SimTk,
                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
                                             std::vector<typename T::const_iterator> hit,
                                             edm::SimTrackContainer::const_iterator trkInfo,
                                             std::vector<int>& multiplicityVector,
                                             bool debug = false);

  double timeOfFlight(DetId id, const CaloGeometry* geo, bool debug = false);

  // takes the EcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc.
  template <typename T>
  std::map<std::string, double> eECALSimInfo(const edm::Event&,
                                             CaloNavigator<DetId>& navigator,
                                             const CaloGeometry* geo,
                                             edm::Handle<T>& hits,
                                             edm::Handle<edm::SimTrackContainer>& SimTk,
                                             edm::Handle<edm::SimVertexContainer>& SimVtx,
                                             const reco::Track* pTrack,
                                             TrackerHitAssociator& associate,
                                             int ieta,
                                             int iphi,
                                             double timeCut = 150,
                                             bool debug = false);

  template <typename T>
  std::map<std::string, double> eECALSimInfoTotal(const edm::Event&,
                                                  const DetId& det,
                                                  const CaloGeometry* geo,
                                                  const CaloTopology* caloTopology,
                                                  edm::Handle<T>& hitsEB,
                                                  edm::Handle<T>& hitsEE,
                                                  edm::Handle<edm::SimTrackContainer>& SimTk,
                                                  edm::Handle<edm::SimVertexContainer>& SimVtx,
                                                  const reco::Track* pTrack,
                                                  TrackerHitAssociator& associate,
                                                  int ieta,
                                                  int iphi,
                                                  int itry = -1,
                                                  double timeCut = 150,
                                                  bool debug = false);

  template <typename T>
  energyMap eECALSimInfoMatrix(const edm::Event&,
                               const DetId& det,
                               const CaloGeometry* geo,
                               const CaloTopology* caloTopology,
                               edm::Handle<T>& hitsEB,
                               edm::Handle<T>& hitsEE,
                               edm::Handle<edm::SimTrackContainer>& SimTk,
                               edm::Handle<edm::SimVertexContainer>& SimVtx,
                               const reco::Track* pTrack,
                               TrackerHitAssociator& associate,
                               int ieta,
                               int iphi,
                               double timeCut = 150,
                               bool debug = false);

  // takes the HcalSimHits and returns a map energy matched to SimTrack, photons, neutral hadrons etc.
  template <typename T>
  std::map<std::string, double> eHCALSimInfoTotal(const edm::Event&,
                                                  const HcalTopology* topology,
                                                  const DetId& det,
                                                  const CaloGeometry* geo,
                                                  edm::Handle<T>& hits,
                                                  edm::Handle<edm::SimTrackContainer>& SimTk,
                                                  edm::Handle<edm::SimVertexContainer>& SimVtx,
                                                  const reco::Track* pTrack,
                                                  TrackerHitAssociator& associate,
                                                  int ieta,
                                                  int iphi,
                                                  int itry = -1,
                                                  double timeCut = 150,
                                                  bool includeHO = false,
                                                  bool debug = false);

  template <typename T>
  energyMap eHCALSimInfoMatrix(const edm::Event&,
                               const HcalTopology* topology,
                               const DetId& det,
                               const CaloGeometry* geo,
                               edm::Handle<T>& hits,
                               edm::Handle<edm::SimTrackContainer>& SimTk,
                               edm::Handle<edm::SimVertexContainer>& SimVtx,
                               const reco::Track* pTrack,
                               TrackerHitAssociator& associate,
                               int ieta,
                               int iphi,
                               double timeCut = 150,
                               bool includeHO = false,
                               bool debug = false);

  // Actual function which does the matching of SimHits to SimTracks using geantTrackId
  template <typename T>
  energyMap caloSimInfoMatrix(const CaloGeometry* geo,
                              edm::Handle<T>& hits,
                              edm::Handle<edm::SimTrackContainer>& SimTk,
                              edm::Handle<edm::SimVertexContainer>& SimVtx,
                              std::vector<typename T::const_iterator> hit,
                              edm::SimTrackContainer::const_iterator trkInfo,
                              double timeCut = 150,
                              bool includeHO = false,
                              bool debug = false);

  // Functions to study the Hits for which history cannot be traced back
  template <typename T>
  std::vector<typename T::const_iterator> missedECALHits(const edm::Event&,
                                                         CaloNavigator<DetId>& navigator,
                                                         edm::Handle<T>& hits,
                                                         edm::Handle<edm::SimTrackContainer>& SimTk,
                                                         edm::Handle<edm::SimVertexContainer>& SimVtx,
                                                         const reco::Track* pTrack,
                                                         TrackerHitAssociator& associate,
                                                         int ieta,
                                                         int iphi,
                                                         bool flag,
                                                         bool debug = false);

  template <typename T>
  std::vector<typename T::const_iterator> missedHCALHits(const edm::Event&,
                                                         const HcalTopology* topology,
                                                         const DetId& det,
                                                         edm::Handle<T>& hits,
                                                         edm::Handle<edm::SimTrackContainer>& SimTk,
                                                         edm::Handle<edm::SimVertexContainer>& SimVtx,
                                                         const reco::Track* pTrack,
                                                         TrackerHitAssociator& associate,
                                                         int ieta,
                                                         int iphi,
                                                         bool flag,
                                                         bool includeHO = false,
                                                         bool debug = false);

  template <typename T>
  std::vector<typename T::const_iterator> missedCaloHits(edm::Handle<T>& hits,
                                                         std::vector<int> matchedId,
                                                         std::vector<typename T::const_iterator> caloHits,
                                                         bool flag,
                                                         bool includeHO = false,
                                                         bool debug = false);
}  // namespace spr

#include "Calibration/IsolatedParticles/interface/CaloSimInfo.icc"
#endif