コード例 #1
0
	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++;
				}
 			}
		}
	}
コード例 #2
0
void SaveParticlesTrackingAction::PostUserTrackingAction(const G4Track* aTrack) {
  if ( aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID()==0) {
    const G4DynamicParticle* g4dynamicparticle = aTrack->GetDynamicParticle();
    ParticleInformation* info = dynamic_cast<ParticleInformation*>(g4dynamicparticle->GetPrimaryParticle()->GetUserInformation());
    info->setEndStatus(1); // how it is defined ???? as in HepMC ?
    info->setEndMomentum(g4dynamicparticle->GetMomentum()*sim::g42edm::energy);
    info->setVertexPosition( aTrack->GetVertexPosition()*sim::g42edm::length);
  }
  return;
}
コード例 #3
0
	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);
 			}
		}
	}
コード例 #4
0
	void fillInputs(ParticleInformation &particle, NeuronLayers& neuronLayers)
	{
		for(int j=0;j<27;j++)
		{
			float sum=0;
			if(particle.getTimeBin()[j]<400)
			 	sum=particle.getTimeBin()[j]/ (float)( 400 );
			else
				sum=1;

			neuronLayers.fillInputNeuron(j, sum);
		}
	}
コード例 #5
0
	/*
	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
		}
	}
コード例 #6
0
void FastSimModelTracker::DoIt(const G4FastTrack& aFastTrack,
                               G4FastStep& aFastStep) {
  // Calculate the position of the particle at the end of volume
  const G4Track* track = aFastTrack.GetPrimaryTrack();
  G4ThreeVector spin = track->GetPolarization() ;
  G4FieldTrack aFieldTrack('t');
  G4FieldTrackUpdator::Update(&aFieldTrack,track);
  G4double retSafety= -1.0;
  ELimited retStepLimited;
  G4FieldTrack endTrack('a');
  G4double currentMinimumStep= 10*m; // TODO change that to sth connected to particle momentum and geometry
  G4PathFinder* fPathFinder = G4PathFinder::GetInstance();
  fPathFinder->ComputeStep( aFieldTrack,
                            currentMinimumStep,
                            0,
                            track->GetCurrentStepNumber(),
                            retSafety,
                            retStepLimited,
                            endTrack,
                            track->GetVolume() );
  aFastStep.ProposePrimaryTrackFinalPosition( endTrack.GetPosition() );

  // Smear particle's momentum according to the tracker resolution
  G4ThreeVector Psm = track->GetMomentum();
  m_smearTool->smearMomentum(Psm);
  G4ThreeVector DeltaP = track->GetMomentum() - Psm;
  G4double Ekinorg = track->GetKineticEnergy();
  aFastStep.ClearDebugFlag(); // to disable Geant checks on energy
  aFastStep.ProposePrimaryTrackFinalKineticEnergyAndDirection(Ekinorg+DeltaP.mag(), Psm.unit());
  // Keep track of smeared momentum
  if(track->GetParentID()==0) {
    ParticleInformation* info = dynamic_cast<ParticleInformation*>(track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
    info->setSmeared(true);
    info->setEndStatus(1); // how it is defined ???? as in HepMC ?
    info->setEndMomentum(Psm);
    info->setVertexPosition( track->GetVertexPosition());
  }
}
コード例 #7
0
	/*
		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));
	}