Locked History Actions

attachment:MakeStableNucleiRootFile.C of 核図表

Attachment 'MakeStableNucleiRootFile.C'

Download

#include <iostream>
#include <fstream>
#include <sstream> 
#include <string>
#include <cstring>
#include "TFile.h"
#include "TTree.h"

using namespace std;

Int_t MakeStableNucleiRootFile() {
  ifstream ifs("./StableNuclei.txt");
  string line;
  stringstream ss;
  char c;

  struct DataOfNuclei_t {
    Int_t A, Z, N;
    DataOfNuclei_t (): A(), Z(), N(){}
  };
  DataOfNuclei_t nucdata;
  
  TFile *f  = new TFile("StableNuclei.root","RECREATE");
  TTree *tree = new TTree("StableNuclei","Stable Nuclei data from ascii file");

  // create one branch with all information from the stucture
  tree->Branch("StableNuclei",&nucdata.A,"A/I:Z:N");

  while( !ifs.eof() ){
    c = ifs.peek();
    getline(ifs, line);
    if ( (c < '0') || (c > '9') ) {
      continue;
    }
    ss.str("");
    /* ss.clear(stringstream::goodbit); too slow to run by CINT!! */

    ss << line.substr(0,3)  << " " 
       << line.substr(12,3) << " "
       << line.substr(16,3) << " " ; /* To privent to set "badbit" for ss */
    ss >> nucdata.A >> nucdata.Z >> nucdata.N;
    //    cout  << nucdata.Z << " " << nucdata.N <<endl;
    tree->Fill();
  }
  tree->Print();
  f->Write();
  delete tree;
  delete f;
  return 0;
}

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-08-15 12:31:59, 11.7 KB) [[attachment:DrawKTUY05DripLine.C]]
  • [get | view] (2011-08-15 12:30:05, 4.2 KB) [[attachment:DrawStableNuclei.C]]
  • [get | view] (2011-08-15 10:52:12, 0.4 KB) [[attachment:Ini.C]]
  • [get | view] (2011-08-15 11:22:39, 423.9 KB) [[attachment:KTUY05_m246.dat]]
  • [get | view] (2011-08-15 11:21:45, 13.3 KB) [[attachment:KTUY05_m246.png]]
  • [get | view] (2011-08-15 11:19:56, 325.8 KB) [[attachment:KTUY05_m246.root]]
  • [get | view] (2011-08-15 12:44:15, 14.4 KB) [[attachment:KTUY_stable.png]]
  • [get | view] (2011-08-15 12:44:47, 9.9 KB) [[attachment:KTUYdl_stable.png]]
  • [get | view] (2011-08-15 11:40:48, 37.7 KB) [[attachment:LiseMassExcess.png]]
  • [get | view] (2011-08-15 11:55:08, 14.6 KB) [[attachment:LiseMassExcessType.png]]
  • [get | view] (2011-08-15 11:19:33, 3.1 KB) [[attachment:MakeKTUY05RootFile.C]]
  • [get | view] (2011-08-15 10:53:14, 1.2 KB) [[attachment:MakeStableNucleiRootFile.C]]
  • [get | view] (2011-08-11 17:37:50, 25.6 KB) [[attachment:NuclearWalletCardsSearch_GetStableNuclei.png]]
  • [get | view] (2011-09-03 04:16:45, 1.2 KB) [[attachment:PlotKTUY.C]]
  • [get | view] (2011-08-15 10:53:26, 0.5 KB) [[attachment:PlotStable.C]]
  • [get | view] (2011-08-15 10:49:44, 8.6 KB) [[attachment:StableNuclei.png]]
  • [get | view] (2011-08-15 10:53:40, 6.0 KB) [[attachment:StableNuclei.root]]
  • [get | view] (2011-08-11 17:50:57, 36.5 KB) [[attachment:StableNuclei.txt]]
  • [get | view] (2013-11-01 17:25:58, 15.2 KB) [[attachment:evenz_oddn_jpi.dat]]
  • [get | view] (2013-11-01 08:50:14, 12.0 KB) [[attachment:first2plus.dat]]
  • [get | view] (2013-11-01 09:06:27, 43.2 KB) [[attachment:first2plus_ss.png]]
  • [get | view] (2013-11-01 17:25:07, 14.7 KB) [[attachment:oddz_evenn_jpi.dat]]
  • [get | view] (2013-11-01 17:26:05, 2.0 KB) [[attachment:plot_evenz_oddn_jpi.C]]
  • [get | view] (2013-11-01 17:26:10, 11.9 KB) [[attachment:plot_evenz_oddn_jpi.png]]
  • [get | view] (2013-11-01 08:49:50, 1.5 KB) [[attachment:plot_first2plus.C]]
  • [get | view] (2013-11-01 08:50:03, 11.5 KB) [[attachment:plot_first2plus.png]]
  • [get | view] (2013-11-01 17:25:18, 2.0 KB) [[attachment:plot_oddz_evenn_jpi.C]]
  • [get | view] (2013-11-01 17:25:23, 11.8 KB) [[attachment:plot_oddz_evenn_jpi.png]]

You are not allowed to attach a file to this page.