//================================================ void DeltaZVsPt(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TH2F *hTrkDzVsPt = (TH2F*)hn->Projection(1,0); c = draw2D(hTrkDzVsPt,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_vs_pt_%s.png",run_type,trigName[kTrigType])); } Double_t pt_cut = 1; hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cut+0.1,100); TH1F *hMthDz = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDzVsPt_%s_proj",trigName[kTrigType])); hMthDz->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (p_{T}>%1.1f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cut)); TH1F *hClone = (TH1F*)hMthDz->Clone(Form("%s_clone",hMthDz->GetName())); c = draw1D(hClone,"",kFALSE,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaZ_%s.png",run_type,trigName[kTrigType])); } Double_t range = 50; TF1 *func = new TF1("func","gaus(0)+gaus(3)",-1*range,range); func->SetParameters(10000,0,10,1000,0,40); c = FitDeltaZ(hMthDz,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.pdf",run_type,pt_cut,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%s.png",run_type,pt_cut,trigName[kTrigType])); } // pt dependence Double_t pt_cuts[5] = {1,2,3,5,20}; for(Int_t i=0; i<4; i++) { hTrkDzVsPt->GetXaxis()->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1); TH1F *htmp = (TH1F*)hTrkDzVsPt->ProjectionY(Form("hTrkDz_pt%1.0f-%1.0f_%s",pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); htmp->SetTitle(Form("%s: #Deltaz of matched track-hit pairs (%1.0f < p_{T} < %1.0f GeV/c);#Deltaz (cm)",trigName[kTrigType],pt_cuts[i],pt_cuts[i+1])); TF1 *func = new TF1(Form("func_pt%1.0f-%1.0f",pt_cuts[i],pt_cuts[i+1]),"gaus(0)+gaus(3)",-1*range,range); if(i==0) func->SetParameters(100,0,100,1000,0,10); if(i==1) func->SetParameters(1000,0,15,1000,0,60); if(i==2) func->SetParameters(1000,0,15,1000,0,60); if(i==3) func->SetParameters(1000,0,60,1000,0,15); c = FitDeltaZ(htmp,func,range,20.); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.pdf",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/FitDz_Pt%1.0f_%1.0f_%s.png",run_type,pt_cuts[i],pt_cuts[i+1],trigName[kTrigType])); } } }
//================================================ void moveHisto() { TFile *fin = TFile::Open("output/bk.Run14.AuAu200.jpsi.EmbedQA.MC.root","read"); TH2F *h2 = (TH2F*)fin->Get("hMcDeltaTof_di_mu"); THnSparseF *hn = (THnSparseF*)fin->Get("mhMcTofQA_di_mu"); TFile *fout = TFile::Open("output/Run14.AuAu200.jpsi.EmbedQA.MC.root","update"); h2->Write("",TObject::kOverwrite); hn->Write("",TObject::kOverwrite); fout->Close(); fin->Close(); }
//================================================ void DeltaY(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TH2F *hTrkDyVsPt = (TH2F*)hn->Projection(2,0); c = draw2D(hTrkDyVsPt,Form("%s: #Deltay of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_vs_pt_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_vs_pt_%s.png",run_type,trigName[kTrigType])); } c = new TCanvas("hDy_TrkPtBin","hDy_TrkPtBin",1200,650); c->Divide(2,2); Double_t pt_cuts[5] = {1,2,4,10,20}; TH1F *hDy[4][2]; for(Int_t i=0; i<4; i++) { for(Int_t j=0; j<2; j++) { hn->GetAxis(5)->SetRange(1+j*2,1+j*2); hn->GetAxis(0)->SetRangeUser(pt_cuts[i]+0.1,pt_cuts[i+1]-0.1); hDy[i][j] = (TH1F*)hn->Projection(2); hDy[i][j]->SetName(Form("hTrkDy_pt%1.0f_%1.0f_%d",pt_cuts[i],pt_cuts[i+1],j)); hDy[i][j]->SetLineColor(color[j]); hDy[i][j]->SetMaximum(1.3*hDy[i][j]->GetMaximum()); hDy[i][j]->SetTitle(""); } c->cd(i+1); hDy[i][0]->Draw(); hDy[i][1]->Draw("sames"); TPaveText *t1 = GetTitleText(Form("%s: #Deltay of matched track-hit pairs",trigName[kTrigType]),0.06); t1->Draw(); t1 = GetPaveText(0.15,0.35,0.7,0.75,0.06); t1->AddText(Form("%1.0f < p_{T} < %1.0f GeV/c",pt_cuts[i],pt_cuts[i+1])); t1->SetTextColor(4); t1->Draw(); } c->cd(1); TLegend *leg = new TLegend(0.6,0.63,0.8,0.83); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.05); leg->AddEntry(hDy[0][0],"Negative","L"); leg->AddEntry(hDy[0][1],"Positive","L"); leg->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_InPtBin_%s.pdf",run_type,trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/DeltaY_InPtBin_%s.png",run_type,trigName[kTrigType])); } }
void createInputs(int n = 2) { for(UInt_t i = 0; i < (UInt_t)n; ++i ) { TFile *file = TFile::Open(TString::Format("input%d.root",i),"RECREATE"); TH1F * h = new TH1F("h1","",10,0,100); h->Fill(10.5); h->Fill(20.5); Int_t nbins[5]; Double_t xmin[5]; Double_t xmax[5]; for(UInt_t j = 0; j < 5; ++j) { nbins[j] = 10; xmin[j] = 0; xmax[j] = 10; } THnSparseF *sparse = new THnSparseF("sparse", "sparse", 5, nbins, xmin, xmax); Double_t coord[5] = {0.5, 1.5, 2.5, 3.5, 4.5}; sparse->Fill(coord); sparse->Write(); THStack *stack = new THStack("stack",""); h = new TH1F("hs_1","",10,0,100); h->Fill(10.5); h->Fill(20.5); h->SetDirectory(0); stack->Add(h); h = new TH1F("hs_2","",10,0,100); h->Fill(30.5); h->Fill(40.5); h->SetDirectory(0); stack->Add(h); stack->Write(); TGraph *gr = new TGraph(3); gr->SetName("exgraph"); gr->SetPoint(0,1,1); gr->SetPoint(1,2,2); gr->SetPoint(2,3,3); gr->Write(); TTree *tree = new TTree("tree","simplistic tree"); Int_t data = 0; tree->Branch("data",&data); for(Int_t l = 0; l < 2; ++l) { data = l; tree->Fill(); } file->Write(); delete file; } }
//================================================ void makeHistos() { TH2F *hDzVsModBL; TH1F *hDz[30][5]; // dz vs mod in each BL THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); Int_t nbins = hn->GetAxis(1)->GetNbins(); Double_t xmin = hn->GetAxis(1)->GetXmin(); Double_t xmax = hn->GetAxis(1)->GetXmax(); hDzVsModBL = new TH2F(Form("hTrkDzVsModBL_%s",trigName[kTrigType]),Form("%s: #Deltaz of matched track-hit pairs;module;#Deltaz (cm)",trigName[kTrigType]),150,0,150,nbins,xmin,xmax); for(int i=0; i<30; i++) { hn->GetAxis(3)->SetRange(i+1,i+1); for(int j=0; j<5; j++) { hn->GetAxis(4)->SetRange(j+1,j+1); hDz[i][j] = (TH1F*)hn->Projection(1); hDz[i][j]->SetName(Form("hTrkDz_BL%d_Mod%d_%s",i+1,j+1,trigName[kTrigType])); if(hDz[i][j]->GetEntries()<=0) continue; for(int ibin=1; ibin<=hDz[i][j]->GetNbinsX(); ibin++) { hDzVsModBL->SetBinContent(i*5+j+1,ibin,hDz[i][j]->GetBinContent(ibin)); hDzVsModBL->SetBinError(i*5+j+1,ibin,hDz[i][j]->GetBinError(ibin)); } hn->GetAxis(4)->SetRange(0,-1); } hn->GetAxis(3)->SetRange(0,-1); } TFile *fout = TFile::Open(Form("Rootfiles/%s%s.TrkMthResidual.root",run_cfg_name.Data(),run_type),"update"); hDzVsModBL->Write(); for(int i=0; i<30; i++) { for(int j=0; j<5; j++) { hDz[i][j]->Write(); } } fout->Close(); }
bool check(int n = 2) { TFile *file = TFile::Open(TString::Format("merged%d.root",n)); bool result = true; TH1F *h; file->GetObject("h1",h); if (!h) { Error("execFileMerger","h1 is missing\n"); result = false; } if (h->GetBinContent(2) != n || h->GetBinContent(3) != n) { Error("execFileMerger","h1 not added properly"); result = false; } THnSparseF *sparse; file->GetObject("sparse",sparse); if (!sparse) { Error("execFileMerger","sparse is missing\n"); result = false; } else { Int_t coordIdx[5] = {1, 2, 3, 4, 5}; Double_t cont = sparse->GetBinContent(coordIdx); if (cont > n + 0.4 || cont < n - 0.4) { Error("execFileMerger","sparse merge failed: expected bin content %g, read %g\n", (Double_t)n, cont); result = false; } Double_t entries = sparse->GetEntries(); if (entries > n + 0.4 || entries < n - 0.4) { Error("execFileMerger","sparse merge failed: expected %g entries, read %g\n", (Double_t)n, entries); result = false; } } THStack *stack; file->GetObject("stack",stack); if (!stack) { Error("execFileMerger","stack is missing\n"); result = false; } h = (TH1F*)stack->GetHists()->FindObject("hs_1"); if (!h) { Error("execFileMerger","hs_1 is missing\n"); result = false; } if (h->GetBinContent(2) != n || h->GetBinContent(3) != n) { Error("execFileMerger","hs_1 not added properly"); result = false; } h = (TH1F*)stack->GetHists()->FindObject("hs_2"); if (!h) { Error("execFileMerger","hs_2 is missing\n"); result = false; } if (h->GetBinContent(4) != n || h->GetBinContent(5) != n) { Error("execFileMerger","hs_2 not added properly"); result = false; } TGraph *gr; file->GetObject("exgraph",gr); if (!gr) { Error("execFileMerger","exgraph is missing\n"); result = false; } if (gr->GetN() != ( n * 3)) { Error("execFileMerger","exgraph not added properly n=%d rather than %d",gr->GetN(),n*3); result = false; } else { for(Int_t k = 0; k < gr->GetN(); ++k) { double x,y; gr->GetPoint(k,x,y); if ( x != ( (k%3)+1 ) || y != ( (k%3)+1 ) ) { Error("execFileMerger","exgraph not added properly"); result = false; } } } TTree *tree; file->GetObject("tree",tree); if (!tree) { Error("execFileMerger","tree is missing\n"); result = false; } if (tree->GetEntries() != n*2) { Error("execFileMerger","tree does not have the expected number of entries: %lld rather than %d",tree->GetEntries(),n*2); result = false; } else { if ( tree->GetEntries("data==1") != n ) { Error("execFileMerger","tree does not have the expected data. We got %lld entries with 'data==1' rather than %d",tree->GetEntries("data==1"),n); tree->Scan(); result = false; } } return result; }
//================================================ void embed(int save = 0) { char *run_config = "Embed.fix."; TString fileName; if(year==2013) fileName = Form("Run13.pp500.jpsi.%sroot",run_config); f = TFile::Open(Form("./output/%s",fileName.Data()),"read"); THnSparseF *hnDtof = (THnSparseF*)f->Get("mhMcTofQA_di_mu"); // dtof vs pt TH2F *hTofVsPt = (TH2F*)hnDtof->Projection(0,3); hTofVsPt->SetName("Embed_dTof_vs_pt"); hTofVsPt->SetTitle("Embedding: tof_{mc} - tof_{exp} vs p_{T}"); hTofVsPt->GetXaxis()->SetRangeUser(0,12); hTofVsPt->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsPt); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.png",run_type,run_config)); } // dtof vs mctof TH2F *hTofVsMcTof = (TH2F*)hnDtof->Projection(0,1); hTofVsMcTof->SetName("Embed_dTof_vs_mc_tof"); hTofVsMcTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{mc}"); hTofVsMcTof->GetXaxis()->SetRangeUser(13,17); hTofVsMcTof->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsMcTof); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.png",run_type,run_config)); } // dtof vs exptof TH2F *hTofVsExpTof = (TH2F*)hnDtof->Projection(0,2); hTofVsExpTof->SetName("Embed_dTof_vs_exp_tof"); hTofVsExpTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{exp}"); hTofVsExpTof->GetXaxis()->SetRangeUser(13,17); hTofVsExpTof->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsExpTof); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.png",run_type,run_config)); } // dtof vs module TH2F *hTofVsMod = (TH2F*)hnDtof->Projection(0,4); hTofVsMod->SetName("Embed_dTof_vs_module"); hTofVsMod->SetTitle("Embedding: tof_{mc} - tof_{exp} vs backleg"); hTofVsMod->GetYaxis()->SetRangeUser(-1,1); c = draw2D(hTofVsMod); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.png",run_type,run_config)); } // dtof intervals TList *list = new TList; TString legName[3]; TH1F *histo[3][3]; double low_bounds[3] = {-5, 0.15, -0.16}; double up_bounds[3] = {5, 0.16, -0.15}; char *name[3] = {"mc_tof","exp_tof","pt"}; double scale[3] = {2,2.5,1.5}; double min[3] = {12,12,0}; double max[3]= {18,18,12}; for(int i=0; i<3; i++) { list->Clear(); for(int j=0; j<3; j++) { hnDtof->GetAxis(0)->SetRangeUser(low_bounds[j]+0.001,up_bounds[j]-0.001); histo[i][j] = (TH1F*)hnDtof->Projection(i+1); histo[i][j]->SetName(Form("%s_dTofBin%d",name[i],j)); histo[i][j]->Scale(1./histo[i][j]->Integral()); histo[i][j]->SetLineWidth(2); histo[i][j]->SetMaximum(scale[i]*histo[i][j]->GetMaximum()); legName[j] = Form("%2.2f #leq #Deltatof #leq %2.2f ns",low_bounds[j],up_bounds[j]); list->Add(histo[i][j]); } c = drawHistos(list,name[i],Form("Embedding: %s distributions",name[i]),kTRUE,min[i],max[i],kFALSE,0.1,10,kFALSE,kTRUE,legName,kTRUE,"",0.5,0.7,0.6,0.85,kFALSE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.pdf",run_type,run_config,name[i])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.png",run_type,run_config,name[i])); } } hnDtof->GetAxis(0)->SetRange(0,-1); // dtof in module TH1F *hTofInMod[5]; TH2F *hTofVsProjMod[5]; for(int i=0; i<5; i++) { hnDtof->GetAxis(5)->SetRange(i+1,i+1); hTofInMod[i] = (TH1F*)hnDtof->Projection(0); hTofInMod[i]->SetName(Form("hTof_Mod%d",i+1)); hTofVsProjMod[i] = (TH2F*)hnDtof->Projection(0,6); hTofVsProjMod[i]->SetName(Form("hTofVsProjMod_Mod%d",i+1)); } hnDtof->GetAxis(5)->SetRange(0,-1); TCanvas *c = new TCanvas("hTof_in_mod","hTof_in_mod",1100,750); c->Divide(3,2); for(int i=0; i<5; i++) { c->cd(i+1); gPad->SetLogy(); hTofInMod[i]->Draw(); hTofInMod[i]->SetTitle(""); hTofInMod[i]->GetXaxis()->SetRangeUser(-1,2); TPaveText *t1 = GetTitleText(Form("Module %d",i+1),0.05); t1->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.png",run_type,run_config)); } TCanvas *c = new TCanvas("hTofVsProjMod_in_mod","hTofVsProjMod_in_mod",1100,750); c->Divide(3,2); for(int i=0; i<5; i++) { c->cd(i+1); gPad->SetLogz(); hTofVsProjMod[i]->SetTitle(";track module"); hTofVsProjMod[i]->GetYaxis()->SetRangeUser(-0.5,0.5); hTofVsProjMod[i]->Draw("colz"); TPaveText *t1 = GetTitleText(Form("Hit in module %d",i+1),0.05); t1->Draw(); } if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.pdf",run_type,run_config)); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.png",run_type,run_config)); } }
//================================================ void DeltaZVsPos(const Int_t save = 0) { THnSparseF *hn = (THnSparseF*)f->Get(Form("mhTrkDzDy_%s",trigName[kTrigType])); TList *list = new TList; // dz vs BL TH2F *hTrkDzVsBL = (TH2F*)hn->Projection(1,3); c = draw2D(hTrkDzVsBL,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_BL_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_BL_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } list->Clear(); TString legName[30]; TH1F *hTrkDzInBL[30]; Int_t counter = 0; for(Int_t i=0; i<30; i++) { hTrkDzInBL[i] = (TH1F*)hTrkDzVsBL->ProjectionY(Form("hDeltaZ_BL%d",i+1),i+1,i+1); if(hTrkDzInBL[i]->GetEntries()>0) { legName[counter] = Form("Module %d",i+1); hTrkDzInBL[i]->SetLineColor(color[counter]); list->Add(hTrkDzInBL[i]); counter ++; } } c = drawHistos(list,"TrkDzInBL",Form("%s: #Deltaz of matched track-hit pairs in backleg;#Deltaz (cm)",trigName[kTrigType]),kTRUE,-100,100,kTRUE,0,1.2*hTrkDzInBL[1]->GetMaximum(),kFALSE,kTRUE,legName,kTRUE,"",0.15,0.25,0.2,0.88,kFALSE,0.04,0.04,kFALSE,1,kTRUE,kFALSE); TLine *line = GetLine(0,0,0,1.1*hTrkDzInBL[1]->GetMaximum(),1); line->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_BL_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_BL_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } // dz vs Mod TH2F *hTrkDzVsMod = (TH2F*)hn->Projection(1,4); c = draw2D(hTrkDzVsMod,Form("%s: #Deltaz of matched track-hit pairs",trigName[kTrigType])); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_vs_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } TH1F *hMthMod = (TH1F*)hTrkDzVsMod->ProjectionX("hMthMod"); hMthMod->Sumw2(); hMthMod->Scale(1./hMthMod->Integral()); TH2F *hMtdHitMap = (TH2F*)f->Get(Form("mhMtdHitMap_%s",trigName[kTrigType])); TH1F *htmp = (TH1F*)hMtdHitMap->ProjectionY("hHitMod_finebin"); htmp->Rebin(12); TH1F *hMtdHitMod = new TH1F(Form("hMtdHitMod_%s",trigName[kTrigType]),"# of MTD hits per module;module",5,1,6); for(int i=0; i<hMtdHitMod->GetNbinsX(); i++) { hMtdHitMod->SetBinContent(i+1,htmp->GetBinContent(i+1)); hMtdHitMod->SetBinError(i+1,htmp->GetBinError(i+1)); } hMtdHitMod->Scale(1./hMtdHitMod->Integral()); list->Clear(); list->Add(hMthMod); list->Add(hMtdHitMod); TString legName3[2] = {"Matched good hits","All good hits"}; c = drawHistos(list,"MtdHitMod",Form("%s: MTD hits per module;module;probability",trigName[kTrigType]),kFALSE,0,5,kTRUE,0,0.5,kFALSE,kTRUE,legName3,kTRUE,"",0.15,0.25,0.6,0.88,kTRUE); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sCompMtdHitMod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sCompMtdHitMod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } list->Clear(); TString legName2[5]; TH1F *hTrkDzInMod[5]; for(Int_t i=0; i<5; i++) { hTrkDzInMod[i] = (TH1F*)hTrkDzVsMod->ProjectionY(Form("hDeltaZ_Mod%d",i+1),i+1,i+1); legName2[i] = Form("Module %d",i+1); list->Add(hTrkDzInMod[i]); } c = drawHistos(list,"TrkDzInMod",Form("%s: #Deltaz of matched track-hit pairs in module;#Deltaz (cm)",trigName[kTrigType]),kTRUE,-100,100,kTRUE,0,1.2*hTrkDzInMod[3]->GetMaximum(),kFALSE,kTRUE,legName2,kTRUE,"",0.15,0.25,0.6,0.88,kTRUE); TLine *line = GetLine(0,0,0,hTrkDzInMod[3]->GetMaximum()*1.05,1); line->Draw(); if(save) { c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_Mod_%s.pdf",run_type,run_cfg_name.Data(),trigName[kTrigType])); c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_Match/%sDeltaZ_in_Mod_%s.png",run_type,run_cfg_name.Data(),trigName[kTrigType])); } }
void drawGenerateDeltaTLookupHistogramsPlots(){ TFile* f = TFile::Open("generateDeltaTLookupHistogramsPlots.root"); RootTools::setWhiteZeroColorScale(); std::vector<Int_t> combos; std::vector<Int_t> ant1s; std::vector<Int_t> ant2s; CrossCorrelator* cc = new CrossCorrelator(); const Int_t numCombos = 336; //NUM_PHI; const Int_t numPhi = 16; // // Draw feed and photogrammetry examples for 0, 16. // TH2D* hPureDiff_2D_feed_0_16 = (TH2D*) f->Get("hPureDiff_2D_feed_0_16"); // TH2D* hPureDiff_2D_photo_0_16 = (TH2D*) f->Get("hPureDiff_2D_photo_0_16"); // RootTools::draw2D(hPureDiff_2D_feed_0_16, "colz"); // return; // for(Int_t comboInd=0; comboInd < numCombos; comboInd++){ // Int_t startCombo = 0; Int_t startCombo = 0; //NUM_COMBOS - 50; Int_t endCombo = 1; //NUM_COMBOS; startCombo = 0; endCombo = 50; // Int_t endCombo = 50; for(Int_t comboInd=startCombo; comboInd < endCombo; comboInd++){ Int_t combo = comboInd; Int_t ant1 = cc->comboToAnt1s.at(comboInd); Int_t ant2 = cc->comboToAnt2s.at(comboInd); if(!(TMath::Abs(ant1 - ant2) == NUM_PHI || TMath::Abs(ant1 - ant2) == (2*NUM_PHI) || TMath::Abs(ant1 - ant2) == 1 || TMath::Abs(ant1 - ant2) == (NUM_PHI-1))){ continue; } // int selPhi = 0; // if(!(ant1==selPhi || ant1==selPhi+NUM_PHI)){ // continue; // } // Int_t phiSect1 = ant1%numPhi; // Int_t phiSect2 = ant2%numPhi; // Int_t deltaPhiSect = phiSect1 - phiSect2; // cout << deltaPhiSect << "\t" << phiSect1 << "\t "<< phiSect2 << endl; // if(TMath::Abs(deltaPhiSect) > 1 && TMath::Abs(deltaPhiSect) < 15){ // continue; // } // Int_t ant1 = comboInd; // i.e. phi // // Int_t ant2 = (comboInd + 1)%16; //NUM_PHI; // // Int_t ant2 = comboInd + 2*16; //NUM_PHI; // Int_t ant2 = comboInd + 16; //NUM_PHI; // Int_t combo = cc->comboIndices[ant1][ant2]; // // std:: cout << ant1 << "\t" << ant2 << "\t" << combo << std::endl; combos.push_back(combo); ant1s.push_back(ant1); ant2s.push_back(ant2); TString name = TString::Format("hDtSparse_%d_%d", ant1, ant2); THnSparseF* hDtSparse = (THnSparseF*) f->Get(name); TCanvas* c1 = new TCanvas(); c1->Divide(2); c1->cd(1); TH2D* hDtProf = hDtSparse->Projection(1, 0); RootTools::draw2D(hDtProf, "colz"); hDtProf->GetYaxis()->SetRangeUser(-9, -5); c1->cd(2); name = TString::Format("hCorrDts_%d_%d", ant1, ant2); THnSparseF* hCorrDts = (THnSparseF*) f->Get(name); // TCanvas* c1 = new TCanvas(); TH1D* hCorrDts_px = hCorrDts->Projection(0); hCorrDts_px->GetYaxis()->SetTitle("Number of events"); hCorrDts_px->GetYaxis()->SetNoExponent(1); hCorrDts_px->Draw(); hCorrDts_px->GetXaxis()->SetRangeUser(-10, 10); gPad->SetLogy(1); cout << combo << "\t" << ant1 << "\t" << ant2 << "\t" << hCorrDts_px->GetMean() << endl; } delete cc; }