CMS 3D CMS Logo

SuperClusterImporter.cc
Go to the documentation of this file.
8 
9 // for single tower H/E
11 
12 //quick pT for superclusters
13 inline double ptFast(const double energy, const math::XYZPoint& position, const math::XYZPoint& origin) {
14  const auto v = position - origin;
15  return energy * std::sqrt(v.perp2() / v.mag2());
16 }
17 
18 #include <memory>
19 
20 #include <unordered_map>
21 
23 public:
25 
26  void updateEventSetup(const edm::EventSetup& es) override;
27 
28  void importToBlock(const edm::Event&, ElementList&) const override;
29 
30 private:
33  const double _maxHoverE, _pTbyPass, _minSCPt;
36  static const math::XYZPoint _zero;
37 };
38 
40 
42 
44  : BlockElementImporterBase(conf, sumes),
45  _srcEB(sumes.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_eb"))),
46  _srcEE(sumes.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_ee"))),
47  _srcTowers(sumes.consumes<CaloTowerCollection>(conf.getParameter<edm::InputTag>("source_towers"))),
48  _maxHoverE(conf.getParameter<double>("maximumHoverE")),
49  _pTbyPass(conf.getParameter<double>("minPTforBypass")),
50  _minSCPt(conf.getParameter<double>("minSuperClusterPt")),
51  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {}
52 
55  es.get<CaloGeometryRecord>().get(ctmaph);
56  towerMap_ = ctmaph.product();
57 }
58 
60  auto eb_scs = e.getHandle(_srcEB);
61  auto ee_scs = e.getHandle(_srcEE);
62  auto const& towers = e.get(_srcTowers);
63  elems.reserve(elems.size() + eb_scs->size() + ee_scs->size());
64  // setup our elements so that all the SCs are grouped together
65  auto SCs_end =
66  std::partition(elems.begin(), elems.end(), [](auto const& a) { return a->type() == reco::PFBlockElement::SC; });
67  // add eb superclusters
68  auto bsc = eb_scs->cbegin();
69  auto esc = eb_scs->cend();
70  reco::PFBlockElementSuperCluster* scbe = nullptr;
72  for (auto sc = bsc; sc != esc; ++sc) {
73  scref = reco::SuperClusterRef(eb_scs, std::distance(bsc, sc));
74  PFBlockElementSCEqual myEqual(scref);
75  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
76  const double scpT = ptFast(sc->energy(), sc->position(), _zero);
77  const auto towersBehindCluster = egamma::towersOf(*sc, *towerMap_);
78  const double H_tower =
79  (egamma::depth1HcalESum(towersBehindCluster, towers) + egamma::depth2HcalESum(towersBehindCluster, towers));
80  const double HoverE = H_tower / sc->energy();
81  if (sc_elem == SCs_end && scpT > _minSCPt && (scpT > _pTbyPass || HoverE < _maxHoverE)) {
82  scbe = new reco::PFBlockElementSuperCluster(scref);
84  SCs_end = elems.emplace(SCs_end, scbe);
85  ++SCs_end; // point to element *after* the new one
86  }
87  } // loop on eb superclusters
88  // add ee superclusters
89  bsc = ee_scs->cbegin();
90  esc = ee_scs->cend();
91  for (auto sc = bsc; sc != esc; ++sc) {
92  scref = reco::SuperClusterRef(ee_scs, std::distance(bsc, sc));
93  PFBlockElementSCEqual myEqual(scref);
94  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
95  const double scpT = ptFast(sc->energy(), sc->position(), _zero);
96  const auto towersBehindCluster = egamma::towersOf(*sc, *towerMap_);
97  const double H_tower =
98  (egamma::depth1HcalESum(towersBehindCluster, towers) + egamma::depth2HcalESum(towersBehindCluster, towers));
99  const double HoverE = H_tower / sc->energy();
100  if (sc_elem == SCs_end && scpT > _minSCPt && (scpT > _pTbyPass || HoverE < _maxHoverE)) {
101  scbe = new reco::PFBlockElementSuperCluster(scref);
103  SCs_end = elems.emplace(SCs_end, scbe);
104  ++SCs_end; // point to element *after* the new one
105  }
106  } // loop on ee superclusters
107  elems.shrink_to_fit();
108 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HLT_FULL_cff.towers
towers
Definition: HLT_FULL_cff.py:36362
electrons_cff.bool
bool
Definition: electrons_cff.py:366
SuperClusterImporter
Definition: SuperClusterImporter.cc:22
edm::EDGetTokenT< reco::SuperClusterCollection >
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
PhotonSelectorAlgo.h
reco::PFBlockElementSuperCluster
Cluster Element.
Definition: PFBlockElementSuperCluster.h:15
reco::PFBlockElement::SC
Definition: PFBlockElement.h:41
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::SortedCollection< CaloTower >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
egamma::depth2HcalESum
double depth2HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:83
EgammaHadTower.h
edm::Ref< SuperClusterCollection >
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
bsc_activity_cfg.bsc
bsc
Definition: bsc_activity_cfg.py:31
SuperClusterImporter::importToBlock
void importToBlock(const edm::Event &, ElementList &) const override
Definition: SuperClusterImporter.cc:59
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
BlockElementImporterBase.h
PFBlockElementSCEqual
Definition: PFBlockElementSCEqual.h:7
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::SuperClusterRef
edm::Ref< SuperClusterCollection > SuperClusterRef
reference to an object in a collection of SuperCluster objects
Definition: SuperClusterFwd.h:15
CaloTowerConstituentsMap
Definition: CaloTowerConstituentsMap.h:18
edm::ESHandle< CaloTowerConstituentsMap >
PFCluster.h
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
SuperClusterImporter::_srcEB
edm::EDGetTokenT< reco::SuperClusterCollection > _srcEB
Definition: SuperClusterImporter.cc:31
CaloGeometryRecord.h
BlockElementImporterBase::ElementList
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: BlockElementImporterBase.h:16
reco::PFBlockElementSuperCluster::setFromPFSuperCluster
void setFromPFSuperCluster(bool val)
Definition: PFBlockElementSuperCluster.h:61
egamma::towersOf
std::vector< CaloTowerDetId > towersOf(reco::SuperCluster const &sc, CaloTowerConstituentsMap const &towerMap, HoeMode mode=HoeMode::SingleTower)
Definition: EgammaHadTower.cc:25
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
a
double a
Definition: hdecay.h:119
edmplugin::PluginFactory
Definition: PluginFactory.h:34
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
SuperClusterImporter::_srcTowers
edm::EDGetTokenT< CaloTowerCollection > _srcTowers
Definition: SuperClusterImporter.cc:32
PFBlockElementSuperCluster.h
SuperClusterImporter::_minSCPt
const double _minSCPt
Definition: SuperClusterImporter.cc:33
edm::EventSetup
Definition: EventSetup.h:58
SuperClusterImporter::_maxHoverE
const double _maxHoverE
Definition: SuperClusterImporter.cc:33
get
#define get
SuperClusterImporter::towerMap_
CaloTowerConstituentsMap const * towerMap_
Definition: SuperClusterImporter.cc:34
SuperClusterImporter::_srcEE
edm::EDGetTokenT< reco::SuperClusterCollection > _srcEE
Definition: SuperClusterImporter.cc:31
SuperCluster.h
SuperClusterImporter::updateEventSetup
void updateEventSetup(const edm::EventSetup &es) override
Definition: SuperClusterImporter.cc:53
egamma::depth1HcalESum
double depth1HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:73
SuperClusterImporter::_zero
static const math::XYZPoint _zero
Definition: SuperClusterImporter.cc:36
ptFast
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
Definition: SuperClusterImporter.cc:13
SuperClusterImporter::_superClustersArePF
bool _superClustersArePF
Definition: SuperClusterImporter.cc:35
PFBlockElementSCEqual.h
SuperClusterImporter::_pTbyPass
const double _pTbyPass
Definition: SuperClusterImporter.cc:33
edm::Event
Definition: Event.h:73
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
SuperClusterImporter::SuperClusterImporter
SuperClusterImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: SuperClusterImporter.cc:43
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
BlockElementImporterBase
Definition: BlockElementImporterBase.h:14