14 #include "TMultiGraph.h"
15 #include "TGraphErrors.h"
25 #include "TPostScript.h"
28 #include "reportingUtils.hpp"
43 TPRegexp histNamePattern)
45 map<string, TH1*> dimaHists;
46 TIterator* keys = dimaFile->GetListOfKeys()->MakeIterator();
47 while (TKey* k = static_cast<TKey*>(keys->Next())) {
49 printWarn <<
"NULL pointer to TKey. skipping." << endl;
52 TObject* o = k->ReadObj();
54 printWarn <<
"cannot read object from TKey '" << k->GetName() <<
"'. skipping." << endl;
57 const string type = o->IsA()->GetName();
58 if (type.find(
"TH1F") != string::npos) {
59 TH1* h =
static_cast<TH1*
>(o);
60 const TString hName = h->GetName();
61 if (hName.Contains(histNamePattern))
62 dimaHists[h->GetTitle()] = h;
72 TString dimaName = waveName;
74 if (dimaName ==
"flat")
78 dimaName.Insert(2,
"(");
79 dimaName.Insert(6,
")");
80 dimaName.Insert(9,
" ");
84 const unsigned int nmbDict = 5;
85 const string dictionary[nmbDict][2] = {
86 {
"sigma",
"f0(1400)"},
91 {
"rho31690",
"rho3"}};
92 for (
unsigned int i = 0;
i < nmbDict; ++
i)
93 dimaName.ReplaceAll(dictionary[
i][0].c_str(), dictionary[
i][1].c_str());
98 map<char, char> dictionary;
99 dictionary[
'0'] =
'S';
100 dictionary[
'1'] =
'P';
101 dictionary[
'2'] =
'D';
102 dictionary[
'3'] =
'F';
103 dictionary[
'4'] =
'G';
104 dictionary[
'5'] =
'H';
105 dictionary[
'6'] =
'I';
106 dictionary[
'7'] =
'K';
107 dictionary[
'8'] =
'L';
109 int pos = dimaName.First(
"_");
110 char L = dimaName(pos + 1);
113 dimaName = dimaName(0, pos);
115 dimaName += dictionary[L];
118 return dimaName.Data();
124 printInfo <<
"comparing intensities with Dima's result for wave " << waveName << endl;
127 map<string, TH1*> dimaIntensityHists;
129 map<string, TH1*> dimaHists =
readDimaHists(dimaFile, TString(
"^h10\\d{2}$"));
131 for (map<string, TH1*>::iterator
i = dimaHists.begin();
i != dimaHists.end(); ++
i) {
132 cout <<
" found intensity histogram '"<<
i->first <<
"' " << flush;
133 TString waveName =
i->first;
134 waveName = waveName.Strip(TString::kTrailing,
' ');
135 dimaIntensityHists[waveName.Data()] =
i->second;
136 cout <<
"for wave '" << waveName <<
"'" << endl;
140 TCanvas *pad =
new TCanvas(waveName.c_str());
143 rootgraph->Draw(
"A*");
145 cout <<
" drawing intensity for wave '" << waveName <<
"' -> '" << dimaName <<
"'" << endl;
149 TH1* hDima = dimaIntensityHists[dimaName];
151 printWarn <<
"cannot find histogram with name '" << dimaName <<
"'. skipping." << endl;
154 hDima->SetMarkerStyle(21);
155 hDima->SetMarkerSize(0.5);
156 hDima->SetLineColor(2);
157 hDima->SetMarkerColor(2);
160 TLegend *leg =
new TLegend(0.82,0.97,0.97,0.82);
162 leg->AddEntry(rootgraph,
"ROOTPWA",
"flpa");
163 leg->AddEntry(hDima,
"COMPASSPWA",
"flpa");
169 TMultiGraph* graph =
static_cast<TMultiGraph*
>(pad->GetPrimitive(waveName.c_str()));
171 const double max = std::max(hDima->GetMaximum(), graph->GetHistogram()->GetMaximum());
172 graph->SetMaximum(1.1 * max);
180 TFile* dimaFile,
const bool createPsFile)
182 printInfo <<
"comparing intensities with Dima's result." << endl;
185 map<string, TH1*> dimaIntensityHists;
187 map<string, TH1*> dimaHists =
readDimaHists(dimaFile, TString(
"^h10\\d{2}$"));
189 for (map<string, TH1*>::iterator
i = dimaHists.begin();
i != dimaHists.end(); ++
i) {
190 cout <<
" found intensity histogram '"<<
i->first <<
"' " << flush;
191 TString waveName =
i->first;
192 waveName = waveName.Strip(TString::kTrailing,
' ');
193 dimaIntensityHists[waveName.Data()] =
i->second;
194 cout <<
"for wave '" << waveName <<
"'" << endl;
203 printInfo <<
"drawing Dima's histograms" << endl;
204 for (
unsigned int i = 0;
i < wavePads.size(); ++
i) {
205 const string waveName = wavePads[
i].first;
207 cout <<
" drawing intensity for wave '" << waveName <<
"' -> '" << dimaName <<
"'" << endl;
210 TLegend *leg =
new TLegend(0.82,0.97,0.97,0.82);
211 TVirtualPad* pad = wavePads[
i].second;
213 TMultiGraph* list = (TMultiGraph*)pad->GetListOfPrimitives();
214 leg->AddEntry(&list[0],
"ROOTPWA",
"flpa");
215 TH1* hDima = dimaIntensityHists[dimaName];
217 printWarn <<
"cannot find histogram with name '" << dimaName <<
"'. skipping." << endl;
221 hDima->SetMarkerStyle(21);
222 hDima->SetMarkerSize(0.5);
223 hDima->SetLineColor(2);
224 hDima->SetMarkerColor(2);
227 leg->AddEntry(hDima,
"COMPASSPWA",
"flpa");
233 TMultiGraph* graph =
static_cast<TMultiGraph*
>(pad->GetPrimitive(waveName.c_str()));
235 const double max = std::max(hDima->GetMaximum(), graph->GetHistogram()->GetMaximum());
236 graph->SetMaximum(1.1 * max);
242 const string psFileName =
"waveIntensities_compareDima.ps";
243 TCanvas dummyCanv(
"dummy",
"dummy");
244 dummyCanv.Print((psFileName +
"[").c_str());
245 vector<TCanvas*> canvases;
246 for (
unsigned int i = 0;
i < wavePads.size(); ++
i) {
247 for (
unsigned int j = 0; j < canvases.size(); j++) {
248 if(canvases[j] == wavePads[
i].second->GetCanvas()) {
252 canvases.push_back(wavePads[
i].second->GetCanvas());
253 wavePads[
i].second->GetCanvas()->Print(psFileName.c_str());
256 dummyCanv.Print((psFileName +
"]").c_str());
257 gSystem->Exec((
"gv " + psFileName).c_str());
266 printInfo <<
"comparing spin totals with Dima's result." << endl;
269 map<string, TH1*> dimaSpinTotalHists;
271 map<string, TH1*> dimaHists =
readDimaHists(dimaFile, TString(
"^h4\\d{3}$"));
274 for (map<string, TH1*>::iterator
i = dimaHists.begin();
i != dimaHists.end(); ++
i) {
275 TString waveName =
i->first;
276 bool waveMatch =
true;
277 if (waveName ==
" Events ")
279 else if ((waveName(1, 6) ==
"J^PC!=") && (waveName(18, 5) ==
"total")) {
280 waveName = waveName(8, 4);
281 waveName.ReplaceAll(
"^",
"");
282 }
else if ((waveName(1, 10) ==
"J^PC!M[c]=") && (waveName(22, 5) ==
"total")) {
283 waveName = waveName(12, 7);
284 waveName.ReplaceAll(
"^",
"");
285 waveName.ReplaceAll(
"!",
"");
289 cout <<
" found spin total histogram '"<<
i->first <<
"' " << flush;
290 dimaSpinTotalHists[waveName.Data()] =
i->second;
291 cout <<
"for wave '" << waveName <<
"'" << endl;
297 vector<pair<string, TVirtualPad*> > wavePads =
plotSpinTotals(tree, kBlack, 0,
true,
"");
301 printInfo<<
"drawing Dima's histograms" << endl;
302 for (
unsigned int i = 0;
i < wavePads.size(); ++
i) {
303 const string waveName = wavePads[
i].first;
304 cout <<
" drawing spinTotal for wave '" << waveName <<
"'" << endl;
307 TVirtualPad* pad = wavePads[
i].second;
309 TH1* hDima = dimaSpinTotalHists[waveName];
311 printWarn <<
"cannot find histogram with name '" << waveName <<
"'. skipping." << endl;
315 hDima->SetMarkerStyle(21);
316 hDima->SetMarkerSize(0.5);
317 hDima->SetLineColor(2);
318 hDima->SetMarkerColor(2);
323 TString graphName =
"total";
324 if (waveName !=
"") {
326 graphName.Append(waveName);
327 graphName.ReplaceAll(
"+",
"p");
328 graphName.ReplaceAll(
"-",
"m");
330 TGraphErrors* graph =
static_cast<TGraphErrors*
>(pad->GetPrimitive(graphName));
332 const double max = std::max(hDima->GetMaximum(), graph->GetHistogram()->GetMaximum());
333 graph->SetMaximum(1.1 * max);
344 const vector<pair<string, string> >& wavenames_phases,
345 const string& branchName =
"fitResult_v2")
347 printInfo <<
"comparing phases with Dima's result." << endl;
350 map<string, TH1*> dimaPhaseHists;
352 map<string, TH1*> dimaHists =
readDimaHists(dimaFile, TString(
"^h4\\d{4}$"));
354 for (map<string, TH1*>::iterator
i = dimaHists.begin();
i != dimaHists.end(); ++
i) {
355 cout <<
" found phase histogram '"<<
i->first <<
"' " << flush;
356 TString hTitle =
i->first;
357 hTitle = hTitle(4, hTitle.Length() - 5);
358 const int pos = hTitle.Index(
" - ");
359 TString waveNames[2] = {hTitle(0, pos - 1), hTitle(pos + 3, hTitle.Length() - (pos + 3))};
360 waveNames[0] = waveNames[0].Strip(TString::kTrailing,
' ');
361 waveNames[1] = waveNames[1].Strip(TString::kTrailing,
' ');
362 dimaPhaseHists[(waveNames[0] +
"|" + waveNames[1]).Data()] =
i->second;
363 cout <<
"for waves '" << waveNames[0] <<
"', '" << waveNames[1] <<
"'" << endl;
369 tree->SetBranchAddress(branchName.c_str(), &massBin);
372 for (
unsigned int i = 0;
i < wavenames_phases.size(); ++
i) {
375 TH1* h = dimaPhaseHists[histName];
377 printWarn <<
"cannot find histogram with name '" << histName <<
"'. skipping." << endl;
383 TMultiGraph* rootgraph =
plotPhase(tree, wavenames_phases[
i].first, wavenames_phases[
i].second);
386 h->SetMarkerStyle(21);
387 h->SetMarkerSize(0.5);
389 h->SetMarkerColor(2);
392 TLegend *leg =
new TLegend(0.82,0.97,0.97,0.82);
394 leg->AddEntry(rootgraph,
"ROOTPWA",
"flpa");
395 leg->AddEntry(h,
"COMPASSPWA",
"flpa");
404 const string& dimaFileName =
"/afs/e18.ph.tum.de/data/compass/bgrube/lambda/pwa/compassPWA/work/hfit.root",
405 const string& wavename =
"",
406 const bool createPsFile =
false)
409 printErr <<
"NULL pointer to tree. exiting." << endl;
413 printInfo <<
"opening Dima's file '" << dimaFileName <<
"'" << endl;
414 TFile* dimaFile = TFile::Open(dimaFileName.c_str(),
"READ");
415 if (!dimaFile || dimaFile->IsZombie()) {
416 printErr <<
"cannot open file '" << dimaFileName <<
"'. exiting." << endl;
423 std::vector<std::pair<std::string, std::string> > phases;
424 phases.push_back(std::make_pair(
"1-1++0+rho770_01_pi0.amp",
"1-2-+0+f21270_02_pi-.amp"));
425 phases.push_back(make_pair(
"1-2++1+rho770_21_pi0.amp",
"1-1++0+rho770_01_pi0.amp"));
426 phases.push_back(make_pair(
"1-2++1+rho770_21_pi0.amp",
"1-2-+0+f21270_02_pi-.amp"));
427 phases.push_back(make_pair(
"1-1-+1+rho770_11_pi0.amp",
"1-2++1+rho770_21_pi0.amp"));
428 phases.push_back(make_pair(
"1-1-+1+rho770_11_pi0.amp",
"1-1++0+rho770_01_pi0.amp"));