CMS 3D CMS Logo

ElectronSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ElectronProducers
4 // Class: ElectronSeedProducer
5 //
13 //
14 // Original Author: Ursula Berthon, Claude Charlot
15 // Created: Mon Mar 27 13:22:06 CEST 2006
16 //
17 //
18 
32 
34 public:
35  explicit ElectronSeedProducer(const edm::ParameterSet&);
36 
37  void produce(edm::Event&, const edm::EventSetup&) final;
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
44 
46  std::vector<edm::EDGetTokenT<TrajectorySeedCollection>> initialSeeds_;
48 
49  std::unique_ptr<ElectronSeedGenerator> matcher_;
50 
51  bool applyHOverECut_ = true;
52  std::unique_ptr<ElectronHcalHelper> hcalHelper_ = nullptr;
55  double SCEtCut_;
56 
58  std::unique_ptr<hgcal::ClusterTools> hgcClusterTools_;
59 };
60 
61 using namespace reco;
62 
64  :
65 
66  initialSeeds_{
67  edm::vector_transform(conf.getParameter<std::vector<edm::InputTag>>("initialSeedsVector"),
68  [this](edm::InputTag const& tag) { return consumes<TrajectorySeedCollection>(tag); })}
69 
70 {
71  SCEtCut_ = conf.getParameter<double>("SCEtCut");
72  auto theconsumes = consumesCollector();
73 
74  // new beamSpot tag
75  beamSpotTag_ = consumes(conf.getParameter<edm::InputTag>("beamSpot"));
76 
77  // for H/E
78  applyHOverECut_ = conf.getParameter<bool>("applyHOverECut");
79  if (applyHOverECut_) {
81  hcalCfg.hOverEConeSize = conf.getParameter<double>("hOverEConeSize");
82  if (hcalCfg.hOverEConeSize > 0) {
83  hcalCfg.useTowers = true;
84  hcalCfg.hcalTowers = consumes(conf.getParameter<edm::InputTag>("hcalTowers"));
85  hcalCfg.hOverEPtMin = conf.getParameter<double>("hOverEPtMin");
86  }
87  hcalHelper_ = std::make_unique<ElectronHcalHelper>(hcalCfg, consumesCollector());
88 
89  allowHGCal_ = conf.getParameter<bool>("allowHGCal");
90  if (allowHGCal_) {
91  const edm::ParameterSet& hgcCfg = conf.getParameterSet("HGCalConfig");
92  hgcClusterTools_ = std::make_unique<hgcal::ClusterTools>(hgcCfg, theconsumes);
93  }
94 
95  maxHOverEBarrel_ = conf.getParameter<double>("maxHOverEBarrel");
96  maxHOverEEndcaps_ = conf.getParameter<double>("maxHOverEEndcaps");
97  }
98 
100  esg_tokens.token_bs = beamSpotTag_;
101  esg_tokens.token_vtx = mayConsume<reco::VertexCollection>(conf.getParameter<edm::InputTag>("vertices"));
102 
103  matcher_ = std::make_unique<ElectronSeedGenerator>(conf, esg_tokens, consumesCollector());
104 
105  superClusters_[0] = consumes(conf.getParameter<edm::InputTag>("barrelSuperClusters"));
106  superClusters_[1] = consumes(conf.getParameter<edm::InputTag>("endcapSuperClusters"));
107 
108  //register your products
109  produces<ElectronSeedCollection>();
110 }
111 
113  LogDebug("ElectronSeedProducer") << "[ElectronSeedProducer::produce] entering ";
114 
115  std::vector<TrajectorySeedCollection const*> initialSeedCollections;
116  std::unique_ptr<TrajectorySeedCollection> initialSeedCollectionPtr = nullptr; //created on the fly
117 
118  if (hcalHelper_) {
119  hcalHelper_->beginEvent(e, iSetup);
120  if (allowHGCal_) {
121  hgcClusterTools_->getEventSetup(iSetup);
122  hgcClusterTools_->getEvent(e);
123  }
124  }
125 
126  matcher_->setupES(iSetup);
127 
128  // get initial TrajectorySeeds
129  initialSeedCollections.clear();
130  for (auto const& seeds : initialSeeds_) {
131  initialSeedCollections.push_back(&e.get(seeds));
132  }
133 
134  auto seeds = std::make_unique<ElectronSeedCollection>();
135  auto const& beamSportPosition = e.get(beamSpotTag_).position();
136 
137  // loop over barrel + endcap
138  for (unsigned int i = 0; i < 2; i++) {
139  auto clusterRefs = filterClusters(beamSportPosition, e.getHandle(superClusters_[i]));
140  matcher_->run(e, clusterRefs, initialSeedCollections, *seeds);
141  }
142 
143  // store the accumulated result
144 #ifdef EDM_ML_DEBUG
145  for (auto const& seed : *seeds) {
146  SuperClusterRef superCluster = seed.caloCluster().castTo<SuperClusterRef>();
147  LogDebug("ElectronSeedProducer") << "new seed with " << seed.nHits() << " hits"
148  << ", charge " << seed.getCharge() << " and cluster energy "
149  << superCluster->energy() << " PID " << superCluster.id();
150  }
151 #endif
152  e.put(std::move(seeds));
153 }
154 
155 //===============================
156 // Filter the superclusters
157 // - with EtCut
158 // - with HoE using calo cone
159 //===============================
160 
162  math::XYZPoint const& beamSpotPosition, const edm::Handle<reco::SuperClusterCollection>& superClusters) const {
163  SuperClusterRefVector sclRefs;
164 
165  for (unsigned int i = 0; i < superClusters->size(); ++i) {
166  auto const& scl = (*superClusters)[i];
167  double sclEta = EleRelPoint(scl.position(), beamSpotPosition).eta();
168  if (scl.energy() / cosh(sclEta) > SCEtCut_) {
169  if (applyHOverECut_) {
170  bool hoeVeto = false;
171  double had = hcalHelper_->hcalESumDepth1(scl) + hcalHelper_->hcalESumDepth2(scl);
172  double scle = scl.energy();
173  int det_group = scl.seed()->hitsAndFractions()[0].first.det();
174  int detector = scl.seed()->hitsAndFractions()[0].first.subdetId();
175  if (detector == EcalBarrel && had / scle < maxHOverEBarrel_)
176  hoeVeto = true;
177  else if (!allowHGCal_ && detector == EcalEndcap && had / scle < maxHOverEEndcaps_)
178  hoeVeto = true;
179  else if (allowHGCal_ && EcalTools::isHGCalDet((DetId::Detector)det_group)) {
180  float had_fraction = hgcClusterTools_->getClusterHadronFraction(*(scl.seed()));
181  hoeVeto = (had_fraction >= 0.f && had_fraction < maxHOverEEndcaps_);
182  }
183  if (hoeVeto) {
184  sclRefs.push_back({superClusters, i});
185  }
186  } else {
187  sclRefs.push_back({superClusters, i});
188  }
189  }
190  }
191  LogDebug("ElectronSeedProducer") << "Filtered out " << sclRefs.size() << " superclusters from "
192  << superClusters->size();
193 
194  return sclRefs;
195 }
196 
199 
200  // steering
201  desc.add<std::vector<edm::InputTag>>("initialSeedsVector", {});
202  desc.add<bool>("useRecoVertex", false);
203  desc.add<edm::InputTag>("vertices", {"offlinePrimaryVerticesWithBS"});
204  desc.add<edm::InputTag>("beamSpot", {"offlineBeamSpot"});
205  desc.add<bool>("dynamicPhiRoad", true);
206 
207  // SC filtering
208  desc.add<double>("SCEtCut", 0.0);
209 
210  // H/E
211  desc.add<bool>("applyHOverECut", true);
212  desc.add<double>("hOverEConeSize", 0.15);
213  desc.add<double>("maxHOverEBarrel", 0.15);
214  desc.add<double>("maxHOverEEndcaps", 0.15);
215 
216  // H/E towers
217  desc.add<edm::InputTag>("hcalTowers", {"towerMaker"});
218  desc.add<double>("hOverEPtMin", 0.0);
219 
220  // H/E equivalent for HGCal
221  desc.add<bool>("allowHGCal", false);
223  psd4.add<edm::InputTag>("HGCEEInput", {"HGCalRecHit", "HGCEERecHits"});
224  psd4.add<edm::InputTag>("HGCFHInput", {"HGCalRecHit", "HGCHEFRecHits"});
225  psd4.add<edm::InputTag>("HGCBHInput", {"HGCalRecHit", "HGCHEBRecHits"});
226  desc.add<edm::ParameterSetDescription>("HGCalConfig", psd4);
227 
228  // r/z windows
229  desc.add<double>("nSigmasDeltaZ1", 5.0); // in case beam spot is used for the matching
230  desc.add<double>("deltaZ1WithVertex", 25.0); // in case reco vertex is used for the matching
231  desc.add<double>("z2MaxB", 0.09);
232  desc.add<double>("r2MaxF", 0.15);
233  desc.add<double>("rMaxI", 0.2); // intermediate region SC in EB and 2nd hits in PXF
234 
235  // phi windows (dynamic)
236  desc.add<double>("LowPtThreshold", 5.0);
237  desc.add<double>("HighPtThreshold", 35.0);
238  desc.add<double>("SizeWindowENeg", 0.675);
239  desc.add<double>("DeltaPhi1Low", 0.23);
240  desc.add<double>("DeltaPhi1High", 0.08);
241  desc.add<double>("DeltaPhi2B", 0.008);
242  desc.add<double>("DeltaPhi2F", 0.012);
243 
244  // phi windows (non dynamic, overwritten in case dynamic is selected)
245  desc.add<double>("ePhiMin1", -0.125);
246  desc.add<double>("ePhiMax1", 0.075);
247  desc.add<double>("PhiMax2B", 0.002);
248  desc.add<double>("PhiMax2F", 0.003);
249 
250  desc.add<edm::InputTag>("barrelSuperClusters",
251  {"particleFlowSuperClusterECAL", "particleFlowSuperClusterECALBarrel"});
252  desc.add<edm::InputTag>("endcapSuperClusters",
253  {"particleFlowSuperClusterECAL", "particleFlowSuperClusterECALEndcapWithPreshower"});
254 
255  descriptions.add("ecalDrivenElectronSeeds", desc);
256 }
257 
ConfigurationDescriptions.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
ElectronSeedProducer::maxHOverEBarrel_
double maxHOverEBarrel_
Definition: ElectronSeedProducer.cc:53
ElectronSeedProducer::produce
void produce(edm::Event &, const edm::EventSetup &) final
Definition: ElectronSeedProducer.cc:112
EcalTools::isHGCalDet
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:49
ElectronSeedProducer::maxHOverEEndcaps_
double maxHOverEEndcaps_
Definition: ElectronSeedProducer.cc:54
edm::EDGetTokenT< reco::SuperClusterCollection >
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ElectronSeedGenerator::Tokens::token_bs
edm::EDGetTokenT< reco::BeamSpot > token_bs
Definition: ElectronSeedGenerator.h:50
EDProducer.h
ElectronSeedProducer::allowHGCal_
bool allowHGCal_
Definition: ElectronSeedProducer.cc:57
edm::RefVector
Definition: EDProductfwd.h:27
ElectronSeedGenerator.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ElectronUtilities.h
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
edm::Ref< SuperClusterCollection >
HLT_FULL_cff.superClusters
superClusters
Definition: HLT_FULL_cff.py:15175
fileCollector.seed
seed
Definition: fileCollector.py:127
MakerMacros.h
EleRelPoint
Definition: ElectronUtilities.h:25
ElectronSeedProducer::beamSpotTag_
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
Definition: ElectronSeedProducer.cc:47
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PVValHelper::eta
Definition: PVValidationHelpers.h:70
ElectronHcalHelper::Configuration::hOverEConeSize
double hOverEConeSize
Definition: ElectronHcalHelper.h:27
ParameterSetDescription.h
ElectronHcalHelper::Configuration
Definition: ElectronHcalHelper.h:25
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::vector_transform
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
ElectronSeedProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ElectronSeedProducer.cc:197
EcalEndcap
Definition: EcalSubdetector.h:10
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:231
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ElectronSeedProducer::applyHOverECut_
bool applyHOverECut_
Definition: ElectronSeedProducer.cc:51
Event.h
ElectronSeedGenerator::Tokens::token_vtx
edm::EDGetTokenT< std::vector< reco::Vertex > > token_vtx
Definition: ElectronSeedGenerator.h:49
ElectronSeedGenerator::Tokens
Definition: ElectronSeedGenerator.h:48
edm::stream::EDProducer
Definition: EDProducer.h:38
DetId::Detector
Detector
Definition: DetId.h:24
edm::EventSetup
Definition: EventSetup.h:58
ElectronSeedProducer::superClusters_
edm::EDGetTokenT< reco::SuperClusterCollection > superClusters_[2]
Definition: ElectronSeedProducer.cc:45
ClusterTools.h
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
EcalTools.h
ElectronSeedProducer::filterClusters
reco::SuperClusterRefVector filterClusters(math::XYZPoint const &beamSpotPosition, const edm::Handle< reco::SuperClusterCollection > &superClusters) const
Definition: ElectronSeedProducer.cc:161
ElectronSeedProducer::ElectronSeedProducer
ElectronSeedProducer(const edm::ParameterSet &)
Definition: ElectronSeedProducer.cc:63
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
ElectronSeedProducer::matcher_
std::unique_ptr< ElectronSeedGenerator > matcher_
Definition: ElectronSeedProducer.cc:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
transform.h
SuperCluster.h
ElectronHcalHelper.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
ElectronSeedProducer::hgcClusterTools_
std::unique_ptr< hgcal::ClusterTools > hgcClusterTools_
Definition: ElectronSeedProducer.cc:58
ElectronSeedProducer
Definition: ElectronSeedProducer.cc:33
ParameterSet.h
ElectronSeedProducer::SCEtCut_
double SCEtCut_
Definition: ElectronSeedProducer.cc:55
edm::Event
Definition: Event.h:73
ElectronSeedProducer::hcalHelper_
std::unique_ptr< ElectronHcalHelper > hcalHelper_
Definition: ElectronSeedProducer.cc:52
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
ElectronSeedProducer::initialSeeds_
std::vector< edm::EDGetTokenT< TrajectorySeedCollection > > initialSeeds_
Definition: ElectronSeedProducer.cc:46
edm::InputTag
Definition: InputTag.h:15
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37