49 produces<pat::MHTCollection>();
56 while (!physobjvector_.empty()) {
57 physobjvector_.erase(physobjvector_.begin(), physobjvector_.end());
61 s_clusteredTowers.clear();
63 double number_of_jets = getJets(
iEvent, iSetup);
65 double number_of_electrons = getElectrons(
iEvent, iSetup);
67 double number_of_muons = getMuons(
iEvent, iSetup);
70 std::cout <<
">>>---> Number of jets: " << number_of_jets << std::endl;
71 std::cout <<
">>>---> Number of electrons: " << number_of_jets << std::endl;
72 std::cout <<
">>>---> Number of muons: " << number_of_muons << std::endl;
81 auto themetsigcoll = std::make_unique<pat::MHTCollection>();
83 if (!physobjvector_.empty()) {
91 met_x = met_et *
cos(met_phi);
92 met_y = met_et *
sin(met_phi);
105 themetsigcoll->push_back(themetsigobj);
118 double number_of_jets_ = 0.0;
121 iEvent.getByToken(jetToken_, jetHandle);
126 if ((jet_iter->pt() < jetPtMin_) || (
TMath::Abs(jet_iter->eta()) > jetEtaMax_) ||
127 (jet_iter->emEnergyFraction() > jetEMfracMax_))
130 double jet_et = jet_iter->et();
131 double jet_phi = jet_iter->phi();
133 if (verbose_ == 3.) {
134 std::cout <<
"jet pt : " << jet_iter->pt() <<
" eta : " << jet_iter->eta()
135 <<
" EMF: " << jet_iter->emEnergyFraction() << std::endl;
138 double sigma_et, sigma_phi;
140 if (controlledUncertainty_) {
141 sigma_et = jetUncertainty.etUncertainty->Eval(jet_et);
142 sigma_phi = jetUncertainty.phiUncertainty->Eval(jet_et);
148 if (verbose_ == 3.) {
149 std::cout <<
"jet sigma_et : " << sigma_et <<
", jet sigma_phi : " << sigma_phi << std::endl;
152 if (sigma_et <= 0 || sigma_phi <= 0)
153 edm::LogWarning(
"PATMHTProducer") <<
" uncertainties for " << objectname <<
" are (et, phi): " << sigma_et <<
","
154 << sigma_phi <<
" (et,phi): " << jet_et <<
"," << jet_phi;
158 if (uncertaintyScaleFactor_ != 1.0) {
159 sigma_et = sigma_et * uncertaintyScaleFactor_;
160 sigma_phi = sigma_phi * uncertaintyScaleFactor_;
165 if (verbose_ == 101.) {
167 std::cout <<
"v101> " << number_of_jets_ <<
" " << jet_et <<
" " << sigma_et <<
" " << jet_phi <<
" "
168 << sigma_phi << std::endl;
172 physobjvector_.push_back(tmp_jet);
176 std::vector<CaloTowerPtr> v_towers = jet_iter->getCaloConstituents();
179 for (
unsigned int ii = 0;
ii < v_towers.size();
ii++) {
180 s_clusteredTowers.insert((*v_towers.at(
ii)).
id());
185 if (verbose_ == 101.) {
186 std::cout <<
"v101> --------------------------------------------" << std::endl;
189 return number_of_jets_;
198 double number_of_electrons_ = 0.0;
205 iEvent.getByToken(eleToken_, electronHandle);
212 if (electron_iter->et() < elePtMin_ ||
TMath::Abs(electron_iter->eta()) > eleEtaMax_)
215 if (verbose_ == 3.) {
216 std::cout <<
"electron pt = " << electron_iter->pt() <<
" eta : " << electron_iter->eta() << std::endl;
219 double electron_et = electron_iter->et();
220 double electron_phi = electron_iter->phi();
222 double sigma_et, sigma_phi;
224 if (controlledUncertainty_) {
225 sigma_et = eleUncertainty.etUncertainty->Eval(electron_et);
226 sigma_phi = eleUncertainty.phiUncertainty->Eval(electron_et);
232 if (verbose_ == 3.) {
233 std::cout <<
"electron sigma_et : " << sigma_et <<
", electron sigma_phi : " << sigma_phi << std::endl;
236 if (sigma_et < 0 || sigma_phi < 0)
237 edm::LogWarning(
"PATMHTProducer") <<
" uncertainties for " << objectname <<
" are (et, phi): " << sigma_et <<
","
238 << sigma_phi <<
" (et,phi): " << electron_et <<
"," << electron_phi;
240 if (uncertaintyScaleFactor_ != 1.0) {
241 sigma_et = sigma_et * uncertaintyScaleFactor_;
242 sigma_phi = sigma_phi * uncertaintyScaleFactor_;
245 metsig::SigInputObj tmp_electron(objectname, electron_et, electron_phi, sigma_et, sigma_phi);
246 physobjvector_.push_back(tmp_electron);
247 number_of_electrons_++;
272 return number_of_electrons_;
282 iEvent.getByToken(muoToken_, muonHandle);
286 std::cout <<
">>> PATMHTSelector not valid muon Handle!" << std::endl;
290 double number_of_muons_ = 0.0;
293 if (muon_iter->pt() < muonPtMin_ ||
TMath::Abs(muon_iter->eta()) > muonEtaMax_)
296 if (verbose_ == 3.) {
297 std::cout <<
"muon pt = " << muon_iter->pt() <<
" eta : " << muon_iter->eta() << std::endl;
300 double muon_pt = muon_iter->pt();
301 double muon_phi = muon_iter->phi();
303 double sigma_et, sigma_phi;
305 if (controlledUncertainty_) {
306 sigma_et = muonUncertainty.etUncertainty->Eval(muon_pt);
307 sigma_phi = muonUncertainty.phiUncertainty->Eval(muon_pt);
313 if (verbose_ == 3.) {
314 std::cout <<
"muon sigma_et : " << sigma_et <<
", muon sigma_phi : " << sigma_phi << std::endl;
317 if (sigma_et < 0 || sigma_phi < 0)
318 edm::LogWarning(
"PATMHTProducer") <<
" uncertainties for " << objectname <<
" are (et, phi): " << sigma_et <<
","
319 << sigma_phi <<
" (pt,phi): " << muon_pt <<
"," << muon_phi;
321 if (uncertaintyScaleFactor_ != 1.0) {
322 sigma_et = sigma_et * uncertaintyScaleFactor_;
323 sigma_phi = sigma_phi * uncertaintyScaleFactor_;
327 physobjvector_.push_back(tmp_muon);
332 return number_of_muons_;
343 ecalEBUncertainty.etUncertainty.reset(
new TF1(
"ecalEBEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
344 ecalEBUncertainty.etUncertainty->SetParameter(0, 0.2);
345 ecalEBUncertainty.etUncertainty->SetParameter(1, 0.03);
346 ecalEBUncertainty.etUncertainty->SetParameter(2, 0.005);
348 ecalEBUncertainty.phiUncertainty.reset(
new TF1(
"ecalEBphiFunc",
"[0]*x", 1));
349 ecalEBUncertainty.phiUncertainty->SetParameter(0, 0.0174);
352 ecalEEUncertainty.etUncertainty.reset(
new TF1(
"ecalEEEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
353 ecalEEUncertainty.etUncertainty->SetParameter(0, 0.2);
354 ecalEEUncertainty.etUncertainty->SetParameter(1, 0.03);
355 ecalEEUncertainty.etUncertainty->SetParameter(2, 0.005);
357 ecalEEUncertainty.phiUncertainty.reset(
new TF1(
"ecalEEphiFunc",
"[0]*x", 1));
358 ecalEEUncertainty.phiUncertainty->SetParameter(0, 0.087);
363 hcalHBUncertainty.etUncertainty.reset(
new TF1(
"hcalHBEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
364 hcalHBUncertainty.etUncertainty->SetParameter(0, 0.);
365 hcalHBUncertainty.etUncertainty->SetParameter(1, 1.22);
366 hcalHBUncertainty.etUncertainty->SetParameter(2, 0.05);
368 hcalHBUncertainty.phiUncertainty.reset(
new TF1(
"ecalHBphiFunc",
"[0]*x", 1));
369 hcalHBUncertainty.phiUncertainty->SetParameter(0, 0.087);
372 hcalHEUncertainty.etUncertainty.reset(
new TF1(
"hcalHEEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
373 hcalHEUncertainty.etUncertainty->SetParameter(0, 0.);
374 hcalHEUncertainty.etUncertainty->SetParameter(1, 1.3);
375 hcalHEUncertainty.etUncertainty->SetParameter(2, 0.05);
377 hcalHEUncertainty.phiUncertainty.reset(
new TF1(
"ecalHEphiFunc",
"[0]*x", 1));
378 hcalHEUncertainty.phiUncertainty->SetParameter(0, 0.087);
381 hcalHOUncertainty.etUncertainty.reset(
new TF1(
"hcalHOEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
382 hcalHOUncertainty.etUncertainty->SetParameter(0, 0.);
383 hcalHOUncertainty.etUncertainty->SetParameter(1, 1.82);
384 hcalHOUncertainty.etUncertainty->SetParameter(2, 0.09);
386 hcalHOUncertainty.phiUncertainty.reset(
new TF1(
"ecalHOphiFunc",
"[0]*x", 1));
387 hcalHOUncertainty.phiUncertainty->SetParameter(0, 0.087);
390 hcalHFUncertainty.etUncertainty.reset(
new TF1(
"hcalHFEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
391 hcalHFUncertainty.etUncertainty->SetParameter(0, 0.);
392 hcalHFUncertainty.etUncertainty->SetParameter(1, 1.82);
393 hcalHFUncertainty.etUncertainty->SetParameter(2, 0.09);
395 hcalHFUncertainty.phiUncertainty.reset(
new TF1(
"ecalHFphiFunc",
"[0]*x", 1));
396 hcalHFUncertainty.phiUncertainty->SetParameter(0, 0.174);
399 jetUncertainty.etUncertainty.reset(
new TF1(
"jetEtFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
401 jetUncertainty.etUncertainty->SetParameter(0, jetEtUncertaintyParameter0_);
402 jetUncertainty.etUncertainty->SetParameter(1, jetEtUncertaintyParameter1_);
403 jetUncertainty.etUncertainty->SetParameter(2, jetEtUncertaintyParameter2_);
411 jetUncertainty.phiUncertainty.reset(
new TF1(
"jetPhiFunc",
"x*sqrt(([0]*[0]/(x*x))+([1]*[1]/x)+([2]*[2]))", 3));
412 jetUncertainty.phiUncertainty->SetParameter(0, jetPhiUncertaintyParameter0_);
413 jetUncertainty.phiUncertainty->SetParameter(1, jetPhiUncertaintyParameter1_);
414 jetUncertainty.phiUncertainty->SetParameter(2, jetPhiUncertaintyParameter2_);
428 eleUncertainty.etUncertainty.reset(
new TF1(
"eleEtFunc",
"[0] * x", 1));
430 eleUncertainty.etUncertainty->SetParameter(0, eleEtUncertaintyParameter0_);
432 eleUncertainty.phiUncertainty.reset(
new TF1(
"elePhiFunc",
"[0] * x", 1));
434 eleUncertainty.phiUncertainty->SetParameter(0, elePhiUncertaintyParameter0_);
439 muonUncertainty.etUncertainty.reset(
new TF1(
"muonEtFunc",
"[0] * x", 1));
441 muonUncertainty.etUncertainty->SetParameter(0, muonEtUncertaintyParameter0_);
442 muonUncertainty.phiUncertainty.reset(
new TF1(
"muonPhiFunc",
"[0] * x", 1));
444 muonUncertainty.phiUncertainty->SetParameter(0, muonPhiUncertaintyParameter0_);