CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes
EgammaHLTGsfTrackVarProducer Class Reference
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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 60 of file EgammaHLTGsfTrackVarProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 105 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by EgammaHLTGsfTrackVarProducer::TrackExtrapolator::mtsTransform().

107  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
108  inputCollectionTag1_(consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("inputCollection"))),
109  inputCollectionTag2_(consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("inputCollection"))),
110  beamSpotTag_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))),
111  upperTrackNrToRemoveCut_(config.getParameter<int>("upperTrackNrToRemoveCut")),
112  lowerTrackNrToRemoveCut_(config.getParameter<int>("lowerTrackNrToRemoveCut")),
113  useDefaultValuesForBarrel_(config.getParameter<bool>("useDefaultValuesForBarrel")),
114  useDefaultValuesForEndcap_(config.getParameter<bool>("useDefaultValuesForEndcap")) {
115  //register your products
116  produces<reco::RecoEcalCandidateIsolationMap>("Deta").setBranchAlias("deta");
117  produces<reco::RecoEcalCandidateIsolationMap>("DetaSeed").setBranchAlias("detaseed");
118  produces<reco::RecoEcalCandidateIsolationMap>("Dphi").setBranchAlias("dphi");
119  produces<reco::RecoEcalCandidateIsolationMap>("OneOESuperMinusOneOP");
120  produces<reco::RecoEcalCandidateIsolationMap>("OneOESeedMinusOneOP");
121  produces<reco::RecoEcalCandidateIsolationMap>("MissingHits").setBranchAlias("missinghits");
122  produces<reco::RecoEcalCandidateIsolationMap>("Chi2").setBranchAlias("chi2");
123  produces<reco::RecoEcalCandidateIsolationMap>("ValidHits").setBranchAlias("validhits");
124 }
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

Member Function Documentation

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

Definition at line 128 of file EgammaHLTGsfTrackVarProducer.cc.

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

Referenced by EgammaHLTGsfTrackVarProducer::TrackExtrapolator::mtsTransform().

128  {
130  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate"));
131  desc.add<edm::InputTag>(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks"));
132  desc.add<edm::InputTag>(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot"));
133  desc.add<int>(("upperTrackNrToRemoveCut"), 9999);
134  desc.add<int>(("lowerTrackNrToRemoveCut"), -1);
135  desc.add<bool>(("useDefaultValuesForBarrel"), false);
136  desc.add<bool>(("useDefaultValuesForEndcap"), false);
137 
138  descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc);
139 }
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 140 of file EgammaHLTGsfTrackVarProducer.cc.

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

Referenced by EgammaHLTGsfTrackVarProducer::TrackExtrapolator::mtsTransform().

140  {
141  trackExtrapolator_.setup(iSetup);
142 
143  // Get the HLT filtered objects
145  iEvent.getByToken(recoEcalCandTag_, recoEcalCandHandle);
146 
148  iEvent.getByToken(inputCollectionTag1_, electronHandle);
149 
151  if (!electronHandle.isValid())
152  iEvent.getByToken(inputCollectionTag2_, gsfTracksHandle);
153 
154  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
155  iEvent.getByToken(beamSpotTag_, recoBeamSpotHandle);
156  // gets its position
157  const reco::BeamSpot& beamSpot = *recoBeamSpotHandle;
158 
159  edm::ESHandle<MagneticField> theMagField;
160  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
161 
162  reco::RecoEcalCandidateIsolationMap dEtaMap(recoEcalCandHandle);
163  reco::RecoEcalCandidateIsolationMap dEtaSeedMap(recoEcalCandHandle);
164  reco::RecoEcalCandidateIsolationMap dPhiMap(recoEcalCandHandle);
165  reco::RecoEcalCandidateIsolationMap oneOverESuperMinusOneOverPMap(recoEcalCandHandle);
166  reco::RecoEcalCandidateIsolationMap oneOverESeedMinusOneOverPMap(recoEcalCandHandle);
167  reco::RecoEcalCandidateIsolationMap missingHitsMap(recoEcalCandHandle);
168  reco::RecoEcalCandidateIsolationMap validHitsMap(recoEcalCandHandle);
169  reco::RecoEcalCandidateIsolationMap chi2Map(recoEcalCandHandle);
170 
171  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin();
172  iRecoEcalCand != recoEcalCandHandle->end();
173  iRecoEcalCand++) {
174  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin());
175 
176  const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster();
177  bool isBarrel = std::abs(recoEcalCandRef->eta()) < 1.479;
178  //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
179  std::vector<const reco::GsfTrack*> gsfTracks;
180  if (electronHandle.isValid()) {
181  for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end();
182  eleIt++) {
183  if (eleIt->superCluster() == scRef) {
184  gsfTracks.push_back(&*eleIt->gsfTrack());
185  }
186  }
187  } else {
188  for (reco::GsfTrackCollection::const_iterator trkIt = gsfTracksHandle->begin(); trkIt != gsfTracksHandle->end();
189  ++trkIt) {
190  edm::RefToBase<TrajectorySeed> seed = trkIt->extra()->seedRef();
192  edm::RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster();
193  reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>();
194  if (scRefFromTrk == scRef) {
195  gsfTracks.push_back(&*trkIt);
196  }
197  }
198  }
199 
200  int validHitsValue = 0;
201  float chi2Value = 9999999.;
202  float missingHitsValue = 9999999;
203  float dEtaInValue = 999999;
204  float dEtaSeedInValue = 999999;
205  float dPhiInValue = 999999;
206  float oneOverESuperMinusOneOverPValue = 999999;
207  float oneOverESeedMinusOneOverPValue = 999999;
208 
209  const int nrTracks = gsfTracks.size();
210  const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ || nrTracks >= upperTrackNrToRemoveCut_;
211  //to use the default values, we require at least one track...
212  const bool useDefaultValues =
213  isBarrel ? useDefaultValuesForBarrel_ && nrTracks >= 1 : useDefaultValuesForEndcap_ && nrTracks >= 1;
214 
215  if (rmCutsDueToNrTracks || useDefaultValues) {
216  dEtaInValue = 0;
217  dEtaSeedInValue = 0;
218  dPhiInValue = 0;
219  missingHitsValue = 0;
220  validHitsValue = 100;
221  chi2Value = 0;
222  oneOverESuperMinusOneOverPValue = 0;
223  oneOverESeedMinusOneOverPValue = 0;
224  } else {
225  for (size_t trkNr = 0; trkNr < gsfTracks.size(); trkNr++) {
226  GlobalPoint scPos(scRef->x(), scRef->y(), scRef->z());
227  GlobalPoint trackExtrapToSC = trackExtrapolator_.extrapolateTrackPosToPoint(*gsfTracks[trkNr], scPos);
228  EleRelPointPair scAtVtx(scRef->position(), trackExtrapToSC, beamSpot.position());
229 
230  float trkP = gsfTracks[trkNr]->p();
231  if (scRef->energy() != 0 && trkP != 0) {
232  if (fabs(1 / scRef->energy() - 1 / trkP) < oneOverESuperMinusOneOverPValue)
233  oneOverESuperMinusOneOverPValue = fabs(1 / scRef->energy() - 1 / trkP);
234  }
235  if (scRef->seed().isNonnull() && scRef->seed()->energy() != 0 && trkP != 0) {
236  if (fabs(1 / scRef->seed()->energy() - 1 / trkP) < oneOverESeedMinusOneOverPValue)
237  oneOverESeedMinusOneOverPValue = fabs(1 / scRef->seed()->energy() - 1 / trkP);
238  }
239 
240  if (gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) < missingHitsValue)
241  missingHitsValue = gsfTracks[trkNr]->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
242 
243  if (gsfTracks[trkNr]->numberOfValidHits() < validHitsValue)
244  validHitsValue = gsfTracks[trkNr]->numberOfValidHits();
245 
246  if (gsfTracks[trkNr]->numberOfValidHits() < chi2Value)
247  chi2Value = gsfTracks[trkNr]->normalizedChi2();
248 
249  if (fabs(scAtVtx.dEta()) < dEtaInValue)
250  dEtaInValue = fabs(scAtVtx.dEta()); //we are allowing them to come from different tracks
251 
252  if (fabs(scAtVtx.dEta()) < dEtaSeedInValue)
253  dEtaSeedInValue = fabs(scAtVtx.dEta() - scRef->position().eta() + scRef->seed()->position().eta());
254 
255  if (fabs(scAtVtx.dPhi()) < dPhiInValue)
256  dPhiInValue = fabs(scAtVtx.dPhi()); //we are allowing them to come from different tracks
257  }
258  }
259 
260  dEtaMap.insert(recoEcalCandRef, dEtaInValue);
261  dEtaSeedMap.insert(recoEcalCandRef, dEtaSeedInValue);
262  dPhiMap.insert(recoEcalCandRef, dPhiInValue);
263  oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef, oneOverESuperMinusOneOverPValue);
264  oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef, oneOverESeedMinusOneOverPValue);
265  missingHitsMap.insert(recoEcalCandRef, missingHitsValue);
266  validHitsMap.insert(recoEcalCandRef, validHitsValue);
267  chi2Map.insert(recoEcalCandRef, chi2Value);
268  }
269 
270  auto dEtaMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dEtaMap);
271  auto dEtaSeedMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dEtaSeedMap);
272  auto dPhiMapForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(dPhiMap);
273  auto oneOverESuperMinusOneOverPMapForEvent =
274  std::make_unique<reco::RecoEcalCandidateIsolationMap>(oneOverESuperMinusOneOverPMap);
275  auto oneOverESeedMinusOneOverPMapForEvent =
276  std::make_unique<reco::RecoEcalCandidateIsolationMap>(oneOverESeedMinusOneOverPMap);
277  auto missingHitsForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(missingHitsMap);
278  auto validHitsForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(validHitsMap);
279  auto chi2ForEvent = std::make_unique<reco::RecoEcalCandidateIsolationMap>(chi2Map);
280 
281  iEvent.put(std::move(dEtaMapForEvent), "Deta");
282  iEvent.put(std::move(dEtaSeedMapForEvent), "DetaSeed");
283  iEvent.put(std::move(dPhiMapForEvent), "Dphi");
284  iEvent.put(std::move(oneOverESuperMinusOneOverPMapForEvent), "OneOESuperMinusOneOP");
285  iEvent.put(std::move(oneOverESeedMinusOneOverPMapForEvent), "OneOESeedMinusOneOP");
286  iEvent.put(std::move(missingHitsForEvent), "MissingHits");
287  iEvent.put(std::move(validHitsForEvent), "ValidHits");
288  iEvent.put(std::move(chi2ForEvent), "Chi2");
289 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:70
const edm::EDGetTokenT< reco::ElectronCollection > inputCollectionTag1_
REF castTo() const
Definition: RefToBase.h:257
T get() const
Definition: EventSetup.h:73
const Point & position() const
position
Definition: BeamSpot.h:59
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 96 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

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

Definition at line 94 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

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

Definition at line 95 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
private

Definition at line 100 of file EgammaHLTGsfTrackVarProducer.cc.

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

Definition at line 93 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

TrackExtrapolator EgammaHLTGsfTrackVarProducer::trackExtrapolator_
private

Definition at line 98 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

const int EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
private

Definition at line 99 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForBarrel_
private

Definition at line 101 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().

const bool EgammaHLTGsfTrackVarProducer::useDefaultValuesForEndcap_
private

Definition at line 102 of file EgammaHLTGsfTrackVarProducer.cc.

Referenced by produce().