File indexing completed on 2025-08-05 08:11:59
0001 #include "TraceBox.h"
0002
0003 int
0004 plot_track_multi()
0005 {
0006
0007
0008 TString fname_irmag("example/updated-magnets-2017.dat");
0009
0010
0011
0012 vector<string> v_filenames;
0013 v_filenames.push_back( "example/eRHIC_updated-magnets-2017_proton_275GeV_22mrad.root" );
0014 v_filenames.push_back( "example/eRHIC_updated-magnets-2017_proton_275GeV_27mrad.root" );
0015 v_filenames.push_back( "example/eRHIC_updated-magnets-2017_proton_275GeV_17mrad.root" );
0016
0017 TObjArray* graphs = new TObjArray();
0018
0019 for ( i = 0; i < v_filenames.size(); i++ )
0020 {
0021
0022 TFile *fin = new TFile( v_filenames.at(i).c_str(), "OPEN" );
0023
0024
0025 TTree *tin = (TTree*)fin->Get("T");
0026
0027 int nhits = 0;
0028 tin->SetBranchAddress("n_G4HIT_FWDDISC",&nhits);
0029
0030
0031
0032 tin->GetEntry(0);
0033 cout << "hits: " << nhits << endl;
0034
0035 tin->Draw("G4HIT_FWDDISC.x:G4HIT_FWDDISC.z","Entry$==0","");
0036
0037 TGraph* g1 = new TGraph(nhits*2, &(tin->GetV2()[0]), &(tin->GetV1()[0]));
0038 g1->SetMarkerStyle(7);
0039 g1->SetMarkerSize(1);
0040
0041 graphs->Add( g1 );
0042
0043 }
0044
0045
0046
0047 TH1F *h1 = new TH1F("h1","",10,0,15000);
0048 h1->GetXaxis()->SetRangeUser(0,12000);
0049 h1->GetYaxis()->SetRangeUser(-50,200);
0050 h1->GetXaxis()->SetTitle("Z(cm)");
0051 h1->GetYaxis()->SetTitle("X(cm)");
0052
0053
0054 TCanvas *c1 = new TCanvas();
0055 h1->Draw("AXIS");
0056
0057
0058 ifstream irstream(fname_irmag);
0059
0060 if(!irstream.is_open())
0061 {
0062 cout << "ERROR: Could not open IR configuration file " << fname_irmag << endl;
0063 return -1;
0064 }
0065
0066 while(!irstream.eof()){
0067 string str;
0068 getline(irstream, str);
0069 if(str[0] == '#') continue;
0070 stringstream ss(str);
0071
0072 string name;
0073 double center_z, center_x, center_y, aperture_radius, length, angle, B, gradient;
0074
0075 ss >> name >> center_z >> center_x >> center_y >> aperture_radius >> length >> angle >> B >> gradient;
0076
0077 if ( name == "" ) continue;
0078
0079
0080 center_x *= 100;
0081 center_y *= 100;
0082 center_z *= 100;
0083 aperture_radius *= 100;
0084 length *= 100;
0085
0086
0087 float outer_radius = 30.0;
0088
0089
0090
0091
0092 B *= -1;
0093
0094
0095 angle = (angle / 1000.);
0096
0097
0098 cout << "New IR component: " << name << " at z = " << center_z << endl;
0099
0100 string volname = "IRMAGNET_";
0101 volname.append(name);
0102
0103
0104 TPolyLine *b1 = TraceBox( angle, center_z, center_x, length, aperture_radius, outer_radius );
0105 TPolyLine *b2 = TraceBox( angle, center_z, center_x, length, -1 * aperture_radius, -1 * outer_radius );
0106
0107 if(B != 0 && gradient == 0.0){
0108
0109 b1->SetFillColor(kOrange+1);
0110 b2->SetFillColor(kOrange+1);
0111 }
0112 else if( B == 0 && gradient != 0.0){
0113
0114 b1->SetFillColor(kBlue+1);
0115 b2->SetFillColor(kBlue+1);
0116 }
0117 else{
0118
0119 b1->SetFillColor(kGray+1);
0120 b2->SetFillColor(kGray+1);
0121 }
0122 b1->Draw("Fsame");
0123 b2->Draw("Fsame");
0124 }
0125
0126
0127 for ( int i = 0; i < graphs->GetEntries(); i++ )
0128 {
0129 graphs->At(i)->Draw("LPsame");
0130 }
0131
0132 c1->Print("multitrack_new.eps");
0133
0134 return 0;
0135 }