Geant4 Cross Reference |
1 void ReadASCII(TString source_file_ascii, TStr 1 void ReadASCII(TString source_file_ascii, TString output_file_root) 2 { 2 { 3 3 4 // This macro converts the results of the simu 4 // This macro converts the results of the simulation stored in ASCII files to ROOT files. 5 ifstream in; 5 ifstream in; 6 in.open(source_file_ascii); 6 in.open(source_file_ascii); 7 7 8 Float_t x,y,z, edep; 8 Float_t x,y,z, edep; 9 Int_t nlines = 0; 9 Int_t nlines = 0; 10 TFile *f = new TFile(output_file_root,"RECRE 10 TFile *f = new TFile(output_file_root,"RECREATE"); 11 TH2F *h20 = new TH2F("h20","h20",801,-100.12 11 TH2F *h20 = new TH2F("h20","h20",801,-100.125,100.125, 801, -100.125, 100.125); 12 12 13 while (1) { 13 while (1) { 14 in >> x >> y >> z >> edep; 14 in >> x >> y >> z >> edep; 15 if (!in.good()) break; 15 if (!in.good()) break; 16 // if (edep !=0.) printf("x=%8f, y=%8f, e 16 // if (edep !=0.) printf("x=%8f, y=%8f, edep=%8f\n",x,y,edep); 17 17 18 h20->Fill(x,y,edep); 18 h20->Fill(x,y,edep); 19 nlines++; 19 nlines++; 20 } 20 } 21 printf(" found %d points\n",nlines); 21 printf(" found %d points\n",nlines); 22 22 23 in.close(); 23 in.close(); 24 24 25 f->Write(); 25 f->Write(); 26 } 26 } 27 27