Fork me on GitHub

source: git/modules/ExampleModule.cc@ ffaa11a

ImprovedOutputFile Timing dual_readout llp
Last change on this file since ffaa11a was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[d7d2da3]1
2/** \class ExampleModule
3 *
4 * Selects candidates from the InputArray according to the efficiency formula.
5 *
6 * $Date$
7 * $Revision$
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "modules/ExampleModule.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
37using namespace std;
38
39//------------------------------------------------------------------------------
40
41ExampleModule::ExampleModule() :
42 fFormula(0), fItInputArray(0)
43{
44 fFormula = new DelphesFormula;
45}
46
47//------------------------------------------------------------------------------
48
49ExampleModule::~ExampleModule()
50{
51 if(fFormula) delete fFormula;
52}
53
54//------------------------------------------------------------------------------
55
56void ExampleModule::Init()
57{
58 // read parameters
59
60 fIntParam = GetInt("IntParam", 10);
61
62 fDoubleParam = GetDouble("DoubleParam", 1.0);
63
64 fFormula->Compile(GetString("EfficiencyFormula", "0.4"));
65
66 ExRootConfParam param = GetParam("ArrayParam");
67 Long_t i, size;
68 fArrayParam.clear();
69
70 size = param.GetSize();
71 for(i = 0; i < size; ++i)
72 {
73 fArrayParam.push_back(param[i].GetDouble());
74 }
75
76 // import input array(s)
77
78 fInputArray = ImportArray(GetString("InputArray", "FastJetFinder/jets"));
79 fItInputArray = fInputArray->MakeIterator();
80
81 // create output array(s)
82
83 fOutputArray = ExportArray(GetString("OutputArray", "jets"));
84
85}
86
87//------------------------------------------------------------------------------
88
89void ExampleModule::Finish()
90{
91 if(fItInputArray) delete fItInputArray;
92}
93
94//------------------------------------------------------------------------------
95
96void ExampleModule::Process()
97{
98 Candidate *candidate;
99 TLorentzVector candidatePosition, candidateMomentum;
100
101 // loop over all input candidates
102 fItInputArray->Reset();
103 while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
104 {
105 candidatePosition = candidate->Position;
106 candidateMomentum = candidate->Momentum;
107
108 // apply an efficency formula
109 if(gRandom->Uniform() <= fFormula->Eval(candidateMomentum.Pt(), candidatePosition.Eta()))
110 {
111 fOutputArray->Add(candidate);
112 }
113 }
114}
115
116//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.