CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

EgammaHLTRecoEcalCandidateProducers Class Reference

#include <EgammaHLTRecoEcalCandidateProducers.h>

Inheritance diagram for EgammaHLTRecoEcalCandidateProducers:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

class  h

Public Member Functions

virtual void beginJob (void)
 EgammaHLTRecoEcalCandidateProducers (const edm::ParameterSet &ps)
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 ~EgammaHLTRecoEcalCandidateProducers ()

Private Attributes

edm::ParameterSet conf_
std::string recoEcalCandidateCollection_
edm::InputTag scHybridBarrelProducer_
edm::InputTag scIslandEndcapProducer_

Detailed Description

Author:
Monica Vazquez Acosta (CERN)

$Id:

Definition at line 26 of file EgammaHLTRecoEcalCandidateProducers.h.


Constructor & Destructor Documentation

EgammaHLTRecoEcalCandidateProducers::EgammaHLTRecoEcalCandidateProducers ( const edm::ParameterSet ps)

Definition at line 29 of file EgammaHLTRecoEcalCandidateProducers.cc.

References conf_, edm::ParameterSet::getParameter(), recoEcalCandidateCollection_, scHybridBarrelProducer_, scIslandEndcapProducer_, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                                                      : 
  conf_(config) 

{
  // use onfiguration file to setup input/output collection names
  scHybridBarrelProducer_       = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer");
  scIslandEndcapProducer_       = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer");
  recoEcalCandidateCollection_  = conf_.getParameter<std::string>("recoEcalCandidateCollection");

  // Register the product
  produces< reco::RecoEcalCandidateCollection >(recoEcalCandidateCollection_);
}
EgammaHLTRecoEcalCandidateProducers::~EgammaHLTRecoEcalCandidateProducers ( )

Definition at line 42 of file EgammaHLTRecoEcalCandidateProducers.cc.

{}

Member Function Documentation

void EgammaHLTRecoEcalCandidateProducers::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 44 of file EgammaHLTRecoEcalCandidateProducers.cc.

{}
void EgammaHLTRecoEcalCandidateProducers::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 46 of file EgammaHLTRecoEcalCandidateProducers.cc.

References edm::Event::getByLabel(), p4, edm::Event::put(), recoEcalCandidateCollection_, scHybridBarrelProducer_, and scIslandEndcapProducer_.

                                                                                                        {

  using namespace edm;

  //
  // create empty output collections
  //

  reco::RecoEcalCandidateCollection outputRecoEcalCandidateCollection;
  std::auto_ptr< reco::RecoEcalCandidateCollection > outputRecoEcalCandidateCollection_p(new reco::RecoEcalCandidateCollection);

  // Get the  Barrel Super Cluster collection
  Handle<reco::SuperClusterCollection> scBarrelHandle;
  theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
  // Get the  Endcap Super Cluster collection
  Handle<reco::SuperClusterCollection> scEndcapHandle;
  theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);

  //  Loop over barrel SC and fill the  recoecal collection
  int iSC=0; // index in recoecal collection
  int lSC=0; // local index on barrel


for(reco::SuperClusterCollection::const_iterator aClus = scBarrelHandle->begin(); aClus != scBarrelHandle->end(); aClus++) {

    const reco::Particle::Point  vtx( 0, 0, 0 );

    // compute correctly the momentum vector of the recoecal from primary vertex and cluster position
    math::XYZVector direction =aClus->position() - vtx;
    math::XYZVector momentum = direction.unit() * aClus->energy();
    const reco::Particle::LorentzVector  p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );

    reco::RecoEcalCandidate newCandidate(0, p4, vtx);

    outputRecoEcalCandidateCollection.push_back(newCandidate);
    reco::SuperClusterRef scRef(reco::SuperClusterRef(scBarrelHandle, lSC));
    outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);

    lSC++;
    iSC++;

  }

  //  Loop over Endcap SC and fill the  recoecal collection
  lSC=0; // reset local index for endcap

for(reco::SuperClusterCollection::const_iterator aClus = scEndcapHandle->begin(); aClus != scEndcapHandle->end(); aClus++) {

    const reco::Particle::Point  vtx( 0, 0, 0 );

    math::XYZVector direction =aClus->position() - vtx;
    math::XYZVector momentum = direction.unit() * aClus->energy();
    const reco::Particle::LorentzVector  p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() );

    reco::RecoEcalCandidate newCandidate(0, p4, vtx);

    outputRecoEcalCandidateCollection.push_back(newCandidate);
    reco::SuperClusterRef scRef(reco::SuperClusterRef(scEndcapHandle, lSC));
    outputRecoEcalCandidateCollection[iSC].setSuperCluster(scRef);
 
    iSC++;
    lSC++;

  }

  // put the product in the event
  outputRecoEcalCandidateCollection_p->assign(outputRecoEcalCandidateCollection.begin(),outputRecoEcalCandidateCollection.end());
  theEvent.put( outputRecoEcalCandidateCollection_p, recoEcalCandidateCollection_);

}

Member Data Documentation