CMS 3D CMS Logo

EgammaTrackExtractor.cc
Go to the documentation of this file.
23 
24 #include <string>
25 #include <vector>
26 
27 namespace egammaisolation {
28 
30  public:
34 
35  ~EgammaTrackExtractor() override {}
36 
37  void fillVetos(const edm::Event& ev, const edm::EventSetup& evSetup, const reco::TrackCollection& track) override {}
38 
40  const edm::EventSetup& evSetup,
41  const reco::Track& track) const;
42 
44  const edm::EventSetup& evSetup,
45  const reco::Track& muon) const override {
46  edm::LogWarning("EgammaIsolationAlgos|EgammaTrackExtractor")
47  << "This Function is not implemented, bad IsoDeposit Returned";
49  }
50 
52  const edm::EventSetup& evSetup,
53  const reco::Candidate& muon) const override;
54 
55  private:
57 
58  private:
59  // Parameter set
62  double minCandEt_;
63  double theDiff_r;
64  double theDiff_z;
65  double theDR_Max;
66  double theDR_Veto;
71  unsigned int theNHits_Min;
72  double theChi2Ndof_Max;
73  double theChi2Prob_Min;
74  double thePt_Min;
75  std::vector<double> paramForIsolBarrel_;
76  std::vector<double> paramForIsolEndcap_;
78  int dzOption;
79  };
80 
81 } // namespace egammaisolation
82 
86 
87 using namespace edm;
88 using namespace std;
89 using namespace reco;
90 using namespace egammaisolation;
92 
93 EgammaTrackExtractor::EgammaTrackExtractor(const ParameterSet& par, edm::ConsumesCollector& iC)
94  : theTrackCollectionToken(iC.consumes<View<Track> >(par.getParameter<edm::InputTag>("inputTrackCollection"))),
95  theDepositLabel(par.getUntrackedParameter<std::string>("DepositLabel")),
96  theDiff_r(par.getParameter<double>("Diff_r")),
97  theDiff_z(par.getParameter<double>("Diff_z")),
98  theDR_Max(par.getParameter<double>("DR_Max")),
99  theDR_Veto(par.getParameter<double>("DR_Veto")),
100  theBeamlineOption(par.getParameter<std::string>("BeamlineOption")),
101  theBeamSpotToken(iC.mayConsume<reco::BeamSpot>(par.getParameter<edm::InputTag>("BeamSpotLabel"))),
102  theNHits_Min(par.getParameter<unsigned int>("NHits_Min")),
103  theChi2Ndof_Max(par.getParameter<double>("Chi2Ndof_Max")),
104  theChi2Prob_Min(par.getParameter<double>("Chi2Prob_Min")),
105  thePt_Min(par.getParameter<double>("Pt_Min")),
106  dzOptionString(par.getParameter<std::string>("dzOption")) {
107  if (!dzOptionString.compare("dz"))
109  else if (!dzOptionString.compare("vz"))
111  else if (!dzOptionString.compare("bs"))
113  else if (!dzOptionString.compare("vtx"))
115  else
117 }
118 
120  const edm::EventSetup& evSetup,
121  const reco::Track& track) const {
123  return reco::IsoDeposit::Vetos(1, veto(dir));
124 }
125 
128  result.vetoDir = dir;
129  result.dR = theDR_Veto;
130  return result;
131 }
132 
134  const EventSetup& eventSetup,
135  const Candidate& candTk) const {
136  static const std::string metname = "EgammaIsolationAlgos|EgammaTrackExtractor";
137 
139  double dzCut = 0;
140 
141  reco::TrackBase::Point beamPoint(0, 0, 0);
142  if (theBeamlineOption == "BeamSpotFromEvent") {
143  //pick beamSpot
144  auto beamSpotH = event.getHandle(theBeamSpotToken);
145 
146  if (beamSpotH.isValid()) {
147  beamPoint = beamSpotH->position();
148  }
149  }
150 
151  if (candTk.isElectron()) {
152  const reco::GsfElectron* elec = dynamic_cast<const reco::GsfElectron*>(&candTk);
153  candDir = reco::isodeposit::Direction(elec->gsfTrack()->eta(), elec->gsfTrack()->phi());
154  } else {
155  candDir = reco::isodeposit::Direction(candTk.eta(), candTk.phi());
156  }
157 
158  IsoDeposit deposit(candDir);
159  deposit.setVeto(veto(candDir));
160  deposit.addCandEnergy(candTk.et());
161 
162  for (auto const& itrTr : event.get(theTrackCollectionToken)) {
163  if (candDir.deltaR(reco::isodeposit::Direction(itrTr.eta(), itrTr.phi())) > theDR_Max)
164  continue;
165 
166  if (itrTr.normalizedChi2() > theChi2Ndof_Max)
167  continue;
168 
169  if (itrTr.pt() < thePt_Min)
170  continue;
171 
172  if (theChi2Prob_Min > 0 && ChiSquaredProbability(itrTr.chi2(), itrTr.ndof()) < theChi2Prob_Min)
173  continue;
174 
175  if (theNHits_Min > 0 && itrTr.numberOfValidHits() < theNHits_Min)
176  continue;
177 
178  if (candTk.isElectron()) {
179  const reco::GsfElectron* elec = dynamic_cast<const reco::GsfElectron*>(&candTk);
180  switch (dzOption) {
182  dzCut = elec->gsfTrack()->dz() - itrTr.dz();
183  break;
185  dzCut = elec->gsfTrack()->vz() - itrTr.vz();
186  break;
188  dzCut = elec->gsfTrack()->dz(beamPoint) - itrTr.dz(beamPoint);
189  break;
191  dzCut = itrTr.dz(elec->gsfTrack()->vertex());
192  break;
193  default:
194  dzCut = elec->gsfTrack()->vz() - itrTr.vz();
195  break;
196  }
197  } else {
198  switch (dzOption) {
200  dzCut = itrTr.dz() - candTk.vertex().z();
201  break;
203  dzCut = itrTr.vz() - candTk.vertex().z();
204  break;
206  dzCut = itrTr.dz(beamPoint) - candTk.vertex().z();
207  break;
209  dzCut = itrTr.dz(candTk.vertex());
210  break;
211  default:
212  dzCut = itrTr.vz() - candTk.vertex().z();
213  break;
214  }
215  }
216 
217  if (fabs(dzCut) > theDiff_z)
218  continue;
219 
220  if (fabs(itrTr.dxy(beamPoint)) > theDiff_r)
221  continue;
222 
223  deposit.addDeposit(reco::isodeposit::Direction(itrTr.eta(), itrTr.phi()), itrTr.pt());
224  }
225 
226  return deposit;
227 }
Handle.h
egammaisolation::EgammaTrackExtractor::paramForIsolBarrel_
std::vector< double > paramForIsolBarrel_
min track pt to include into iso deposit
Definition: EgammaTrackExtractor.cc:75
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:163
MessageLogger.h
muon
Definition: MuonCocktails.h:17
egammaisolation
Definition: EgammaTrackSelector.h:11
egammaisolation::EgammaTrackExtractor::paramForIsolEndcap_
std::vector< double > paramForIsolEndcap_
Barrel requirements to determine if isolated for selective filling.
Definition: EgammaTrackExtractor.cc:76
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
edm::EDGetTokenT
Definition: EDGetToken.h:33
ChiSquaredProbability
float ChiSquaredProbability(double chiSquared, double nrDOF)
Definition: ChiSquaredProbability.cc:13
edm
HLT enums.
Definition: AlignableModifier.h:19
egammaisolation::EgammaTrackExtractor::theBeamSpotToken
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
Definition: EgammaTrackExtractor.cc:70
reco::IsoDeposit::addDeposit
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:19
pat::IsoDeposit
reco::IsoDeposit IsoDeposit
Definition: Isolation.h:7
egammaisolation::EgammaTrackExtractor::fillVetos
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &track) override
Definition: EgammaTrackExtractor.cc:37
ChiSquaredProbability.h
egammaisolation::EgammaTrackExtractor::EgammaTrackExtractor
EgammaTrackExtractor()
Definition: EgammaTrackExtractor.cc:31
egammaisolation::EgammaTrackExtractor::theDepositLabel
std::string theDepositLabel
Track Collection Label.
Definition: EgammaTrackExtractor.cc:61
reco::IsoDeposit::Veto
Definition: IsoDeposit.h:59
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
egammaisolation::EgammaTrackExtractor::theDR_Max
double theDR_Max
z distance to vertex
Definition: EgammaTrackExtractor.cc:65
RecoCandidate.h
IsoDepositDirection.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
egammaisolation::EgammaTrackExtractor::theChi2Ndof_Max
double theChi2Ndof_Max
trk.numberOfValidHits >= theNHits_Min
Definition: EgammaTrackExtractor.cc:72
egammaisolation::EgammaTrackSelector::bs
Definition: EgammaTrackSelector.h:20
MakerMacros.h
Track.h
TrackFwd.h
BeamSpot.h
egammaisolation::EgammaTrackExtractor::deposit
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &muon) const override
Definition: EgammaTrackExtractor.cc:43
reco::BeamSpot
Definition: BeamSpot.h:21
TrackSplittingMonitor_cfi.dzCut
dzCut
Definition: TrackSplittingMonitor_cfi.py:20
egammaisolation::EgammaTrackExtractor::dzOption
int dzOption
Definition: EgammaTrackExtractor.cc:78
reco::Track
Definition: Track.h:27
reco::GsfElectron
Definition: GsfElectron.h:34
egammaisolation::EgammaTrackExtractor::~EgammaTrackExtractor
~EgammaTrackExtractor() override
Definition: EgammaTrackExtractor.cc:35
GsfElectron.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
egammaisolation::EgammaTrackSelector::vtx
Definition: EgammaTrackSelector.h:20
IsoDeposit.h
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IsoDepositExtractor.h
egammaisolation::EgammaTrackExtractor::theChi2Prob_Min
double theChi2Prob_Min
trk.normalizedChi2 < theChi2Ndof_Max
Definition: EgammaTrackExtractor.cc:73
egammaisolation::EgammaTrackExtractor::theDiff_r
double theDiff_r
minimum candidate et
Definition: EgammaTrackExtractor.cc:63
edm::View
Definition: CaloClusterFwd.h:14
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
reco::isodeposit::Direction::deltaR
double deltaR(const Direction &dir2) const
Definition: IsoDepositDirection.h:47
egammaisolation::EgammaTrackExtractor::theNHits_Min
unsigned int theNHits_Min
BeamSpot name.
Definition: EgammaTrackExtractor.cc:71
egammaisolation::EgammaTrackExtractor::theDR_Veto
double theDR_Veto
Maximum cone angle for deposits.
Definition: EgammaTrackExtractor.cc:66
egammaisolation::EgammaTrackSelector::dz
Definition: EgammaTrackSelector.h:20
edmplugin::PluginFactory
Definition: PluginFactory.h:34
egammaisolation::EgammaTrackExtractor::theDiff_z
double theDiff_z
transverse distance to vertex
Definition: EgammaTrackExtractor.cc:64
reco::Candidate::vertex
virtual const Point & vertex() const =0
vertex position
createfilelist.int
int
Definition: createfilelist.py:10
GsfTrack.h
egammaisolation::EgammaTrackExtractor::thePt_Min
double thePt_Min
ChiSquaredProbability(trk.chi2,trk.ndof) > theChi2Prob_Min.
Definition: EgammaTrackExtractor.cc:74
egammaisolation::EgammaTrackExtractor
Definition: EgammaTrackExtractor.cc:29
edm::EventSetup
Definition: EventSetup.h:58
EgammaTrackSelector.h
reco::Candidate
Definition: Candidate.h:27
egammaisolation::EgammaTrackExtractor::vetos
virtual reco::IsoDeposit::Vetos vetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
Definition: EgammaTrackExtractor.cc:119
reco::TrackBase::Point
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
reco::IsoDeposit::addCandEnergy
void addCandEnergy(double et)
Set energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:132
egammaisolation::EgammaTrackExtractor::EgammaTrackExtractor
EgammaTrackExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
Definition: EgammaTrackExtractor.cc:32
reco::Candidate::isElectron
virtual bool isElectron() const =0
std
Definition: JetResolutionObject.h:76
GsfTrackFwd.h
egammaisolation::EgammaTrackExtractor::theBeamlineOption
std::string theBeamlineOption
Veto cone angle.
Definition: EgammaTrackExtractor.cc:67
SuperClusterFwd.h
egammaisolation::EgammaTrackExtractor::dzOptionString
std::string dzOptionString
Endcap requirements to determine if isolated for selective filling.
Definition: EgammaTrackExtractor.cc:77
egammaisolation::EgammaTrackSelector::vz
Definition: EgammaTrackSelector.h:20
egammaisolation::EgammaTrackExtractor::minCandEt_
double minCandEt_
name for deposit
Definition: EgammaTrackExtractor.cc:62
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
EgammaRecHitIsolation.h
SuperCluster.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
IsoDepositExtractorFactory.h
reco::IsoDeposit
Definition: IsoDeposit.h:49
egammaisolation::EgammaTrackExtractor::theTrackCollectionToken
edm::EDGetTokenT< edm::View< reco::Track > > theTrackCollectionToken
Definition: EgammaTrackExtractor.cc:60
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
Candidate.h
View.h
reco::isodeposit::IsoDepositExtractor
Definition: IsoDepositExtractor.h:24
egammaisolation::EgammaTrackExtractor::barrelEcalHitsTag_
edm::InputTag barrelEcalHitsTag_
"NONE", "BeamSpotFromEvent"
Definition: EgammaTrackExtractor.cc:68
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
reco::IsoDeposit::Vetos
std::vector< Veto > Vetos
Definition: IsoDeposit.h:65
egammaisolation::EgammaTrackExtractor::veto
reco::IsoDeposit::Veto veto(const reco::IsoDeposit::Direction &dir) const
Definition: EgammaTrackExtractor.cc:126
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
reco::IsoDeposit::setVeto
void setVeto(const Veto &aVeto)
Set veto.
Definition: IsoDeposit.h:82
egammaisolation::EgammaTrackExtractor::endcapEcalHitsTag_
edm::InputTag endcapEcalHitsTag_
Definition: EgammaTrackExtractor.cc:69
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
reco::Candidate::et
virtual double et() const =0
transverse energy