Solenoid effect in 200 MeV and up range
Jump to navigation
Jump to search
Program
void Effects_MeV() { struct evt_t { Int_t event; Float_t KE; Float_t shift; }; ifstream in; evt_t evt; double E,delta_phi; Int_t nlines=0; float Base_Number1,Base_Number2,Base_Number3,Base_Number4,Base_Number5=0; float normal1,normal2,normal3,normal4,normal5; float neg5T_number1,neg5T_number2,neg5T_number3,neg5T_number4,neg5T_number5; float pos5T_number1,pos5T_number2,pos5T_number3,pos5T_number4,pos5T_number5; float neg25T_number1,neg25T_number2,neg25T_number3,neg25T_number4,neg25T_number5; float pos25T_number1,pos25T_number2,pos25T_number3,pos25T_number4,pos25T_number5; float pos6T_number1,pos6T_number2,pos6T_number3,pos6T_number4,pos6T_number5; float pos4T_number1,pos4T_number2,pos4T_number3,pos4T_number4,pos4T_number5; float avg_0T,avg_pos5T,avg_neg5T,avg_neg25T,avg_pos25T,avg_pos4T,avg_pos6T; float total_0T,total_pos5T,total_neg5T,total_pos25T,total_neg25T,total_pos4T,total_pos6T; float stderror_0T,stderror_pos5T,stderror_neg5T,stderror_pos25T,stderror_neg25T,stderror_pos4T,stderror_pos6T; TFile *f = new TFile("Phi_Shift_counts.root","RECREATE"); TTree *tree = new TTree("Phi_Shift_counts","Phi Shift counts wrt 0T"); TH2F *Normalized_count= new TH2F("Normalized_count","Phi Shift ratios wrt 0T vs. B",30,-7.5,7.5,40,0,2); Normalized_count->GetXaxis()->SetTitle("Magnetic Field (T) "); Normalized_count->GetYaxis()->SetTitle("Ratio of Phi shifts wrt 0T (26030) "); // //Count entries from 0T // in.open("Energy_Phi_Shift_MeV_0T_1.dat"); tree->Branch("evt",&evt.event,"event/I:KE/F:shift"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } Base_Number1=nlines; normal1=Base_Number1/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_0T_2.dat"); tree->Branch("evt",&evt.event,"event/I:KE/F:shift"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } Base_Number2=nlines; normal2=Base_Number2/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_0T_3.dat"); tree->Branch("evt",&evt.event,"event/I:KE/F:shift"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } Base_Number3=nlines; normal3=Base_Number3/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_0T_4.dat"); tree->Branch("evt",&evt.event,"event/I:KE/F:shift"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } Base_Number4=nlines; normal4=Base_Number4/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_0T_5.dat"); tree->Branch("evt",&evt.event,"event/I:KE/F:shift"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } Base_Number5=nlines; normal5=Base_Number5/Base_Number5; nlines=0; in.close(); // // Normalize the -5T file // in.open("Energy_Phi_Shift_MeV_neg5T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg5T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg5T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg5T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg5T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg5T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg5T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg5T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg5T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg5T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Normalize the 5T file // in.open("Energy_Phi_Shift_MeV_pos5T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos5T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos5T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos5T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos5T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos5T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos5T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos5T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos5T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos5T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Normalize the -2.5T file // in.open("Energy_Phi_Shift_MeV_neg25T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg25T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg25T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg25T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg25T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg25T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg25T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg25T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_neg25T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } neg25T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Normalize the 2.5T file // in.open("Energy_Phi_Shift_MeV_pos25T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos25T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos25T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos25T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos25T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos25T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos25T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos25T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos25T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos25T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Normalize the 6T file // in.open("Energy_Phi_Shift_MeV_pos6T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos6T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos6T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos6T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos6T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos6T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos6T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos6T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos6T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos6T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Normalize the 4T file // in.open("Energy_Phi_Shift_MeV_pos4T_1.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos4T_number1=nlines/Base_Number1; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos4T_2.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos4T_number2=nlines/Base_Number2; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos4T_3.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos4T_number3=nlines/Base_Number3; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos4T_4.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos4T_number4=nlines/Base_Number4; nlines=0; in.close(); in.open("Energy_Phi_Shift_MeV_pos4T_5.dat"); while(in.good()) { evt.event=nlines; in >> evt.KE >> evt.shift; nlines++; } pos4T_number5=nlines/Base_Number5; nlines=0; in.close(); // // Calculate the error bars // // B=0T total_0T=normal1+normal2+normal3+normal4+normal5; avg_0T=total_0T/5; // B=5T total_pos5T=pos5T_number1+pos5T_number2+pos5T_number3+pos5T_number4+pos5T_number5; avg_pos5T=total_pos5T/5; // B=-5T total_neg5T=neg5T_number1+neg5T_number2+neg5T_number3+neg5T_number4+neg5T_number5; avg_neg5T=total_neg5T/5; // B=2.5T total_pos25T=pos25T_number1+pos25T_number2+pos25T_number3+pos25T_number4+pos25T_number5; avg_pos25T=total_pos25T/5; // B=-2.5T total_neg25T=neg25T_number1+neg25T_number2+neg25T_number3+neg25T_number4+neg25T_number5; avg_neg25T=total_neg25T/5; // B=4T total_pos4T=pos4T_number1+pos4T_number2+pos4T_number3+pos4T_number4+pos4T_number5; avg_pos4T=total_pos4T/5; // B=6T total_pos6T=pos6T_number1+pos6T_number2+pos6T_number3+pos6T_number4+pos6T_number5; avg_pos6T=total_pos6T/5; stderror_0T=0; stderror_0T=(normal1-avg_0T)*(normal1-avg_0T)+stderror_0T; stderror_0T=0; stderror_0T=(normal1-avg_0T)*(normal1-avg_0T)+stderror_0T; stderror_0T=(normal2-avg_0T)*(normal2-avg_0T)+stderror_0T; stderror_0T=(normal3-avg_0T)*(normal3-avg_0T)+stderror_0T; stderror_0T=(normal4-avg_0T)*(normal4-avg_0T)+stderror_0T; stderror_0T=(normal5-avg_0T)*(normal5-avg_0T)+stderror_0T; stderror_0T=sqrt(stderror_0T); stderror_0T=stderror_0T/4; stderror_pos5T=0; stderror_pos5T=(pos5T_number1-avg_pos5T)*(pos5T_number1-avg_pos5T)+stderror_pos5T; stderror_pos5T=(pos5T_number2-avg_pos5T)*(pos5T_number2-avg_pos5T)+stderror_pos5T; stderror_pos5T=(pos5T_number3-avg_pos5T)*(pos5T_number3-avg_pos5T)+stderror_pos5T; stderror_pos5T=(pos5T_number4-avg_pos5T)*(pos5T_number4-avg_pos5T)+stderror_pos5T; stderror_pos5T=(pos5T_number5-avg_pos5T)*(pos5T_number5-avg_pos5T)+stderror_pos5T; stderror_pos5T=sqrt(stderror_pos5T); stderror_pos5T=stderror_pos5T/4; stderror_neg5T=0; stderror_neg5T=(neg5T_number1-avg_neg5T)*(neg5T_number1-avg_neg5T)+stderror_neg25T; stderror_neg5T=(neg5T_number1-avg_neg5T)*(neg5T_number1-avg_neg5T)+stderror_neg25T; stderror_neg5T=(neg5T_number1-avg_neg5T)*(neg5T_number1-avg_neg5T)+stderror_neg25T; stderror_neg5T=(neg5T_number1-avg_neg5T)*(neg5T_number1-avg_neg5T)+stderror_neg25T; stderror_neg5T=(neg5T_number1-avg_neg5T)*(neg5T_number1-avg_neg5T)+stderror_neg25T; stderror_neg5T=sqrt(stderror_neg5T); stderror_neg5T=stderror_neg5T/4; stderror_neg25T=0; stderror_neg25T=(neg25T_number1-avg_neg25T)*(neg25T_number1-avg_neg25T)+stderror_neg25T; stderror_neg25T=(neg25T_number2-avg_neg25T)*(neg25T_number2-avg_neg25T)+stderror_neg25T; stderror_neg25T=(neg25T_number3-avg_neg25T)*(neg25T_number3-avg_neg25T)+stderror_neg25T; stderror_neg25T=(neg25T_number4-avg_neg25T)*(neg25T_number4-avg_neg25T)+stderror_neg25T; stderror_neg25T=(neg25T_number5-avg_neg25T)*(neg25T_number5-avg_neg25T)+stderror_neg25T; stderror_neg25T=sqrt(stderror_neg25T); stderror_neg25T=stderror_neg25T/4; stderror_pos25T=0; stderror_pos25T=(pos25T_number1-avg_pos25T)*(pos25T_number1-avg_pos25T)+stderror_pos25T; stderror_pos25T=(pos25T_number2-avg_pos25T)*(pos25T_number2-avg_pos25T)+stderror_pos25T; stderror_pos25T=(pos25T_number3-avg_pos25T)*(pos25T_number3-avg_pos25T)+stderror_pos25T; stderror_pos25T=(pos25T_number4-avg_pos25T)*(pos25T_number4-avg_pos25T)+stderror_pos25T; stderror_pos25T=(pos25T_number5-avg_pos25T)*(pos25T_number5-avg_pos25T)+stderror_pos25T; stderror_pos25T=sqrt(stderror_pos25T); stderror_pos25T=stderror_pos25T/4; stderror_pos4T=0; stderror_pos4T=(pos4T_number1-avg_pos4T)*(pos4T_number1-avg_pos4T)+stderror_pos4T; stderror_pos4T=(pos4T_number2-avg_pos4T)*(pos4T_number2-avg_pos4T)+stderror_pos4T; stderror_pos4T=(pos4T_number3-avg_pos4T)*(pos4T_number3-avg_pos4T)+stderror_pos4T; stderror_pos4T=(pos4T_number4-avg_pos4T)*(pos4T_number4-avg_pos4T)+stderror_pos4T; stderror_pos4T=(pos4T_number5-avg_pos4T)*(pos4T_number5-avg_pos4T)+stderror_pos4T; stderror_pos4T=sqrt(stderror_pos4T); stderror_pos4T=stderror_pos4T/4; stderror_pos6T=0; stderror_pos6T=(pos6T_number1-avg_pos6T)*(pos6T_number1-avg_pos6T)+stderror_pos6T; stderror_pos6T=(pos6T_number2-avg_pos6T)*(pos6T_number2-avg_pos6T)+stderror_pos6T; stderror_pos6T=(pos6T_number3-avg_pos6T)*(pos6T_number3-avg_pos6T)+stderror_pos6T; stderror_pos6T=(pos6T_number4-avg_pos6T)*(pos6T_number4-avg_pos6T)+stderror_pos6T; stderror_pos6T=(pos6T_number5-avg_pos6T)*(pos6T_number5-avg_pos6T)+stderror_pos6T; stderror_pos6T=sqrt(stderror_pos6T); stderror_pos6T=stderror_pos6T/4; // Make an xmgrace file fprintf(stdout,"%d %g %g\n",-5,avg_neg5T,stderror_neg5T); fprintf(stdout,"%d %g %g\n",-2.5,avg_neg25T,stderror_neg25T); fprintf(stdout,"%d %g %g\n",0,avg_0T,stderror_0T); fprintf(stdout,"%d %g %g\n",2.5,avg_pos25T,stderror_pos25T); fprintf(stdout,"%d %g %g\n",4,avg_pos4T,stderror_pos4T); fprintf(stdout,"%d %g %g\n",5,avg_pos5T,stderror_pos5T); fprintf(stdout,"%d %g %g\n",6,avg_pos6T,stderror_pos6T); // Make a histogram Normalized_count->Fill(-5.0,neg5T_number1); Normalized_count->Fill(-2.5,neg25T_number1); Normalized_count->Fill(0,normal1); Normalized_count->Fill(2.5,pos25T_number1); Normalized_count->Fill(4.0,pos4T_number1); Normalized_count->Fill(5.0,pos5T_number1); Normalized_count->Fill(6.0,pos6T_number1); tree->Print(); tree->Write(); f->Write(); delete tree; delete f; }