Geant4 Cross Reference |
1 struct SpeciesInfo 1 2 { 3 SpeciesInfo() 4 { 5 } 6 SpeciesInfo(const SpeciesInfo& right) : 7 fG(right.fG), 8 fGerr(right.fGerr), 9 fLET(right.fLET), 10 fLETerr(right.fLETerr), 11 fName(right.fName) 12 {} 13 SpeciesInfo& operator=(const SpeciesInfo& r 14 { 15 if(this == &right) return *this; 16 fG = right.fG; 17 fGerr = right.fGerr; 18 fLET = right.fLET; 19 fLETerr = right.fLETerr; 20 fName = right.fName; 21 return *this; 22 } 23 24 std::vector<Double_t> fG; 25 std::vector<Double_t> fGerr; 26 std::vector<Double_t> fLET; 27 std::vector<Double_t> fLETerr; 28 string fName; 29 }; 30 31 const char* filetypes[] = { 32 "PostScript", "*.ps", 33 "Encapsulated PostScript", "*.eps", 34 "PDF files", "*.pdf", 35 "Gif files", "*.gif", 36 "PNG files", "*.png", 37 "All files", "*", 38 0, 0 39 }; 40 41 TGTab *gTab = nullptr; 42 43 void Save() 44 { 45 TGFileInfo fi; 46 fi.fFileTypes = filetypes; 47 48 new TGFileDialog(gClient->GetRoot(),gClient- 49 gROOT->GetListOfCanvases()->At(gTab->GetCurr 50 } 51 52 void plotG_LET() 53 { 54 55 std::map<Int_t, SpeciesInfo> speciesInfo; 56 57 gROOT->SetStyle("Plain"); 58 gStyle->SetPalette(1); 59 gStyle->SetCanvasBorderMode(0); 60 gStyle->SetFrameBorderMode(0); 61 gStyle->SetPadTickX(1); 62 gStyle->SetPadTickY(1); 63 64 TGMainFrame *main = new TGMainFrame(gClient 65 gTab = new TGTab(main, 200, 200); 66 67 Int_t ncols, tag, runID; 68 Double_t LET, LET_sigma, Gvalue, Gvalue_sig 69 string name; 70 string dummy; 71 string string_key, string_value; 72 73 ifstream file; 74 file.open("Species.txt",std::ios::in); 75 76 runID = 0; 77 78 while(1) { 79 // Read LET values 80 file >> dummy >> LET >> dummy >> LET_sig 81 if (file.eof()) break; 82 83 std::getline(file,dummy); 84 85 if (!std::getline(file,string_key)) brea 86 std::istringstream key(string_key); // R 87 if (!std::getline(file,string_value)) br 88 std::istringstream value(string_value); 89 while(1) { 90 key >> name >> tag; 91 value >> Gvalue >> Gvalue_sigma; 92 if (!key || !value) break; 93 speciesInfo[tag].fName = name; 94 speciesInfo[tag].fG.resize(runID+1); 95 speciesInfo[tag].fGerr.resize(runID+1 96 speciesInfo[tag].fLET.resize(runID+1) 97 speciesInfo[tag].fLETerr.resize(runID 98 99 speciesInfo[tag].fG[runID] = Gvalue; 100 speciesInfo[tag].fGerr[runID] = Gvalu 101 speciesInfo[tag].fLET[runID] = LET; 102 speciesInfo[tag].fLETerr[runID] = LET 103 } 104 runID++; 105 } 106 file.close(); 107 108 for (auto it_map : speciesInfo) { 109 110 auto map = it_map.second; 111 TGraphErrors* gSpecies = new TGraphError 112 113 114 115 116 117 Int_t color = (2+it_map.first)%TColor::G 118 if (color == 5 || color == 10 || color = 119 120 121 TGCompositeFrame *tf = gTab->AddTab(map. 122 TGCompositeFrame *frame = new TGComposit 123 124 125 tf->AddFrame(frame, new TGLayoutHints(kL 126 10,10,10,2)); 127 128 TRootEmbeddedCanvas *c1 = new TRootEmbed 129 130 frame->AddFrame(c1, new TGLayoutHints(kL 131 10,10,10,2)); 132 c1->GetCanvas()->SetLogx(); 133 134 TGHorizontalFrame* hframe = new TGHorizo 135 136 TGTextButton* save = new TGTextButton(hf 137 "S 138 hframe->AddFrame(save, new TGLayoutHints 139 140 TGTextButton *exit = new TGTextButton(hf 141 "g 142 hframe->AddFrame(exit, new TGLayoutHints 143 144 tf->AddFrame(hframe, new TGLayoutHints(k 145 146 gSpecies->SetTitle(map.fName.c_str()); 147 gSpecies->SetMarkerStyle(20+it_map.first 148 gSpecies->SetMarkerColor(color); 149 gSpecies->GetXaxis()->SetTitle("LET (keV 150 gSpecies->GetXaxis()->SetTitleOffset(1.1 151 gSpecies->GetYaxis()->SetTitle("G value 152 gSpecies->GetYaxis()->SetTitleOffset(1.2 153 gSpecies->Draw("AP"); 154 } 155 156 main->AddFrame(gTab, new TGLayoutHints(kLHi 157 kLHi 158 159 main->MapSubwindows(); 160 main->Resize(); // resize to default size 161 main->MapWindow(); 162 } 163 164