8 #include <boost/bind.hpp>
10 #include "Math/GenVector/Cartesian3D.h"
11 #include "Math/GenVector/VectorUtil.h"
13 #include "HepMC/GenEvent.h"
14 #include "HepMC/SimpleVector.h"
30 template<
typename T1,
typename T2,
typename R>
31 struct DeltaRSeparation :
public std::binary_function<T1, T2, R> {
32 double operator () (
const T1 &v1_,
const T2 &v2_)
const
34 using namespace ROOT::Math;
35 Cartesian3D<R> v1(v1_.px(), v1_.py(), v1_.pz());
36 Cartesian3D<R> v2(v2_.px(), v2_.py(), v2_.pz());
37 return VectorUtil::DeltaR(v1, v2);
42 template<
typename T2,
typename R>
47 using namespace ROOT::Math;
48 Cartesian3D<R> v1(v1_->momentum().px(),
50 v1_->momentum().pz());
51 Cartesian3D<R> v2(v2_.px(), v2_.py(), v2_.pz());
52 return VectorUtil::DeltaR(v1, v2);
56 struct ParticlePtGreater {
59 {
return v1->momentum().perp() > v2->momentum().perp(); }
62 inline HepMC::FourVector
convert(
const JetClustering::Jet &
jet)
63 {
return HepMC::FourVector(jet.px(), jet.py(), jet.pz(), jet.e()); }
68 maxDeltaR(params.getParameter<double>(
"maxDeltaR")),
69 minJetPt(params.getParameter<double>(
"jetPtMin")),
70 maxEta(params.getParameter<double>(
"maxEta")),
71 matchPtFraction(0.75),
72 useEt(params.getParameter<bool>(
"useEt")),
79 if (params.
exists(
"matchPtFraction"))
87 if (matchMode ==
"inclusive")
89 else if (matchMode ==
"exclusive")
93 <<
"Invalid matching mode '" << matchMode
94 <<
"' specified." << std::endl;
104 result.insert(
"matchSummary");
112 const HepMC::GenEvent *finalState,
113 bool showeredFinalState)
116 std::sort(partons.begin(), partons.end(), ParticlePtGreater());
119 showeredFinalState ? (*partonInput)(finalState)
120 : (*this->jetInput)(finalState);
121 std::sort(jetInput.begin(), jetInput.end(), ParticlePtGreater());
123 std::vector<JetClustering::Jet>
jets = (*jetClustering)(
jetInput);
126 std::cout <<
"===== Partons:" << std::endl;
127 for(JetClustering::ParticleVector::const_iterator
c = partons.begin();
128 c != partons.end();
c++)
129 std::cout <<
"\tpid = " << (*c)->pdg_id()
130 <<
", pt = " << (*c)->momentum().perp()
131 <<
", eta = " << (*c)->momentum().eta()
132 <<
", phi = " << (*c)->momentum().phi()
134 std::cout <<
"===== JetInput:" << std::endl;
135 for(JetClustering::ParticleVector::const_iterator
c = jetInput.begin();
136 c != jetInput.end();
c++)
137 std::cout <<
"\tpid = " << (*c)->pdg_id()
138 <<
", pt = " << (*c)->momentum().perp()
139 <<
", eta = " << (*c)->momentum().eta()
140 <<
", phi = " << (*c)->momentum().phi()
142 std::cout <<
"----- " << jets.size() <<
" jets:" << std::endl;
143 for(std::vector<JetClustering::Jet>::const_iterator
iter = jets.begin();
146 <<
", eta = " <<
iter->eta()
147 <<
", phi = " <<
iter->phi()
149 for(JetClustering::ParticleVector::const_iterator
c =
iter->constituents().begin();
150 c !=
iter->constituents().end();
c++)
151 std::cout <<
"\tpid = " << (*c)->pdg_id()
152 <<
", pt = " << (*c)->momentum().perp()
153 <<
", eta = " << (*c)->momentum().eta()
154 <<
", phi = " << (*c)->momentum().phi()
159 std::cout << partons.size() <<
" partons and "
160 << std::count_if(jets.begin(), jets.end(),
161 bind(std::greater<double>(),
163 minJetPt)) <<
" jets." << std::endl;
171 std::vector<Match> matches =
174 std::bind2nd(std::less<double>(),
maxDeltaR));
177 for(std::vector<Match>::const_iterator
iter = matches.begin();
180 <<
iter->index2 <<
" with a Delta_R of "
181 << matching.delta(*
iter) << std::endl;
184 unsigned int unmatchedPartons = 0;
185 unsigned int unmatchedJets = 0;
188 for(std::vector<Match>::const_iterator
iter = matches.begin();
197 matching.delta(*
iter),
198 partons[
iter->index1]->pdg_id()));
202 if (!matching.isMatched1st(
i)) {
206 partons[
i]->pdg_id()));
211 if (!matching.isMatched2nd(
i)) {
223 if (!unmatchedJets && !unmatchedPartons)
227 if (!unmatchedPartons)
T getParameter(std::string const &) const
std::set< std::string > capabilities() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::auto_ptr< JetInput > partonInput
virtual std::set< std::string > capabilities() const
double match(const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState)
std::auto_ptr< JetInput > jetInput
std::auto_ptr< JetClustering > jetClustering
Abs< T >::type abs(const T &t)
Container::value_type value_type
SimpleMatrix< Delta >::size_type index_type
std::vector< JetPartonMatch > matchSummary
JetMatchingMLM(const edm::ParameterSet ¶ms)