CMS 3D CMS Logo

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

std::string label_
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 18 of file MultiClustersFromTrackstersProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 34 of file MultiClustersFromTrackstersProducer.cc.

References label_.

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

Definition at line 21 of file MultiClustersFromTrackstersProducer.cc.

References fillDescriptions(), and produce().

21 {}

Member Function Documentation

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

Definition at line 41 of file MultiClustersFromTrackstersProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~MultiClustersFromTrackstersProducer().

41  {
42  // hgcalMultiClusters
44  desc.add<edm::InputTag>("Tracksters", edm::InputTag("Tracksters", "TrackstersByCA"));
45  desc.add<edm::InputTag>("LayerClusters", edm::InputTag("hgcalLayerClusters"));
46  desc.add<std::string>("label", "MultiClustersFromTracksterByCA");
47  desc.addUntracked<unsigned int>("verbosity", 3);
48  descriptions.add("multiClustersFromTrackstersProducer", desc);
49 }
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 51 of file MultiClustersFromTrackstersProducer.cc.

References begin, end, HLT_2018_cff::fraction, edm::Event::getByToken(), reco::CaloCluster::hgcal_em, mps_fire::i, training_settings::idx, label_, layer_clusters_token_, eostools::move(), edm::PtrVector< T >::push_back(), groupFilesInBlocks::temp, tracksters_token_, HcalDetIdTransform::transform(), heppy_batch::val, and mps_merge::weight.

Referenced by ~MultiClustersFromTrackstersProducer().

51  {
52  auto multiclusters = std::make_unique<std::vector<reco::HGCalMultiCluster>>();
54  evt.getByToken(tracksters_token_, tracksterHandle);
55 
56  edm::Handle<std::vector<reco::CaloCluster>> layer_clustersHandle;
57  evt.getByToken(layer_clusters_token_, layer_clustersHandle);
58 
59  auto const& tracksters = *tracksterHandle;
60  auto const& layerClusters = *layer_clustersHandle;
61 
63  for (unsigned i = 0; i < layerClusters.size(); ++i) {
64  edm::Ptr<reco::BasicCluster> ptr(layer_clustersHandle, i);
65  clusterPtrs.push_back(ptr);
66  }
67 
68  std::for_each(std::begin(tracksters), std::end(tracksters), [&](auto const& trackster) {
69  std::array<double, 3> baricenter{{0., 0., 0.}};
70  double total_weight = 0.;
72  int counter = 0;
73  std::for_each(std::begin(trackster.vertices), std::end(trackster.vertices), [&](unsigned int idx) {
74  temp.push_back(clusterPtrs[idx]);
75  auto fraction = 1.f / trackster.vertex_multiplicity[counter++];
76  for (auto const& cell : clusterPtrs[idx]->hitsAndFractions()) {
77  temp.addHitAndFraction(cell.first, cell.second * fraction);
78  }
79  auto weight = clusterPtrs[idx]->energy() * fraction;
80  total_weight += weight;
81  baricenter[0] += clusterPtrs[idx]->x() * weight;
82  baricenter[1] += clusterPtrs[idx]->y() * weight;
83  baricenter[2] += clusterPtrs[idx]->z() * weight;
84  });
86  std::begin(baricenter), std::end(baricenter), std::begin(baricenter), [&total_weight](double val) -> double {
87  return val / total_weight;
88  });
89  temp.setEnergy(total_weight);
90  temp.setCorrectedEnergy(total_weight);
91  temp.setPosition(math::XYZPoint(baricenter[0], baricenter[1], baricenter[2]));
93  multiclusters->push_back(temp);
94  });
95 
96  evt.put(std::move(multiclusters), label_);
97 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
void setPosition(const math::XYZPoint &p)
Definition: CaloCluster.h:139
void setEnergy(double energy)
Definition: CaloCluster.h:135
Definition: weight.py:1
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksters_token_
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:136
#define end
Definition: vmac.h:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void setAlgoId(const AlgoId &id)
Definition: CaloCluster.h:143
#define begin
Definition: vmac.h:32
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layer_clusters_token_
def move(src, dest)
Definition: eostools.py:511
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

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

Definition at line 28 of file MultiClustersFromTrackstersProducer.cc.

Referenced by produce().

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

Definition at line 29 of file MultiClustersFromTrackstersProducer.cc.

Referenced by produce().