File indexing completed on 2024-10-04 22:54:47
0001 #include "TStyle.h"
0002 #include "TH2F.h"
0003 #include "TText.h"
0004 #include "TCanvas.h"
0005 #include "TString.h"
0006 #include "TPRegexp.h"
0007 #include "TObjArray.h"
0008 #include "TObjString.h"
0009
0010 #include <fstream>
0011 #include <iostream>
0012 #include <cstdlib>
0013
0014 int main(int , char** ) {
0015 gStyle->SetOptStat(0);
0016 gStyle->SetCanvasBorderMode(0);
0017 gStyle->SetPadBorderMode(1);
0018 gStyle->SetOptTitle(0);
0019 gStyle->SetStatFont(42);
0020 gStyle->SetTitleFont(22);
0021 gStyle->SetCanvasColor(10);
0022 gStyle->SetPadColor(0);
0023 gStyle->SetLabelFont(42, "x");
0024 gStyle->SetLabelFont(42, "y");
0025 gStyle->SetHistFillStyle(1001);
0026 gStyle->SetHistFillColor(0);
0027 gStyle->SetHistLineStyle(1);
0028 gStyle->SetHistLineWidth(3);
0029 gStyle->SetTitleXOffset(1.1);
0030 gStyle->SetTitleYOffset(1.15);
0031 gStyle->SetOptStat(0);
0032
0033 gStyle->SetOptFit(0);
0034 gStyle->SetStatH(0.11);
0035
0036 TCanvas* myCanvas = new TCanvas("myC", "myC", 2000, 2000);
0037 TH2F* reference = new TH2F("reference", "reference", 300, -160., 160, 300, -160., 160.);
0038 reference->GetXaxis()->SetTitle("X [cm]");
0039 reference->GetYaxis()->SetTitle("Y [cm]");
0040 reference->Draw();
0041
0042 std::ifstream endcapDump;
0043 endcapDump.open("ee.C");
0044 if (!endcapDump) {
0045 std::cout << "ERROR: file ee.C not found" << std::endl;
0046 exit(-1);
0047 }
0048 TText* t = new TText();
0049 t->SetTextSize(0.004);
0050 t->SetTextAngle(40);
0051 int i = 0;
0052
0053
0054
0055 while (!endcapDump.eof()) {
0056 char line[256];
0057 endcapDump.getline(line, 256);
0058 TString aLine(line);
0059 if (TPRegexp("iz \\-").Match(aLine)) {
0060 TObjArray* tokens = aLine.Tokenize(" ");
0061 int ix = (((TObjString*)tokens->At(5))->String()).Atoi();
0062 TString sy = ((TObjString*)tokens->At(8))->String();
0063 TPRegexp("\\)").Substitute(sy, "");
0064 int iy = sy.Atoi();
0065 endcapDump.getline(line, 256);
0066 endcapDump.getline(line, 256);
0067 TString secondLine(line);
0068 TObjArray* newTokens = secondLine.Tokenize("(");
0069 TObjArray* coordinates = ((TObjString*)newTokens->At(3))->String().Tokenize(",");
0070 float x = ((TObjString*)coordinates->At(0))->String().Atof();
0071 float y = ((TObjString*)coordinates->At(1))->String().Atof();
0072
0073 char text[10];
0074 sprintf(text, "%d,%d", ix, iy);
0075 t->DrawText(x, y, text);
0076 std::cout << "Volume " << ++i << " ix " << ix << " iy " << iy << " Position (" << x << "," << y << ")"
0077 << std::endl;
0078 }
0079 }
0080 myCanvas->SaveAs("eeIndices.eps");
0081 delete reference;
0082 delete myCanvas;
0083 delete t;
0084 endcapDump.close();
0085 }