CMS 3D CMS Logo

GSFTrackImporter.cc
Go to the documentation of this file.
10 
12 public:
14  : BlockElementImporterBase(conf, sumes),
15  _src(sumes.consumes<reco::GsfPFRecTrackCollection>(conf.getParameter<edm::InputTag>("source"))),
16  _isSecondary(conf.getParameter<bool>("gsfsAreSecondary")),
17  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")) {}
18 
19  void importToBlock(const edm::Event&, ElementList&) const override;
20 
21 private:
24 };
25 
27 
29  auto gsftracks = e.getHandle(_src);
30  elems.reserve(elems.size() + gsftracks->size());
31  // setup our elements so that all the SCs are grouped together
32  auto SCs_end =
33  std::partition(elems.begin(), elems.end(), [](const auto& a) { return a->type() == reco::PFBlockElement::SC; });
34  // insert gsf tracks and SCs, binding pre-existing SCs to ECAL-Driven GSF
35  auto bgsf = gsftracks->cbegin();
36  auto egsf = gsftracks->cend();
37  for (auto gsftrack = bgsf; gsftrack != egsf; ++gsftrack) {
38  reco::GsfPFRecTrackRef gsfref(gsftracks, std::distance(bgsf, gsftrack));
39  const reco::GsfTrackRef& basegsfref = gsftrack->gsfTrackRef();
40  const auto& gsfextraref = basegsfref->extra();
41  // import associated super clusters
42  if (gsfextraref.isAvailable() && gsfextraref->seedRef().isAvailable()) {
43  reco::ElectronSeedRef seedref = gsfextraref->seedRef().castTo<reco::ElectronSeedRef>();
44  if (seedref.isAvailable() && seedref->isEcalDriven()) {
45  reco::SuperClusterRef scref = seedref->caloCluster().castTo<reco::SuperClusterRef>();
46  if (scref.isNonnull()) {
47  // explicitly veto HGCal super clusters
48  if (scref->seed()->seed().det() == DetId::HGCalEE || scref->seed()->seed().det() == DetId::HGCalHSi ||
49  scref->seed()->seed().det() == DetId::HGCalHSc || scref->seed()->seed().det() == DetId::Forward)
50  continue;
51  PFBlockElementSCEqual myEqual(scref);
52  auto sc_elem = std::find_if(elems.begin(), SCs_end, myEqual);
53  if (sc_elem != SCs_end) {
54  reco::PFBlockElementSuperCluster* scbe = static_cast<reco::PFBlockElementSuperCluster*>(sc_elem->get());
55  scbe->setFromGsfElectron(true);
56  } else {
58  scbe->setFromGsfElectron(true);
60  SCs_end = elems.emplace(SCs_end, scbe);
61  ++SCs_end; // point to element *after* the new one
62  }
63  }
64  }
65  } // gsf extra ref?
66  // cache the SC_end offset
67  size_t SCs_end_position = std::distance(elems.begin(), SCs_end);
68  // get track momentum information
69  const std::vector<reco::PFTrajectoryPoint>& PfGsfPoint = gsftrack->trajectoryPoints();
70  unsigned int c_gsf = 0;
71  bool PassTracker = false;
72  unsigned int IndexPout = 0;
73  for (const auto& pfGsfPoint : PfGsfPoint) {
74  if (pfGsfPoint.isValid()) {
75  int layGsfP = pfGsfPoint.layer();
76  if (layGsfP == -1)
77  PassTracker = true;
78  else if (PassTracker && layGsfP > 0) {
79  IndexPout = c_gsf - 1;
80  break;
81  }
82  ++c_gsf;
83  }
84  }
85  const math::XYZTLorentzVector& pin = PfGsfPoint[0].momentum();
86  const math::XYZTLorentzVector& pout = PfGsfPoint[IndexPout].momentum();
88  if (_isSecondary) {
89  temp->setTrackType(reco::PFBlockElement::T_FROM_GAMMACONV, true);
90  }
91  elems.emplace_back(temp);
92  // import brems from this primary gsf
93  for (const auto& brem : gsfref->PFRecBrem()) {
94  const unsigned TrajP = brem.indTrajPoint();
95  if (TrajP != 99) {
96  const double DP = brem.DeltaP();
97  const double sDP = brem.SigmaDeltaP();
98  elems.emplace_back(new reco::PFBlockElementBrem(gsfref, DP, sDP, TrajP));
99  }
100  }
101  // protect against reallocations, create a fresh iterator
102  SCs_end = elems.begin() + SCs_end_position;
103  } // loop on gsf tracks
104  elems.shrink_to_fit();
105 }
GSFTrackImporter
Definition: GSFTrackImporter.cc:11
electrons_cff.bool
bool
Definition: electrons_cff.py:372
reco::GsfPFRecTrackCollection
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
Definition: GsfPFRecTrackFwd.h:9
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
edm::EDGetTokenT< reco::GsfPFRecTrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::PFBlockElementSuperCluster
Cluster Element.
Definition: PFBlockElementSuperCluster.h:15
reco::PFBlockElement::SC
Definition: PFBlockElement.h:41
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
GSFTrackImporter::_src
edm::EDGetTokenT< reco::GsfPFRecTrackCollection > _src
Definition: GSFTrackImporter.cc:22
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PFBlockElementBrem.h
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
GSFTrackImporter::_superClustersArePF
const bool _superClustersArePF
Definition: GSFTrackImporter.cc:23
edm::Ref< GsfPFRecTrackCollection >
DetId::HGCalHSi
Definition: DetId.h:33
DetId::HGCalEE
Definition: DetId.h:32
BlockElementImporterBase.h
PFBlockElementSCEqual
Definition: PFBlockElementSCEqual.h:7
PFCluster.h
reco::PFBlockElementBrem
Track Element.
Definition: PFBlockElementBrem.h:17
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
BlockElementImporterBase::ElementList
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: BlockElementImporterBase.h:16
reco::PFBlockElementSuperCluster::setFromPFSuperCluster
void setFromPFSuperCluster(bool val)
Definition: PFBlockElementSuperCluster.h:61
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
a
double a
Definition: hdecay.h:119
edmplugin::PluginFactory
Definition: PluginFactory.h:34
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
GsfTrack.h
reco::PFBlockElement::T_FROM_GAMMACONV
Definition: PFBlockElement.h:47
GSFTrackImporter::importToBlock
void importToBlock(const edm::Event &, ElementList &) const override
Definition: GSFTrackImporter.cc:28
reco::PFBlockElementSuperCluster::setFromGsfElectron
void setFromGsfElectron(bool val)
set provenance
Definition: PFBlockElementSuperCluster.h:56
GSFTrackImporter::GSFTrackImporter
GSFTrackImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
Definition: GSFTrackImporter.cc:13
reco::PFBlockElementGsfTrack
Track Element.
Definition: PFBlockElementGsfTrack.h:18
DetId::HGCalHSc
Definition: DetId.h:34
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
SuperCluster.h
GSFTrackImporter::_isSecondary
const bool _isSecondary
Definition: GSFTrackImporter.cc:23
PFBlockElementSCEqual.h
GsfPFRecTrack.h
DetId::Forward
Definition: DetId.h:30
edm::Event
Definition: Event.h:73
PFBlockElementGsfTrack.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
ElectronSeed.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
BlockElementImporterBase
Definition: BlockElementImporterBase.h:14