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 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  useDefaultValuesForBarrel_ (config.getParameter<bool>("useDefaultValuesForBarrel")),
41  useDefaultValuesForEndcap_ (config.getParameter<bool>("useDefaultValuesForEndcap"))
42 {
43 
44  //register your products
45  produces < reco::RecoEcalCandidateIsolationMap >( "Deta" ).setBranchAlias( "deta" );
46  produces < reco::RecoEcalCandidateIsolationMap >( "DetaSeed" ).setBranchAlias( "detaseed" );
47  produces < reco::RecoEcalCandidateIsolationMap >( "Dphi" ).setBranchAlias( "dphi" );
48  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESuperMinusOneOP" );
49  produces < reco::RecoEcalCandidateIsolationMap >( "OneOESeedMinusOneOP" );
50  produces < reco::RecoEcalCandidateIsolationMap >( "MissingHits" ).setBranchAlias( "missinghits" );
51  produces < reco::RecoEcalCandidateIsolationMap >( "Chi2" ).setBranchAlias( "chi2" );
52  produces < reco::RecoEcalCandidateIsolationMap >( "ValidHits" ).setBranchAlias( "validhits" );
53 }
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 55 of file EgammaHLTGsfTrackVarProducer.cc.

56 {}

Member Function Documentation

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

Definition at line 58 of file EgammaHLTGsfTrackVarProducer.cc.

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

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

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

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForBarrel_
private

Definition at line 84 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForEndcap_
private

Definition at line 85 of file EgammaHLTGsfTrackVarProducer.h.

Referenced by produce().