[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 Delphes
|
---|
| 20 | *
|
---|
| 21 | * Main Delphes module.
|
---|
| 22 | * Controls execution of all other modules.
|
---|
| 23 | *
|
---|
| 24 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #include "modules/Delphes.h"
|
---|
| 29 |
|
---|
| 30 | #include "classes/DelphesClasses.h"
|
---|
| 31 | #include "classes/DelphesFactory.h"
|
---|
| 32 | #include "classes/DelphesFormula.h"
|
---|
| 33 |
|
---|
| 34 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootConfReader.h"
|
---|
[341014c] | 36 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 37 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
[d7d2da3] | 38 | #include "ExRootAnalysis/ExRootTreeWriter.h"
|
---|
| 39 |
|
---|
[341014c] | 40 | #include "TDatabasePDG.h"
|
---|
[d7d2da3] | 41 | #include "TFolder.h"
|
---|
| 42 | #include "TFormula.h"
|
---|
| 43 | #include "TLorentzVector.h"
|
---|
[341014c] | 44 | #include "TMath.h"
|
---|
| 45 | #include "TObjArray.h"
|
---|
| 46 | #include "TROOT.h"
|
---|
| 47 | #include "TRandom3.h"
|
---|
| 48 | #include "TString.h"
|
---|
[d7d2da3] | 49 |
|
---|
[341014c] | 50 | #include <algorithm>
|
---|
[d7d2da3] | 51 | #include <iostream>
|
---|
| 52 | #include <sstream>
|
---|
[341014c] | 53 | #include <stdexcept>
|
---|
[d7d2da3] | 54 |
|
---|
| 55 | #include <stdio.h>
|
---|
[341014c] | 56 | #include <string.h>
|
---|
[d7d2da3] | 57 |
|
---|
| 58 | using namespace std;
|
---|
| 59 |
|
---|
| 60 | Delphes::Delphes(const char *name) :
|
---|
| 61 | fFactory(0)
|
---|
| 62 | {
|
---|
[06630ef] | 63 | TFolder *folder;
|
---|
| 64 |
|
---|
[d7d2da3] | 65 | fFactory = new DelphesFactory("ObjectFactory");
|
---|
| 66 |
|
---|
[06630ef] | 67 | folder = new TFolder(name, "");
|
---|
| 68 |
|
---|
[d7d2da3] | 69 | SetName(name);
|
---|
| 70 | SetFolder(folder);
|
---|
| 71 |
|
---|
| 72 | folder->Add(this);
|
---|
| 73 | folder->Add(fFactory);
|
---|
| 74 |
|
---|
| 75 | gROOT->GetListOfBrowsables()->Add(folder);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | //------------------------------------------------------------------------------
|
---|
| 79 |
|
---|
| 80 | Delphes::~Delphes()
|
---|
| 81 | {
|
---|
| 82 | TFolder *folder = GetFolder();
|
---|
| 83 | if(folder)
|
---|
| 84 | {
|
---|
[06630ef] | 85 | gROOT->GetListOfBrowsables()->Remove(folder);
|
---|
[d7d2da3] | 86 | folder->Clear();
|
---|
| 87 | delete folder;
|
---|
| 88 | }
|
---|
[2fedc72] | 89 | if(fFactory) delete fFactory;
|
---|
[d7d2da3] | 90 | }
|
---|
| 91 |
|
---|
| 92 | //------------------------------------------------------------------------------
|
---|
| 93 |
|
---|
| 94 | void Delphes::Clear()
|
---|
| 95 | {
|
---|
| 96 | if(fFactory) fFactory->Clear();
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | //------------------------------------------------------------------------------
|
---|
| 100 |
|
---|
| 101 | void Delphes::SetTreeWriter(ExRootTreeWriter *treeWriter)
|
---|
| 102 | {
|
---|
| 103 | treeWriter->SetName("TreeWriter");
|
---|
| 104 | GetFolder()->Add(treeWriter);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | //------------------------------------------------------------------------------
|
---|
| 108 |
|
---|
| 109 | void Delphes::Init()
|
---|
| 110 | {
|
---|
| 111 | stringstream message;
|
---|
| 112 | ExRootConfReader *confReader = GetConfReader();
|
---|
| 113 | confReader->SetName("ConfReader");
|
---|
| 114 | GetFolder()->Add(confReader);
|
---|
| 115 |
|
---|
| 116 | TString name;
|
---|
| 117 | ExRootTask *task;
|
---|
| 118 | const ExRootConfReader::ExRootTaskMap *modules = confReader->GetModules();
|
---|
| 119 | ExRootConfReader::ExRootTaskMap::const_iterator itModules;
|
---|
| 120 |
|
---|
| 121 | ExRootConfParam param = confReader->GetParam("::ExecutionPath");
|
---|
| 122 | Long_t i, size = param.GetSize();
|
---|
| 123 |
|
---|
[4a9ec82] | 124 | gRandom->SetSeed(confReader->GetInt("::RandomSeed", 0));
|
---|
| 125 |
|
---|
[d7d2da3] | 126 | for(i = 0; i < size; ++i)
|
---|
| 127 | {
|
---|
| 128 | name = param[i].GetString();
|
---|
| 129 | itModules = modules->find(name);
|
---|
| 130 | if(itModules != modules->end())
|
---|
| 131 | {
|
---|
| 132 | task = NewTask(itModules->second, itModules->first);
|
---|
| 133 | if(task)
|
---|
| 134 | {
|
---|
| 135 | task->SetFolder(GetFolder());
|
---|
| 136 | Add(task);
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | else
|
---|
| 140 | {
|
---|
| 141 | message << "module '" << name;
|
---|
| 142 | message << "' is specified in ExecutionPath but not configured.";
|
---|
| 143 | throw runtime_error(message.str());
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | //------------------------------------------------------------------------------
|
---|
| 149 |
|
---|
| 150 | void Delphes::Process()
|
---|
| 151 | {
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | //------------------------------------------------------------------------------
|
---|
| 155 |
|
---|
| 156 | void Delphes::Finish()
|
---|
| 157 | {
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | //------------------------------------------------------------------------------
|
---|