source: trunk/modules/MadGraphMatchingAnalysis.cc@ 5

Last change on this file since 5 was 2, checked in by Pavel Demin, 17 years ago

first commit

File size: 4.1 KB
Line 
1
2#include "modules/MadGraphMatchingAnalysis.h"
3
4
5#include "ExRootAnalysis/ExRootResult.h"
6#include "ExRootAnalysis/ExRootClasses.h"
7
8#include "ExRootAnalysis/ExRootCandidate.h"
9
10#include "TClonesArray.h"
11
12#include "TH1.h"
13#include "TH2.h"
14#include "TString.h"
15#include "TCanvas.h"
16#include "TLorentzVector.h"
17
18#include <iostream>
19
20using namespace std;
21
22//------------------------------------------------------------------------------
23
24MadGraphMatchingAnalysis::MadGraphMatchingAnalysis()
25{
26}
27
28//------------------------------------------------------------------------------
29
30MadGraphMatchingAnalysis::~MadGraphMatchingAnalysis()
31{
32}
33
34//------------------------------------------------------------------------------
35
36void MadGraphMatchingAnalysis::Init()
37{
38 fOutputFileName = GetString("OutputFile", "matching_plots.root");
39
40 // import array with output from filter/classifier module
41
42 fInputArrayCandidates = ImportArray(GetString("InputArrayCandidates", "jetfinder/candidates"));
43
44 fInputArrayMatching = ImportArray(GetString("InputArrayMatching", "jetfinder/matching"));
45
46}
47
48//------------------------------------------------------------------------------
49
50void MadGraphMatchingAnalysis::Finish()
51{
52 GetPlots()->Write(fOutputFileName);
53
54 GetPlots()->GetCanvas()->SetLogy(1);
55 GetPlots()->Print();
56 GetPlots()->GetCanvas()->SetLogy(0);
57}
58
59//------------------------------------------------------------------------------
60
61void MadGraphMatchingAnalysis::Process()
62{
63 ExRootCandidate *candidate = 0;
64 ExRootMatching *matching = 0;
65 MatchingHistograms *histograms = 0;
66 Int_t maxEntry, entry;
67 TString name;
68
69 Double_t pt, signPz, rapidity;
70
71 // loop over jets
72 maxEntry = fInputArrayCandidates->GetEntriesFast();
73 for(entry = 0; entry < maxEntry; ++entry)
74 {
75 candidate = static_cast<ExRootCandidate*>(fInputArrayCandidates->At(entry));
76
77 const TLorentzVector &momentum = candidate->GetP4();
78
79 pt = momentum.Pt();
80 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
81 rapidity = (pt == 0.0 ? signPz*999.9 : momentum.Rapidity());
82 }
83
84
85 // fill matching histograms
86 maxEntry = fInputArrayMatching->GetEntriesFast();
87 for(entry = 0; entry < maxEntry; ++entry)
88 {
89 matching = static_cast<ExRootMatching*>(fInputArrayMatching->At(entry));
90
91 name = Form("q_{%d #rightarrow %d}", entry + 1, entry);
92 histograms = GetMatchingHistograms(name);
93
94 histograms->fYMerge->Fill(TMath::Log10(matching->DMerge));
95 }
96
97}
98
99//------------------------------------------------------------------------------
100
101void MadGraphMatchingAnalysis::BookMatchingHistograms(MadGraphMatchingAnalysis::MatchingHistograms *histograms,
102 const char *name, const char *title)
103{
104 ExRootResult *result = GetPlots();
105 histograms->fYMerge = result->AddHist1D(name, title, title,
106 "entries", 60, 0.0, 10.0, 0, 1);
107 histograms->fYMerge->SetStats(kTRUE);
108
109}
110
111//------------------------------------------------------------------------------
112
113MadGraphMatchingAnalysis::MatchingHistograms *
114MadGraphMatchingAnalysis::GetMatchingHistograms(const char *name)
115{
116 map<TString, MatchingHistograms *>::iterator itMatchingHistogramsMap;
117 MatchingHistograms *histograms = 0;
118 TString newName = Form("%s", name);
119 newName.ReplaceAll("{", "");
120 newName.ReplaceAll("}", "");
121 newName.ReplaceAll("^", "");
122 newName.ReplaceAll("#bar", "anti_");
123 newName.ReplaceAll("#rightarrow", "to");
124 newName.ReplaceAll("#", "");
125 newName.ReplaceAll(" ", "_");
126 TString title = Form("%s", name);
127 itMatchingHistogramsMap = fMatchingHistogramsMap.find(newName);
128 if(itMatchingHistogramsMap == fMatchingHistogramsMap.end())
129 {
130 histograms = new MatchingHistograms;
131
132 BookMatchingHistograms(histograms, newName, title);
133
134 fMatchingHistogramsMap[newName] = histograms;
135 }
136 else
137 {
138 histograms = itMatchingHistogramsMap->second;
139 }
140 return histograms;
141}
142
143//------------------------------------------------------------------------------
144
Note: See TracBrowser for help on using the repository browser.