source: trunk/modules/MadGraphKtJetFinder.cc@ 5

Last change on this file since 5 was 2, checked in by Pavel Demin, 17 years ago

first commit

File size: 3.6 KB
Line 
1
2#include "modules/MadGraphKtJetFinder.h"
3
4#include "ExRootAnalysis/ExRootClasses.h"
5#include "ExRootAnalysis/ExRootFactory.h"
6#include "ExRootAnalysis/ExRootCandidate.h"
7
8#include "KtJet/KtEvent.h"
9#include "KtJet/KtLorentzVector.h"
10
11#include "TString.h"
12#include "TLorentzVector.h"
13
14#include <iostream>
15#include <vector>
16
17using namespace std;
18using namespace KtJet;
19
20//------------------------------------------------------------------------------
21
22MadGraphKtJetFinder::MadGraphKtJetFinder() :
23 fItInputArray(0)
24{
25
26}
27
28//------------------------------------------------------------------------------
29
30MadGraphKtJetFinder::~MadGraphKtJetFinder()
31{
32
33}
34
35//------------------------------------------------------------------------------
36
37void MadGraphKtJetFinder::Init()
38{
39
40 // define KtJet algorithm
41
42 fCollisionType = GetInt("CollisionType", 4); // PP
43 fDistanceScheme = GetInt("DistanceScheme", 1); // Angular
44 fRecombinationScheme = GetInt("RecombinationScheme", 1); // E
45 fParameterR = GetDouble("ParameterR", 1.0);
46
47 fIsExclusive = GetBool("Exclusive", false);
48 fECut = GetDouble("ECut", -1.0);
49 fDCut = GetDouble("DCut", 900.0);
50
51 fParticleNumberMin = GetInt("ParticleNumberMin", 1);
52
53 // import array with output from filter/classifier module
54
55 fInputArray = ImportArray(GetString("InputArray", "selection/candidates"));
56 fItInputArray = fInputArray->MakeIterator();
57
58 // create output arrays
59
60 fOutputArrayCandidates = ExportArray("candidates");
61 fOutputArrayMatching = ExportArray("matching");
62
63}
64
65//------------------------------------------------------------------------------
66
67void MadGraphKtJetFinder::Finish()
68{
69 if(fItInputArray) delete fItInputArray;
70}
71
72//------------------------------------------------------------------------------
73
74void MadGraphKtJetFinder::Process()
75{
76 ExRootCandidate *candidate;
77 ExRootMatching* matching;
78 TLorentzVector momentum;
79 KtEvent *event = 0;
80 Int_t entry;
81
82 if(fInputArray->GetEntriesFast() < fParticleNumberMin) return;
83
84 ExRootFactory *factory = GetFactory();
85
86 fTowersList.clear();
87
88 // loop over all particles in event and select stable ones
89 fItInputArray->Reset();
90 while((candidate = static_cast<ExRootCandidate*>(fItInputArray->Next())))
91 {
92 momentum = candidate->GetP4();
93 fTowersList.push_back(KtLorentzVector(momentum.Px(), momentum.Py(),
94 momentum.Pz(), momentum.E()));
95 }
96
97 // construct jets from a list of stable particles
98 if(fIsExclusive)
99 {
100 event = new KtEvent(fTowersList, fCollisionType, fDistanceScheme,
101 fRecombinationScheme);
102
103 if(fECut > 0.0) event->setECut(fECut);
104 event->findJetsY(fDCut);
105 }
106 else
107 {
108 event = new KtEvent(fTowersList, fCollisionType, fDistanceScheme,
109 fRecombinationScheme, fParameterR);
110
111 }
112
113 fJetsList.clear();
114 fJetsList = event->getJetsPt();
115
116 // loop over all jets and export them
117 vector<KtLorentzVector>::iterator itJet;
118 for(itJet = fJetsList.begin(), entry = 1; itJet != fJetsList.end(); ++itJet, ++entry)
119 {
120 momentum.SetPxPyPzE(itJet->px(), itJet->py(), itJet->pz(), itJet->e());
121
122 candidate = factory->NewCandidate();
123
124 candidate->SetP4(momentum);
125 candidate->SetName(Form("jet_{%d}", entry ));
126
127 fOutputArrayCandidates->Add(candidate);
128 }
129
130 for(entry = 0; entry < fTowersList.size(); ++entry)
131 {
132 matching = factory->New<ExRootMatching>();
133
134 matching->DMerge = event->getDMerge(entry);
135 matching->YMerge = event->getYMerge(entry);
136
137 fOutputArrayMatching->Add(matching);
138 }
139
140 if(event) delete event;
141}
Note: See TracBrowser for help on using the repository browser.