47 #include <CLHEP/Random/RandFlat.h>
48 #include <CLHEP/Random/RandGauss.h>
53 produces<std::vector<reco::PFCandidate> >();
60 pfToken_ = consumes<edm::View<reco::PFCandidate> >(
64 std::vector<double> defEtaEdges;
65 defEtaEdges.push_back(-999999.);
66 defEtaEdges.push_back(999999.);
67 etaBinEdges_ =
pset.getUntrackedParameter<std::vector<double> >(
"EtaBinEdges", defEtaEdges);
71 std::vector<double> defDistortion;
72 defDistortion.push_back(0.);
75 pset.getUntrackedParameter<std::vector<double> >(
"ShiftOnOneOverPt", defDistortion);
77 for (
unsigned int i = 1;
i < ninputs_expected;
i++) {
84 for (
unsigned int i = 1;
i < ninputs_expected;
i++) {
90 pset.getUntrackedParameter<std::vector<double> >(
"UncertaintyOnOneOverPt", defDistortion);
92 for (
unsigned int i = 1;
i < ninputs_expected;
i++) {
99 for (
unsigned int i = 1;
i < ninputs_expected;
i++) {
105 std::vector<double> defEfficiencyRatio;
106 defEfficiencyRatio.push_back(1.);
108 pset.getUntrackedParameter<std::vector<double> >(
"EfficiencyRatioOverMC", defEfficiencyRatio);
110 for (
unsigned int i = 1;
i < ninputs_expected;
i++) {
120 if (effWrong and momWrong) {
122 <<
"WARNING: DistortedPFCandProducer : Size of some parameters do not match the EtaBinEdges vector!!";
143 edm::LogError(
"") <<
">>> Muon collection does not exist !!!";
149 edm::LogError(
"") <<
">>> Muon-GenParticle match map does not exist !!!";
156 edm::LogError(
"") <<
">>> PFCandidate collection does not exist !!!";
161 unsigned int pfCollectionSize = pfCollection->size();
163 if (pfCollectionSize < 1)
167 bool pfMuonFound =
false;
172 for (
unsigned int j = 0;
j < pfCollectionSize;
j++) {
176 double ptmu =
pf->pt();
178 for (
unsigned int i = 0;
i < muonCollectionSize;
i++) {
185 if (muref.
key() ==
mu.key()) {
186 if (
mu->isStandAloneMuon() && ptmu == muref->standAloneMuon()->pt() &&
187 ((!
mu->isGlobalMuon() || (
mu->isGlobalMuon() && ptmu != muref->combinedMuon()->pt())) &&
188 (!
mu->isTrackerMuon() || (
mu->isTrackerMuon() && ptmu !=
mu->track()->pt())))) {
190 }
else if (!
mu->isTrackerMuon()) {
207 double ptgen =
pf->pt();
208 double etagen =
pf->eta();
214 LogTrace(
"") <<
">>> Muon-GenParticle match found; ptmu= " <<
pf->pt() <<
", ptgen= " << ptgen;
216 LogTrace(
"") <<
">>> MUON-GENPARTICLE MATCH NOT FOUND!!!";
220 double effRatio = 0.;
230 for (
unsigned int j = 1;
j <=
nbins; ++
j) {
238 LogTrace(
"") <<
">>> etaBin: " <<
etaBin <<
", for etagen =" << etagen;
241 LogTrace(
"") <<
">>> Muon outside eta range: reject it; etagen = " << etagen;
252 LogTrace(
"") <<
"\tshiftOnOneOverPt= " << shift1 * 100 <<
" [%]";
253 LogTrace(
"") <<
"\trelativeShiftOnPt= " << shift2 * 100 <<
" [%]";
258 LogTrace(
"") <<
"\tuncertaintyOnOneOverPt= " << sigma1 <<
" [1/GeV]";
259 LogTrace(
"") <<
"\trelativeUncertaintyOnPt= " << sigma2 * 100 <<
" [%]";
263 LogTrace(
"") <<
"\tefficiencyRatioOverMC= " << effRatio;
266 double rndf = CLHEP::RandFlat::shoot();
271 double rndg1 = CLHEP::RandGauss::shoot();
272 double rndg2 = CLHEP::RandGauss::shoot();
276 ptmu += ptgen * (shift1 * ptgen + shift2 + sigma1 * rndg1 * ptgen + sigma2 * rndg2);