1 |
|
---|
2 | /** \class FastJetGridMedianEstimator
|
---|
3 | *
|
---|
4 | *
|
---|
5 | * Computes median energy density per event using a fixed grid.
|
---|
6 | *
|
---|
7 | * \author M. Selvaggi - UCL, Louvain-la-Neuve
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | #include "modules/FastJetGridMedianEstimator.h"
|
---|
12 |
|
---|
13 | #include "classes/DelphesClasses.h"
|
---|
14 | #include "classes/DelphesFactory.h"
|
---|
15 | #include "classes/DelphesFormula.h"
|
---|
16 |
|
---|
17 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
18 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
19 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
20 |
|
---|
21 | #include "TMath.h"
|
---|
22 | #include "TString.h"
|
---|
23 | #include "TFormula.h"
|
---|
24 | #include "TRandom3.h"
|
---|
25 | #include "TObjArray.h"
|
---|
26 | #include "TDatabasePDG.h"
|
---|
27 | #include "TLorentzVector.h"
|
---|
28 |
|
---|
29 | #include <algorithm>
|
---|
30 | #include <stdexcept>
|
---|
31 | #include <iostream>
|
---|
32 | #include <sstream>
|
---|
33 | #include <vector>
|
---|
34 | #include <utility>
|
---|
35 |
|
---|
36 | #include "fastjet/PseudoJet.hh"
|
---|
37 | #include "fastjet/JetDefinition.hh"
|
---|
38 | #include "fastjet/ClusterSequence.hh"
|
---|
39 | #include "fastjet/Selector.hh"
|
---|
40 | #include "fastjet/RectangularGrid.hh"
|
---|
41 | #include "fastjet/ClusterSequenceArea.hh"
|
---|
42 | #include "fastjet/tools/JetMedianBackgroundEstimator.hh"
|
---|
43 |
|
---|
44 | #include "fastjet/tools/GridMedianBackgroundEstimator.hh"
|
---|
45 |
|
---|
46 | #include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
|
---|
47 | #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
|
---|
48 | #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
|
---|
49 |
|
---|
50 | #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
|
---|
51 | #include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
|
---|
52 | #include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
|
---|
53 | #include "fastjet/contribs/Nsubjettiness/WinnerTakeAllRecombiner.hh"
|
---|
54 |
|
---|
55 | using namespace std;
|
---|
56 | using namespace fastjet;
|
---|
57 | using namespace fastjet::contrib;
|
---|
58 |
|
---|
59 |
|
---|
60 | //------------------------------------------------------------------------------
|
---|
61 |
|
---|
62 | FastJetGridMedianEstimator::FastJetGridMedianEstimator() :
|
---|
63 | fItInputArray(0)
|
---|
64 | {
|
---|
65 |
|
---|
66 | }
|
---|
67 |
|
---|
68 | //------------------------------------------------------------------------------
|
---|
69 |
|
---|
70 | FastJetGridMedianEstimator::~FastJetGridMedianEstimator()
|
---|
71 | {
|
---|
72 |
|
---|
73 | }
|
---|
74 |
|
---|
75 | //------------------------------------------------------------------------------
|
---|
76 |
|
---|
77 | void FastJetGridMedianEstimator::Init()
|
---|
78 | {
|
---|
79 | // read eta ranges
|
---|
80 |
|
---|
81 | ExRootConfParam param = GetParam("GridRange");
|
---|
82 | Long_t i, size;
|
---|
83 |
|
---|
84 | fGrid.clear();
|
---|
85 | size = param.GetSize();
|
---|
86 | for(i = 0; i < size/4; ++i)
|
---|
87 | {
|
---|
88 | fGrid[make_pair(param[i*4].GetDouble(), param[i*4 + 1].GetDouble())] = make_pair(param[i*4 + 2].GetDouble(), param[i*4 + 3].GetDouble());
|
---|
89 | //cout<<param[i*4].GetDouble()<<","<< param[i*4 + 1].GetDouble()<<","<< param[i*4 + 2].GetDouble()<<","<< param[i*4 + 3].GetDouble()<<endl;
|
---|
90 |
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | //cout<<fGrid[make_pair(0.0,2.5)].first<<","<<fGrid[make_pair(0.0,2.5)].second<<endl;
|
---|
95 |
|
---|
96 | // import input array
|
---|
97 |
|
---|
98 | fInputArray = ImportArray(GetString("InputArray", "Calorimeter/towers"));
|
---|
99 | fItInputArray = fInputArray->MakeIterator();
|
---|
100 |
|
---|
101 | fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho"));
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | //------------------------------------------------------------------------------
|
---|
106 |
|
---|
107 | void FastJetGridMedianEstimator::Finish()
|
---|
108 | {
|
---|
109 | if(fItInputArray) delete fItInputArray;
|
---|
110 | }
|
---|
111 |
|
---|
112 | //------------------------------------------------------------------------------
|
---|
113 |
|
---|
114 | void FastJetGridMedianEstimator::Process()
|
---|
115 | {
|
---|
116 | Candidate *candidate;
|
---|
117 | TLorentzVector momentum;
|
---|
118 | Double_t deta, dphi, detaMin, detaMax;
|
---|
119 | Int_t number;
|
---|
120 | Double_t rho = 0;
|
---|
121 | PseudoJet jet;
|
---|
122 | vector<PseudoJet> inputList, outputList;
|
---|
123 |
|
---|
124 | std::map< std::pair< Double_t , Double_t > , std::pair< Double_t , Double_t > >::iterator itGrid;
|
---|
125 |
|
---|
126 | DelphesFactory *factory = GetFactory();
|
---|
127 |
|
---|
128 | inputList.clear();
|
---|
129 |
|
---|
130 | // loop over input objects
|
---|
131 | fItInputArray->Reset();
|
---|
132 | number = 0;
|
---|
133 | while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
|
---|
134 | {
|
---|
135 | momentum = candidate->Momentum;
|
---|
136 | jet = PseudoJet(momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E());
|
---|
137 | jet.set_user_index(number);
|
---|
138 | inputList.push_back(jet);
|
---|
139 | ++number;
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | // compute rho and store it
|
---|
144 |
|
---|
145 | // cout<<"caio"<<endl;
|
---|
146 | for(itGrid = fGrid.begin(); itGrid != fGrid.end(); ++itGrid)
|
---|
147 | {
|
---|
148 | //Selector select_rapidity = SelectorAbsRapRange(itEtaRangeMap->first, itEtaRangeMap->second);
|
---|
149 | // JetMedianBackgroundEstimator estimator(select_rapidity, *fDefinition, *fAreaDefinition);
|
---|
150 |
|
---|
151 | //cout<<itGrid->first.first<<endl;
|
---|
152 |
|
---|
153 | detaMin = (itGrid->first).first;
|
---|
154 | detaMax = (itGrid->first).second;
|
---|
155 | deta = (itGrid->second).first;
|
---|
156 | dphi = (itGrid->second).second;
|
---|
157 |
|
---|
158 | //cout<<detaMin<<","<<detaMax<<","<<deta<<","<<dphi<<endl;
|
---|
159 |
|
---|
160 |
|
---|
161 | RectangularGrid grid(detaMin, detaMax, deta, dphi);
|
---|
162 | //cout<<grid.is_initialised()<<endl;
|
---|
163 | //cout<<grid.rapmin()<<","<<grid.rapmax()<<","<<grid.drap()<<","<<grid.dphi()<<endl;
|
---|
164 |
|
---|
165 | GridMedianBackgroundEstimator estimator(grid);
|
---|
166 |
|
---|
167 | estimator.set_particles(inputList);
|
---|
168 |
|
---|
169 | //cout<<estimator.description()<<endl;
|
---|
170 |
|
---|
171 | rho = estimator.rho();
|
---|
172 | //cout<<rho<<endl;
|
---|
173 |
|
---|
174 |
|
---|
175 | candidate = factory->NewCandidate();
|
---|
176 | candidate->Momentum.SetPtEtaPhiE(rho, 0.0, 0.0, rho);
|
---|
177 | candidate->Edges[0] = detaMin;
|
---|
178 | candidate->Edges[1] = detaMax;
|
---|
179 | fRhoOutputArray->Add(candidate);
|
---|
180 | }
|
---|
181 |
|
---|
182 | }
|
---|