本文整理汇总了C++中Jet::lorentzVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Jet::lorentzVector方法的具体用法?C++ Jet::lorentzVector怎么用?C++ Jet::lorentzVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jet
的用法示例。
在下文中一共展示了Jet::lorentzVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smearedJet
Jet smearedJet(const Jet & origJet, unsigned mode) {
if (origJet.getVarF("jn_genpt") <= 0)
return origJet;
//smearing factors are described in https://twiki.cern.ch/twiki/bin/view/CMS/JetResolution
double eta = fabs(origJet.lorentzVector().Eta());
double pt = origJet.lorentzVector().Pt();
double ptSF = 1.0;
double ptSF_err = 0.06;
if (eta < 0.5) {
ptSF = 1.052;
ptSF_err = sqrt(pow(0.012, 2) + pow(0.5 * (0.062 + 0.061), 2));
} else if (eta >= 0.5 && eta < 1.1) {
ptSF = 1.057;
ptSF_err = sqrt(pow(0.012, 2) + pow(0.5 * (0.056 + 0.055), 2));
} else if (eta >= 1.1 && eta < 1.7) {
ptSF = 1.096;
ptSF_err = sqrt(pow(0.017, 2) + pow(0.5 * (0.063 + 0.062), 2));
} else if (eta >= 1.7 && eta < 2.3) {
ptSF = 1.134;
ptSF_err = sqrt(pow(0.035, 2) + pow(0.5 * (0.087 + 0.085),2));
} else if (eta >= 2.3 && eta < 5.0) {
ptSF = 1.288;
ptSF_err = sqrt(pow(0.127, 2) + pow(0.5 * (0.155 + 0.153), 2));
}
if (mode == 1)
ptSF += ptSF_err;
else if (mode == 2)
ptSF -= ptSF_err;
ptSF = max(0., (origJet.getVarF("jn_genpt") + ptSF * (pt - origJet.getVarF("jn_genpt")))) / pt; //deterministic version
if (ptSF <= 0)
return origJet;
double px = origJet.getVarF("jn_px") * ptSF;
double py = origJet.getVarF("jn_py") * ptSF;
double pz = origJet.getVarF("jn_pz");
double mass = origJet.lorentzVector().M();
double en = sqrt(mass * mass + px * px + py * py + pz * pz);
Jet smearedJet(origJet);
smearedJet.addFloatVar( "jn_px", px );
smearedJet.addFloatVar( "jn_py", py );
smearedJet.addFloatVar( "jn_pz", pz );
smearedJet.addFloatVar( "jn_en", en );
return smearedJet;
}
示例2: string
vector<Jet> selectJetsCMG(const Event & ev, const vector<Lepton> & leptons, JetCorrectionUncertainty & jecUnc, TLorentzVector * diff, unsigned mode, double ptMin, double etaMax) {
#else
vector<Jet> selectJetsCMG(const Event & ev, const vector<Lepton> & leptons, TLorentzVector * diff, unsigned mode, double ptMin, double etaMax) {
#endif
const SingleVariableContainer<int> * jn = dynamic_cast<const SingleVariableContainer<int> *>(ev.findVariable("jn"));
const ArrayVariableContainer<float> * jn_px = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_px"));
const ArrayVariableContainer<float> * jn_py = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_py"));
const ArrayVariableContainer<float> * jn_pz = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_pz"));
const ArrayVariableContainer<float> * jn_en = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_en"));
const ArrayVariableContainer<float> * jn_jp = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_jp"));
const ArrayVariableContainer<float> * jn_genpx = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_genjpx"));
const ArrayVariableContainer<float> * jn_genpy = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_genjpy"));
const ArrayVariableContainer<float> * jn_genpz = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_genjpz"));
const ArrayVariableContainer<float> * jn_genen = dynamic_cast<const ArrayVariableContainer<float> *>(ev.findVariable("jn_genjen"));
const ArrayVariableContainer<int> * jn_idbits = dynamic_cast<const ArrayVariableContainer<int> *>(ev.findVariable("jn_idbits"));
if (mode == 1 || mode == 2) {
if (diff == 0)
throw string("ERROR - selectJetsCMG(): NULL pointer!");
diff->SetPxPyPzE(0, 0, 0, 0);
}
vector<Jet> jets;
for ( int i = 0; i < jn->getVal(); ++i ) {
TLorentzVector jet(jn_px->getVal(i), jn_py->getVal(i), jn_pz->getVal(i), jn_en->getVal(i));
bool matchesLepton = false;
for (unsigned k = 0; k < leptons.size(); ++k) {
TLorentzVector lepton = leptons[k].lorentzVector();
double delR = deltaR(lepton.Eta(), lepton.Phi(), jet.Eta(), jet.Phi());
if (delR < 0.15) {
matchesLepton = true;
break;
}
}
if (matchesLepton)
continue;
if (mode == 1 || mode == 2) {
#ifdef CMSSWENV
jecUnc.setJetEta(jet.Eta());
jecUnc.setJetPt(jet.Pt());
double sF = fabs(jecUnc.getUncertainty(true));
if ( sF > 0.3 ) {
cout << setw(10) << jet.Pt() << setw(10) << jet.Eta() << setw(10) << sF << endl;
throw string("ERROR!");
}
if (mode == 1)
sF = 1 + sF;
else
sF = 1 - sF;
TLorentzVector newJet = sF * jet;
(*diff) += (newJet - jet);
jet = newJet;
#else
throw string("ERROR: Jet Uncertainty Systematic variation not supported!");
#endif
}
Jet tmp;
tmp.addFloatVar( jn_px->getName(), jet.Px() );
tmp.addFloatVar( jn_py->getName(), jet.Py() );
tmp.addFloatVar( jn_pz->getName(), jet.Pz() );
tmp.addFloatVar( jn_en->getName(), jet.E() );
tmp.addIntVar( jn_idbits->getName(), jn_idbits->getVal(i) );
tmp.addFloatVar( jn_jp->getName(), jn_jp->getVal(i) );
TLorentzVector genJet( jn_genpx->getVal(i), jn_genpy->getVal(i), jn_genpz->getVal(i), jn_genen->getVal(i) );
tmp.addFloatVar( "jn_genpt", genJet.Pt() );
jets.push_back(tmp);
}
return jets;
}
TLorentzVector smearJets(vector<Jet> & jets, unsigned mode) {
TLorentzVector jetDiff;
for ( unsigned j = 0; j < jets.size(); ++j ) {
Jet smJet = smearedJet( jets[j], mode );
jetDiff += (smJet.lorentzVector() - jets[j].lorentzVector());
jets[j] = smJet;
}
return jetDiff;
}