CMS 3D CMS Logo

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