CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ticl::TracksterP4FromEnergySum Class Referencefinal
Inheritance diagram for ticl::TracksterP4FromEnergySum:
ticl::TracksterMomentumPluginBase

Public Member Functions

void setP4 (const std::vector< const Trackster * > &tracksters, std::vector< TICLCandidate > &ticl_cands, edm::Event &event) const override
 
 TracksterP4FromEnergySum (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
- Public Member Functions inherited from ticl::TracksterMomentumPluginBase
 TracksterMomentumPluginBase (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
virtual ~TracksterMomentumPluginBase ()
 

Private Member Functions

std::tuple< TracksterMomentumPluginBase::LorentzVector, float > calcP4 (const ticl::Trackster &trackster, const reco::Vertex &vertex, const std::vector< reco::CaloCluster > &calo_clusters) const
 

Private Attributes

bool energy_from_regression_
 
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
 
edm::EDGetTokenT< std::vector< reco::Vertex > > vertex_token_
 

Additional Inherited Members

- Public Types inherited from ticl::TracksterMomentumPluginBase
typedef reco::Candidate::LorentzVector LorentzVector
 

Detailed Description

Definition at line 11 of file TracksterP4FromEnergySumPlugin.cc.

Constructor & Destructor Documentation

◆ TracksterP4FromEnergySum()

ticl::TracksterP4FromEnergySum::TracksterP4FromEnergySum ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 28 of file TracksterP4FromEnergySumPlugin.cc.

30  energy_from_regression_(ps.getParameter<bool>("energyFromRegression")),
31  vertex_token_(ic.consumes<std::vector<reco::Vertex>>(ps.getParameter<edm::InputTag>("vertices"))),
33  ic.consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layerClusters"))) {}

Member Function Documentation

◆ calcP4()

std::tuple< TracksterMomentumPluginBase::LorentzVector, float > ticl::TracksterP4FromEnergySum::calcP4 ( const ticl::Trackster trackster,
const reco::Vertex vertex,
const std::vector< reco::CaloCluster > &  calo_clusters 
) const
private

Definition at line 64 of file TracksterP4FromEnergySumPlugin.cc.

67  {
68  std::array<double, 3> barycentre{{0., 0., 0.}};
69  double energy = 0.;
70  size_t counter = 0;
71 
72  for (auto idx : trackster.vertices()) {
73  auto n_vertices = trackster.vertex_multiplicity(counter++);
74  auto fraction = n_vertices ? 1.f / n_vertices : 1.f;
75  auto weight = calo_clusters[idx].energy() * fraction;
76  energy += weight;
77  barycentre[0] += calo_clusters[idx].x() * weight;
78  barycentre[1] += calo_clusters[idx].y() * weight;
79  barycentre[2] += calo_clusters[idx].z() * weight;
80  }
82  std::begin(barycentre), std::end(barycentre), std::begin(barycentre), [&energy](double val) -> double {
83  return energy >= 0. ? val / energy : val;
84  });
85 
86  math::XYZVector direction(barycentre[0] - vertex.x(), barycentre[1] - vertex.y(), barycentre[2] - vertex.z());
87  direction = direction.Unit();
88  auto raw_energy = energy;
89  energy = energy_from_regression_ ? trackster.regressed_energy() : raw_energy;
90  direction *= energy;
91 
92  math::XYZTLorentzVector cartesian(direction.X(), direction.Y(), direction.Z(), energy);
93  // Convert px, py, pz, E vector to CMS standard pt/eta/phi/m vector
95  return std::tuple(p4, raw_energy);
96  }

References mps_fire::end, HCALHighEnergyHPDFilter_cfi::energy, energy_from_regression_, HLT_FULL_cff::fraction, heavyIonCSV_trainingSettings::idx, p4, ticl::Trackster::regressed_energy(), HcalDetIdTransform::transform(), heppy_batch::val, bphysicsOniaDQM_cfi::vertex, ticl::Trackster::vertex_multiplicity(), ticl::Trackster::vertices(), and mps_merge::weight.

Referenced by setP4().

◆ setP4()

void ticl::TracksterP4FromEnergySum::setP4 ( const std::vector< const Trackster * > &  tracksters,
std::vector< TICLCandidate > &  ticl_cands,
edm::Event event 
) const
overridevirtual

Implements ticl::TracksterMomentumPluginBase.

Definition at line 35 of file TracksterP4FromEnergySumPlugin.cc.

37  {
38  // Find best vertex
40  event.getByToken(vertex_token_, vertex_h);
41  auto vertex_coll = *vertex_h;
42  reco::Vertex best_vertex;
43  if (!vertex_coll.empty()) {
44  const auto& vertex = vertex_coll[0];
45  if (vertex.isValid() && !(vertex.isFake())) {
46  best_vertex = vertex;
47  }
48  }
49 
51  event.getByToken(layer_clusters_token_, layer_clusters_h);
52 
53  auto size = std::min(tracksters.size(), ticl_cands.size());
54  for (size_t i = 0; i < size; ++i) {
55  const auto* trackster = tracksters[i];
56  auto ret = calcP4(*trackster, best_vertex, *layer_clusters_h);
57 
58  auto& ticl_cand = ticl_cands[i];
59  ticl_cand.setP4(std::get<0>(ret));
60  ticl_cand.setRawEnergy(std::get<1>(ret));
61  }
62  }

References calcP4(), mps_fire::i, layer_clusters_token_, min(), runTheMatrix::ret, findQualityFiles::size, bphysicsOniaDQM_cfi::vertex, and vertex_token_.

Referenced by Jet.Jet::setCorrP4().

Member Data Documentation

◆ energy_from_regression_

bool ticl::TracksterP4FromEnergySum::energy_from_regression_
private

Definition at line 23 of file TracksterP4FromEnergySumPlugin.cc.

Referenced by calcP4().

◆ layer_clusters_token_

edm::EDGetTokenT<std::vector<reco::CaloCluster> > ticl::TracksterP4FromEnergySum::layer_clusters_token_
private

Definition at line 25 of file TracksterP4FromEnergySumPlugin.cc.

Referenced by setP4().

◆ vertex_token_

edm::EDGetTokenT<std::vector<reco::Vertex> > ticl::TracksterP4FromEnergySum::vertex_token_
private

Definition at line 24 of file TracksterP4FromEnergySumPlugin.cc.

Referenced by setP4().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
counter
Definition: counter.py:1
mps_fire.i
i
Definition: mps_fire.py:428
ticl::TracksterMomentumPluginBase::LorentzVector
reco::Candidate::LorentzVector LorentzVector
Definition: TracksterMomentumPluginBase.h:17
min
T min(T a, T b)
Definition: MathUtil.h:58
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::Handle
Definition: AssociativeIterator.h:50
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
ticl::TracksterP4FromEnergySum::layer_clusters_token_
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
Definition: TracksterP4FromEnergySumPlugin.cc:25
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52858
ticl::Trackster::vertex_multiplicity
std::vector< uint8_t > & vertex_multiplicity()
Definition: Trackster.h:54
mps_fire.end
end
Definition: mps_fire.py:242
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
ticl::TracksterMomentumPluginBase::TracksterMomentumPluginBase
TracksterMomentumPluginBase(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
Definition: TracksterMomentumPluginBase.h:16
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
p4
double p4[4]
Definition: TauolaWrapper.h:92
ticl::TracksterP4FromEnergySum::vertex_token_
edm::EDGetTokenT< std::vector< reco::Vertex > > vertex_token_
Definition: TracksterP4FromEnergySumPlugin.cc:24
ticl::TracksterP4FromEnergySum::calcP4
std::tuple< TracksterMomentumPluginBase::LorentzVector, float > calcP4(const ticl::Trackster &trackster, const reco::Vertex &vertex, const std::vector< reco::CaloCluster > &calo_clusters) const
Definition: TracksterP4FromEnergySumPlugin.cc:64
ticl::TracksterP4FromEnergySum::energy_from_regression_
bool energy_from_regression_
Definition: TracksterP4FromEnergySumPlugin.cc:23
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
ticl::Trackster::vertices
std::vector< unsigned int > & vertices()
Definition: Trackster.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ticl::Trackster::regressed_energy
const float regressed_energy() const
Definition: Trackster.h:125
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
reco::Vertex
Definition: Vertex.h:35
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443