CMS 3D CMS Logo

EgammaHLTGsfTrackVarProducer.cc
Go to the documentation of this file.
1 
9 // this class is designed to calculate dEtaIn,dPhiIn gsf track - supercluster
10 // pairs it can take as input std::vector<Electron> which the gsf track-sc is
11 // already done or it can run over the std::vector<GsfTrack> directly in which
12 // case it will pick the smallest dEta,dPhi the dEta, dPhi do not have to be
13 // from the same track it can optionally set dEta, dPhi to 0 based on the number
14 // of tracks found
15 
40 
42 public:
44  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 private:
52 
55 
60 
70 };
71 
73  : recoEcalCandToken_(
74  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
75  electronToken_{consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("inputCollection"))},
76  gsfTrackToken_{consumes<reco::GsfTrackCollection>(config.getParameter<edm::InputTag>("inputCollection"))},
77  beamSpotToken_{consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))},
78  magneticFieldToken_{esConsumes()},
79  trackerGeometryToken_{esConsumes()},
80  upperTrackNrToRemoveCut_{config.getParameter<int>("upperTrackNrToRemoveCut")},
81  lowerTrackNrToRemoveCut_{config.getParameter<int>("lowerTrackNrToRemoveCut")},
82  useDefaultValuesForBarrel_{config.getParameter<bool>("useDefaultValuesForBarrel")},
83  useDefaultValuesForEndcap_{config.getParameter<bool>("useDefaultValuesForEndcap")},
84  dEtaMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("Deta").setBranchAlias("deta")},
85  dEtaSeedMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("DetaSeed").setBranchAlias("detaseed")},
86  dPhiMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("Dphi").setBranchAlias("dphi")},
87  oneOverESuperMinusOneOverPMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("OneOESuperMinusOneOP")},
88  oneOverESeedMinusOneOverPMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("OneOESeedMinusOneOP")},
89  missingHitsMapPutToken_{
90  produces<reco::RecoEcalCandidateIsolationMap>("MissingHits").setBranchAlias("missinghits")},
91  validHitsMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("ValidHits").setBranchAlias("validhits")},
92  nLayerITMapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("NLayerIT").setBranchAlias("nlayerit")},
93  chi2MapPutToken_{produces<reco::RecoEcalCandidateIsolationMap>("Chi2").setBranchAlias("chi2")} {}
94 
97  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltRecoEcalSuperClusterActivityCandidate"));
98  desc.add<edm::InputTag>(("inputCollection"), edm::InputTag("hltActivityElectronGsfTracks"));
99  desc.add<edm::InputTag>(("beamSpotProducer"), edm::InputTag("hltOnlineBeamSpot"));
100  desc.add<int>(("upperTrackNrToRemoveCut"), 9999);
101  desc.add<int>(("lowerTrackNrToRemoveCut"), -1);
102  desc.add<bool>(("useDefaultValuesForBarrel"), false);
103  desc.add<bool>(("useDefaultValuesForEndcap"), false);
104 
105  descriptions.add("hltEgammaHLTGsfTrackVarProducer", desc);
106 }
108  // Get the HLT filtered objects
109  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandToken_);
110 
111  auto const& beamSpotPosition = iEvent.get(beamSpotToken_).position();
112  auto const& magneticField = iSetup.getData(magneticFieldToken_);
113  auto const& trackerGeometry = iSetup.getData(trackerGeometryToken_);
114 
117 
118  reco::RecoEcalCandidateIsolationMap dEtaMap(recoEcalCandHandle);
119  reco::RecoEcalCandidateIsolationMap dEtaSeedMap(recoEcalCandHandle);
120  reco::RecoEcalCandidateIsolationMap dPhiMap(recoEcalCandHandle);
121  reco::RecoEcalCandidateIsolationMap oneOverESuperMinusOneOverPMap(recoEcalCandHandle);
122  reco::RecoEcalCandidateIsolationMap oneOverESeedMinusOneOverPMap(recoEcalCandHandle);
123  reco::RecoEcalCandidateIsolationMap missingHitsMap(recoEcalCandHandle);
124  reco::RecoEcalCandidateIsolationMap validHitsMap(recoEcalCandHandle);
125  reco::RecoEcalCandidateIsolationMap nLayerITMap(recoEcalCandHandle);
126  reco::RecoEcalCandidateIsolationMap chi2Map(recoEcalCandHandle);
127 
128  for (unsigned int iRecoEcalCand = 0; iRecoEcalCand < recoEcalCandHandle->size(); ++iRecoEcalCand) {
129  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
130 
131  const reco::SuperClusterRef scRef = recoEcalCandRef->superCluster();
132  // the idea is that we can take the tracks from properly associated
133  // electrons or just take all gsf tracks with that sc as a seed
134  std::vector<const reco::GsfTrack*> gsfTracks;
135  if (auto electronHandle = iEvent.getHandle(electronToken_)) {
136  for (auto const& ele : *electronHandle) {
137  if (ele.superCluster() == scRef) {
138  gsfTracks.push_back(ele.gsfTrack().get());
139  }
140  }
141  } else {
142  for (auto const& trk : iEvent.get(gsfTrackToken_)) {
143  auto elseed = trk.extra()->seedRef().castTo<reco::ElectronSeedRef>();
144  if (elseed->caloCluster().castTo<reco::SuperClusterRef>() == scRef) {
145  gsfTracks.push_back(&trk);
146  }
147  }
148  }
149 
150  int nLayerITValue = -1;
151  int validHitsValue = 0;
152  float chi2Value = 9999999.;
153  float missingHitsValue = 9999999;
154  float dEtaInValue = 999999;
155  float dEtaSeedInValue = 999999;
156  float dPhiInValue = 999999;
157  float oneOverESuperMinusOneOverPValue = 999999;
158  float oneOverESeedMinusOneOverPValue = 999999;
159 
160  const int nrTracks = gsfTracks.size();
161  const bool rmCutsDueToNrTracks = nrTracks <= lowerTrackNrToRemoveCut_ || nrTracks >= upperTrackNrToRemoveCut_;
162  // to use the default values, we require at least one track...
163  const bool useDefaultValues = std::abs(recoEcalCandRef->eta()) < 1.479
164  ? useDefaultValuesForBarrel_ && nrTracks >= 1
165  : useDefaultValuesForEndcap_ && nrTracks >= 1;
166 
167  if (rmCutsDueToNrTracks || useDefaultValues) {
168  nLayerITValue = 100;
169  dEtaInValue = 0;
170  dEtaSeedInValue = 0;
171  dPhiInValue = 0;
172  missingHitsValue = 0;
173  validHitsValue = 100;
174  chi2Value = 0;
175  oneOverESuperMinusOneOverPValue = 0;
176  oneOverESeedMinusOneOverPValue = 0;
177  } else {
178  for (size_t trkNr = 0; trkNr < gsfTracks.size(); trkNr++) {
179  GlobalPoint scPos(scRef->x(), scRef->y(), scRef->z());
180 
181  GlobalPoint trackExtrapToSC;
182  {
183  auto innTSOS =
185  auto posTSOS = extrapolator.extrapolate(innTSOS, scPos);
186  multiTrajectoryStateMode::positionFromModeCartesian(posTSOS, trackExtrapToSC);
187  }
188 
189  EleRelPointPair scAtVtx(scRef->position(), trackExtrapToSC, beamSpotPosition);
190 
191  float trkP = gsfTracks[trkNr]->p();
192  if (scRef->energy() != 0 && trkP != 0) {
193  if (std::abs(1 / scRef->energy() - 1 / trkP) < oneOverESuperMinusOneOverPValue) {
194  oneOverESuperMinusOneOverPValue = std::abs(1 / scRef->energy() - 1 / trkP);
195  }
196  }
197  if (scRef->seed().isNonnull() && scRef->seed()->energy() != 0 && trkP != 0) {
198  if (std::abs(1 / scRef->seed()->energy() - 1 / trkP) < oneOverESeedMinusOneOverPValue) {
199  oneOverESeedMinusOneOverPValue = std::abs(1 / scRef->seed()->energy() - 1 / trkP);
200  }
201  }
202 
203  if (gsfTracks[trkNr]->missingInnerHits() < missingHitsValue) {
204  missingHitsValue = gsfTracks[trkNr]->missingInnerHits();
205  }
206 
207  // we are saving the best value, and highest value of validHits is the
208  // best
209  if (gsfTracks[trkNr]->numberOfValidHits() > validHitsValue) {
210  validHitsValue = gsfTracks[trkNr]->numberOfValidHits();
211  }
212 
213  if (gsfTracks[trkNr]->hitPattern().pixelLayersWithMeasurement() > nLayerITValue) {
214  nLayerITValue = gsfTracks[trkNr]->hitPattern().pixelLayersWithMeasurement();
215  }
216 
217  if (gsfTracks[trkNr]->normalizedChi2() < chi2Value) {
218  chi2Value = gsfTracks[trkNr]->normalizedChi2();
219  }
220 
221  if (std::abs(scAtVtx.dEta()) < dEtaInValue) {
222  // we are allowing them to come from different tracks
223  dEtaInValue = std::abs(scAtVtx.dEta());
224  }
225 
226  if (std::abs(scAtVtx.dEta()) < dEtaSeedInValue) {
227  dEtaSeedInValue = std::abs(scAtVtx.dEta() - scRef->position().eta() + scRef->seed()->position().eta());
228  }
229 
230  if (std::abs(scAtVtx.dPhi()) < dPhiInValue) {
231  // we are allowing them to come from different tracks
232  dPhiInValue = std::abs(scAtVtx.dPhi());
233  }
234  }
235  }
236 
237  dEtaMap.insert(recoEcalCandRef, dEtaInValue);
238  dEtaSeedMap.insert(recoEcalCandRef, dEtaSeedInValue);
239  dPhiMap.insert(recoEcalCandRef, dPhiInValue);
240  oneOverESuperMinusOneOverPMap.insert(recoEcalCandRef, oneOverESuperMinusOneOverPValue);
241  oneOverESeedMinusOneOverPMap.insert(recoEcalCandRef, oneOverESeedMinusOneOverPValue);
242  missingHitsMap.insert(recoEcalCandRef, missingHitsValue);
243  validHitsMap.insert(recoEcalCandRef, validHitsValue);
244  nLayerITMap.insert(recoEcalCandRef, nLayerITValue);
245  chi2Map.insert(recoEcalCandRef, chi2Value);
246  }
247 
248  iEvent.emplace(dEtaMapPutToken_, dEtaMap);
249  iEvent.emplace(dEtaSeedMapPutToken_, dEtaSeedMap);
250  iEvent.emplace(dPhiMapPutToken_, dPhiMap);
251  iEvent.emplace(oneOverESuperMinusOneOverPMapPutToken_, oneOverESuperMinusOneOverPMap);
252  iEvent.emplace(oneOverESeedMinusOneOverPMapPutToken_, oneOverESeedMinusOneOverPMap);
253  iEvent.emplace(missingHitsMapPutToken_, missingHitsMap);
254  iEvent.emplace(validHitsMapPutToken_, validHitsMap);
255  iEvent.emplace(nLayerITMapPutToken_, nLayerITMap);
256  iEvent.emplace(chi2MapPutToken_, chi2Map);
257 }
258 
RecoEcalCandidateIsolation.h
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
EgammaHLTGsfTrackVarProducer::chi2MapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > chi2MapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:69
TrajectoryStateOnSurface.h
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
anyDirection
Definition: PropagationDirection.h:4
TrackerGeometry.h
EgammaHLTGsfTrackVarProducer::trackerGeometryToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:54
EgammaHLTGsfTrackVarProducer::dEtaSeedMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > dEtaSeedMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:62
GsfPropagatorAdapter.h
EgammaHLTGsfTrackVarProducer::validHitsMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > validHitsMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:67
edm::EDGetTokenT< reco::RecoEcalCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
EgammaHLTGsfTrackVarProducer::gsfTrackToken_
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:50
TrackCollections2monitor_cff.numberOfValidHits
numberOfValidHits
Definition: TrackCollections2monitor_cff.py:248
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
EgammaHLTGsfTrackVarProducer::upperTrackNrToRemoveCut_
const int upperTrackNrToRemoveCut_
Definition: EgammaHLTGsfTrackVarProducer.cc:56
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ElectronUtilities.h
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
edm::Ref
Definition: AssociativeIterator.h:58
config
Definition: config.py:1
EgammaHLTGsfTrackVarProducer::electronToken_
const edm::EDGetTokenT< reco::ElectronCollection > electronToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:49
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EgammaHLTGsfTrackVarProducer::useDefaultValuesForBarrel_
const bool useDefaultValuesForBarrel_
Definition: EgammaHLTGsfTrackVarProducer.cc:58
MultiTrajectoryStateMode.h
EgammaHLTGsfTrackVarProducer
Definition: EgammaHLTGsfTrackVarProducer.cc:41
IdealMagneticFieldRecord.h
EgammaHLTGsfTrackVarProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EgammaHLTGsfTrackVarProducer.cc:95
ecalDrivenGsfElectronCoresFromMultiCl_cff.gsfTracks
gsfTracks
Definition: ecalDrivenGsfElectronCoresFromMultiCl_cff.py:4
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
EgammaHLTGsfTrackVarProducer::dPhiMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > dPhiMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:63
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AnalyticalPropagator_cfi.AnalyticalPropagator
AnalyticalPropagator
Definition: AnalyticalPropagator_cfi.py:3
MultiTrajectoryStateTransform.h
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EgammaHLTGsfTrackVarProducer::nLayerITMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > nLayerITMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:68
edm::AssociationMap
Definition: AssociationMap.h:48
EgammaHLTGsfTrackVarProducer::useDefaultValuesForEndcap_
const bool useDefaultValuesForEndcap_
Definition: EgammaHLTGsfTrackVarProducer.cc:59
EgammaHLTGsfTrackVarProducer::lowerTrackNrToRemoveCut_
const int lowerTrackNrToRemoveCut_
Definition: EgammaHLTGsfTrackVarProducer.cc:57
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
iEvent
int iEvent
Definition: GenABIO.cc:224
multiTrajectoryStateMode::positionFromModeCartesian
bool positionFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalPoint &position)
Definition: MultiTrajectoryStateMode.cc:63
EgammaHLTGsfTrackVarProducer::beamSpotToken_
const edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:51
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
AnalyticalPropagator.h
EleRelPointPair
Definition: ElectronUtilities.h:43
EgammaHLTGsfTrackVarProducer::missingHitsMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > missingHitsMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:66
TrackCollections2monitor_cff.normalizedChi2
normalizedChi2
Definition: TrackCollections2monitor_cff.py:247
TrajectorySeedCollection.h
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
edm::AssociationMap::insert
void insert(const key_type &k, const data_type &v)
insert an association
Definition: AssociationMap.h:166
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Electron.h
RecoEcalCandidate.h
SuperCluster.h
EgammaHLTGsfTrackVarProducer::dEtaMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > dEtaMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:61
TransverseImpactPointExtrapolator.h
ElectronIsolationAssociation.h
MultiTrajectoryStateTransform::innerStateOnSurface
TrajectoryStateOnSurface innerStateOnSurface(const reco::GsfTrack &tk) const
Definition: MultiTrajectoryStateTransform.cc:23
EgammaHLTGsfTrackVarProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: EgammaHLTGsfTrackVarProducer.cc:107
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EgammaHLTGsfTrackVarProducer::EgammaHLTGsfTrackVarProducer
EgammaHLTGsfTrackVarProducer(const edm::ParameterSet &)
Definition: EgammaHLTGsfTrackVarProducer.cc:72
EDProducer.h
GsfPropagatorAdapter
Definition: GsfPropagatorAdapter.h:14
edm::Event
Definition: Event.h:73
EgammaHLTGsfTrackVarProducer::oneOverESuperMinusOneOverPMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > oneOverESuperMinusOneOverPMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:64
EgammaHLTGsfTrackVarProducer::recoEcalCandToken_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:48
EgammaHLTGsfTrackVarProducer::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:53
edm::InputTag
Definition: InputTag.h:15
ElectronSeed.h
EgammaHLTGsfTrackVarProducer::oneOverESeedMinusOneOverPMapPutToken_
const edm::EDPutTokenT< reco::RecoEcalCandidateIsolationMap > oneOverESeedMinusOneOverPMapPutToken_
Definition: EgammaHLTGsfTrackVarProducer.cc:65