示例#1
0
void PIDStudy::InitializeFits()
{

	for (int multBin = 0; multBin < nMultiplicityBins; multBin++)
	for (int PBin=0; PBin < nPBins_lin; PBin++)
	{	


		TF1 pion("pion", "gaus(0)", 2.0, 4.0);
		pion.SetParameter(0,10000);
		pion.SetParameter(1,2.8);
		pion.SetParameter(2,0.2);

		TF1 kaon("kaon", "gaus(0)", 3.0, 6.0);
		kaon.SetParameter(0,2000);
		kaon.SetParameter(1,4);
		kaon.SetParameter(2,0.2);

		TF1 prot("prot", "gaus(0)", 5.0, 8.0);
		prot.SetParameter(0,1000);
		prot.SetParameter(1,7);
		prot.SetParameter(2,0.4);

		// "R" means only using fit range.
		//dEdxDistr_log[multBin][PBin]->Fit(&pion, "R");
		//dEdxDistr_log[multBin][PBin]->Fit(&kaon, "R");
		//dEdxDistr_log[multBin][PBin]->Fit(&prot, "R");

		double pion_amp = pion.GetParameter(0);
		double pion_pos = pion.GetParameter(1);
		double pion_sig = pion.GetParameter(2);

		double kaon_amp = kaon.GetParameter(0);
		double kaon_pos = kaon.GetParameter(1);
		double kaon_sig = kaon.GetParameter(2);

		double prot_amp = prot.GetParameter(0);
		double prot_pos = prot.GetParameter(1);
		double prot_sig = prot.GetParameter(2);

 	   // Pion
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(0,pion_amp);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(1,pion_pos);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(2,pion_sig);

		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(3,kaon_amp);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(4,kaon_pos);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(5,kaon_sig);

		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(6,prot_amp);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(7,prot_pos);
		dEdxDistr_log_Fit[multBin][PBin]->SetParameter(8,prot_sig);
	}

}
void drawing_pion_decay(){

	double Pi_lifetime = 0.26033e-6; //s
	double c = 3e8;//m/s
	TCanvas *c1 = new TCanvas("test", "test");
	TRandom *r = new TRandom();
	

	TView *view = TView::CreateView(1, 0, 0);
	view->ShowAxis();
	view->SetRange(-5, -5, 0, 5, 5, 10);
	
	

	for (int i = 0; i < 100; ++i)
	{
		double px = 0.3;
		double py = 0.3;
		double pz = -1; // GeV
		double energy = sqrt(px*px+py*py+pz*pz+M_pion*M_pion);
		
		//life time
		double t = r->Exp(Pi_lifetime);
		//decay length
		double gamma = energy/M_pion;
		double length = c*t*gamma/1e3;
		// decay position
		double vx = 0;
		double vy = 0;
		double vz = 10 - length;

		TLorentzVector pion(px, py, pz, energy);

		double decay_particle_mass[2] = {M_muon, M_neu};
		TGenPhaseSpace event;
		event.SetDecay(pion, 2, decay_particle_mass);
		event.Generate();

		TLorentzVector Muon = *(event.GetDecay(0));
		TLorentzVector Neu = *(event.GetDecay(1));
		
		plot_particle(Muon, vx, vy, vz, 2);
		plot_particle(Neu, vx, vy, vz, 4);


	}


}
示例#3
0
文件: .C 项目: TuringTW/ntu_2015_fall
void recursive_inter_with_air(){
	TFile *f1 = new TFile("muon.root", "recreate");
	TCanvas *c1 = new TCanvas("test", "test", 600, 700);

	TH1F * mu_c_1 = new TH1F("mu_c_1", "mu_c_1", 100, 0, 500);
	TH1F * mu_c_2 = new TH1F("mu_c_2", "mu_c_2", 100, 0, 500);
	TH1F * mu_c_3 = new TH1F("mu_c_3", "mu_c_3", 100, 0, 500);

	fn_muon_dxde = new TF1("f1", dxde_muon, M_mu, 1000, 1);
	TNtuple * ntuple = new TNtuple("ntuple", "ntuple", "nobs:detz:theta:press");
	// TNtuple *ntuple = new TNtuple("ntuple", "ntuple", "id:flag:e:px:py:pz:x:y:z");
	r = new TRandom();
	// r ->SetSeed(12232);
	for (int ievertex_nt = 0; ievertex_nt < 500; ievertex_nt++)
	{
		n_particle = 0;

		// init muon conunter
		int mu_counter1 = 0;
		int mu_counter2 = 0;
		int mu_counter3 = 0;

		double E = 1000; // GeV
		double theta = 0;
		// double theta = acos(r->Rndm());
		double phi = r->Rndm()*pi*2;
		double x = 0, y = 0, z = 1.0e10; //infinity
		double vertex_z, vertex_x, vertex_y; //km

		

		Get_Int_Posi(pdg_proton_p, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z);

		Hillas_Split(pdg_proton_p, E, theta, phi, vertex_x, vertex_y, vertex_z);

		double proton_threshold = 10;
		double pion_threshold = 10;
		int i_particle = 0;
		while(i_particle < n_particle){
			int id = Ptcl_bank[i_particle].id;
			int flag = Ptcl_bank[i_particle].flag;
			double e = Ptcl_bank[i_particle].e;
			double x = Ptcl_bank[i_particle].vertex_x;
			double y = Ptcl_bank[i_particle].vertex_y;
			double z = Ptcl_bank[i_particle].vertex_z;
			if (id == pdg_proton_p && flag == 1 && e > proton_threshold)
			{
				Get_Int_Posi(id, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z);
				if (vertex_z > 0)
				{
					Hillas_Split(id, e, theta, phi, vertex_x, vertex_y, vertex_z);
					Ptcl_bank[i_particle].flag = 0;
				}
			}
			if (id == pdg_pion_p &&flag == 1){

				Get_Int_Posi(id, theta, phi, x, y, z, vertex_x, vertex_y, vertex_z)	;			
				double l_to_interaction = sqrt((vertex_x-x)*(vertex_x-x)+(vertex_y-y)*(vertex_y-y)+(vertex_z-z)*(vertex_z-z));
				double l_to_decay = get_decay_length(pdg_pion_p, tau_pion, e);
				
				if (l_to_decay>l_to_interaction){
					if (vertex_z > 0){
						Hillas_Split(id, e, theta, phi, vertex_x, vertex_y, vertex_z);
						Ptcl_bank[i_particle].flag = 0;
					}
				}else{ // pion decay
					Ptcl_bank[i_particle].flag = 0;
					double px = Ptcl_bank[i_particle].px;
					double py = Ptcl_bank[i_particle].py;
					double pz = Ptcl_bank[i_particle].pz; // GeV
					TLorentzVector pion(px, py, pz, e);
					double decay_particle_mass[2] = {M_mu, M_neu};
					TGenPhaseSpace event;
					event.SetDecay(pion, 2, decay_particle_mass);
					event.Generate();
					TLorentzVector Muon = *(event.GetDecay(0));
					TLorentzVector Neu = *(event.GetDecay(1));

					double mu_theta = Muon.Theta();
					double mu_phi = Muon.Phi();
					
					if (mu_theta>pi/2.)	{
						double mu_E = Muon.E();
						double muon_decay_time = r ->Exp(tau_muon);
						double muon_decay_length = get_decay_length(pdg_muon_n, tau_muon, mu_E);

						float det_x = 0;
						float det_y = 0;
						float det_z = 0;
						mu_counter1++;
						double l_mu_vtx_to_det = sqrt(pow(vertex_x-det_x,2)+pow(vertex_y-det_y,2)+pow(vertex_z-det_z,2));
						// cout << "MuE" << mu_E << " Mass" <<M_mu<< " dl" << muon_decay_length << " lvd" << l_mu_vtx_to_det << endl;
						if (muon_decay_length > l_mu_vtx_to_det)	
						{
							mu_counter2++;

							double mu_stop_x;
							double mu_stop_y;
							double mu_stop_z;

							get_muon_stop_position(mu_E, mu_theta, mu_phi, vertex_x, vertex_y, vertex_z, mu_stop_x, mu_stop_y, mu_stop_z);
							double l_muon_stop = sqrt(pow(vertex_x-mu_stop_x,2)+pow(vertex_y-mu_stop_y,2)+pow(vertex_z-mu_stop_z,2));
							// cout << l_muon_stop << " " << l_mu_vtx_to_det <<endl;
							if (l_muon_stop > l_mu_vtx_to_det)
							{
								mu_counter3++;
							}
							
							
						}
					}
				}
			}
			i_particle++;
		}
		mu_c_1 ->Fill(mu_counter1);
		mu_c_2 ->Fill(mu_counter2);
		mu_c_3 ->Fill(mu_counter3);

		// for (int i_particle = 0; i_particle < n_particle; ++i_particle){
		// 	int id = Ptcl_bank[i_particle].id;
		// 	int flag = Ptcl_bank[i_particle].flag;
		// 	double e = Ptcl_bank[i_particle].e;
		// 	double px = Ptcl_bank[i_particle].px;
		// 	double py = Ptcl_bank[i_particle].py;
		// 	double pz = Ptcl_bank[i_particle].pz;
		// 	double x = Ptcl_bank[i_particle].vertex_x;
		// 	double y = Ptcl_bank[i_particle].vertex_y;
		// 	double z = Ptcl_bank[i_particle].vertex_z;
		// 	ntuple->Fill(id, flag, e, px, py, pz, x, y, z);
		// }
	}

	mu_c_3 ->Draw();
	mu_c_2 ->SetLineColor(2);
	mu_c_2 ->Draw("same");
	mu_c_1 ->SetLineColor(4);
	mu_c_1 ->Draw("same");
	// ntuple->Draw("z");
}