CMS 3D CMS Logo

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

Classes

class  TrackExtrapolator
 

Public Member Functions

 EgammaHLTGsfTrackVarProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTGsfTrackVarProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::EDGetTokenT< reco::BeamSpotbeamSpotTag_
 
const edm::EDGetTokenT< reco::ElectronCollectioninputCollectionTag1_
 
const edm::EDGetTokenT< reco::GsfTrackCollectioninputCollectionTag2_
 
const int lowerTrackNrToRemoveCut_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateCollectionrecoEcalCandTag_
 
TrackExtrapolator trackExtrapolator_
 
const int upperTrackNrToRemoveCut_
 
const bool useDefaultValuesForBarrel_
 
const bool useDefaultValuesForEndcap_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Author
Roberto Covarelli (CERN)
Id
EgammaHLTGsfTrackVarProducer.cc,v 1.1 2012/01/23 12:56:38 sharper Exp

Definition at line 41 of file EgammaHLTGsfTrackVarProducer.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file EgammaHLTGsfTrackVarProducer.cc.

32  :
33  recoEcalCandTag_ (consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
34  inputCollectionTag1_ (consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("inputCollection"))),
35  inputCollectionTag2_ (consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("inputCollection"))),
36  beamSpotTag_ (consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))),
37  upperTrackNrToRemoveCut_ (config.getParameter<int>("upperTrackNrToRemoveCut")),
38  lowerTrackNrToRemoveCut_ (config.getParameter<int>("lowerTrackNrToRemoveCut")),
39  useDefaultValuesForBarrel_ (config.getParameter<bool>("useDefaultValuesForBarrel")),
40  useDefaultValuesForEndcap_ (config.getParameter<bool>("useDefaultValuesForEndcap"))
41 {
42 
43  //register your products
44  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
45  produces < reco::RecoEcalCandidateIsolationMap >( "DetaSeed" ).setBranchAlias( "detaseed" );
46  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
47  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESuperMinusOneOP" );
48  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESeedMinusOneOP" );
49  produces < reco::RecoEcalCandidateIsolationMap >( "MissingHits" ).setBranchAlias( "missinghits" );
50  produces < reco::RecoEcalCandidateIsolationMap >( "Chi2" ).setBranchAlias( "chi2" );
51  produces < reco::RecoEcalCandidateIsolationMap >( "ValidHits" ).setBranchAlias( "validhits" );
52 }
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 ( )
override

Definition at line 54 of file EgammaHLTGsfTrackVarProducer.cc.

55 {}

Member Function Documentation

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

Definition at line 57 of file EgammaHLTGsfTrackVarProducer.cc.

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

57  {
59  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate"));
60  desc.add<edm::InputTag>(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks"));
61  desc.add<edm::InputTag>(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot"));
62  desc.add<int>(("upperTrackNrToRemoveCut"), 9999);
63  desc.add<int>(("lowerTrackNrToRemoveCut"), -1);
64  desc.add<bool>(("useDefaultValuesForBarrel"),false);
65  desc.add<bool>(("useDefaultValuesForEndcap"),false);
66 
67  descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc);
68 }
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 
)
override

Definition at line 69 of file EgammaHLTGsfTrackVarProducer.cc.

References funct::abs(), ecalDrivenElectronSeedsParameters_cff::beamSpot, beamSpotTag_, edm::RefToBase< T >::castTo(), EgammaHLTGsfTrackVarProducer::TrackExtrapolator::extrapolateTrackPosToPoint(), edm::EventSetup::get(), edm::Event::getByToken(), gedGsfElectronCores_cfi::gsfTracks, inputCollectionTag1_, inputCollectionTag2_, edm::AssociationMap< Tag >::insert(), GeomDetEnumerators::isBarrel(), edm::HandleBase::isValid(), lowerTrackNrToRemoveCut_, reco::HitPattern::MISSING_INNER_HITS, eostools::move(), reco::BeamSpot::position(), edm::Event::put(), recoEcalCandTag_, SurveyInfoScenario_cff::seed, EgammaHLTGsfTrackVarProducer::TrackExtrapolator::setup(), trackExtrapolator_, upperTrackNrToRemoveCut_, useDefaultValuesForBarrel_, and useDefaultValuesForEndcap_.

69  {
70 
71  trackExtrapolator_.setup(iSetup);
72 
73  // Get the HLT filtered objects
75  iEvent.getByToken(recoEcalCandTag_,recoEcalCandHandle);
76 
78  iEvent.getByToken(inputCollectionTag1_,electronHandle);
79 
81  if(!electronHandle.isValid())
82  iEvent.getByToken(inputCollectionTag2_, gsfTracksHandle);
83 
84  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
85  iEvent.getByToken(beamSpotTag_,recoBeamSpotHandle);
86  // gets its position
87  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle;
88 
89  edm::ESHandle<MagneticField> theMagField;
90  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
91 
92  reco::RecoEcalCandidateIsolationMap dEtaMap(recoEcalCandHandle);
93  reco::RecoEcalCandidateIsolationMap dEtaSeedMap(recoEcalCandHandle);
94  reco::RecoEcalCandidateIsolationMap dPhiMap(recoEcalCandHandle);
95  reco::RecoEcalCandidateIsolationMap oneOverESuperMinusOneOverPMap(recoEcalCandHandle);
96  reco::RecoEcalCandidateIsolationMap oneOverESeedMinusOneOverPMap(recoEcalCandHandle);
97  reco::RecoEcalCandidateIsolationMap missingHitsMap(recoEcalCandHandle);
98  reco::RecoEcalCandidateIsolationMap validHitsMap(recoEcalCandHandle);
99  reco::RecoEcalCandidateIsolationMap chi2Map(recoEcalCandHandle);
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  bool isBarrel = std::abs(recoEcalCandRef->eta())<1.479;
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 
127  int validHitsValue = 0;
128  float chi2Value = 9999999.;
129  float missingHitsValue = 9999999;
130  float dEtaInValue=999999;
131  float dEtaSeedInValue=999999;
132  float dPhiInValue=999999;
133  float oneOverESuperMinusOneOverPValue=999999;
134  float oneOverESeedMinusOneOverPValue=999999;
135 
136  const int nrTracks = gsfTracks.size();
137  const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ ||
138  nrTracks >= upperTrackNrToRemoveCut_;
139  //to use the default values, we require at least one track...
140  const bool useDefaultValues = isBarrel ? useDefaultValuesForBarrel_ && nrTracks>=1 : useDefaultValuesForEndcap_ && nrTracks>=1;
141 
142  if(rmCutsDueToNrTracks || useDefaultValues){
143  dEtaInValue=0;
144  dEtaSeedInValue=0;
145  dPhiInValue=0;
146  missingHitsValue = 0;
147  validHitsValue = 100;
148  chi2Value = 0;
149  oneOverESuperMinusOneOverPValue = 0;
150  oneOverESeedMinusOneOverPValue = 0;
151  }else{
152  for(size_t trkNr=0;trkNr<gsfTracks.size();trkNr++){
153 
154  GlobalPoint scPos(scRef->x(),scRef->y(),scRef->z());
155  GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr],scPos);
156  EleRelPointPair scAtVtx(scRef->position(),trackExtrapToSC,beamSpot.position());
157 
158  float trkP = gsfTracks[trkNr]->p();
159  if(scRef->energy()!=0 && trkP!=0){
160  if(fabs(1/scRef->energy() - 1/trkP)<oneOverESuperMinusOneOverPValue) oneOverESuperMinusOneOverPValue =fabs(1/scRef->energy() - 1/trkP);
161  }
162  if(scRef->seed().isNonnull() && scRef->seed()->energy()!=0 && trkP!=0){
163  if(fabs(1/scRef->seed()->energy() - 1/trkP)<oneOverESeedMinusOneOverPValue) oneOverESeedMinusOneOverPValue =fabs(1/scRef->seed()->energy() - 1/trkP);
164  }
165 
166 
167  if (gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < missingHitsValue)
168  missingHitsValue = gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
169 
170  if (gsfTracks[trkNr]->numberOfValidHits() < validHitsValue)
171  validHitsValue = gsfTracks[trkNr]->numberOfValidHits();
172 
173  if (gsfTracks[trkNr]->numberOfValidHits() < chi2Value)
174  chi2Value = gsfTracks[trkNr]->normalizedChi2();
175 
176  if (fabs(scAtVtx.dEta())<dEtaInValue)
177  dEtaInValue=fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks
178 
179  if (fabs(scAtVtx.dEta())<dEtaSeedInValue)
180  dEtaSeedInValue = fabs(scAtVtx.dEta()-scRef->position().eta()+scRef->seed()->position().eta());
181 
182  if (fabs(scAtVtx.dPhi())<dPhiInValue)
183  dPhiInValue=fabs(scAtVtx.dPhi());//we are allowing them to come from different tracks
184  }
185  }
186 
187  dEtaMap.insert(recoEcalCandRef, dEtaInValue);
188  dEtaSeedMap.insert(recoEcalCandRef, dEtaSeedInValue);
189  dPhiMap.insert(recoEcalCandRef, dPhiInValue);
190  oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef,oneOverESuperMinusOneOverPValue);
191  oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef,oneOverESeedMinusOneOverPValue);
192  missingHitsMap.insert(recoEcalCandRef, missingHitsValue);
193  validHitsMap.insert(recoEcalCandRef, validHitsValue);
194  chi2Map.insert(recoEcalCandRef, chi2Value);
195  }
196 
197  auto dEtaMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dEtaMap);
198  auto dEtaSeedMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dEtaSeedMap);
199  auto dPhiMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dPhiMap);
200  auto oneOverESuperMinusOneOverPMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(oneOverESuperMinusOneOverPMap);
201  auto oneOverESeedMinusOneOverPMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(oneOverESeedMinusOneOverPMap);
202  auto missingHitsForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(missingHitsMap);
203  auto validHitsForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(validHitsMap);
204  auto chi2ForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(chi2Map);
205 
206  iEvent.put(std::move(dEtaMapForEvent), "Deta" );
207  iEvent.put(std::move(dEtaSeedMapForEvent), "DetaSeed" );
208  iEvent.put(std::move(dPhiMapForEvent), "Dphi" );
209  iEvent.put(std::move(oneOverESuperMinusOneOverPMapForEvent), "OneOESuperMinusOneOP");
210  iEvent.put(std::move(oneOverESeedMinusOneOverPMapForEvent), "OneOESeedMinusOneOP");
211  iEvent.put(std::move(missingHitsForEvent), "MissingHits");
212  iEvent.put(std::move(validHitsForEvent), "ValidHits");
213  iEvent.put(std::move(chi2ForEvent), "Chi2");
214 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool isBarrel(GeomDetEnumerators::SubDetector m)
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandTag_
GlobalPoint extrapolateTrackPosToPoint(const reco::GsfTrack &gsfTrack, const GlobalPoint &pointToExtrapTo)
const edm::EDGetTokenT< reco::GsfTrackCollection > inputCollectionTag2_
const edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
const edm::EDGetTokenT< reco::ElectronCollection > inputCollectionTag1_
REF castTo() const
Definition: RefToBase.h:289
T get() const
Definition: EventSetup.h:71
const Point & position() const
position
Definition: BeamSpot.h:62
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 77 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 75 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 76 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
private

Definition at line 81 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

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

Definition at line 74 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

TrackExtrapolator EgammaHLTGsfTrackVarProducer::trackExtrapolator_
private

Definition at line 79 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
private

Definition at line 80 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForBarrel_
private

Definition at line 82 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForEndcap_
private

Definition at line 83 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().