Changeset 1342 for trunk/examples/advanced/microbeam/plot.C
- Timestamp:
- Nov 5, 2010, 4:08:39 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/advanced/microbeam/plot.C
r1230 r1342 1 1 // ------------------------------------------------------------------- 2 // $Id: plot.C,v 1. 5 2009/04/30 10:23:57sincerti Exp $2 // $Id: plot.C,v 1.6 2010/10/07 14:03:11 sincerti Exp $ 3 3 // ------------------------------------------------------------------- 4 4 // … … 24 24 gROOT->SetStyle("Plain"); 25 25 Double_t scale; 26 26 27 27 28 c1 = new TCanvas ("c1","",20,20,1200,900); 28 29 c1.Divide(4,3); 29 30 FILE * fp = fopen("dose.txt","r");31 Float_t nD,cD;32 Int_t ncols=0;33 Int_t nlines = 0;34 35 TH1F *h1 = new TH1F("Absorbed dose distribution in Nucleus","Dose distribution in Nucleus",100,0.001,0.5);36 TH1F *h10 = new TH1F("Absorbed dose distribution in Cytoplasm","Dose distribution in Cytoplasm",100,0.001,0.2);37 38 while (1)39 {40 ncols = fscanf(fp,"%f %f",&nD,&cD);41 if (ncols < 0) break;42 h1->Fill(nD);43 h10->Fill(cD);44 nlines++;45 }46 fclose(fp);47 48 c1.cd(2);49 scale = 1/h1->Integral();50 h1->Scale(scale);51 h1->Draw();52 h1->GetXaxis()->SetLabelSize(0.025);53 h1->GetYaxis()->SetLabelSize(0.025);54 h1->GetXaxis()->SetTitleSize(0.035);55 h1->GetYaxis()->SetTitleSize(0.035);56 h1->GetXaxis()->SetTitleOffset(1.4);57 h1->GetYaxis()->SetTitleOffset(1.4);58 h1->GetXaxis()->SetTitle("Absorbed dose (Gy)");59 h1->GetYaxis()->SetTitle("Fraction of events");60 h1->SetLineColor(3);61 h1->SetFillColor(3);62 63 //*****************64 // DOSE IN CYTOPLASM65 //*****************66 67 c1.cd(6);68 scale = 1/h10->Integral();69 h10->Scale(scale);70 h10->Draw();71 h10->GetXaxis()->SetLabelSize(0.025);72 h10->GetYaxis()->SetLabelSize(0.025);73 h10->GetXaxis()->SetTitleSize(0.035);74 h10->GetYaxis()->SetTitleSize(0.035);75 h10->GetXaxis()->SetTitleOffset(1.4);76 h10->GetYaxis()->SetTitleOffset(1.4);77 h10->GetXaxis()->SetTitle("Absorbed dose (Gy)");78 h10->GetYaxis()->SetTitle("Fraction of events");79 h10->SetLineColor(2);80 h10->SetFillColor(2);81 82 //********************************83 // STOPPING POWER AT CELL ENTRANCE84 //********************************85 86 gStyle->SetOptStat(0000);87 gStyle->SetOptFit();88 gStyle->SetPalette(1);89 gROOT->SetStyle("Plain");90 91 Float_t d;92 FILE * fp = fopen("stoppingPower.txt","r");93 94 TH1F *h2 = new TH1F("Beam stopping Power at cell entrance","h1",200,0,300);95 while (1)96 {97 ncols = fscanf(fp,"%f",&d);98 if (ncols < 0) break;99 h2->Fill(d);100 nlines++;101 }102 fclose(fp);103 104 c1.cd(9);105 scale = 1/h2->Integral();106 h2->Scale(scale);107 h2->Draw();108 h2->GetXaxis()->SetLabelSize(0.025);109 h2->GetYaxis()->SetLabelSize(0.025);110 h2->GetXaxis()->SetTitleSize(0.035);111 h2->GetYaxis()->SetTitleSize(0.035);112 h2->GetXaxis()->SetTitleOffset(1.4);113 h2->GetYaxis()->SetTitleOffset(1.4);114 h2->GetXaxis()->SetTitle("dE/dx (keV/µm)");115 h2->GetYaxis()->SetTitle("Fraction of events");116 h2->SetTitle("dE/dx at cell entrance");117 h2->SetFillColor(4);118 h2->SetLineColor(4);119 h2->Fit("gaus");120 gaus->SetLineColor(6);121 h2->Fit("gaus");122 123 //**************124 // RANGE IN CELL125 //**************126 127 Float_t Xc,Zc,X1,Y1,Z1,x,z,X2,Y2,Z2;128 Float_t d;129 130 // X position of target in World131 Xc = -1295.59e3 - 955e3*sin(10*TMath::Pi()/180);132 133 // Z position of target in World134 Zc = -1327e3 + 955e3*cos(10*TMath::Pi()/180);135 136 // Line alignment (cf MicrobeamEMField.cc)137 Xc = Xc + 5.24*cos(10*TMath::Pi()/180);138 Zc = Zc + 5.24*sin(10*TMath::Pi()/180);139 140 FILE * fp = fopen("range.txt","r");141 142 TNtuple *ntuple = new TNtuple("Rmax","ntuple","Z2:Y2:X2");143 144 while (1)145 {146 ncols = fscanf(fp,"%f %f %f",&X1,&Y1,&Z1);147 if (ncols < 0) break;148 x = X1-Xc;149 z = Z1-Zc;150 Z2 = z*cos(10*TMath::Pi()/180)-x*sin(10*TMath::Pi()/180);151 X2 = z*sin(10*TMath::Pi()/180)+x*cos(10*TMath::Pi()/180);152 Y2 = Y1;153 154 ntuple->Fill(Z2,Y2,X2);155 nlines++;156 }157 fclose(fp);158 159 c1.cd(10);160 ntuple->Draw("X2:Z2","abs(X2)<50","surf3");161 gPad->SetLogz();162 htemp->GetXaxis()->SetLabelSize(0.025);163 htemp->GetYaxis()->SetLabelSize(0.025);164 htemp->GetZaxis()->SetLabelSize(0.025);165 htemp->GetXaxis()->SetTitleSize(0.035);166 htemp->GetYaxis()->SetTitleSize(0.035);167 htemp->GetXaxis()->SetTitleOffset(1.4);168 htemp->GetYaxis()->SetTitleOffset(1.4);169 htemp->GetXaxis()->SetTitle("Z (µm)");170 htemp->GetYaxis()->SetTitle("X (µm)");171 htemp->SetTitle("Range in cell");172 30 173 31 //********************* 174 32 // INTENSITY HISTOGRAMS 175 33 //********************* 34 jump: 176 35 177 36 FILE * fp = fopen("phantom.dat","r"); … … 189 48 190 49 TNtuple *ntupleYXN = new TNtuple("NUCLEUS","ntuple","Y:X:vox"); 191 TNtuple *ntupleZX = new TNtuple("CYTOP ASM","ntuple","Z:X:vox");192 TNtuple *ntupleYX = new TNtuple("CYTOP ASM","ntuple","Y:X:vox");50 TNtuple *ntupleZX = new TNtuple("CYTOPLASM","ntuple","Z:X:vox"); 51 TNtuple *ntupleYX = new TNtuple("CYTOPLASM","ntuple","Y:X:vox"); 193 52 194 53 nlines=0; … … 308 167 hist->SetTitle("Nucleus intensity on transverse section"); 309 168 310 //**************** 311 // ENERGY DEPOSITS 312 //**************** 313 169 // 170 171 TFile f("microbeam.root"); 172 173 TNtuple* ntuple0; 174 TNtuple* ntuple1; 175 TNtuple* ntuple2; 176 TNtuple* ntuple3; 177 TNtuple* ntuple4; 178 179 ntuple0 = (TNtuple*)f->Get("ntuple0"); 180 ntuple1 = (TNtuple*)f->Get("ntuple1"); 181 ntuple2 = (TNtuple*)f->Get("ntuple2"); 182 ntuple3 = (TNtuple*)f->Get("ntuple3"); 183 ntuple4 = (TNtuple*)f->Get("ntuple4"); 184 185 TH1F *h1 = new TH1F("h1","Dose distribution in Nucleus",100,0.001,1.); 186 TH1F *h10 = new TH1F("h10","Dose distribution in Cytoplasm",100,0.001,.2); 187 188 c1.cd(2); 189 190 ntuple3->Project("h1","doseN"); 191 scale = 1/h1->Integral(); 192 h1->Scale(scale); 193 h1->Draw(); 194 h1->GetXaxis()->SetLabelSize(0.025); 195 h1->GetYaxis()->SetLabelSize(0.025); 196 h1->GetXaxis()->SetTitleSize(0.035); 197 h1->GetYaxis()->SetTitleSize(0.035); 198 h1->GetXaxis()->SetTitleOffset(1.4); 199 h1->GetYaxis()->SetTitleOffset(1.4); 200 h1->GetXaxis()->SetTitle("Absorbed dose (Gy)"); 201 h1->GetYaxis()->SetTitle("Fraction of events"); 202 h1->SetLineColor(3); 203 h1->SetFillColor(3); 204 205 //***************** 206 // DOSE IN CYTOPLASM 207 //***************** 208 209 c1.cd(6); 210 ntuple3->Project("h10","doseC"); 211 scale = 1/h10->Integral(); 212 h10->Scale(scale); 213 h10->Draw(); 214 h10->GetXaxis()->SetLabelSize(0.025); 215 h10->GetYaxis()->SetLabelSize(0.025); 216 h10->GetXaxis()->SetTitleSize(0.035); 217 h10->GetYaxis()->SetTitleSize(0.035); 218 h10->GetXaxis()->SetTitleOffset(1.4); 219 h10->GetYaxis()->SetTitleOffset(1.4); 220 h10->GetXaxis()->SetTitle("Absorbed dose (Gy)"); 221 h10->GetYaxis()->SetTitle("Fraction of events"); 222 h10->SetLineColor(2); 223 h10->SetFillColor(2); 224 225 //******************************** 226 // STOPPING POWER AT CELL ENTRANCE 227 //******************************** 228 314 229 gStyle->SetOptStat(0000); 315 230 gStyle->SetOptFit(); … … 317 232 gROOT->SetStyle("Plain"); 318 233 319 FILE * fp = fopen("3DDose.txt","r"); 320 321 TNtuple *ntuple2 = new TNtuple("CELL","ntuple","yVox:xVox:dose"); 322 TNtuple *ntuple3 = new TNtuple("CELL","ntuple","xVox:zVox:dose"); 323 TNtuple *ntuplezyx = new TNtuple("DOSE","ntuple","zVox:yVox:xVox:dose"); 324 325 while (1) 326 { 327 ncols = fscanf(fp,"%f %f %f %f",&xVox, &yVox, &zVox, &dose); 328 if (ncols < 0) break; 329 330 xVox= xVox*voxelSizeX; 331 yVox= yVox*voxelSizeY; 332 zVox= zVox*voxelSizeZ; 333 334 ntuple2->Fill(yVox,xVox,dose); 335 ntuple3->Fill(xVox,zVox,dose); 336 ntuplezyx->Fill(zVox,yVox,xVox,dose); 337 } 338 fclose(fp); 234 Float_t d; 235 236 TH1F *h2 = new TH1F("h2","Beam stopping power at cell entrance",200,0,300); 237 238 c1.cd(9); 239 ntuple0->Project("h2","sp"); 240 scale = 1/h2->Integral(); 241 h2->Scale(scale); 242 h2->Draw(); 243 h2->GetXaxis()->SetLabelSize(0.025); 244 h2->GetYaxis()->SetLabelSize(0.025); 245 h2->GetXaxis()->SetTitleSize(0.035); 246 h2->GetYaxis()->SetTitleSize(0.035); 247 h2->GetXaxis()->SetTitleOffset(1.4); 248 h2->GetYaxis()->SetTitleOffset(1.4); 249 h2->GetXaxis()->SetTitle("dE/dx (keV/µm)"); 250 h2->GetYaxis()->SetTitle("Fraction of events"); 251 h2->SetTitle("dE/dx at cell entrance"); 252 h2->SetFillColor(4); 253 h2->SetLineColor(4); 254 h2->Fit("gaus"); 255 gaus->SetLineColor(6); 256 h2->Fit("gaus"); 257 258 259 //************** 260 // RANGE IN CELL 261 //************** 262 263 Double_t Xc,Zc,X1,Y1,Z1,X2,Y2,Z2; 264 265 // X position of target in World 266 Xc = -1295.59e3 - 955e3*sin(10*TMath::Pi()/180); 267 268 // Z position of target in World 269 Zc = -1327e3 + 955e3*cos(10*TMath::Pi()/180); 270 271 // Line alignment (cf MicrobeamEMField.cc) 272 Xc = Xc + 5.24*cos(10*TMath::Pi()/180); 273 Zc = Zc + 5.24*sin(10*TMath::Pi()/180); 274 275 TNtuple *ntupleR = new TNtuple("Rmax","ntuple","Z2:Y2:X2"); 276 Double_t x,y,z,xx,zz; 277 ntuple2->SetBranchAddress("x",&x); 278 ntuple2->SetBranchAddress("y",&y); 279 ntuple2->SetBranchAddress("z",&z); 280 Int_t nentries = (Int_t)ntuple2->GetEntries(); 281 for (Int_t i=0;i<nentries;i++) 282 { 283 ntuple2->GetEntry(i); 284 X1=x; 285 Y1=y; 286 Z1=z; 287 xx = X1-Xc; 288 zz = Z1-Zc; 289 Z2 = zz*cos(10*TMath::Pi()/180)-xx*sin(10*TMath::Pi()/180); 290 X2 = zz*sin(10*TMath::Pi()/180)+xx*cos(10*TMath::Pi()/180); 291 Y2 = Y1; 292 ntupleR->Fill(Z2,Y2,X2); 293 } 294 295 c1.cd(10); 296 ntupleR->Draw("X2:Z2","abs(X2)<50","surf3"); 297 gPad->SetLogz(); 298 /* 299 htemp->GetXaxis()->SetLabelSize(0.025); 300 htemp->GetYaxis()->SetLabelSize(0.025); 301 htemp->GetZaxis()->SetLabelSize(0.025); 302 htemp->GetXaxis()->SetTitleSize(0.035); 303 htemp->GetYaxis()->SetTitleSize(0.035); 304 htemp->GetXaxis()->SetTitleOffset(1.4); 305 htemp->GetYaxis()->SetTitleOffset(1.4); 306 htemp->GetXaxis()->SetTitle("Z (µm)"); 307 htemp->GetYaxis()->SetTitle("X (µm)"); 308 htemp->SetTitle("Range in cell"); 309 */ 310 311 //**************** 312 // ENERGY DEPOSITS 313 //**************** 314 315 316 gStyle->SetOptStat(0000); 317 gStyle->SetOptFit(); 318 gStyle->SetPalette(1); 319 gROOT->SetStyle("Plain"); 339 320 340 321 c1.cd(11); 341 322 TH2F *hist = new TH2F("hist","hist",50,-20,20,50,-20,20); 342 ntuple 2->Draw("yVox:xVox>>hist","dose","contz");323 ntuple4->Draw("y*0.359060:x*0.359060>>hist","doseV","contz"); 343 324 gPad->SetLogz(); 344 325 hist->Draw("contz"); … … 353 334 hist->GetYaxis()->SetTitle("X (µm)"); 354 335 hist->SetTitle("Mean energy deposit -transverse- (z axis in eV)"); 336 355 337 356 338 c1.cd(12); 357 339 TH2F *hist = new TH2F("hist","hist",50,-20,20,50,-20,20); 358 ntuple 3->Draw("xVox:zVox>>hist","dose","contz");340 ntuple4->Draw("x*0.359060:z*0.162810>>hist","doseV","contz"); 359 341 gPad->SetLogz(); 360 342 hist->Draw("contz"); … … 379 361 gROOT->SetStyle("Plain"); 380 362 381 Float_t bx, by; 382 FILE * fp = fopen("beamPosition.txt","r"); 383 384 TH1F *h77 = new TH1F("Beam X transverse position at cell entrance","h1",200,-10,10); 385 TH1F *h88 = new TH1F("Beam Y transverse position at cell entrance","h1",200,-10,10); 386 while (1) 387 { 388 ncols = fscanf(fp,"%f %f",&bx, &by); 389 if (ncols < 0) break; 390 h77->Fill(bx); 391 h88->Fill(by); 392 nlines++; 393 } 394 fclose(fp); 395 363 TH1F *h77 = new TH1F("hx","h1",200,-10,10); 364 TH1F *h88 = new TH1F("hy","h1",200,-10,10); 365 396 366 c1.cd(4); 397 scale = 1/h77->Integral(); 367 ntuple1->Project("hx","x"); 368 scale = 1/h77->Integral(); 398 369 h77->Scale(scale); 399 370 h77->Draw(); … … 413 384 414 385 c1.cd(8); 415 scale = 1/h88->Integral(); 386 ntuple1->Project("hy","y"); 387 scale = 1/h88->Integral(); 416 388 h88->Scale(scale); 417 389 h88->Draw();
Note: See TracChangeset
for help on using the changeset viewer.