File talk:Comparison beam and storage experiments for neutron lifetime measurement.svg
Jump to navigation
Jump to search
Code[edit]
Le code suivant a été utilisé pour générer le graphique avec le logiciel ROOT.
#include <TGraphErrors.h>
#include <TMultiGraph.h>
#include <TMath.h>
#include <TF1.h>
#include <TPad.h>
#include <TPave.h>
#include <TColor.h>
#include <TAxis.h>
#include <TROOT.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <vector>
using namespace std;
void neutron() {
gStyle->SetCanvasPreferGL(kTRUE);
vector < double > beam, beamErr, beamErrStat, beamErrSyst, beamYear;
//BYRNE
beamYear.push_back(1996); beam.push_back(889.2); beamErrStat.push_back(3.0); beamErrSyst.push_back(3.8);
// //NICO
// beamYear.push_back(2005); beam.push_back(886.3); beamErrStat.push_back(1.2); beamErrSyst.push_back(3.2);
//YUE
beamYear.push_back(2013); beam.push_back(887.7); beamErrStat.push_back(1.2); beamErrSyst.push_back(1.9);
vector < double > bottle, bottleErr, bottleErrStat, bottleErrSyst, bottleYear;
//MAMPE
bottleYear.push_back(1993); bottle.push_back(882.6); bottleErrStat.push_back(2.7); bottleErrSyst.push_back(0.);
//SEREBROV
bottleYear.push_back(2005); bottle.push_back(878.5); bottleErrStat.push_back(0.7); bottleErrSyst.push_back(0.3);
//PICHLMAIER
bottleYear.push_back(2010); bottle.push_back(880.7); bottleErrStat.push_back(1.3); bottleErrSyst.push_back(1.2);
//STEYERL
bottleYear.push_back(2012.5); bottle.push_back(882.5); bottleErrStat.push_back(1.4); bottleErrSyst.push_back(1.5);
//ARZUMANOV
bottleYear.push_back(2015); bottle.push_back(880.2); bottleErrStat.push_back(1.2); bottleErrSyst.push_back(0.);
// //ARZUMANOV (2012)
// bottleYear.push_back(2012); bottle.push_back(881.6); bottleErrStat.push_back(0.8); bottleErrSyst.push_back(1.9);
TCanvas *c = new TCanvas("c","c",1600,1600);
TMultiGraph *mg = new TMultiGraph();
Color_t colorBeam = gROOT->GetColor(kBlue)->GetNumber();
Color_t colorBottle = gROOT->GetColor(kGreen)->GetNumber();
vector < double > zero;
for(unsigned int i=0 ; i<beamYear.size() ; i++) {
zero.push_back(0.);
beamErr.push_back(TMath::Sqrt(beamErrStat[i]*beamErrStat[i] + beamErrSyst[i]*beamErrSyst[i]));
}
TGraphErrors *gBeam = new TGraphErrors(beamYear.size(), &(beamYear[0]), &(beam[0]), &(zero[0]), &(beamErr[0]));
gBeam->SetLineWidth(4);
gBeam->SetLineColor(colorBeam);
gBeam->SetMarkerStyle(20);
gBeam->SetMarkerSize(2);
gBeam->SetMarkerColor(colorBeam);
mg->Add(gBeam);
zero.clear();
for(unsigned int i=0 ; i<bottleYear.size() ; i++) {
zero.push_back(0.);
bottleErr.push_back(TMath::Sqrt(bottleErrStat[i]*bottleErrStat[i] + bottleErrSyst[i]*bottleErrSyst[i]));
}
TGraphErrors *gBottle = new TGraphErrors(bottleYear.size(), &(bottleYear[0]), &(bottle[0]), &(zero[0]), &(bottleErr[0]));
gBottle->SetLineWidth(4);
gBottle->SetLineColor(colorBottle);
gBottle->SetMarkerStyle(20);
gBottle->SetMarkerSize(2);
gBottle->SetMarkerColor(colorBottle);
mg->Add(gBottle);
mg->Draw("AP");
//on fit pour obtenir la valeur moyenne et l'incertitude
TF1 *fBeam = new TF1("fBeam","pol0",1900,2100);
gBeam->Fit("fBeam","0");
TF1 *fBottle = new TF1("fBottle","pol0",1900,2100);
gBottle->Fit("fBottle","0");
mg->GetYaxis()->SetRangeUser(870.,900.);
mg->GetXaxis()->SetTitle("Année de l'expérience");
mg->GetXaxis()->CenterTitle(true);
mg->GetYaxis()->SetTitle("Durée de vie moyenne du neutron (en secondes)");
mg->GetYaxis()->CenterTitle(true);
//gPad->SetFrameLineColor(kWhite);
gPad->Update();
// on affiche un rectangle de valeurs probables
TPave *pBeam = new TPave(mg->GetXaxis()->GetXmin(),
fBeam->GetParameter(0) - fBeam->GetParError(0),
mg->GetXaxis()->GetXmax(),
fBeam->GetParameter(0) + fBeam->GetParError(0),
0.);
pBeam->SetFillColorAlpha(colorBeam,0.4);
pBeam->Draw();
TPave *pBottle = new TPave(mg->GetXaxis()->GetXmin(),
fBottle->GetParameter(0) - fBottle->GetParError(0),
mg->GetXaxis()->GetXmax(),
fBottle->GetParameter(0) + fBottle->GetParError(0),
0.);
pBottle->SetFillColorAlpha(colorBottle,0.4);
pBottle->Draw();
}