source: HiSusy/trunk/Delphes-3.0.0/modules/ExampleModule.cc @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 2.6 KB
Line 
1
2/** \class ExampleModule
3 *
4 *  Selects candidates from the InputArray according to the efficiency formula.
5 *
6 *  $Date: 2012-11-18 15:57:08 +0100 (Sun, 18 Nov 2012) $
7 *  $Revision: 814 $
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  fIntParam = GetInt("IntParam", 10);
59
60  fDoubleParam = GetDouble("DoubleParam", 1.0);
61
62  fFormula->Compile(GetString("EfficiencyFormula", "0.4"));
63
64  ExRootConfParam param = GetParam("ArrayParam");
65  Long_t i, size;
66  fArrayParam.clear();
67
68  size = param.GetSize();
69  for(i = 0; i < size; ++i)
70  {
71    fArrayParam.push_back(param[i].GetDouble());
72  }
73 
74  // import input array(s)
75
76  fInputArray = ImportArray(GetString("InputArray", "FastJetFinder/jets"));
77  fItInputArray = fInputArray->MakeIterator();
78
79  // create output array(s)
80
81  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
82
83}
84
85//------------------------------------------------------------------------------
86
87void ExampleModule::Finish()
88{
89  if(fItInputArray) delete fItInputArray;
90}
91
92//------------------------------------------------------------------------------
93
94void ExampleModule::Process()
95{
96  Candidate *candidate;
97  TLorentzVector candidatePosition, candidateMomentum;
98
99  // loop over all input candidates
100  fItInputArray->Reset();
101  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
102  {
103    candidatePosition = candidate->Position;
104    candidateMomentum = candidate->Momentum;
105
106    // apply an efficency formula
107    if(gRandom->Uniform() <= fFormula->Eval(candidateMomentum.Pt(), candidatePosition.Eta()))
108    {
109      fOutputArray->Add(candidate);
110    }
111  }
112}
113
114//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.