CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
EgammaHLTGsfTrackVarProducer Class Reference

#include <EgammaHLTGsfTrackVarProducer.h>

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

Classes

class  TrackExtrapolator
 

Public Member Functions

 EgammaHLTGsfTrackVarProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~EgammaHLTGsfTrackVarProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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_.

52 {
53  recoEcalCandTag_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
54  inputCollectionTag_ = config.getParameter<edm::InputTag>("inputCollection");
55  beamSpotTag_ = config.getParameter<edm::InputTag>("beamSpotProducer");
56  upperTrackNrToRemoveCut_ = config.getParameter<int>("upperTrackNrToRemoveCut"); //zeros out dEtaIn,dPhiIn if nrTracks>= this
57  lowerTrackNrToRemoveCut_ = config.getParameter<int>("lowerTrackNrToRemoveCut"); //zeros out dEtaIn,dPhiIn if nrTracks<= this
58 
59 
60 
61  //register your products
62  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
63  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
64 }
T getParameter(std::string const &) const
EgammaHLTGsfTrackVarProducer::~EgammaHLTGsfTrackVarProducer ( )

Definition at line 66 of file EgammaHLTGsfTrackVarProducer.cc.

66 {}

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_.

76 {
77 
78  trackExtrapolator_.setup(iSetup);
79 
80  // Get the HLT filtered objects
82  iEvent.getByLabel(recoEcalCandTag_,recoEcalCandHandle);
83 
85  iEvent.getByLabel(inputCollectionTag_,electronHandle);
86 
88  if(!electronHandle.isValid()) iEvent.getByLabel (inputCollectionTag_,gsfTracksHandle);
89 
90  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
91  iEvent.getByLabel(beamSpotTag_,recoBeamSpotHandle);
92  // gets its position
93  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle;
94 
95  edm::ESHandle<MagneticField> theMagField;
96  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
97 
100 
101  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
102  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
103 
104  const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster();
105 
106  //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
107  std::vector<const reco::GsfTrack*> gsfTracks;
108  if(electronHandle.isValid()){
109  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
110  if(eleIt->superCluster()==scRef){
111  gsfTracks.push_back(&*eleIt->gsfTrack());
112  }
113  }
114  }else{
115  for(reco::GsfTrackCollection::const_iterator trkIt =gsfTracksHandle->begin();trkIt!=gsfTracksHandle->end();++trkIt){
116  edm::RefToBase<TrajectorySeed> seed = trkIt->extra()->seedRef() ;
118  edm::RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster() ;
119  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>() ;
120  if(scRefFromTrk==scRef){
121  gsfTracks.push_back(&*trkIt);
122  }
123  }
124 
125  }
126  float dEtaInValue=999999;
127  float dPhiInValue=999999;
128 
129  if(static_cast<int>(gsfTracks.size())>=upperTrackNrToRemoveCut_){
130  dEtaInValue=0;
131  dPhiInValue=0;
132  }else if(static_cast<int>(gsfTracks.size())<=lowerTrackNrToRemoveCut_){
133  dEtaInValue=0;
134  dPhiInValue=0;
135  }else{
136  for(size_t trkNr=0;trkNr<gsfTracks.size();trkNr++){
137 
138  GlobalPoint scPos(scRef->x(),scRef->y(),scRef->z());
139  GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr],scPos);
140  EleRelPointPair scAtVtx(scRef->position(),trackExtrapToSC,beamSpot.position());
141 
142  if(fabs(scAtVtx.dEta())<dEtaInValue) dEtaInValue=fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks
143  if(fabs(scAtVtx.dPhi())<dPhiInValue) dPhiInValue=fabs(scAtVtx.dPhi());//we are allowing them to come from different tracks
144  }
145  }
146 
147  dEtaMap.insert(recoEcalCandRef, dEtaInValue);
148  dPhiMap.insert(recoEcalCandRef, dPhiInValue);
149  }
150 
151  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dEtaMapForEvent(new reco::RecoEcalCandidateIsolationMap(dEtaMap));
152  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dPhiMapForEvent(new reco::RecoEcalCandidateIsolationMap(dPhiMap));
153  iEvent.put(dEtaMapForEvent, "Deta" );
154  iEvent.put(dPhiMapForEvent, "Dphi" );
155 
156 }
GlobalPoint extrapolateTrackPosToPoint(const reco::GsfTrack &gsfTrack, const GlobalPoint &pointToExtrapTo)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
const Point & position() const
position
Definition: BeamSpot.h:63

Member Data Documentation

edm::InputTag EgammaHLTGsfTrackVarProducer::beamSpotTag_
private

Definition at line 79 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

edm::InputTag EgammaHLTGsfTrackVarProducer::inputCollectionTag_
private

Definition at line 78 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

int EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
private

Definition at line 82 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

edm::InputTag EgammaHLTGsfTrackVarProducer::recoEcalCandTag_
private

Definition at line 77 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

TrackExtrapolator EgammaHLTGsfTrackVarProducer::trackExtrapolator_
private

Definition at line 80 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

int EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
private

Definition at line 81 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().