Fork me on GitHub

source: git/modules/FastJetGridMedianEstimator.cc@ 537d24f

Last change on this file since 537d24f was 341014c, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

apply .clang-format to all .h, .cc and .cpp files

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[01f457a]1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
[1fa50c2]4 *
[01f457a]5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
[1fa50c2]9 *
[01f457a]10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
[1fa50c2]14 *
[01f457a]15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
[6fb1a5d]19/** \class FastJetGridMedianEstimator
20 *
21 * Computes median energy density per event using a fixed grid.
22 *
23 * \author M. Selvaggi - UCL, Louvain-la-Neuve
24 *
25 */
26
27#include "modules/FastJetGridMedianEstimator.h"
28
29#include "classes/DelphesClasses.h"
30#include "classes/DelphesFactory.h"
31#include "classes/DelphesFormula.h"
32
33#include "ExRootAnalysis/ExRootClassifier.h"
[341014c]34#include "ExRootAnalysis/ExRootFilter.h"
35#include "ExRootAnalysis/ExRootResult.h"
[6fb1a5d]36
37#include "TDatabasePDG.h"
[341014c]38#include "TFormula.h"
[6fb1a5d]39#include "TLorentzVector.h"
[341014c]40#include "TMath.h"
41#include "TObjArray.h"
42#include "TRandom3.h"
43#include "TString.h"
[6fb1a5d]44
45#include <algorithm>
46#include <iostream>
47#include <sstream>
[341014c]48#include <stdexcept>
[6fb1a5d]49#include <utility>
[341014c]50#include <vector>
[6fb1a5d]51
52#include "fastjet/ClusterSequence.hh"
53#include "fastjet/ClusterSequenceArea.hh"
[341014c]54#include "fastjet/JetDefinition.hh"
55#include "fastjet/PseudoJet.hh"
56#include "fastjet/RectangularGrid.hh"
57#include "fastjet/Selector.hh"
[6fb1a5d]58#include "fastjet/tools/JetMedianBackgroundEstimator.hh"
59
60#include "fastjet/tools/GridMedianBackgroundEstimator.hh"
61
62#include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
[341014c]63#include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
64#include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
[6fb1a5d]65
[341014c]66#include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
[6fb1a5d]67#include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
68#include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
[341014c]69#include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
[6fb1a5d]70
71using namespace std;
72using namespace fastjet;
73using namespace fastjet::contrib;
74
75//------------------------------------------------------------------------------
76
77FastJetGridMedianEstimator::FastJetGridMedianEstimator() :
78 fItInputArray(0)
79{
80}
81
82//------------------------------------------------------------------------------
83
84FastJetGridMedianEstimator::~FastJetGridMedianEstimator()
85{
86}
87
88//------------------------------------------------------------------------------
89
90void FastJetGridMedianEstimator::Init()
91{
[406b698]92 ExRootConfParam param;
[6fb1a5d]93 Long_t i, size;
[406b698]94 Double_t drap, dphi, rapMin, rapMax;
95
96 // read rapidity ranges
97
98 param = GetParam("GridRange");
[6fb1a5d]99 size = param.GetSize();
[406b698]100
101 fEstimators.clear();
[341014c]102 for(i = 0; i < size / 4; ++i)
[6fb1a5d]103 {
[341014c]104 rapMin = param[i * 4].GetDouble();
105 rapMax = param[i * 4 + 1].GetDouble();
106 drap = param[i * 4 + 2].GetDouble();
107 dphi = param[i * 4 + 3].GetDouble();
[406b698]108 fEstimators.push_back(new GridMedianBackgroundEstimator(rapMin, rapMax, drap, dphi));
[6fb1a5d]109 }
[406b698]110
111 // import input array
[6fb1a5d]112
113 fInputArray = ImportArray(GetString("InputArray", "Calorimeter/towers"));
114 fItInputArray = fInputArray->MakeIterator();
115
116 fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho"));
117}
118
119//------------------------------------------------------------------------------
120
121void FastJetGridMedianEstimator::Finish()
122{
[341014c]123 vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
[406b698]124
125 for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
126 {
127 if(*itEstimators) delete *itEstimators;
128 }
129
[6fb1a5d]130 if(fItInputArray) delete fItInputArray;
131}
132
133//------------------------------------------------------------------------------
134
135void FastJetGridMedianEstimator::Process()
136{
137 Candidate *candidate;
138 TLorentzVector momentum;
139 Int_t number;
140 Double_t rho = 0;
141 PseudoJet jet;
[341014c]142 vector<PseudoJet> inputList, outputList;
[406b698]143
[341014c]144 vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
145 ;
[406b698]146
[6fb1a5d]147 DelphesFactory *factory = GetFactory();
[406b698]148
[6fb1a5d]149 inputList.clear();
[406b698]150
[6fb1a5d]151 // loop over input objects
152 fItInputArray->Reset();
153 number = 0;
[341014c]154 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
[6fb1a5d]155 {
156 momentum = candidate->Momentum;
157 jet = PseudoJet(momentum.Px(), momentum.Py(), momentum.Pz(), momentum.E());
158 jet.set_user_index(number);
159 inputList.push_back(jet);
160 ++number;
161 }
162
163 // compute rho and store it
[406b698]164
165 for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
[6fb1a5d]166 {
[406b698]167 (*itEstimators)->set_particles(inputList);
[6fb1a5d]168
[406b698]169 rho = (*itEstimators)->rho();
[6fb1a5d]170
171 candidate = factory->NewCandidate();
172 candidate->Momentum.SetPtEtaPhiE(rho, 0.0, 0.0, rho);
[406b698]173 candidate->Edges[0] = (*itEstimators)->rapmin();
174 candidate->Edges[1] = (*itEstimators)->rapmax();
[6fb1a5d]175 fRhoOutputArray->Add(candidate);
176 }
177}
Note: See TracBrowser for help on using the repository browser.