Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:15:03

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 /*
0010  * compareAssignedRealPos.C
0011  *
0012  *  Created on: 16 Dec 2016
0013  *      Author: jhrdinka
0014  */
0015 
0016 #include <tuple>
0017 #include "TFile.h"
0018 #include "TH2F.h"
0019 #include "TIterator.h"
0020 #include "TROOT.h"
0021 #include "TTree.h"
0022 
0023 // This root script prints global real position of layers in darker
0024 // color and the assigned positions in corresponding lighter color.
0025 // All the layers which should be printed into one canvas need to be in the same
0026 // file. Every layer has its own directory with the contained material
0027 // histograms.
0028 // This script is foreseen to use the input of scripts/layerMaterial.C
0029 
0030 void
0031 compareAssignedRealPos(std::string inFile,
0032                        std::string infile_geoRZ   = "",
0033                        std::string histName_geoRZ = "",
0034                        std::string infile_geoXY   = "",
0035                        std::string histName_geoXY = "")
0036 {
0037   std::cout << "Opening file: " << inFile << std::endl;
0038   TFile  inputFile(inFile.c_str());
0039   TList* layers = inputFile.GetListOfKeys();
0040   std::cout << "Layers to print: " << std::endl;
0041   layers->Print();
0042   TIter    next(layers);
0043   TObject* obj = 0;
0044 
0045   int      entry   = 2;
0046   TCanvas* canvas1 = new TCanvas();
0047   TCanvas* canvas2 = new TCanvas();
0048 
0049   while ((obj = next())) {
0050     inputFile.cd();
0051     TDirectory* dir          = inputFile.GetDirectory(obj->GetName());
0052     TH2F*       r_z          = (TH2F*)dir->Get("r_z");
0053     TH2F*       r_z_assigned = (TH2F*)dir->Get("r_z_assigned");
0054     TH2F*       x_y          = (TH2F*)dir->Get("x_y");
0055     TH2F*       x_y_assigned = (TH2F*)dir->Get("x_y_assigned");
0056     if (entry == 17) entry = 20;
0057     if (entry == 10 || entry == 50) entry++;
0058     if (r_z && r_z_assigned) {
0059       canvas1->cd();
0060       r_z->SetStats(0);
0061       r_z->SetMarkerColor(TColor::GetColorDark(entry));
0062       r_z->SetMarkerStyle(6);
0063       r_z->GetXaxis()->SetTitle("z");
0064       r_z->GetYaxis()->SetTitle("r");
0065       r_z->Draw("same");
0066 
0067       r_z_assigned->SetStats(0);
0068       r_z_assigned->SetMarkerColor(TColor::GetColorBright(entry));
0069       r_z_assigned->SetMarkerStyle(6);
0070       r_z_assigned->GetXaxis()->SetTitle("z");
0071       r_z_assigned->GetYaxis()->SetTitle("r");
0072       r_z_assigned->Draw("same");
0073 
0074       r_z->SetDirectory(0);
0075       r_z_assigned->SetDirectory(0);
0076     }
0077     if (x_y && x_y_assigned) {
0078       canvas2->cd();
0079       x_y->SetStats(0);
0080       x_y->SetMarkerColor(TColor::GetColorDark(entry));
0081       x_y->SetMarkerStyle(6);
0082       x_y->GetXaxis()->SetTitle("x");
0083       x_y->GetYaxis()->SetTitle("y");
0084       x_y->Draw("same");
0085 
0086       x_y_assigned->SetStats(0);
0087       x_y_assigned->SetMarkerColor(TColor::GetColorBright(entry));
0088       x_y_assigned->SetMarkerStyle(6);
0089       x_y_assigned->GetXaxis()->SetTitle("x");
0090       x_y_assigned->GetYaxis()->SetTitle("y");
0091       x_y_assigned->Draw("same");
0092 
0093       x_y->SetDirectory(0);
0094       x_y_assigned->SetDirectory(0);
0095     }
0096     entry++;
0097   }
0098 
0099   inputFile.Close();
0100 
0101   std::cout << "Opening file: " << infile_geoRZ << std::endl;
0102   TFile inputFileRZ(infile_geoRZ.c_str());
0103 
0104   TH2F* geo_rz = (TH2F*)inputFileRZ.Get(histName_geoRZ.c_str());
0105   canvas1->cd();
0106   if (geo_rz)
0107     geo_rz->Draw("same");
0108   else
0109     std::cout << "Can not access histogram with name: " << histName_geoRZ
0110               << std::endl;
0111   geo_rz->SetDirectory(0);
0112 
0113   inputFileRZ.Close();
0114 
0115   std::cout << "Opening file: " << infile_geoXY << std::endl;
0116   TFile inputFileXY(infile_geoXY.c_str());
0117 
0118   TH2F* geo_xy = (TH2F*)inputFileXY.Get(histName_geoXY.c_str());
0119   canvas2->cd();
0120   if (geo_xy)
0121     geo_xy->Draw("same");
0122   else
0123     std::cout << "Can not access histogram with name: " << histName_geoXY
0124               << std::endl;
0125   geo_xy->SetDirectory(0);
0126 
0127   inputFileXY.Close();
0128 }