CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTRecoEcalCandidateProducers.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 #include <vector>
11 #include <memory>
12 
17 
19 
20 
22  conf_(config) {
23  // use onfiguration file to setup input/output collection names
24  scHybridBarrelProducer_ = consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scHybridBarrelProducer"));
25  scIslandEndcapProducer_ = consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scIslandEndcapProducer"));
26 
27  recoEcalCandidateCollection_ = conf_.getParameter<std::string>("recoEcalCandidateCollection");
28 
29  // Register the product
30  produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_);
31 }
32 
34 
37  desc.add<edm::InputTag>(("scHybridBarrelProducer"), edm::InputTag("correctedHybridSuperClusters"));
38  desc.add<edm::InputTag>(("scIslandEndcapProducer"), edm::InputTag("correctedEndcapSuperClustersWithPreshower"));
39  desc.add<std::string>(("recoEcalCandidateCollection"), "");
40  descriptions.add(("hltEgammaHLTRecoEcalCandidateProducers"), desc);
41 }
42 
44 
46 
47  using namespace edm;
48 
49  //
50  // create empty output collections
51  //
52 
53  reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
54  std::auto_ptr< reco::RecoEcalCandidateCollection > outputRecoEcalCandidateCollection_p(new reco::RecoEcalCandidateCollection);
55 
56  // Get the Barrel Super Cluster collection
58  theEvent.getByToken(scHybridBarrelProducer_,scBarrelHandle);
59  // Get the Endcap Super Cluster collection
61  theEvent.getByToken(scIslandEndcapProducer_,scEndcapHandle);
62 
63  // Loop over barrel SC and fill the recoecal collection
64  int iSC=0; // index in recoecal collection
65  int lSC=0; // local index on barrel
66 
67 
68 for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) {
69 
70  const reco::Particle::Point vtx( 0, 0, 0 );
71 
72  // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
73  math::XYZVector direction =aClus->position() - vtx;
74  math::XYZVector momentum = direction.unit() * aClus->energy();
75  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
76 
77  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
78 
79  outputRecoEcalCandidateCollection.push_back(newCandidate);
80  reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
81  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
82 
83  lSC++;
84  iSC++;
85 
86  }
87 
88  // Loop over Endcap SC and fill the recoecal collection
89  lSC=0; // reset local index for endcap
90 
91 for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) {
92 
93  const reco::Particle::Point vtx( 0, 0, 0 );
94 
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(scEndcapHandle, lSC));
103  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
104 
105  iSC++;
106  lSC++;
107 
108  }
109 
110  // put the product in the event
111  outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
112  theEvent.put( outputRecoEcalCandidateCollection_p, recoEcalCandidateCollection_);
113 
114 }
115 
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:31
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
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
virtual void produce(edm::Event &evt, const edm::EventSetup &es)