double Getmean(TString sys1, TString sys2, float cent1, float cent2){ gROOT->SetStyle("Plain"); TFile *infile = TFile::Open(Form("glau_%s%s_ntuple_1M.root",sys1.Data(),sys2.Data())); infile->cd(); TH2F *pEcc2B = new TH2F("pEcc2B","#epsilon_{2} vs impact paramter in 200 GeV Collisions from Glauber MC;B;#epsilon_{n}",25200,-0.5,251.5,100,0,1); if(sys2.Contains("smeared")){ TNtuple *nt = (TNtuple*)infile->Get("nt"); nt->Project("pEcc2B","Ecc3G:B"); } else{ TNtuple *nt = (TNtuple*)infile->Get(Form("nt_%s_%s",sys1.Data(),sys2.Data())); nt->Project("pEcc2B","Ecc2:B"); } TH1D* hB = (TH1D*)pEcc2B->ProjectionX("hB",0,-1); for(int ibin=0;ibin<hB->GetNbinsX();ibin++){ if(hB->Integral(0,ibin) >= cent1 /100. * hB->Integral()){ int bin1 = ibin; break;} } for(int ibin=0;ibin<hB->GetNbinsX();ibin++){ if(hB->Integral(0,ibin) >= cent2 /100. * hB->Integral()){ int bin2 = ibin; break;} } cout<< bin1 << "\t" << bin2 << endl; TH1D* hEcc2 = (TH1D*)pEcc2B->ProjectionY("hEcc2",bin1,bin2); // hEcc2->Draw(); cout << hEcc2 -> GetEntries() << endl; double mean = hEcc2->GetMean(); return mean; }
void Hijing() { TFile *fin = TFile::Open("/sphenix/user/pinkenbu/jade/hijingdat2.root"); gROOT->cd(); TH1 *hjbkg = new TH1F("hjbkg","Hijing Background",100,0.,0.5); TNtuple *de = (TNtuple *) fin->Get("de"); de->Project("hjbkg","dtotal","(ID<=2)*edep/250."); char fname [100]; sprintf(fname, "Gamma_Neutron_Hijing_Energy_Graphs.root"); TFile *fout = TFile::Open(fname,"UPDATE"); hjbkg->Write(); fout->Write(); fout->Close(); fin->Close(); }
void testMM() { //TFile *fout = new TFile("fout.root","recreate"); TH1F *hx1 = new TH1F("hx1","hx1",100,0,1); TH1F *hx2 = new TH1F("hx2","hx2",100,0,1); TH1F *hx3 = new TH1F("hx3","hx3",100,0,1); TH1F *hchi2 = new TH1F("hchi2","hchi2",1000,0,2000); TH1F *mc1, *mc2, *mc3, *data, *tmp; mc1 = new TH1F("mc1","mc1",bins,x1,x2); mc2 = new TH1F("mc2","mc2",bins,x1,x2); mc3 = new TH1F("mc3","mc3",bins,x1,x2); TNtuple *d = new TNtuple("d","d","x:weight"); TH1F *pred = new TH1F("pred","pred",bins,x1,x2); TH1F *truth = new TH1F("truth","truth",bins,x1,x2); data = new TH1F("data","data",bins,x1,x2); tmp = new TH1F("tmp","tmp",bins,x1,x2); mc1->Sumw2(); mc2->Sumw2(); mc3->Sumw2(); data->Sumw2(); //GenerateData(mc1,mc2,mc3,data); GenerateDataUnbinned(mc1,mc2,mc3,d); d->Project("data","x","weight"); TCanvas *cc = new TCanvas ("temp","temp",600,600); data->Draw(); cc->SaveAs("data.pdf"); cout<<"???"<<data->Integral()<<endl; double chi2 = Fit(mc1,mc2,mc3,d,hx1,hx2,hx3,hchi2); cout<<"Fit chi2 = "<<chi2<<endl; TH1F *mctmp1, *mctmp2, *mctmp3; mctmp1 = (TH1F *)mc1->Clone("mctmp1x"); mctmp2 = (TH1F *)mc2->Clone("mctmp2x"); mctmp3 = (TH1F *)mc3->Clone("mctmp3x"); ShakeMC(mc1,mc2,mc3,mctmp1,mctmp2,mctmp3); TCanvas *c2 = new TCanvas("c2","c2",600,600); mc1->Draw(); mctmp1->Draw("same"); TCanvas *c3 = new TCanvas("c3","c3",600,600); hx1->Draw(); hx2->Draw("same"); hx3->Draw("same"); double ymax = hx1->GetMaximum(); TLine *l1 = new TLine(x1true,0,x1true,ymax); l1->SetLineWidth(2.0);l1->SetLineColor(kRed); l1->Draw(); TLine *l2 = new TLine(x2true,0,x2true,ymax); l2->SetLineWidth(2.0);l2->SetLineColor(kRed); l2->Draw(); TLine *l3 = new TLine(x3true,0,x3true,ymax); l3->SetLineWidth(2.0);l3->SetLineColor(kRed); l3->Draw(); TCanvas *cchi2 = new TCanvas("cchi2","cchi2",600,600); hchi2->Draw(); cout<<"x1 = "<<hx1->GetMean()<<"±"<<hx1->GetStdDev()<<endl; cout<<"x2 = "<<hx2->GetMean()<<"±"<<hx2->GetStdDev()<<endl; cout<<"x3 = "<<hx3->GetMean()<<"±"<<hx3->GetStdDev()<<endl; cout<<"Median 1 "<<median1(hx1)<<endl; cout<<"Median 2 "<<median1(hx2)<<endl; cout<<"Median 3 "<<median1(hx3)<<endl; double xx[]={x1true,x2true,x3true}; //cout<<"Chi2 of truth = "<<Chi2(xx)<<endl; mc1->Scale(hx1->GetMean()); mc2->Scale(hx2->GetMean()); mc3->Scale(hx3->GetMean()); pred->Add(mc1); pred->Add(mc2); pred->Add(mc3); pred->SetMarkerColor(kBlue); truth->Add(mc1,x1true/mc1->Integral()); truth->Add(mc2,x2true/mc2->Integral()); truth->Add(mc3,x3true/mc3->Integral()); truth->SetMarkerColor(kBlack); data->Scale(1/data->Integral()); data->SetMarkerColor(kRed); TCanvas *c1 = new TCanvas("c1","c1",600,600); data->Draw(); mc1->Draw("same,hist"); mc2->Draw("same,hist"); mc3->Draw("same,hist"); pred->Draw("same"); data->Draw("same"); truth->Draw("same"); float legendx1 = 0.65, legendy1 = 0.65, legendx2 = 0.84, legendy2 = 0.84; TLegend *l = new TLegend(legendx1,legendy1,legendx2,legendy2); l->AddEntry(pred,"Fit","P"); l->AddEntry(data,"Data","P"); l->AddEntry(truth,"Truth","P"); l->Draw(); }
void fragmentEnergyDistributionDifferentAngles() { gStyle->SetOptStat(0000000000); //remove the for this graphs totally redundant statbox // gROOT->SetStyle("clearRetro"); TString pDepth, fragment, Znum, normToOneAtZeroAngle; cout << "Enter phantom depth (eg. 27.9, see experimentalData directory for choices): "; cin >> pDepth; TString simulationDataPath = "IAEA_" + pDepth + ".root"; TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); dir.ReplaceAll("basic.C",""); dir.ReplaceAll("/./","/"); ifstream in; in.open(Form("experimentalData/iaeaBenchmark/fragmentEnergySpctra279mmWater0deg.dat",dir.Data())); Float_t f1,f2,f3, f4,f5,f6; Int_t nlines = 0; TFile *f = new TFile("fragmentEnergyWithAngularDistribution.root","RECREATE"); TNtuple *ntuple = new TNtuple("ntuple","Data from ascii file","Energy:He:B:H:Li:Be"); Char_t DATAFLAG[4]; Int_t NDATA; Char_t n1[6], n2[2], n3[2], n4[2], n5[2], n6[2]; in >> DATAFLAG >> NDATA ; // Read EXFOR line: 'DATA 6' in >> n1 >> n2 >> n3 >> n4 >> n5 >> n6; // Read column titles: 'Energy He B [...]' cout <<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<"\n"; while (1) { in >> f1 >> f2 >> f3 >>f4 >> f5 >> f6; if (!in.good()) break; if (nlines < 500 ) printf("%f %0.2f %0.2f %0.2f %0.2f %0.2f \n",f1,f2,f3,f4,f5,f6); ntuple->Fill(f1,f2,f3,f4,f5,f6); nlines++; } //Let's pull in the simulation-data TFile *MCData = TFile::Open("IAEA_200000.root"); TNtuple *fragments = (TNtuple*) MCData->Get("fragmentNtuple"); //Block bellow pulls out the simulation's metadata from the metadata ntuple. TNtuple *metadata = (TNtuple*) MCData->Get("metaData"); Float_t events, detectorDistance,waterThickness,beamEnergy,energyError,phantomCenterDistance; metadata->SetBranchAddress("events",&events); metadata->SetBranchAddress("waterThickness",&waterThickness); metadata->SetBranchAddress("detectorDistance",&detectorDistance); metadata->SetBranchAddress("beamEnergy",&beamEnergy); metadata->SetBranchAddress("energyError",&energyError); metadata->SetBranchAddress("phantomCenterDistance",&phantomCenterDistance); metadata->GetEntry(0); //there is just one row to consider. //good to keep for ref. G4 might give weird units due to change. metadata->Scan(); std::cout << "Recieved metadata-row: " << events << " " << detectorDistance << " " << waterThickness << " " << beamEnergy << " " << energyError << " " << phantomCenterDistance; //A lot of hardcoded histograms, ugly Double_t binAmount = 50.0; //casting from int failed somehow, so in float temporarily, fixme Double_t maxEnergy = 450.0; Double_t binWidth = maxEnergy / binAmount; TH1F *hist1 = new TH1F("hist1", "", binAmount, 0.0, maxEnergy); TH1F *hist2 = new TH1F("hist2", "", binAmount, 0.0, maxEnergy); TH1F *hist3 = new TH1F("hist3", "", binAmount, 0.0, maxEnergy); TH1F *hist4 = new TH1F("hist4", "", binAmount, 0.0, maxEnergy); TH1F *hist5 = new TH1F("hist5", "", binAmount, 0.0, maxEnergy); TH1F *hist6 = new TH1F("hist6", "", binAmount, 0.0, maxEnergy); TH1F *hist7 = new TH1F("hist7", "", binAmount, 0.0, maxEnergy); TH1F *hist8 = new TH1F("hist8", "", binAmount, 0.0, maxEnergy); TH1F *hist9 = new TH1F("hist9", "", binAmount, 0.0, maxEnergy); for(int k = 1; k <= 6; k++){ TString Znum = Form("%i", k); hist1->SetTitle("Z=" + Znum); //ALL UNITS ARE cm! Double_t detectorSideLength = 4; //40mm, as e.haettner H1 detector Double_t scatteringDistance = detectorDistance - phantomCenterDistance; //temporarily hard-coded, should be distance from target-center to detector Double_t degrees; //< actually radians Double_t r, rMin, rMax, deltaOmega, normFloat; TString rMinString, rMaxString, normString; TString same = ""; TString histName; TCanvas *c3 = new TCanvas("histograms", "Distribution (at different angles)"); int i = 0; //so that the degree steps can be varied to unevenly spaced values separate counter is used std::cout << "The following numbers also make it possible to make number of fragments comparison to the graph in A1 of E.Haettner\n"; for(Double_t j = 0.0; j <= 8.0; j=j+1.0){ i++; degrees = j * TMath::DegToRad(); //std::cout << "plotting for Z = " << Znum << " at " << j << " degrees\n"; //Distance from straight beam at the requested angle r = scatteringDistance * TMath::Tan(degrees); //now the "detector is rotated around all possible perpendicularlynangle values to beamline". //This forms an annulus with rMin and RMax as otuer and inner radiuses //Notice this will give a bit of approximation at small angles where at 0 degrees this gives a round sensor. Double_t deltaPhi = TMath::ATan((TMath::Cos(degrees)*detectorSideLength)/(2*scatteringDistance)); rMin = TMath::Max(0.0,r - (detectorSideLength/(2*TMath::Cos(degrees)))); rMax = rMin + ((detectorSideLength*TMath::Sin(degrees))/TMath::Tan((TMath::Pi()/2) - degrees - deltaPhi)) + (detectorSideLength*TMath::Cos(degrees)); rMinString = Form("%f", rMin); rMaxString = Form("%f", rMax); //normalization of the bins. deltaPhi = degrees - TMath::ATan(TMath::Tan(degrees) - detectorSideLength/(2*scatteringDistance)); // this should be around arctan(detectorsidelength/sd) if(j != 0.0){ deltaOmega = 2*TMath::Pi()*(TMath::Cos(TMath::Max(0.0,degrees-deltaPhi)) - TMath::Cos(degrees+deltaPhi)); }else{ deltaOmega = 4 * TMath::ASin(pow(detectorSideLength,2.0) / (4*pow(scatteringDistance,2) + pow(detectorSideLength,2)) ); } normFloat = deltaOmega * events * binWidth; normString = Form("/%f", normFloat); // The following is veryvery ugly relies on a bunch of hardcoded histograms because other solutions did not work histName = Form("hist%i", i); if(j != 0.0){ fragments->Project(histName,"energy", "(Z == " + Znum + " && energy > 0 && sqrt(posY^2 + posZ^2) < " + rMaxString + "&& sqrt(posY*posY + posZ*posZ) > " + rMinString + ")" + normString); }else{ fragments->Project(histName,"energy", "(Z == " + Znum + " && energy > 0 && posZ < " + rMaxString + "&& posY < " + rMaxString + " && posY > 0 && posZ > 0)" + normString); } int numEntries = fragments->GetEntries("(Z == " + Znum + " && energy > 0 && sqrt(posY^2 + posZ^2) < " + rMaxString + "&& sqrt(posY*posY + posZ*posZ) > " + rMinString + ")"); std::cout << "\nj: "<< numEntries/(deltaOmega * events) << " entries for " << j; } //the ugly hardcoded histograms being plotted //0 degrees hist1->SetLineColor(kBlue); hist1->Draw(); //1 degree hist2->SetLineColor(kGreen); hist2->Draw("same"); //add "same" when also plotting 0 degrees //2 degrees hist3->SetLineColor(kRed); hist3->Draw("same"); //3 degrees //hist4->SetLineColor(kGreen + 5); //hist4->Draw("same"); //4 degrees hist5->SetLineColor(kGreen + 3); //gives a darker shade of green hist5->Draw("same"); //5 degrees //hist6->SetLineColor(kRed); //hist6->Draw("same"); //6 degrees hist7->SetLineColor(kRed); hist7->Draw("same"); //7 degrees //hist8->SetLineColor(kRed); //hist8->Draw("same"); //8 degrees //hist9->SetLineColor(kRed); //hist9->Draw("same"); // Legends for the data leg = new TLegend(0.9,0.7,1,1); //coordinates are fractions leg->SetHeader("Angles"); leg->AddEntry(hist1,"0","l"); leg->AddEntry(hist2,"1","l"); leg->AddEntry(hist3,"2","l"); leg->AddEntry(hist5,"4","l"); leg->AddEntry(hist7,"6","l"); leg->Draw(); c3->SaveAs("AEDistrib" + Znum + ".png"); } in.close(); f->Write(); }
void plotGlauberCenVars(Float_t eff=1., const Char_t* file="ZNA_ntuple_195483.root") { TFile *f = TFile::Open(file); TNtuple* ntuple = dynamic_cast<TNtuple*> (f->Get("gnt")); TGraphErrors *gNpart=new TGraphErrors(0); gNpart->SetName("gNpart"); TGraphErrors *gNcoll=new TGraphErrors(0); gNcoll->SetName("gNcoll"); TGraphErrors *gtAA=new TGraphErrors(0); gtAA->SetName("gtAA"); /*TFile *ffd = TFile::Open("hZNAcalibRUN195483.root"); TH1F * hd = dynamic_cast<TH1F*> (ffd->Get(("hZNA"))); hd->Sumw2();*/ // TFile *ff = TFile::Open("ZNA_fit_195483.root"); TH1F * hd = dynamic_cast<TH1F*> (ff->Get(("hZNA"))); hd->Sumw2(); TH1F * hg = dynamic_cast<TH1F*> (ff->Get(("hZNA_GLAU"))); hd->SetMarkerColor(kBlue+3); hd->SetMarkerSize(1.); hd->SetLineColor(kBlue+3); hd->SetLineWidth(2); hd->SetMarkerStyle(20); hd->SetLineWidth(2); // hg->Scale(1./hd->GetEntries()); // hd->Scale(1./hd->GetEntries()); hd->SetMinimum(1.e-01); hd->SetXTitle("E_{ZNA} (TeV)"); hg->SetLineColor(kPink-2); hg->SetLineWidth(2); TH1F* hist = (TH1F*) hg->Clone("hist"); //--------------------------------------------------- getCentrality(hist, eff); //--------------------------------------------------- TCanvas* canvas = new TCanvas("canvas","Multiplicity",200,200,600,600); canvas->cd(); canvas->SetLogy(); hd->Draw("pe"); //hd->GetXaxis()->SetRangeUser(0.,130.); hd->SetMinimum(0.01); hg->Draw("SAME"); float low = 0; float high = hist->GetNbinsX(); for(int i=0; i<binUp->GetSize(); i++){ low = binUp->At(i); hist->GetXaxis()->SetRange(low+1, high); hist->SetFillColor((i%2==0)?0:kAzure+6); hist->SetLineColor((i%2==0)?0:kAzure+6); printf(" bin %d low %f high %f\n",i,low,high); hist->DrawCopy("h same"); high=low; } hd->Draw("esame"); hg->Draw("SAME"); canvas->Print("plotGlauber.gif"); TCanvas* canvas2 = new TCanvas("canvas2","NPart"); canvas2->cd(); canvas2->SetLogy(); TH1F *hist2 = new TH1F("hist2","N_{part}",35,0.,35); ntuple->Project("hist2","fNpart"); //hist2->SetStats(0); hist2->SetTitle(""); hist2->GetXaxis()->SetTitle("NPart"); hist2->GetXaxis()->SetTitleSize(0.05); hist2->GetXaxis()->SetLabelSize(0.04); hist2->GetXaxis()->SetTitleOffset(1.2); hist2->GetYaxis()->SetTitle(""); hist2->GetYaxis()->SetTitleOffset(1.3); hist2->GetYaxis()->SetTitleSize(0.05); hist2->GetYaxis()->SetLabelSize(0.04); hist2->DrawCopy(); float lownp=0; float highnp=5000; TH1F *htemp10[nbins]; printf("\n ***** N_part \n"); for(int i=0; i<Multbin->GetSize(); i++){ lownp = Multbin->At(i); char cuts[120]; char histname[20]; sprintf(cuts,"Etot>%f && Etot<=%f",lownp,highnp); sprintf(histname,"htemp10[%i]",i); htemp10[i] = new TH1F(histname,"N_{part}",35,0.,35); //printf(" cut: %s\n", cuts); ntuple->Project(histname,"fNpart",cuts); htemp10[i]->SetLineColor(i+1); htemp10[i]->Draw("same"); cout << i << " | " << lownp << " | " << highnp << " | " << setprecision(3) << htemp10[i]->GetMean() << " | " << htemp10[i]->GetRMS() << " | " << endl; gNpart->SetPoint(i,Float_t(i),htemp10[i]->GetMean()); gNpart->SetPointError(i,0,htemp10[i]->GetRMS()); highnp = lownp; } cout << endl; TCanvas* canvas3 = new TCanvas("canvas3","NColl"); canvas3->SetLogy(); TH1F *hist3 = new TH1F("hist3","N_{coll}",35,0.,35); ntuple->Project("hist3","fNcoll"); //hist3->SetStats(0); hist3->SetTitle(""); hist3->GetXaxis()->SetTitle("NColl"); hist3->GetXaxis()->SetTitleSize(0.05); hist3->GetXaxis()->SetLabelSize(0.04); hist3->GetXaxis()->SetTitleOffset(1.2); hist3->GetXaxis()->SetTitle(""); hist3->GetXaxis()->SetTitleOffset(1.3); hist3->GetXaxis()->SetTitleSize(0.05); hist3->GetXaxis()->SetLabelSize(0.04); hist3->DrawCopy(); float lownc = 0; float highnc = 5000; TH1F *htemp11[nbins]; printf("\n ***** N_coll \n"); for(int i=0; i<Multbin->GetSize(); i++){ lownc = Multbin->At(i); char cuts[120]; char histname[20]; sprintf(cuts,"Etot>%f && Etot<=%f",lownc,highnc); sprintf(histname,"htemp11[%i]",i); htemp11[i] = new TH1F(histname,"N_{coll}",35,0.,35.); ntuple->Project(histname,"fNcoll",cuts); htemp11[i]->SetLineColor(i+1); htemp11[i]->Draw("same"); cout << setprecision(3) << htemp11[i]->GetMean() << " | " << htemp11[i]->GetRMS() << " | " << endl; gNcoll->SetPoint(i,Float_t(i),htemp11[i]->GetMean()); gNcoll->SetPointError(i,0,htemp11[i]->GetRMS()); highnc = lownc; } cout << endl; TCanvas* canvas4 = new TCanvas("canvas4","Impact Parameter"); canvas4->cd(); TH1F *hist4 = new TH1F("hist4","b",100,0.,16.); ntuple->Project("hist4","fB"); //hist4->SetStats(0); hist4->SetTitle(""); hist4->GetXaxis()->SetTitle("b"); hist4->GetXaxis()->SetTitleSize(0.05); hist4->GetXaxis()->SetLabelSize(0.04); hist4->GetXaxis()->SetTitleOffset(1.2); hist4->GetYaxis()->SetTitle(""); hist4->GetYaxis()->SetTitleOffset(1.3); hist4->GetYaxis()->SetTitleSize(0.05); hist4->GetYaxis()->SetLabelSize(0.04); hist4->DrawCopy(); float lowb = 0; float highb = 5000; TH1F *htemp12[nbins]; printf("\n ***** b \n"); for(int i=0; i<Multbin->GetSize(); i++){ lowb = Multbin->At(i); char cuts[100]; char histname[25]; sprintf(cuts,"Etot>%f && Etot<=%f",lowb,highb); sprintf(histname,"htemp12[%i]",i); htemp12[i] = new TH1F(histname,"b",100,0.,16.); //printf(" cut: %s\n", cuts); ntuple->Project(histname,"fB",cuts); htemp12[i]->SetLineColor(i+1); htemp12[i]->DrawCopy("same"); cout << i << " | " << lowb << " | " << highb << " | " << setprecision(3) << htemp12[i]->GetMean() << " | " << htemp12[i]->GetRMS() << " | " << endl; highb = lowb; } TCanvas* canvas5 = new TCanvas("canvas5","Taa"); canvas5->SetLogy(); TH1F *hist5 = new TH1F("hist5","T_{AA}",100,0.,0.5); ntuple->Project("hist5","fTaa"); //hist5->SetStats(0); hist5->SetTitle(""); hist5->GetXaxis()->SetTitle("tAA"); hist5->GetXaxis()->SetTitleSize(0.05); hist5->GetXaxis()->SetLabelSize(0.04); hist5->GetXaxis()->SetTitleOffset(1.2); hist5->GetYaxis()->SetTitle(""); hist5->GetYaxis()->SetTitleOffset(1.3); hist5->GetYaxis()->SetTitleSize(0.05); hist5->GetYaxis()->SetLabelSize(0.04); hist5->DrawCopy(); float lowtaa = 0; float hightaa = 5000; TH1F *htemp13[nbins]; printf("\n ***** T_AA \n"); for (int i=0; i<Multbin->GetSize(); i++){ lowtaa = Multbin->At(i); char cuts[100]; char histname[100]; sprintf(cuts,"Etot>%f && Etot<%f",lowtaa,hightaa); //printf(" cut: %s\n", cuts); sprintf(histname,"htemp13[%i]",i); htemp13[i] = new TH1F(histname,"b",100,0.,0.5); ntuple->Project(histname,"fTaa",cuts); htemp13[i]->SetLineColor(i+1); htemp13[i]->DrawCopy("same"); cout << setprecision(3) << htemp13[i]->GetMean() << " | " << htemp13[i]->GetRMS() << " | " << endl; gtAA->SetPoint(i,Float_t(i),htemp13[i]->GetMean()); gtAA->SetPointError(i,0,htemp13[i]->GetRMS()); hightaa = lowtaa; } /*TCanvas* canvas6 = new TCanvas("canvas6","Mean Mult"); canvas6->SetLogy(); //ntuple->Draw("ntot/Npart/23.867>>hmultperanc"); ntuple->Draw("Etot/(0.801*Npart+(1-0.801)*Ncoll)/3.9>>hmultperanc"); TH1F* hmultperanc = (TH1F*)gPad->GetPrimitive("hmultperanc"); TH1F* hist6 = (TH1F*)hmultperanc->Clone(); hist6->SetStats(0); hist6->SetTitle(""); hist6->GetXaxis()->SetTitle("Mult/NPart"); hist6->GetXaxis()->SetTitleSize(0.05); hist6->GetXaxis()->SetLabelSize(0.04); hist6->GetXaxis()->SetTitleOffset(1.); hist6->GetYaxis()->SetTitle(""); hist6->GetYaxis()->SetTitleOffset(1.); hist6->GetYaxis()->SetTitleSize(0.05); hist6->GetYaxis()->SetLabelSize(0.04); hist6->DrawCopy(); low=0; high=50000; for (int i=0; i<Multbin->GetSize(); i++) { low=Multbin->At(i); char cuts[100]; char histtitle1[100]; char histtitle[100]; sprintf(cuts,"Etot>%i && Etot<%i",low,high); //sprintf(histtitle,"ntot/Npart/23.867>>htemp%i(100)",80+i); sprintf(histtitle,"Etot/(0.801*Npart+(1-0.801)*Ncoll)/3.9>>htemp%i(100)",80+i); sprintf(histtitle1,"htemp%i",80+i); ntuple->Draw(histtitle,cuts,"same"); TH1F* htemp14 = (TH1F*)gPad->GetPrimitive(histtitle1); htemp14 = (TH1F*)gPad->GetPrimitive(histtitle1); htemp14->SetFillColor(i+1); htemp14->DrawCopy("same"); //cout << i << " | " << low << " | " << high << " | " << setprecision(3) << htemp14->GetMean() << " | " << htemp14->GetRMS() << " | " << endl; high=low; h->SetBinContent(i+1,htemp14->GetMean()); h->SetBinError(i+1,0.01*htemp14->GetRMS()); } TCanvas* c7 = new TCanvas("c7","c7"); c7->cd(); h->Draw(); */ //TFile *outrootfile = new TFile("OutGlauber_Hijing.root","RECREATE"); TFile *outrootfile = new TFile("test.root","RECREATE"); outrootfile->cd(); //h->Write(); gNpart->Write(); gNcoll->Write(); gtAA->Write(); hd->Write(); outrootfile->Close(); }
void gammaJetDifferentialxjg() { TH1::SetDefaultSumw2(); TFile *inFile = TFile::Open("gammaJets_inclusive_dphi7pi8_pPbData_v2.root"); TNtuple *inTuple = (TNtuple*)inFile->Get("gammaJets"); //book histos TH1D *gammaJetEta[nhfBins]; TH1D *x_jg[nhfBins]; TH1D *hfEnergy[nhfBins]; Int_t numEvts[nhfBins]; Int_t numEvtsEtaPlus[nhfBins]; TCanvas *c[4]; c[0] = new TCanvas(); c[1] = new TCanvas(); TLegend *leg = new TLegend(0.65,0.65,0.9,0.9); leg->SetFillColor(0); for(Int_t i = 0; i < nhfBins; ++i) { TString s_gammaJetEta = "gammaJetEta"; s_gammaJetEta += i; gammaJetEta[i] = new TH1D(s_gammaJetEta,";Avg #eta_{#gamma jet};Event Fraction",14,-3,3); TString s_hfEnergy = "hfEnergy"; s_hfEnergy += i; hfEnergy[i] = new TH1D(s_hfEnergy,"",1000,0,1000); TString s_x_jg = "x_jg"; s_x_jg += i; x_jg[i] = new TH1D(s_x_jg,";p_{T}^{jet}/p_{T}^{#gamma};Event Fraction",20,0,1.5); TCut isolationCut = "(cc4 + cr4 + ct4PtCut20 < 1.0)"; //TCut etaCut = "(abs(gEta) > 1.479)"; //TCut showerShapeCut = "(sigmaIetaIeta < 0.035)"; TCut etaShowerCut = "((abs(gEta) < 1.479) && (sigmaIetaIeta < 0.01) || (abs(gEta) > 1.479) && (sigmaIetaIeta < 0.035))"; TCut ptCut = "(jPt > 30) && (gPt > 50)"; TString hfCut = Form("((HFplusEta4+HFminusEta4) > %f) && ((HFplusEta4+HFminusEta4) > %f)", hfBins[i], hfBins[i+1]); //TCut cut = isolationCut && etaCut && showerShapeCut && ptCut && hfCut; TCut cut = isolationCut && etaShowerCut && ptCut && hfCut; //printf("cut: %s\n",(const char*)cut); TString runFlip = "((run > 211257)*(-1) + (run < 211257))"; numEvts[i] = inTuple->Project(s_gammaJetEta,"avgEta*"+runFlip,cut); numEvtsEtaPlus[i] = inTuple->GetEntries( cut && "( avgEta*(run < 211257) >0 ) || ( avgEta*(run > 211257) <0 )" ); inTuple->Project(s_hfEnergy,"(HFplusEta4+HFminusEta4)",cut); inTuple->Project(s_x_jg,"jPt/gPt",cut); gammaJetEta[i]->Scale(1./numEvts[i]); gammaJetEta[i]->SetMarkerColor(i+1); gammaJetEta[i]->SetLineColor(i+1); x_jg[i]->Scale(1./numEvts[i]); x_jg[i]->SetMarkerColor(i+1); x_jg[i]->SetLineColor(i+1); TString label; label += hfBins[i]; label += " < E_{T}^{HF[|#eta|>4]} < "; label += hfBins[i+1]; leg->AddEntry(gammaJetEta[i], label, "lp"); if(i==0) { //TLatex *lnorm = new TLatex(0.2,0.85, "Monte Carlo"); //lnorm->SetNDC(1); //lnorm->SetTextSize(0.05); gammaJetEta[i]->GetXaxis()->CenterTitle(); gammaJetEta[i]->GetYaxis()->CenterTitle(); gammaJetEta[i]->SetMaximum(gammaJetEta[i]->GetMaximum()*1.7); x_jg[i]->GetXaxis()->CenterTitle(); x_jg[i]->GetYaxis()->CenterTitle(); x_jg[i]->SetMaximum(x_jg[i]->GetMaximum()*1.7); c[0]->cd(); gammaJetEta[i]->Draw(""); //lnorm->Draw("same"); c[1]->cd(); x_jg[i]->Draw(""); //lnorm->Draw("same"); } else { c[0]->cd(); gammaJetEta[i]->Draw("same"); c[1]->cd(); x_jg[i]->Draw("same"); } c[0]->cd(); gammaJetEta[i]->Draw("same Lhist"); leg->Draw(); c[1]->cd(); x_jg[i]->Draw("same Lhist"); leg->Draw(); } //c[0]->SaveAs("avgeta_gammajet_sumiso1_numevts_v2.gif"); //";E_{T}^{HF[|#eta|>4]};<#eta_{#gamma jet}>"); Double_t x[nhfBins];// = {10, 25, 40}; Double_t y[nhfBins]; Double_t ye[nhfBins]; Double_t y2[nhfBins]; Double_t y2e[nhfBins]; for(Int_t i = 0; i < nhfBins; i++) { x[i] = hfEnergy[i]->GetMean(); y[i] = gammaJetEta[i]->GetMean(); ye[i]= gammaJetEta[i]->GetMeanError(); y2[i] = x_jg[i]->GetMean(); y2e[i] = x_jg[i]->GetMeanError(); } c[2] = new TCanvas(); TGraphErrors *means = new TGraphErrors(nhfBins,x,y,0,ye); means->GetXaxis()->SetTitle("E_{T}^{HF[|#eta|>4]}"); means->GetXaxis()->CenterTitle(); means->GetYaxis()->SetTitle("<#eta_{#gamma jet}>"); means->GetYaxis()->CenterTitle(); //means->SetMinimum(-0.7); means->SetMaximum(0); means->Draw("AP"); c[3] = new TCanvas(); TGraphErrors *x_jg_means = new TGraphErrors(nhfBins,x,y2,0,y2e); x_jg_means->GetXaxis()->SetTitle("E_{T}^{HF[|#eta|>4]}"); x_jg_means->GetXaxis()->CenterTitle(); x_jg_means->GetYaxis()->SetTitle("<x_{J #gamma}>"); x_jg_means->GetYaxis()->CenterTitle(); x_jg_means->Draw("AP"); }
void EdepPercentSmall (const char *part="e")//,int nevent = 1000) { char infile[100]; int pz[9] = {1,2,4,8,12,16,32,40,50}; double x[9]; double means[9] = {0}; double y[9]; double mval = 0; int lastbincont = 0; bool lastbin = false; for (int i=0; i<9; i++) { x[i] = pz[i]; y[i] = means[i]; sprintf(infile, "/sphenix/user/jpinkenburg/ShowerSize/ntuple/%s_eta0_%dGeV.root",part, pz[i]); char hname [100]; sprintf(hname, "%s%dd",part,pz[i]); TH1F *h1 = new TH1F(hname, hname, 8000, 0, 4); TFile *f = TFile::Open(infile); gROOT->cd(); TNtuple *nt = (TNtuple *)f->Get("de"); nt->Project(hname,"dtotal","(ID<=2)*edep"); //h1->Draw(); /* for (int j = 1000; j>0; j--) { if (lastbin == false) { if (h1->GetBinContent(j) == 0) { cout << j << endl; } else { lastbin = true; lastbincont = (j/1000)*3.5; } } else { j=0; } } char revhname[100]; sprintf(revhname,"%s%dGeV",part,pz[i]); TH1F *h4 = new TH1F(revhname,revhname,10000,0,lastbincont); nt->Project(revhname,"dtotal","(ID<=2)*edep",""); */f->Close(); h1->Draw(); /* mval = h1->Integral(); // cout << "mval " << mval << endl; cout << "mval_supposed_to_be " << h4->Integral() << endl; means[i] += mval; mval = 0; cout << "6" << endl; */ char fname [100]; sprintf(fname, "%s_ThinBins.root",part); TFile *fout = TFile::Open(fname,"UPDATE"); h1->Write(); fout->Write(); cout << h1->Integral() << " " << hname << " " << pz[i] << endl; fout->Write(); fout->Close(); } /* TFile *f1 = TFile::Open("anti_neutronShowerEdepPercent.root"); gROOT->cd(); TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,1,1,0,.01); gStyle->SetOptStat(0); TMarker *mean = new TMarker(); mean->SetMarkerStyle(20); mean->SetMarkerColor(3); TMarker *test = new TMarker(); test->SetMarkerStyle(20); test->SetMarkerColor(5); TCanvas *c2 = new TCanvas("c2","stupid graph",1); double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; TGraph *gr = new TGraph(9,dtot,means); gr->Draw("AC*"); h2->Draw(); test->DrawMarker(0.5,0.005); mean->DrawMarker(0,0); double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; double z[9]; // cout << "bflmv" << meanval[0] << endl; for (int i=0;i<9;i++) { // sprintf( cout << "coming" << endl; z[i] = dtot[i]; // mean->DrawMarker(0,0); // test->DrawMarker(dtot[i],.005); cout << "meanval" << " " << dtot[i] << endl; cout << "means" << " " << means[i] << endl; // cout << means[i] << endl; } char fname [100]; sprintf(fname, "%sShowerEdepPercent.root",part); TFile *fout = TFile::Open(fname,"UPDATE"); h2->Draw(); // h2->Write(); // fout->Write(); fout->Close(); f1->Close(); */ }