void ReadTree_normDet(){ bool testrun = 0; const int norder_ = 2; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; TFile * fVNDet; TH1D * hVNDetX_0; TH1D * hVNDetY_0; TH1D * hVNDetX_1; TH1D * hVNDetY_1; TH1D * hVNDetX_full; TH1D * hVNDetY_full; TFile * fHists; TDirectory * qwebye; TH2D * hVn2Dfull[NCENT]; TH2D * hVn2Dsub0[NCENT]; TH2D * hVn2Dsub1[NCENT]; TH2D * hVn2D0v1[NCENT]; TH1D * hVnFull[NCENT]; TH1D * hVnSub0[NCENT]; TH1D * hVnSub1[NCENT]; TH1I * Mult[NCENT]; TH2D * h2Vn2D0v1[NCENT]; TH1D * h2Vn2D0v1Magnitude[NCENT]; double VnRaw_x_0; double VnRaw_y_0; double VnRaw_x_1; double VnRaw_y_1; double VnRaw_x_full; double VnRaw_y_full; double sumw_0; double sumw_1; double sumw_full; double VnCorrected_x_0; double VnCorrected_y_0; double VnCorrected_x_1; double VnCorrected_y_1; double VnCorrected_x_full; double VnCorrected_y_full; int evtMult_0; int evtMult_1; int evtMult_full; // // MAIN // setTDRStyle(); TH1D::SetDefaultSumw2(); TH2D::SetDefaultSumw2(); TH1I::SetDefaultSumw2(); //-- Set up analyzer objects fAna = new TFile(fAnaTreeName); tree = (TTree *) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); //-- Set up VN detector objects fVNDet = new TFile( Form("V%iDet.root", norder_ ) ); hVNDetX_0 = (TH1D*) fVNDet->Get("SubEvt_0/hVNDetX_0"); hVNDetY_0 = (TH1D*) fVNDet->Get("SubEvt_0/hVNDetY_0"); hVNDetX_1 = (TH1D*) fVNDet->Get("SubEvt_1/hVNDetX_1"); hVNDetY_1 = (TH1D*) fVNDet->Get("SubEvt_1/hVNDetY_1"); hVNDetX_full = (TH1D*) fVNDet->Get("FullEvt/hVNDetX_full"); hVNDetY_full = (TH1D*) fVNDet->Get("FullEvt/hVNDetY_full"); //-- Setup the output objects fHists = new TFile("CastleEbyE.root","recreate"); qwebye = (TDirectory*) fHists->mkdir("qwebye"); for(int icent = 0; icent < NCENT; icent++){ qwebye->cd(); hVn2Dfull[icent] = new TH2D(Form("hVn2Dfull_c%i", icent), Form("hVn2Dfull_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dfull[icent]->SetOption("colz"); hVn2Dfull[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs}", norder_) ); hVn2Dfull[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs}", norder_) ); hVn2Dsub0[icent] = new TH2D( Form("hVn2Dsub0_c%i", icent), Form("hVn2Dsub0_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub0[icent]->SetOption("colz"); hVn2Dsub0[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a}", norder_) ); hVn2Dsub0[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a}", norder_) ); hVn2Dsub1[icent] = new TH2D( Form("hVn2Dsub1_c%i", icent), Form("hVn2Dsub1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub1[icent]->SetOption("colz"); hVn2Dsub1[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,b}", norder_) ); hVn2Dsub1[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,b}", norder_) ); hVn2D0v1[icent] = new TH2D( Form("hVn2D0v1_c%i", icent), Form("hVn2D0v1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2D0v1[icent]->SetOption("colz"); hVn2D0v1[icent]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b}", norder_, norder_) ); hVn2D0v1[icent]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b}", norder_, norder_) ); hVnFull[icent] = new TH1D( Form("hVnFull_c%i", icent), Form("hVnFull_c%i", icent), NBins, 0., vnMax[norder_] ); hVnFull[icent]->GetXaxis()->SetTitle( Form("v_{%i}", norder_) ); hVnFull[icent]->GetYaxis()->SetTitle( "Events" ); hVnSub0[icent] = new TH1D( Form("hVnSub0_c%i", icent), Form("hVnSub0_c%i", icent), NBins, 0., vnMax[norder_] ); hVnSub0[icent]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,a}", norder_) ); hVnSub1[icent] = new TH1D( Form("hVnSub1_c%i", icent), Form("hVnSub1_c%i", icent), NBins, 0., vnMax[norder_] ); hVnSub1[icent]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,b}", norder_) ); Mult[icent] = new TH1I( Form("Mult_c%i", icent), Form("Mult_c%i", icent), 250, 1, 10000 ); Mult[icent]->GetXaxis()->SetTitle("Multiplicity"); h2Vn2D0v1[icent] = new TH2D( Form("h2Vn2D0v1_c%i", icent), Form("h2Vn2D0v1_c%i", icent), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); h2Vn2D0v1[icent]->GetXaxis()->SetTitle( Form("(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent]->GetYaxis()->SetTitle( Form("(v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent]->SetOption("colz"); h2Vn2D0v1Magnitude[icent] = new TH1D( Form("h2Vn2D0v1Magnitude_c%i", icent), Form("h2Vn2D0v1Magnitude_c%i", icent), NBins, 0., vnMax[norder_] ); h2Vn2D0v1Magnitude[icent]->GetXaxis()->SetTitle( Form("|(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2|", norder_, norder_) ); } // // Tree Loop // cout<<"Begin FINAL loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if( testrun ) N = 10000; else N = tree->GetEntries(); for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout<<"Processing Event "<<ievent+1<<"\t"<<100.*(ievent+1)/(double)N<<"% Completed"<<endl; tree->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) < 3.0 || TMath::Abs(vtx) > 15.0) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = hCentBins.FindBin(centval)-1; //-- Reset raw and sumw values VnRaw_x_0 = 0; VnRaw_y_0 = 0; VnRaw_x_1 = 0; VnRaw_y_1 = 0; VnRaw_x_full = 0; VnRaw_y_full = 0; sumw_0 = 0; sumw_1 = 0; sumw_full = 0; evtMult_0 = 0; evtMult_1 = 0; evtMult_full = 0; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VnRaw_x_0 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_0 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VnRaw_x_1 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_1 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VnRaw_x_full += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_full += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Fill Histograms, only use events that have at least two tracks in each SE if(sumw_0 == 0 || sumw_1 == 0 || evtMult_1 < 2 || evtMult_full < 2) continue; VnRaw_x_full /= sumw_full; VnRaw_y_full /= sumw_full; VnRaw_x_0 /= sumw_0; VnRaw_y_0 /= sumw_0; VnRaw_x_1 /= sumw_1; VnRaw_y_1 /= sumw_1; //-- Full Tracker VnCorrected_x_full = VnRaw_x_full - hVNDetX_full->GetBinContent(icent+1); VnCorrected_y_full = VnRaw_y_full - hVNDetY_full->GetBinContent(icent+1); double vn_full = TMath::Sqrt( VnCorrected_x_full * VnCorrected_x_full + VnCorrected_y_full * VnCorrected_y_full); hVnFull[icent] -> Fill( vn_full ); hVn2Dfull[icent] -> Fill(VnCorrected_x_full, VnCorrected_y_full); Mult[icent]->Fill(evtMult_full); //-- SubEvt 0 (Eta > 0) VnCorrected_x_0 = VnRaw_x_0 - hVNDetX_0->GetBinContent(icent+1); VnCorrected_y_0 = VnRaw_y_0 - hVNDetY_0->GetBinContent(icent+1); double vn_0 = TMath::Sqrt( VnCorrected_x_0 * VnCorrected_x_0 + VnCorrected_y_0 * VnCorrected_y_0 ); hVnSub0[icent] -> Fill( vn_0 ); hVn2Dsub0[icent] -> Fill(VnCorrected_x_0, VnCorrected_y_0); //-- SubEvt 1 (Eta < 0) VnCorrected_x_1 = VnRaw_x_1 - hVNDetX_1->GetBinContent(icent+1); VnCorrected_y_1 = VnRaw_y_1 - hVNDetY_1->GetBinContent(icent+1); double vn_1 = TMath::Sqrt( VnCorrected_x_1 * VnCorrected_x_1 + VnCorrected_y_1 *VnCorrected_y_1 ); hVnSub1[icent] -> Fill( vn_1 ); hVn2Dsub1[icent] -> Fill(VnCorrected_x_1, VnCorrected_y_1); //-- SubEvt Difference double vn0m1_x = VnCorrected_x_0 - VnCorrected_x_1; double vn0m1_y = VnCorrected_y_0 - VnCorrected_y_1; hVn2D0v1[icent]->Fill(vn0m1_x, vn0m1_y); //-- SubEvt Difference for DD response double vn0m1_x2 = (VnCorrected_x_0 - VnCorrected_x_1) / 2.; double vn0m1_y2 = (VnCorrected_y_0 - VnCorrected_y_1) / 2.; h2Vn2D0v1[icent]->Fill(vn0m1_x2, vn0m1_y2); double vn0m12 = TMath::Sqrt( pow(vn0m1_x2, 2) + pow(vn0m1_y2, 2) ); h2Vn2D0v1Magnitude[icent]->Fill(vn0m12); } //-- End Event loop cout<<"End FINAL loop!"<<endl; fHists->Write(); cout<<"File written, process completed"<<endl; }
void makeVNDet(){ bool testrun = 0; const int norder_ = 2; const int QnBinOrder_ = 2; const double vtxCut = 15.; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; double qnHFx_EP[NumEPNames]; double qnHFy_EP[NumEPNames]; double sumET_EP[NumEPNames]; TFile * fQNDet; TH1D * hqnHFDet_x[NumEPNames]; TH1D * hqnHFDet_y[NumEPNames]; TFile * fQN; TH1D * hqbins[NCENT][NEPSymm]; TFile * fOut; TDirectory * SubEvt_0; TDirectory * SubEvt_1; TDirectory * FullEvt; TH2D * hVNDetX_0[NQN]; TH2D * hVNDetY_0[NQN]; TH2D * hVNDetX_1[NQN]; TH2D * hVNDetY_1[NQN]; TH2D * hVNDetX_full[NQN]; TH2D * hVNDetY_full[NQN]; double VNRawX_0[NCENT][NEPSymm][NQN]; double VNRawY_0[NCENT][NEPSymm][NQN]; double VNRawX_1[NCENT][NEPSymm][NQN]; double VNRawY_1[NCENT][NEPSymm][NQN]; double VNRawX_full[NCENT][NEPSymm][NQN]; double VNRawY_full[NCENT][NEPSymm][NQN]; double sumw_0[NCENT][NEPSymm][NQN]; double sumw_1[NCENT][NEPSymm][NQN]; double sumw_full[NCENT][NEPSymm][NQN]; int evtMult_0[NCENT][NEPSymm][NQN]; int evtMult_1[NCENT][NEPSymm][NQN]; int evtMult_full[NCENT][NEPSymm][NQN]; double VNDetX_0[NCENT][NEPSymm][NQN]; double VNDetY_0[NCENT][NEPSymm][NQN]; double VNDetX_1[NCENT][NEPSymm][NQN]; double VNDetY_1[NCENT][NEPSymm][NQN]; double VNDetX_full[NCENT][NEPSymm][NQN]; double VNDetY_full[NCENT][NEPSymm][NQN]; int Nevents[NCENT][NEPSymm][NQN]; int NFails[NCENT][NEPSymm][NQN]; // // MAIN // //-- Set up the analyzer objects fAna = new TFile(fAnaTreeName); tree = (TTree*) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); tree->SetBranchAddress("qnHFx_EP", &qnHFx_EP); tree->SetBranchAddress("qnHFy_EP", &qnHFy_EP); tree->SetBranchAddress("sumET_EP", &sumET_EP); //-- Get the QN Detector histograms fQNDet = new TFile( Form("../../../../../../v%i/eta2.4/systematicStudies/vtxCut/vtx3_15/AnalyzerResults/Q%iDet.root", QnBinOrder_, QnBinOrder_) ); for(int iEP = 0; iEP < NumEPNames; iEP++){ int EPbin = EPSymmPartnerBin[iEP]; if( EPbin != EPSymmBin ) continue; hqnHFDet_x[iEP] = (TH1D*) fQNDet->Get( Form("hqnHFDet_x_%s", EPNames[iEP].data()) ); hqnHFDet_y[iEP] = (TH1D*) fQNDet->Get( Form("hqnHFDet_y_%s", EPNames[iEP].data()) ); } //-- Setup the QN binning objects fQN = new TFile( Form( "../../../../../../v%i/eta2.4/systematicStudies/vtxCut/vtx3_15/AnalyzerResults/q%iCuts.root", QnBinOrder_, QnBinOrder_) ); for(int icent = 0; icent < NCENT; icent++){ for(int iEP = 0; iEP < NEPSymm; iEP++){ if( iEP != EPSymmBin ) continue; hqbins[icent][iEP] = (TH1D*) fQN->Get( Form("hqbins_%s_c%i", EPSymmNames[iEP].data(), icent) ); } } //-- Setup the output objects fOut = new TFile( Form("V%iDet.root", norder_), "recreate" ); SubEvt_0 = fOut->mkdir("SubEvt_0"); SubEvt_1 = fOut->mkdir("SubEvt_1"); FullEvt = fOut->mkdir("FullEvt"); for(int iqn = 0; iqn < NQN; iqn++){ SubEvt_0->cd(); hVNDetX_0[iqn] = new TH2D( Form("hVNDetX_0_qbin%i", iqn), Form("hVNDetX_0_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetX_0[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetX_0[iqn]->SetOption("colz"); hVNDetY_0[iqn] = new TH2D( Form("hVNDetY_0_qbin%i", iqn), Form("hVNDetY_0_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetY_0[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_0[iqn]->SetOption("colz"); SubEvt_1->cd(); hVNDetX_1[iqn] = new TH2D( Form("hVNDetX_1_qbin%i", iqn), Form("hVNDetX_1_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetX_1[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetX_1[iqn]->SetOption("colz"); hVNDetY_1[iqn] = new TH2D( Form("hVNDetY_1_qbin%i", iqn), Form("hVNDetY_1_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetY_1[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_1[iqn]->SetOption("colz"); FullEvt->cd(); hVNDetX_full[iqn] = new TH2D( Form("hVNDetX_full_qbin%i", iqn), Form("hVNDetX_full_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetX_full[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetX_full[iqn]->SetOption("colz"); hVNDetY_full[iqn] = new TH2D( Form("hVNDetY_full_qbin%i", iqn), Form("hVNDetY_full_qbin%i", iqn), NCENT, centbinsDefault, NEPSymm, epbinsDefault ); hVNDetY_full[iqn]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_full[iqn]->SetOption("colz"); for(int iEP = 0; iEP < NEPSymm; iEP++){ hVNDetX_0[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); hVNDetY_0[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); hVNDetX_1[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); hVNDetY_1[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); hVNDetX_full[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); hVNDetY_full[iqn]->GetYaxis()->SetBinLabel(iEP+1, EPSymmNames[iEP].data()); } } //-- initialize all variables for(int icent = 0; icent<NCENT; icent++){ for(int iEP = 0; iEP < NEPSymm; iEP++){ if( iEP != EPSymmBin ) continue; for(int iqn = 0; iqn < NQN; iqn++){ VNDetX_0[icent][iEP][iqn] = 0.; VNDetY_0[icent][iEP][iqn] = 0.; VNDetX_1[icent][iEP][iqn] = 0.; VNDetY_1[icent][iEP][iqn] = 0.; VNDetX_full[icent][iEP][iqn] = 0.; VNDetY_full[icent][iEP][iqn] = 0.; evtMult_0[icent][iEP][iqn] = 0; evtMult_1[icent][iEP][iqn] = 0; evtMult_full[icent][iEP][iqn] = 0; Nevents[icent][iEP][iqn] = 0; NFails[icent][iEP][iqn] = 0; } } } // // Calculate Vn_det // cout<<"Begin DETECTOR loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if(testrun) N = 10000; else N = tree->GetEntries(); //-- Begin event loop for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout << "Processing Event " << ievent+1 << "\t" << (100.*(ievent+1)/N) << "% Completed" << endl; tree->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) < 3. || TMath::Abs(vtx) > 15.) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = hCentBins.FindBin(centval)-1; //-- begin EP loop for(int iEP = 0; iEP < NEP; iEP++){ int EPbin = EPSymmPartnerBin[iEP]; if( EPbin != EPSymmBin ) continue; //-- Calculate qbin double qx = qnHFx_EP[iEP]; double qy = qnHFy_EP[iEP]; double qxDet = hqnHFDet_x[iEP]->GetBinContent(icent+1); double qyDet = hqnHFDet_y[iEP]->GetBinContent(icent+1); double sumET = sumET_EP[iEP]; if(sumET == 0) continue; qx -= qxDet; qy -= qyDet; qx /= sumET; qy /= sumET; double qn = TMath::Sqrt( qx*qx + qy*qy ); int iqn = hqbins[icent][EPbin]->FindBin( qn ) - 1; if(iqn >= NQN) continue; //-- Reset Raw and sumw values VNRawX_0[icent][EPbin][iqn] = 0.; VNRawY_0[icent][EPbin][iqn] = 0.; VNRawX_1[icent][EPbin][iqn] = 0.; VNRawY_1[icent][EPbin][iqn] = 0.; VNRawX_full[icent][EPbin][iqn] = 0.; VNRawY_full[icent][EPbin][iqn] = 0.; sumw_0[icent][EPbin][iqn] = 0.; sumw_1[icent][EPbin][iqn] = 0.; sumw_full[icent][EPbin][iqn] = 0.; evtMult_0[icent][EPbin][iqn] = 0; evtMult_1[icent][EPbin][iqn] = 0; evtMult_full[icent][EPbin][iqn] = 0; Nevents[icent][EPbin][iqn]++; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VNRawX_0[icent][EPbin][iqn] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_0[icent][EPbin][iqn] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0[icent][EPbin][iqn] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0[icent][EPbin][iqn] += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VNRawX_1[icent][EPbin][iqn] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_1[icent][EPbin][iqn] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1[icent][EPbin][iqn] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1[icent][EPbin][iqn] += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VNRawX_full[icent][EPbin][iqn] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_full[icent][EPbin][iqn] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full[icent][EPbin][iqn] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full[icent][EPbin][iqn] += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Only use events that have tracks in all subevents AND subevents that have at least two tracks to determine VN if( sumw_0[icent][EPbin][iqn] == 0 || sumw_1[icent][EPbin][iqn] == 0 || evtMult_0[icent][EPbin][iqn] < 2 || evtMult_1[icent][EPbin][iqn] < 2 ){ NFails[icent][EPbin][iqn]++; } else{ VNDetX_0[icent][EPbin][iqn] += VNRawX_0[icent][EPbin][iqn] / sumw_0[icent][EPbin][iqn]; VNDetY_0[icent][EPbin][iqn] += VNRawY_0[icent][EPbin][iqn] / sumw_0[icent][EPbin][iqn]; VNDetX_1[icent][EPbin][iqn] += VNRawX_1[icent][EPbin][iqn] / sumw_1[icent][EPbin][iqn]; VNDetY_1[icent][EPbin][iqn] += VNRawY_1[icent][EPbin][iqn] / sumw_1[icent][EPbin][iqn]; VNDetX_full[icent][EPbin][iqn] += VNRawX_full[icent][EPbin][iqn] / sumw_full[icent][EPbin][iqn]; VNDetY_full[icent][EPbin][iqn] += VNRawY_full[icent][EPbin][iqn] / sumw_full[icent][EPbin][iqn]; } } //-- End EP loop } //-- End event loop std::cout<<"End DETECTOR loop"<<std::endl; //-- Average VNDet over all events for each centrality, EP and, qn bin for(int iqn = 0; iqn < NQN; iqn++){ for(int icent = 0; icent < NCENT; icent++){ for(int iEP = 0; iEP < NEPSymm; iEP++){ if( iEP != EPSymmBin ) continue; double Neffective = (double) Nevents[icent][iEP][iqn] - (double) NFails[icent][iEP][iqn]; if( Neffective == 0) continue; VNDetX_0[icent][iEP][iqn] /= Neffective; VNDetY_0[icent][iEP][iqn] /= Neffective; VNDetX_1[icent][iEP][iqn] /= Neffective; VNDetY_1[icent][iEP][iqn] /= Neffective; VNDetX_full[icent][iEP][iqn] /= Neffective; VNDetY_full[icent][iEP][iqn] /= Neffective; //-- Populate histograms that will be used by ReadTree_normDet.C hVNDetX_0[iqn] -> SetBinContent(icent+1, iEP+1, VNDetX_0[icent][iEP][iqn]); hVNDetX_1[iqn] -> SetBinContent(icent+1, iEP+1, VNDetX_1[icent][iEP][iqn]); hVNDetX_full[iqn] -> SetBinContent(icent+1, iEP+1, VNDetX_full[icent][iEP][iqn]); hVNDetY_0[iqn] -> SetBinContent(icent+1, iEP+1, VNDetY_0[icent][iEP][iqn]); hVNDetY_1[iqn] -> SetBinContent(icent+1, iEP+1, VNDetY_1[icent][iEP][iqn]); hVNDetY_full[iqn] -> SetBinContent(icent+1, iEP+1, VNDetY_full[icent][iEP][iqn]); } } } //-- END TRIPLE LOOP fOut->Write(); cout<<"File written, process completed"<<endl; }
void makeVNDet(){ bool testrun = 0; const int norder_ = 2; const double vtxCut = 15.; const double ptMin = 0.3; const double ptMax = 3.00; const double etaMax = 1.0; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; TFile * fOut; TDirectory * SubEvt_0; TDirectory * SubEvt_1; TDirectory * FullEvt; TH1D * hVNDetX_0; TH1D * hVNDetY_0; TH1D * hVNDetX_1; TH1D * hVNDetY_1; TH1D * hVNDetX_full; TH1D * hVNDetY_full; double VNRawX_0[NCENT]; double VNRawY_0[NCENT]; double VNRawX_1[NCENT]; double VNRawY_1[NCENT]; double VNRawX_full[NCENT]; double VNRawY_full[NCENT]; double sumw_0[NCENT]; double sumw_1[NCENT]; double sumw_full[NCENT]; int evtMult_0[NCENT]; int evtMult_1[NCENT]; int evtMult_full[NCENT]; double VNDetX_0[NCENT]; double VNDetY_0[NCENT]; double VNDetX_1[NCENT]; double VNDetY_1[NCENT]; double VNDetX_full[NCENT]; double VNDetY_full[NCENT]; int Nevents[NCENT]; int NFails[NCENT]; // // MAIN // //-- Set up the analyzer objects fAna = new TFile("/rfs/jcastle/PbPb2015/PixelTracking_MB2/EbyETree_EPOS_LHC_RECO_SMEAR5.root"); tree = (TTree*) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); //-- Setup the output objects fOut = new TFile( Form("V%iDet.root", norder_), "recreate" ); SubEvt_0 = fOut->mkdir("SubEvt_0"); SubEvt_1 = fOut->mkdir("SubEvt_1"); FullEvt = fOut->mkdir("FullEvt"); SubEvt_0->cd(); hVNDetX_0 = new TH1D( "hVNDetX_0", "hVNDetX_0", NCENT, centbinsDefault); hVNDetX_0->GetXaxis()->SetTitle("Centrality %"); hVNDetY_0 = new TH1D( "hVNDetY_0", "hVNDetY_0", NCENT, centbinsDefault); hVNDetY_0->GetXaxis()->SetTitle("Centrality %"); SubEvt_1->cd(); hVNDetX_1 = new TH1D( "hVNDetX_1", "hVNDetX_1", NCENT, centbinsDefault); hVNDetX_1->GetXaxis()->SetTitle("Centrality %"); hVNDetY_1 = new TH1D( "hVNDetY_1", "hVNDetY_1", NCENT, centbinsDefault); hVNDetY_1->GetXaxis()->SetTitle("Centrality %"); FullEvt->cd(); hVNDetX_full = new TH1D( "hVNDetX_full", "hVNDetX_full", NCENT, centbinsDefault); hVNDetX_full->GetXaxis()->SetTitle("Centrality %"); hVNDetY_full = new TH1D( "hVNDetY_full", "hVNDetY_full", NCENT, centbinsDefault); hVNDetY_full->GetXaxis()->SetTitle("Centrality %"); //-- initialize all variables for(int icent = 0; icent<NCENT; icent++){ VNDetX_0[icent] = 0.; VNDetY_0[icent] = 0.; VNDetX_1[icent] = 0.; VNDetY_1[icent] = 0.; VNDetX_full[icent] = 0.; VNDetY_full[icent] = 0.; evtMult_0[icent] = 0; evtMult_1[icent] = 0; evtMult_full[icent] = 0; Nevents[icent] = 0; NFails[icent] = 0; } // // Calculate Vn_det // cout<<"Begin DETECTOR loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if(testrun) N = 10000; else N = tree->GetEntries(); //-- Begin event loop for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout << "Processing Event " << ievent+1 << "\t" << (100.*(ievent+1)/N) << "% Completed" << endl; tree->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) > vtxCut) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = hCentBins.FindBin(centval)-1; //-- Reset Raw and sumw values VNRawX_0[icent] = 0.; VNRawY_0[icent] = 0.; VNRawX_1[icent] = 0.; VNRawY_1[icent] = 0.; VNRawX_full[icent] = 0.; VNRawY_full[icent] = 0.; sumw_0[icent] = 0.; sumw_1[icent] = 0.; sumw_full[icent] = 0.; evtMult_0[icent] = 0; evtMult_1[icent] = 0; evtMult_full[icent] = 0; Nevents[icent]++; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ double pt = sumw->GetXaxis()->GetBinCenter(ipt+1); double eta = sumw->GetYaxis()->GetBinCenter(ieta+1); if( pt < ptMin || pt > ptMax ) continue; if( fabs( eta ) > etaMax ) continue; if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VNRawX_0[icent] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_0[icent] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0[icent] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0[icent] += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VNRawX_1[icent] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_1[icent] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1[icent] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1[icent] += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VNRawX_full[icent] += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_full[icent] += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full[icent] += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full[icent] += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Only use events that have tracks in all subevents AND subevents that have at least two tracks to determine VN if( sumw_0[icent] == 0 || sumw_1[icent] == 0 || evtMult_0[icent] < 2 || evtMult_1[icent] < 2 ){ NFails[icent]++; } else{ VNDetX_0[icent] += VNRawX_0[icent] / sumw_0[icent]; VNDetY_0[icent] += VNRawY_0[icent] / sumw_0[icent]; VNDetX_1[icent] += VNRawX_1[icent] / sumw_1[icent]; VNDetY_1[icent] += VNRawY_1[icent] / sumw_1[icent]; VNDetX_full[icent] += VNRawX_full[icent] / sumw_full[icent]; VNDetY_full[icent] += VNRawY_full[icent] / sumw_full[icent]; } } //-- End event loop std::cout<<"End DETECTOR loop"<<std::endl; //-- Average VNDet over all events for each centrality, EP and, qn bin for(int icent = 0; icent < NCENT; icent++){ double Neffective = (double) Nevents[icent] - (double) NFails[icent]; if( Neffective == 0 ) continue; VNDetX_0[icent] /= Neffective; VNDetY_0[icent] /= Neffective; VNDetX_1[icent] /= Neffective; VNDetY_1[icent] /= Neffective; VNDetX_full[icent] /= Neffective; VNDetY_full[icent] /= Neffective; //-- Populate histograms that will be used by ReadTree_normDet.C hVNDetX_0 -> SetBinContent(icent+1, VNDetX_0[icent]); hVNDetX_1 -> SetBinContent(icent+1, VNDetX_1[icent]); hVNDetX_full -> SetBinContent(icent+1, VNDetX_full[icent]); hVNDetY_0 -> SetBinContent(icent+1, VNDetY_0[icent]); hVNDetY_1 -> SetBinContent(icent+1, VNDetY_1[icent]); hVNDetY_full -> SetBinContent(icent+1, VNDetY_full[icent]); } fOut->Write(); cout<<"File written, process completed"<<endl; }
void ReadTree_normDet(){ bool testrun = 0; const int norder_ = 4; const int QnBinOrder_ = 2; const double vtxCut = 15.; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; double qnHFx_EP[NumEPNames]; double qnHFy_EP[NumEPNames]; double sumET_EP[NumEPNames]; TFile * fQNDet; TH1D * hqnHFDet_x[NumEPNames]; TH1D * hqnHFDet_y[NumEPNames]; TFile * fQN; TH1D * hqbins[NCENT][NEPSymm]; TFile * fVNDet; TH2D * hVNDetX_0[NQN]; TH2D * hVNDetY_0[NQN]; TH2D * hVNDetX_1[NQN]; TH2D * hVNDetY_1[NQN]; TH2D * hVNDetX_full[NQN]; TH2D * hVNDetY_full[NQN]; TFile * fHists; TDirectory * qwebye; TH2D * hVn2Dfull[NCENT][NEPSymm][NQN]; TH2D * hVn2Dsub0[NCENT][NEPSymm][NQN]; TH2D * hVn2Dsub1[NCENT][NEPSymm][NQN]; TH2D * hVn2D0v1[NCENT][NEPSymm][NQN]; TH1D * hVnFull[NCENT][NEPSymm][NQN]; TH1D * hVnSub0[NCENT][NEPSymm][NQN]; TH1D * hVnSub1[NCENT][NEPSymm][NQN]; TH1I * Mult[NCENT][NEPSymm][NQN]; TH2D * h2Vn2D0v1[NCENT][NEPSymm][NQN]; TH1D * h2Vn2D0v1Magnitude[NCENT][NEPSymm][NQN]; double VnRaw_x_0; double VnRaw_y_0; double VnRaw_x_1; double VnRaw_y_1; double VnRaw_x_full; double VnRaw_y_full; double sumw_0; double sumw_1; double sumw_full; double VnCorrected_x_0; double VnCorrected_y_0; double VnCorrected_x_1; double VnCorrected_y_1; double VnCorrected_x_full; double VnCorrected_y_full; int evtMult_0; int evtMult_1; int evtMult_full; // // MAIN // setTDRStyle(); TH1D::SetDefaultSumw2(); TH2D::SetDefaultSumw2(); TH1I::SetDefaultSumw2(); //-- Set up analyzer objects fAna = new TFile("/rfs/jcastle/PbPb2015/PixelTracking_MB2/EbyETree_pixel_noTeff.root"); tree = (TTree *) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); tree->SetBranchAddress("qnHFx_EP", &qnHFx_EP); tree->SetBranchAddress("qnHFy_EP", &qnHFy_EP); tree->SetBranchAddress("sumET_EP", &sumET_EP); //-- Get the QN Detector histograms fQNDet = new TFile( Form("../../../../../v%i/eta2.4/AnalyzerResults/Q%iDet.root", QnBinOrder_, QnBinOrder_) ); for(int iEP = 0; iEP < NumEPNames; iEP++){ int EPbin = EPSymmPartnerBin[iEP]; if( EPbin != EPSymmBin ) continue; hqnHFDet_x[iEP] = (TH1D*) fQNDet->Get( Form("hqnHFDet_x_%s", EPNames[iEP].data()) ); hqnHFDet_y[iEP] = (TH1D*) fQNDet->Get( Form("hqnHFDet_y_%s", EPNames[iEP].data()) ); } //-- Setup the QN binning objects fQN = new TFile( Form( "../../../../../v%i/eta2.4/AnalyzerResults/q%iCuts.root", QnBinOrder_, QnBinOrder_) ); for(int icent = 0; icent < NCENT; icent++){ for(int iEP = 0; iEP < NEPSymm; iEP++){ if( iEP != EPSymmBin ) continue; hqbins[icent][iEP] = (TH1D*) fQN->Get( Form("hqbins_%s_c%i", EPSymmNames[iEP].data(), icent) ); } } //-- Set up VN detector objects fVNDet = new TFile( Form("V%iDet.root", norder_ ) ); for(int iqn = 0; iqn < NQN; iqn++){ hVNDetX_0[iqn] = (TH2D*) fVNDet->Get( Form("SubEvt_0/hVNDetX_0_qbin%i", iqn) ); hVNDetY_0[iqn] = (TH2D*) fVNDet->Get( Form("SubEvt_0/hVNDetY_0_qbin%i", iqn) ); hVNDetX_1[iqn] = (TH2D*) fVNDet->Get( Form("SubEvt_1/hVNDetX_1_qbin%i", iqn) ); hVNDetY_1[iqn] = (TH2D*) fVNDet->Get( Form("SubEvt_1/hVNDetY_1_qbin%i", iqn) ); hVNDetX_full[iqn] = (TH2D*) fVNDet->Get( Form("FullEvt/hVNDetX_full_qbin%i", iqn) ); hVNDetY_full[iqn] = (TH2D*) fVNDet->Get( Form("FullEvt/hVNDetY_full_qbin%i", iqn) ); } //-- Setup the output objects fHists = new TFile("CastleEbyE.root","recreate"); qwebye = (TDirectory*) fHists->mkdir("qwebye"); for(int iqn = 0; iqn < NQN; iqn++){ for(int icent = 0; icent < NCENT; icent++){ for(int iEP = 0; iEP < NEPSymm; iEP++){ if( iEP != EPSymmBin ) continue; qwebye->cd(); hVn2Dfull[icent][iEP][iqn] = new TH2D(Form("hVn2Dfull_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVn2Dfull_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dfull[icent][iEP][iqn]->SetOption("colz"); hVn2Dfull[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs}", norder_) ); hVn2Dfull[icent][iEP][iqn]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs}", norder_) ); hVn2Dsub0[icent][iEP][iqn] = new TH2D( Form("hVn2Dsub0_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVn2Dsub0_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub0[icent][iEP][iqn]->SetOption("colz"); hVn2Dsub0[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a}", norder_) ); hVn2Dsub0[icent][iEP][iqn]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a}", norder_) ); hVn2Dsub1[icent][iEP][iqn] = new TH2D( Form("hVn2Dsub1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVn2Dsub1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2Dsub1[icent][iEP][iqn]->SetOption("colz"); hVn2Dsub1[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,b}", norder_) ); hVn2Dsub1[icent][iEP][iqn]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,b}", norder_) ); hVn2D0v1[icent][iEP][iqn] = new TH2D( Form("hVn2D0v1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVn2D0v1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); hVn2D0v1[icent][iEP][iqn]->SetOption("colz"); hVn2D0v1[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b}", norder_, norder_) ); hVn2D0v1[icent][iEP][iqn]->GetYaxis()->SetTitle( Form("v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b}", norder_, norder_) ); hVnFull[icent][iEP][iqn] = new TH1D( Form("hVnFull_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVnFull_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), NBins, 0., vnMax[norder_] ); hVnFull[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i}", norder_) ); hVnFull[icent][iEP][iqn]->GetYaxis()->SetTitle( "Events" ); hVnSub0[icent][iEP][iqn] = new TH1D( Form("hVnSub0_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVnSub0_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), NBins, 0., vnMax[norder_] ); hVnSub0[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,a}", norder_) ); hVnSub1[icent][iEP][iqn] = new TH1D( Form("hVnSub1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("hVnSub1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), NBins, 0., vnMax[norder_] ); hVnSub1[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("v_{%i}^{obs,b}", norder_) ); Mult[icent][iEP][iqn] = new TH1I( Form("Mult_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("Mult_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 300, 1, 1500 ); Mult[icent][iEP][iqn]->GetXaxis()->SetTitle("Multiplicity"); h2Vn2D0v1[icent][iEP][iqn] = new TH2D( Form("h2Vn2D0v1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("h2Vn2D0v1_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), 2*NBins, -vnMax[norder_], vnMax[norder_], 2*NBins, -vnMax[norder_], vnMax[norder_] ); h2Vn2D0v1[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent][iEP][iqn]->GetYaxis()->SetTitle( Form("(v_{%i,y}^{obs,a} - v_{%i,y}^{obs,b})/2", norder_, norder_) ); h2Vn2D0v1[icent][iEP][iqn]->SetOption("colz"); h2Vn2D0v1Magnitude[icent][iEP][iqn] = new TH1D( Form("h2Vn2D0v1Magnitude_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), Form("h2Vn2D0v1Magnitude_%s_c%i_qbin%i", EPSymmNames[iEP].data(), icent, iqn), NBins, 0., vnMax[norder_] ); h2Vn2D0v1Magnitude[icent][iEP][iqn]->GetXaxis()->SetTitle( Form("|(v_{%i,x}^{obs,a} - v_{%i,x}^{obs,b})/2|", norder_, norder_) ); } } } // // Tree Loop // cout<<"Begin FINAL loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if( testrun ) N = 10000; else N = tree->GetEntries(); for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout<<"Processing Event "<<ievent+1<<"\t"<<100.*(ievent+1)/(double)N<<"% Completed"<<endl; tree->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) > vtxCut) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = hCentBins.FindBin(centval)-1; //-- begin EP loop for(int iEP = 0; iEP < NEP; iEP++){ int EPbin = EPSymmPartnerBin[iEP]; if( EPbin != EPSymmBin ) continue; //-- Calculate qbin double qx = qnHFx_EP[iEP]; double qy = qnHFy_EP[iEP]; double qxDet = hqnHFDet_x[iEP]->GetBinContent(icent+1); double qyDet = hqnHFDet_y[iEP]->GetBinContent(icent+1); double sumET = sumET_EP[iEP]; if(sumET == 0) continue; qx -= qxDet; qy -= qyDet; qx /= sumET; qy /= sumET; double qn = TMath::Sqrt( qx*qx + qy*qy ); int iqn = hqbins[icent][EPbin]->FindBin( qn ) - 1; if(iqn >= NQN) continue; //-- Reset raw and sumw values VnRaw_x_0 = 0; VnRaw_y_0 = 0; VnRaw_x_1 = 0; VnRaw_y_1 = 0; VnRaw_x_full = 0; VnRaw_y_full = 0; sumw_0 = 0; sumw_1 = 0; sumw_full = 0; evtMult_0 = 0; evtMult_1 = 0; evtMult_full = 0; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VnRaw_x_0 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_0 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VnRaw_x_1 += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_1 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VnRaw_x_full += sumwqx->GetBinContent(ipt+1,ieta+1); VnRaw_y_full += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Fill Histograms, only use events that have at least two tracks in each SE if(sumw_0 == 0 || sumw_1 == 0 || evtMult_1 < 2 || evtMult_full < 2) continue; VnRaw_x_full /= sumw_full; VnRaw_y_full /= sumw_full; VnRaw_x_0 /= sumw_0; VnRaw_y_0 /= sumw_0; VnRaw_x_1 /= sumw_1; VnRaw_y_1 /= sumw_1; //-- Full Tracker VnCorrected_x_full = VnRaw_x_full - hVNDetX_full[iqn]->GetBinContent(icent+1, EPbin+1); VnCorrected_y_full = VnRaw_y_full - hVNDetY_full[iqn]->GetBinContent(icent+1, EPbin+1); double vn_full = TMath::Sqrt( VnCorrected_x_full * VnCorrected_x_full + VnCorrected_y_full * VnCorrected_y_full); hVnFull[icent][EPbin][iqn] -> Fill( vn_full ); hVn2Dfull[icent][EPbin][iqn] -> Fill(VnCorrected_x_full, VnCorrected_y_full); Mult[icent][EPbin][iqn]->Fill(evtMult_full); //-- SubEvt 0 (Eta > 0) VnCorrected_x_0 = VnRaw_x_0 - hVNDetX_0[iqn]->GetBinContent(icent+1, EPbin+1); VnCorrected_y_0 = VnRaw_y_0 - hVNDetY_0[iqn]->GetBinContent(icent+1, EPbin+1); double vn_0 = TMath::Sqrt( VnCorrected_x_0 * VnCorrected_x_0 + VnCorrected_y_0 * VnCorrected_y_0 ); hVnSub0[icent][EPbin][iqn] -> Fill( vn_0 ); hVn2Dsub0[icent][EPbin][iqn] -> Fill(VnCorrected_x_0, VnCorrected_y_0); //-- SubEvt 1 (Eta < 0) VnCorrected_x_1 = VnRaw_x_1 - hVNDetX_1[iqn]->GetBinContent(icent+1, EPbin+1); VnCorrected_y_1 = VnRaw_y_1 - hVNDetY_1[iqn]->GetBinContent(icent+1, EPbin+1); double vn_1 = TMath::Sqrt( VnCorrected_x_1 * VnCorrected_x_1 + VnCorrected_y_1 *VnCorrected_y_1 ); hVnSub1[icent][EPbin][iqn] -> Fill( vn_1 ); hVn2Dsub1[icent][EPbin][iqn] -> Fill(VnCorrected_x_1, VnCorrected_y_1); //-- SubEvt Difference double vn0m1_x = VnCorrected_x_0 - VnCorrected_x_1; double vn0m1_y = VnCorrected_y_0 - VnCorrected_y_1; hVn2D0v1[icent][EPbin][iqn]->Fill(vn0m1_x, vn0m1_y); //-- SubEvt Difference for DD response double vn0m1_x2 = (VnCorrected_x_0 - VnCorrected_x_1) / 2.; double vn0m1_y2 = (VnCorrected_y_0 - VnCorrected_y_1) / 2.; h2Vn2D0v1[icent][EPbin][iqn]->Fill(vn0m1_x2, vn0m1_y2); double vn0m12 = TMath::Sqrt( pow(vn0m1_x2, 2) + pow(vn0m1_y2, 2) ); h2Vn2D0v1Magnitude[icent][EPbin][iqn]->Fill(vn0m12); } //-- End EP loop } //-- End Event loop cout<<"End FINAL loop!"<<endl; fHists->Write(); cout<<"File written, process completed"<<endl; }
void makeVNDet(){ bool testrun = 0; const int norder_ = 2; const double vtxCut = 15.; static const int ptBinMin = 0; static const int ptBinMax = nptbinsDefault-1; static const int etaBinMin = 0; //0; static const int etaBinMax = netabinsDefault-1; TFile * fAna; TTree * tree; double centval; double vtx; TH2D * sumw; TH2D * sumwqx; TH2D * sumwqy; TH2I * hMult; TFile * fSplit; TTree * treeSplit; int iSplit; TFile * fOut; TH1D * hVNDetX_0[NSPLIT]; TH1D * hVNDetY_0[NSPLIT]; TH1D * hVNDetX_1[NSPLIT]; TH1D * hVNDetY_1[NSPLIT]; TH1D * hVNDetX_full[NSPLIT]; TH1D * hVNDetY_full[NSPLIT]; double VNDetX_0[NCENT][NSPLIT]; double VNDetY_0[NCENT][NSPLIT]; double VNDetX_1[NCENT][NSPLIT]; double VNDetY_1[NCENT][NSPLIT]; double VNDetX_full[NCENT][NSPLIT]; double VNDetY_full[NCENT][NSPLIT]; int Nevents[NCENT][NSPLIT]; int NFails[NCENT][NSPLIT]; // // MAIN // //-- Set up the analyzer objects fAna = new TFile("/rfs/jcastle/PbPb2015/PixelTracking_MB2/EbyETree_pixel_noTeff.root"); tree = (TTree*) fAna->Get("ebyeana/tree"); sumwqx = new TH2D(Form("sumwqx%i", norder_), Form("sumwqx%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumwqy = new TH2D(Form("sumwqy%i", norder_), Form("sumwqy%i", norder_), nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); sumw = new TH2D("sumw", "sumw", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); hMult = new TH2I("hMult", "hMult", nptbinsDefault, ptbinsDefault, netabinsDefault, etabinsDefault); tree->SetBranchAddress("Cent", ¢val); tree->SetBranchAddress("Vtx", &vtx); tree->SetBranchAddress("mult", &hMult); tree->SetBranchAddress(Form("sumwqx%i", norder_), &sumwqx); tree->SetBranchAddress(Form("sumwqy%i", norder_), &sumwqy); tree->SetBranchAddress("sumw", &sumw); //-- Set up the file splitter fSplit = new TFile(fileSplit); treeSplit = (TTree*) fSplit->Get("SplitTree"); treeSplit->SetBranchAddress("iSplit", &iSplit); //-- Setup the output objects fOut = new TFile( Form("V%iDet.root", norder_), "recreate" ); for(int iS = 0; iS < NSPLIT; iS++){ fOut->cd(); hVNDetX_0[iS] = new TH1D( Form("hVNDetX_0_Split%i", iS), Form("hVNDetX_0_Split%i", iS), NCENT, centbinsDefault); hVNDetX_0[iS]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_0[iS] = new TH1D( Form("hVNDetY_0_Split%i", iS), Form("hVNDetY_0_Split%i", iS), NCENT, centbinsDefault); hVNDetY_0[iS]->GetXaxis()->SetTitle("Centrality %"); hVNDetX_1[iS] = new TH1D( Form("hVNDetX_1_Split%i", iS), Form("hVNDetX_1_Split%i", iS), NCENT, centbinsDefault); hVNDetX_1[iS]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_1[iS] = new TH1D( Form("hVNDetY_1_Split%i", iS), Form("hVNDetY_1_Split%i", iS), NCENT, centbinsDefault); hVNDetY_1[iS]->GetXaxis()->SetTitle("Centrality %"); hVNDetX_full[iS] = new TH1D( Form("hVNDetX_full_Split%i", iS), Form("hVNDetX_full_Split%i", iS), NCENT, centbinsDefault); hVNDetX_full[iS]->GetXaxis()->SetTitle("Centrality %"); hVNDetY_full[iS] = new TH1D( Form("hVNDetY_full_Split%i", iS), Form("hVNDetY_full_Split%i", iS), NCENT, centbinsDefault); hVNDetY_full[iS]->GetXaxis()->SetTitle("Centrality %"); } //-- initialize all variables for(int icent = 0; icent<NCENT; icent++){ for(int iS = 0; iS < NSPLIT; iS++){ VNDetX_0[icent][iS] = 0.; VNDetY_0[icent][iS] = 0.; VNDetX_1[icent][iS] = 0.; VNDetY_1[icent][iS] = 0.; VNDetX_full[icent][iS] = 0.; VNDetY_full[icent][iS] = 0.; Nevents[icent][iS] = 0; NFails[icent][iS] = 0; } } // // Calculate Vn_det // cout<<"Begin DETECTOR loop, contains "<<tree->GetEntries()<<" Events"<<endl; int N; if(testrun) N = 10000; else N = tree->GetEntries(); //-- Begin event loop for(int ievent = 0; ievent < N; ievent++) { if((ievent+1)% 500000 == 0) cout << "Processing Event " << ievent+1 << "\t" << (100.*(ievent+1)/N) << "% Completed" << endl; int itree = tree->GetEntry(ievent); if(itree < 0){ std::cout<<"!!! BAD EVENT !!!"<<std::endl; continue; } treeSplit->GetEntry(ievent); //-- Vertex Cut if(TMath::Abs(vtx) > vtxCut) continue; //-- Calculate centbin if( centval > cent_max[NCENT-1]) continue; int icent = (centval - cent_min[0]) / centBinWidth; //-- Reset Raw and sumw values double VNRawX_0 = 0.; double VNRawY_0 = 0.; double VNRawX_1 = 0.; double VNRawY_1 = 0.; double VNRawX_full = 0.; double VNRawY_full = 0.; double sumw_0 = 0.; double sumw_1 = 0.; double sumw_full = 0.; double evtMult_0 = 0; double evtMult_1 = 0; double evtMult_full = 0; Nevents[icent][iSplit]++; //-- Begin analyzer histogram loops for(int ipt = ptBinMin; ipt <= ptBinMax; ipt++){ for(int ieta = etaBinMin; ieta <= etaBinMax; ieta++){ if(sumw->GetBinContent(ipt+1,ieta+1) !=0){ //-- Subevent 0 (eta >= 0) if(etabinsDefault[ieta] >= 0){ VNRawX_0 += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_0 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_0 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_0 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Subevent 1 (eta < 0) else{ VNRawX_1 += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_1 += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_1 += sumw->GetBinContent(ipt+1,ieta+1); evtMult_1 += hMult->GetBinContent(ipt+1,ieta+1); } //-- Full Event VNRawX_full += sumwqx->GetBinContent(ipt+1,ieta+1); VNRawY_full += sumwqy->GetBinContent(ipt+1,ieta+1); sumw_full += sumw->GetBinContent(ipt+1,ieta+1); evtMult_full += hMult->GetBinContent(ipt+1,ieta+1); } } //-- End eta loop } //-- End pt loop //-- Only use events that have tracks in all subevents AND subevents that have at least two tracks to determine VN if( sumw_0 == 0 || sumw_1 == 0 || evtMult_0 < 2 || evtMult_1 < 2 ){ NFails[icent][iSplit]++; } else{ VNDetX_0[icent][iSplit] += VNRawX_0 / sumw_0; VNDetY_0[icent][iSplit] += VNRawY_0 / sumw_0; VNDetX_1[icent][iSplit] += VNRawX_1 / sumw_1; VNDetY_1[icent][iSplit] += VNRawY_1 / sumw_1; VNDetX_full[icent][iSplit] += VNRawX_full / sumw_full; VNDetY_full[icent][iSplit] += VNRawY_full / sumw_full; } } //-- End event loop std::cout<<"End DETECTOR loop"<<std::endl; //-- Average VNDet over all events for each centrality, EP and, qn bin for(int icent = 0; icent < NCENT; icent++){ for(int iS = 0; iS < NSPLIT; iS++){ double Neffective = (double) Nevents[icent][iS] - (double) NFails[icent][iS]; if( Neffective == 0 ) continue; VNDetX_0[icent][iS] /= Neffective; VNDetY_0[icent][iS] /= Neffective; VNDetX_1[icent][iS] /= Neffective; VNDetY_1[icent][iS] /= Neffective; VNDetX_full[icent][iS] /= Neffective; VNDetY_full[icent][iS] /= Neffective; //-- Populate histograms that will be used by ReadTree_normDet.C hVNDetX_0[iS] -> SetBinContent(icent+1, VNDetX_0[icent][iS]); hVNDetX_1[iS] -> SetBinContent(icent+1, VNDetX_1[icent][iS]); hVNDetX_full[iS] -> SetBinContent(icent+1, VNDetX_full[icent][iS]); hVNDetY_0[iS] -> SetBinContent(icent+1, VNDetY_0[icent][iS]); hVNDetY_1[iS] -> SetBinContent(icent+1, VNDetY_1[icent][iS]); hVNDetY_full[iS] -> SetBinContent(icent+1, VNDetY_full[icent][iS]); } } fOut->Write(); cout<<"File written, process completed"<<endl; }