Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:15

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