1 |
|
---|
2 | /** \class UniqueObjectFinder
|
---|
3 | *
|
---|
4 | * Finds uniquely identified photons, electrons and jets.
|
---|
5 | *
|
---|
6 | * $Date: 2013-11-04 10:21:27 +0000 (Mon, 04 Nov 2013) $
|
---|
7 | * $Revision: 1314 $
|
---|
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 | map< TIterator *, TObjArray * >::iterator previousItInputMap;
|
---|
120 | TObjArray *array;
|
---|
121 |
|
---|
122 | // loop over previous arrays
|
---|
123 | for(previousItInputMap = fInputMap.begin(); previousItInputMap != itInputMap; ++previousItInputMap)
|
---|
124 | {
|
---|
125 | array = previousItInputMap->second;
|
---|
126 | TIter iterator(array);
|
---|
127 |
|
---|
128 | // loop over all candidates
|
---|
129 | iterator.Reset();
|
---|
130 | while((previousCandidate = static_cast<Candidate*>(iterator.Next())))
|
---|
131 | {
|
---|
132 | if(candidate->Overlaps(previousCandidate))
|
---|
133 | {
|
---|
134 | return kFALSE;
|
---|
135 | }
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | return kTRUE;
|
---|
140 | }
|
---|
141 |
|
---|
142 | //------------------------------------------------------------------------------
|
---|