CMS 3D CMS Logo

TracksterP4FromTrackAndPCA.cc
Go to the documentation of this file.
1 // Plugin for getting the four-vector of a Trackster from the track, if
2 // present, or from PCA decomposition.
3 
9 
10 namespace ticl {
12  public:
14  void setP4(const std::vector<const Trackster*>& tracksters,
15  std::vector<TICLCandidate>& ticl_cands,
16  edm::Event& event) const override;
17 
18  private:
19  std::tuple<TracksterMomentumPluginBase::LorentzVector, float> calcP4(const ticl::Trackster& trackster) const;
22  };
23 
26  energy_from_regression_(ps.getParameter<bool>("energyFromRegression")),
27  tracks_token_(ic.consumes<reco::TrackCollection>(ps.getParameter<edm::InputTag>("tracks"))) {}
28 
29  void TracksterP4FromTrackAndPCA::setP4(const std::vector<const Trackster*>& tracksters,
30  std::vector<TICLCandidate>& ticl_cands,
31  edm::Event& event) const {
33  event.getByToken(tracks_token_, tracks_h);
34  edm::ProductID trkId = tracks_h.id();
35  const reco::TrackCollection& trackCollection = *tracks_h.product();
36 
37  auto size = std::min(tracksters.size(), ticl_cands.size());
38  for (size_t i = 0; i < size; ++i) {
39  const auto* trackster = tracksters[i];
40  // If there's a track, use it.
41  if (trackster->seedIndex() != -1) {
42  assert(trackster->seedID() == trkId);
43  auto const& tkRef = trackCollection[trackster->seedIndex()];
44  auto const& three_mom = tkRef.momentum();
45  constexpr double mpion2 = 0.13957 * 0.13957;
46  double energy = std::sqrt(tkRef.momentum().mag2() + mpion2);
47  math::XYZTLorentzVector trk_p4(three_mom.x(), three_mom.y(), three_mom.z(), energy);
48  auto& ticl_cand = ticl_cands[i];
49  ticl_cand.setP4(trk_p4);
50  ticl_cand.setRawEnergy(energy);
51  } else {
52  auto direction = trackster->eigenvectors(0).Unit();
53  auto energy = energy_from_regression_ ? trackster->regressed_energy() : trackster->raw_energy();
54  direction *= energy;
55  math::XYZTLorentzVector cartesian(direction.X(), direction.Y(), direction.Z(), energy);
56  auto& ticl_cand = ticl_cands[i];
57  ticl_cand.setP4(cartesian);
58  ticl_cand.setRawEnergy(energy);
59  }
60  }
61  }
62 } // namespace ticl
63 
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
cms::cuda::assert
assert(be >=bs)
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ticl
Definition: Common.h:8
edm::Handle< reco::TrackCollection >
ticl::TracksterMomentumPluginBase
Definition: TracksterMomentumPluginBase.h:14
MakerMacros.h
ticl::TracksterP4FromTrackAndPCA::tracks_token_
edm::EDGetTokenT< reco::TrackCollection > tracks_token_
Definition: TracksterP4FromTrackAndPCA.cc:21
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
ParameterSetDescription.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
ticl::TracksterP4FromTrackAndPCA
Definition: TracksterP4FromTrackAndPCA.cc:11
edm::ParameterSet
Definition: ParameterSet.h:47
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
Event.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
LorentzVector.h
ticl::TracksterP4FromTrackAndPCA::calcP4
std::tuple< TracksterMomentumPluginBase::LorentzVector, float > calcP4(const ticl::Trackster &trackster) const
ticl::TracksterP4FromTrackAndPCA::setP4
void setP4(const std::vector< const Trackster * > &tracksters, std::vector< TICLCandidate > &ticl_cands, edm::Event &event) const override
Definition: TracksterP4FromTrackAndPCA.cc:29
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
ConsumesCollector.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
ticl::TracksterP4FromTrackAndPCA::energy_from_regression_
bool energy_from_regression_
Definition: TracksterP4FromTrackAndPCA.cc:20
ticl::TracksterP4FromTrackAndPCA::TracksterP4FromTrackAndPCA
TracksterP4FromTrackAndPCA(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
Definition: TracksterP4FromTrackAndPCA.cc:24
edm::HandleBase::id
ProductID id() const
Definition: HandleBase.cc:29
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
TracksterMomentumPluginBase.h
edm::ProductID
Definition: ProductID.h:27
ticl::Trackster
Definition: Trackster.h:19
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443