CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ElectronSeedProducer Class Reference
Inheritance diagram for ElectronSeedProducer:
edm::stream::EDProducer<>

Public Member Functions

 ElectronSeedProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) final
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

reco::SuperClusterRefVector filterClusters (math::XYZPoint const &beamSpotPosition, const edm::Handle< reco::SuperClusterCollection > &superClusters, HcalPFCuts const *hcalCuts) const
 

Private Attributes

bool allowHGCal_
 
bool applyHOverECut_ = true
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotTag_
 
bool cutsFromDB_
 
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcdhcalCutsToken_
 
std::unique_ptr< ElectronHcalHelperhcalHelper_ = nullptr
 
std::unique_ptr< hgcal::ClusterToolshgcClusterTools_
 
std::vector< edm::EDGetTokenT< TrajectorySeedCollection > > initialSeeds_
 
std::unique_ptr< ElectronSeedGeneratormatcher_
 
double maxHOverEBarrel_
 
double maxHOverEEndcaps_
 
double SCEtCut_
 
edm::EDGetTokenT< reco::SuperClusterCollectionsuperClusters_ [2]
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: EDProducer of ElectronSeed objects

Implementation: <Notes on="" implementation>="">

Definition at line 36 of file ElectronSeedProducer.cc.

Constructor & Destructor Documentation

◆ ElectronSeedProducer()

ElectronSeedProducer::ElectronSeedProducer ( const edm::ParameterSet conf)
explicit

Definition at line 70 of file ElectronSeedProducer.cc.

References edm::ParameterSet::getParameter(), makeGlobalPositionRcd_cfg::tag, and edm::vector_transform().

71  :
72 
74  edm::vector_transform(conf.getParameter<std::vector<edm::InputTag>>("initialSeedsVector"),
75  [this](edm::InputTag const& tag) { return consumes<TrajectorySeedCollection>(tag); })}
76 
77 {
78  SCEtCut_ = conf.getParameter<double>("SCEtCut");
79  auto theconsumes = consumesCollector();
80 
81  // new beamSpot tag
82  beamSpotTag_ = consumes(conf.getParameter<edm::InputTag>("beamSpot"));
83 
84  // for H/E
85  applyHOverECut_ = conf.getParameter<bool>("applyHOverECut");
86  if (applyHOverECut_) {
88  hcalCfg.hOverEConeSize = conf.getParameter<double>("hOverEConeSize");
89  if (hcalCfg.hOverEConeSize > 0) {
90  hcalCfg.onlyBehindCluster = false;
91  hcalCfg.checkHcalStatus = false;
92 
93  hcalCfg.hbheRecHits = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheRecHits"));
94 
95  hcalCfg.eThresHB = conf.getParameter<EgammaHcalIsolation::arrayHB>("recHitEThresholdHB");
96  hcalCfg.maxSeverityHB = conf.getParameter<int>("maxHcalRecHitSeverity");
97  hcalCfg.eThresHE = conf.getParameter<EgammaHcalIsolation::arrayHE>("recHitEThresholdHE");
98  hcalCfg.maxSeverityHE = hcalCfg.maxSeverityHB;
99  }
100  hcalHelper_ = std::make_unique<ElectronHcalHelper>(hcalCfg, consumesCollector());
101 
102  allowHGCal_ = conf.getParameter<bool>("allowHGCal");
103  if (allowHGCal_) {
104  const edm::ParameterSet& hgcCfg = conf.getParameterSet("HGCalConfig");
105  hgcClusterTools_ = std::make_unique<hgcal::ClusterTools>(hgcCfg, theconsumes);
106  }
107 
108  maxHOverEBarrel_ = conf.getParameter<double>("maxHOverEBarrel");
109  maxHOverEEndcaps_ = conf.getParameter<double>("maxHOverEEndcaps");
110  }
111 
112  //Retrieve HCAL PF thresholds - from config or from DB
113  cutsFromDB_ = conf.getParameter<bool>("usePFThresholdsFromDB");
114  if (cutsFromDB_) {
115  hcalCutsToken_ = esConsumes<HcalPFCuts, HcalPFCutsRcd>(edm::ESInputTag("", "withTopo"));
116  }
117 
119  esg_tokens.token_bs = beamSpotTag_;
120  esg_tokens.token_vtx = mayConsume<reco::VertexCollection>(conf.getParameter<edm::InputTag>("vertices"));
121 
122  matcher_ = std::make_unique<ElectronSeedGenerator>(conf, esg_tokens, consumesCollector());
123 
124  superClusters_[0] = consumes(conf.getParameter<edm::InputTag>("barrelSuperClusters"));
125  superClusters_[1] = consumes(conf.getParameter<edm::InputTag>("endcapSuperClusters"));
126 
127  //register your products
128  produces<ElectronSeedCollection>();
129 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::BeamSpot > token_bs
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< ElectronHcalHelper > hcalHelper_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::unique_ptr< ElectronSeedGenerator > matcher_
edm::EDGetTokenT< reco::SuperClusterCollection > superClusters_[2]
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
std::array< double, 4 > arrayHB
edm::EDGetTokenT< std::vector< reco::Vertex > > token_vtx
std::unique_ptr< hgcal::ClusterTools > hgcClusterTools_
std::vector< edm::EDGetTokenT< TrajectorySeedCollection > > initialSeeds_
std::array< double, 7 > arrayHE

Member Function Documentation

◆ fillDescriptions()

void ElectronSeedProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 223 of file ElectronSeedProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and submitPVResolutionJobs::desc.

223  {
225 
226  // steering
227  desc.add<std::vector<edm::InputTag>>("initialSeedsVector", {});
228  desc.add<bool>("useRecoVertex", false);
229  desc.add<edm::InputTag>("vertices", {"offlinePrimaryVerticesWithBS"});
230  desc.add<edm::InputTag>("beamSpot", {"offlineBeamSpot"});
231  desc.add<bool>("dynamicPhiRoad", true);
232 
233  // SC filtering
234  desc.add<double>("SCEtCut", 0.0);
235 
236  // H/E
237  desc.add<bool>("applyHOverECut", true);
238  desc.add<double>("hOverEConeSize", 0.15);
239  desc.add<double>("maxHOverEBarrel", 0.15);
240  desc.add<double>("maxHOverEEndcaps", 0.15);
241  desc.add<edm::InputTag>("hbheRecHits", {"hbhereco"});
242  desc.add<std::vector<double>>("recHitEThresholdHB", {0., 0., 0., 0.});
243  desc.add<std::vector<double>>("recHitEThresholdHE", {0., 0., 0., 0., 0., 0., 0.});
244  desc.add<int>("maxHcalRecHitSeverity", 999999);
245  desc.add<bool>("usePFThresholdsFromDB", false);
246 
247  // H/E equivalent for HGCal
248  desc.add<bool>("allowHGCal", false);
250  psd4.add<edm::InputTag>("HGCEEInput", {"HGCalRecHit", "HGCEERecHits"});
251  psd4.add<edm::InputTag>("HGCFHInput", {"HGCalRecHit", "HGCHEFRecHits"});
252  psd4.add<edm::InputTag>("HGCBHInput", {"HGCalRecHit", "HGCHEBRecHits"});
253  desc.add<edm::ParameterSetDescription>("HGCalConfig", psd4);
254 
255  // r/z windows
256  desc.add<double>("nSigmasDeltaZ1", 5.0); // in case beam spot is used for the matching
257  desc.add<double>("deltaZ1WithVertex", 25.0); // in case reco vertex is used for the matching
258  desc.add<double>("z2MaxB", 0.09);
259  desc.add<double>("r2MaxF", 0.15);
260  desc.add<double>("rMaxI", 0.2); // intermediate region SC in EB and 2nd hits in PXF
261 
262  // phi windows (dynamic)
263  desc.add<double>("LowPtThreshold", 5.0);
264  desc.add<double>("HighPtThreshold", 35.0);
265  desc.add<double>("SizeWindowENeg", 0.675);
266  desc.add<double>("DeltaPhi1Low", 0.23);
267  desc.add<double>("DeltaPhi1High", 0.08);
268  desc.add<double>("DeltaPhi2B", 0.008);
269  desc.add<double>("DeltaPhi2F", 0.012);
270 
271  // phi windows (non dynamic, overwritten in case dynamic is selected)
272  desc.add<double>("ePhiMin1", -0.125);
273  desc.add<double>("ePhiMax1", 0.075);
274  desc.add<double>("PhiMax2B", 0.002);
275  desc.add<double>("PhiMax2F", 0.003);
276 
277  desc.add<edm::InputTag>("barrelSuperClusters",
278  {"particleFlowSuperClusterECAL", "particleFlowSuperClusterECALBarrel"});
279  desc.add<edm::InputTag>("endcapSuperClusters",
280  {"particleFlowSuperClusterECAL", "particleFlowSuperClusterECALEndcapWithPreshower"});
281 
282  descriptions.add("ecalDrivenElectronSeedsDefault", desc);
283 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ filterClusters()

SuperClusterRefVector ElectronSeedProducer::filterClusters ( math::XYZPoint const &  beamSpotPosition,
const edm::Handle< reco::SuperClusterCollection > &  superClusters,
HcalPFCuts const *  hcalCuts 
) const
private

Definition at line 185 of file ElectronSeedProducer.cc.

References allowHGCal_, applyHOverECut_, hgcalTestNeighbor_cfi::detector, EcalBarrel, EcalEndcap, PVValHelper::eta, hcalHelper_, hgcClusterTools_, mps_fire::i, EcalTools::isHGCalDet(), LogDebug, maxHOverEBarrel_, maxHOverEEndcaps_, edm::RefVector< C, T, F >::push_back(), SCEtCut_, edm::RefVector< C, T, F >::size(), and HLT_2024v12_cff::superClusters.

Referenced by produce().

188  {
189  SuperClusterRefVector sclRefs;
190 
191  for (unsigned int i = 0; i < superClusters->size(); ++i) {
192  auto const& scl = (*superClusters)[i];
193  double sclEta = EleRelPoint(scl.position(), beamSpotPosition).eta();
194  if (scl.energy() / cosh(sclEta) > SCEtCut_) {
195  if (applyHOverECut_) {
196  bool hoeVeto = false;
197  double had = hcalHelper_->hcalESum(scl, 0, hcalCuts);
198  double scle = scl.energy();
199  int det_group = scl.seed()->hitsAndFractions()[0].first.det();
200  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId();
201  if (detector == EcalBarrel && had / scle < maxHOverEBarrel_)
202  hoeVeto = true;
203  else if (!allowHGCal_ && detector == EcalEndcap && had / scle < maxHOverEEndcaps_)
204  hoeVeto = true;
205  else if (allowHGCal_ && EcalTools::isHGCalDet((DetId::Detector)det_group)) {
206  float had_fraction = hgcClusterTools_->getClusterHadronFraction(*(scl.seed()));
207  hoeVeto = (had_fraction >= 0.f && had_fraction < maxHOverEEndcaps_);
208  }
209  if (hoeVeto) {
210  sclRefs.push_back({superClusters, i});
211  }
212  } else {
213  sclRefs.push_back({superClusters, i});
214  }
215  }
216  }
217  LogDebug("ElectronSeedProducer") << "Filtered out " << sclRefs.size() << " superclusters from "
218  << superClusters->size();
219 
220  return sclRefs;
221 }
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:49
std::unique_ptr< ElectronHcalHelper > hcalHelper_
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
Detector
Definition: DetId.h:24
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
std::unique_ptr< hgcal::ClusterTools > hgcClusterTools_
#define LogDebug(id)

◆ produce()

void ElectronSeedProducer::produce ( edm::Event e,
const edm::EventSetup iSetup 
)
final

Definition at line 131 of file ElectronSeedProducer.cc.

References allowHGCal_, beamSpotTag_, cutsFromDB_, MillePedeFileConverter_cfg::e, filterClusters(), edm::EventSetup::getData(), hcalCutsToken_, hcalHelper_, hgcClusterTools_, mps_fire::i, edm::Ref< C, T, F >::id(), initialSeeds_, LogDebug, matcher_, eostools::move(), fileCollector::seed, HLT_2024v12_cff::seeds, and superClusters_.

131  {
132  LogDebug("ElectronSeedProducer") << "[ElectronSeedProducer::produce] entering ";
133 
134  HcalPFCuts const* hcalCuts = nullptr;
135  if (cutsFromDB_) {
136  hcalCuts = &iSetup.getData(hcalCutsToken_);
137  }
138 
139  std::vector<TrajectorySeedCollection const*> initialSeedCollections;
140  std::unique_ptr<TrajectorySeedCollection> initialSeedCollectionPtr = nullptr; //created on the fly
141 
142  if (hcalHelper_) {
143  hcalHelper_->beginEvent(e, iSetup);
144  if (allowHGCal_) {
145  hgcClusterTools_->getEventSetup(iSetup);
146  hgcClusterTools_->getEvent(e);
147  }
148  }
149 
150  matcher_->setupES(iSetup);
151 
152  // get initial TrajectorySeeds
153  initialSeedCollections.clear();
154  for (auto const& seeds : initialSeeds_) {
155  initialSeedCollections.push_back(&e.get(seeds));
156  }
157 
158  auto seeds = std::make_unique<ElectronSeedCollection>();
159  auto const& beamSpotPosition = e.get(beamSpotTag_).position();
160 
161  // loop over barrel + endcap
162  for (unsigned int i = 0; i < 2; i++) {
163  auto clusterRefs = filterClusters(beamSpotPosition, e.getHandle(superClusters_[i]), hcalCuts);
164  matcher_->run(e, clusterRefs, initialSeedCollections, *seeds);
165  }
166 
167  // store the accumulated result
168 #ifdef EDM_ML_DEBUG
169  for (auto const& seed : *seeds) {
170  SuperClusterRef superCluster = seed.caloCluster().castTo<SuperClusterRef>();
171  LogDebug("ElectronSeedProducer") << "new seed with " << seed.nHits() << " hits"
172  << ", charge " << seed.getCharge() << " and cluster energy "
173  << superCluster->energy() << " PID " << superCluster.id();
174  }
175 #endif
176  e.put(std::move(seeds));
177 }
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
std::unique_ptr< ElectronHcalHelper > hcalHelper_
std::unique_ptr< ElectronSeedGenerator > matcher_
edm::EDGetTokenT< reco::SuperClusterCollection > superClusters_[2]
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
reco::SuperClusterRefVector filterClusters(math::XYZPoint const &beamSpotPosition, const edm::Handle< reco::SuperClusterCollection > &superClusters, HcalPFCuts const *hcalCuts) const
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< hgcal::ClusterTools > hgcClusterTools_
std::vector< edm::EDGetTokenT< TrajectorySeedCollection > > initialSeeds_
#define LogDebug(id)

Member Data Documentation

◆ allowHGCal_

bool ElectronSeedProducer::allowHGCal_
private

Definition at line 61 of file ElectronSeedProducer.cc.

Referenced by filterClusters(), and produce().

◆ applyHOverECut_

bool ElectronSeedProducer::applyHOverECut_ = true
private

Definition at line 55 of file ElectronSeedProducer.cc.

Referenced by filterClusters().

◆ beamSpotTag_

edm::EDGetTokenT<reco::BeamSpot> ElectronSeedProducer::beamSpotTag_
private

Definition at line 51 of file ElectronSeedProducer.cc.

Referenced by produce().

◆ cutsFromDB_

bool ElectronSeedProducer::cutsFromDB_
private

Definition at line 65 of file ElectronSeedProducer.cc.

Referenced by produce().

◆ hcalCutsToken_

edm::ESGetToken<HcalPFCuts, HcalPFCutsRcd> ElectronSeedProducer::hcalCutsToken_
private

Definition at line 64 of file ElectronSeedProducer.cc.

Referenced by produce().

◆ hcalHelper_

std::unique_ptr<ElectronHcalHelper> ElectronSeedProducer::hcalHelper_ = nullptr
private

Definition at line 56 of file ElectronSeedProducer.cc.

Referenced by filterClusters(), and produce().

◆ hgcClusterTools_

std::unique_ptr<hgcal::ClusterTools> ElectronSeedProducer::hgcClusterTools_
private

Definition at line 62 of file ElectronSeedProducer.cc.

Referenced by filterClusters(), and produce().

◆ initialSeeds_

std::vector<edm::EDGetTokenT<TrajectorySeedCollection> > ElectronSeedProducer::initialSeeds_
private

Definition at line 50 of file ElectronSeedProducer.cc.

Referenced by produce().

◆ matcher_

std::unique_ptr<ElectronSeedGenerator> ElectronSeedProducer::matcher_
private

Definition at line 53 of file ElectronSeedProducer.cc.

Referenced by produce().

◆ maxHOverEBarrel_

double ElectronSeedProducer::maxHOverEBarrel_
private

Definition at line 57 of file ElectronSeedProducer.cc.

Referenced by filterClusters().

◆ maxHOverEEndcaps_

double ElectronSeedProducer::maxHOverEEndcaps_
private

Definition at line 58 of file ElectronSeedProducer.cc.

Referenced by filterClusters().

◆ SCEtCut_

double ElectronSeedProducer::SCEtCut_
private

Definition at line 59 of file ElectronSeedProducer.cc.

Referenced by filterClusters().

◆ superClusters_

edm::EDGetTokenT<reco::SuperClusterCollection> ElectronSeedProducer::superClusters_[2]
private

Definition at line 49 of file ElectronSeedProducer.cc.

Referenced by produce().