#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();
}

Edited 7 Years Ago by peter_budo: Please do not use CODE SNIPPED option to post your questions. Use FORUM THREAD

Comments
As bad as it gets.
This article has been dead for over six months. Start a new discussion instead.