I am trying to create a text file and then fill it. I have never done this before but I looked around and I got a text file created, however, it only puts the column labels. I want the first column to be filled with the variable A and the second one to be filled with the variable Z. Here is what I have:
void analysis(int index=0){
TChain *chain = new TChain("EICTree"); //Au-197
chain->Add("eD/eD_0.root");
chain->Add("eD/eD_1.root");
chain->Add("eD/eD_2.root");
chain->SetBranchAddress("event",&event);
Int_t nevents = chain->GetEntries();
//Create text file
ofstream myfile;
myfile.open("Measured-Isotopes.txt");
myfile << "A Z\n";
int A(0),Z(0);
for(int j=0;j<nParticles;j++){
particle_eA = particle->eA;
A = particle_eA->massNum;
Z = particle_eA->charge;
if(id >= 80000 && Status == 1000){
cout << A << " " << Z << endl;
myfile << A << " " << Z << "\n";
}
myfile.close();
}
I left out some stuff that doesn’t really relate to this issue. I am just having trouble filling the text file with the actual data.