CMS 3D CMS Logo

AllLayerClusterToTracksterAssociatorsProducer.cc
Go to the documentation of this file.
1 // Author: Felice Pantaleo, felice.pantaleo@cern.ch 08/2024
2 
13 
15 public:
18 
19  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
20 
21 private:
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
25  std::vector<std::pair<std::string, edm::EDGetTokenT<std::vector<ticl::Trackster>>>> tracksterCollectionTokens_;
26 };
27 
29  const edm::ParameterSet& pset)
30  : layerClustersToken_(
31  consumes<std::vector<reco::CaloCluster>>(pset.getParameter<edm::InputTag>("layer_clusters"))) {
32  const auto& tracksterCollections = pset.getParameter<std::vector<edm::InputTag>>("tracksterCollections");
33  for (const auto& tag : tracksterCollections) {
34  std::string label = tag.label();
35  if (tag.instance() != "") {
36  label += tag.instance();
37  }
38  tracksterCollectionTokens_.emplace_back(label, consumes<std::vector<ticl::Trackster>>(tag));
39  }
40 
41  // Produce separate association maps for each trackster collection using the trackster label
42  for (const auto& tracksterToken : tracksterCollectionTokens_) {
43  produces<ticl::AssociationMap<ticl::mapWithFraction, std::vector<reco::CaloCluster>, std::vector<ticl::Trackster>>>(
44  tracksterToken.first);
45  }
46 }
47 
50  const edm::EventSetup&) const {
51  using namespace edm;
52 
55 
56  for (const auto& tracksterToken : tracksterCollectionTokens_) {
58  iEvent.getByToken(tracksterToken.second, tracksters);
59 
60  // Create association map
61  auto lcToTracksterMap = std::make_unique<
64 
65  // Loop over tracksters
66  for (unsigned int tracksterId = 0; tracksterId < tracksters->size(); ++tracksterId) {
67  const auto& trackster = (*tracksters)[tracksterId];
68  // Loop over vertices in trackster
69  for (unsigned int i = 0; i < trackster.vertices().size(); ++i) {
70  // Get layerCluster
71  const auto& lc = (*layer_clusters)[trackster.vertices()[i]];
72  float sharedEnergy = lc.energy() / trackster.vertex_multiplicity()[i];
73  edm::Ref<std::vector<reco::CaloCluster>> lcRef(layer_clusters, trackster.vertices()[i]);
74  edm::Ref<std::vector<ticl::Trackster>> tracksterRef(tracksters, tracksterId);
75  lcToTracksterMap->insert(lcRef, tracksterRef, sharedEnergy);
76  }
77  }
78 
79  iEvent.put(std::move(lcToTracksterMap), tracksterToken.first);
80  }
81 }
82 
85  desc.add<std::vector<edm::InputTag>>("tracksterCollections",
86  {edm::InputTag("ticlTrackstersCLUE3DHigh"),
87  edm::InputTag("ticlTrackstersLinks"),
88  edm::InputTag("ticlCandidate")});
89  desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalMergeLayerClusters"));
90  descriptions.add("AllLayerClusterToTracksterAssociatorsProducer", desc);
91 }
92 
93 // Define this as a plug-in
edm::EDGetTokenT< std::vector< reco::CaloCluster > > layerClustersToken_
std::vector< std::pair< std::string, edm::EDGetTokenT< std::vector< ticl::Trackster > > > > tracksterCollectionTokens_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
char const * label
int iEvent
Definition: GenABIO.cc:224
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~AllLayerClusterToTracksterAssociatorsProducer() override=default
void add(std::string const &label, ParameterSetDescription const &psetDescription)
float sharedEnergy(reco::CaloCluster const &clu1, reco::CaloCluster const &clu2, EcalRecHitCollection const &barrelRecHits, EcalRecHitCollection const &endcapRecHits)
fixed size matrix
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511