CMS 3D CMS Logo

SuperClusterImporter.cc
Go to the documentation of this file.
18 
19 //quick pT for superclusters
20 inline double ptFast(const double energy, const math::XYZPoint& position, const math::XYZPoint& origin) {
21  const auto v = position - origin;
22  return energy * std::sqrt(v.perp2() / v.mag2());
23 }
24 
25 #include <memory>
26 
27 #include <unordered_map>
28 
30 public:
32 
33  void updateEventSetup(const edm::EventSetup& es) override;
34 
35  void importToBlock(const edm::Event&, ElementList&) const override;
36 
37 private:
39  const double _maxHoverE, _pTbyPass, _minSCPt;
41  const int maxSeverityHB_;
42  const int maxSeverityHE_;
43  bool cutsFromDB;
50  static const math::XYZPoint _zero;
51 
58  HcalPFCuts const* hcalCuts = nullptr;
59 };
60 
62 
64 
67  _srcEB(cc.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_eb"))),
68  _srcEE(cc.consumes<reco::SuperClusterCollection>(conf.getParameter<edm::InputTag>("source_ee"))),
69  _maxHoverE(conf.getParameter<double>("maximumHoverE")),
70  _pTbyPass(conf.getParameter<double>("minPTforBypass")),
71  _minSCPt(conf.getParameter<double>("minSuperClusterPt")),
72  hbheRecHitsTag_(cc.consumes(conf.getParameter<edm::InputTag>("hbheRecHitsTag"))),
73  maxSeverityHB_(conf.getParameter<int>("maxSeverityHB")),
74  maxSeverityHE_(conf.getParameter<int>("maxSeverityHE")),
75  cutsFromDB(conf.getParameter<bool>("usePFThresholdsFromDB")),
76  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")),
77  _ctmapToken(cc.esConsumes<edm::Transition::BeginLuminosityBlock>()),
78  caloGeometryToken_{cc.esConsumes<edm::Transition::BeginLuminosityBlock>()},
79  hcalTopologyToken_{cc.esConsumes<edm::Transition::BeginLuminosityBlock>()},
80  hcalChannelQualityToken_{cc.esConsumes<edm::Transition::BeginLuminosityBlock>(edm::ESInputTag("", "withTopo"))},
81  hcalSevLvlComputerToken_{cc.esConsumes<edm::Transition::BeginLuminosityBlock>()} {
82  if (cutsFromDB) {
84  edm::ESInputTag("", "withTopo"));
85  }
86 }
87 
90  if (cutsFromDB) {
92  }
97 }
98 
100  auto eb_scs = e.getHandle(_srcEB);
101  auto ee_scs = e.getHandle(_srcEE);
102  elems.reserve(elems.size() + eb_scs->size() + ee_scs->size());
103  // setup our elements so that all the SCs are grouped together
104  auto SCs_end =
105  std::partition(elems.begin(), elems.end(), [](auto const& a) { return a->type() == reco::PFBlockElement::SC; });
106  // add eb superclusters
107  auto bsc = eb_scs->cbegin();
108  auto esc = eb_scs->cend();
109  reco::PFBlockElementSuperCluster* scbe = nullptr;
110  reco::SuperClusterRef scref;
111 
113  0, //outercone
115  0, //innercone
116  {{0, 0, 0, 0}},
117  {{0, 0, 0, 0}},
119  {{0, 0, 0, 0, 0, 0, 0}},
120  {{0, 0, 0, 0, 0, 0, 0}},
122  e.get(hbheRecHitsTag_),
123  caloGeom_,
124  hcalTopo_,
126  hcalSev_,
127  towerMap_);
128 
129  for (auto sc = bsc; sc != esc; ++sc) {
130  scref = reco::SuperClusterRef(eb_scs, std::distance(bsc, sc));
131  PFBlockElementSCEqual myEqual(scref);
132  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
133  const double scpT = ptFast(sc->energy(), sc->position(), _zero);
134  const double H_tower = thisHcalVar_.getHcalESumBc(scref.get(), 0, hcalCuts);
135  const double HoverE = H_tower / sc->energy();
136  if (sc_elem == SCs_end && scpT > _minSCPt && (scpT > _pTbyPass || HoverE < _maxHoverE)) {
137  scbe = new reco::PFBlockElementSuperCluster(scref);
139  SCs_end = elems.emplace(SCs_end, scbe);
140  ++SCs_end; // point to element *after* the new one
141  }
142  } // loop on eb superclusters
143  // add ee superclusters
144  bsc = ee_scs->cbegin();
145  esc = ee_scs->cend();
146  for (auto sc = bsc; sc != esc; ++sc) {
147  scref = reco::SuperClusterRef(ee_scs, std::distance(bsc, sc));
148  PFBlockElementSCEqual myEqual(scref);
149  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
150  const double scpT = ptFast(sc->energy(), sc->position(), _zero);
151  const double H_tower = thisHcalVar_.getHcalESumBc(scref.get(), 0, hcalCuts);
152  const double HoverE = H_tower / sc->energy();
153  if (sc_elem == SCs_end && scpT > _minSCPt && (scpT > _pTbyPass || HoverE < _maxHoverE)) {
154  scbe = new reco::PFBlockElementSuperCluster(scref);
156  SCs_end = elems.emplace(SCs_end, scbe);
157  ++SCs_end; // point to element *after* the new one
158  }
159  } // loop on ee superclusters
160  elems.shrink_to_fit();
161 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
CaloGeometry const * caloGeom_
CaloTowerConstituentsMap const * towerMap_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< CaloTowerConstituentsMap, CaloGeometryRecord > _ctmapToken
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
HcalTopology const * hcalTopo_
edm::EDGetTokenT< reco::SuperClusterCollection > _srcEE
double getHcalESumBc(const reco::Candidate *c, int depth, const HcalPFCuts *hcalCuts) const
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)
HcalPFCuts const * hcalCuts
HcalSeverityLevelComputer const * hcalSev_
SuperClusterImporter(const edm::ParameterSet &, edm::ConsumesCollector &)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
T sqrt(T t)
Definition: SSEVec.h:19
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Transition
Definition: Transition.h:12
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hcalTopologyToken_
const edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > hcalSevLvlComputerToken_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
static int position[264][3]
Definition: ReadPGInfo.cc:289
const edm::EDGetTokenT< HBHERecHitCollection > hbheRecHitsTag_
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
static const math::XYZPoint _zero
const edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hcalChannelQualityToken_
HcalChannelQuality const * hcalChannelQual_
void updateEventSetup(const edm::EventSetup &es) override