Skip to content
Snippets Groups Projects
Commit b0e86bdf authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

Merge branch 'NPTool.2.dev' of gitlab.in2p3.fr:np/nptool into NPTool.2.dev

parents 1e2f9028 9dbc8211
No related branches found
No related tags found
No related merge requests found
Pipeline #122864 passed
...@@ -160,6 +160,9 @@ class TMinosPhysics : public TObject, public NPL::VDetector { ...@@ -160,6 +160,9 @@ class TMinosPhysics : public TObject, public NPL::VDetector {
double GetVertexX() {return X_Vertex;} //! double GetVertexX() {return X_Vertex;} //!
double GetVertexY() {return Y_Vertex;} //! double GetVertexY() {return Y_Vertex;} //!
double GetVertexZ() {return Z_Vertex;} //! double GetVertexZ() {return Z_Vertex;} //!
double GetDeltaVertex() {return Delta_Vertex;} //!
double GetTheta12() {return Theta_12;} //!
int GetNbrOfTracks(){return Tracks_P0.size();} int GetNbrOfTracks(){return Tracks_P0.size();}
......
...@@ -156,6 +156,11 @@ class TSamuraiHodoscopePhysics : public TObject, public NPL::VDetector { ...@@ -156,6 +156,11 @@ class TSamuraiHodoscopePhysics : public TObject, public NPL::VDetector {
// clear the pre-treated object // clear the pre-treated object
void ClearPreTreatedData() {m_PreTreatedData->Clear();} void ClearPreTreatedData() {m_PreTreatedData->Clear();}
vector <double> GetCharge() {return Charge;}
vector <double> GetTime() {return Time;}
vector<int> GetID() {return ID;}
// give and external TSamuraiHodoscopeData object to TSamuraiHodoscopePhysics. // give and external TSamuraiHodoscopeData object to TSamuraiHodoscopePhysics.
// needed for online analysis for example // needed for online analysis for example
......
...@@ -6,8 +6,10 @@ double devE(const double* parameter){ ...@@ -6,8 +6,10 @@ double devE(const double* parameter){
//Beam spot offset //Beam spot offset
TVector3 offset(parameter[0],parameter[1],parameter[2]); TVector3 offset(parameter[0],parameter[1],parameter[2]);
unsigned int size = pos.size();
//Other variable initilizations
unsigned int size = pos.size();
TVector3 MugastNormal;
double dE,Theta; double dE,Theta;
TVector3 dir; TVector3 dir;
...@@ -25,24 +27,53 @@ double devE(const double* parameter){ ...@@ -25,24 +27,53 @@ double devE(const double* parameter){
//Particle path vector //Particle path vector
dir=*(pos[i])-offset; dir=*(pos[i])-offset;
//Detected energy, and angle of particle leaving target //Define normal vector for the MG# of detection
double Theta= dir.Angle(TVector3(0,0,1)); //[[[[ UPDATE WITH NEW MG POSITIONS FROM SURVEY ]]]]
switch(detnum[i]){
case 1:
MugastNormal.SetXYZ(-0.453915, +0.455463, -0.765842);
break;
case 2:
MugastNormal.SetXYZ(-0.642828, +0.000000, -0.766010);
break;
case 3:
MugastNormal.SetXYZ(-0.454594, -0.450670, -0.768271);
break;
case 4:
MugastNormal.SetXYZ(-0.002437, -0.638751, -0.769409);
break;
case 5:
MugastNormal.SetXYZ(+0.452429, -0.454575, -0.767248);
break;
case 7:
MugastNormal.SetXYZ(+0.443072, +0.443265, -0.779232);
break;
default:
cout << "ERROR:: Invalid DetNum " << detnum[i] << " at event " << i << endl;
return 1; // Exit code
}
//Angle leaving target, angle entering MUGAST & energy deposited in MUGAST
double ThetaTarget = dir.Angle(TVector3(0,0,1));
double ThetaMugast = dir.Angle(MugastNormal);
double Energy = energy[i]; double Energy = energy[i];
//NOTE!!! Not calucualting energy loss in Al??? //Energy loss in Al
Energy=Al.EvaluateInitialEnergy(
Energy, //energy after Al
0.4*micrometer, //thickness of Al
ThetaMugast); //angle impinging on MUGAST
//Energy loss in target //Energy loss in target
Energy=CD2.EvaluateInitialEnergy( Energy=CD2.EvaluateInitialEnergy(
Energy, //energy after leaving target Energy, //energy after leaving target
0.5*parameter[4]*micrometer, //pass through half target 0.5*parameter[3]*micrometer, //pass through half target
Theta); //angle leaving target ThetaTarget); //angle leaving target
//Final value of Ex //Final value of Ex
double Ex = reaction.ReconstructRelativistic(Energy,Theta); double Ex = reaction.ReconstructRelativistic(Energy,ThetaTarget);
//Fill histogram with ERROR in Ex! //Fill histograms with Ex
//h->Fill(Ex-refE); h->Fill(Ex);
h->Fill(Ex);
switch(detnum[i]){ switch(detnum[i]){
case 1: case 1:
h1->Fill(Ex); h1->Fill(Ex);
...@@ -63,70 +94,76 @@ double devE(const double* parameter){ ...@@ -63,70 +94,76 @@ double devE(const double* parameter){
h7->Fill(Ex); h7->Fill(Ex);
break; break;
default: default:
cout << "ERROR! Invalid detnum: " << detnum[i] << " @" << i << endl; cout << "ERROR:: Invalid DetNum " << detnum[i] << " at event " << i << endl;
return 1; // Exit code return 1; // Exit code
} }
} }
//End loop over events //End loop over events
//Write vals to screen //Write vals to screen
cout << "Mean: " << h->GetMean() cout << "Mean: " << h->GetMean()
<< "\t StdDev: " << h->GetStdDev() << "\t StdDev: " << h->GetStdDev()
<< "\t Thickness??: " << parameter[4] << "\t Thickness: " << parameter[3] << " um"
<< endl; << endl;
//Draw histogram(s) //Draw histogram(s)
h->Draw(); h->Draw();
if(flagDraw){ InitiliseCanvas(); } if(flagDraw){ InitiliseCanvas(); }
/*
cout << pow(h->GetMean()-refE,2) << " + "
<< pow(0.1*h->GetStdDev(),2) << " = "
<< pow(h->GetMean()-refE,2) + pow(0.1*h->GetStdDev(),2)
<< endl;
*/
//Adapt the metric as needed //Adapt the metric as needed
return sqrt( pow(h->GetMean()-refE,2) + pow(0.1*h->GetStdDev(),2) ); return sqrt( pow(h->GetMean()-refE,2) + pow(0.1*h->GetStdDev(),2) );
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void MinimizeBeamSpot(){ void MinimizeBeamSpot(){
// Read data in //Read data in
LoadFile(); LoadFile();
// Start with beam (0,0,0) and 4.7um 0.5mg/c2 target //Start with beam (0,0,0) and 4.76um 0.5mg/c2 target
double parameter[4] = {0.0, 0.0, 0.0, 4.7}; double parameter[4] = {0.0, 0.0, 0.0, 4.76};
devE(parameter); devE(parameter);
// Function with 4 parameter XYZ and Target thickness //Function with 4 parameter XYZ and Target thickness
auto func = ROOT::Math::Functor(&devE,4); auto func = ROOT::Math::Functor(&devE,4);
// Minimizer //Minimizer
auto minim = ROOT::Math::Factory::CreateMinimizer("Minuit2","Migrad"); auto minim = ROOT::Math::Factory::CreateMinimizer("Minuit2","Migrad");
minim->SetPrintLevel(0); minim->SetPrintLevel(0);
minim->SetPrecision(1e-10); minim->SetPrecision(1e-10);
// Set minimizer function //Set minimizer function
minim->SetFunction(func); minim->SetFunction(func);
// Assign variable limits //Assign variable limits
minim->SetLimitedVariable(0,"X",parameter[0],0.01,-10,10); minim->SetLimitedVariable(0,"X",parameter[0],0.01,-10,10);
minim->SetLimitedVariable(1,"Y",parameter[1],0.01,-10,10); minim->SetLimitedVariable(1,"Y",parameter[1],0.01,-10,10);
minim->SetLimitedVariable(2,"Z",parameter[2],0.01,-5,5); minim->SetLimitedVariable(2,"Z",parameter[2],0.01,-5,5);
minim->SetLimitedVariable(3,"T",parameter[3],0.01, 4.7-3.0, 4.7+3.0); minim->SetLimitedVariable(3,"T",parameter[3],0.01,4.76*0.5,4.76*1.5);
// Don't draw iterations of minimizer //Don't draw iterations of minimizer
flagDraw = 0; flagDraw = 0;
// Shrink it, babeyyy //Shrink it, babeyyy
minim->Minimize(); minim->Minimize();
// Draw minimal value //Draw minimal value
flagDraw = 1; flagDraw = 1;
// Pull values from minimizer //Pull values from minimizer
const double* x = minim->X(); const double* x = minim->X();
cout << "========================================" << endl; cout << "========================================" << endl;
cout << "\t\tX =" << x[0] << endl; cout << "\t\tX =" << x[0] << endl;
cout << "\t\tY =" << x[1] << endl; cout << "\t\tY =" << x[1] << endl;
cout << "\t\tZ =" << x[2] << endl; cout << "\t\tZ =" << x[2] << endl;
cout << "\t\tT =" << x[3] << endl; cout << "\t\tT =" << x[3] << endl;
cout << "Minimum: " << devE(x) << endl; devE(x);
cout << "========================================" << endl; cout << "========================================" << endl;
} }
...@@ -14,8 +14,8 @@ NPL::EnergyLoss Al("proton_Al.G4table","G4Table",100); ...@@ -14,8 +14,8 @@ NPL::EnergyLoss Al("proton_Al.G4table","G4Table",100);
using namespace std; using namespace std;
bool flagDraw = 0; bool flagDraw = 0;
static auto h = new TH1D("h","h", 80,-1.,1.); static auto h = new TH1D("h","All MG#'s", 60,-1.,1.);
static auto h1 = new TH1D("h1","h1", 40,-1.,1.); static auto h1 = new TH1D("h1","Individual MG#'s", 40,-1.,1.);
static auto h2 = new TH1D("h2","h2", 40,-1.,1.); static auto h2 = new TH1D("h2","h2", 40,-1.,1.);
static auto h3 = new TH1D("h3","h3", 40,-1.,1.); static auto h3 = new TH1D("h3","h3", 40,-1.,1.);
static auto h4 = new TH1D("h4","h4", 40,-1.,1.); static auto h4 = new TH1D("h4","h4", 40,-1.,1.);
...@@ -125,6 +125,7 @@ void InitiliseCanvas(){ ...@@ -125,6 +125,7 @@ void InitiliseCanvas(){
// ----- ALL ----- // ----- ALL -----
canv->cd(2); canv->cd(2);
h->SetStats(0); h->SetStats(0);
h->SetLineColor(kBlack);
h->GetXaxis()->SetTitle("Ex [MeV]"); h->GetXaxis()->SetTitle("Ex [MeV]");
h->GetYaxis()->SetTitle("Counts"); h->GetYaxis()->SetTitle("Counts");
h->Draw(); h->Draw();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment