CMS 3D CMS Logo

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