CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CommonTools/RecoAlgos/src/SuperClusterToCandidate.h

Go to the documentation of this file.
00001 #ifndef RecoAlgos_SuperClusterToCandidate_h
00002 #define RecoAlgos_SuperClusterToCandidate_h
00003 #include "CommonTools/RecoAlgos/src/MassiveCandidateConverter.h"
00004 #include "CommonTools/RecoAlgos/src/CandidateProducer.h"
00005 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00006 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
00008 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00009 
00010 namespace converter {
00011   struct SuperClusterToCandidate : public MassiveCandidateConverter {
00012     typedef reco::SuperCluster value_type;
00013     typedef reco::SuperClusterCollection Components;
00014     typedef reco::RecoEcalCandidate Candidate;
00015     SuperClusterToCandidate(const edm::ParameterSet & cfg) : 
00016       MassiveCandidateConverter(cfg) {
00017     }
00018     void convert(reco::SuperClusterRef scRef, reco::RecoEcalCandidate & c) const {
00019       const reco::SuperCluster & sc = * scRef;
00020       math::XYZPoint v(0, 0, 0); // this should be taken from something else...
00021       math::XYZVector p = sc.energy() * (sc.position() - v).unit();
00022       double t = sqrt(massSqr_ + p.mag2());
00023       c.setCharge(0);
00024       c.setVertex(v);
00025       c.setP4(reco::Candidate::LorentzVector(p.x(), p.y(), p.z(), t));
00026       c.setSuperCluster(scRef);
00027       c.setPdgId(particle_.pdgId());
00028     }
00029   };
00030 
00031   namespace helper {
00032     template<>
00033     struct CandConverter<reco::SuperCluster> { 
00034       typedef SuperClusterToCandidate type;
00035     };
00036   }
00037 }
00038 
00039 #endif