CMS 3D CMS Logo

EgammaHLTRecoEcalCandidateProducers.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 #include <vector>
11 #include <memory>
12 
17 
19 
20 
22  scHybridBarrelProducer_(consumes<reco::SuperClusterCollection>(config.getParameter<edm::InputTag>("scHybridBarrelProducer"))),
23  scIslandEndcapProducer_(consumes<reco::SuperClusterCollection>(config.getParameter<edm::InputTag>("scIslandEndcapProducer"))),
24  recoEcalCandidateCollection_(config.getParameter<std::string>("recoEcalCandidateCollection")) {
25 
26  // Register the product
27  produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_);
28 }
29 
31 {}
32 
35  desc.add<edm::InputTag>(("scHybridBarrelProducer"), edm::InputTag("correctedHybridSuperClusters"));
36  desc.add<edm::InputTag>(("scIslandEndcapProducer"), edm::InputTag("correctedEndcapSuperClustersWithPreshower"));
37  desc.add<std::string>(("recoEcalCandidateCollection"), "");
38  descriptions.add(("hltEgammaHLTRecoEcalCandidateProducers"), desc);
39 }
40 
42 
43  using namespace edm;
44 
45  //
46  // create empty output collections
47  //
48 
49  reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
50  auto outputRecoEcalCandidateCollection_p = std::make_unique<reco::RecoEcalCandidateCollection>();
51 
52  // Get the Barrel Super Cluster collection
54  theEvent.getByToken(scHybridBarrelProducer_,scBarrelHandle);
55  // Get the Endcap Super Cluster collection
57  theEvent.getByToken(scIslandEndcapProducer_,scEndcapHandle);
58 
59  // Loop over barrel SC and fill the recoecal collection
60  int iSC=0; // index in recoecal collection
61  int lSC=0; // local index on barrel
62 
63 
64 for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) {
65 
66  const reco::Particle::Point vtx( 0, 0, 0 );
67 
68  // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
69  math::XYZVector direction =aClus->position() - vtx;
70  math::XYZVector momentum = direction.unit() * aClus->energy();
71  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
72 
73  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
74 
75  outputRecoEcalCandidateCollection.push_back(newCandidate);
76  reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
77  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
78 
79  lSC++;
80  iSC++;
81 
82  }
83 
84  // Loop over Endcap SC and fill the recoecal collection
85  lSC=0; // reset local index for endcap
86 
87 for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) {
88 
89  const reco::Particle::Point vtx( 0, 0, 0 );
90 
91  math::XYZVector direction =aClus->position() - vtx;
92  math::XYZVector momentum = direction.unit() * aClus->energy();
93  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
94 
95  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
96 
97  outputRecoEcalCandidateCollection.push_back(newCandidate);
98  reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC));
99  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
100 
101  iSC++;
102  lSC++;
103 
104  }
105 
106  // put the product in the event
107  outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
108  theEvent.put(std::move(outputRecoEcalCandidateCollection_p), recoEcalCandidateCollection_);
109 
110 }
111 
const edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:460
Definition: config.py:1
const edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:25
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
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:510