#include <iostream>
#include <fstream>
//#include <scientific>

using namespace std;

main ()
{

   ifstream in;
   ifstream in1;
   ofstream out;
  
 
  out.open("electrons.dat");
   double x,y,z,electronenergydeposit,gammaenergy; 
   int nlines = 0,nlines1=0,electronparent,electrontrack,electronevent,electronevent0=-1,gammaevent=-1,gammatrack,gammaparent,stepNo,process,creatNum;
long pos, poscurrentevent=0, posnextevent=-1;
 //  TFile *f = new TFile("Depos.root","RECREATE");
  // TFile *f1 = new TFile("gammas.root","RECREATE");
  in.open("Depos.dat");
 in1.open("gammas.dat");
  
    while (!in.eof()) {
in>>electronevent>>x>>y>>z>>electronparent>>electrontrack>>electronenergydeposit;

if (electronevent==electronevent0) in1.seekg(poscurrentevent);

if (electronevent>electronevent0) { 
if (gammaevent>0) in1.seekg(posnextevent);
while (!in1.eof()) {
pos=in1.tellg();
in1 >>gammaevent>>gammatrack>>gammaparent>>gammaenergy;
if (gammaevent>electronevent) {
if (electronevent>0) poscurrentevent=posnextevent;
posnextevent=pos;break;
}
}
}

electronevent0=electronevent;

int check=0;
in1.seekg(poscurrentevent);
while (!in1.eof()) {
pos=in1.tellg();
 in1 >>gammaevent>>gammatrack>>gammaparent>>gammaenergy;
if (pos==posnextevent) break;
 if (electronevent == gammaevent && gammatrack == electronparent)
{
if ( check > 0 ) break;

out << scientific<<electronevent<<  "        " <<x <<  "        " <<y<< "       "<<z << "       " <<electronparent<< "     "<< electrontrack << "     " <<electronenergydeposit  <<endl;


check++;

}

nlines1++;

}
 
nlines++;

//cout << electronevent << "     "<< nlines << "    " << nlines1 << endl;

cout << electronevent << endl;
}


 
in.close();
in1.close();
out.close();
}
William Hemsworth commented: As bad as it gets. -1

Help you do what??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.