1 |
|
---|
2 | /** \class Efficiency
|
---|
3 | *
|
---|
4 | * Selects candidates from the InputArray according to the efficiency formula.
|
---|
5 | *
|
---|
6 | * $Date: 2013-02-12 13:57:44 +0000 (Tue, 12 Feb 2013) $
|
---|
7 | * $Revision: 905 $
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "modules/Efficiency.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 |
|
---|
37 | using namespace std;
|
---|
38 |
|
---|
39 | //------------------------------------------------------------------------------
|
---|
40 |
|
---|
41 | Efficiency::Efficiency() :
|
---|
42 | fFormula(0), fItInputArray(0)
|
---|
43 | {
|
---|
44 | fFormula = new DelphesFormula;
|
---|
45 | }
|
---|
46 |
|
---|
47 | //------------------------------------------------------------------------------
|
---|
48 |
|
---|
49 | Efficiency::~Efficiency()
|
---|
50 | {
|
---|
51 | if(fFormula) delete fFormula;
|
---|
52 | }
|
---|
53 |
|
---|
54 | //------------------------------------------------------------------------------
|
---|
55 |
|
---|
56 | void Efficiency::Init()
|
---|
57 | {
|
---|
58 | // read efficiency formula
|
---|
59 |
|
---|
60 | fFormula->Compile(GetString("EfficiencyFormula", "1.0"));
|
---|
61 |
|
---|
62 | // import input array
|
---|
63 |
|
---|
64 | fInputArray = ImportArray(GetString("InputArray", "ParticlePropagator/stableParticles"));
|
---|
65 | fItInputArray = fInputArray->MakeIterator();
|
---|
66 |
|
---|
67 | // create output array
|
---|
68 |
|
---|
69 | fOutputArray = ExportArray(GetString("OutputArray", "stableParticles"));
|
---|
70 | }
|
---|
71 |
|
---|
72 | //------------------------------------------------------------------------------
|
---|
73 |
|
---|
74 | void Efficiency::Finish()
|
---|
75 | {
|
---|
76 | if(fItInputArray) delete fItInputArray;
|
---|
77 | }
|
---|
78 |
|
---|
79 | //------------------------------------------------------------------------------
|
---|
80 |
|
---|
81 | void Efficiency::Process()
|
---|
82 | {
|
---|
83 | Candidate *candidate;
|
---|
84 | Double_t pt, eta, phi;
|
---|
85 |
|
---|
86 | fItInputArray->Reset();
|
---|
87 | while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
|
---|
88 | {
|
---|
89 | const TLorentzVector &candidatePosition = candidate->Position;
|
---|
90 | const TLorentzVector &candidateMomentum = candidate->Momentum;
|
---|
91 | eta = candidatePosition.Eta();
|
---|
92 | phi = candidatePosition.Phi();
|
---|
93 | pt = candidateMomentum.Pt();
|
---|
94 |
|
---|
95 | // apply an efficency formula
|
---|
96 | if(gRandom->Uniform() > fFormula->Eval(pt, eta)) continue;
|
---|
97 |
|
---|
98 | fOutputArray->Add(candidate);
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | //------------------------------------------------------------------------------
|
---|