10 #include "Pythia8/Pythia.h"
12 using namespace Pythia8;
15 #include "fastjet/PseudoJet.hh"
16 #include "fastjet/ClusterSequence.hh"
17 #include "fastjet/CDFMidPointPlugin.hh"
18 #include "fastjet/CDFJetCluPlugin.hh"
19 #include "fastjet/D0RunIIConePlugin.hh"
26 double pTfirstJet(
const Event& event,
int nJetMin,
double Rparam) {
28 double yPartonMax = 4.;
31 fastjet::Strategy strategy = fastjet::Best;
32 fastjet::RecombinationScheme recombScheme = fastjet::E_scheme;
33 fastjet::JetDefinition *jetDef = NULL;
35 if(event[3].colType() != 0 || event[4].colType() != 0)
36 jetDef =
new fastjet::JetDefinition(fastjet::kt_algorithm, Rparam,
37 recombScheme, strategy);
40 jetDef =
new fastjet::JetDefinition(fastjet::ee_kt_algorithm,
41 recombScheme, strategy);
43 std::vector <fastjet::PseudoJet> fjInputs;
48 for (
int i = 0; i <
event.size(); ++i) {
50 if ( !event[i].isFinal()
51 ||
event[i].isLepton()
52 ||
event[i].id() == 23
53 || abs(event[i].
id()) == 24
54 || abs(event[i].y()) > yPartonMax)
58 fjInputs.push_back( fastjet::PseudoJet (event[i].px(),
59 event[i].py(), event[i].pz(),event[i].e() ) );
63 if (
int(fjInputs.size()) == 0) {
69 fastjet::ClusterSequence clustSeq(fjInputs, *jetDef);
71 double pTFirst = sqrt(clustSeq.exclusive_dmerge_max(nJetMin-1));
95 virtual double tmsDefinition(
const Event& event);
99 virtual double dampenIfFailCuts(
const Event& inEvent );
102 double myKTdurham(
const Particle& RadAfterBranch,
103 const Particle& EmtAfterBranch,
int Type,
double D );
110 MyMergingHooks::MyMergingHooks() {}
113 MyMergingHooks::~MyMergingHooks() {}
117 double MyMergingHooks::dampenIfFailCuts(
const Event& inEvent ){
121 for(
int i=0; i < inEvent.size(); ++i)
122 if(inEvent[i].isFinal() && inEvent[i].colType() != 0) {
123 pT = sqrt(pow(inEvent[i].px(),2) + pow(inEvent[i].py(),2));
128 if(pT < 10.)
return 0.;
138 double MyMergingHooks::tmsDefinition(
const Event& event){
142 int nFinalColoured = 0;
144 for(
int i=0; i <
event.size(); ++i) {
145 if(event[i].isFinal()){
146 if(event[i].
id() != 23 && abs(event[i].
id()) != 24)
148 if( event[i].colType() != 0)
154 int nLeptons = nHardOutLeptons();
155 int nQuarks = nHardOutPartons();
156 int nResNow = nResInCurrent();
159 if(nFinalNow - ( (nLeptons+nQuarks)/2 - nResNow)*2 != nFinalColoured){
163 if(nFinalNow != nFinalColoured)
return 0.;
167 int nMPI = infoPtr->nMPI();
168 if(nMPI > 1)
return 0.;
174 vector <int> FinalPartPos;
175 FinalPartPos.clear();
177 for (
int i=0; i <
event.size(); ++i)
178 if(event[i].isFinal() &&
event[i].colType() != 0)
179 FinalPartPos.push_back(i);
183 int type = (
event[3].colType() == 0 &&
event[4].colType() == 0) ? 1 : kTtype;
185 double ktmin =
event[0].e();
186 for(
int i=0; i < int(FinalPartPos.size()); ++i){
189 if(type == -1 || type == -2) {
190 double temp =
event[FinalPartPos[i]].pT();
191 kt12 = min(kt12, temp);
194 for(
int j=i+1; j < int(FinalPartPos.size()); ++j) {
195 double temp = kTdurham( event[FinalPartPos[i]], event[FinalPartPos[j]],
197 kt12 = min(kt12, temp);
200 ktmin = min(ktmin,kt12);
212 double MyMergingHooks::myKTdurham(
const Particle& RadAfterBranch,
213 const Particle& EmtAfterBranch,
int Type,
double D ){
218 Vec4 jet1 = RadAfterBranch.p();
219 Vec4 jet2 = EmtAfterBranch.p();
225 if (jet1.pAbs()*jet2.pAbs() <=0.) costh = 1.;
227 costh = costheta(jet1,jet2);
230 ktdur = 2.0*min( pow(jet1.e(),2) , (pow(jet2.e(),2)) )*(1.0 - costh);
231 }
else if( Type == -1 ){
233 double eta1 = 0.5*log( (jet1.e() + jet1.pz()) / (jet1.e() - jet1.pz()) );
234 double eta2 = 0.5*log( (jet2.e() + jet2.pz()) / (jet2.e() - jet2.pz()) );
236 double pt1 = sqrt( pow(jet1.px(),2) + pow(jet1.py(),2) );
237 double pt2 = sqrt( pow(jet2.px(),2) + pow(jet2.py(),2) );
238 double cosdPhi = ( jet1.px()*jet2.px() + jet1.py()*jet2.py() ) / (pt1*pt2);
239 double dPhi = acos( cosdPhi );
241 ktdur = min( pow(pt1,2),pow(pt2,2) )
242 * ( pow(eta1-eta2,2) + pow(dPhi,2) ) / pow(D,2);
243 }
else if( Type == -2 ){
245 double eta1 = 0.5*log( (jet1.e() + jet1.pz()) / (jet1.e() - jet1.pz()) );
246 double eta2 = 0.5*log( (jet2.e() + jet2.pz()) / (jet2.e() - jet2.pz()) );
247 double coshdEta = cosh( eta1 - eta2 );
249 double pt1 = sqrt( pow(jet1.px(),2) + pow(jet1.py(),2) );
250 double pt2 = sqrt( pow(jet2.px(),2) + pow(jet2.py(),2) );
251 double cosdPhi = ( jet1.px()*jet2.px() + jet1.py()*jet2.py() ) / (pt1*pt2);
253 ktdur = 2.0*min( pow(pt1,2),pow(pt2,2) )
254 * ( coshdEta - cosdPhi ) / pow(D,2);
266 int main(
int argc,
char* argv[] ){
270 cerr <<
" Unexpected number of command-line arguments. \n You are"
271 <<
" expected to provide the arguments \n"
272 <<
" 1. Input file for settings \n"
273 <<
" 2. Full name of the input LHE file (with path) \n"
274 <<
" 3. Path for output histogram files \n"
275 <<
" Program stopped. " << endl;
285 pythia.readFile(argv[1]);
286 string iPath = string(argv[2]);
287 string oPath = string(argv[3]);
290 int nEvent = pythia.mode(
"Main:numberOfEvents");
294 pythia.setMergingHooksPtr( myMergingHooks );
297 pythia.settings.forceParm(
"SpaceShower:pT0Ref",0.);
300 Hist histPTFirst(
"pT of first jet",100,0.,100.);
301 Hist histPTSecond(
"pT of second jet",100,0.,100.);
304 pythia.init(iPath,
false);
306 if(pythia.flag(
"Main:showChangedSettings")) {
307 pythia.settings.listChanged();
311 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
314 if( ! pythia.next())
continue;
317 double weight = pythia.info.mergingWeight();
320 double pTfirst = pTfirstJet(pythia.event,1, 0.4);
321 double pTsecnd = pTfirstJet(pythia.event,2, 0.4);
322 histPTFirst.fill( pTfirst, weight);
323 histPTSecond.fill( pTsecnd, weight);
325 if(iEvent%1000 == 0) cout << iEvent << endl;
334 * pythia.info.sigmaGen()
335 * 1./ double(nEvent);
338 histPTSecond *= norm;
341 string jetsInLHEF = iPath.substr(iPath.size()-5, iPath.size());
342 jetsInLHEF = jetsInLHEF.substr(0, jetsInLHEF.size()-4);
351 suffix << jetsInLHEF <<
"_wv.dat";
354 write.open( (
char*)(oPath +
"PTjet1_" + suffix.str()).c_str());
355 histPTFirst.table(write);
358 write.open( (
char*)(oPath +
"PTjet2_" + suffix.str()).c_str());
359 histPTSecond.table(write);
363 delete myMergingHooks;