Commit 5e2753a8 authored by Adrien Matta's avatar Adrien Matta
Browse files

* Progress on Nebula Calibration

parent 62586fc8
TChain* MakeChain1();
TChain* MakeChain2();
TChain* MakeChain();
TH2F* MakeTH2();
TH2F* GetTH2();
TH1F* GetV(unsigned int b);
TH1F* GetR(unsigned int b);
TGraph* graph = new TGraph();
unsigned int point = 1;
double off;
double c_light=299.792458;//mm/ns
auto chain = MakeChain();
void process1bar(int b);
auto h = new TH2F("h","h",200,0,201,500,0,1000);
auto r = new TH2F("r","r",200,0,201,10000,17000,20000);
ofstream output("Calibration/Nebula/offset_gamma.txt");
////////////////////////////////////////////////////////////////////////////////
......@@ -28,8 +27,6 @@ void gamma(){
auto c = new TCanvas("tof","tof");
chain->SetAlias("R","sqrt(Nebula.PosX*Nebula.PosX+Nebula.PosY*Nebula.PosY+(Nebula.PosZ+3774.7)*(Nebula.PosZ+3774.7))");
h=GetTH2();
h->Draw("colz");
new TCanvas();
unsigned int select =60;
for(unsigned int i = 0 ; i < 150 ; i++){
......@@ -46,13 +43,15 @@ void gamma(){
////////////////////////////////////////////////////////////////////////////////
void process1bar(int b){
//new TCanvas();
// Get the Radius for the distance to this barre
auto r1 = r->ProjectionY(Form("h%d",b),b,b+1);
r1->Rebin(4);
// Get the Radius for the distance to this bar
auto r1 = GetR(b);
//r1->Rebin(4);
double R = r1->GetBinCenter(r1->GetMaximumBin());
auto h1 = h->ProjectionY(Form("h%d",b),b,b+1);
h1->Rebin(8);
auto h1 = GetV(b);
if(h1->GetEntries()<10)
return;
//h1->Rebin(8);
double max = h1->GetBinCenter(h1->GetMaximumBin());
//h1->Draw();
auto f = new TF1("f","gaus(0)+pol0(3)",max-100,max+100);
......@@ -81,28 +80,23 @@ void process1bar(int b){
}
}
////////////////////////////////////////////////////////////////////////////////
TH2F* GetTH2(){
auto File= new TFile("Calibration/Nebula/hist_v.root");
h = (TH2F*) File->FindObjectAny("h");
File= new TFile("Calibration/Nebula/hist_r.root");
r = (TH2F*) File->FindObjectAny("r");
TH1F* GetV(unsigned int b){
auto File= new TFile("Calibration/Nebula/hist_gamma.root");
auto h = (TH1F*) File->FindObjectAny(Form("h%d",b));
h->Rebin(4);
h->GetXaxis()->SetRangeUser(500,800);
// File= new TFile("Calibration/Nebula/hist_r.root");
// r = (TH2F*) File->FindObjectAny("r");
return h;
}
////////////////////////////////////////////////////////////////////////////////
TH2F* MakeTH2(){
TString cond=Form("(Nebula.TOF-%f)>20&&(Nebula.TOF-%f)<38",off,off);
TString draw=Form("R/(Nebula.TOF-%f):Nebula.DetectorNumber>>h",off);
chain->Draw(draw,cond,"colz");
h->SaveAs("Calibration/Nebula/hist_v.root");
chain->Draw("R:Nebula.DetectorNumber>>r","","colz");
r->SaveAs("Calibration/Nebula/hist_r.root");
TH1F* GetR(unsigned int b){
auto File= new TFile("Calibration/Nebula/hist_gamma.root");
auto h = (TH1F*) File->FindObjectAny(Form("r%d",b));
return h;
}
////////////////////////////////////////////////////////////////////////////////
TChain* MakeChain(){
auto chain = new TChain("PhysicsTree");
......
TChain* MakeChain();
double c_light=299.792458;//mm/ns
void make_gamma(){
auto file = new TFile("Calibration/Nebula/hist_gamma.root","RECREATE");
// Create histograms
vector<TH1F*> h,r;
for(unsigned int i = 0 ; i < 150 ; i++){
TString name = Form("h%d",i);
h.push_back(new TH1F(name,name,500,0,1000));
name = Form("r%d",i);
r.push_back(new TH1F(name,name,10000,17000,20000));
}
auto chain = MakeChain();
auto neb = new TNebulaPhysics();
double beta=0.5504;
// Distance from SBT(-7377.56) to target(3774.7 for FP + a value for each target)
double D1=7377.56-3774.7+2.795;
double D2=7377.56-3774.7+6.972;
// time offset for each case
double off1 = D1/(beta*c_light);
double off2 = D2/(beta*c_light);
double off = (off1+off2)*0.5;
cout << "Offset1 : " << off1 << endl;
cout << "Offset2 : " << off2 << endl;
cout << "Mean : " << off << endl;
chain->SetBranchAddress("Nebula",&neb);
unsigned int size = chain->GetEntries();
// unsigned int size = 10000;
for(unsigned int i = 0 ; i < size ; i++){
if(i%1000==0)
cout << "\r entry " << i << " / " << size << flush;
chain->GetEntry(i);
if(neb->DetectorNumber.size()==1){
double R = sqrt(neb->PosX[0]*neb->PosX[0]+neb->PosY[0]*neb->PosY[0]+(neb->PosZ[0]+3774.7)*(neb->PosZ[0]+3774.7));
double v = R/(neb->TOF[0]-off);
h[neb->DetectorNumber[0]]->Fill(v);
r[neb->DetectorNumber[0]]->Fill(R);
}
}
for(auto it = h.begin(); it !=h.end(); it++)
(*it)->Write();
for(auto it = r.begin(); it !=r.end(); it++)
(*it)->Write();
file->Close();
cout << endl;
}
////////////////////////////////////////////////////////////////////////////////
TChain* MakeChain(){
auto chain = new TChain("PhysicsTree");
chain->Add("root/analysis/gamma/run*.root");
return chain;
}
NEBULA_T_ID0 34.5443
NEBULA_T_ID1 34.6041
NEBULA_T_ID2 34.7518
NEBULA_T_ID3 34.6263
NEBULA_T_ID4 34.7264
NEBULA_T_ID5 34.7805
NEBULA_T_ID6 34.7154
NEBULA_T_ID7 34.7419
NEBULA_T_ID8 34.4646
NEBULA_T_ID9 34.5757
NEBULA_T_ID10 34.6319
NEBULA_T_ID11 34.684
NEBULA_T_ID12 34.6671
NEBULA_T_ID13 34.5219
NEBULA_T_ID14 34.6426
NEBULA_T_ID15 34.6614
NEBULA_T_ID16 34.5045
NEBULA_T_ID17 34.2474
NEBULA_T_ID18 34.3315
NEBULA_T_ID19 34.4367
NEBULA_T_ID20 34.3501
NEBULA_T_ID21 34.4006
NEBULA_T_ID22 34.2355
NEBULA_T_ID23 34.1699
NEBULA_T_ID24 34.3718
NEBULA_T_ID25 34.6248
NEBULA_T_ID26 34.3355
NEBULA_T_ID27 34.3709
NEBULA_T_ID28 34.6222
NEBULA_T_ID29 34.8974
NEBULA_T_ID30 33.9325
NEBULA_T_ID31 34.4291
NEBULA_T_ID32 34.1664
NEBULA_T_ID33 34.0149
NEBULA_T_ID34 34.1137
NEBULA_T_ID35 34.2463
NEBULA_T_ID36 34.4991
NEBULA_T_ID37 34.4827
NEBULA_T_ID38 34.3254
NEBULA_T_ID39 34.1954
NEBULA_T_ID40 34.0749
NEBULA_T_ID41 34.4117
NEBULA_T_ID42 34.459
NEBULA_T_ID43 34.2735
NEBULA_T_ID44 34.1037
NEBULA_T_ID45 34.3806
NEBULA_T_ID46 34.4906
NEBULA_T_ID47 34.5923
NEBULA_T_ID48 34.4633
NEBULA_T_ID49 34.307
NEBULA_T_ID50 34.3805
NEBULA_T_ID51 34.3969
NEBULA_T_ID52 34.588
NEBULA_T_ID53 34.5001
NEBULA_T_ID54 34.5203
NEBULA_T_ID55 34.5992
NEBULA_T_ID56 34.0684
NEBULA_T_ID57 34.8204
NEBULA_T_ID58 35.1604
NEBULA_T_ID59 35.1723
NEBULA_T_ID61 34.1618
NEBULA_T_ID62 33.8713
NEBULA_T_ID63 34.8467
NEBULA_T_ID64 34.6529
NEBULA_T_ID65 34.9478
NEBULA_T_ID66 34.8999
NEBULA_T_ID67 34.2035
NEBULA_T_ID68 33.7549
NEBULA_T_ID69 33.9205
NEBULA_T_ID70 34.2526
NEBULA_T_ID71 33.7645
NEBULA_T_ID72 33.983
NEBULA_T_ID73 34.254
NEBULA_T_ID74 34.2696
NEBULA_T_ID75 34.5276
NEBULA_T_ID76 34.8105
NEBULA_T_ID77 34.1207
NEBULA_T_ID78 33.8232
NEBULA_T_ID79 34.3802
NEBULA_T_ID80 34.6536
NEBULA_T_ID81 33.795
NEBULA_T_ID82 33.5954
NEBULA_T_ID83 34.5733
NEBULA_T_ID84 33.7437
NEBULA_T_ID85 34.0008
NEBULA_T_ID86 34.138
NEBULA_T_ID87 33.5396
NEBULA_T_ID88 32.7999
NEBULA_T_ID89 34.0736
NEBULA_T_ID90 34.04
NEBULA_T_ID91 34.4174
NEBULA_T_ID92 34.4746
NEBULA_T_ID93 34.1962
NEBULA_T_ID94 33.9695
NEBULA_T_ID95 34.0982
NEBULA_T_ID96 34.6771
NEBULA_T_ID97 34.5538
NEBULA_T_ID98 34.8161
NEBULA_T_ID99 34.8409
NEBULA_T_ID100 34.5276
NEBULA_T_ID101 34.2538
NEBULA_T_ID102 34.3322
NEBULA_T_ID103 34.6166
NEBULA_T_ID104 34.7776
NEBULA_T_ID105 34.9334
NEBULA_T_ID106 34.6325
NEBULA_T_ID107 34.0925
NEBULA_T_ID108 34.449
NEBULA_T_ID109 33.5975
NEBULA_T_ID110 33.6435
NEBULA_T_ID111 34.4499
NEBULA_T_ID112 34.3772
NEBULA_T_ID113 33.4742
NEBULA_T_ID114 33.9552
NEBULA_T_ID115 33.8484
NEBULA_T_ID116 34.4536
NEBULA_T_ID117 34.7238
NEBULA_T_ID118 34.8648
NEBULA_T_ID119 35.1404
NEBULA_T_ID120 35.5016
NEBULA_T_ID121 33.6429
NEBULA_T_ID122 33.969
NEBULA_T_ID123 34.1937
NEBULA_T_ID124 34.3994
NEBULA_T_ID125 34.4839
NEBULA_T_ID126 34.4435
NEBULA_T_ID127 34.313
NEBULA_T_ID128 34.2042
NEBULA_T_ID129 34.2139
NEBULA_T_ID130 34.3013
NEBULA_T_ID131 33.3367
NEBULA_T_ID132 32.8974
NEBULA_T_ID133 34.331
NEBULA_T_ID134 34.3026
NEBULA_T_ID135 34.6377
NEBULA_T_ID136 34.7342
NEBULA_T_ID137 34.4055
NEBULA_T_ID138 34.4339
NEBULA_T_ID139 34.7883
NEBULA_T_ID140 29.8549
NEBULA_T_ID141 31.701
NEBULA_T_ID142 34.8278
NEBULA_T_ID143 34.4204
NEBULA_T_ID144 34.0676
NEBULA_T_ID60 34.2291
NEBULA_T_ID1 34.5922
NEBULA_T_ID2 34.7694
NEBULA_T_ID3 34.9723
NEBULA_T_ID4 34.6604
NEBULA_T_ID5 34.8851
NEBULA_T_ID6 34.6936
NEBULA_T_ID7 34.7044
NEBULA_T_ID8 34.7642
NEBULA_T_ID9 34.4816
NEBULA_T_ID10 34.5612
NEBULA_T_ID11 34.6275
NEBULA_T_ID12 34.619
NEBULA_T_ID13 34.3853
NEBULA_T_ID14 34.3388
NEBULA_T_ID15 35.0631
NEBULA_T_ID16 34.5556
NEBULA_T_ID17 33.9783
NEBULA_T_ID18 34.2425
NEBULA_T_ID19 34.5992
NEBULA_T_ID20 34.2835
NEBULA_T_ID21 34.4126
NEBULA_T_ID22 34.4358
NEBULA_T_ID23 34.0272
NEBULA_T_ID24 34.1103
NEBULA_T_ID25 34.5739
NEBULA_T_ID26 35.0359
NEBULA_T_ID27 34.9156
NEBULA_T_ID28 34.2105
NEBULA_T_ID29 34.8138
NEBULA_T_ID30 34.9965
NEBULA_T_ID31 34.1339
NEBULA_T_ID32 34.4452
NEBULA_T_ID33 34.0956
NEBULA_T_ID34 34.3118
NEBULA_T_ID35 34.3546
NEBULA_T_ID36 34.3213
NEBULA_T_ID37 34.7201
NEBULA_T_ID38 34.2632
NEBULA_T_ID39 34.4773
NEBULA_T_ID40 33.719
NEBULA_T_ID41 34.5495
NEBULA_T_ID42 34.3425
NEBULA_T_ID43 34.2744
NEBULA_T_ID44 34.6795
NEBULA_T_ID45 34.1254
NEBULA_T_ID46 34.5549
NEBULA_T_ID47 34.4596
NEBULA_T_ID48 34.5931
NEBULA_T_ID49 34.2254
NEBULA_T_ID50 34.2657
NEBULA_T_ID51 34.5111
NEBULA_T_ID52 34.581
NEBULA_T_ID53 34.099
NEBULA_T_ID54 34.0757
NEBULA_T_ID55 34.6373
NEBULA_T_ID56 34.6463
NEBULA_T_ID57 34.8271
NEBULA_T_ID58 34.5796
NEBULA_T_ID59 35.2348
NEBULA_T_ID61 34.1897
NEBULA_T_ID62 34.2115
NEBULA_T_ID63 35.6809
NEBULA_T_ID64 34.6327
NEBULA_T_ID65 35.0425
NEBULA_T_ID66 35.4113
NEBULA_T_ID67 34.9083
NEBULA_T_ID68 34.1289
NEBULA_T_ID69 33.5752
NEBULA_T_ID70 34.4984
NEBULA_T_ID71 34.2975
NEBULA_T_ID72 33.7079
NEBULA_T_ID73 34.2989
NEBULA_T_ID74 34.3563
NEBULA_T_ID75 33.5771
NEBULA_T_ID76 34.7965
NEBULA_T_ID77 34.7209
NEBULA_T_ID78 33.7591
NEBULA_T_ID79 34.059
NEBULA_T_ID80 34.8741
NEBULA_T_ID82 33.0554
NEBULA_T_ID83 34.4457
NEBULA_T_ID84 34.4195
NEBULA_T_ID85 33.5292
NEBULA_T_ID86 34.8708
NEBULA_T_ID87 33.9424
NEBULA_T_ID88 33.1291
NEBULA_T_ID89 34.668
NEBULA_T_ID90 33.7628
NEBULA_T_ID91 34.5667
NEBULA_T_ID92 32.1052
NEBULA_T_ID93 34.6439
NEBULA_T_ID94 34.174
NEBULA_T_ID95 34.4052
NEBULA_T_ID96 34.777
NEBULA_T_ID97 34.8321
NEBULA_T_ID98 34.5154
NEBULA_T_ID99 34.8771
NEBULA_T_ID100 34.82
NEBULA_T_ID101 34.3954
NEBULA_T_ID102 34.5721
NEBULA_T_ID103 34.6479
NEBULA_T_ID104 34.5427
NEBULA_T_ID105 35.1569
NEBULA_T_ID106 34.8748
NEBULA_T_ID107 35.0694
NEBULA_T_ID108 33.8616
NEBULA_T_ID109 34.5262
NEBULA_T_ID110 33.4922
NEBULA_T_ID111 34.367
NEBULA_T_ID112 34.8241
NEBULA_T_ID113 33.6154
NEBULA_T_ID114 35.2176
NEBULA_T_ID115 33.723
NEBULA_T_ID116 40.2125
NEBULA_T_ID117 35.4705
NEBULA_T_ID118 34.2625
NEBULA_T_ID119 35.471
NEBULA_T_ID120 34.8941
NEBULA_T_ID121 33.6064
NEBULA_T_ID122 34.3692
NEBULA_T_ID123 32.8653
NEBULA_T_ID124 34.6004
NEBULA_T_ID125 35.4875
NEBULA_T_ID126 23.867
NEBULA_T_ID127 33.0042
NEBULA_T_ID128 32.6078
NEBULA_T_ID129 34.4132
NEBULA_T_ID130 34.1434
NEBULA_T_ID131 23.8805
NEBULA_T_ID132 32.6514
NEBULA_T_ID133 35.5018
NEBULA_T_ID134 34.633
NEBULA_T_ID135 36.0812
NEBULA_T_ID136 35.0311
NEBULA_T_ID137 32.5883
NEBULA_T_ID138 25.9258
NEBULA_T_ID139 28.8419
NEBULA_T_ID140 25.3851
NEBULA_T_ID141 32.6386
NEBULA_T_ID142 28.5499
NEBULA_T_ID143 29.1687
NEBULA_T_ID144 60.234
NEBULA_T_ID60 34.7372
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment