--- ParDirCalc/QtoInclination.C 2008/01/17 16:15:13 1.1.1.1 +++ ParDirCalc/QtoInclination.C 2008/09/16 09:38:49 1.3 @@ -6,6 +6,7 @@ // #include "TrAng.h" #include "QtoInc.h" +#include "option.h" #include #include @@ -24,15 +25,370 @@ #include //#include #include "TStyle.h" -#include +//#include +#include +#include #include #include using namespace std; + +TH2F* NormalizeTH2F(TH2F* h1,Int_t Nev){ + TH2F* h2 = new TH2F("h2","Zenit, deg; Azimut, deg",36,0,360,20,140,180); + //h2-SetName("h2"); + //h2.SetBins(36,0,360,20,140,180); + for(Int_t i=0;i<=36;i++) for(Int_t j=0;j<=20;j++)h2->Fill(i*10-5,j*2+139,h1->GetBinContent(i,j)/Nev); + return h2; +} + +void DivideHystTH2F(TString file1, TString file2, TString hyst1, TString hyst2, Int_t Nev1, Int_t Nev2, string outdir,Bool_t Err){ + gStyle->SetPalette(1); + TFile* f1 = new TFile(file1); + TFile* f2 = new TFile(file2); + TH2F* h1 = (TH2F*)f1->Get(hyst1); + TH2F* h2 = (TH2F*)f2->Get(hyst2); + TH2F* h1n = NormalizeTH2F(h1,1); + TH2F* h2n = NormalizeTH2F(h2,1); + /*TH2F* h1n = new TH2F("h1n","Zenit, deg; Azimut, deg",36,0,360,20,140,180); + TH2F* h2n = new TH2F("h2n","Zenit, deg; Azimut, deg",36,0,360,20,140,180); + for(Int_t i=0;i<=36;i++) for(Int_t j=0;j<=20;j++){ + h1n->Fill(i*10-5,j*2+140,h1->GetBinContent(i,j)/h1->GetEntries()); + h2n->Fill(i*10-5,j*2+140,h2->GetBinContent(i,j)/h2->GetEntries()); + }*/ + //vector GrafErr(8); + TH2F* h3 = new TH2F("h3","Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + h3->Divide(h1n,h2n); + TH2F* h3ErrPer; + if(Err){ + TH2F* h3Err = new TH2F("h3Err","Errot of Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + h3ErrPer = new TH2F("h3Err","Errot of Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + //ofstream fe((TString)outdir+"Divide_errors"+hyst1+"_"+hyst2+".txt"); + ofstream fe2((TString)outdir+"Protons_Divide_errors"+hyst1+"_"+hyst2+".txt"); + //Int_t Nev1 = 0; + //Int_t Nev2 = 0; + //for(Int_t i=1;i<=36;i++) for(Int_t j=0;j<=20;j++){Nev1=Nev1+h1->GetBinContent(i,j);Nev2=Nev2+h2->GetBinContent(i,j);} + //cout<<"Nev1 = "<GetBinContent(i,j)<<"/"<GetBinContent(i,j)<<" = "; + if(h2->GetBinContent(i,j)!=0){ + Float_t Val = (h1->GetBinContent(i,j))/(h2->GetBinContent(i,j)); + Float_t Err = 0; + if(h1->GetBinContent(i,j)==0)Err=0;else Err = Val*(sqrt(1./h1->GetBinContent(i,j)+1./h2->GetBinContent(i,j))); + //Float_t Err = (h2->GetBinContent(i,j)*sqrt(h1->GetBinContent(i,j))-h1->GetBinContent(i,j)*sqrt(h2->GetBinContent(i,j)))/pow(h2->GetBinContent(i,j),2); + //Float_t Err = (h1->GetBinContent(i,j)/pow(h2->GetBinContent(i,j),2))+pow(h1->GetBinContent(i,j),2)*h2->GetBinContent(i,j)/pow(h2->GetBinContent(i,j),4); + Float_t ErrPer = Err*100/(fabs(Val-1)); + fe2<<(-j+20)*2+1<<"\t"<GetBinContent(i,j)<<"\t"<GetBinContent(i,j)<100)ErrPer=100; + h3ErrPer->Fill(i*10-5,j*2+139,ErrPer); + h3Err->Fill(i*10-5,j*2+139,Err); + } + } + //fe<<"\n"; + } + + //h1ErrCanv->Divide(1,8); + for(Int_t i=0;i<8;i++){ + Float_t x[36]; + Float_t y[36]; + Float_t y1[36]; + Float_t Ex[36]; + Float_t Ey[36]; + TH1F* Profil1D = new TH1F("Profil1D","Profil1D",36,0,36); + Profil1D->SetFillColor(2); + for(Int_t j=0;j<36;j++){ + y[j] = h3->GetBinContent(j,19-i); + Ey[j] = h3Err->GetBinContent(j,19-i); + x[j] = j; + Ex[j] = 0; + y1[j] = 1; + Profil1D->Fill(j,h2->GetBinContent(j,19-i)); + } + TCanvas* h1ErrCanv = new TCanvas("h1ErrCanv","",1200,800); + h1ErrCanv->Divide(1,2); + TGraphErrors* Gep = new TGraphErrors(36,x,y,Ex,Ey); + TGraph* _1 = new TGraph(36,x,y1); + Gep->SetLineColor(4); + Gep->SetFillColor(2); + h1ErrCanv->cd(1); + Gep->Draw("AB"); + _1->Draw(""); + h1ErrCanv->cd(2); + Profil1D->Draw(""); + /*string s; + stringstream out; + out<SaveAs((TString)outdir+"Divide_"+hyst1+"_"+hyst2+"_1Ds"+s+".png");*/ + Gep->Delete(); + delete h1ErrCanv; + } + /*fe2.close(); + TFile f3((TString)outdir+"DivideHyst"+hyst1+"_"+hyst2+".root","recreate"); + h3->Write(); + f3.Close();*/ + } + /*TCanvas* c1 = new TCanvas("c1",hyst1+"/"+hyst2,1200,1200); + if(Err) c1->Divide(1,2); + c1->cd(1); + h3->Draw("colz"); + if(Err){ + c1->cd(2); + h3ErrPer->Draw("colz"); + } + c1->SaveAs((TString)outdir+"Divide_"+hyst1+"_"+hyst2+".png"); + delete c1;*/ + h2->Delete(); + h1->Delete(); + h3->Delete(); + f1->Delete(); + f2->Delete(); +} + +void DiferenceHystTH2F(TString file1, TString file2, TString hyst1, TString hyst2, Int_t Nev1, Int_t Nev2, string outdir){ + gStyle->SetPalette(1); + TFile* f1 = new TFile(file1); + TFile* f2 = new TFile(file2); + TH2F* h1 = (TH2F*)f1->Get(hyst1); + TH2F* h2 = (TH2F*)f2->Get(hyst2); + TH2F* h1n = NormalizeTH2F(h1,Nev1); + TH2F* h2n = NormalizeTH2F(h2,Nev2); + TH2F* h3 = new TH2F("h3","Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + TH2F* h3Err = new TH2F("h3Err","Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + TH2F* h3ErrPer = new TH2F("h3Err","Errot of Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + ofstream fe((TString)outdir+"Diference_errors2.txt"); + for(Int_t i=1;i<=36;i++){ + for(Int_t j=1;j<=20;j++){ + Float_t Val = h1->GetBinContent(i,j)/Nev1-h2->GetBinContent(i,j)/Nev2; + Float_t Err = sqrt(pow(h1->GetBinContent(i,j)/Nev1,2)*(1./h1->GetBinContent(i,j)+1./Nev1)+pow(h2->GetBinContent(i,j)/Nev2,2)*(1./h2->GetBinContent(i,j)+1./Nev2)); + Float_t ErrPer = Err*100/(fabs(Val)); + h3->Fill(i*10-5,j*2+139,h1->GetBinContent(i,j)/Nev1-h2->GetBinContent(i,j)/Nev2); + fe<GetBinContent(i,j)/Nev1<<" - "<GetBinContent(i,j)/Nev2<<" = "<GetBinContent(i,j)!=0 && h2->GetBinContent(i,j)!=0){ + fe<<" +/- "<100)ErrPer=100; + h3Err->Fill(i*10-5,j*2+139,Err); + h3ErrPer->Fill(i*10-5,j*2+139,ErrPer); + }else fe<<"\n"; + } + fe<<"\n"; + } + for(Int_t i=0;i<8;i++){ + Float_t x[36]; + Float_t y[36]; + Float_t Ex[36]; + Float_t Ey[36]; + TH1F* Profil1D = new TH1F("Profil1D","Profil1D",36,0,36); + Profil1D->SetFillColor(2); + for(Int_t j=0;j<36;j++){ + if(h1n->GetBinContent(j,19-i)!=0)y[j] = h3->GetBinContent(j,19-i)*100/h1n->GetBinContent(j,19-i); else y[j]=0; + if(h1n->GetBinContent(j,19-i)!=0) Ey[j] = h3Err->GetBinContent(j,19-i)*100/h1n->GetBinContent(j,19-i); else Ey[j]=0; + Profil1D->Fill(j,h2->GetBinContent(j,19-i)); + //cout<<"h3 = "<GetBinContent(j,19-i)<<" h1n = "<GetBinContent(j,19-i)<<" yn = "<GetBinContent(j,19-i); + //cout<Divide(1,2); + TGraphErrors* Gep = new TGraphErrors(36,x,y,Ex,Ey); + Gep->SetLineColor(4); + Gep->SetFillColor(2); + h1ErrCanv->cd(1); + Gep->Draw("AB"); + h1ErrCanv->cd(2); + Profil1D->Draw(""); + string s; + stringstream out; + out<SaveAs((TString)outdir+"Diference_"+hyst1+"_"+hyst2+"_1Ds"+s+".png"); + Gep->Delete(); + Profil1D->Delete(); + delete h1ErrCanv; + } + fe.close(); + TFile f3((TString)outdir+"resultDifferenceHyst.root","recreate"); + h3->Write(); + f3.Close(); + TCanvas* c1 = new TCanvas("c1",hyst1+" - "+hyst2,1200,1200); + c1->Divide(1,2); + c1->cd(1); + h3->Draw("colz"); + c1->cd(2); + h3ErrPer->Draw("colz"); + c1->SaveAs((TString)outdir+"Difference_"+hyst1+"_"+hyst2+".png"); + delete c1; + h2->Delete(); + h1->Delete(); + h3->Delete(); + f1->Delete(); + f2->Delete(); +} + +void MergeHystTH2F(TString file1, TString file2, TString hyst1, TString hyst2, string outdir){ + gStyle->SetPalette(1); + TFile* f1 = new TFile(file1); + TFile* f2 = new TFile(file2); + TH2F* h1 = (TH2F*)f1->Get(hyst1); + TH2F* h2 = (TH2F*)f2->Get(hyst2); + TH2F* h3 = new TH2F("h3","Zenit angle, deg; Azimut angle, deg",36,0,360,20,140,180); + for(Int_t i=0;i<=36;i++) for(Int_t j=0;j<=20;j++) h3->Fill(i*10-5,j*2+140,h1->GetBinContent(i,j)+h2->GetBinContent(i,j)); + TFile f3((TString)outdir+hyst1+"_"+hyst2+"_resultMergeHyst.root","recreate"); + h3->Write(); + f3.Close(); + TCanvas* c1 = new TCanvas("c1",hyst1+" + "+hyst2,1200,800); + c1->cd(); + h3->Draw("colz"); + c1->SaveAs((TString)outdir+"Merge_"+hyst1+"_"+hyst2+".png"); + delete c1; + h2->Delete(); + h1->Delete(); + h3->Delete(); + f1->Delete(); + f2->Delete(); +} + + +void Convert2Dto1Dhyst(TString file, TString hyst, string outdir){ + TFile* f1 = new TFile(file); + TH2F* h1 = (TH2F*)f1->Get(hyst); + //TH1F* h2 = new TH1F("h2","Zenit Efficiency",20,140,180); + //TH1F* h3 = new TH1F("h3","Azimuth Efficiency",36,0,360); + //for(Int_t i=0;i<36;i++) for(Int_t j=0;j<20;j++) h3->Fill(i*10-5,h1->GetBinContent(i,j)); + //for(Int_t i=0;i<20;i++) for(Int_t j=0;j<36;j++) h2->Fill(j*2+140,h1->GetBinContent(j,i)); + TH1D* h2 = (TH1D*)h1->ProjectionY(" ",1,20,""); + TCanvas* c1 = new TCanvas("c1","Zenit Efficiency",1200,800); + c1->cd(); + h2->Draw(); + c1->SaveAs((TString)outdir+hyst+"Zenit.png"); + delete c1; + TFile f2((TString)outdir+hyst+"Zenit.root","recreate"); + h2->Write(); + f2.Close(); + TH1D* h3 = (TH1D*)h1->ProjectionX(" ",1,36,""); + TCanvas* c2 = new TCanvas("c2","Azimuth Efficiency",1200,800); + c2->cd(); + h3->Draw(); + c2->SaveAs((TString)outdir+hyst+"Azimuth.png"); + delete c2; + TFile f3((TString)outdir+hyst+"Azimuth.root","recreate"); + h3->Write(); + f3.Close(); + h3->Delete(); + h1->Delete(); + h2->Delete(); + f1->Delete(); +} + +void ReBinTH2F(TString file, TString hyst, string outdir){ + gStyle->SetPalette(1); + TFile* f1 = new TFile(file); + TH2F* h1 = (TH2F*)f1->Get(hyst); + TH2F* h2 = new TH2F("h2","Zenith, deg; Azimuth, deg",18,0,360,20,140,180); + for(Int_t i=0;i<=20;i++) for(Int_t j=0;j<=36;j++){h2->Fill(j*10-5,i*2+140,h1->GetBinContent(j,i)+h1->GetBinContent(j+1,i));j++;} + TFile f2((TString)outdir+hyst+"Re-Bin.root","recreate"); + h2->Write(); + f2.Close(); + TCanvas* c1 = new TCanvas("c1",hyst,800,600); + c1->cd(); + h2->Draw("colz"); + c1->SaveAs((TString)outdir+hyst+"Re-Bin.png"); + delete c1; + h2->Delete(); + h1->Delete(); + f1->Delete(); +} + +void Modeling(Double_t R, Int_t Nevents, Float_t zmax, string outdir){ + cout<<"Modelling..."<SetPalette(1); + TH2F* h1 = new TH2F("h1","Azimut,deg;Zenit,deg",36,0,360,20,140,180); + TH2F* h2 = new TH2F("h2","Azimut,deg;Zenit,deg",36,0,360,20,140,180); + TH2F* h3 = new TH2F("h3","Azimut,deg;Zenit,deg",36,0,360,20,140,180); + TH2F* h4 = new TH2F("h4","Azimut,deg;Zenit,deg",36,0,360,20,140,180); + Float_t A; + Float_t Zenit; + Float_t Azimuth; + for(Int_t i=0;iFill(Azimuth,180-Zenit); + /*for(Int_t nx=0;nx<24;nx++){ + for(Int_t ny=0;ny<24;ny++){ + h2->Fill(Azimuth,180-Zenit); + Float_t x = (nx+0.5)*6.75; + Float_t y = (ny+0.5)*5.5; + Float_t k = sin(TMath::DegToRad()*Zenit)*cos(TMath::DegToRad()*Azimuth); + Float_t l = sin(TMath::DegToRad()*Zenit)*sin(TMath::DegToRad()*Azimuth); + Float_t m = cos(TMath::DegToRad()*Zenit); + Float_t xl = x+k*zmax/m; + Float_t yl = y+l*zmax/m; + Float_t hl = sqrt(pow(x-xl,2)+zmax); + Float_t za=0; Float_t xa=0; + Float_t Rk=1000*0.3*R/0.4; + //cout<<"Zenith = "<Draw("colz"); + c1->SaveAs((TString)outdir+".png"); + TFile f2((TString)outdir+".root","recreate"); + h1->Write(); + f2.Close(); + */ + TCanvas* c3 = new TCanvas("c3","Model Isotropic distribution",1200,800); + h4->Draw("colz"); + c3->SaveAs((TString)outdir+"_isotrop.png"); + TFile f4((TString)outdir+"_isotrop.root","recreate"); + h4->Write(); + f4.Close(); + /* + TFile f3((TString)outdir+"Abs.root","recreate"); + h2->Write(); + f3.Close(); + h3->Divide(h2,h1); + TCanvas* c2 = new TCanvas("c2","Model distribution",1200,800); + h3->Draw("colz"); + c2->SaveAs((TString)outdir+"Rate.png"); + delete c1; + delete c2;*/ + delete c3; + h1->Delete(); + h2->Delete(); + h3->Delete(); + h4->Delete(); +} int main(int argc, char* argv[]){ +OptionParam opt1; + string outdir = "/home/pamelaprod/malakhov/QtoInc/Picture/"; Bool_t AnglHist = false; Bool_t DiffHist = false; @@ -41,13 +397,39 @@ Bool_t PamAngTime = false; Bool_t PamExp = false; +/*vector Hyst(1); +Hyst[0].SetName("ElectronLowEnergy"); +Hyst[0].SetBins(36,0,360); +Hyst[0].FillRandom("gaus",5000); +TFile f1("/home/pamelaprod/malakhov/QtoInc/TEST/TEST.root","recreate"); +Hyst[0].Write(); +f1.Close(); +//TFile* f1 = new TFile("/home/pamelaprod/malakhov/QtoInc/TEST/TEST.root"); +//TH1F* h1 = (TH1F*)f1->Get(""); +//cout<GetEntries()<Hyst2DF(1); +//Hyst2DF[0].SetName("Test1"); +//Hyst2DF[0].SetBins(36,0,360,36,0,360); +//Hyst2DF.resize(Hyst2DF.size()+1); +//Hyst2DF[1].SetName("Test2"); +//Hyst2DF[1].SetBins(36,0,360,36,0,360); +//cout<= argc){ + cout<<"--Normalize needs argument\n See --help\n"; + exit(1); + } + NormalizeTH2F((TString)argv[2],(TString)argv[3],argv[4]); + exit(0); +}*/ + +if(!strcmp(argv[1],"--Model")){ + if(5 >= argc){ + cout<<"--Model needs argument\n See --help\n"; + exit(1); + } + Modeling(atof(argv[2]),atoi(argv[3]),atof(argv[4]),argv[5]); + exit(0); +} + +if(!strcmp(argv[1],"--Diference")){ + if(6 >= argc){ + cout<<"--Diference needs argument\n See --help\n"; + exit(1); + } + + DiferenceHystTH2F((TString)argv[2],(TString)argv[3],(TString)argv[4],(TString)argv[5],atoi(argv[6]),atoi(argv[7]),argv[8]); + exit(0); +} + +if(!strcmp(argv[1],"--Compare")){ + //gStyle->SetPalette(1); + //TMultiGraph* mg; + //vector Gep; + Float_t Val[20][36]; + Float_t Err[20][36]; + string tmp; + char g; + TString out = ""; + for(Int_t ii=2;ii0;i--){ + for(Int_t j=1;j<=36;j++){ + in>>tmp;in>>tmp;in>>g; + if(g=='0'){ + Val[i-1][j-1]=0; + Err[i-1][j-1]=0; + Bool_t xx=false; + Bool_t yy=false; + while(g!='='){ + in>>g; + if(g=='/'){yy=true;continue;} + if(yy && g=='0') xx=true; else yy=false; + } + if(!xx){ + in>>tmp; + in>>tmp; + in>>tmp; + } + }else{ + while(g!='/') in>>g; + in>>g; + if(g=='0'){ + in>>tmp; + Val[i-1][j-1]=0; + Err[i-1][j-1]=0; + }else{ + while(g!='=') in>>g; + in>>Val[i-1][j-1]; + in>>tmp; + in>>Err[i-1][j-1]; + } + } + }} + ii++; + //Val.resize(Val.size()+1); + //Val[Val.size()-1][1][1]=0; + } + } + ofstream fv(out+"Val.txt"); + ofstream fe(out+"Err.txt"); + for(Int_t i=20;i>0;i--){ + for(Int_t j=1;j<=36;j++){fv<= argc){ + cout<<"--Merge needs argument\n See --help\n"; + exit(1); + } + gStyle->SetPalette(1); + //vector Hysts; + //vector Files; + vector h1; + vector h2; + TH2F h2sum; + TH1F h1sum; + Bool_t H2 = false; + TString out = ""; + if(!strcmp(argv[2],"2D")) H2=true; + for(Int_t i=3;ils(); + h2[h2.size()-1] = (TH2F*)f2->Get(argv[i+1]); + //cout<GetNbinsX()<Get(argv[i+1]); + i++; + } + } + } + cout<<"outputh is "<cd(); + h2sum.Draw("colz"); + c1->SaveAs(out+".png"); + delete c1; + }else{ + TFile fsum(out+".root","recreate"); + h1sum.Write(); + fsum.Close(); + TCanvas* c1 = new TCanvas("c1","resultMerge",1200,800); + c1->cd(); + h1sum.Draw(); + c1->SaveAs(out+".png"); + delete c1; + } + //MergeHystTH2F((TString)argv[2],(TString)argv[3],(TString)argv[4],(TString)argv[5],argv[6]); + exit(0); +} + +if(!strcmp(argv[1],"--PlotEfficiency")){ + vector ge; + TString out = ""; + Int_t t = 1; + //TGraphErrors tmp; + for(Int_t i=2;i>Val[j][k];inErr>>Err[j][k];} + if(!strcmp(argv[i+2],"-yline")){ + Int_t n = atoi(argv[i+3]); + Float_t x[36]; + Float_t y[36]; + Float_t xe[36]; + Float_t ye[36]; + ge.resize(ge.size()+1); + //ge[ge.size()-1]->Set(36); + for(Int_t j=0;j<36;j++){ + x[j]=j*10+5; + xe[j]=5; + y[j]=Val[n][j]; + ye[j]=Err[n][j]; + ge[ge.size()-1].SetPoint(j,x[j],y[j]); + ge[ge.size()-1].SetPointError(j,xe[j],ye[j]); + //tmp.SetPoint(j,x[j],y[j]); + } + ge[ge.size()-1].SetLineColor(t); + ge[ge.size()-1].SetTitle((TString)argv[i+1]+" Pitch "+(TString)argv[i+3]); + t++; + //TGraphErrors *tmp = new TGraphErrors(36,x,y,xe,ye); + + + //TGraphErrors df; + //df = *tmp; + //cout<<"check"<Delete(); + i+=3; + } + if(!strcmp(argv[i+2],"-xline")){ + Int_t p = 0; + Int_t n=0; + if(!strcmp(argv[i+3],"All")) p=36;else n = atoi(argv[i+3]); + Float_t x[20]; + Float_t y[20]; + Float_t xe[20]; + Float_t ye[20]; + for(Int_t j=0;j<20;j++){y[j]=0;ye[j]=0;} + ge.resize(ge.size()+1); + for(Int_t j=0;j<20;j++){ + x[j]=j*2+1; + xe[j]=1; + for(Int_t yi=0;yiDelete(); + i+=3; + } + } + } + TMultiGraph* mg = new TMultiGraph(); + cout<<"check"<SetLineColor(i+1); + //cout<Add(&ge[i]); + } + TCanvas* c1 = new TCanvas("c1","eryt",1200,800); + c1->cd(); + mg->Draw("AP"); + cout<<"check"<Delete(); exit(1); } -if(!strcmp(argv[3],"--OutPuth")){ - if (4 >= argc){ - cout<<"--OutPath needs argument\n See --help\n"; - }else outdir = argv[4]; +if(!strcmp(argv[1],"--Divide")){ + if(argc<7){ + cout<<"--Divide needs argument\n See --help\n"; + exit(1); + }/* + Bool_t H2 = false; + TString out = ""; + if(!strcmp(argv[2],"2D")) H2=true; + out = (TString)argv[7]; + gStyle->SetPalette(1); + TFile* f1 = new TFile((TString)argv[3]); + TFile* f2 = new TFile((TString)argv[5]); + TH1F* h11D; TH1F* h21D; + TH2F* h12D; TH2F* h22D; + TH1F h1n1D; TH1F h2n1D; + TH2F h1n2D; TH2F h2n2D; + TH1F h1div; TH2F h2div; + cout<<"out is "<Get(argv[4]); + h22D = (TH2F*)f2->Get(argv[6]); + h1n2D.SetBins(h12D->GetNbinsX(),h12D->GetXaxis()->GetXmin(),h12D->GetXaxis()->GetXmax(),h12D->GetNbinsY(),h12D->GetYaxis()->GetXmin(),h12D->GetYaxis()->GetXmax()); + h2n2D.SetBins(h12D->GetNbinsX(),h12D->GetXaxis()->GetXmin(),h12D->GetXaxis()->GetXmax(),h12D->GetNbinsY(),h12D->GetYaxis()->GetXmin(),h12D->GetYaxis()->GetXmax()); + h2div.SetBins(h12D->GetNbinsX(),h12D->GetXaxis()->GetXmin(),h12D->GetXaxis()->GetXmax(),h12D->GetNbinsY(),h12D->GetYaxis()->GetXmin(),h12D->GetYaxis()->GetXmax()); + for(Int_t i = 0; i < h12D->GetNbinsX(); i++){ + for(Int_t j = 0; j < h12D->GetNbinsY(); j++){ + h1n2D.SetBinContent(i,j,h12D->GetBinContent(i,j)/h12D->GetEntries()); + h2n2D.SetBinContent(i,j,h22D->GetBinContent(i,j)/h22D->GetEntries()); + } + } + h2div.Divide(&h1n2D,&h2n2D); + }else{ + h11D = (TH1F*)f1->Get((TString)argv[4]); + h21D = (TH1F*)f2->Get((TString)argv[6]); + h1n1D.SetBins(h11D->GetNbinsX(),h11D->GetXaxis()->GetXmin(),h11D->GetXaxis()->GetXmax()); + h2n1D.SetBins(h21D->GetNbinsX(),h21D->GetXaxis()->GetXmin(),h21D->GetXaxis()->GetXmax()); + h1div.SetBins(h21D->GetNbinsX(),h21D->GetXaxis()->GetXmin(),h21D->GetXaxis()->GetXmax()); + for(Int_t i = 0; iGetNbinsX();i++){ + h1n1D.SetBinContent(i,h11D->GetBinContent(i)/h11D->GetEntries()); + h2n1D.SetBinContent(i,h21D->GetBinContent(i)/h21D->GetEntries()); + } + h1div.Divide(&h1n1D,&h2n1D); + } + h2div.SetName("Proton"); + h1div.SetName("Proton"); + if(H2){ + TFile fdiv(out+".root","recreate"); + h2div.Write(); + fdiv.Close(); + TCanvas* c1 = new TCanvas("c1","resultDivide",1200,800); + c1->cd(); + h2div.Draw("colz"); + c1->SaveAs(out+".png"); + delete c1; + }else{ + TFile fdiv(out+".root","recreate"); + h1div.Write(); + fdiv.Close(); + TCanvas* c1 = new TCanvas("c1","resultDivide",1200,800); + c1->cd(); + h1div.Draw(); + c1->SaveAs(out+".png"); + delete c1; + }*/ + Bool_t Err = false; + if((argc==10) && !strcmp(argv[9],"-Err")) Err = true; + DivideHystTH2F((TString)argv[2],(TString)argv[3],(TString)argv[4],(TString)argv[5],atoi(argv[6]),atoi(argv[7]),argv[8],Err); + exit(0); } -for(Int_t i=4; i= argc){ + cout<<"--ReBin needs argument\n See --help\n"; + exit(1); + } + ReBinTH2F((TString)argv[2],(TString)argv[3],argv[4]); + exit(0); } -if(!PamEff && !DiffHist && !AnglHist && !PamAngTime && !PamExp) AnglHist = true; +if(!strcmp(argv[1],"--2Dto1D")){ + if(4 >= argc){ + cout<<"--2Dto1D needs argument\n See --help\n"; + exit(1); + } + Convert2Dto1Dhyst((TString)argv[2],(TString)argv[3],argv[4]); + exit(0); +} + +if(!strcmp(argv[3],"--OutPuth")){ + if (4 >= argc){ + cout<<"--OutPath needs argument\n See --help\n"; + }else{ + outdir = argv[4]; + opt1.outdir = argv[4]; + } +}else{ + cout<<"\n ERROR:\tYou need --OutPuth as second argument for run programm\n See --help for more information\n"<= argc){ - cout<<"--WorkDir needs argument\n See --help\n"; + cout<<"--WorkDir needs argument\n See --help\n"; + exit(1); + } +}else{ + cout<<"\n ERROR:\tYou need --WorkDir as first argument for run programm\n See --help for more information\n"<=argc){ + //opt1.AnglHystDefault(); + if(opt1.debug) cout<<"Setting default value for AnglHyst option.\n\n"; + }else{ + + Int_t i0 = i+1; + + Bool_t inside = false; //Check that we go inside loop + + Int_t NPth = 0; Int_t NMA = 0; Int_t NPNO = 0; + opt1.AnglHystFunc(argc,argv); + + } //if((i+1)>=argc) {...}; else + + } //AnglHyst + + if(!strcmp(argv[i],"--DiffHyst")){ + //opt1.opt.DH.DiffHystOn = true; + //opt1.DiffHystFunc(argc,argv); + }*/ + if(!strcmp(argv[i],"--PamEff")){ + //opt1.opt.PE.PamEffOn = true; + opt1.PamEffFunc(argc,argv); + /*if(opt1.debug){ + for(Int_t i = 0; i=argc || !atoi(argv[i+1])){ + cout<<"\n ERROR! \t -verbose needs arguments \n See --help \n"; + if(opt1.debug) cout<<"Argument number\t"<3){ + cout<<"\n ERROR! \t -verbose needs 0, 1, 2 or 3 only \n See --help \n"; + if(opt1.debug) cout<<"Argument\t"<=argc || (strcmp(argv[i7],"jpg") && strcmp(argv[i7],"png") && strcmp(argv[i7],"bmp") && strcmp(argv[i7],"root") && + strcmp(argv[i7],"txt") && strcmp(argv[i7],"all"))){ + cout<<"\n ERROR! \t -outform needs argument \n See --help \n"; + if(opt1.debug) cout<<"Argument number - "<=argc || !atoi(argv[i+1])){ + cout<<"\n ERROR! \t -nevents needs ULong integer \n See --help \n"; + exit(1); + } + if(atoi(argv[i+1])<0){ + cout<<"\n ERROR! \t -nevents needs ULong integer \n See --help \n"; + exit(1); + } + opt1.opt.Neve = atoi(argv[i+1]); + } + if(!strcmp(argv[i],"-nv") || (!strcmp(argv[i],"-Nverbose"))){ + if(i+1>=argc || !atoi(argv[i+1])){ + cout<<"\n ERROR! \t -nevents needs ULong integer \n See --help \n"; + exit(1); + } + if(atoi(argv[i+1])<0){ + cout<<"\n ERROR! \t -nevents needs ULong integer \n See --help \n"; + exit(1); + } + opt1.opt.Nverb = atoi(argv[i+1]); + } + if(!strcmp(argv[i],"-ns") || (!strcmp(argv[i],"-Nstart"))){ + if(i+1>=argc || !atoi(argv[i+1])){ + cout<<"\n ERROR! \t -Nstart needs ULong integer \n See --help \n"; + exit(1); + } + if(atoi(argv[i+1])<0){ + cout<<"\n ERROR! \t -nstart needs ULong integer \n See --help \n"; + exit(1); + } + opt1.opt.Nstart = atoi(argv[i+1]); + } + if(!strcmp(argv[i],"--Show")){ + Int_t a=0; + if(opt1.debug) a=1; + if(i>5+a){ + cout<<"\n Error!: \t --Show must be used as single option without any other \n See --help \n"; + if(opt1.debug) cout<<"Argument number - "<=argc){ + cout<<"\n ERROR! \t -FullInformation needs argument \n See --help \n"; + exit(1); + } + while(j6=argc || !atoi(argv[j6+1])){ + cout<<"\n ERROR! \t -nevents needs argument \n See --help \n"; + exit(1); + } + opt1.opt.SP.FI.NEvent = atoi(argv[j6+1]); + if(opt1.debug) cout<<"Event number\t"<=argc || !atoi(argv[j6+1])){ + cout<<"\n ERROR! \t -absTime needs argument \n See --help \n"; + exit(1); + } + opt1.opt.SP.FI.AbsTime = atoi(argv[j6+1]); + if(opt1.debug) cout<<"Absolute time of Event\t"<=argc){ + cout<<"\n ERROR! \t -UTS needs argument \n See --help \n"; + exit(1); + } + opt1.opt.SP.FI.UTS = argv[j6+1]; + if(opt1.debug) cout<<"UTS of Event\t"<=argc || !atoi(argv[i+2])){ + cout<<"\n ERROR! \t -event needs integer argument \n See --help \n"; + exit(1); + } + opt1.opt.SP.AbsTime = atoi(argv[i+2]); + if(opt1.debug) cout<<"AbsTime for convert is "<=argc){ + cout<<"\n ERROR! \t -UTS needs argument \n See --help \n"; + exit(1); + } + opt1.opt.SP.UTS = argv[i+2]; + if(opt1.debug) cout<<"UTS for convert is "<SetOptStat(111111); - TSystemDirectory *workdir = new TSystemDirectory("workdir",dirname); - TList *flist=workdir->GetListOfFiles(); + if(opt.opt.verbose>=2) cout<<"\nGeneral variables initialisation...\n\n"; + + TSystemDirectory* workdir = new TSystemDirectory("workdir",dirname); + //TSystemDirectory* workdir2 = new TSystemDirectory("workdir2","/data01/_3/607_3/"); + TList* flist = workdir->GetListOfFiles(); PamLevel2* pam_events = new PamLevel2(); - PamelaOrientation* PO = new PamelaOrientation(); + PamelaOrientation* PO = new PamelaOrientation(); TTree *T = pam_events->GetPamTree(flist,"treename"); ULong_t nevents = T->GetEntries(); + + if(opt.opt.verbose>=1) cout<<"\n Nevents = "<GetTrkLevel2()->LoadField("/data01/pamhome/installed/pamela_software/calib/trk-param/field_param-0/"); + pam_events->GetTrkLevel2()->LoadField("/data01/pam7/installed/pamela_software/calib/trk-param/field_param-0/"); /********************************************************************************/ Int_t nz = 6; Float_t zin[6]; for (Int_t ip=0;ipGetToFLevel2()->GetZTOF(pam_events->GetToFLevel2()->GetToFPlaneID(ip));cout<=2) cout<<"\n Other Variables initialisation...\n\n"; + PamTrack *track; - Int_t ntr; - Float_t Argv = 0; - Double_t PamAzim = 0; - Double_t PamZenit = 0; - Double_t MyAzim = 0; - Double_t MyZenit = 0; - Double_t Px; - Double_t Py; - Double_t Pz; - - /*********************************************************************************/ - // Angular exposure. How much time Pamela have any Azimutal and Zenital angle - /*********************************************************************************/ - - TH2F *hhigh; - TH2F *hlow; - - TFile fhigh((TString)outdir+"PamAngEfficiencyHighEnergy.root"); - TFile flow((TString)outdir+"PamAngEfficiencyLowEnergy.root"); - if(PamExp){ - - if (fhigh.IsZombie()||flow.IsZombie()){ - cout<<"Problem with Hystogrammfiles"<=2) cout<<"\n--AnglHyst Hystogramm block...\n\n"; /***************************************************************************************/ - //Histogramms for diferences in results between calculating using DoTrack2 + //Histogramms for differences in results between calculating using DoTrack2 //and using axv[0], ayv[0] /**************************************************************************************/ - //if(DiffHist){ - - TH1F *DifDoTr2ANdaxvAzim = new TH1F("DifDoTr2AndaxvAzim","Diference between Azimutal angles",360,-180,180); - TH1F *DifDoTr2ANdaxvZenit = new TH1F("DifDoTr2AndaxvZenit","Diference between Zenit angles",360,-180,180); - - //} - - /*************************************************************************************/ - //Histogramm for Pamela's angular efficiency - /*************************************************************************************/ - - TH2F *PamAngEffhigh = new TH2F("PamAngEffhigh","Zenit Angle, deg; Azimutal Angle, deg",360,0,360,100,80,180); - TH2F *PamAngEfflow = new TH2F("PamAngEfflow","Zenit Angle, deg; Azimutal Angle, deg",360,0,360,100,80,180); - TCanvas *c7 = new TCanvas("c7","Pamela's angular efficiency", 1600,2000); - - /*************************************************************************************/ - //Hystogramm to count how much time Pamela have each PitchAngle - /*************************************************************************************/ - - TH1F *PitchTime = new TH1F("PitchTime","Time for Pitch",360,0,360); - TCanvas *c8 = new TCanvas("c8","PitchTime",1200,600); - - TH1F *PitchExposure = new TH1F("PitchExposure","Time for Pitch",360,0,360); - TCanvas *c9 = new TCanvas("c9","PitchTime",1200,600); + if(opt.opt.verbose>=2) cout<<"\n--DiffHyst Hystogramm block...\n\n"; + /***************************************************************************************/ //Initialization histogramms for count of protons depends from Energy. Volodia. /***************************************************************************************/ -/* - TH1F* proton10log= new TH1F("Protons Flux","",80,-1.,3.); - proton10log->GetXaxis()->SetTitle("log10(Energy) , GeV"); - TH1F* proton1log= new TH1F("Protons Flux","",80,-1.,3.); - TH1F* binw= new TH1F("w","",80,-1.,3.); - proton1log->GetXaxis()->SetTitle("log10(Energy) , GeV"); - proton1log->SetLineColor(kRed); - TCanvas *plogCanvas = new TCanvas("proton flux","protonflux", 800, 800); + +// TH1F* proton10log= new TH1F("Protons Flux","",80,-1.,3.); +// proton10log->GetXaxis()->SetTitle("log10(Energy) , GeV"); +// TH1F* proton1log= new TH1F("Protons Flux","",80,-1.,3.); + //TH1F* binw= new TH1F("w","",80,-1.,3.); + TH1F binw; + binw.SetBins(80,-1.,3.); +// proton1log->GetXaxis()->SetTitle("log10(Energy) , GeV"); +// proton1log->SetLineColor(kRed); +// TCanvas *plogCanvas = new TCanvas("proton flux","protonflux", 800, 800); // this is bins wide to calculate Flux - Float_t x; - Float_t xmin, xmax; - Float_t binwide[80]; + //Float_t x; + //Float_t xmin, xmax; + //Float_t binwide[80]; for (Int_t l=0 ; l<80; l++) { - binw->Fill(-1.+0.05*l,pow(10.,0.05*(Float_t)(l+1)-1.)- pow(10.,0.05*(Float_t)(l)-1.)); + binw.Fill(-1.+0.05*l,pow(10.,0.05*(Float_t)(l+1)-1.)- pow(10.,0.05*(Float_t)(l)-1.)); + //binwide[l]=-1.+0.05*l,pow(10.,0.05*(Float_t)(l+1)-1.)- pow(10.,0.05*(Float_t)(l)-1.) } - for (Int_t l=0 ; l<80; l++) { - binwide[l]=binw->GetBinContent(l+1); - } -*/ + //for (Int_t l=0 ; l<80; l++) { + //binwide[l]=binw->GetBinContent(l+1); +// } + /****************************************************************************/ //Geometrical Factor. Volodia /****************************************************************************/ @@ -305,458 +1161,662 @@ //General loop /****************************************************************************/ - for(ULong_t i=0; iGetEntry(i); + Bool_t OneTrack = false; + + if(pam_events->GetTrkLevel2()->GetNTracks()==1) OneTrack = true; - if(pam_events->GetTrkLevel2()->GetNTracks()==1){ - - /*************************************************************************/ - //Getting general parameters - /*************************************************************************/ - - track = pam_events->GetTrack(0); - Int_t M0DE = pam_events->GetOrbitalInfo()->mode; //0 is zero here - Float_t Bx = -pam_events->GetOrbitalInfo()->Bdown; - Float_t By = pam_events->GetOrbitalInfo()->Beast; - Float_t Bz = pam_events->GetOrbitalInfo()->Bnorth; - Float_t Babs = pam_events->GetOrbitalInfo()->Babs; - Float_t L = pam_events->GetOrbitalInfo()->L; - Float_t rigev = 1/track->GetTrkTrack()->GetDeflection(); - - /*************************************************************************/ - //Track selection - /*************************************************************************/ - - ntr = 0; - if ((track->GetTrkTrack()->chi2<=0) || (track->GetTrkTrack()->chi2>=500)) ntr=-1; - for(Int_t ii=1;ii<=12;ii++){ - if ((track->GetToFTrack()->beta[i]<0) || (track->GetToFTrack()->beta[i]>99)) ntr=-1; - } - if((track->GetTrkTrack()->GetNX()<=4)&&(track->GetTrkTrack()->GetNY()<4)) ntr=-1; - if((M0DE!=0)&&(M0DE!=1)&&(M0DE!=6)&&(M0DE!=2)&&(M0DE!=3)&&(M0DE!=8)&&(M0DE!=4)) ntr=-1; - if(sqrt(pow(Bx,2)+pow(By,2)+pow(Bz,2))<0.001) ntr=-1; - if(rigev<0.600) ntr=-1; - - if(ntr!=-1 || PamExp){ - - /*******************************************************************************/ - //Transit reference system - /*******************************************************************************/ - - TMatrixD Fij = PO->ECItoGreenwich(PO->QuatoECI(pam_events->GetOrbitalInfo()->q0,pam_events->GetOrbitalInfo()->q1,pam_events->GetOrbitalInfo()->q2,pam_events->GetOrbitalInfo()->q3),pam_events->GetOrbitalInfo()->absTime); - TMatrixD Dij = PO->GreenwichtoGEO(pam_events->GetOrbitalInfo()->lat,pam_events->GetOrbitalInfo()->lon,Fij); - TMatrixD Iij = PO->ColPermutation(Dij); - - /*****************************************************************************/ - //Calculate Zenit and Azimutal angle and vector of particle flight in Pamela - //using axv[0] and ayv[0] variables - /*****************************************************************************/ + Int_t M0DE = pam_events->GetOrbitalInfo()->mode; //0 is zero here + Float_t Bx = -pam_events->GetOrbitalInfo()->Bdown; //don't need for PamExp ExpOnly for all geography areas + Float_t By = pam_events->GetOrbitalInfo()->Beast; //don't need for PamExp ExpOnly for all geography areas + Float_t Bz = pam_events->GetOrbitalInfo()->Bnorth; //don't need for PamExp ExpOnly for all geography areas + Float_t Babs = pam_events->GetOrbitalInfo()->Babs; //don't need for PamExp ExpOnly for all geography areas + Float_t L = pam_events->GetOrbitalInfo()->L; //don't need for PamExp ExpOnly for all geography areas + Float_t Alt = pam_events->GetOrbitalInfo()->alt; + Float_t Lat = pam_events->GetOrbitalInfo()->lat; + Float_t Lon = pam_events->GetOrbitalInfo()->lon; + Float_t LieveTime = 0.16*pam_events->GetTrigLevel2()->dltime[0]; + Float_t DeathTime = 0.01*pam_events->GetTrigLevel2()->dltime[1]; + Float_t rigev = 0; + Float_t detr = 0; + Int_t hm0; Int_t hm1; + Int_t hs0; Int_t hs1; + + ntr = 0; + + Double_t A1; Double_t A2; Double_t A3; + Double_t SB = 1000; Double_t SA; Double_t SC; Double_t ZC; + + if(OneTrack){ + track = pam_events->GetTrack(0); //don't need for PamExp option + rigev = 1/track->GetTrkTrack()->GetDeflection(); //dont need for AnglHyst, DiffHyst and PamExp options; + detr = track->GetTrkTrack()->GetDEDX(); + hm0 = pam_events->GetAcLevel2()->hitmap[0]; + hm1 = pam_events->GetAcLevel2()->hitmap[1]; + hs0 = pam_events->GetAcLevel2()->hitstatus[0]; + hs1 = pam_events->GetAcLevel2()->hitstatus[1]; + + if(!OneTrack) ntr = -1; else{ + //cout<<"OneTrack"<GetTrkTrack()->GetDeflection())*1.85+3.0; + if ((track->GetTrkTrack()->chi2<=0) || (track->GetTrkTrack()->chi2>=pow(ichi2lim,4.))) ntr=-1; + /*for(Int_t ii=1;ii<=12;ii++){ + if ((track->GetToFTrack()->beta[ii]<0) || (track->GetToFTrack()->beta[ii]>99)) ntr=-1; + }*/ + if ((track->GetToFTrack()->beta[12]<0) || (track->GetToFTrack()->beta[12]>99)) ntr=-1; + if((track->GetTrkTrack()->GetNX()<=4)&&(track->GetTrkTrack()->GetNY()<4)) ntr=-1; + if(!track->GetTrkTrack()->IsInsideCavity()) ntr=-1; + if(sqrt(pow(Bx,2)+pow(By,2)+pow(Bz,2))<0.001) ntr=-1; + if((M0DE!=0)&&(M0DE!=1)&&(M0DE!=6)&&(M0DE!=2)&&(M0DE!=3)&&(M0DE!=8)&&(M0DE!=4)) ntr=-1; + } - if(!DoTr || DiffHist){ + if(ntr!=-1){ + if(!opt.opt.DoTr){ + Double_t Aaxv = TMath::Abs(track->GetTrkTrack()->axv[0])*TMath::DegToRad(); - Double_t Aayv = TMath::Abs(track->GetTrkTrack()->ayv[0])*TMath::DegToRad(); + Double_t Aayv = TMath::Abs(track->GetTrkTrack()->ayv[0])*TMath::DegToRad(); PamZenit = TMath::RadToDeg()*asin(sqrt(pow(sin(Aayv), 2) + pow(sin(Aaxv), 2))); - - Double_t axv = -track->GetTrkTrack()->axv[0] * TMath::DegToRad(); - Double_t ayv = -track->GetTrkTrack()->ayv[0] * TMath::DegToRad(); - Double_t angle = atan(sin(TMath::Abs(ayv))/sin(TMath::Abs(axv))) * TMath::RadToDeg(); - - PamAzim = 360. - angle; - if(axv>=0 && ayv >=0) PamAzim = angle; - if(axv<0 && ayv >0) PamAzim = 180. - angle; - if(axv<0 && ayv <0) PamAzim = 180. + angle; - - PamAzim = PamAzim * TMath::DegToRad(); - PamZenit = (180 - PamZenit) * TMath::DegToRad(); - Px = sin(axv); - Py = sin(ayv); - Pz = cos(PamZenit); - + + Double_t axv = -track->GetTrkTrack()->axv[0] * TMath::DegToRad(); + Double_t ayv = -track->GetTrkTrack()->ayv[0] * TMath::DegToRad(); + Double_t angle = atan(sin(TMath::Abs(ayv))/sin(TMath::Abs(axv))) * TMath::RadToDeg(); + + PamAzim = 360. - angle; + if(axv>=0 && ayv >=0) PamAzim = angle; + if(axv<0 && ayv >0) PamAzim = 180. - angle; + if(axv<0 && ayv <0) PamAzim = 180. + angle; + + PamAzim = PamAzim * TMath::DegToRad(); + PamZenit = (180 - PamZenit) * TMath::DegToRad(); + Px = sin(axv); + Py = sin(ayv); + Pz = cos(PamZenit); + + //cout<<"PamAzimuth = "<opt.US[jy].USP[jx].Bmore && Lopt.US[jy].USP[jx].Lmore && Altopt.US[jy].USP[jx].altmore && SBopt.PS[jz].PitchMin){ + for(Int_t hg = 0; hgGetTrigLevel2()->dltime[0]; + opt.Hyst1D[thg].HI.DeathTime+= 0.01*pam_events->GetTrigLevel2()->dltime[1]; + //cout<<"Pitch = "<GetTrigLevel2()->dltime[0]; + opt.Hyst2D[thg].HI.DeathTime+= 0.01*pam_events->GetTrigLevel2()->dltime[1]; + } + } + } + for(Int_t hg = 0; hgGetTrigLevel2()->dltime[0]; + opt.Hyst3D[thg].HI.DeathTime+= 0.01*pam_events->GetTrigLevel2()->dltime[1]; + } + } + } + jx = opt.US[jy].USP.size(); } } - } - - } - - /***********************************************************************/ - //Filling hystogram to count how much time Pamela have each Pitch-Angle - /***********************************************************************/ - - if(PamAngTime) { - - Float_t AnglTime = 0.16*pam_events->GetTrigLevel2()->dltime[0]+0.01*pam_events->GetTrigLevel2()->dltime[1]; - PitchTime->Fill(SA,AnglTime); - - } - - if(AnglHist){ + } + } + } + //cout<GetTrigLevel2()->dltime[0]; - PitchExpositionBrazil->Fill(SB,Argv); - MainAxisPamelaExpositionBrazil->Fill(SA,Argv); - PitchExpositionNoOrientationBrazil->Fill(SC,Argv); - PitchCountBrazil->Fill(SB); - MainAxisPamelaCountBrazil->Fill(SA); - PitchCountNoOrientationBrazil->Fill(SC); - ZenitAngle->Fill(ZC); - PitchvsLatInBrazil->Fill(pam_events->GetOrbitalInfo()->lat,SA); - LieveTimevsLatInBrazil->Fill(pam_events->GetOrbitalInfo()->lat,Argv); - } - - /***********************************************************************/ - //Filling angulars histogramms for areas without Brazil - /***********************************************************************/ + if(ntr!=-1){ + + Bool_t verb = false; + if(opt.opt.Nverb!=-1) if(i>=opt.opt.Nverb) verb = true; + //if(opt.opt.Nverb==-1) verb = false; + + if(verb) cout<<"\n\ni = "<GetCaloTrack()->qpre; + Int_t calonpre=track->GetCaloTrack()->npre; + Float_t caloqtrack=track->GetCaloTrack()->qtrack; + Float_t caloqmax=pam_events->GetCaloLevel2()->qmax; + Int_t dncore=track->GetCaloTrack()->ncore; + Int_t lepton = 0; + Bool_t ACSelection = false; + + if((hm0 & hs0)==0 && (hm1 & hs1)==0) ACSelection = true; + //cout<<"hm0 = "<0.24){ - Argv = 0.16*pam_events->GetTrigLevel2()->dltime[0]; - PitchExpositionWithoutBrazil->Fill(SB,Argv); - MainAxisPamelaExpositionWithoutBrazil->Fill(SA,Argv); - PitchExpositionNoOrientationWithoutBrazil->Fill(SC,Argv); - PitchCountWithoutBrazil->Fill(SB); - MainAxisPamelaCountWithoutBrazil->Fill(SA); - PitchCountNoOrientationWithoutBrazil->Fill(SC); - ZenitAngle->Fill(ZC); - - /***************************************************************/ - //Filling angulars histogramm for equator - /***************************************************************/ - - if(L<1.2){ - Argv = 0.16*pam_events->GetTrigLevel2()->dltime[0]; - PitchExpositionEquator->Fill(SB,Argv); - MainAxisPamelaExpositionEquator->Fill(SA,Argv); - PitchExpositionNoOrientationEquator->Fill(SC,Argv); - PitchCountEquator->Fill(SB); - MainAxisPamelaCountEquator->Fill(SA); - PitchCountNoOrientationEquator->Fill(SC); - ZenitAngle->Fill(ZC); - } + if(verb){ + //if(rigev>1.7 && rigev<= 1.8 && L>6 && Lat>60 && Lat<-60){ + cout<<"rigev = "<>rigev; + cout<<"Write detr, please:"<>detr; + cout<<"Write lepton, please:"<>lepton; + cout<<"Write Anticounter, please:"<>ACSelection; + cout<<"Write Babs, please:"<>Babs; + cout<<"Write L, please:"<>L; + cout<<"Write Altitude, please:"<>Alt;*/ - } // if(AnglHist) - - } // if(PamEff||AnglHist) - + Double_t Rmin = 0; + Double_t Rmax = 0; + Double_t Detrmin = 0; + Double_t Detrmax = 0; + for(Int_t k=0;k>we; + } + jx = opt.US[nus].USP.size(); + } + } + } + for(Int_t cu=0;cuBmore && BabsLmore && Laltmore && AltRmore && rigevPmore && SB1.7 && rigev<= 1.8){ + cout<<"nus = "<>we; + } + jx = opt.US[nus].USP.size(); + } + } + } + for(Int_t d=0;dRmin && rigev<=Rmax && detr>Detrmin && detr<=Detrmax){ + Int_t ExpType = opt.Hyst1D[N1D[d]].HI.ExpType; + Double_t LTI = 0; + Double_t DTI = 0; + if(ExpType == 1 || ExpType == 3) LTI = 0.16*pam_events->GetTrigLevel2()->dltime[0]; + if(ExpType == 2 || ExpType == 3) DTI = 0.01*pam_events->GetTrigLevel2()->dltime[1]; + switch ( ExpType ){ + case 1:{Argv = LTI;break;} + case 2:{Argv = DTI;break;} + case 3:{Argv = LTI+DTI;break;} + case 4:{ + Argv = opt.Hyst1D[N1D[d]].HI.LieveTime; + opt.Hyst1D[N1D[d]].HI.LieveTime = 0; + break; + } + case 5:{ + Argv = opt.Hyst1D[N1D[d]].HI.DeathTime; + opt.Hyst1D[N1D[d]].HI.DeathTime = 0; + break; + } + case 6:{ + Argv = opt.Hyst1D[N1D[d]].HI.LieveTime+opt.Hyst1D[N1D[d]].HI.DeathTime; + opt.Hyst1D[N1D[d]].HI.LieveTime = 0; + opt.Hyst1D[N1D[d]].HI.DeathTime = 0; + break; + } + }; + Double_t Xfill = 0; + //cout<<"XType = "<Divide(1,6); - c2->Divide(1,6); - c3->Divide(1,6); - c4->Divide(1,7); - c5->Divide(1,2); + TCanvas* Canv; + TCanvas* Canvdiv; + TCanvas* CanvExp; + TCanvas* CanvLog; + TString Ext[3]; + Ext[0] = ".jpg"; Ext[1] = ".png"; Ext[2] = ".bmp"; - } - - /***************************************************************************************/ - //Canvas for histogramms for diferences in results between calculating using DoTrack2 - //and using axv[0], ayv[0] - /**************************************************************************************/ - - if(DiffHist){ - - c6->Divide(1,2); - - } - - /**************************************************************************************/ - //Canvas for Pamela's efficiency hystogramm - /**************************************************************************************/ + if(opt.opt.verbose>=2) cout<<"\n\nSave block...\n\n"; - if(PamEff){ - - c7->Divide(1,2); - - } + gStyle->SetPalette(1); - /**************************************************************************************/ - //Draw Angular Histogramms - /**************************************************************************************/ - - if(AnglHist){ - - c1->cd(1); - MainAxisPamelaExpositionBrazil->Draw(); - c1->cd(2); - MainAxisPamelaCountBrazil->Draw(); - c1->cd(3); - PitchExpositionNoOrientationBrazil->Draw(); - c1->cd(4); - PitchCountNoOrientationBrazil->Draw(); - c1->cd(5); - DiferenceBetweenNoOrientationAndWithOrientationBrazil->Divide(PitchExpositionNoOrientationBrazil,MainAxisPamelaExpositionBrazil); - DiferenceBetweenNoOrientationAndWithOrientationBrazil->Draw(); - c1->cd(6); - for(Int_t iu=0;iu<360;iu++){ - BinContent = DiferenceBetweenNoOrientationAndWithOrientationBrazil->GetBinContent(iu); - DifferenceCountInBrazil->Fill(BinContent); - } - DifferenceCountInBrazil->Draw(); - //DifferenceCountInBrazil->SaveAs((TString)outdir+"PIC001A_BrazilExpositionAndCount.root"); - c1->SaveAs((TString)outdir+"PIC001A_BrazilExpositionAndCount.jpg"); - - c2->cd(1); - MainAxisPamelaExpositionWithoutBrazil->Draw(); - c2->cd(2); - MainAxisPamelaCountWithoutBrazil->Draw(); - c2->cd(3); - PitchExpositionNoOrientationWithoutBrazil->Draw(); - c2->cd(4); - PitchCountNoOrientationWithoutBrazil->Draw(); - c2->cd(5); - DiferenceBetweenNoOrientationAndWithOrientationWithoutBrazil->Divide(PitchExpositionNoOrientationWithoutBrazil,MainAxisPamelaExpositionWithoutBrazil); - DiferenceBetweenNoOrientationAndWithOrientationWithoutBrazil->Draw(); - c2->cd(6); - for(Int_t iu=0;iu<360;iu++){ - BinContent = DiferenceBetweenNoOrientationAndWithOrientationWithoutBrazil->GetBinContent(iu); - DifferenceCountWithoutBrazil->Fill(BinContent); - } - DifferenceCountWithoutBrazil->Draw(); - c2->SaveAs((TString)outdir+"PIC003A_WithoutBrazilExpositionAndCount.jpg"); - - c3->cd(1); - MainAxisPamelaExpositionEquator->Draw(); - c3->cd(2); - MainAxisPamelaCountEquator->Draw(); - c3->cd(3); - PitchExpositionNoOrientationEquator->Draw(); - c3->cd(4); - PitchCountNoOrientationEquator->Draw(); - c3->cd(5); - DiferenceBetweenNoOrientationAndWithOrientationEquator->Divide(PitchExpositionNoOrientationEquator,MainAxisPamelaExpositionEquator); - DiferenceBetweenNoOrientationAndWithOrientationEquator->Draw(); - c3->cd(6); - for(Int_t iu=0;iu<360;iu++){ - BinContent = DiferenceBetweenNoOrientationAndWithOrientationEquator->GetBinContent(iu); - DifferenceCountEquator->Fill(BinContent); - } - DifferenceCountEquator->Draw(); - c3->SaveAs((TString)outdir+"PIC005A_EquatorExpositionAndCount.jpg"); - - c4->cd(1); - PitchExpositionBrazil->Draw(); - c4->cd(2); - PitchCountBrazil->Draw(); - c4->cd(3); - PitchExpositionWithoutBrazil->Draw(); - c4->cd(4); - PitchCountWithoutBrazil->Draw(); - c4->cd(5); - PitchExpositionEquator->Draw(); - c4->cd(6); - PitchCountEquator->Draw(); - c4->cd(7); - ZenitAngle->Draw(); - c4->SaveAs((TString)outdir+"PIC006A_PitchCountsAndExpositions.jpg"); - - c5->cd(1); - PitchvsLatInBrazil->Draw(); - c5->cd(2); - LieveTimevsLatInBrazil->Draw(); - c5->SaveAs((TString)outdir+"PIC006A_PitchvsLotitudeBrazil.jpg"); - + for(Int_t i = 0; iGetXmin(),opt.Hyst1D[i].Hyst1DF.GetXaxis()->GetXmax()); + h2n1D.SetBins(opt.Hyst1D[i].Hyst1DF.GetNbinsX(),opt.Hyst1D[i].Hyst1DF.GetXaxis()->GetXmin(),opt.Hyst1D[i].Hyst1DF.GetXaxis()->GetXmax()); + //h2div.SetBins(h12D->GetNbinsX(),h12D->GetXaxis()->GetXmin(),h12D->GetXaxis()->GetXmax(),h12D->GetNbinsY(),h12D->GetYaxis()->GetXmin(),h12D->GetYaxis()->GetXmax()); + for(Int_t ii = 0; ii < opt.Hyst1D[i].Hyst1DF.GetNbinsX(); ii++){ + h1n1D.SetBinContent(ii,opt.Hyst1D[i].Hyst1DF.GetBinContent(ii)/opt.Hyst1D[i].Hyst1DF.GetEntries()); + h2n1D.SetBinContent(ii,opt.Hyst1D[i].Hyst1DFExp.GetBinContent(ii)/opt.Hyst1D[i].Hyst1DFExp.GetEntries()); + } + hdiv.SetName(opt.Hyst1D[i].Hyst1DF.GetName()); + hdiv.SetBins(opt.Hyst1D[i].Hyst1DF.GetNbinsX(),opt.Hyst1D[i].Hyst1DF.GetXaxis()->GetXmin(),opt.Hyst1D[i].Hyst1DF.GetXaxis()->GetXmax()); + hdiv.Divide(&h1n1D,&h2n1D); + cout<<"i = "< 0){ + Canv = new TCanvas("Canv",opt.Hyst1D[i].Hyst1DF.GetName(),1200,800); + Canv->cd(); + opt.Hyst1D[i].Hyst1DF.Draw(); + Canv->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+".png"); + if(opt.Hyst1D[i].HI.ExpType!=0){ + CanvExp = new TCanvas("CanvExp",opt.Hyst1D[i].Hyst1DFExp.GetName(),1200,800); + CanvExp->cd(); + opt.Hyst1D[i].Hyst1DFExp.Draw(); + CanvExp->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"_Exp.png"); + Canvdiv = new TCanvas("Canvdiv",hdiv.GetName(),1200,800); + Canvdiv->cd(); + hdiv.Draw(); + Canvdiv->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"DivExp.png"); + } + if(opt.Hyst1D[i].XType==17){ + CanvLog = new TCanvas("CanvLog",opt.Hyst1D[i].Hyst1DF.GetName(),1200,800); + CanvLog->cd(); + hlog.Draw(); + CanvLog->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"_DivBinWide.png"); + } + } + if(opt.Hyst1D[i].HI.TypeExt == 0 || opt.Hyst1D[i].HI.TypeExt == 2){ + TFile fg((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+".root","recreate"); + opt.Hyst1D[i].Hyst1DF.Write(); + fg.Close(); + TFile fe((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"_DivWide.root","recreate"); + hlog.Write(); + fe.Close(); + if(opt.Hyst1D[i].HI.ExpType!=0){ + TFile fgExp((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"_Exp.root","recreate"); + opt.Hyst1D[i].Hyst1DFExp.Write(); + fg.Close(); + TFile fgdiv((TString)outdir+"ParDirCalc_"+opt.Hyst1D[i].HI.filename+"_DivExp.root","recreate"); + hdiv.Write(); + fgdiv.Close(); + } + + } } - - /***************************************************************************************/ - //Draw hystogramms for diferences in results between calculating using DoTrack2 - //and using axv[0], ayv[0] - /**************************************************************************************/ - - if(DiffHist){ - - c6->cd(1); - DifNicoANdMeAzim->Draw(); - c6->cd(2); - DifNicoANdMeZenit->Draw(); - c6->SaveAs((TString)outdir+"PIC001Diference.jpg"); - + for(Int_t i = 0; iGetXmin(),opt.Hyst2D[i].Hyst2DF.GetXaxis()->GetXmax(),opt.Hyst2D[i].Hyst2DF.GetNbinsY(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmin(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmax()); + h2n2D.SetBins(opt.Hyst2D[i].Hyst2DF.GetNbinsX(),opt.Hyst2D[i].Hyst2DF.GetXaxis()->GetXmin(),opt.Hyst2D[i].Hyst2DF.GetXaxis()->GetXmax(),opt.Hyst2D[i].Hyst2DF.GetNbinsY(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmin(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmax()); + //h2div.SetBins(h12D->GetNbinsX(),h12D->GetXaxis()->GetXmin(),h12D->GetXaxis()->GetXmax(),h12D->GetNbinsY(),h12D->GetYaxis()->GetXmin(),h12D->GetYaxis()->GetXmax()); + for(Int_t ii = 0; ii < opt.Hyst2D[i].Hyst2DF.GetNbinsX(); ii++){ + for(Int_t j = 0; j < opt.Hyst2D[i].Hyst2DF.GetNbinsY(); j++){ + h1n2D.SetBinContent(ii,j,opt.Hyst2D[i].Hyst2DF.GetBinContent(ii,j)/opt.Hyst2D[i].Hyst2DF.GetEntries()); + h2n2D.SetBinContent(ii,j,opt.Hyst2D[i].Hyst2DFExp.GetBinContent(ii,j)/opt.Hyst2D[i].Hyst2DFExp.GetEntries()); + } + } + hdiv.SetName(opt.Hyst2D[i].Hyst2DF.GetName()); + hdiv.SetBins(opt.Hyst2D[i].Hyst2DF.GetNbinsX(),opt.Hyst2D[i].Hyst2DF.GetXaxis()->GetXmin(),opt.Hyst2D[i].Hyst2DF.GetXaxis()->GetXmax(),opt.Hyst2D[i].Hyst2DF.GetNbinsY(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmin(),opt.Hyst2D[i].Hyst2DF.GetYaxis()->GetXmax()); + //cout<<"I try to divide it!!!"<cd(); + //cout<<"Canvas..."<SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst2D[i].HI.filename+".png"); + cout<<"Save canvas..."<cd(); + opt.Hyst2D[i].Hyst2DFExp.Draw("colz"); + CanvExp->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst2D[i].HI.filename+"_Exp.png"); + Canvdiv = new TCanvas("Canvdiv",hdiv.GetName(),1200,800); + Canvdiv->cd(); + hdiv.Draw("colz"); + Canvdiv->SaveAs((TString)outdir+"ParDirCalc_"+opt.Hyst2D[i].HI.filename+"DivExp.png"); + } + } + if(opt.Hyst2D[i].HI.TypeExt == 0 || opt.Hyst2D[i].HI.TypeExt == 2){ + TFile fg((TString)outdir+"ParDirCalc_"+opt.Hyst2D[i].HI.filename+".root","recreate"); + opt.Hyst2D[i].Hyst2DF.Write(); + fg.Close(); + if(opt.Hyst2D[i].HI.ExpType!=0){ + TFile fgExp((TString)outdir+"ParDirCalc_"+opt.Hyst2D[i].HI.filename+"_Exp.root","recreate"); + opt.Hyst2D[i].Hyst2DFExp.Write(); + fg.Close(); + cout<<"I'm here!"<cd(); - PitchTime->Draw(); - c8->SaveAs((TString)outdir+"PIC002PamAngTime.jpg"); - } - - if(PamExp){ - - c9->cd(); - PitchExposure->Draw(); - c9->SaveAs((TString)outdir+"PIC003PamAngTime.jpg"); - - } - - /**************************************************************************************/ - //Draw Hystogramm for Pamela's angular efficiency - /**************************************************************************************/ - gStyle->SetPalette(1); - - if(PamEff){ - c7->cd(1); - PamAngEffhigh->Draw("colz"); - TFile fh((TString)outdir+"PamAngEfficiencyHighEnergy.root","recreate"); - PamAngEffhigh->Write(); - fh.Close(); - //PamAngEffhigh->SaveAs((TString)outdir+"PamAngEfficiencyHighEnergy.root"); - c7->cd(2); - PamAngEfflow->Draw("colz"); - TFile fl((TString)outdir+"PamAngEfficiencyLowEnergy.root","recreate"); - PamAngEffhigh->Write(); - fl.Close(); - //PamAngEfflow->SaveAs((TString)outdir+"PamAngEfficiencyLowEnergy.root"); - c7->SaveAs((TString)outdir+"PIC001PamAngEfficiencyHighEnergy.jpg"); - - } - /**************************************************************************************/ //Draw hystogramms for protons. Volodia /**************************************************************************************/