Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compareAssignedRealPos.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file compareAssignedRealPos.C
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 /*
10  * compareAssignedRealPos.C
11  *
12  * Created on: 16 Dec 2016
13  * Author: jhrdinka
14  */
15 
16 #include <tuple>
17 #include "TFile.h"
18 #include "TH2F.h"
19 #include "TIterator.h"
20 #include "TROOT.h"
21 #include "TTree.h"
22 
23 // This root script prints global real position of layers in darker
24 // color and the assigned positions in corresponding lighter color.
25 // All the layers which should be printed into one canvas need to be in the same
26 // file. Every layer has its own directory with the contained material
27 // histograms.
28 // This script is foreseen to use the input of scripts/layerMaterial.C
29 
30 void
32  std::string infile_geoRZ = "",
33  std::string histName_geoRZ = "",
34  std::string infile_geoXY = "",
35  std::string histName_geoXY = "")
36 {
37  std::cout << "Opening file: " << inFile << std::endl;
38  TFile inputFile(inFile.c_str());
39  TList* layers = inputFile.GetListOfKeys();
40  std::cout << "Layers to print: " << std::endl;
41  layers->Print();
42  TIter next(layers);
43  TObject* obj = 0;
44 
45  int entry = 2;
46  TCanvas* canvas1 = new TCanvas();
47  TCanvas* canvas2 = new TCanvas();
48 
49  while ((obj = next())) {
50  inputFile.cd();
51  TDirectory* dir = inputFile.GetDirectory(obj->GetName());
52  TH2F* r_z = (TH2F*)dir->Get("r_z");
53  TH2F* r_z_assigned = (TH2F*)dir->Get("r_z_assigned");
54  TH2F* x_y = (TH2F*)dir->Get("x_y");
55  TH2F* x_y_assigned = (TH2F*)dir->Get("x_y_assigned");
56  if (entry == 17) entry = 20;
57  if (entry == 10 || entry == 50) entry++;
58  if (r_z && r_z_assigned) {
59  canvas1->cd();
60  r_z->SetStats(0);
61  r_z->SetMarkerColor(TColor::GetColorDark(entry));
62  r_z->SetMarkerStyle(6);
63  r_z->GetXaxis()->SetTitle("z");
64  r_z->GetYaxis()->SetTitle("r");
65  r_z->Draw("same");
66 
67  r_z_assigned->SetStats(0);
68  r_z_assigned->SetMarkerColor(TColor::GetColorBright(entry));
69  r_z_assigned->SetMarkerStyle(6);
70  r_z_assigned->GetXaxis()->SetTitle("z");
71  r_z_assigned->GetYaxis()->SetTitle("r");
72  r_z_assigned->Draw("same");
73 
74  r_z->SetDirectory(0);
75  r_z_assigned->SetDirectory(0);
76  }
77  if (x_y && x_y_assigned) {
78  canvas2->cd();
79  x_y->SetStats(0);
80  x_y->SetMarkerColor(TColor::GetColorDark(entry));
81  x_y->SetMarkerStyle(6);
82  x_y->GetXaxis()->SetTitle("x");
83  x_y->GetYaxis()->SetTitle("y");
84  x_y->Draw("same");
85 
86  x_y_assigned->SetStats(0);
87  x_y_assigned->SetMarkerColor(TColor::GetColorBright(entry));
88  x_y_assigned->SetMarkerStyle(6);
89  x_y_assigned->GetXaxis()->SetTitle("x");
90  x_y_assigned->GetYaxis()->SetTitle("y");
91  x_y_assigned->Draw("same");
92 
93  x_y->SetDirectory(0);
94  x_y_assigned->SetDirectory(0);
95  }
96  entry++;
97  }
98 
99  inputFile.Close();
100 
101  std::cout << "Opening file: " << infile_geoRZ << std::endl;
102  TFile inputFileRZ(infile_geoRZ.c_str());
103 
104  TH2F* geo_rz = (TH2F*)inputFileRZ.Get(histName_geoRZ.c_str());
105  canvas1->cd();
106  if (geo_rz)
107  geo_rz->Draw("same");
108  else
109  std::cout << "Can not access histogram with name: " << histName_geoRZ
110  << std::endl;
111  geo_rz->SetDirectory(0);
112 
113  inputFileRZ.Close();
114 
115  std::cout << "Opening file: " << infile_geoXY << std::endl;
116  TFile inputFileXY(infile_geoXY.c_str());
117 
118  TH2F* geo_xy = (TH2F*)inputFileXY.Get(histName_geoXY.c_str());
119  canvas2->cd();
120  if (geo_xy)
121  geo_xy->Draw("same");
122  else
123  std::cout << "Can not access histogram with name: " << histName_geoXY
124  << std::endl;
125  geo_xy->SetDirectory(0);
126 
127  inputFileXY.Close();
128 }