CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

EgammaHLTGsfTrackVarProducer Class Reference

#include <EgammaHLTGsfTrackVarProducer.h>

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

List of all members.

Classes

class  TrackExtrapolator

Public Member Functions

 EgammaHLTGsfTrackVarProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EgammaHLTGsfTrackVarProducer ()

Private Attributes

edm::InputTag beamSpotTag_
edm::InputTag inputCollectionTag_
int lowerTrackNrToRemoveCut_
edm::InputTag recoEcalCandTag_
TrackExtrapolator trackExtrapolator_
int upperTrackNrToRemoveCut_

Detailed Description

Definition at line 32 of file EgammaHLTGsfTrackVarProducer.h.


Constructor & Destructor Documentation

EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer ( const edm::ParameterSet config) [explicit]

Definition at line 51 of file EgammaHLTGsfTrackVarProducer.cc.

References beamSpotTag_, edm::ParameterSet::getParameter(), inputCollectionTag_, lowerTrackNrToRemoveCut_, recoEcalCandTag_, and upperTrackNrToRemoveCut_.

{
  recoEcalCandTag_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
  inputCollectionTag_             = config.getParameter<edm::InputTag>("inputCollection");
  beamSpotTag_                   = config.getParameter<edm::InputTag>("beamSpotProducer");
  upperTrackNrToRemoveCut_  = config.getParameter<int>("upperTrackNrToRemoveCut"); //zeros out dEtaIn,dPhiIn if nrTracks>= this
  lowerTrackNrToRemoveCut_  = config.getParameter<int>("lowerTrackNrToRemoveCut"); //zeros out dEtaIn,dPhiIn if nrTracks<= this
 
  
  
  //register your products
  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" ); 
}
EgammaHLTGsfTrackVarProducer::~EgammaHLTGsfTrackVarProducer ( )

Definition at line 66 of file EgammaHLTGsfTrackVarProducer.cc.

{}

Member Function Documentation

void EgammaHLTGsfTrackVarProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 75 of file EgammaHLTGsfTrackVarProducer.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, beamSpotTag_, edm::RefToBase< T >::castTo(), EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackPosToPoint(), edm::EventSetup::get(), edm::Event::getByLabel(), inputCollectionTag_, edm::AssociationMap< Tag >::insert(), edm::HandleBase::isValid(), lowerTrackNrToRemoveCut_, reco::BeamSpot::position(), edm::Event::put(), recoEcalCandTag_, EgammaHLTGsfTrackVarProducer::TrackExtrapolator::setup(), trackExtrapolator_, and upperTrackNrToRemoveCut_.

{

  trackExtrapolator_.setup(iSetup);

  // Get the HLT filtered objects
  edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
  iEvent.getByLabel(recoEcalCandTag_,recoEcalCandHandle);

  edm::Handle<reco::ElectronCollection> electronHandle;
  iEvent.getByLabel(inputCollectionTag_,electronHandle);

  edm::Handle<reco::GsfTrackCollection> gsfTracksHandle;
  if(!electronHandle.isValid()) iEvent.getByLabel (inputCollectionTag_,gsfTracksHandle);

  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
  iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle);
  // gets its position
  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle; 

  edm::ESHandle<MagneticField> theMagField;
  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);

  reco::RecoEcalCandidateIsolationMap dEtaMap;
  reco::RecoEcalCandidateIsolationMap dPhiMap;
  
  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
    reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
   
    const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster();
   
    //the idea is that we can take the tracks from properly associated electrons or just take all gsf tracks with that sc as a seed
    std::vector<const reco::GsfTrack*> gsfTracks;
    if(electronHandle.isValid()){
      for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
        if(eleIt->superCluster()==scRef){
          gsfTracks.push_back(&*eleIt->gsfTrack());
        }
      }
    }else{ 
      for(reco::GsfTrackCollection::const_iterator trkIt =gsfTracksHandle->begin();trkIt!=gsfTracksHandle->end();++trkIt){
        edm::RefToBase<TrajectorySeed> seed = trkIt->extra()->seedRef() ;
        reco::ElectronSeedRef elseed = seed.castTo<reco::ElectronSeedRef>() ;
        edm::RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster() ;
        reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>() ;
        if(scRefFromTrk==scRef){
          gsfTracks.push_back(&*trkIt);
        }
      }
      
    }
    float dEtaInValue=999999;
    float dPhiInValue=999999;
    
    if(static_cast<int>(gsfTracks.size())>=upperTrackNrToRemoveCut_){
      dEtaInValue=0;
      dPhiInValue=0;
    }else if(static_cast<int>(gsfTracks.size())<=lowerTrackNrToRemoveCut_){
      dEtaInValue=0;
      dPhiInValue=0;
    }else{
      for(size_t trkNr=0;trkNr<gsfTracks.size();trkNr++){
      
        GlobalPoint scPos(scRef->x(),scRef->y(),scRef->z());
        GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr],scPos);
        EleRelPointPair scAtVtx(scRef->position(),trackExtrapToSC,beamSpot.position());
        
        if(fabs(scAtVtx.dEta())<dEtaInValue) dEtaInValue=fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks
        if(fabs(scAtVtx.dPhi())<dPhiInValue) dPhiInValue=fabs(scAtVtx.dPhi());//we are allowing them to come from different tracks
      } 
    }
    
    dEtaMap.insert(recoEcalCandRef, dEtaInValue);
    dPhiMap.insert(recoEcalCandRef, dPhiInValue);
  }

  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dEtaMapForEvent(new reco::RecoEcalCandidateIsolationMap(dEtaMap));
  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dPhiMapForEvent(new reco::RecoEcalCandidateIsolationMap(dPhiMap));
  iEvent.put(dEtaMapForEvent, "Deta" );
  iEvent.put(dPhiMapForEvent, "Dphi" );

}

Member Data Documentation

Definition at line 79 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

Definition at line 78 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

Definition at line 82 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

Definition at line 77 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

Definition at line 80 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

Definition at line 81 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().