CMS 3D CMS Logo

GSFTrackImporter.cc
Go to the documentation of this file.
13 
15 public:
17  edm::ConsumesCollector& sumes) :
18  BlockElementImporterBase(conf,sumes),
19  _src(sumes.consumes<reco::GsfPFRecTrackCollection>(conf.getParameter<edm::InputTag>("source"))),
20  _isSecondary(conf.getParameter<bool>("gsfsAreSecondary")),
21  _superClustersArePF(conf.getParameter<bool>("superClustersArePF")){}
22 
23  void importToBlock( const edm::Event& ,
24  ElementList& ) const override;
25 
26 private:
29 };
30 
33  "GSFTrackImporter");
34 
40  e.getByToken(_src,gsftracks);
41  elems.reserve(elems.size() + gsftracks->size());
42  // setup our elements so that all the SCs are grouped together
43  auto SCs_end = std::partition(elems.begin(),elems.end(),
44  [](const ElementType& a){
45  return a->type() == reco::PFBlockElement::SC;
46  });
47  size_t SCs_end_position = std::distance(elems.begin(),SCs_end);
48  // insert gsf tracks and SCs, binding pre-existing SCs to ECAL-Driven GSF
49  auto bgsf = gsftracks->cbegin();
50  auto egsf = gsftracks->cend();
51  for( auto gsftrack = bgsf; gsftrack != egsf; ++gsftrack ) {
52  reco::GsfPFRecTrackRef gsfref(gsftracks,std::distance(bgsf,gsftrack));
53  const reco::GsfTrackRef& basegsfref = gsftrack->gsfTrackRef();
54  const auto& gsfextraref = basegsfref->extra();
55  // import associated super clusters
56  if( gsfextraref.isAvailable() && gsfextraref->seedRef().isAvailable()) {
57  reco::ElectronSeedRef seedref =
58  gsfextraref->seedRef().castTo<reco::ElectronSeedRef>();
59  if( seedref.isAvailable() && seedref->isEcalDriven() ) {
60  reco::SuperClusterRef scref =
61  seedref->caloCluster().castTo<reco::SuperClusterRef>();
62  if( scref.isNonnull() ) {
63  // explicitly veto HGCal super clusters
64  if( scref->seed()->seed().det() == DetId::Forward ) continue;
65  PFBlockElementSCEqual myEqual(scref);
66  auto sc_elem = std::find_if(elems.begin(),SCs_end,myEqual);
67  if( sc_elem != SCs_end ) {
69  static_cast<reco::PFBlockElementSuperCluster*>(sc_elem->get());
70  scbe->setFromGsfElectron(true);
71  } else {
74  scbe->setFromGsfElectron(true);
76  SCs_end = elems.insert(SCs_end,ElementType(scbe));
77  ++SCs_end; // point to element *after* the new one
78  }
79  }
80  }
81  }// gsf extra ref?
82  // cache the SC_end offset
83  SCs_end_position = std::distance(elems.begin(),SCs_end);
84  // get track momentum information
85  const std::vector<reco::PFTrajectoryPoint>& PfGsfPoint
86  = gsftrack->trajectoryPoints();
87  unsigned int c_gsf=0;
88  bool PassTracker = false;
89  bool GetPout = false;
90  unsigned int IndexPout = 0;
91  for(auto itPfGsfPoint = PfGsfPoint.begin();
92  itPfGsfPoint!= PfGsfPoint.end();++itPfGsfPoint) {
93  if (itPfGsfPoint->isValid()){
94  int layGsfP = itPfGsfPoint->layer();
95  if (layGsfP == -1) PassTracker = true;
96  if (PassTracker && layGsfP > 0 && GetPout == false) {
97  IndexPout = c_gsf-1;
98  GetPout = true;
99  }
100  //const math::XYZTLorentzVector GsfMoment = itPfGsfPoint->momentum();
101  ++c_gsf;
102  }
103  }
104  const math::XYZTLorentzVector& pin = PfGsfPoint[0].momentum();
105  const math::XYZTLorentzVector& pout = PfGsfPoint[IndexPout].momentum();
107  new reco::PFBlockElementGsfTrack(gsfref,pin,pout);
108  if( _isSecondary ) {
110  }
111  elems.emplace_back(temp);
112  // import brems from this primary gsf
113  for( const auto& brem : gsfref->PFRecBrem() ) {
114  const unsigned TrajP = brem.indTrajPoint();
115  if( TrajP != 99 ) {
116  const double DP = brem.DeltaP();
117  const double sDP = brem.SigmaDeltaP();
118  elems.emplace_back(new reco::PFBlockElementBrem(gsfref,DP,sDP,TrajP));
119  }
120  }
121  // protect against reallocations, create a fresh iterator
122  SCs_end = elems.begin() + SCs_end_position;
123  }// loop on gsf tracks
124  elems.shrink_to_fit();
125 }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const bool _isSecondary
void setFromGsfElectron(bool val)
set provenance
GSFTrackImporter(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
virtual void setTrackType(TrackType trType, bool value)
the trackType
void importToBlock(const edm::Event &, ElementList &) const override
fixed size matrix
HLT enums.
double a
Definition: hdecay.h:121
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
edm::EDGetTokenT< reco::GsfPFRecTrackCollection > _src
const bool _superClustersArePF