CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  std::auto_ptr<reco::GsfElectronCollection> out(new 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(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 = 0 ;
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
tuple cfg
Definition: looper.py:293
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:192
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
bool isNotFinite(T x)
Definition: isFinite.h:10
T sqrt(T t)
Definition: SSEVec.h:48
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:182
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: GsfElectron.h:386
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
tuple out
Definition: dbtoconf.py:99
Definition: DetId.h:18
virtual void produce(edm::Event &, const edm::EventSetup &)
void calculateShowerShape_full5x5(const reco::SuperClusterRef &theClus, bool pflow, reco::GsfElectron::ShowerShape &showerShape)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
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:449
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)