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::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  TrackExtrapolator
 

Public Member Functions

 EgammaHLTGsfTrackVarProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTGsfTrackVarProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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.

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

Definition at line 52 of file EgammaHLTGsfTrackVarProducer.cc.

53 {}

Member Function Documentation

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

Definition at line 55 of file EgammaHLTGsfTrackVarProducer.cc.

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

55  {
57  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate"));
58  desc.add<edm::InputTag>(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks"));
59  desc.add<edm::InputTag>(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot"));
60  desc.add<int>(("upperTrackNrToRemoveCut"), 9999);
61  desc.add<int>(("lowerTrackNrToRemoveCut"), -1);
62  descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc);
63 }
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 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 64 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_.

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

Member Data Documentation

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

Definition at line 79 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 77 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 78 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
private

Definition at line 83 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 76 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

TrackExtrapolator EgammaHLTGsfTrackVarProducer::trackExtrapolator_
private

Definition at line 81 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
private

Definition at line 82 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().