CMS 3D CMS Logo

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

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

reco::PFClusterRef closestCluster (const reco::PFTrajectoryPoint &point, const edm::Handle< reco::PFClusterCollection > &clusters, std::vector< int > &matched)
 

Private Attributes

const double dr2_
 
const edm::EDGetTokenT< reco::PFClusterCollectionecalClusters_
 
const edm::EDGetTokenT< reco::GsfPFRecTrackCollectiongsfPfRecTracks_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 27 of file LowPtGsfElectronSCProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronSCProducer()

LowPtGsfElectronSCProducer::LowPtGsfElectronSCProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 47 of file LowPtGsfElectronSCProducer.cc.

48  : gsfPfRecTracks_{consumes<reco::GsfPFRecTrackCollection>(cfg.getParameter<edm::InputTag>("gsfPfRecTracks"))},
49  ecalClusters_{consumes<reco::PFClusterCollection>(cfg.getParameter<edm::InputTag>("ecalClusters"))},
50  dr2_{cfg.getParameter<double>("MaxDeltaR2")} {
51  produces<reco::CaloClusterCollection>();
52  produces<reco::SuperClusterCollection>();
53  produces<edm::ValueMap<reco::SuperClusterRef> >();
54 }

References looper::cfg.

Member Function Documentation

◆ closestCluster()

reco::PFClusterRef LowPtGsfElectronSCProducer::closestCluster ( const reco::PFTrajectoryPoint point,
const edm::Handle< reco::PFClusterCollection > &  clusters,
std::vector< int > &  matched 
)
private

Definition at line 223 of file LowPtGsfElectronSCProducer.cc.

225  {
226  reco::PFClusterRef closest;
227  if (point.isValid()) {
228  float dr2min = dr2_;
229  for (size_t ii = 0; ii < clusters->size(); ++ii) {
230  if (std::find(matched.begin(), matched.end(), ii) == matched.end()) {
231  float dr2 = reco::deltaR2(clusters->at(ii), point.positionREP());
232  if (dr2 < dr2min) {
233  closest = reco::PFClusterRef(clusters, ii);
234  dr2min = dr2;
235  }
236  }
237  }
238  if (dr2min < (dr2_ - 1.e-6)) {
239  matched.push_back(closest.index());
240  }
241  }
242  return closest;
243 }

References bsc_activity_cfg::clusters, reco::deltaR2(), dr2_, MillePedeFileConverter_cfg::e, spr::find(), cuy::ii, edm::Ref< C, T, F >::index(), muonTagProbeFilters_cff::matched, and point.

◆ fillDescriptions()

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

Definition at line 247 of file LowPtGsfElectronSCProducer.cc.

247  {
249  desc.add<edm::InputTag>("gsfPfRecTracks", edm::InputTag("lowPtGsfElePfGsfTracks"));
250  desc.add<edm::InputTag>("ecalClusters", edm::InputTag("particleFlowClusterECAL"));
251  desc.add<edm::InputTag>("hcalClusters", edm::InputTag("particleFlowClusterHCAL"));
252  desc.add<double>("MaxDeltaR2", 0.5);
253  descriptions.add("lowPtGsfElectronSuperClusters", desc);
254 }

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

◆ produce()

void LowPtGsfElectronSCProducer::produce ( edm::Event event,
const edm::EventSetup  
)
override

Definition at line 58 of file LowPtGsfElectronSCProducer.cc.

58  {
59  // Input GsfPFRecTracks collection
61 
62  // Input EcalClusters collection
64 
65  // Output SuperClusters collection and getRefBeforePut
66  auto superClusters = std::make_unique<reco::SuperClusterCollection>(reco::SuperClusterCollection());
67  superClusters->reserve(gsfPfRecTracks->size());
68  const reco::SuperClusterRefProd superClustersRefProd = event.getRefBeforePut<reco::SuperClusterCollection>();
69 
70  // Output ValueMap container of GsfPFRecTrackRef index to SuperClusterRef
71  std::vector<reco::SuperClusterRef> superClustersValueMap;
72 
73  // Output CaloClusters collection
74  auto caloClusters = std::make_unique<reco::CaloClusterCollection>(reco::CaloClusterCollection());
75  caloClusters->reserve(ecalClusters.size());
76 
77  // Index[GSF track][trajectory point] for "best" CaloCluster
78  std::vector<std::vector<int> > cluster_idx;
79  cluster_idx.reserve(gsfPfRecTracks->size());
80 
81  // Index[GSF track][trajectory point] for "best" PFCluster
82  std::vector<std::vector<int> > pfcluster_idx;
83  pfcluster_idx.reserve(gsfPfRecTracks->size());
84 
85  // dr2min[GSF track][trajectory point] for "best" CaloCluster
86  std::vector<std::vector<float> > cluster_dr2min;
87  cluster_dr2min.reserve(gsfPfRecTracks->size());
88 
89  // Construct list of trajectory points from the GSF track and electron brems
90  std::vector<std::vector<const reco::PFTrajectoryPoint*> > points;
91  points.reserve(gsfPfRecTracks->size());
92  for (auto const& trk : *gsfPfRecTracks) {
93  // Extrapolated track
94  std::vector<const reco::PFTrajectoryPoint*> traj;
95  traj.reserve(trk.PFRecBrem().size() + 1);
96  traj.push_back(&trk.extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax));
97  // Extrapolated brem trajectories
98  for (auto const& brem : trk.PFRecBrem()) {
99  traj.push_back(&brem.extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax));
100  }
101  auto size = traj.size();
102  points.push_back(std::move(traj));
103  // Size containers
104  cluster_idx.emplace_back(size, -1);
105  pfcluster_idx.emplace_back(size, -1);
106  cluster_dr2min.emplace_back(size, 1.e6);
107  }
108 
109  // For each cluster, find closest trajectory point ("global" arbitration at event level)
110  for (size_t iclu = 0; iclu < ecalClusters.size(); ++iclu) { // Cluster loop
111  std::pair<int, int> point = std::make_pair(-1, -1);
112  float dr2min = 1.e6;
113  for (size_t ipoint = 0; ipoint < points.size(); ++ipoint) { // GSF track loop
114  for (size_t jpoint = 0; jpoint < points[ipoint].size(); ++jpoint) { // Traj point loop
115  if (points[ipoint][jpoint]->isValid()) {
116  float dr2 = reco::deltaR2(ecalClusters[iclu], points[ipoint][jpoint]->positionREP());
117  if (dr2 < dr2min) {
118  // Store nearest point to this cluster
119  dr2min = dr2;
120  point = std::make_pair(ipoint, jpoint);
121  }
122  }
123  }
124  }
125  if (point.first >= 0 && point.second >= 0 && // if this cluster is matched to a point ...
126  dr2min < cluster_dr2min[point.first][point.second]) { // ... and cluster is closest to the same point
127  // Copy CaloCluster to new collection
128  caloClusters->push_back(ecalClusters[iclu]);
129  // Store cluster index for creation of SC later
130  cluster_idx[point.first][point.second] = caloClusters->size() - 1;
131  pfcluster_idx[point.first][point.second] = iclu;
132  cluster_dr2min[point.first][point.second] = dr2min;
133  }
134  }
135 
136  // Put CaloClusters in event and get orphan handle
137  const edm::OrphanHandle<reco::CaloClusterCollection>& caloClustersH = event.put(std::move(caloClusters));
138 
139  // Loop through GSF tracks
140  for (size_t itrk = 0; itrk < gsfPfRecTracks->size(); ++itrk) {
141  // Used to create SC
142  float energy = 0.;
143  float X = 0., Y = 0., Z = 0.;
146  std::vector<const reco::PFCluster*> barePtrs;
147 
148  // Find closest match in dr2 from points associated to given track
149  int index = -1;
150  float dr2 = 1.e6;
151  for (size_t ipoint = 0; ipoint < cluster_idx[itrk].size(); ++ipoint) {
152  if (cluster_idx[itrk][ipoint] < 0) {
153  continue;
154  }
155  if (cluster_dr2min[itrk][ipoint] < dr2) {
156  dr2 = cluster_dr2min[itrk][ipoint];
157  index = cluster_idx[itrk][ipoint];
158  }
159  }
160 
161  // For each track, loop through points and use associated cluster
162  for (size_t ipoint = 0; ipoint < cluster_idx[itrk].size(); ++ipoint) {
163  if (cluster_idx[itrk][ipoint] < 0) {
164  continue;
165  }
166  reco::CaloClusterPtr clu(caloClustersH, cluster_idx[itrk][ipoint]);
167  if (clu.isNull()) {
168  continue;
169  }
170  if (!(cluster_dr2min[itrk][ipoint] < dr2_ || // Require cluster to be closer than dr2_ ...
171  index == cluster_idx[itrk][ipoint])) {
172  continue;
173  } // ... unless it is the closest one ...
174  if (seed.isNull()) {
175  seed = clu;
176  }
177  clusters.push_back(clu);
178  energy += clu->correctedEnergy();
179  X += clu->position().X() * clu->correctedEnergy();
180  Y += clu->position().Y() * clu->correctedEnergy();
181  Z += clu->position().Z() * clu->correctedEnergy();
182  auto index = pfcluster_idx[itrk][ipoint];
183  if (index < static_cast<decltype(index)>(ecalClusters.size())) {
184  barePtrs.push_back(&(ecalClusters[index]));
185  }
186  }
187  X /= energy;
188  Y /= energy;
189  Z /= energy;
190 
191  // Create SC
192  if (seed.isNonnull()) {
194  sc.setCorrectedEnergy(energy);
195  sc.setSeed(seed);
196  sc.setClusters(clusters);
197  PFClusterWidthAlgo pfwidth(barePtrs);
198  sc.setEtaWidth(pfwidth.pflowEtaWidth());
199  sc.setPhiWidth(pfwidth.pflowPhiWidth());
200  sc.rawEnergy(); // Cache the value of raw energy
201  superClusters->push_back(sc);
202 
203  // Populate ValueMap container
204  superClustersValueMap.push_back(reco::SuperClusterRef(superClustersRefProd, superClusters->size() - 1));
205  } else {
206  superClustersValueMap.push_back(reco::SuperClusterRef(superClustersRefProd.id()));
207  }
208 
209  } // GSF tracks
210 
211  // Put SuperClusters in event
212  event.put(std::move(superClusters));
213 
214  auto ptr = std::make_unique<edm::ValueMap<reco::SuperClusterRef> >(edm::ValueMap<reco::SuperClusterRef>());
216  filler.insert(gsfPfRecTracks, superClustersValueMap.begin(), superClustersValueMap.end());
217  filler.fill();
218  event.put(std::move(ptr));
219 }

References bsc_activity_cfg::clusters, reco::deltaR2(), dr2_, RecoEcal_cff::ecalClusters, ecalClusters_, HCALHighEnergyHPDFilter_cfi::energy, trigObjTnPSource_cfi::filler, uncleanedOnlyElectronSequence_cff::gsfPfRecTracks, gsfPfRecTracks_, edm::RefProd< C >::id(), plotBeamSpotDB::ipoint, edm::Ptr< T >::isNull(), edm::makeValid(), eostools::move(), PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), point, HLT_FULL_cff::points, reco::SuperCluster::rawEnergy(), fileCollector::seed, reco::SuperCluster::setClusters(), reco::CaloCluster::setCorrectedEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), reco::SuperCluster::setSeed(), findQualityFiles::size, HLT_FULL_cff::superClusters, X, BeamSpotPI::Y, and BeamSpotPI::Z.

Member Data Documentation

◆ dr2_

const double LowPtGsfElectronSCProducer::dr2_
private

Definition at line 42 of file LowPtGsfElectronSCProducer.cc.

Referenced by closestCluster(), and produce().

◆ ecalClusters_

const edm::EDGetTokenT<reco::PFClusterCollection> LowPtGsfElectronSCProducer::ecalClusters_
private

Definition at line 41 of file LowPtGsfElectronSCProducer.cc.

Referenced by produce().

◆ gsfPfRecTracks_

const edm::EDGetTokenT<reco::GsfPFRecTrackCollection> LowPtGsfElectronSCProducer::gsfPfRecTracks_
private

Definition at line 40 of file LowPtGsfElectronSCProducer.cc.

Referenced by produce().

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
edm::RefProd
Definition: EDProductfwd.h:25
reco::PFClusterCollection
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
edm::RefProd::id
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:124
LowPtGsfElectronSCProducer::gsfPfRecTracks_
const edm::EDGetTokenT< reco::GsfPFRecTrackCollection > gsfPfRecTracks_
Definition: LowPtGsfElectronSCProducer.cc:40
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21521
reco::SuperCluster
Definition: SuperCluster.h:18
X
#define X(str)
Definition: MuonsGrabber.cc:38
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Ref::index
key_type index() const
Definition: Ref.h:253
edm::Ref< PFClusterCollection >
HLT_FULL_cff.superClusters
superClusters
Definition: HLT_FULL_cff.py:15237
reco::PFClusterRef
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
Definition: PFClusterFwd.h:15
uncleanedOnlyElectronSequence_cff.gsfPfRecTracks
gsfPfRecTracks
Definition: uncleanedOnlyElectronSequence_cff.py:141
fileCollector.seed
seed
Definition: fileCollector.py:127
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::PtrVector< CaloCluster >
reco::CaloClusterCollection
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
Definition: CaloClusterFwd.h:19
plotBeamSpotDB.ipoint
ipoint
Definition: plotBeamSpotDB.py:340
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
LowPtGsfElectronSCProducer::ecalClusters_
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
Definition: LowPtGsfElectronSCProducer.cc:41
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
RecoEcal_cff.ecalClusters
ecalClusters
Definition: RecoEcal_cff.py:26
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
edm::makeValid
auto makeValid(const U &iOtherHandleType) noexcept(false)
Definition: ValidHandle.h:52
edm::Ptr< CaloCluster >
looper.cfg
cfg
Definition: looper.py:297
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
edm::ValueMap
Definition: ValueMap.h:107
PFClusterWidthAlgo
Definition: PFClusterWidthAlgo.h:6
LowPtGsfElectronSCProducer::dr2_
const double dr2_
Definition: LowPtGsfElectronSCProducer.cc:42
BeamSpotPI::Y
Definition: BeamSpotPayloadInspectorHelper.h:31
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::helper::Filler
Definition: ValueMap.h:22
BeamSpotPI::Z
Definition: BeamSpotPayloadInspectorHelper.h:32
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
event
Definition: event.py:1
cuy.ii
ii
Definition: cuy.py:590
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37