source: trunk/modules/MadGraphClassMerger.cc@ 5

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

first commit

File size: 2.0 KB
Line 
1
2#include "modules/MadGraphClassMerger.h"
3
4#include "ExRootAnalysis/ExRootClasses.h"
5#include "ExRootAnalysis/ExRootFactory.h"
6#include "ExRootAnalysis/ExRootCandidate.h"
7
8#include "TString.h"
9#include "TLorentzVector.h"
10
11#include <iostream>
12
13using namespace std;
14
15//------------------------------------------------------------------------------
16
17MadGraphClassMerger::MadGraphClassMerger() :
18 fItInputArray(0)
19{
20}
21
22//------------------------------------------------------------------------------
23
24MadGraphClassMerger::~MadGraphClassMerger()
25{
26}
27
28//------------------------------------------------------------------------------
29
30void MadGraphClassMerger::Init()
31{
32 // import array with output from filter/classifier module
33
34 fInputArray = ImportArray(GetString("InputArray", "selection/candidates"));
35 fItInputArray = fInputArray->MakeIterator();
36
37 // create output array
38
39 fOutputArray = ExportArray("candidates");
40}
41
42//------------------------------------------------------------------------------
43
44void MadGraphClassMerger::Finish()
45{
46 if(fItInputArray) delete fItInputArray;
47}
48
49//------------------------------------------------------------------------------
50
51void MadGraphClassMerger::Process()
52{
53 TObjArray *array = 0;
54 ExRootLHEFParticle *particle = 0;
55 ExRootCandidate *candidate = 0;
56 ExRootFactory *factory = GetFactory();
57
58 Int_t entry;
59 TString name;
60 TLorentzVector momentum;
61
62 fItInputArray->Reset();
63 while(array = static_cast<TObjArray*>(fItInputArray->Next()))
64 {
65 TIter itArray(array);
66 name = array->GetName();
67 entry = 1;
68
69 while(particle = static_cast<ExRootLHEFParticle*>(itArray.Next()))
70 {
71 momentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
72
73 candidate = factory->NewCandidate();
74
75 candidate->SetP4(momentum);
76 candidate->SetName(Form("%s_{%d}", name.Data(), entry ));
77 if(particle->Status != 1) candidate->SetResonance(kTRUE);
78
79 fOutputArray->Add(candidate);
80 ++entry;
81 }
82 }
83}
84
Note: See TracBrowser for help on using the repository browser.