CMS 3D CMS Logo

GsfElectronFull5x5Filler.cc
Go to the documentation of this file.
1 
4 
11 
13 
16 
18 
23 
29 
32 
33 #include <iostream>
34 #include <string>
35 
36 using namespace reco;
37 
39  {
40  _source = consumes<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("source"));
41 
42  ElectronHcalHelper::Configuration hcalCfg, hcalCfgPflow;
43 
44  hcalCfg.hOverEConeSize = cfg.getParameter<double>("hOverEConeSize") ;
45  if (hcalCfg.hOverEConeSize>0)
46  {
47  hcalCfg.useTowers = true ;
48  hcalCfg.hcalTowers =
49  consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
50  hcalCfg.hOverEPtMin = cfg.getParameter<double>("hOverEPtMin") ;
51  }
52  hcalCfgPflow.hOverEConeSize = cfg.getParameter<double>("hOverEConeSizePflow") ;
53  if (hcalCfgPflow.hOverEConeSize>0)
54  {
55  hcalCfgPflow.useTowers = true ;
56  hcalCfgPflow.hcalTowers =
57  consumes<CaloTowerCollection>(cfg.getParameter<edm::InputTag>("hcalTowers")) ;
58  hcalCfgPflow.hOverEPtMin = cfg.getParameter<double>("hOverEPtMinPflow") ;
59  }
60  _hcalHelper.reset(new ElectronHcalHelper(hcalCfg));
61  _hcalHelperPflow.reset(new ElectronHcalHelper(hcalCfg));
62 
63  _ebRecHitsToken = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("barrelRecHitCollectionTag"));
64  _eeRecHitsToken = consumes<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("endcapRecHitCollectionTag"));
65 
66  produces<reco::GsfElectronCollection >();
67  }
68 
70  {}
71 
72 // ------------ method called to produce the data ------------
74  {
75  auto out = std::make_unique<reco::GsfElectronCollection>();
76 
78  event.getByToken(_source,eles);
79 
80  event.getByToken(_ebRecHitsToken,_ebRecHits);
81  event.getByToken(_eeRecHitsToken,_eeRecHits);
82 
83  for( const auto& ele : *eles ) {
86  calculateShowerShape_full5x5(temp.superCluster(),true,full5x5_ss);
87  temp.full5x5_setShowerShape(full5x5_ss);
88  out->push_back(temp);
89  }
90 
91  event.put(std::move(out));
92  }
93 
95  edm::EventSetup const& es) {
98  es.get<CaloGeometryRecord>().get(caloGeom);
99  es.get<CaloTopologyRecord>().get(caloTopo);
100  _geometry = caloGeom.product();
101  _topology = caloTopo.product();
102 }
103 
105  {
106  const reco::CaloCluster & seedCluster = *(theClus->seed()) ;
107  // temporary, till CaloCluster->seed() is made available
108  DetId seedXtalId = seedCluster.hitsAndFractions()[0].first ;
109  int detector = seedXtalId.subdetId() ;
110 
111  const EcalRecHitCollection * recHits = nullptr ;
112  if (detector==EcalBarrel)
113  {
114  recHits = _ebRecHits.product() ;
115  }
116  else
117  {
118  recHits = _eeRecHits.product() ;
119  }
120 
121  std::vector<float> covariances = noZS::EcalClusterTools::covariances(seedCluster,recHits,_topology,_geometry) ;
122  std::vector<float> localCovariances = noZS::EcalClusterTools::localCovariances(seedCluster,recHits,_topology) ;
123  showerShape.sigmaEtaEta = sqrt(covariances[0]) ;
124  showerShape.sigmaIetaIeta = sqrt(localCovariances[0]) ;
125  if (!edm::isNotFinite(localCovariances[2])) showerShape.sigmaIphiIphi = sqrt(localCovariances[2]) ;
126  showerShape.e1x5 = noZS::EcalClusterTools::e1x5(seedCluster,recHits,_topology) ;
127  showerShape.e2x5Max = noZS::EcalClusterTools::e2x5Max(seedCluster,recHits,_topology) ;
128  showerShape.e5x5 = noZS::EcalClusterTools::e5x5(seedCluster,recHits,_topology) ;
129  showerShape.r9 = noZS::EcalClusterTools::e3x3(seedCluster,recHits,_topology)/theClus->rawEnergy() ;
130 
131  if (pflow)
132  {
133  showerShape.hcalDepth1OverEcal = _hcalHelperPflow->hcalESumDepth1(*theClus)/theClus->energy() ;
134  showerShape.hcalDepth2OverEcal = _hcalHelperPflow->hcalESumDepth2(*theClus)/theClus->energy() ;
135  showerShape.hcalTowersBehindClusters = _hcalHelperPflow->hcalTowersBehindClusters(*theClus) ;
136  showerShape.hcalDepth1OverEcalBc = _hcalHelperPflow->hcalESumDepth1BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
137  showerShape.hcalDepth2OverEcalBc = _hcalHelperPflow->hcalESumDepth2BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
138  }
139  else
140  {
141  showerShape.hcalDepth1OverEcal = _hcalHelper->hcalESumDepth1(*theClus)/theClus->energy() ;
142  showerShape.hcalDepth2OverEcal = _hcalHelper->hcalESumDepth2(*theClus)/theClus->energy() ;
143  showerShape.hcalTowersBehindClusters = _hcalHelper->hcalTowersBehindClusters(*theClus) ;
144  showerShape.hcalDepth1OverEcalBc = _hcalHelper->hcalESumDepth1BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
145  showerShape.hcalDepth2OverEcalBc = _hcalHelper->hcalESumDepth2BehindClusters(showerShape.hcalTowersBehindClusters)/showerShape.e5x5 ;
146  }
147  }
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)
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
#define nullptr
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
bool isNotFinite(T x)
Definition: isFinite.h:10
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:396
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:68
void produce(edm::Event &, const edm::EventSetup &) override
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:184
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:483
T const * product() const
Definition: ESHandle.h:84
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)