[b443089] | 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 | *
|
---|
[b443089] | 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 | *
|
---|
[b443089] | 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 | *
|
---|
[b443089] | 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 |
|
---|
[d7d2da3] | 19 | /** \class ConstituentFilter
|
---|
| 20 | *
|
---|
| 21 | * Drops all input objects that are not constituents of any jet.
|
---|
| 22 | *
|
---|
| 23 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include "modules/ConstituentFilter.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"
|
---|
[d7d2da3] | 36 |
|
---|
| 37 | #include "TDatabasePDG.h"
|
---|
[341014c] | 38 | #include "TFormula.h"
|
---|
[d7d2da3] | 39 | #include "TLorentzVector.h"
|
---|
[341014c] | 40 | #include "TMath.h"
|
---|
| 41 | #include "TObjArray.h"
|
---|
| 42 | #include "TRandom3.h"
|
---|
| 43 | #include "TString.h"
|
---|
[d7d2da3] | 44 |
|
---|
| 45 | #include <algorithm>
|
---|
| 46 | #include <iostream>
|
---|
| 47 | #include <sstream>
|
---|
[341014c] | 48 | #include <stdexcept>
|
---|
[d7d2da3] | 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 |
|
---|
| 52 | //------------------------------------------------------------------------------
|
---|
| 53 |
|
---|
| 54 | ConstituentFilter::ConstituentFilter()
|
---|
| 55 | {
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | //------------------------------------------------------------------------------
|
---|
| 59 |
|
---|
| 60 | ConstituentFilter::~ConstituentFilter()
|
---|
| 61 | {
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | //------------------------------------------------------------------------------
|
---|
| 65 |
|
---|
| 66 | void ConstituentFilter::Init()
|
---|
| 67 | {
|
---|
| 68 | ExRootConfParam param;
|
---|
| 69 | Long_t i, size;
|
---|
| 70 | const TObjArray *array;
|
---|
| 71 | TIterator *iterator;
|
---|
| 72 |
|
---|
| 73 | fJetPTMin = GetDouble("JetPTMin", 0.0);
|
---|
| 74 |
|
---|
| 75 | // import input array(s)
|
---|
| 76 |
|
---|
| 77 | param = GetParam("JetInputArray");
|
---|
| 78 | size = param.GetSize();
|
---|
| 79 | for(i = 0; i < size; ++i)
|
---|
| 80 | {
|
---|
| 81 | array = ImportArray(param[i].GetString());
|
---|
| 82 | iterator = array->MakeIterator();
|
---|
| 83 |
|
---|
| 84 | fInputList.push_back(iterator);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | param = GetParam("ConstituentInputArray");
|
---|
| 88 | size = param.GetSize();
|
---|
[341014c] | 89 | for(i = 0; i < size / 2; ++i)
|
---|
[d7d2da3] | 90 | {
|
---|
[341014c] | 91 | array = ImportArray(param[i * 2].GetString());
|
---|
[d7d2da3] | 92 | iterator = array->MakeIterator();
|
---|
| 93 |
|
---|
[341014c] | 94 | fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
|
---|
[d7d2da3] | 95 | }
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //------------------------------------------------------------------------------
|
---|
| 99 |
|
---|
| 100 | void ConstituentFilter::Finish()
|
---|
| 101 | {
|
---|
[341014c] | 102 | map<TIterator *, TObjArray *>::iterator itInputMap;
|
---|
| 103 | vector<TIterator *>::iterator itInputList;
|
---|
[d7d2da3] | 104 | TIterator *iterator;
|
---|
| 105 |
|
---|
| 106 | for(itInputList = fInputList.begin(); itInputList != fInputList.end(); ++itInputList)
|
---|
| 107 | {
|
---|
| 108 | iterator = *itInputList;
|
---|
| 109 | if(iterator) delete iterator;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
|
---|
| 113 | {
|
---|
| 114 | iterator = itInputMap->first;
|
---|
| 115 | if(iterator) delete iterator;
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | //------------------------------------------------------------------------------
|
---|
| 120 |
|
---|
| 121 | void ConstituentFilter::Process()
|
---|
| 122 | {
|
---|
| 123 | Candidate *jet, *constituent;
|
---|
[341014c] | 124 | map<TIterator *, TObjArray *>::iterator itInputMap;
|
---|
| 125 | vector<TIterator *>::iterator itInputList;
|
---|
[d7d2da3] | 126 | TIterator *iterator;
|
---|
| 127 | TObjArray *array;
|
---|
| 128 |
|
---|
| 129 | // loop over all jet input arrays
|
---|
| 130 | for(itInputList = fInputList.begin(); itInputList != fInputList.end(); ++itInputList)
|
---|
| 131 | {
|
---|
| 132 | iterator = *itInputList;
|
---|
| 133 |
|
---|
| 134 | // loop over all jets
|
---|
| 135 | iterator->Reset();
|
---|
[341014c] | 136 | while((jet = static_cast<Candidate *>(iterator->Next())))
|
---|
[d7d2da3] | 137 | {
|
---|
| 138 | TIter itConstituents(jet->GetCandidates());
|
---|
| 139 |
|
---|
| 140 | if(jet->Momentum.Pt() <= fJetPTMin) continue;
|
---|
| 141 |
|
---|
| 142 | // loop over all constituents
|
---|
[341014c] | 143 | while((constituent = static_cast<Candidate *>(itConstituents.Next())))
|
---|
[d7d2da3] | 144 | {
|
---|
| 145 | // set the IsConstituent flag
|
---|
| 146 | constituent->IsConstituent = 1;
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | // loop over all constituent input arrays
|
---|
| 152 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
|
---|
| 153 | {
|
---|
| 154 | iterator = itInputMap->first;
|
---|
| 155 | array = itInputMap->second;
|
---|
| 156 |
|
---|
| 157 | // loop over all constituents
|
---|
| 158 | iterator->Reset();
|
---|
[341014c] | 159 | while((constituent = static_cast<Candidate *>(iterator->Next())))
|
---|
[d7d2da3] | 160 | {
|
---|
| 161 | // check the IsConstituent flag
|
---|
| 162 | if(constituent->IsConstituent)
|
---|
| 163 | {
|
---|
| 164 | array->Add(constituent);
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | //------------------------------------------------------------------------------
|
---|