void DataRetrieval :: formatOutput(vector<string>& lines) 
	{
		int count=0;
		string particleType ="UNKNOWN";
		for(int i=0;i<lines.size();i++)
		{
			string line = lines[i];


 			if (( (line.find("track") != string::npos) || (line.find("----------------------------------------------------------")!= string::npos) ) && (i+1<lines.size()))
 			{
 				ParticleInformation currParticle;

				if(!(lines[i+1].compare("ELECTRON") ) || !(lines[i+1].compare("PION")))
				{
					particleType =lines[i+1];
					currParticle.setType(particleType); 	 //constructor call
					cout << lines[i+1] << endl;
					i=i+2;
				}
				else
				{
					if((i+1<lines.size()) && (lines[i+1].find("sum") != string::npos ) )
					{
						currParticle.setType(particleType); 	 //constructor call
						i=i+1;
					}
					else
						i++;
				}

				int j=i;
				while(lines[j].find("sum") != string::npos)
				{
					vector<string> parts = split(lines[j], ' ');

					for(int a=1;a<28;a++)
					{	
						currParticle.addTimebin(a-1, atoi(parts[a].c_str()));
					}
				  	j++;
				 }
				 i=j-1;
				 
				
				
				if(currParticle.getType()!=("UNKNOWN"))
				{
					particle.push_back(currParticle);
					cout << pidParticle[count].getPID() << endl;
					//System.out.println(pidParticle[count].getPID());
					count++;
				}
 			}
		}
	}
	void DataRetrieval :: formatData(vector<string>& lines) // need to still save the event number and track number
	{
		string particleType ="UNKNOWN";
		for(int i=0;i<lines.size();i++)
		{
			string line = lines[i];


 			if (( (line.find("track") != string::npos) || (line.find("----------------------------------------------------------")!= string::npos) ) && (i+1<lines.size()))
 			{
 				ParticleInformation currParticle;
				if(!(lines[i+1].compare("ELECTRON") ) || !(lines[i+1].compare("PION")))
				{
					particleType =lines[i+1];
					currParticle.setType(particleType); 	 //constructor call
					i=i+2;
				}
				else
				{
					if((i+1<lines.size()) && (lines[i+1].find("sum") != string::npos ) )
					{
						currParticle.setType(particleType); 	 //constructor call
						i=i+1;
					}
					else
						i++;
				}

				int j=i;
				while(lines[j].find("sum") != string::npos)
				{
					//cout<< lines[i] << endl;	// THIS LINE SPOTS FOR ERRORS

					vector<string> parts = split(lines[j], ' ');
					// cout << parts.size() << endl;
					// for(int d=0;d<parts.size();d++)
					// {
					// 	cout << " "<< parts[d];
					// }
					// cout << endl;
					for(int a=1;a<28;a++)
					{
						//cout << " "<<  atoi(parts[a].c_str());
						currParticle.addTimebin(a-1, atoi(parts[a].c_str()));
					}
					//cout << endl;
				  	j++;
				 }
				 i=j-1;
				
				if(currParticle.getType()!=("UNKNOWN"))
					particle.push_back(currParticle);
 			}
		}
	}
	/*
	Filling target neurons
	*/
	void fillTargets(ParticleInformation &particle, NeuronLayers& neuronLayers)
	{
		if(particle.getType()==("ELECTRON"))
		{
			neuronLayers.setTarget((float) 1, 0);	//electron
			neuronLayers.setTarget((float) 0, 1);	//pion
		}
		else
		{
			neuronLayers.setTarget((float) 0, 0);	//electron
			neuronLayers.setTarget((float) 1, 1);	//pion
		}
	}
	/*
		Makes PID Histogram
	*/
	float makeNeuralNetworkHistogram(int begin, int end, bool print)
	{
		int histogram_4ELECTRON[16][16];
		for(int i=0;i<16;i++)
			std::fill(histogram_4ELECTRON[i], histogram_4ELECTRON[i]+16,0);
		
		int histogram_4PION[16][16];
		for(int i=0;i<16;i++)
			std::fill(histogram_4PION[i], histogram_4PION[i]+16,0);
		
		int totalE=0;
		int totalP=0;

		for(int i=begin;i<end;i++)
		{
			ParticleInformation particle = particles[i];

			string type = particle.getType();
			if(type==("ELECTRON"))
			{
				histogram_4ELECTRON[particle.getPID4_electron()][particle.getPID4_pion()]++;
				totalE++;
			}
			else if(type==("PION"))
			{
				histogram_4PION[particle.getPID4_electron()][particle.getPID4_pion()]++;
				totalP++;
			}
		}

		if(print)
		{
			cout << "Electron Histogram" << endl;
			for(int i=15;i>=0;i--)
			{
				for(int j=0;j<16;j++)
				{
					cout << "\t" <<histogram_4ELECTRON[i][j];
				}
				cout << endl;
			}
			cout<< endl;
			

			cout << "Pion Histogram" << endl;
			for(int i=15;i>=0;i--)
			{
				for(int j=0;j<16;j++)
					cout << "\t" <<histogram_4PION[i][j];
				cout << endl;
			}
			cout<< endl;
		}

		int partNintyE=totalE*0.9;
		int indexOfNintyE;
		int indexOfNintyP;
		int countingE=0;
		for(int i=15;i>=0;i--)
		{
			for(int j=0;j<16;j++)
			{
				countingE+=histogram_4ELECTRON[i][j];
				//clog << " "<< countingE;

				if(countingE>=partNintyE)
				{
	//				clog << " "<< countingE;
					//clog << " " << i << " " << j;
					indexOfNintyE=i;
					indexOfNintyP=j;
					break;
				}
			}
			if(countingE>=partNintyE)
			{
				break;
			}

		}

		int pionsMisidentified=0;
	//	clog << " BLOCKS:  "<<indexOfNintyE << " " << indexOfNintyP <<  " ";
 
		for(int i=15;i>=indexOfNintyE;i--)
		{
			for(int j=0;j<indexOfNintyP;j++)
			{
				pionsMisidentified+=histogram_4PION[i][j];
			}
		}


		return (pionsMisidentified/(float)(totalP));
	}