CandConverter

SuperClusterToCandidate

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#ifndef RecoAlgos_SuperClusterToCandidate_h
#define RecoAlgos_SuperClusterToCandidate_h
#include "CommonTools/RecoAlgos/interface/MassiveCandidateConverter.h"
#include "CommonTools/RecoAlgos/interface/CandidateProducer.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/Candidate/interface/CandidateFwd.h"

namespace converter {
  struct SuperClusterToCandidate : public MassiveCandidateConverter {
    typedef reco::SuperCluster value_type;
    typedef reco::SuperClusterCollection Components;
    typedef reco::RecoEcalCandidate Candidate;
    SuperClusterToCandidate(const edm::ParameterSet& cfg, edm::ConsumesCollector iC)
        : MassiveCandidateConverter(cfg, iC) {}
    void convert(reco::SuperClusterRef scRef, reco::RecoEcalCandidate& c) const {
      const reco::SuperCluster& sc = *scRef;
      math::XYZPoint v(0, 0, 0);  // this should be taken from something else...
      math::XYZVector p = sc.energy() * (sc.position() - v).unit();
      double t = sqrt(massSqr_ + p.mag2());
      c.setCharge(0);
      c.setVertex(v);
      c.setP4(reco::Candidate::LorentzVector(p.x(), p.y(), p.z(), t));
      c.setSuperCluster(scRef);
      c.setPdgId(particle_.pdgId());
    }
  };

  namespace helper {
    template <>
    struct CandConverter<reco::SuperCluster> {
      typedef SuperClusterToCandidate type;
    };
  }  // namespace helper
}  // namespace converter

#endif