CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
MultiClustersFromTrackstersProducer Class Reference
Inheritance diagram for MultiClustersFromTrackstersProducer:
edm::stream::EDProducer<>

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< std::vector
< reco::CaloCluster > > 
layer_clusters_token_
 
edm::EDGetTokenT< std::vector
< ticl::Trackster > > 
tracksters_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 18 of file MultiClustersFromTrackstersProducer.cc.

Constructor & Destructor Documentation

MultiClustersFromTrackstersProducer::MultiClustersFromTrackstersProducer ( const edm::ParameterSet ps)

Definition at line 33 of file MultiClustersFromTrackstersProducer.cc.

34  : layer_clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("LayerClusters"))),
35  tracksters_token_(consumes<std::vector<ticl::Trackster>>(ps.getParameter<edm::InputTag>("Tracksters"))) {
36  produces<std::vector<reco::HGCalMultiCluster>>();
37 }
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksters_token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
MultiClustersFromTrackstersProducer::~MultiClustersFromTrackstersProducer ( )
inlineoverride

Definition at line 21 of file MultiClustersFromTrackstersProducer.cc.

21 {}

Member Function Documentation

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

Definition at line 39 of file MultiClustersFromTrackstersProducer.cc.

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

39  {
40  // hgcalMultiClusters
42  desc.add<edm::InputTag>("Tracksters", edm::InputTag("Tracksters", "TrackstersByCA"));
43  desc.add<edm::InputTag>("LayerClusters", edm::InputTag("hgcalLayerClusters"));
44  desc.addUntracked<unsigned int>("verbosity", 3);
45  descriptions.add("multiClustersFromTrackstersProducer", desc);
46 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void MultiClustersFromTrackstersProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 48 of file MultiClustersFromTrackstersProducer.cc.

References reco::CaloCluster::addHitAndFraction(), SplitLinear::begin, counter, dataset::end, HLT_FULL_cff::fraction, edm::Event::getByToken(), reco::CaloCluster::hgcal_em, mps_fire::i, layer_clusters_token_, eostools::move(), reco::HGCalMultiCluster::push_back(), edm::PtrVector< T >::push_back(), edm::Event::put(), reco::CaloCluster::setAlgoId(), reco::CaloCluster::setCorrectedEnergy(), reco::CaloCluster::setEnergy(), reco::CaloCluster::setPosition(), reco::PFCluster::setTime(), groupFilesInBlocks::temp, tracksters_token_, HcalDetIdTransform::transform(), hgcalPerformanceValidation::val, and histoStyle::weight.

48  {
49  auto multiclusters = std::make_unique<std::vector<reco::HGCalMultiCluster>>();
51  evt.getByToken(tracksters_token_, tracksterHandle);
52 
53  edm::Handle<std::vector<reco::CaloCluster>> layer_clustersHandle;
54  evt.getByToken(layer_clusters_token_, layer_clustersHandle);
55 
56  auto const& tracksters = *tracksterHandle;
57  auto const& layerClusters = *layer_clustersHandle;
58 
60  for (unsigned i = 0; i < layerClusters.size(); ++i) {
61  edm::Ptr<reco::BasicCluster> ptr(layer_clustersHandle, i);
62  clusterPtrs.push_back(ptr);
63  }
64 
65  std::for_each(std::begin(tracksters), std::end(tracksters), [&](auto const& trackster) {
66  // Create an empty multicluster if the trackster has no layer clusters.
67  // This could happen when a seed leads to no trackster and a dummy one is produced.
68 
69  std::array<double, 3> baricenter{{0., 0., 0.}};
70  double total_weight = 0.;
72  int counter = 0;
73  if (!trackster.vertices().empty()) {
74  std::for_each(std::begin(trackster.vertices()), std::end(trackster.vertices()), [&](unsigned int idx) {
75  temp.push_back(clusterPtrs[idx]);
76  auto fraction = 1.f / trackster.vertex_multiplicity(counter++);
77  for (auto const& cell : clusterPtrs[idx]->hitsAndFractions()) {
78  temp.addHitAndFraction(cell.first, cell.second * fraction);
79  }
80  auto weight = clusterPtrs[idx]->energy() * fraction;
81  total_weight += weight;
82  baricenter[0] += clusterPtrs[idx]->x() * weight;
83  baricenter[1] += clusterPtrs[idx]->y() * weight;
84  baricenter[2] += clusterPtrs[idx]->z() * weight;
85  });
87  std::begin(baricenter), std::end(baricenter), std::begin(baricenter), [&total_weight](double val) -> double {
88  return val / total_weight;
89  });
90  }
91  temp.setEnergy(total_weight);
92  temp.setCorrectedEnergy(total_weight);
93  temp.setPosition(math::XYZPoint(baricenter[0], baricenter[1], baricenter[2]));
95  temp.setTime(trackster.time(), trackster.timeError());
96  multiclusters->push_back(temp);
97  });
98 
99  evt.put(std::move(multiclusters));
100 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void addHitAndFraction(DetId id, float fraction)
Definition: CaloCluster.h:203
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:140
void setTime(float time, float timeError=0)
Definition: PFCluster.h:84
void setEnergy(double energy)
Definition: CaloCluster.h:136
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksters_token_
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
void push_back(const edm::Ptr< reco::BasicCluster > &b)
def move
Definition: eostools.py:511
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:144
static std::atomic< unsigned int > counter
string end
Definition: dataset.py:937
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
int weight
Definition: histoStyle.py:51
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

edm::EDGetTokenT<std::vector<reco::CaloCluster> > MultiClustersFromTrackstersProducer::layer_clusters_token_
private

Definition at line 27 of file MultiClustersFromTrackstersProducer.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<ticl::Trackster> > MultiClustersFromTrackstersProducer::tracksters_token_
private

Definition at line 28 of file MultiClustersFromTrackstersProducer.cc.

Referenced by produce().