1 | |
---|
2 | /** \class UniqueObjectFinder |
---|
3 | * |
---|
4 | * Finds uniquely identified photons, electrons, taus and jets. |
---|
5 | * |
---|
6 | * $Date: 2012-11-19 02:29:59 +0100 (Mon, 19 Nov 2012) $ |
---|
7 | * $Revision: 825 $ |
---|
8 | * |
---|
9 | * |
---|
10 | * \author P. Demin - UCL, Louvain-la-Neuve |
---|
11 | * |
---|
12 | */ |
---|
13 | |
---|
14 | #include "modules/UniqueObjectFinder.h" |
---|
15 | |
---|
16 | #include "classes/DelphesClasses.h" |
---|
17 | #include "classes/DelphesFactory.h" |
---|
18 | #include "classes/DelphesFormula.h" |
---|
19 | |
---|
20 | #include "ExRootAnalysis/ExRootResult.h" |
---|
21 | #include "ExRootAnalysis/ExRootFilter.h" |
---|
22 | #include "ExRootAnalysis/ExRootClassifier.h" |
---|
23 | |
---|
24 | #include "TMath.h" |
---|
25 | #include "TString.h" |
---|
26 | #include "TFormula.h" |
---|
27 | #include "TRandom3.h" |
---|
28 | #include "TObjArray.h" |
---|
29 | #include "TDatabasePDG.h" |
---|
30 | #include "TLorentzVector.h" |
---|
31 | |
---|
32 | #include <algorithm> |
---|
33 | #include <stdexcept> |
---|
34 | #include <iostream> |
---|
35 | #include <sstream> |
---|
36 | |
---|
37 | using namespace std; |
---|
38 | |
---|
39 | //------------------------------------------------------------------------------ |
---|
40 | |
---|
41 | UniqueObjectFinder::UniqueObjectFinder() |
---|
42 | { |
---|
43 | } |
---|
44 | |
---|
45 | //------------------------------------------------------------------------------ |
---|
46 | |
---|
47 | UniqueObjectFinder::~UniqueObjectFinder() |
---|
48 | { |
---|
49 | } |
---|
50 | |
---|
51 | //------------------------------------------------------------------------------ |
---|
52 | |
---|
53 | void UniqueObjectFinder::Init() |
---|
54 | { |
---|
55 | // import arrays with output from other modules |
---|
56 | |
---|
57 | ExRootConfParam param = GetParam("InputArray"); |
---|
58 | Long_t i, size; |
---|
59 | const TObjArray *array; |
---|
60 | TIterator *iterator; |
---|
61 | |
---|
62 | size = param.GetSize(); |
---|
63 | for(i = 0; i < size/2; ++i) |
---|
64 | { |
---|
65 | array = ImportArray(param[i*2].GetString()); |
---|
66 | iterator = array->MakeIterator(); |
---|
67 | |
---|
68 | fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());; |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | //------------------------------------------------------------------------------ |
---|
73 | |
---|
74 | void UniqueObjectFinder::Finish() |
---|
75 | { |
---|
76 | map< TIterator *, TObjArray * >::iterator itInputMap; |
---|
77 | TIterator *iterator; |
---|
78 | |
---|
79 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap) |
---|
80 | { |
---|
81 | iterator = itInputMap->first; |
---|
82 | |
---|
83 | if(iterator) delete iterator; |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | //------------------------------------------------------------------------------ |
---|
88 | |
---|
89 | void UniqueObjectFinder::Process() |
---|
90 | { |
---|
91 | Candidate *candidate; |
---|
92 | map< TIterator *, TObjArray * >::iterator itInputMap; |
---|
93 | TIterator *iterator; |
---|
94 | TObjArray *array; |
---|
95 | |
---|
96 | // loop over all input arrays |
---|
97 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap) |
---|
98 | { |
---|
99 | iterator = itInputMap->first; |
---|
100 | array = itInputMap->second; |
---|
101 | |
---|
102 | // loop over all candidates |
---|
103 | iterator->Reset(); |
---|
104 | while((candidate = static_cast<Candidate*>(iterator->Next()))) |
---|
105 | { |
---|
106 | if(Unique(candidate, itInputMap)) |
---|
107 | { |
---|
108 | array->Add(candidate); |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | //------------------------------------------------------------------------------ |
---|
115 | |
---|
116 | Bool_t UniqueObjectFinder::Unique(Candidate *candidate, map< TIterator *, TObjArray * >::iterator itInputMap) |
---|
117 | { |
---|
118 | Candidate *previousCandidate; |
---|
119 | TLorentzVector difference; |
---|
120 | map< TIterator *, TObjArray * >::iterator previousItInputMap; |
---|
121 | TObjArray *array; |
---|
122 | |
---|
123 | // loop over previous arrays |
---|
124 | for(previousItInputMap = fInputMap.begin(); previousItInputMap != itInputMap; ++previousItInputMap) |
---|
125 | { |
---|
126 | array = previousItInputMap->second; |
---|
127 | TIter iterator(array); |
---|
128 | |
---|
129 | // loop over all candidates |
---|
130 | iterator.Reset(); |
---|
131 | while((previousCandidate = static_cast<Candidate*>(iterator.Next()))) |
---|
132 | { |
---|
133 | difference = candidate->Position - previousCandidate->Position; |
---|
134 | |
---|
135 | // within 10 degrees |
---|
136 | if(difference.CosTheta() > 0.9848) |
---|
137 | { |
---|
138 | return kFALSE; |
---|
139 | } |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | return kTRUE; |
---|
144 | } |
---|
145 | |
---|
146 | //------------------------------------------------------------------------------ |
---|