CMS 3D CMS Logo

ElectronConversionRejectionValidator.cc
Go to the documentation of this file.
1 #include <iostream>
2 //
5 //
7 
8 //
12 //
13 
14 //
27 
28 //
29 //
30 #include "TFile.h"
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TTree.h"
34 #include "TVector3.h"
35 #include "TProfile.h"
36 #include "TMath.h"
37 //
46 using namespace std;
47 
49  fName_ = pset.getUntrackedParameter<std::string>("Name");
50  verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
51  parameters_ = pset;
52 
53  gsfElectronCollectionProducer_ = pset.getParameter<std::string>("gsfElectronProducer");
54  gsfElectronCollection_ = pset.getParameter<std::string>("gsfElectronCollection");
55 
56  conversionCollectionProducer_ = pset.getParameter<std::string>("convProducer");
57  conversionCollection_ = pset.getParameter<std::string>("conversionCollection");
58  // conversionTrackProducer_ = pset.getParameter<std::string>("trackProducer");
59  gsfElecToken_ =
60  consumes<reco::GsfElectronCollection>(edm::InputTag(gsfElectronCollectionProducer_, gsfElectronCollection_));
61  convToken_ =
62  consumes<reco::ConversionCollection>(edm::InputTag(conversionCollectionProducer_, conversionCollection_));
63 
64  isRunCentrally_ = pset.getParameter<bool>("isRunCentrally");
65 
66  elePtMin_ = pset.getParameter<double>("elePtMin");
67  eleExpectedHitsInnerMax_ = pset.getParameter<int>("eleExpectedHitsInnerMax");
68  eleD0Max_ = pset.getParameter<double>("eleD0Max");
69  offline_pvToken_ = consumes<reco::VertexCollection>(
70  pset.getUntrackedParameter<edm::InputTag>("offlinePV", edm::InputTag("offlinePrimaryVertices")));
71  beamspotToken_ =
72  consumes<reco::BeamSpot>(pset.getUntrackedParameter<edm::InputTag>("beamspot", edm::InputTag("offlineBeamSpot")));
73 
74  nEvt_ = 0;
75  nEntry_ = 0;
76 }
77 
79 
81  edm::Run const&,
82  edm::EventSetup const&) {
83  double ptMin = parameters_.getParameter<double>("ptMin");
84  double ptMax = parameters_.getParameter<double>("ptMax");
85  int ptBin = parameters_.getParameter<int>("ptBin");
86 
87  double trackptMin = parameters_.getParameter<double>("trackptMin");
88  double trackptMax = parameters_.getParameter<double>("trackptMax");
89  int trackptBin = parameters_.getParameter<int>("trackptBin");
90 
91  double etaMin = parameters_.getParameter<double>("etaMin");
92  double etaMax = parameters_.getParameter<double>("etaMax");
93  int etaBin = parameters_.getParameter<int>("etaBin");
94 
95  double phiMin = -TMath::Pi();
96  double phiMax = TMath::Pi();
97  int phiBin = parameters_.getParameter<int>("phiBin");
98 
99  double rhoMin = parameters_.getParameter<double>("rhoMin");
100  double rhoMax = parameters_.getParameter<double>("rhoMax");
101  int rhoBin = parameters_.getParameter<int>("rhoBin");
102 
103  double zMin = parameters_.getParameter<double>("zMin");
104  double zMax = parameters_.getParameter<double>("zMax");
105  int zBin = parameters_.getParameter<int>("zBin");
106 
108  // SC from reco photons
109 
110  //TString simfolder = TString(
111  //std::string simpath = dqmpath_ + "SimulationInfo";
112  ibooker.setCurrentFolder(dqmpath_);
113  //
114  // simulation information about conversions
115  // Histograms for efficiencies
116  h_elePtAll_ = ibooker.book1D("elePtAll", "# of Electrons", ptBin, ptMin, ptMax);
117  h_eleEtaAll_ = ibooker.book1D("eleEtaAll", "# of Electrons", etaBin, etaMin, etaMax);
118  h_elePhiAll_ = ibooker.book1D("elePhiAll", "# of Electrons", phiBin, phiMin, phiMax);
119 
120  h_elePtPass_ = ibooker.book1D("elePtPass", "# of Electrons", ptBin, ptMin, ptMax);
121  h_eleEtaPass_ = ibooker.book1D("eleEtaPass", "# of Electrons", etaBin, etaMin, etaMax);
122  h_elePhiPass_ = ibooker.book1D("elePhiPass", "# of Electrons", phiBin, phiMin, phiMax);
123 
124  h_elePtFail_ = ibooker.book1D("elePtFail", "# of Electrons", ptBin, ptMin, ptMax);
125  h_eleEtaFail_ = ibooker.book1D("eleEtaFail", "# of Electrons", etaBin, etaMin, etaMax);
126  h_elePhiFail_ = ibooker.book1D("elePhiFail", "# of Electrons", phiBin, phiMin, phiMax);
127 
128  h_convPt_ = ibooker.book1D("convPt", "# of Electrons", ptBin, ptMin, ptMax);
129  h_convEta_ = ibooker.book1D("convEta", "# of Electrons", etaBin, etaMin, etaMax);
130  h_convPhi_ = ibooker.book1D("convPhi", "# of Electrons", phiBin, phiMin, phiMax);
131  h_convRho_ = ibooker.book1D("convRho", "# of Electrons", rhoBin, rhoMin, rhoMax);
132  h_convZ_ = ibooker.book1D("convZ", "# of Electrons", zBin, zMin, zMax);
133  h_convProb_ = ibooker.book1D("convProb", "# of Electrons", 100, 0.0, 1.0);
134 
135  h_convLeadTrackpt_ = ibooker.book1D("convLeadTrackpt", "# of Electrons", trackptBin, trackptMin, trackptMax);
136 
137  h_convTrailTrackpt_ = ibooker.book1D("convTrailTrackpt", "# of Electrons", trackptBin, trackptMin, trackptMax);
138 
139  h_convLog10TrailTrackpt_ = ibooker.book1D("convLog10TrailTrackpt", "# of Electrons", ptBin, -2.0, 3.0);
140 
141  h_convLeadTrackAlgo_ = ibooker.book1D(
142  "convLeadTrackAlgo", "# of Electrons", reco::TrackBase::algoSize, -0.5, reco::TrackBase::algoSize - 0.5);
143  h_convTrailTrackAlgo_ = ibooker.book1D(
144  "convLeadTrackAlgo", "# of Electrons", reco::TrackBase::algoSize, -0.5, reco::TrackBase::algoSize - 0.5);
145 }
146 
148  using namespace edm;
149 
150  nEvt_++;
151  LogInfo("ElectronConversionRejectionValidator")
152  << "ElectronConversionRejectionValidator Analyzing event number: " << e.id() << " Global Counter " << nEvt_
153  << "\n";
154 
157  e.getByToken(convToken_, convHandle);
158  if (!convHandle.isValid()) {
159  edm::LogError("ElectronConversionRejectionValidator") << "Error! Can't get the Conversion collection " << std::endl;
160  return;
161  }
162 
164  Handle<reco::GsfElectronCollection> gsfElectronHandle;
165  e.getByToken(gsfElecToken_, gsfElectronHandle);
166  const reco::GsfElectronCollection& gsfElectronCollection = *(gsfElectronHandle.product());
167  if (!gsfElectronHandle.isValid()) {
168  edm::LogError("ElectronConversionRejectionValidator") << "Error! Can't get the Electron collection " << std::endl;
169  return;
170  }
171 
172  // offline Primary vertex
174  e.getByToken(offline_pvToken_, vertexHandle);
175  if (!vertexHandle.isValid()) {
176  edm::LogError("ElectronConversionRejectionValidator") << "Error! Can't get the product primary Vertex Collection "
177  << "\n";
178  return;
179  }
180  const reco::Vertex& thevtx = vertexHandle->at(0);
181 
183  e.getByToken(beamspotToken_, bsHandle);
184  if (!bsHandle.isValid()) {
185  edm::LogError("ElectronConversionRejectionValidator") << "Error! Can't get the product beamspot Collection "
186  << "\n";
187  return;
188  }
189  const reco::BeamSpot& thebs = *bsHandle.product();
190 
191  //loop over electrons
192  for (reco::GsfElectronCollection::const_iterator iele = gsfElectronCollection.begin();
193  iele != gsfElectronCollection.end();
194  ++iele) {
195  //apply basic pre-selection cuts to remove the conversions with obviously displaced tracks which will anyways be
196  //removed from the analysis by the hit pattern or impact parameter requirements
197  if (iele->pt() < elePtMin_)
198  continue;
199  if (iele->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) >
200  eleExpectedHitsInnerMax_)
201  continue;
202  if (std::abs(iele->gsfTrack()->dxy(thevtx.position())) > eleD0Max_)
203  continue;
204 
205  //fill information for all electrons
206  h_elePtAll_->Fill(iele->pt());
207  h_eleEtaAll_->Fill(iele->eta());
208  h_elePhiAll_->Fill(iele->phi());
209 
210  //find matching conversion if any
211  reco::Conversion const* conv = ConversionTools::matchedConversion(*iele, *convHandle, thebs.position());
212  //fill information on passing electrons only if there is no matching conversion (electron passed the conversion rejection cut!)
213  if (conv == nullptr) {
214  h_elePtPass_->Fill(iele->pt());
215  h_eleEtaPass_->Fill(iele->eta());
216  h_elePhiPass_->Fill(iele->phi());
217  } else {
218  //matching conversion, electron failed conversion rejection cut
219  //fill information on electron and matching conversion
220  //(Note that in case of multiple matching conversions passing the requirements, the conversion tools returns the one closest to the IP,
221  //which is most likely to be the conversion of the primary photon in case there was one.)
222 
223  //fill electron info
224  h_elePtFail_->Fill(iele->pt());
225  h_eleEtaFail_->Fill(iele->eta());
226  h_elePhiFail_->Fill(iele->phi());
227 
228  //fill conversion info
229  math::XYZVectorF convmom = conv->refittedPairMomentum();
230  h_convPt_->Fill(convmom.rho());
231  h_convEta_->Fill(convmom.eta());
232  h_convPhi_->Fill(convmom.phi());
233  h_convRho_->Fill(conv->conversionVertex().position().rho());
234  h_convZ_->Fill(conv->conversionVertex().position().z());
235  h_convProb_->Fill(ChiSquaredProbability(conv->conversionVertex().chi2(), conv->conversionVertex().ndof()));
236 
237  //fill information about conversion tracks
238  if (conv->tracks().size() < 2)
239  continue;
240 
241  RefToBase<reco::Track> tk1 = conv->tracks().front();
242  RefToBase<reco::Track> tk2 = conv->tracks().back();
243 
244  RefToBase<reco::Track> tklead;
245  RefToBase<reco::Track> tktrail;
246  if (tk1->pt() >= tk2->pt()) {
247  tklead = tk1;
248  tktrail = tk2;
249  } else {
250  tklead = tk2;
251  tktrail = tk1;
252  }
253  h_convLeadTrackpt_->Fill(tklead->pt());
254  h_convTrailTrackpt_->Fill(tktrail->pt());
255  h_convLog10TrailTrackpt_->Fill(log10(tktrail->pt()));
256  h_convLeadTrackAlgo_->Fill(tklead->algo());
257  h_convTrailTrackAlgo_->Fill(tktrail->algo());
258  }
259  }
260 }
TrackExtra.h
reco::Conversion
Definition: Conversion.h:23
Handle.h
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
photonAnalyzer_cfi.zMax
zMax
Definition: photonAnalyzer_cfi.py:95
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ElectronConversionRejectionValidator::ElectronConversionRejectionValidator
ElectronConversionRejectionValidator(const edm::ParameterSet &)
Definition: ElectronConversionRejectionValidator.cc:48
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
ConversionTools.h
photonAnalyzer_cfi.zBin
zBin
Definition: photonAnalyzer_cfi.py:93
conv
static HepMC::IO_HEPEVT conv
Definition: BeamHaloProducer.cc:48
edm::Run
Definition: Run.h:45
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:75
ChiSquaredProbability
float ChiSquaredProbability(double chiSquared, double nrDOF)
Definition: ChiSquaredProbability.cc:13
electronConversionRejectionValidator.trackptBin
trackptBin
Definition: electronConversionRejectionValidator.py:24
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::LogInfo
Definition: MessageLogger.h:254
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
ChiSquaredProbability.h
PhotonFwd.h
reco::Vertex::position
const Point & position() const
position
Definition: Vertex.h:114
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
electronConversionRejectionValidator.trackptMax
trackptMax
Definition: electronConversionRejectionValidator.py:25
ElectronConversionRejectionValidator.h
ElectronConversionRejectionValidator::~ElectronConversionRejectionValidator
~ElectronConversionRejectionValidator() override
Definition: ElectronConversionRejectionValidator.cc:78
electronConversionRejectionValidator.trackptMin
trackptMin
Definition: electronConversionRejectionValidator.py:26
edm::Handle< reco::ConversionCollection >
muonRecoAnalyzer_cfi.ptBin
ptBin
Definition: muonRecoAnalyzer_cfi.py:45
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:608
MakerMacros.h
Photon.h
Track.h
TrackFwd.h
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
Service.h
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
reco::BeamSpot
Definition: BeamSpot.h:21
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
GsfElectron.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
ElectronConversionRejectionValidator::bookHistograms
void bookHistograms(DQMStore::IBooker &bei, edm::Run const &, edm::EventSetup const &) override
Definition: ElectronConversionRejectionValidator.cc:80
photonAnalyzer_cfi.zMin
zMin
Definition: photonAnalyzer_cfi.py:94
electronConversionRejectionValidator.rhoBin
rhoBin
Definition: electronConversionRejectionValidator.py:58
HLT_2018_cff.rhoMax
rhoMax
Definition: HLT_2018_cff.py:13607
edm::EventSetup
Definition: EventSetup.h:57
ElectronConversionRejectionValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ElectronConversionRejectionValidator.cc:147
reco::TrackBase::algo
TrackAlgorithm algo() const
Definition: TrackBase.h:532
std
Definition: JetResolutionObject.h:76
reco::TrackBase::algoSize
Definition: TrackBase.h:141
SuperCluster.h
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
ConversionTools::matchedConversion
static const reco::Conversion * matchedConversion(const reco::GsfElectron &ele, const reco::ConversionCollection &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
Definition: ConversionTools.cc:258
math::XYZVectorF
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
edm::RefToBase< reco::Track >
Exception.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
electronConversionRejectionValidator.rhoMin
rhoMin
Definition: electronConversionRejectionValidator.py:59
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
deltaPhi.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
electronConversionRejectionValidator.gsfElectronCollection
gsfElectronCollection
Definition: electronConversionRejectionValidator.py:12
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
Conversion.h