CMS 3D CMS Logo

GsfElectronFull5x5Filler.cc
Go to the documentation of this file.
1 
4 
11 
13 
16 
18 
23 
28 
31 
32 #include <iostream>
33 #include <string>
34 
35 using namespace reco;
36 
38  {
39  _source = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("source"));
40 
41  ElectronHcalHelper::Configuration hcalCfg, hcalCfgPflow;
42 
43  hcalCfg.hOverEConeSize = cfg.getParameter<double>("hOverEConeSize") ;
44  if (hcalCfg.hOverEConeSize>0)
45  {
46  hcalCfg.useTowers = true ;
47  hcalCfg.hcalTowers =
48  consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
49  hcalCfg.hOverEPtMin = cfg.getParameter<double>("hOverEPtMin") ;
50  }
51  hcalCfgPflow.hOverEConeSize = cfg.getParameter<double>("hOverEConeSizePflow") ;
52  if (hcalCfgPflow.hOverEConeSize>0)
53  {
54  hcalCfgPflow.useTowers = true ;
55  hcalCfgPflow.hcalTowers =
56  consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
57  hcalCfgPflow.hOverEPtMin = cfg.getParameter<double>("hOverEPtMinPflow") ;
58  }
59  _hcalHelper.reset(new ElectronHcalHelper(hcalCfg));
60  _hcalHelperPflow.reset(new ElectronHcalHelper(hcalCfg));
61 
62  _ebRecHitsToken = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("barrelRecHitCollectionTag"));
63  _eeRecHitsToken = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("endcapRecHitCollectionTag"));
64 
65  produces<reco::GsfElectronCollection >();
66  }
67 
69  {}
70 
71 // ------------ method called to produce the data ------------
73  {
74  auto out = std::make_unique<reco::GsfElectronCollection>();
75 
77  event.getByToken(_source,eles);
78 
79  event.getByToken(_ebRecHitsToken,_ebRecHits);
80  event.getByToken(_eeRecHitsToken,_eeRecHits);
81 
82  for( const auto& ele : *eles ) {
85  calculateShowerShape_full5x5(temp.superCluster(),true,full5x5_ss);
86  temp.full5x5_setShowerShape(full5x5_ss);
87  out->push_back(temp);
88  }
89 
90  event.put(std::move(out));
91  }
92 
94  edm::EventSetup const& es) {
97  es.get<CaloGeometryRecord>().get(caloGeom);
98  es.get<CaloTopologyRecord>().get(caloTopo);
99  _geometry = caloGeom.product();
100  _topology = caloTopo.product();
101 }
102 
104  {
105  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
106  // temporary, till CaloCluster->seed() is made available
107  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
108  int detector = seedXtalId.subdetId() ;
109 
110  const EcalRecHitCollection * recHits = nullptr ;
111  if (detector==EcalBarrel)
112  {
113  recHits = _ebRecHits.product() ;
114  }
115  else
116  {
117  recHits = _eeRecHits.product() ;
118  }
119 
120  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,_topology,_geometry) ;
121  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,_topology) ;
122  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
123  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
124  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
125  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,_topology) ;
126  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,_topology) ;
127  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,_topology) ;
128  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,_topology)/theClus->rawEnergy() ;
129 
130  if (pflow)
131  {
132  showerShape.hcalDepth1OverEcal = _hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
133  showerShape.hcalDepth2OverEcal = _hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
134  showerShape.hcalTowersBehindClusters = _hcalHelperPflow->hcalTowersBehindClusters(*theClus) ;
135  showerShape.hcalDepth1OverEcalBc = _hcalHelperPflow->hcalESumDepth1BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
136  showerShape.hcalDepth2OverEcalBc = _hcalHelperPflow->hcalESumDepth2BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
137  }
138  else
139  {
140  showerShape.hcalDepth1OverEcal = _hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
141  showerShape.hcalDepth2OverEcal = _hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
142  showerShape.hcalTowersBehindClusters = _hcalHelper->hcalTowersBehindClusters(*theClus) ;
143  showerShape.hcalDepth1OverEcalBc = _hcalHelper->hcalESumDepth1BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
144  showerShape.hcalDepth2OverEcalBc = _hcalHelper->hcalESumDepth2BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
145  }
146  }
T getParameter(std::string const &) const
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
#define nullptr
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
T sqrt(T t)
Definition: SSEVec.h:18
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:400
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:18
void calculateShowerShape_full5x5(const reco::SuperClusterRef &theClus, bool pflow, reco::GsfElectron::ShowerShape &showerShape)
fixed size matrix
T get() const
Definition: EventSetup.h:71
void produce(edm::Event &, const edm::EventSetup &) override
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
edm::EDGetTokenT< CaloTowerCollection > hcalTowers
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
GsfElectronFull5x5Filler(const edm::ParameterSet &)
void full5x5_setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:487
T const * product() const
Definition: ESHandle.h:86
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)