当前位置: 首页>>代码示例>>C++>>正文


C++ Jet::addFloatVar方法代码示例

本文整理汇总了C++中Jet::addFloatVar方法的典型用法代码示例。如果您正苦于以下问题:C++ Jet::addFloatVar方法的具体用法?C++ Jet::addFloatVar怎么用?C++ Jet::addFloatVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jet的用法示例。


在下文中一共展示了Jet::addFloatVar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:qbaza,项目名称:CMSSW_MacroLibrary,代码行数:81,代码来源:preselectionCMG.cpp


注:本文中的Jet::addFloatVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。