1 |
|
---|
2 | #include "modules/MadGraphClassFilter.h"
|
---|
3 |
|
---|
4 | #include "modules/MadGraphParticleClassifier.h"
|
---|
5 |
|
---|
6 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
7 | #include "ExRootAnalysis/ExRootClasses.h"
|
---|
8 |
|
---|
9 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
10 |
|
---|
11 | #include "TClonesArray.h"
|
---|
12 |
|
---|
13 | #include <map>
|
---|
14 | #include <set>
|
---|
15 | #include <deque>
|
---|
16 |
|
---|
17 | #include <iostream>
|
---|
18 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | //------------------------------------------------------------------------------
|
---|
22 |
|
---|
23 | MadGraphClassFilter::MadGraphClassFilter()
|
---|
24 | {
|
---|
25 | }
|
---|
26 |
|
---|
27 | //------------------------------------------------------------------------------
|
---|
28 |
|
---|
29 | MadGraphClassFilter::~MadGraphClassFilter()
|
---|
30 | {
|
---|
31 | }
|
---|
32 |
|
---|
33 | //------------------------------------------------------------------------------
|
---|
34 |
|
---|
35 | void MadGraphClassFilter::Init()
|
---|
36 | {
|
---|
37 | TString className;
|
---|
38 | ExRootConfParam param, classParticles;
|
---|
39 |
|
---|
40 | Bool_t extendable;
|
---|
41 | Int_t i, j, status, pid, sizeParam, sizeParticles;
|
---|
42 |
|
---|
43 | // import ROOT tree branch
|
---|
44 |
|
---|
45 | fBranchParticle = UseBranch("Particle");
|
---|
46 |
|
---|
47 | // create classifier and filter
|
---|
48 |
|
---|
49 | fClassifier = new MadGraphParticleClassifier();
|
---|
50 | fFilter = new ExRootFilter(fBranchParticle);
|
---|
51 |
|
---|
52 | // read particle status from configuration file and setup classifier
|
---|
53 |
|
---|
54 | param = GetParam("ParticleStatus");
|
---|
55 | sizeParam = param.GetSize();
|
---|
56 |
|
---|
57 | for(i = 0; i < sizeParam; ++i)
|
---|
58 | {
|
---|
59 | status = param[i].GetInt();
|
---|
60 | fClassifier->InsertParticleStatus(status);
|
---|
61 | }
|
---|
62 |
|
---|
63 | // read particle classes from configuration file and setup classifier
|
---|
64 |
|
---|
65 | param = GetParam("ClassParticles");
|
---|
66 | sizeParam = param.GetSize();
|
---|
67 |
|
---|
68 | for(i = 0; i < sizeParam/2; ++i)
|
---|
69 | {
|
---|
70 | className = param[i*2].GetString();
|
---|
71 | classParticles = param[i*2 + 1];
|
---|
72 | sizeParticles = classParticles.GetSize();
|
---|
73 |
|
---|
74 | for(j = 0; j < sizeParticles; ++j)
|
---|
75 | {
|
---|
76 | pid = classParticles[j].GetInt();
|
---|
77 | fClassifier->InsertClassPID(className, pid);
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | // allow classifier to create additional classes for particles with unknown PID
|
---|
82 |
|
---|
83 | extendable = GetBool("AllowExtendableClasses", kTRUE);
|
---|
84 |
|
---|
85 | fClassifier->SetExtendable(extendable);
|
---|
86 |
|
---|
87 | // create output arrays
|
---|
88 |
|
---|
89 | fOutputArray = ExportArray("particles");
|
---|
90 | }
|
---|
91 |
|
---|
92 | //------------------------------------------------------------------------------
|
---|
93 |
|
---|
94 | void MadGraphClassFilter::Finish()
|
---|
95 | {
|
---|
96 | if(fFilter) delete fFilter;
|
---|
97 | if(fClassifier) delete fClassifier;
|
---|
98 | }
|
---|
99 |
|
---|
100 | //------------------------------------------------------------------------------
|
---|
101 |
|
---|
102 | void MadGraphClassFilter::Process()
|
---|
103 | {
|
---|
104 | TObjArray *subarray;
|
---|
105 | Int_t category;
|
---|
106 |
|
---|
107 | fFilter->Reset();
|
---|
108 |
|
---|
109 | // make filter classify particles and fill all subarrays
|
---|
110 | // at this point classifier creates additional/missing classes
|
---|
111 | fFilter->GetSubArray(fClassifier, 0);
|
---|
112 |
|
---|
113 | // loop over all classes and export class names and classified particles
|
---|
114 | for(category = 0; category < fClassifier->GetMaxCategories(); ++category)
|
---|
115 | {
|
---|
116 | subarray = fFilter->GetSubArray(fClassifier, category);
|
---|
117 | if(subarray)
|
---|
118 | {
|
---|
119 | subarray->SetName(fClassifier->GetCategoryClassName(category));
|
---|
120 | fOutputArray->Add(subarray);
|
---|
121 |
|
---|
122 | // sort particles by PT
|
---|
123 | ExRootLHEFParticle::fgCompare = ExRootComparePT<ExRootLHEFParticle>::Instance();
|
---|
124 | subarray->Sort();
|
---|
125 | }
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | //------------------------------------------------------------------------------
|
---|
130 |
|
---|