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 | Static Public Member Functions | Private Attributes
EgammaHLTGsfTrackVarProducer Class Reference

#include <EgammaHLTGsfTrackVarProducer.h>

Inheritance diagram for EgammaHLTGsfTrackVarProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase 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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotTag_
 
edm::EDGetTokenT
< reco::ElectronCollection
inputCollectionTag1_
 
edm::EDGetTokenT
< reco::GsfTrackCollection
inputCollectionTag2_
 
int lowerTrackNrToRemoveCut_
 
edm::EDGetTokenT
< reco::RecoEcalCandidateCollection
recoEcalCandTag_
 
TrackExtrapolator trackExtrapolator_
 
int upperTrackNrToRemoveCut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 41 of file EgammaHLTGsfTrackVarProducer.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file EgammaHLTGsfTrackVarProducer.cc.

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

34 {
35  recoEcalCandTag_ = consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
36  inputCollectionTag1_ = consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("inputCollection"));
37  inputCollectionTag2_ = consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("inputCollection"));
38  beamSpotTag_ = consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"));
39  upperTrackNrToRemoveCut_ = config.getParameter<int>("upperTrackNrToRemoveCut");
40  lowerTrackNrToRemoveCut_ = config.getParameter<int>("lowerTrackNrToRemoveCut");
41 
42  //register your products
43  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
44  produces < reco::RecoEcalCandidateIsolationMap >( "DetaSeed" ).setBranchAlias( "detaseed" );
45  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
46  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESuperMinusOneOP" );
47  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESeedMinusOneOP" );
48  produces < reco::RecoEcalCandidateIsolationMap >( "MissingHits" ).setBranchAlias( "missinghits" );
49  produces < reco::RecoEcalCandidateIsolationMap >( "Chi2" ).setBranchAlias( "chi2" );
50  produces < reco::RecoEcalCandidateIsolationMap >( "ValidHits" ).setBranchAlias( "validhits" );
51 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::ElectronCollection > inputCollectionTag1_
edm::EDGetTokenT< reco::GsfTrackCollection > inputCollectionTag2_
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandTag_
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
EgammaHLTGsfTrackVarProducer::~EgammaHLTGsfTrackVarProducer ( )

Definition at line 53 of file EgammaHLTGsfTrackVarProducer.cc.

54 {}

Member Function Documentation

void EgammaHLTGsfTrackVarProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 56 of file EgammaHLTGsfTrackVarProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

56  {
58  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate"));
59  desc.add<edm::InputTag>(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks"));
60  desc.add<edm::InputTag>(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot"));
61  desc.add<int>(("upperTrackNrToRemoveCut"), 9999);
62  desc.add<int>(("lowerTrackNrToRemoveCut"), -1);
63  descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc);
64 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void EgammaHLTGsfTrackVarProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 65 of file EgammaHLTGsfTrackVarProducer.cc.

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

65  {
66 
67  trackExtrapolator_.setup(iSetup);
68 
69  // Get the HLT filtered objects
71  iEvent.getByToken(recoEcalCandTag_,recoEcalCandHandle);
72 
74  iEvent.getByToken(inputCollectionTag1_,electronHandle);
75 
77  if(!electronHandle.isValid())
78  iEvent.getByToken(inputCollectionTag2_, gsfTracksHandle);
79 
80  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
81  iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle);
82  // gets its position
83  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle;
84 
85  edm::ESHandle<MagneticField> theMagField;
86  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
87 
91  reco::RecoEcalCandidateIsolationMap oneOverESuperMinusOneOverPMap;
92  reco::RecoEcalCandidateIsolationMap oneOverESeedMinusOneOverPMap;
96 
97  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
98  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
99 
100  const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster();
101 
102  //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
103  std::vector<const reco::GsfTrack*> gsfTracks;
104  if(electronHandle.isValid()){
105  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
106  if(eleIt->superCluster()==scRef){
107  gsfTracks.push_back(&*eleIt->gsfTrack());
108  }
109  }
110  }else{
111  for(reco::GsfTrackCollection::const_iterator trkIt =gsfTracksHandle->begin();trkIt!=gsfTracksHandle->end();++trkIt){
112  edm::RefToBase<TrajectorySeed> seed = trkIt->extra()->seedRef() ;
114  edm::RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster() ;
115  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>() ;
116  if(scRefFromTrk==scRef){
117  gsfTracks.push_back(&*trkIt);
118  }
119  }
120 
121  }
122 
123  int validHitsValue = 9999999;
124  float chi2Value = 9999999.;
125  float missingHitsValue = 9999999;
126  float dEtaInValue=999999;
127  float dEtaSeedInValue=999999;
128  float dPhiInValue=999999;
129  float oneOverESuperMinusOneOverPValue=999999;
130  float oneOverESeedMinusOneOverPValue=999999;
131 
132  if(static_cast<int>(gsfTracks.size())>=upperTrackNrToRemoveCut_){
133  dEtaInValue=0;
134  dEtaSeedInValue=0;
135  dPhiInValue=0;
136  missingHitsValue = 0;
137  validHitsValue = 0;
138  chi2Value = 0;
139  }else if(static_cast<int>(gsfTracks.size())<=lowerTrackNrToRemoveCut_){
140  dEtaInValue=0;
141  dEtaSeedInValue=0;
142  dPhiInValue=0;
143  missingHitsValue = 0;
144  validHitsValue = 0;
145  chi2Value = 0;
146  }else{
147  for(size_t trkNr=0;trkNr<gsfTracks.size();trkNr++){
148 
149  GlobalPoint scPos(scRef->x(),scRef->y(),scRef->z());
150  GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr],scPos);
151  EleRelPointPair scAtVtx(scRef->position(),trackExtrapToSC,beamSpot.position());
152 
153 
154  float trkP = gsfTracks[trkNr]->p();
155  if(scRef->energy()!=0 && trkP!=0){
156  if(fabs(1/scRef->energy() - 1/trkP)<oneOverESuperMinusOneOverPValue) oneOverESuperMinusOneOverPValue =fabs(1/scRef->energy() - 1/trkP);
157  }
158  if(scRef->seed().isNonnull() && scRef->seed()->energy()!=0 && trkP!=0){
159  if(fabs(1/scRef->seed()->energy() - 1/trkP)<oneOverESeedMinusOneOverPValue) oneOverESeedMinusOneOverPValue =fabs(1/scRef->seed()->energy() - 1/trkP);
160  }
161 
162  // Code for 71X
163  //if (gsfTracks[trkNr]->trackerExpectedHitsInner().numberOfLostHits() < missingHitsValue)
164  // missingHitsValue = gsfTracks[trkNr]->trackerExpectedHitsInner().numberOfLostHits();
165  // Code for 72X
166  if (gsfTracks[trkNr]->hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS) < missingHitsValue)
167  missingHitsValue = gsfTracks[trkNr]->hitPattern().numberOfHits(reco::HitPattern::MISSING_INNER_HITS);
168 
169  if (gsfTracks[trkNr]->numberOfValidHits() < validHitsValue)
170  validHitsValue = gsfTracks[trkNr]->numberOfValidHits();
171 
172  if (gsfTracks[trkNr]->numberOfValidHits() < chi2Value)
173  chi2Value = gsfTracks[trkNr]->normalizedChi2();
174 
175  if (fabs(scAtVtx.dEta())<dEtaInValue)
176  dEtaInValue=fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks
177 
178  if (fabs(scAtVtx.dEta())<dEtaSeedInValue)
179  dEtaSeedInValue = fabs(scAtVtx.dEta()-scRef->position().eta()+scRef->seed()->position().eta());
180 
181  if (fabs(scAtVtx.dPhi())<dPhiInValue)
182  dPhiInValue=fabs(scAtVtx.dPhi());//we are allowing them to come from different tracks
183  }
184  }
185 
186  dEtaMap.insert(recoEcalCandRef, dEtaInValue);
187  dEtaSeedMap.insert(recoEcalCandRef, dEtaSeedInValue);
188  dPhiMap.insert(recoEcalCandRef, dPhiInValue);
189  oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef,oneOverESuperMinusOneOverPValue);
190  oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef,oneOverESeedMinusOneOverPValue);
191  missingHitsMap.insert(recoEcalCandRef, missingHitsValue);
192  validHitsMap.insert(recoEcalCandRef, validHitsValue);
193  chi2Map.insert(recoEcalCandRef, chi2Value);
194  }
195 
196  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dEtaMapForEvent(new reco::RecoEcalCandidateIsolationMap(dEtaMap));
197  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dEtaSeedMapForEvent(new reco::RecoEcalCandidateIsolationMap(dEtaSeedMap));
198  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dPhiMapForEvent(new reco::RecoEcalCandidateIsolationMap(dPhiMap));
199  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> oneOverESuperMinusOneOverPMapForEvent(new reco::RecoEcalCandidateIsolationMap(oneOverESuperMinusOneOverPMap));
200  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> oneOverESeedMinusOneOverPMapForEvent(new reco::RecoEcalCandidateIsolationMap(oneOverESeedMinusOneOverPMap));
201  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> missingHitsForEvent(new reco::RecoEcalCandidateIsolationMap(missingHitsMap));
202  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> validHitsForEvent(new reco::RecoEcalCandidateIsolationMap(validHitsMap));
203  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> chi2ForEvent(new reco::RecoEcalCandidateIsolationMap(chi2Map));
204 
205  iEvent.put(dEtaMapForEvent, "Deta" );
206  iEvent.put(dEtaSeedMapForEvent, "DetaSeed" );
207  iEvent.put(dPhiMapForEvent, "Dphi" );
208  iEvent.put(oneOverESuperMinusOneOverPMapForEvent,"OneOESuperMinusOneOP");
209  iEvent.put(oneOverESeedMinusOneOverPMapForEvent,"OneOESeedMinusOneOP");
210  iEvent.put(missingHitsForEvent, "MissingHits");
211  iEvent.put(validHitsForEvent, "ValidHits");
212  iEvent.put(chi2ForEvent, "Chi2");
213 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
edm::EDGetTokenT< reco::ElectronCollection > inputCollectionTag1_
edm::EDGetTokenT< reco::GsfTrackCollection > inputCollectionTag2_
GlobalPoint extrapolateTrackPosToPoint(const reco::GsfTrack &gsfTrack, const GlobalPoint &pointToExtrapTo)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandTag_
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
bool isValid() const
Definition: HandleBase.h:76
void insert(const key_type &k, const data_type &v)
insert an association
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:242
const T & get() const
Definition: EventSetup.h:55
const Point & position() const
position
Definition: BeamSpot.h:62

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> EgammaHLTGsfTrackVarProducer::beamSpotTag_
private

Definition at line 80 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

edm::EDGetTokenT<reco::ElectronCollection> EgammaHLTGsfTrackVarProducer::inputCollectionTag1_
private

Definition at line 78 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

edm::EDGetTokenT<reco::GsfTrackCollection> EgammaHLTGsfTrackVarProducer::inputCollectionTag2_
private

Definition at line 79 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

int EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
private

Definition at line 84 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

edm::EDGetTokenT<reco::RecoEcalCandidateCollection> EgammaHLTGsfTrackVarProducer::recoEcalCandTag_
private

Definition at line 77 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().

TrackExtrapolator EgammaHLTGsfTrackVarProducer::trackExtrapolator_
private

Definition at line 82 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

int EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
private

Definition at line 83 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by EgammaHLTGsfTrackVarProducer(), and produce().