]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PYTHIA8/pythia8145/examples/main05.cc
New pythia8 version
[u/mrichter/AliRoot.git] / PYTHIA8 / pythia8145 / examples / main05.cc
1 // main05.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2010 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5
6 // This is a simple test program. 
7 // It studies jet production at the LHC, using CellJet.
8
9 #include "Pythia.h"
10 using namespace Pythia8;
11  
12 int main() {
13
14   // Number of events, generated and listed ones.
15   int nEvent    = 200;
16   int nList     = 0;
17   int nListJets = 5;
18
19   // Generator. Process selection. LHC initialization.
20   Pythia pythia;
21   pythia.readString("HardQCD:all = on");    
22   pythia.readString("PhaseSpace:pTHatMin = 200.");    
23   pythia.init( 2212, 2212, 14000.);
24
25   // Range and granularity of jet finder.
26   double etaMax     = 4.;
27   int    nEta       = 80;
28   int    nPhi       = 64;
29   // Exclude neutrinos (and other invisible) from study
30   int    nSel       = 2;
31   // Character and amount of energy smearing, cell by cell.
32   int    smear      = 2;
33   double resolution = 0.3;
34   double upperCut   = 2.;
35   double threshold  = 0.1;
36   Rndm*  rndmPtr    = &pythia.rndm;
37   // The  jet finder itself. 
38   CellJet cellJet( etaMax, nEta, nPhi, nSel, smear, resolution,
39     upperCut, threshold, rndmPtr);
40
41   // Histograms.
42   Hist nJets("number of jets", 20, -0.5, 19.5);
43   Hist eTjets("eT for jets", 100, 0., 500.);
44   Hist etaJets("eta for jets", 100, -5., 5.);
45   Hist phiJets("phi for jets", 100, -M_PI, M_PI);  
46   Hist distJets("R distance between jets", 100, 0., 10.);
47   Hist eTdiff("eT difference", 100, -100., 400.);
48
49   // Begin event loop. Generate event. Skip if error. list first few. 
50   for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
51     if (!pythia.next()) continue;
52
53     // List first few events.
54     if (iEvent < nList) {
55       pythia.info.list(); 
56       pythia.process.list();
57       pythia.event.list();
58     }
59
60     // Analyze jet properties. List first few. 
61     cellJet. analyze( pythia.event );
62     if (iEvent < nListJets) cellJet.list();
63
64     // Fill inclusive jet distributions.
65     nJets.fill( cellJet.size() );
66     for (int i = 0; i < cellJet.size(); ++i) {
67       eTjets.fill( cellJet.eT(i) );
68       etaJets.fill( cellJet.etaWeighted(i) );
69       phiJets.fill( cellJet.phiWeighted(i) );
70     }
71
72     // Fill distance between jets.
73     for (int i = 0; i < cellJet.size() - 1; ++i)
74     for (int j = i +1; j < cellJet.size(); ++j) {
75       double dEta = cellJet.etaWeighted(i) 
76         - cellJet.etaWeighted(j);
77       double dPhi = abs( cellJet.phiWeighted(i) 
78         - cellJet.phiWeighted(j) );
79       if (dPhi > M_PI) dPhi = 2. * M_PI - dPhi;
80       double dR = sqrt( pow2(dEta) + pow2(dPhi) );
81       distJets.fill( dR );
82     }
83
84     // Fill ET-difference between jets (to check ordering of list).
85     for (int i = 1; i < cellJet.size(); ++i) 
86       eTdiff.fill( cellJet.eT(i-1)- cellJet.eT(i) );
87
88   // End of event loop. Statistics. Histograms. 
89   }
90   pythia.statistics();
91   cout << nJets << eTjets << etaJets << phiJets 
92        << distJets << eTdiff;
93
94   // Done. 
95   return 0;
96 }