📜  如何在根目录下读取宏文件中的许多文本文件 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:22.288000             🧑  作者: Mango

代码示例1
void mult(){
   auto hs = new THStack("hs","test stacked histograms");

   ifstream in;
   in.open(Form("test1.txt"));
   Float_t x,y;
   TH1F *he1 = new TH1F("he1"," with Histogram ",100,-150,150);

   while (1) {
      in >> x >> y;
      if (!in.good()) break;
      he1->Fill(x,y);
   }

   he1->SetFillColor(kYellow);
   hs->Add(he1,"hist");

   ifstream inp;
   inp.open(Form("test2.txt"));
   Float_t e,r;

   TH1F *he2 = new TH1F("he2"," with Histogram ",100,-150,150);
   while (1) {
      inp >> e >> r;
      if (!inp.good()) break;
      he2->Fill(e,r);
   }
   he2->SetFillColor(kRed);
   hs->Add(he2, "hist");

   hs->Draw("nostack");
}