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& theEventSetup) 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 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
EgammaHLTRecoEcalCandidateProducers::EgammaHLTRecoEcalCandidateProducers
EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet &ps)
Definition: EgammaHLTRecoEcalCandidateProducers.cc:47
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
EgammaHLTRecoEcalCandidateProducers::produce
void produce(edm::StreamID sid, edm::Event &evt, const edm::EventSetup &es) const override
Definition: EgammaHLTRecoEcalCandidateProducers.cc:67
ESHandle.h
edm::EDGetTokenT< reco::SuperClusterCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
edm::Ref< SuperClusterCollection >
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
config
Definition: config.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EgammaHLTRecoEcalCandidateProducers::scHybridBarrelProducer_
const edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
Definition: EgammaHLTRecoEcalCandidateProducers.cc:42
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ParameterSetDescription.h
EgammaHLTRecoEcalCandidateProducers::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EgammaHLTRecoEcalCandidateProducers.cc:59
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
p4
double p4[4]
Definition: TauolaWrapper.h:92
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
EgammaHLTRecoEcalCandidateProducers::~EgammaHLTRecoEcalCandidateProducers
~EgammaHLTRecoEcalCandidateProducers() override
Definition: EgammaHLTRecoEcalCandidateProducers.cc:57
edm::EventSetup
Definition: EventSetup.h:57
EgammaHLTRecoEcalCandidateProducers
Definition: EgammaHLTRecoEcalCandidateProducers.cc:33
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
RecoEcalCandidate.h
SuperClusterFwd.h
SuperCluster.h
EventSetup.h
RecoEcalCandidateFwd.h
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
ParameterSet.h
EDProducer.h
reco::RecoEcalCandidate
Definition: RecoEcalCandidate.h:15
edm::Event
Definition: Event.h:73
EgammaHLTRecoEcalCandidateProducers::recoEcalCandidateCollection_
const std::string recoEcalCandidateCollection_
Definition: EgammaHLTRecoEcalCandidateProducers.cc:44
edm::InputTag
Definition: InputTag.h:15
EgammaHLTRecoEcalCandidateProducers::scIslandEndcapProducer_
const edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
Definition: EgammaHLTRecoEcalCandidateProducers.cc:43