CMS 3D CMS Logo

EgammaHLTRecoEcalCandidateProducers.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaHLTProducers
4 // Class: EgammaHLTRecoEcalCandidateProducers
5 //
8 //
9 // Original Author: Monica Vazquez Acosta (CERN)
10 // Created: Tue Jun 13 14:48:33 CEST 2006
11 // $Id:
12 //
13 //
14 
20 
23 
28 
29 #include <iostream>
30 #include <vector>
31 #include <memory>
32 
34 public:
37 
38  void produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const override;
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
45 };
46 
48  : scHybridBarrelProducer_(
49  consumes<reco::SuperClusterCollection>(config.getParameter<edm::InputTag>("scHybridBarrelProducer"))),
50  scIslandEndcapProducer_(
51  consumes<reco::SuperClusterCollection>(config.getParameter<edm::InputTag>("scIslandEndcapProducer"))),
52  recoEcalCandidateCollection_(config.getParameter<std::string>("recoEcalCandidateCollection")) {
53  // Register the product
54  produces<reco::RecoEcalCandidateCollection>(recoEcalCandidateCollection_);
55 }
56 
58 
61  desc.add<edm::InputTag>(("scHybridBarrelProducer"), edm::InputTag("correctedHybridSuperClusters"));
62  desc.add<edm::InputTag>(("scIslandEndcapProducer"), edm::InputTag("correctedEndcapSuperClustersWithPreshower"));
63  desc.add<std::string>(("recoEcalCandidateCollection"), "");
64  descriptions.add(("hltEgammaHLTRecoEcalCandidateProducers"), desc);
65 }
66 
68  edm::Event& theEvent,
69  const edm::EventSetup&) const {
70  using namespace edm;
71 
72  //
73  // create empty output collections
74  //
75 
76  reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
77  auto outputRecoEcalCandidateCollection_p = std::make_unique<reco::RecoEcalCandidateCollection>();
78 
79  // Get the Barrel Super Cluster collection
81  theEvent.getByToken(scHybridBarrelProducer_, scBarrelHandle);
82  // Get the Endcap Super Cluster collection
84  theEvent.getByToken(scIslandEndcapProducer_, scEndcapHandle);
85 
86  // Loop over barrel SC and fill the recoecal collection
87  int iSC = 0; // index in recoecal collection
88  int lSC = 0; // local index on barrel
89 
90  for (reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end();
91  aClus++) {
92  const reco::Particle::Point vtx(0, 0, 0);
93 
94  // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
95  math::XYZVector direction = aClus->position() - vtx;
96  math::XYZVector momentum = direction.unit() * aClus->energy();
97  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy());
98 
99  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
100 
101  outputRecoEcalCandidateCollection.push_back(newCandidate);
102  reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
103  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
104 
105  lSC++;
106  iSC++;
107  }
108 
109  // Loop over Endcap SC and fill the recoecal collection
110  lSC = 0; // reset local index for endcap
111 
112  for (reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end();
113  aClus++) {
114  const reco::Particle::Point vtx(0, 0, 0);
115 
116  math::XYZVector direction = aClus->position() - vtx;
117  math::XYZVector momentum = direction.unit() * aClus->energy();
118  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy());
119 
120  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
121 
122  outputRecoEcalCandidateCollection.push_back(newCandidate);
123  reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC));
124  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
125 
126  iSC++;
127  lSC++;
128  }
129 
130  // put the product in the event
131  outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),
132  outputRecoEcalCandidateCollection.end());
133  theEvent.put(std::move(outputRecoEcalCandidateCollection_p), recoEcalCandidateCollection_);
134 }
135 
const edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet &ps)
void produce(edm::StreamID sid, edm::Event &evt, const edm::EventSetup &es) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Definition: config.py:1
const edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
math::XYZPoint Point
point in the space
Definition: Particle.h:25
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
fixed size matrix
HLT enums.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:511