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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 struct SpeciesInfo
  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& right)
 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->GetRoot(),kFDSave,&fi);
 49   gROOT->GetListOfCanvases()->At(gTab->GetCurrent())->SaveAs(fi.fFilename);
 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->GetRoot(), 200, 200);
 65    gTab = new TGTab(main, 200, 200);
 66 
 67    Int_t ncols, tag, runID;
 68    Double_t LET, LET_sigma, Gvalue, Gvalue_sigma;
 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_sigma;
 81       if (file.eof()) break;
 82 
 83       std::getline(file,dummy);
 84 
 85       if (!std::getline(file,string_key)) break;
 86       std::istringstream key(string_key); // Read keys (name of molecule)
 87       if (!std::getline(file,string_value)) break;
 88       std::istringstream value(string_value); // Read G 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+1);
 98 
 99          speciesInfo[tag].fG[runID] = Gvalue;
100          speciesInfo[tag].fGerr[runID] = Gvalue_sigma;
101          speciesInfo[tag].fLET[runID] = LET;
102          speciesInfo[tag].fLETerr[runID] = LET_sigma;
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 TGraphErrors(map.fG.size(),
112                                                 map.fLET.data(),
113                                                 map.fG.data(),
114                                                 map.fLETerr.data(),
115                                                 map.fGerr.data());
116 
117       Int_t color = (2+it_map.first)%TColor::GetNumberOfColors();
118       if (color == 5 || color == 10 || color == 0) ++color;
119 
120 
121       TGCompositeFrame *tf = gTab->AddTab(map.fName.c_str());
122       TGCompositeFrame *frame = new TGCompositeFrame(tf, 60, 60,
123                                                      kHorizontalFrame);
124 
125       tf->AddFrame(frame, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,
126                    10,10,10,2));
127 
128       TRootEmbeddedCanvas *c1 = new TRootEmbeddedCanvas(map.fName.c_str(),
129                                                         frame, 700, 500);
130       frame->AddFrame(c1, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,
131                       10,10,10,2));
132       c1->GetCanvas()->SetLogx();
133 
134       TGHorizontalFrame* hframe = new TGHorizontalFrame(tf, 200, 40);
135 
136       TGTextButton* save = new TGTextButton(hframe, "&Save as ...",
137                                             "Save()");
138       hframe->AddFrame(save, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
139 
140       TGTextButton *exit = new TGTextButton(hframe, "&Exit ",
141                                             "gApplication->Terminate()");
142       hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
143 
144       tf->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
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/um)");
150       gSpecies->GetXaxis()->SetTitleOffset(1.1);
151       gSpecies->GetYaxis()->SetTitle("G value (molecules/100 eV)");
152       gSpecies->GetYaxis()->SetTitleOffset(1.2);
153       gSpecies->Draw("AP");
154    }
155 
156    main->AddFrame(gTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
157                                           kLHintsExpandY, 2, 2, 5, 1));
158 
159    main->MapSubwindows();
160    main->Resize();   // resize to default size
161    main->MapWindow();
162 }
163 
164