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 
13 // Framework
20 //
25 
27 
28 
30  conf_(config)
31 
32 {
33  // use onfiguration file to setup input/output collection names
34  scHybridBarrelProducer_ = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer");
35  scIslandEndcapProducer_ = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer");
36  recoEcalCandidateCollection_ = conf_.getParameter<std::string>("recoEcalCandidateCollection");
37 
38  // Register the product
39  produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_);
40 }
41 
43 
45 
47 
48  using namespace edm;
49 
50  //
51  // create empty output collections
52  //
53 
54  reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
55  std::auto_ptr< reco::RecoEcalCandidateCollection > outputRecoEcalCandidateCollection_p(new reco::RecoEcalCandidateCollection);
56 
57  // Get the Barrel Super Cluster collection
59  theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
60  // Get the Endcap Super Cluster collection
62  theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);
63 
64  // Loop over barrel SC and fill the recoecal collection
65  int iSC=0; // index in recoecal collection
66  int lSC=0; // local index on barrel
67 
68 
69 for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) {
70 
71  const reco::Particle::Point vtx( 0, 0, 0 );
72 
73  // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
74  math::XYZVector direction =aClus->position() - vtx;
75  math::XYZVector momentum = direction.unit() * aClus->energy();
76  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
77 
78  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
79 
80  outputRecoEcalCandidateCollection.push_back(newCandidate);
81  reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
82  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
83 
84  lSC++;
85  iSC++;
86 
87  }
88 
89  // Loop over Endcap SC and fill the recoecal collection
90  lSC=0; // reset local index for endcap
91 
92 for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) {
93 
94  const reco::Particle::Point vtx( 0, 0, 0 );
95 
96  math::XYZVector direction =aClus->position() - vtx;
97  math::XYZVector momentum = direction.unit() * aClus->energy();
98  const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );
99 
100  reco::RecoEcalCandidate newCandidate(0, p4, vtx);
101 
102  outputRecoEcalCandidateCollection.push_back(newCandidate);
103  reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC));
104  outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
105 
106  iSC++;
107  lSC++;
108 
109  }
110 
111  // put the product in the event
112  outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
113  theEvent.put( outputRecoEcalCandidateCollection_p, recoEcalCandidateCollection_);
114 
115 }
116 
T getParameter(std::string const &) const
EgammaHLTRecoEcalCandidateProducers(const edm::ParameterSet &ps)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
double p4[4]
Definition: TauolaWrapper.h:92
math::XYZPoint Point
point in the space
Definition: Particle.h:30
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
tuple config
Definition: cmsDriver.py:17
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
virtual void produce(edm::Event &evt, const edm::EventSetup &es)