Double_t fTH1toTF1(Double_t *x, Double_t *par) { Double_t g4 = x[0]; // -> g^4 value Int_t mll = (Int_t)par[0]; // -> dilepton invariant mass bin number TH2D* h2 = (TH2D*)h2Template->Clone(); TH1D* hTmp = (TH1D*)TH2toTH1(h2,mll); // TH1 histogram of g^4 in the dilepton mass bin number mll Int_t nbinsx = hTmp->GetNbinsX(); Double_t xval = -999.; if(doInterpolation) { Int_t bin = hTmp->FindBin(g4); if(bin==0 || bin==1) xval = hTmp->GetBinContent(1); // cannot interpolate on the first bin or the underflow else if(bin==nbinsx+1) xval = hTmp->GetBinContent(bin-1); // cannot interpolate on the last bin or the overflow else if(bin==nbinsx) xval = hTmp->GetBinContent(bin); // cannot interpolate on the last bin or the overflow else xval = hTmp->Interpolate(g4); // interpolated dN/dg^4 at g^4, between the 2 adjacent bin centers } else { Int_t bin = hTmp->FindBin(g4); if(bin==nbinsx+1) xval = hTmp->GetBinContent(bin-1); // overflow else if(bin==0) xval = hTmp->GetBinContent(1); // underflow else xval = hTmp->GetBinContent(bin); // normal } delete h2; delete hTmp; return xval; }
float getWeight(bool t_isPrompt, bool t_isPair, float t_pt, float t_eta) { TH1D* hTmp; if (t_isPrompt) { if (t_isPair) { if ( TMath::Abs(t_eta) < 0.8) hTmp = hPairRatio_PR_0; else if ( TMath::Abs(t_eta) < 1.2) hTmp = hPairRatio_PR_1; else if ( TMath::Abs(t_eta) < 2.0) hTmp = hPairRatio_PR_2; else hTmp = hPairRatio_PR_3; } else { if ( TMath::Abs(t_eta) < 0.8) hTmp = hTrkRatio_PR_0; else if ( TMath::Abs(t_eta) < 1.2) hTmp = hTrkRatio_PR_1; else if ( TMath::Abs(t_eta) < 2.0) hTmp = hTrkRatio_PR_2; else hTmp = hTrkRatio_PR_3; } }else { if (t_isPair) { if ( TMath::Abs(t_eta) < 0.8) hTmp = hPairRatio_NP_0; else if ( TMath::Abs(t_eta) < 1.2) hTmp = hPairRatio_NP_1; else if ( TMath::Abs(t_eta) < 2.0) hTmp = hPairRatio_NP_2; else hTmp = hPairRatio_NP_3; } else { if ( TMath::Abs(t_eta) < 0.8) hTmp = hTrkRatio_NP_0; else if ( TMath::Abs(t_eta) < 1.2) hTmp = hTrkRatio_NP_1; else if ( TMath::Abs(t_eta) < 2.0) hTmp = hTrkRatio_NP_2; else hTmp = hTrkRatio_NP_3; } } int tmpbin = hTmp->FindBin(t_pt); float tmpW = hTmp->GetBinContent(tmpbin); return tmpW; }
CombineSpectra(TH1D *h, TObjArray *oa) { /* combine with weighted mean */ Double_t ptcen, w, sumw, mean, meane, cont, conte, syse, tote, minvalue, maxvalue, maxerror, maxmindiff; Int_t ptbin; TH1D *hin; for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) { mean = 0.; sumw = 0.; minvalue = kMaxInt; maxvalue = 0.; maxerror = 0.; ptcen = h->GetBinCenter(ipt + 1); TProfile prof(Form("prof_%d", ipt), "", 1, 0., 1.); /* to get RMS */ for (Int_t ih = 0; ih < oa->GetEntries(); ih++) { hin = (TH1D *)oa->At(ih); ptbin = hin->FindBin(ptcen); if (ptbin <= 0.) continue; cont = hin->GetBinContent(ptbin); conte = hin->GetBinError(ptbin); if (cont == 0. || conte == 0.) continue; w = 1. / (conte * conte); mean += cont * w; sumw += w; if (cont < minvalue) minvalue = cont; if (cont > maxvalue) maxvalue = cont; if (conte > maxerror) maxerror = conte; prof.Fill(0., cont); } if (sumw == 0.) { mean = 0.; meane = 0.; syse = 0.; tote = 0.; } else { mean /= sumw; meane = TMath::Sqrt(1. / sumw); syse = 0.5 * (maxvalue - minvalue); tote = TMath::Sqrt(meane * meane + syse * syse); // if (tote < maxerror) // tote = maxerror; } // printf("pt = %f, mean = %f, meane = %f, syse = %f, tote = %f\n", ptcen, mean, meane, syse, tote); // syse = prof.GetBinError(1); h->SetBinContent(ipt + 1, mean); h->SetBinError(ipt + 1, tote); // h->SetBinError(ipt + 1, TMath::Sqrt(meane * meane + syse * syse + mean * mean * 0.1 * 0.1)); /* add extra 10% systematics */ } }
TF1* GetFitFunc_ZYAM_pp(TH1D* h) { TH1D* hcorrphi = (TH1D*)h->Clone(h->GetName()); // double histminY = hcorrphi->GetBinContent(hcorrphi->GetMinimumBin()); // double histminX = hcorrphi->GetBinCenter(hcorrphi->GetMinimumBin()); double histminY = hcorrphi->GetBinContent(hcorrphi->FindBin(1.2)); double histminX = hcorrphi->GetBinCenter(hcorrphi->FindBin(1.2)); //hcorrphi->SetAxisRange(-0.01,1.2,"X"); TF1* fitfunc = new TF1(Form("fitfunc_%s",h->GetName()),"[0]+[1]*(x-[2])*(x-[2])+[3]*abs((x-[2])*(x-[2])*(x-[2]))",0.5,2.5); //std 0.6 1.55 vs pT ; 0.6 1.8 vs eta fitfunc->SetParameters(histminY,0.002,histminX,0.0); fitfunc->SetParLimits(1,0,1000); fitfunc->SetParLimits(2,0.2,2.0); // fitfunc->SetParLimits(3,0,100); fitfunc->FixParameter(3,0); for(int ifit=0;ifit<3;ifit++) hcorrphi->Fit(Form("fitfunc_%s",h->GetName()),"NO","",histminX-0.6,histminX+0.6); fitfunc->SetName(Form("fitfunc_%s_%.3f",h->GetName(),fitfunc->GetParameter(0))); return fitfunc; }
// -- Draw 1D histos TH1D *plot1Dhisto(double intLumi,TFile *fileName,TString folderName,TString histoName,int color,int rebin,float xMin,float xMax,TString xName, TString yName,TString sampleName,bool mc) { TH1D *hTemp = (TH1D*)fileName->Get(folderName+"/"+histoName); hTemp->SetName(histoName+"_"+sampleName); // hTemp->Sumw2(); if (mc) { hTemp->Scale(intLumi/100.); } hTemp->Rebin(rebin); hTemp->SetLineColor(color); hTemp->SetLineWidth(3); hTemp->GetXaxis()->SetRangeUser(xMin,xMax); hTemp->GetXaxis()->SetTitle(xName); hTemp->GetYaxis()->SetTitle(yName); // last bin: put put overflow hTemp->SetBinContent(hTemp->FindBin(xMax),hTemp->Integral(hTemp->FindBin(xMax),hTemp->GetNbinsX()+1)); // cout << "Nbins=" << hTemp->GetNbinsX() << "\n"; return hTemp; } // ~ end of plot1Dhisto function
TH1D * GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3}; Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6}; TList *list = (TList *)file->Get("output"); TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent)); if (!hin) return NULL; /* get systematics */ TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root"); TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part])); TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin); Double_t pt, width, value, error, sys; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); /*** TEMP ADD SYS ***/ if (addSystematicError) { sys = hsys->GetBinContent(bin) * value; error = TMath::Sqrt(error * error + sys * sys); } h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("ITSsa"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(20); h->SetMarkerColor(1); h->SetFillStyle(0); h->SetFillColor(0); return h; }
TH1D * GetITSTPCSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent) { TList *list = (TList *)file->Get("output"); TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSTPCPartName[part], ITSTPCChargeName[charge], cent + 1)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hITSTPC_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSTPC", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } #if 0 /* add systematic error */ Double_t sys; if (part == 2) sys = 0.5; else sys = 0.1; Double_t cont, conte; for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) { cont = h->GetBinContent(ipt + 1); conte = h->GetBinError(ipt + 1); conte = TMath::Sqrt(conte * conte + sys * sys * cont * cont); h->SetBinError(ipt + 1, conte); } #endif h->SetTitle("ITSTPC"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(21); h->SetMarkerColor(2); h->SetFillStyle(0); h->SetFillColor(0); return h; }
// Rebin first histogram to match the second TH1D *tools::Rebin(const TH1D *h, const TH1D* href) { //assert(href->GetNbinsX()<=h->GetNbinsX()); if (!(href->GetNbinsX()<=h->GetNbinsX())) { cout << "Histo has less bins than ref: " << h->GetNbinsX() << " vs " << href->GetNbinsX() << " for " << h->GetName() << endl; } // First, we need to rebin inclusive jets to match b-tagged jets TH1D *hre = (TH1D*)href->Clone(Form("%s_rebin",h->GetName())); hre->Reset(); for (int i = 1; i != h->GetNbinsX()+1; ++i) { double x = h->GetBinLowEdge(i); int j = hre->FindBin(x); // Check that h is fully contained within href bin if (h->GetBinContent(i)!=0) { if (!(h->GetBinLowEdge(i)>=hre->GetBinLowEdge(j) - 1e-5 && h->GetBinLowEdge(i+1)<=hre->GetBinLowEdge(j+1) + 1e-5)) { cerr << Form("Warning, bin edges overlapping: h=[%1.0f,%1.0f]," " hre=[%1.0f,%1.0f] (%s)", h->GetBinLowEdge(i), h->GetBinLowEdge(i+1), hre->GetBinLowEdge(j), hre->GetBinLowEdge(j+1), h->GetName()) << endl; } double y = ( hre->GetBinContent(j)*hre->GetBinWidth(j) + h->GetBinContent(i)*h->GetBinWidth(i) ) / hre->GetBinWidth(j); //double ey = ( hre->GetBinError(j)*hre->GetBinWidth(j) // + h->GetBinError(i)*h->GetBinWidth(i) ) // / hre->GetBinWidth(j); double ey = sqrt( pow(hre->GetBinError(j)*hre->GetBinWidth(j),2) + pow(h->GetBinError(i)*h->GetBinWidth(i),2) ) / hre->GetBinWidth(j); hre->SetBinContent(j, y); hre->SetBinError(j, ey); } } // for i return hre; } // Rebin
TH1D * GetTPCTOFSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0., 0., 0.}; Double_t ptMax[AliPID::kSPECIES] = {0., 0., 1.2, 1.2, 1.8}; TH1D *hin = (TH1D *)file->Get(Form("%sFinal%s%d", TPCTOFPartName[part], TPCTOFChargeName[charge], cent)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hTPCTOF_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "TPCTOF", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TPCTOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(22); h->SetMarkerColor(8); h->SetFillStyle(0); h->SetFillColor(0); return h; }
// Draw 1D histos TH1D *plot1Dhisto(double intLumi,TFile *fileName,TString folderName,TString histoName,int color,int rebin,float xMin,float xMax,TString xName, TString yName,TString sampleName,bool mc) { TH1D *hTemp = (TH1D*)fileName->Get(folderName+"/"+histoName); hTemp->SetName(histoName+"_"+sampleName); if (mc){ hTemp->Scale(intLumi/100.); } hTemp->Rebin(rebin); hTemp->SetLineColor(color); hTemp->SetLineWidth(5); hTemp->GetXaxis()->SetRangeUser(xMin,xMax); hTemp->GetXaxis()->SetTitle(xName); hTemp->GetXaxis()->SetTitleSize(0.06); hTemp->GetXaxis()->SetLabelSize(0.06); hTemp->GetYaxis()->SetTitle(yName); hTemp->GetYaxis()->SetTitleSize(0.06); hTemp->GetYaxis()->SetLabelSize(0.06); hTemp->SetTitleOffset(1.5, "Y"); // last/first bin: put over/underflow hTemp->SetBinContent(hTemp->FindBin(xMax),hTemp->Integral(hTemp->FindBin(xMax),hTemp->GetNbinsX()+1)); hTemp->SetBinContent(hTemp->FindBin(xMin),hTemp->Integral(-1,hTemp->FindBin(xMin))); hTemp->SetBinError(hTemp->FindBin(xMax),sqrt(hTemp->Integral(hTemp->FindBin(xMax),hTemp->GetNbinsX()+1))); hTemp->SetBinError(hTemp->FindBin(xMin),sqrt(hTemp->Integral(-1,hTemp->FindBin(xMin)))); //fileName->Close(); /* if (histoName != "LP_tot") { if (histoName != "SumLepPt_tot") { if ((folderName == "ANplots150_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,300.); } if ((folderName == "ANplots250_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,400.); } if ((folderName == "ANplots350_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,500.); } if ((folderName == "ANplots450_NOLP")) { hTemp->GetXaxis()->SetRangeUser(0.,1000.); } } else { if ((folderName == "ANplots150_NOLP")) { hTemp->GetXaxis()->SetRangeUser(100.,300.); } if ((folderName == "ANplots250_NOLP")) { hTemp->GetXaxis()->SetRangeUser(200.,400.); } if ((folderName == "ANplots350_NOLP")) { hTemp->GetXaxis()->SetRangeUser(300.,500.); } if ((folderName == "ANplots450_NOLP")) { hTemp->GetXaxis()->SetRangeUser(400.,1000.); } } } */ return hTemp; } // ~ end of plot1Dhisto function
void DetermineAnchorsPP(const Char_t* inputDir, TString lPeriodName = "LHC18f", Int_t runNo, const Char_t* chunkName = "", Bool_t automaticMode=kFALSE) { // // In automatic mode the function does not request any standard input and creates anchor points if the fit was ok // using the anchor value determined automatically. // One must check the QA plots for individual run to make sure the automatic values are fine and eventually run this // function again in manual mode. // Bool_t lUseDefaultAnchorPercentile = kFALSE; Double_t lDefaultAnchorPercentile = 0.10; Double_t lMinimumAnchorPercentile = 0.05; // open minimum bias OADB file TString lOADBfile = Form("OADB-%s-MB.root", lPeriodName.Data()); cout << "Opening minimum bias info ... " << endl; TFile *foadb = new TFile( lOADBfile.Data(), "READ" ); AliOADBContainer *lOADBcontainer = (AliOADBContainer*)foadb->Get("MultSel"); // set percentile boundaries for the estimator histos // (based on what is implemented in the calibration) Double_t lDesiredBoundaries[1000]; Long_t lNDesiredBoundaries=0; lDesiredBoundaries[0] = 0.0; //From High To Low Multiplicity for( Int_t ib = 1; ib < 101; ib++) { // 100 bins ] 0.0 , 0.1 ] lNDesiredBoundaries++; lDesiredBoundaries[lNDesiredBoundaries] = lDesiredBoundaries[lNDesiredBoundaries-1] + 0.01; } for( Int_t ib = 1; ib < 91; ib++) { // 90 bins ] 1.0 , 10. ] lNDesiredBoundaries++; lDesiredBoundaries[lNDesiredBoundaries] = lDesiredBoundaries[lNDesiredBoundaries-1] + 0.1; } for( Int_t ib = 1; ib < 91; ib++) { // 90 bins ] 10.0 , 100.0 ] lNDesiredBoundaries++; lDesiredBoundaries[lNDesiredBoundaries] = lDesiredBoundaries[lNDesiredBoundaries-1] + 1.0; } FILE *fap = 0x0; // auxiliary objects TLegend *legEstimator = 0x0; // TLine *anchorLine = new TLine(); anchorLine->SetLineStyle(2); // TLatex *latex = new TLatex(); latex->SetTextFont(42); latex->SetTextSize(0.025); // constant function for the scaling factor determination TF1 *fpol0 = new TF1("fpol0", "[0]", 0.005, lMinimumAnchorPercentile); fpol0->SetLineStyle(3); fpol0->SetLineWidth(1); fpol0->SetLineColor(kBlack); TF1 *fpol0_hi = (TF1*)fpol0->Clone("fpol0_hi"); TF1 *fpol0_lo = (TF1*)fpol0->Clone("fpol0_lo"); // Int_t npar = 3; TF1 *fturnon = new TF1("fturnon", func_turnon, 0., 1., npar); fturnon->SetParameters(1., 0.1, -1.); fturnon->SetParLimits(1, lMinimumAnchorPercentile, 1.0); fturnon->SetParLimits(2, -1.e15, 0.); fturnon->SetLineColor(1); // open input AnalysisResults.root file for the VHM sample TString fileIdentifier = Form("%d", runNo); if(chunkName[0]!='\0') fileIdentifier = chunkName; TFile *fin = TFile::Open(Form("%s/AnalysisResults_%s.root", inputDir, fileIdentifier.Data()), "READ"); TTree *treeEvent = (TTree*)fin->Get("MultSelection/fTreeEvent"); cout << " - run number....................: " << runNo << endl; // define estimator histo for this run TH1D* hEstimator = new TH1D(Form("hEstimator_%d", runNo), "", lNDesiredBoundaries, lDesiredBoundaries); hEstimator->Sumw2(); hEstimator->GetXaxis()->SetTitle("V0M Percentile"); hEstimator->GetYaxis()->SetTitle("Counts"); hEstimator->SetStats(0); hEstimator->SetLineColor(kRed); // get corresponding calibration histogram from OADB AliOADBMultSelection* lOADB = (AliOADBMultSelection*)lOADBcontainer->GetObject( runNo, "Default" ); if( (Int_t)lOADBcontainer->GetIndexForRun( runNo )<0 ) { cout << " ---> Warning: no calibration histo found for this run - skipping..." << endl; return; } // set the pointer to the calib histo for this run hCalib = (TH1D*)lOADB->GetCalibHisto( "hCalib_V0M" );; // Double_t nall = treeEvent->Draw(Form("get_percentile(fAmplitude_V0A+fAmplitude_V0C)>>hEstimator_%d", runNo), Form("fRunNumber==%d && fEvSel_Triggered && fEvSel_IsNotPileupInMultBins && fEvSel_PassesTrackletVsCluster && fEvSel_INELgtZERO && fEvSel_HasNoInconsistentVertices && TMath::Abs(fEvSel_VtxZ)<=10.0 && isSelectedHM(fEvSel_TriggerMask)", runNo), "goff"); hEstimator->Scale(1., "width"); Double_t nevents = (Double_t)hEstimator->GetEntries(); cout << " - number of events (selected)...: " << nevents << endl; // draw histogram TCanvas *cEstimator = new TCanvas(Form("cEstimator_%d", runNo), "Estimator Distribution", 10, 10, 1000, 750); cEstimator->SetRightMargin(0.05); cEstimator->SetTopMargin(0.11); hEstimator->GetXaxis()->SetRangeUser(0., 0.2); hEstimator->Draw("hist e0"); latex->SetNDC(); latex->SetTextSize(0.06); latex->DrawLatex(0.1, 0.93, Form("Run: %d", runNo)); // first, fit a pol0 in the flat region (usually up to 0.05) hEstimator->Fit(fpol0, "RQ0"); Double_t flat_top = fpol0->GetParameter(0); // get standard deviantion of bin contents in the flat region Double_t flat_top_stdev = 0.; for(Int_t ibin=1; ibin<=hEstimator->FindBin(lMinimumAnchorPercentile); ++ibin) { Double_t content = hEstimator->GetBinContent(ibin); Double_t width = hEstimator->GetBinWidth(ibin); flat_top_stdev += TMath::Power((content-flat_top), 2.)*width; } flat_top_stdev = TMath::Sqrt(flat_top_stdev/lMinimumAnchorPercentile) / 2.; fpol0_hi->SetParameter(0, flat_top+flat_top_stdev); fpol0_lo->SetParameter(0, flat_top-flat_top_stdev); // now, fix the constant parameter in the turnon function fturnon->SetParameters(1., 0.1, -1.); fturnon->FixParameter(0, flat_top); // get the maximum range to perform the fit Double_t range_max = (hEstimator->GetBinLowEdge(hEstimator->FindLastBinAbove())) / 1.8; fturnon->SetRange(0.005, (range_max>0.1) ? range_max : 0.1); // get anchor percentile Double_t anchor_percentile = -1.; TString fitstatus = ""; if(nevents>0) { TFitResultPtr fitr = hEstimator->Fit(fturnon, "RQM"); fturnon->Draw("lsame"); fitstatus = gMinuit->fCstatu; } cEstimator->Flush(); cEstimator->Update(); cout << " - fit status....................: " << fitstatus << endl; if( !fitstatus.Contains("OK") ) { if(gROOT->IsBatch()) { cout << " ---> Warning: fit failed! -- skipping this run..." << endl; if(!automaticMode) { fap = fopen(Form("temp/anchors/Anchor_%s_%d_VHM.txt", lPeriodName.Data(), runNo), "w"); fprintf(fap, "%d %d %.2lf %lf\n", runNo, runNo, -1., -1.); } return; } if(!automaticMode) { cout << " - Please, provide an anchor percentile to continue: " << endl; cout << " (entering a negative value will skip this run)" << endl; cout << " >>>> anchor percentile: "; cin >> anchor_percentile; if(anchor_percentile<0.) { cout << " ---> Warning: percentile provided is negative -- skipping this run..." << endl; fap = fopen(Form("temp/anchors/Anchor_%s_%d_VHM.txt", lPeriodName.Data(), runNo), "w"); fprintf(fap, "%d %d %.2lf %lf\n", runNo, runNo, -1., -1.); return; } } else return; // in automatic mode we do not create an anchor file
void scan2() { /* TFile f1("hist.root"); TFile f2("SysTot.root"); TH1D *datahist = (TH1D*)f1.Get("datahist"); TH1D *fithist = (TH1D*)f1.Get("fithist"); TH1D *totlow = (TH1D*)f2.Get("totlow"); TH1D *tothigh = (TH1D*)f2.Get("tothigh"); */ TF1 *fun1 = new TF1("fun",fun,0,1000,3); TFile f("Output.root"); TH1F *datahist = dynamic_cast<TH1F*> (f.Get("InvMass")); TH1F *fithist = dynamic_cast<TH1F*> (f.Get("hist_err")); TH1F *tothigh = dynamic_cast<TH1F*> (f.Get("SystPlus")); TH1F *totlow = dynamic_cast<TH1F*> (f.Get("SystMinus")); new TCanvas(); datahist->DrawCopy(); fithist->DrawCopy("same"); gPad->SetEditable(0); /* if (datahist->IsZombie()) { std::cout << "Err! datahist not found " << std::endl; return; } if (fithist->IsZombie()) { std::cout << "Err! err_hist not found " << std::endl; return; } if (tothigh->IsZombie()) { std::cout << "Err! syst_plus hist not found " << std::endl; return; } if (totlow->IsZombie()) { std::cout << "Err! syst_minus hist not found " << std::endl; return; } */ TH1D *p = new TH1D("p","Probability",100,150,900); for (int i = 1; i<=fithist->GetNbinsX(); i++) { double mass = fithist->GetBinCenter(i); if (mass>440 && mass<450) { double sigma = sqrt(2.0)*sqrt(pow(0.135*sqrt(mass/2.0),2)+ pow(0.02*(mass/2.0),2)); cout<< " ===================== mass +/- sigma = " << mass<<"+/-"<<sigma<<endl; int bin1 = fithist->FindBin(mass-sigma/2); int bin2 = fithist->FindBin(mass+sigma/2); cout<<mass<<" "<<bin1<<" "<<bin2<<endl; double data = 0; double bg = 0; double err = 0; for (int j = bin1; j<=bin2; j++) { data+=datahist->GetBinContent(j); bg+=fithist->GetBinContent(j); double err1 = -totlow->GetBinContent(j); double err2 = tothigh->GetBinContent(j); err+=TMath::Max(err1,err2)*bg; //why multiply by bg??? } cout << "Total Data/Bg+/-err in mass window[" << mass << "] = "<< data <<"/ "<< bg << "+/-" << err <<endl; double prob = 0; fun1->SetParameter(0,bg); fun1->SetParameter(1,err); for (int j = int(data+0.001); j<100; j++) { fun1->SetParameter(2,j); //fun1->Print(); //cout << "Evaluating Intrgral for j = " << j << " from x0= " << TMath::Max(0.0,bg-10*err) << " to x1 = " << bg+10*err << endl; double val = fun1->Integral(TMath::Max(0.0,bg-10*err),bg+10*err); //double val = fun1->Integral(TMath::Max(0.0,bg-2*err),bg+2*err); /*for (int z=TMath::Max(0.0,bg-2*err); z < bg+2*err; ++z) { if (c<4) { std::cout << "func at [" << z << "]=" << fun1->Eval(z) << std::endl; } } */ prob += val; } cout<< "Prob for mass[" << mass<<"]="<< prob <<endl; p->SetBinContent(p->FindBin(mass),prob); } } /* delete gRandom; gRandom = (TRandom*) new TRandom3; gRandom->SetSeed(3); TH1D *minp = new TH1D("minp","Minimum Probability of Each PseudoExpt",100,0,0.2); //int nexp = 50000; int nexp = 10; TH1D *htemp = (TH1D*)datahist->Clone("htemp"); for (int iexp = 0; iexp<nexp; iexp++){ //if (iexp%10==0) cout<<iexp<<endl; //generate pseudo-experiments htemp->Reset(); for (int i = 1; i<=htemp->GetNbinsX(); i++){ double mass = htemp->GetBinCenter(i); if (mass>150&&mass<650){ double bg = fithist->GetBinContent(i); double err1 = -totlow->GetBinContent(i); double err2 = tothigh->GetBinContent(i); double err = TMath::Max(err1,err2)*bg; double mean = gRandom->Gaus(bg,err); if (mean<0) mean = 0; htemp->SetBinContent(i,gRandom->Poisson(mean)); } } double minprob = 2.; for (int i = 1; i<=fithist->GetNbinsX(); i++){ double mass = fithist->GetBinCenter(i); if (mass>150&&mass<650){ double sigma = sqrt(2.0)*sqrt(pow(0.135*sqrt(mass/2.0),2)+ pow(0.02*(mass/2.0),2)); //cout<<mass<<" "<<sigma<<endl; int bin1 = fithist->FindBin(mass-sigma/2); int bin2 = fithist->FindBin(mass+sigma/2); //cout<<mass<<" "<<bin1<<" "<<bin2<<endl; double data = 0; double bg = 0; double err = 0; for (int j = bin1; j<=bin2; j++){ data+=htemp->GetBinContent(j); bg+=fithist->GetBinContent(j); double err1 = -totlow->GetBinContent(j); double err2 = tothigh->GetBinContent(j); err+=TMath::Max(err1,err2)*bg; } //cout<<mass<<" "<<data<<" "<<bg<<" "<<err<<endl; double prob = 0; fun1->SetParameter(0,bg); fun1->SetParameter(1,err); for (int j = int(data+0.001); j<100; j++){ fun1->SetParameter(2,j); prob += fun1->Integral(TMath::Max(0.0,bg-10*err),bg+10*err); } if (prob<minprob) minprob=prob; } } minp->Fill(minprob); } */ TCanvas *c1 = new TCanvas("c1","c1"); TH2D *fr = new TH2D("fr","",100,150,900,100,1e-5,2); fr->SetStats(0); fr->SetXTitle("M(#gamma,lead jet)(GeV)"); fr->SetYTitle("Prob of fluctuation #geq N_{obs}"); fr->GetXaxis()->CenterTitle(); fr->GetYaxis()->CenterTitle(); fr->DrawCopy(); p->SetLineWidth(2); p->DrawCopy("same"); double minp=0; double mgg=0; double minc = 10; for (int i = 1; i<=p->GetNbinsX(); i++) { double bin = p->GetBinCenter(i); double binc = p->GetBinContent(i); if (binc<minc) { minp = binc; mgg = bin; minc = binc; } } cout<<mgg<<" "<<minp<<endl; gPad->SetLogy(); double p1s = 0.00458319; double m1s = 0.0435982; double s3s = 0.000100319; TLine *l1 = new TLine(150,p1s,900,p1s); TLine *l2 = new TLine(150,m1s,900,m1s); TLine *l3 = new TLine(150,s3s,900,s3s); l1->SetLineColor(4); l2->SetLineColor(4); l3->SetLineColor(2); l1->SetLineWidth(2); l2->SetLineWidth(2); l3->SetLineWidth(2); l1->Draw(); l2->Draw(); l3->Draw(); TLatex *t1 = new TLatex(250,m1s/4,"Expected Range for Min. Obs. Prob."); t1->SetTextColor(4); t1->SetTextSize(0.05); t1->Draw(); TLatex *t2 = new TLatex(350,s3s*1.5,"3 #sigma evidence level"); t2->SetTextColor(2); t2->SetTextSize(0.05); t2->Draw(); TLatex *t3 = new TLatex(0.3,0.93,"CDF Run II Preliminary, 2.0 fb^{-1}"); t3->SetNDC(true); t3->SetTextSize(0.06); t3->Draw(); // // TCanvas *c2 = new TCanvas("c2","c2"); // minp->DrawCopy(); //cout<<minp->GetMean()<<endl; }
int main( int argc, const char *argv[] ) { if(argc != 7) { std::cerr << "Usage: TrackCorrection <MC sample> <DATA sample> <tag> <nEventsDATA> <nEventsMC> <PIDconfig>" << std::endl; exit(1); } std::string inpFilenameDATA = argv[1]; std::string inpFilenameMC = argv[2]; std::string tag = argv[3]; int nEvMaxDATA = atoi( argv[4] ); int nEvMaxMC = atoi( argv[5] ); std::string PIDconfig = argv[6]; PIDUtil *pidutil = new PIDUtil; pidutil->ReadInConfig(PIDconfig); // Binning int *nPtBins = new int[nCorrTyp_]; for(int TypBin = 0; TypBin < nCorrTyp; TypBin++) { nPtBins[TypBin] = nPtBins_[TypBin]; } int nMultiplicityBins_Ana = nMultiplicityBins_Ana_HDR; int nMultiplicityBins_EvM = nMultiplicityBins_EvM_HDR; int nZvtxBins = nZvtxBins_; LogFile log("log"); log.repeat = 1000; /////////////////////////// // Global initialization // /////////////////////////// TH1D *zvtxDistrMC = new TH1D("zvtxDistrMC ",";zvtx;nEvents", nZvtxDistrBins, zVtxDistrMin, zVtxDistrMax); TH1D *zvtxDistrDATA = new TH1D("zvtxDistrDATA",";zvtx;nEvents", nZvtxDistrBins, zVtxDistrMin, zVtxDistrMax); TH1D *ratiozvtx; // ptbins const int nptlogmax = 15; const double l10 = TMath::Log(10); double ptbinslog[nCorrTyp][nptlogmax]; double dptlog[nCorrTyp]; for(int i = 0; i < nCorrTyp; i++) { dptlog[i] = ( TMath::Log(ptmaxlog[i]) - TMath::Log(ptminlog[i]) )/nptlog[i]/l10; } ///////////////////////////////////// // // // ====== zvtx distribution ====== // // // ///////////////////////////////////// //////////////////////// // === DATA z-vtx === // //////////////////////// /////////////// // Open file // /////////////// TFile *fdt = NULL; fdt = TFile::Open(inpFilenameDATA.c_str()); if ( fdt->IsZombie() || (fdt == NULL) ) {std::cerr << "Error opening file: " << inpFilenameDATA.c_str() << std::endl; exit(-1);} else {std::cout << Form("TFile %s seem to have loaded.\n", inpFilenameDATA.c_str()); } ////////////////// // Initializing // ////////////////// EvtAnalyzer EvAnaDATA; EvAnaDATA.setupEvtAnaTree( fdt ); EvtSelection EvSelDATA; EvSelDATA.setupSkimTree_pPb( fdt, false); //////////////// // Event loop // //////////////// log.wr( "Starting to process DATA for zvtx distribution." ); if (nEvMaxDATA == -1) { nEvMaxDATA = EvSelDATA.SkimAna->GetEntries(); } log.wr( Form("nEvMaxDATA: %d", nEvMaxDATA) ); for (int iEv = 0; iEv < nEvMaxDATA; iEv++) { // EventCounter log.EventCounter(iEv); // EventSelection if ( !EvSelDATA.isGoodEv_pPb( iEv ) ) continue; EvAnaDATA.GetEntry( iEv ); zvtxDistrDATA->Fill( EvAnaDATA.getvz() ); } log.wr( "DATA processed." ); log.wr( "zVtx distribution." ); fdt->Close(); delete fdt; ////////////////////// // === MC z-vtx === // ////////////////////// /////////////// // Open file // /////////////// TFile *fmc = NULL; fmc = TFile::Open(inpFilenameMC.c_str()); if ( (fmc->IsZombie()) || (fmc == NULL) ) {std::cerr << "Error opening file: " << inpFilenameMC << std::endl; exit(-1);} else {std::cout << Form("TFile %s seem to have loaded.\n", inpFilenameMC.c_str()); } ////////////////// // Initializing // ////////////////// EvtAnalyzer EvAnaMC; EvAnaMC.setupEvtAnaTree( fmc ); EvtSelection EvSelMC; EvSelMC.setupSkimTree_pPb( fmc, true); //////////////// // Event loop // //////////////// log.wr( "Starting to process MC for zvtx distribution." ); if (nEvMaxMC == -1) { nEvMaxMC = EvSelMC.SkimAna->GetEntries(); } log.wr( Form("nEvMaxMC: %d", nEvMaxMC) ); for (int iEv = 0; iEv < nEvMaxMC; iEv++) { // Event counter info log.EventCounter(iEv); // EventSelection if ( !EvSelMC.isGoodEv_pPb( iEv ) ) continue; EvAnaMC.GetEntry( iEv ); zvtxDistrMC->Fill( EvAnaMC.getvz() ); } //////////////////// // Setting output // //////////////////// TFile *output = new TFile(Form("./trkCorrections_%s.root", tag.c_str() ),"RECREATE"); output->cd(); double nEvDATA = zvtxDistrDATA->Integral(); double nEvMC = zvtxDistrMC ->Integral(); zvtxDistrDATA->Scale(1./nEvDATA); zvtxDistrMC ->Scale(1./nEvMC); ratiozvtx = (TH1D*)zvtxDistrDATA->Clone("zvtxratio"); ratiozvtx->Divide( zvtxDistrMC ); ////////////////////////////////////// // // // ====== MC eff calculation ====== // // // ////////////////////////////////////// /////////////// // Open file // /////////////// TTree *trackTree = (TTree*)fmc->Get("ppTrack/trackTree"); Tracks_c tTracks; setupTrackTree_c(trackTree, tTracks, true); ////////////////////////////// // // // ***** Initializing ***** // // // ////////////////////////////// std::cout << "Initializing..." << std::endl; TH3D **hmatched3D = Setup_TH3D_nCorrTyp("hmatched3D", ";p_{T};#eta;#phi", npt,ptMin,ptMax,neta,etaMin,etaMax,nphi,phiMin,phiMax); TH3D **hgen3D = Setup_TH3D_nCorrTyp("hgen3D", ";p_{T};#eta;#phi", npt,ptMin,ptMax,neta,etaMin,etaMax,nphi,phiMin,phiMax); TH3D *heff3D[nCorrTyp]; std::cout << "hmatched3D, hgen3D, heff3D initialized." << std::endl; TH2D **hmatched2D = Setup_TH2D_nCorrTyp("hmatched2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hgen2D = Setup_TH2D_nCorrTyp("hgen2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hfake2D = Setup_TH2D_nCorrTyp("hfake2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hreco2D = Setup_TH2D_nCorrTyp("hreco2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hsecondary2D = Setup_TH2D_nCorrTyp("hsecondary2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hreal2D = Setup_TH2D_nCorrTyp("hreal2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D **hmultrec2D = Setup_TH2D_nCorrTyp("hmultrec2D", ";p_{T};#eta", npt,ptMin,ptMax,neta,etaMin,etaMax); TH2D *hmultrecrate2D[nCorrTyp]; std::cout << "hmatched2D, hgen2D, hfake2D, hreco2D, hsecondary2D, hreco2D, hmultrecrate2D, hmultrecrate2D initialized." << std::endl; TH1D **hmatched1D = Setup_TH1D_nCorrTyp("hmatched1D", ";#eta", neta,etaMin,etaMax); TH1D **hgen1D = Setup_TH1D_nCorrTyp("hgen1D", ";#eta", neta,etaMin,etaMax); TH1D **hfake1D = Setup_TH1D_nCorrTyp("hfake1D", ";#eta", neta,etaMin,etaMax); TH1D **hreco1D = Setup_TH1D_nCorrTyp("hreco1D", ";#eta", neta,etaMin,etaMax); TH1D **hsecondary1D = Setup_TH1D_nCorrTyp("hsecondary1D", ";#eta", neta,etaMin,etaMax); TH1D **hreal1D = Setup_TH1D_nCorrTyp("hreal1D", ";#eta", neta,etaMin,etaMax); TH1D **hmultrec1D = Setup_TH1D_nCorrTyp("hmultrec1D", ";#eta", neta,etaMin,etaMax); TH1D *hmultrecrate1D[nCorrTyp]; std::cout << "hmatched1D, hgen1D, hfakse1D, hreco1D, hsecondary1D, hreal1D, hmultrec1D, hmultrecrate1D initialized." << std::endl; TH3D **hcorr3D = Setup_TH3D_nCorrTyp("hcorr3D", ";p_{T};#eta;#phi", npt,ptMin,ptMax,neta,etaMin,etaMax,nphi,phiMin,phiMax); std::cout << "hcorr3D initialized." << std::endl; /////////////////////////////////////// // // // ***** Calculate corrections ***** // // // /////////////////////////////////////// log.wr( "Starting to process MC to calclulate track corrrections..." ); TH1D *hist = new TH1D("hist", ";eta;", 20, -1.0, 1.0); // Event loop if ( nEvMaxMC == -1 ) { nEvMaxMC = trackTree->GetEntries(); } log.wr( Form("nEvMaxMC: %d", nEvMaxMC)); for (int iEvA = 0; iEvA < nEvMaxMC; iEvA++) { // EventCounter log.EventCounter(iEvA); // Event Selection if ( !EvSelMC.isGoodEv_pPb( iEvA ) ) continue;; // Event zvtx EvAnaMC.GetEntry( iEvA ); float vz = EvAnaMC.getvz(); int vzB = ratiozvtx->FindBin(vz) ; int wzvtx = ratiozvtx->GetBinContent(vzB); if ( (vzB == -1) || ((nZvtxDistrBins) == vzB)) continue; // Tracks & particles trackTree->GetEntry(iEvA); int nTrk = tTracks.nTrk; // Track loop for (int iTrk = 0; iTrk < nTrk; iTrk++) { // *** Track selection *** // if ( !TrackSelection(tTracks, iTrk ) ) continue; double pt = tTracks.trkPt [iTrk]; double eta = tTracks.trkEta[iTrk]; double phi = tTracks.trkPhi[iTrk]; float p = pt * cosh(eta); int PID = pidutil->GetID( tTracks, iTrk); bool isPID = (PID != 99); bool isInsideChrPt = ( ptbin( 0, pt) != -1 ); bool isInsidePIDPt = ( ptbin(PID, pt) != -1 ); // Fake tracks if( tTracks.trkFake[iTrk] ) { hfake2D[ 0 ]->Fill(pt,eta, wzvtx); if (isInsideChrPt) { hfake1D[ 0 ]->Fill( eta, wzvtx);} if (isPID) {hfake2D[PID]->Fill(pt,eta, wzvtx); if (isInsidePIDPt) { hfake1D[PID]->Fill(eta, wzvtx);}}; } else // Real track { hreal2D[ 0 ]->Fill(pt,eta, wzvtx); if (isInsideChrPt) {hreal1D[ 0 ]->Fill( eta, wzvtx);} if (isPID) {hreal2D[PID]->Fill(pt,eta, wzvtx); if (isInsidePIDPt) {hreal1D[PID]->Fill( eta, wzvtx);}} // Real secondary track if( tTracks.trkStatus[iTrk] < 0 ) { hsecondary2D[ 0 ]->Fill(pt,eta,wzvtx); if (isInsideChrPt) {hsecondary1D[ 0 ]->Fill( eta,wzvtx);} if (isPID) { hsecondary2D[PID]->Fill(pt,eta,wzvtx); if (isInsidePIDPt) {hsecondary1D[PID]->Fill( eta,wzvtx);}} }; } // Reconstructed tracks hreco2D[ 0 ]->Fill(pt,eta,wzvtx); if (isInsideChrPt) {hreco1D[ 0 ]->Fill( eta,wzvtx);} if (isPID) {hreco2D[PID]->Fill(pt,eta,wzvtx); if (isInsidePIDPt) {hreco1D[PID]->Fill( eta,wzvtx);}} } // === Particle loop === // for(int iPart = 0; iPart < tTracks.nParticle; iPart++) { double pt = tTracks.pPt [iPart]; double eta = tTracks.pEta[iPart]; double phi = tTracks.pPhi[iPart]; int PID = pidutil->GetIDgenPart_trkCorr( tTracks, iPart); bool isPID = (PID != 99); bool isInsideChrPt = ( ptbin( 0, pt) != -1 ); bool isInsidePIDPt = ( ptbin(PID, pt) != -1 ); // particle selection if( fabs(eta) > 2.4 ) continue; if( pt < ptGlobalMin ) continue; hgen3D[ 0 ]->Fill( pt,eta,phi,wzvtx ); hgen2D[ 0 ]->Fill( pt,eta, wzvtx ); if (isInsideChrPt) {hgen1D[ 0 ]->Fill( eta, wzvtx );} if ( isPID ) { hgen3D[PID]->Fill( pt,eta,phi,wzvtx ); hgen2D[PID]->Fill( pt,eta ,wzvtx ); if (isInsidePIDPt) {hgen1D[PID]->Fill( eta, wzvtx );}}; // matched track selection if( tTracks.pNRec[iPart] == 0 ) continue; // if( !( mTrackSelection_c( tTracks, iPart) )) continue; int mPID = pidutil->GetIDmTrk_trkCorr(tTracks, iPart); bool PID_match = (PID == mPID); hmatched3D[ 0 ]->Fill(pt,eta,phi,wzvtx); hmatched2D[ 0 ]->Fill(pt,eta, wzvtx); hmultrec2D[ 0 ]->Fill(pt,eta,wzvtx*tTracks.pNRec[iPart]); if (isInsideChrPt) { hmultrec1D[ 0 ]->Fill( eta,wzvtx*tTracks.pNRec[iPart]); hmatched1D[ 0 ]->Fill( eta, wzvtx); } if ( isPID && PID_match ) { hmatched3D[PID]->Fill(pt,eta,phi,wzvtx); hmatched2D[PID]->Fill(pt,eta, wzvtx); hmultrec2D[PID]->Fill(pt,eta,wzvtx*tTracks.pNRec[iPart]); if (isInsidePIDPt) { hmatched1D[PID]->Fill( eta, wzvtx); hmultrec1D[PID]->Fill( eta,wzvtx*tTracks.pNRec[iPart]); } } } } for( int iPar = 0; iPar < nCorrTyp; iPar++) { hfake2D [iPar] -> Divide( hreco2D [iPar] ); hfake1D [iPar] -> Divide( hreco1D [iPar] ); hsecondary2D[iPar] -> Divide( hreal2D [iPar] ); hsecondary1D[iPar] -> Divide( hreal1D [iPar] ); heff3D [iPar] = (TH3D*)hmatched3D [iPar]->Clone(Form("heff3D part %d", iPar)); heff3D [iPar] -> Divide( hgen3D [iPar] ); hmultrecrate2D [iPar] = (TH2D*)hmultrec2D [iPar]->Clone(Form("hmultrecrate2D part %d", iPar)); hmultrecrate1D [iPar] = (TH1D*)hmultrec1D [iPar]->Clone(Form("hmultrecrate1D part %d", iPar)); hmultrecrate2D [iPar] -> Divide( hmatched2D[iPar] ); hmultrecrate1D [iPar] -> Divide( hmatched1D[iPar] ); } // Filling track correction table double ptbw[4]; for(int i = 0; i < nCorrTyp; i++) { ptbw[i] = (ptMax[i]-ptMin[i])/npt[i]; } double etabw[4]; for(int i = 0; i < nCorrTyp; i++) { etabw[i] = (etaMax[i]-etaMin[i])/neta[i];} const double phibw = (phiMax-phiMin)/nphi; for(int i = 0; i < nCorrTyp; i++) for(int x = 1; x < npt[i] +1; x++) for(int y = 1; y < neta[i] +1; y++) for(int z = 1; z < nphi +1; z++) { double pt = ptMin[i]+x*ptbw[i]; double eta = etaMin[i]+y*etabw[i]; double phi = phiMin+z*phibw; double value = (1.0-hfake2D[i]->GetBinContent(x,y))*(1.0-hsecondary2D[i]->GetBinContent(x,y)) / ((heff3D[i]->GetBinContent(x,y,z)) * (hmultrecrate2D[i]->GetBinContent(x,y))); hcorr3D[i]->SetBinContent(x,y,z,value); log.wr(Form("%d %.3f %.2f %.2f : %.4f", i, pt, eta, phi, value)); } ////////////////////// // // // **** OUTPUT **** // // // ////////////////////// output->cd(); zvtxDistrDATA->Write(); zvtxDistrMC->Write(); output->Write(); //heff->wr(); //hfake->wr(); //hmultrec->wr(); //hsecondary->wr(); // log.Close(); output->Close(); delete output; printf("Done.\n"); }
TH1D * GetITSsaRatio(TFile *file, Int_t num, Int_t den, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE) { /* pt limits for combined spectra */ // Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3}; // Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6}; TH1 *hnum, *hden; Double_t ptMin = 0., ptMax = 10.; switch (num) { case kPiMinus: ptMin = TMath::Min(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kPion, 1, cent, kFALSE, kFALSE); break; case kPiPlus: ptMin = TMath::Min(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kPion, 0, cent, kFALSE, kFALSE); break; case kPi: ptMin = TMath::Min(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kPion, 1, cent, kFALSE, kFALSE); hnum->Add(GetITSsaSpectrum(file, AliPID::kPion, 0, cent, kFALSE, kFALSE)); break; case kKaMinus: ptMin = TMath::Min(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hnum = GetITSsaSpectrum(file, AliPID::kKaon, 1, cent, kFALSE, kFALSE); break; case kKaPlus: ptMin = TMath::Min(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hnum = GetITSsaSpectrum(file, AliPID::kKaon, 0, cent, kFALSE, kFALSE); break; case kKa: ptMin = TMath::Min(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hnum = GetITSsaSpectrum(file, AliPID::kKaon, 1, cent, kFALSE, kFALSE); hnum->Add(GetITSsaSpectrum(file, AliPID::kKaon, 0, cent, kFALSE, kFALSE)); break; case kPrMinus: ptMin = TMath::Min(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kProton, 1, cent, kFALSE, kFALSE); break; case kPrPlus: ptMin = TMath::Min(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kProton, 0, cent, kFALSE, kFALSE); break; case kPr: ptMin = TMath::Min(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hnum = GetITSsaSpectrum(file, AliPID::kProton, 1, cent, kFALSE, kFALSE); hnum->Add(GetITSsaSpectrum(file, AliPID::kProton, 0, cent, kFALSE, kFALSE)); break; } switch (den) { case kPiMinus: ptMin = TMath::Max(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kPion, 1, cent, kFALSE, kFALSE); break; case kPiPlus: ptMin = TMath::Max(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kPion, 0, cent, kFALSE, kFALSE); break; case kPi: ptMin = TMath::Max(ptMin, 0.1); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kPion, 1, cent, kFALSE, kFALSE); hden->Add(GetITSsaSpectrum(file, AliPID::kPion, 0, cent, kFALSE, kFALSE)); break; case kKaMinus: ptMin = TMath::Max(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hden = GetITSsaSpectrum(file, AliPID::kKaon, 1, cent, kFALSE, kFALSE); break; case kKaPlus: ptMin = TMath::Max(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hden = GetITSsaSpectrum(file, AliPID::kKaon, 0, cent, kFALSE, kFALSE); break; case kKa: ptMin = TMath::Max(ptMin, 0.2); ptMax = TMath::Min(ptMax, 0.5); hden = GetITSsaSpectrum(file, AliPID::kKaon, 1, cent, kFALSE, kFALSE); hden->Add(GetITSsaSpectrum(file, AliPID::kKaon, 0, cent, kFALSE, kFALSE)); break; case kPrMinus: ptMin = TMath::Max(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kProton, 1, cent, kFALSE, kFALSE); break; case kPrPlus: ptMin = TMath::Max(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kProton, 0, cent, kFALSE, kFALSE); break; case kPr: ptMin = TMath::Max(ptMin, 0.3); ptMax = TMath::Min(ptMax, 0.6); hden = GetITSsaSpectrum(file, AliPID::kProton, 1, cent, kFALSE, kFALSE); hden->Add(GetITSsaSpectrum(file, AliPID::kProton, 0, cent, kFALSE, kFALSE)); break; } if (!hnum || !hden) return NULL; Char_t sysname[1024]; if (num == kPiMinus && den == kPiPlus) sprintf(sysname, "Pi_Pos2Neg"); else if (num == kKaMinus && den == kKaPlus) sprintf(sysname, "K_Pos2Neg"); else if (num == kPrMinus && den == kPrPlus) sprintf(sysname, "P_Pos2Neg"); else if ((num == kKa || num == kKaPlus || num == kKaMinus) && (den == kPi || den == kPiPlus || den == kPiMinus)) sprintf(sysname, "K2Pi"); else if ((num == kPr || num == kPrPlus || num == kPrMinus) && (den == kPi || den == kPiPlus || den == kPiMinus)) sprintf(sysname, "P2Pi"); TH1D *hin = (TH1D *)hnum->Clone("hin"); hin->Divide(hden); /* get systematics */ TFile *fsys = TFile::Open("RATIOSYS_ITSsa.root"); TH1 *hsys = fsys->Get(Form("hSystTot%s", sysname)); TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, ratioName[num], ratioName[den]), "ITSsa", NptBins, ptBin); Double_t pt, width, value, error, sys; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) { // printf("skipping %f because of sanity checks\n", pt); continue; } /* check pt limits */ if (cutSpectrum && (pt < ptMin || pt > ptMax)) { // printf("skipping %f because of limits\n", pt); continue; } /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); /*** TEMP ADD SYS ***/ if (addSystematicError) { sys = hsys->GetBinContent(bin) * value; error = TMath::Sqrt(error * error + sys * sys); } h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("ITSsa"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(20); h->SetMarkerColor(1); h->SetFillStyle(0); h->SetFillColor(0); return h; }
//_______________________________________ void FitMCshape(AliDielectronSignalBase *sig) { TFile mcFile(mcLineShapeFile); if (!mcFile.IsOpen()) { printf("mcMinv_LHC10e2 not found!!!\n"); return; } TH1D *hMmc = (TH1D*)mcFile.Get("mcMinv"); if (!hMmc) { printf("mcMinv not found!!\n"); return; } hMmc->SetDirectory(0); hMmc->SetName("mcMinv"); mcFile.Close(); TH1* hMsub=sig->GetSignalHistogram(); Double_t mb1=sig->GetIntegralMin(); Double_t mb2=sig->GetIntegralMax(); Double_t effInt = 0.; for(Int_t iBin=hMmc->FindBin(mb1); iBin<hMmc->FindBin(mb2); iBin++) { effInt += hMmc->GetBinContent(iBin); } effInt/=hMmc->Integral(); printf("MC signal fraction in range %4.2f-%4.2f GeV: %5.3f \n",hMmc->GetBinLowEdge(hMmc->FindBin(mb1)),hMmc->GetBinLowEdge(hMmc->FindBin(mb2)+1),effInt); Float_t mcScale1=(hMsub->GetXaxis()->GetBinWidth(1)/hMmc->GetXaxis()->GetBinWidth(1))* hMsub->Integral(hMsub->FindBin(mb1),hMsub->FindBin(mb2))/ hMmc->Integral(hMmc->FindBin(mb1),hMmc->FindBin(mb2)); printf("1st guess of MC scale factor: %6.3f\n",mcScale1); Float_t mcScale=0.; Float_t chi2_min=100000.; Int_t iMin=0; Int_t ndf=0; for(Int_t i=0; i<20; i++){ Float_t chi2=0.; Float_t scale=(0.4+0.05*(Float_t)i)*mcScale1; ndf=0; for(Int_t ib=1; ib<=hMsub->GetXaxis()->GetNbins(); ib++){ Float_t data=(Float_t)hMsub->GetBinContent(ib); Float_t err=(Float_t)hMsub->GetBinError(ib); Float_t mc=scale*((Float_t)hMmc->GetBinContent(hMmc->FindBin(hMsub->GetBinCenter(ib)))); if (err>0) { chi2 += ((data-mc)*(data-mc))/(err*err); ndf++; } else { //printf("bin %d Err: %6.3f, chi2: %6.1f\n",ib,err,chi2); } } //printf("%d scale factor: %6.3f, chi2: %6.1f\n",i,scale,chi2); if(chi2 < chi2_min){ chi2_min = chi2; mcScale = scale; iMin=i; } } //Float_t chi2dof=chi2_min/(Float_t)(hMinv->GetXaxis()->GetNbins()-1); Float_t chi2dof=chi2_min/((Float_t)(ndf-1)); printf("MC fit (i=%d): chi2/dof: %6.3f/%d, Scale: %7.4f \n",iMin,chi2_min,(ndf-1),mcScale); hMmc->SetTitle(Form("%f",chi2dof)); //mcScale=IntData/IntMC;printf("Int Data, MC: %10.1f %10.1f, MC scale: %6.3f\n",IntData,IntMC,mcScale); hMmc->Scale(mcScale); hMmc->SetOption("sameHISTC"); hMsub->GetListOfFunctions()->Add(hMmc); }
void vn_spectra_trackHF() { TString filename = Form("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_INCLv1HF_nmin-1_nmax-1_etatrg-5.0--3.0_etaass3.0-5.0_centmin110_centmax1000.root"); TFile* fdiff = new TFile(filename.Data()); TH1D* hpt_ref; TH2D* hsignal_ref; TH2D* hbackground_ref; TH1D* hsignal_ref_1D; TH1D* hbackground_ref_1D; TH1D* hcorr_ref_1D; TH1D* hpt[20]; TH2D* hsignal[20]; TH2D* hbackground[20]; TH1D* hsignal_1D[20]; TH1D* hbackground_1D[20]; TH1D* hcorr_1D[20]; TGraphErrors* gr[20]; TGraphErrors* gr_corr[20]; for(int i=0;i<20;i++) { if(i>=5) { gr[i] = new TGraphErrors(11); gr_corr[i] = new TGraphErrors(11); } else { gr[i] = new TGraphErrors(13); gr_corr[i] = new TGraphErrors(13); } gr[i]->SetName(Form("vnpt_%d",i)); gr_corr[i]->SetName(Form("vnpt_corr_%d",i)); } double factor[20]={1.,1.3,1.0,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8}; double factor_err[20]={0.,0.1,0.4,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6}; double VnArray[20][20],Vn0[20],vn0[20],vn0err[20],vn01[20],vn01err[20],vn0_corr[20],vn0_corr_up[20],vn0_corr_down[20],vn0_corr_sys[28],vn0err_corr[20],vn0_ratio[20],vn0err_ratio[20]; hsignal_ref = (TH2D*)fdiff->Get("signalcosn_trg0_ass0"); hbackground_ref = (TH2D*)fdiff->Get("backgroundcosn_trg0_ass0"); hsignal_ref_1D = (TH1D*)hsignal_ref->ProfileY("signal_1D_trg0_ass0_ref",1,-1,"e"); hbackground_ref_1D = (TH1D*)hbackground_ref->ProfileY("background_1D_trg0_ass0_ref",1,-1,"e"); hcorr_ref_1D = new TH1D("Vn_1D_trg0_ass0_ref",";n;V_{n#Delta}",15,0.5,15.5); for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++) { double Vn=hsignal_ref_1D->GetBinContent(n)-hbackground_ref_1D->GetBinContent(n); double VnError=sqrt(hsignal_ref_1D->GetBinError(n)*hsignal_ref_1D->GetBinError(n)+hbackground_ref_1D->GetBinError(n)*hbackground_ref_1D->GetBinError(n)); hcorr_ref_1D->SetBinContent(n,Vn); hcorr_ref_1D->SetBinError(n,VnError); Vn0[n] = Vn; vn0[n] = sqrt(fabs(Vn)); vn0err[n] = fabs(VnError/Vn)*vn0[n]; } TFile* fpt = new TFile(Form("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_INCLv1TrackHF_nmin-1_nmax-1_etatrg-2.4-0.0_etaass3.0-5.0_centmin110_centmax1000.root")); TH1D* hptcorr = (TH1D*)fpt->Get("ptcorrall_trg"); double merit[20]={0}; double merit_err[20]={0}; double total[20]={0}; double merit_corr[20]={0}; double merit_corr_up[20]={0}; double merit_corr_down[20]={0}; double merit_corr_err[20]={0}; double total_corr[20]={0}; for(int i=13;i>=0;i--) { hpt[i] = (TH1D*)fdiff1->Get(Form("ptcorr_trg_%d",i+1)); if(i>2) { hsignal[i] = (TH2D*)fdiff->Get(Form("signalcosn_trg%d_ass0",i+1)); hbackground[i] = (TH2D*)fdiff->Get(Form("backgroundcosn_trg%d_ass0",i+1)); } else { hsignal[i] = (TH2D*)fdiff1->Get(Form("signalcosn_trg%d_ass0",i+1)); hbackground[i] = (TH2D*)fdiff1->Get(Form("backgroundcosn_trg%d_ass0",i+1)); } hsignal_1D[i] = (TH1D*)hsignal[i]->ProfileY(Form("signal_1D_trg%d_ass0",i+1),1,-1,"e"); hbackground_1D[i] = (TH1D*)hbackground[i]->ProfileY(Form("background_1D_trg%d_ass0",i+1),1,-1,"e"); hcorr_1D[i] = new TH1D(Form("Vn_1D_trg%d_ass0",i+1),";n;V_{n#Delta}",15,0.5,15.5); for(int n=1;n<=hcorr_1D[i]->GetNbinsX();n++) { if(n>=6 && hpt[i]->GetMean()>5.0) continue; if(n==5 && hpt[i]->GetMean()>8.0) continue; if(n==4 && hpt[i]->GetMean()>10.0) continue; double Vn=hsignal_1D[i]->GetBinContent(n)-hbackground_1D[i]->GetBinContent(n); double VnError=sqrt(hsignal_1D[i]->GetBinError(n)*hsignal_1D[i]->GetBinError(n)+hbackground_1D[i]->GetBinError(n)*hbackground_1D[i]->GetBinError(n)); VnArray[n][i] = Vn; hcorr_1D[i]->SetBinContent(n,Vn); hcorr_1D[i]->SetBinError(n,VnError); double vn=Vn/vn0[n]; if(i<=2) vn=Vn/vn01[n]; double vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn0err[n]*vn0err[n]); if(i<=2) vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn01err[n]*vn01err[n]); gr[n-1]->SetPoint(i,hpt[i]->GetMean(),vn); gr[n-1]->SetPointError(i,0,vnerr); /* double integral = hpt[i]->Integral(); if(i==0) integral = hpt[1]->Integral(); if(hpt[i]->GetMean()>3.0) continue; merit[n-1] = merit[n-1] + integral/1000.*vn; merit_err[n-1] = merit_err[n-1] + integral/1000.*vnerr; total[n-1] = total[n-1] + integral/1000.; gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1])); if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl; */ double integral = hptcorr->GetBinContent(hptcorr->FindBin(hpt[i]->GetMean()))*hptcorr->GetBinWidth(hptcorr->FindBin(hpt[i]->GetMean())); if(hpt[i]->GetMean()>3.0) continue; merit[n-1] = merit[n-1] + integral/1000.*vn; merit_err[n-1] = merit_err[n-1] + integral/1000.*vnerr; total[n-1] = total[n-1] + integral/1000.; gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1])); if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl; } } TH1D* h1corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),0,0,1.9,4.0); TH1D* h2corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),11,0,1.9,4.0); TCanvas* ccorr = new TCanvas("ccorr","ccorr",900,400); ccorr->Divide(2,1); ccorr->cd(1); ccorr->GetPad(1)->SetLeftMargin(0.23); h1corr->SetAxisRange(50.9,52.,"Y"); h1corr->GetYaxis()->SetTitleOffset(1.2); h1corr->GetXaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98); h1corr->GetYaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98); h1corr->GetXaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98); h1corr->GetYaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98); h1corr->GetYaxis()->SetTitleOffset(h1corr->GetYaxis()->GetTitleOffset()*1.4); h1corr->GetXaxis()->CenterTitle(); h1corr->GetYaxis()->CenterTitle(); h1corr->Draw("PE"); ccorr->cd(2); ccorr->GetPad(2)->SetLeftMargin(0.23); h2corr->SetAxisRange(50.8,52.4,"Y"); h2corr->GetYaxis()->SetTitleOffset(1.2); h2corr->GetXaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98); h2corr->GetYaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98); h2corr->GetXaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98); h2corr->GetYaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98); h2corr->GetYaxis()->SetTitleOffset(h2corr->GetYaxis()->GetTitleOffset()*1.4); h2corr->GetXaxis()->CenterTitle(); h2corr->GetYaxis()->CenterTitle(); h2corr->Draw("PE"); TF1* fitfunc1 = FitVnFunc(h1corr); TF1* fitfunc2 = FitVnFunc(h2corr); fitfunc1->SetLineStyle(4); fitfunc2->SetLineStyle(4); fitfunc1->SetParameters(fitfunc1->GetParameter(0),Vn0[1],Vn0[2],Vn0[3],Vn0[4],Vn0[5],Vn0[6],Vn0[7],Vn0[8],Vn0[9],Vn0[10]); fitfunc2->SetParameters(fitfunc2->GetParameter(0),VnArray[1][10],VnArray[2][10],VnArray[3][10],VnArray[4][10],VnArray[5][10],VnArray[6][10],VnArray[7][10],VnArray[8][10],VnArray[9][10],VnArray[10][10]); ccorr->cd(1); fitfunc1->Draw("Lsame"); ccorr->cd(2); fitfunc2->Draw("Lsame"); TF1* fitfuns1[6]; TF1* fitfuns2[6]; for(int i=0;i<6;i++) { fitfuns1[i] = (TF1*)fitfunc1->Clone(Form("fitfuncs1_%d",i)); fitfuns2[i] = (TF1*)fitfunc2->Clone(Form("fitfuncs2_%d",i)); fitfuns1[i]->SetLineColor(i+1); fitfuns2[i]->SetLineColor(i+1); fitfuns1[i]->SetLineWidth(1); fitfuns2[i]->SetLineWidth(1); fitfuns1[i]->SetLineStyle(1); fitfuns2[i]->SetLineStyle(1); } fitfuns1[0]->SetLineColor(1); fitfuns1[1]->SetLineColor(2); fitfuns1[2]->SetLineColor(9); fitfuns1[3]->SetLineColor(4); fitfuns1[4]->SetLineColor(8); fitfuns1[5]->SetLineColor(6); fitfuns2[0]->SetLineColor(1); fitfuns2[1]->SetLineColor(2); fitfuns2[2]->SetLineColor(9); fitfuns2[3]->SetLineColor(4); fitfuns2[4]->SetLineColor(8); fitfuns2[5]->SetLineColor(6); fitfuns1[0]->SetParameters(fitfuns1[0]->GetParameter(0),fitfuns1[0]->GetParameter(1),0,0,0,0,0,0,0,0,0); fitfuns1[1]->SetParameters(fitfuns1[1]->GetParameter(0),0,fitfuns1[1]->GetParameter(2),0,0,0,0,0,0,0,0); fitfuns1[2]->SetParameters(fitfuns1[2]->GetParameter(0),0,0,fitfuns1[2]->GetParameter(3),0,0,0,0,0,0,0); fitfuns1[3]->SetParameters(fitfuns1[3]->GetParameter(0),0,0,0,fitfuns1[3]->GetParameter(4),0,0,0,0,0,0); fitfuns1[4]->SetParameters(fitfuns1[4]->GetParameter(0),0,0,0,0,fitfuns1[4]->GetParameter(5),0,0,0,0,0); fitfuns1[5]->SetParameters(fitfuns1[5]->GetParameter(0),0,0,0,0,0,fitfuns1[5]->GetParameter(6),0,0,0,0); fitfuns2[0]->SetParameters(fitfuns2[0]->GetParameter(0),fitfuns2[0]->GetParameter(1),0,0,0,0,0,0,0,0,0); fitfuns2[1]->SetParameters(fitfuns2[1]->GetParameter(0),0,fitfuns2[1]->GetParameter(2),0,0,0,0,0,0,0,0); fitfuns2[2]->SetParameters(fitfuns2[2]->GetParameter(0),0,0,fitfuns2[2]->GetParameter(3),0,0,0,0,0,0,0); fitfuns2[3]->SetParameters(fitfuns2[3]->GetParameter(0),0,0,0,fitfuns2[3]->GetParameter(4),0,0,0,0,0,0); fitfuns2[4]->SetParameters(fitfuns2[4]->GetParameter(0),0,0,0,0,fitfuns2[4]->GetParameter(5),0,0,0,0,0); fitfuns2[5]->SetParameters(fitfuns2[5]->GetParameter(0),0,0,0,0,0,fitfuns2[5]->GetParameter(6),0,0,0,0); ccorr->cd(1); fitfuns1[0]->Draw("Lsame"); fitfuns1[1]->Draw("Lsame"); fitfuns1[2]->Draw("Lsame"); fitfuns1[3]->Draw("Lsame"); fitfuns1[4]->Draw("Lsame"); fitfuns1[5]->Draw("Lsame"); ccorr->cd(2); fitfuns2[0]->Draw("Lsame"); fitfuns2[1]->Draw("Lsame"); fitfuns2[2]->Draw("Lsame"); fitfuns2[3]->Draw("Lsame"); fitfuns2[4]->Draw("Lsame"); fitfuns2[5]->Draw("Lsame"); TLegend* legend_corr = new TLegend(0.28,0.63,0.7,0.92); legend_corr->SetFillStyle(0); legend_corr->SetTextFont(42); legend_corr->AddEntry(fitfunc1,"Sum","L"); legend_corr->AddEntry(fitfuns1[0],"n = 1","L"); legend_corr->AddEntry(fitfuns1[1],"n = 2","L"); legend_corr->AddEntry(fitfuns1[2],"n = 3","L"); legend_corr->AddEntry(fitfuns1[3],"n = 4","L"); legend_corr->AddEntry(fitfuns1[4],"n = 5","L"); legend_corr->AddEntry(fitfuns1[5],"n = 6","L"); ccorr->cd(1); legend_corr->Draw("same"); ccorr->cd(2); legend_corr->Draw("same"); ccorr->cd(1); TLatex* latex_corr = new TLatex(); latex_corr->SetNDC(1); latex_corr->SetTextSize(latex_corr->GetTextSize()*0.8); latex_corr->DrawLatex(0.47,0.88,"CMS PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex_corr->DrawLatex(0.63,0.82,centtag.Data()); latex_corr->DrawLatex(0.76,0.76,"|#Delta#eta| > 2"); ccorr->cd(2); TLatex* latex1_corr = new TLatex(); latex1_corr->SetNDC(1); latex1_corr->SetTextSize(latex1_corr->GetTextSize()*0.8); latex1_corr->DrawLatex(0.47,0.88,"CMS PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex1_corr->DrawLatex(0.63,0.82,centtag.Data()); latex1_corr->DrawLatex(0.76,0.76,"|#Delta#eta| > 2"); ccorr->cd(1); TLatex* latex_trg1 = new TLatex(); latex_trg1->SetNDC(1); latex_trg1->SetTextSize(latex_trg1->GetTextSize()*0.8); latex_trg1->DrawLatex(0.59,0.635,"1 < p_{T}^{trig} < 3 GeV/c"); latex_trg1->DrawLatex(0.59,0.57,"1 < p_{T}^{assoc} < 3 GeV/c"); ccorr->cd(2); TLatex* latex_trg2 = new TLatex(); latex_trg2->SetNDC(1); latex_trg2->SetTextSize(latex_trg2->GetTextSize()*0.8); latex_trg2->DrawLatex(0.59,0.635,"4 < p_{T}^{trig} < 5 GeV/c"); latex_trg2->DrawLatex(0.59,0.57,"1 < p_{T}^{assoc} < 3 GeV/c"); SaveCanvas(ccorr,"HI/UCC",Form("corr1Dfit_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax)); /* TCanvas* ccc = new TCanvas("ccc","ccc",900,400); ccc->Divide(2,1); ccc->cd(1); ccc->GetPad(1)->SetLeftMargin(0.3); hsignal_ref_1D->GetYaxis()->SetTitleOffset(2.0); hsignal_ref_1D->GetYaxis()->CenterTitle(); hsignal_ref_1D->SetAxisRange(1.5,10.5,"X"); hsignal_ref_1D->SetAxisRange(-0.00025,0.0019,"Y"); hsignal_ref_1D->SetYTitle("<cos(n#Delta#phi)>"); hsignal_ref_1D->Draw("PE"); hbackground_ref_1D->SetMarkerStyle(24); hbackground_ref_1D->Draw("PESAME"); TLegend* legend = new TLegend(0.5,0.75,0.9,0.9); legend->SetFillStyle(0); legend->SetTextFont(42); legend->AddEntry(hsignal_ref_1D,"Signal","P"); legend->AddEntry(hbackground_ref_1D,"Background","P"); legend->Draw("same"); ccc->cd(2); ccc->GetPad(2)->SetLeftMargin(0.3); hcorr_ref_1D->GetYaxis()->SetTitleOffset(2.0); hcorr_ref_1D->GetYaxis()->CenterTitle(); hcorr_ref_1D->SetAxisRange(1.5,10.5,"X"); hcorr_ref_1D->Draw("PE"); SaveCanvas(ccc,"HI/UCC",Form("sigbak_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax)); */ for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++) { vn0[n] = merit[n-1]/total[n-1]; vn0err[n] = merit_err[n-1]/total[n-1]; } TFile* ffake = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTightMerged_ucc_new.root"); TH1D* hfake = (TH1D*)ffake->Get("hFake"); // TFile* ffake1 = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTight_ucc_new.root"); // TH1D* hfake1 = (TH1D*)ffake1->Get("hFake"); TFile* ffake1 = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTightMerged_ucc_new.root"); TH1D* hfake1 = (TH1D*)ffake1->Get("hFake"); for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++) { cout<<"n="<<n<<endl; for(i=0;i<13;i++) { double x,y,xerr,yerr; gr[n-1]->GetPoint(i,x,y); xerr=gr[n-1]->GetErrorX(i); yerr=gr[n-1]->GetErrorY(i); if(n>=6 && i>10) continue; double fake = 0; if(x>1.0) fake = hfake1->GetBinContent(hfake1->FindBin(x)); if(x<1.0) fake = hfake->GetBinContent(hfake->FindBin(x)); double vn_corr = (y-fake*factor[n-1]*vn0[n])/(1-fake); gr_corr[n-1]->SetPoint(i,x,vn_corr); gr_corr[n-1]->SetPointError(i,0,yerr); cout<<x<<" "<<vn_corr<<" "<<yerr<<endl; double vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.02; double vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.02; // temporarily add additional systematics due to EP comparison /* if(n==2 && i==8) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.08; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.08; } if(n==2 && i==9) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.10; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.10; } if(n==2 && i==10) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.17; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.17; } if(n==2 && i>10) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.17; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.17; } if(n==3 && i>=8) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.04; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.04; } if(n==5) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.04; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.04; } if(n>5) { vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.08; vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.08; } */ if(n>=6) { gr_syst[n-1]->SetPoint(i,x,vn_corr_up); gr_syst[n-1]->SetPoint(21-i,x,vn_corr_down); } else { gr_syst[n-1]->SetPoint(i,x,vn_corr_up); gr_syst[n-1]->SetPoint(25-i,x,vn_corr_down); } gr_ratio[n-1]->SetPoint(i,x,vn_corr/y); gr_ratio[n-1]->SetPointError(i,0,0); // double integral = hpt[i]->Integral(); // if(i==0) integral = hpt[1]->Integral(); double integral = hptcorr->GetBinContent(hptcorr->FindBin(hpt[i]->GetMean()))*hptcorr->GetBinWidth(hptcorr->FindBin(hpt[i]->GetMean())); merit_corr[n-1] = merit_corr[n-1] + integral/1000.*vn_corr; merit_corr_up[n-1] = merit_corr_up[n-1] + integral/1000.*vn_corr_up; merit_corr_down[n-1] = merit_corr_down[n-1] + integral/1000.*vn_corr_down; merit_corr_err[n-1] = merit_corr_err[n-1] + integral/1000.*yerr; total_corr[n-1] = total_corr[n-1] + integral/1000.; } } for(int n=2;n<=15;n++) { vn0_corr[n] = merit_corr[n-1]/total_corr[n-1]; cout<<n<<" "<<vn0_corr[n]<<endl; vn0_corr_up[n] = merit_corr_up[n-1]/total_corr[n-1]; vn0_corr_down[n] = merit_corr_down[n-1]/total_corr[n-1]; vn0_corr_sys[n-2] = vn0_corr_up[n]; vn0_corr_sys[29-n] = vn0_corr_down[n]; if(n>=5) { vn0_corr_sys[n-2] = vn0_corr[n]+0.0004; vn0_corr_sys[29-n] = vn0_corr[n]-0.0004; } vn0err_corr[n] = merit_corr_err[n-1]/total_corr[n-1]; vn0_ratio[n] = vn0_corr[n]/vn0[n]; vn0err_ratio[n] = 0; } double vn_hydro_ideal[4] = {0.21,0.1875,0.1,0.0375}; double vn_hydro_004[4] = {0.195,0.167,0.08,0.025}; double vn_hydro_008[4] = {0.18,0.15,0.0625,0.0167}; double vn_hydro_012[4] = {0.167,0.14,0.05,0.0084}; double vn_hydro_016[4] = {0.15,0.128,0.04,0.001}; double etas[4] = {2,3,4,5}; for(int i=3;i>=0;i--) { vn_hydro_ideal[i] = vn_hydro_ideal[i]/vn_hydro_ideal[0]*vn0[2]; vn_hydro_004[i] = vn_hydro_004[i]/vn_hydro_004[0]*vn0[2]; vn_hydro_008[i] = vn_hydro_008[i]/vn_hydro_008[0]*vn0[2]; vn_hydro_012[i] = vn_hydro_012[i]/vn_hydro_012[0]*vn0[2]; vn_hydro_016[i] = vn_hydro_016[i]/vn_hydro_016[0]*vn0[2]; } TGraph* gr_ideal = new TGraph(4,etas,vn_hydro_ideal); TGraph* gr_004 = new TGraph(4,etas,vn_hydro_004); TGraph* gr_008 = new TGraph(4,etas,vn_hydro_008); TGraph* gr_012 = new TGraph(4,etas,vn_hydro_012); TGraph* gr_016 = new TGraph(4,etas,vn_hydro_016); gr_004->SetLineColor(kRed); gr_008->SetLineColor(kBlue); gr_012->SetLineColor(kGreen); gr_016->SetLineColor(6); gr_ideal->SetLineStyle(9); gr_ideal->SetLineWidth(2); gr_004->SetLineWidth(2); gr_008->SetLineWidth(2); gr_012->SetLineWidth(2); gr_016->SetLineWidth(2); double narray[15] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}; double narray2[28] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,14,13,12,11,10,9,8,7,6,5,4,3,2}; double narrayerr[15] = {0}; TGraphErrors* gr_vn0 = new TGraphErrors(15,narray,vn0,narrayerr,vn0err); gr_vn0->SetName("vnn"); TCanvas* c1 = new TCanvas("c1","",580,500); c1->SetLeftMargin(0.16); TH2D* htmp1 = new TH2D("htmp1",";n;v_{n}",100,0.5,7.9+5,100,0.00003-0.01,0.04); htmp1->GetXaxis()->CenterTitle(); htmp1->GetYaxis()->CenterTitle(); htmp1->GetXaxis()->SetLabelSize(0.8*htmp1->GetXaxis()->GetLabelSize()); htmp1->GetYaxis()->SetLabelSize(0.8*htmp1->GetYaxis()->GetLabelSize()); htmp1->GetYaxis()->SetTitleOffset(0.96*htmp1->GetYaxis()->GetTitleOffset()); htmp1->GetXaxis()->SetTitleOffset(1.02*htmp1->GetXaxis()->GetTitleOffset()); htmp1->GetYaxis()->SetTitleSize(1.1*htmp1->GetYaxis()->GetTitleSize()); htmp1->GetXaxis()->SetTitleSize(0.9*htmp1->GetXaxis()->GetTitleSize()); // c1->SetLogy(); htmp1->Draw(""); gr_vn0->Draw("PESAME"); gr_ideal->Draw("LSAME"); gr_004->Draw("LSAME"); gr_008->Draw("LSAME"); gr_012->Draw("LSAME"); gr_016->Draw("LSAME"); TLine* line1 = new TLine(0.5,0.0,7.9+5,0.0); line1->SetLineStyle(9); line1->Draw("lsame"); TLatex* latex1 = new TLatex(); latex1->SetNDC(1); latex1->SetTextSize(latex1->GetTextSize()*1.0); latex1->DrawLatex(0.65,0.87,"CMS Preliminary"); latex1->DrawLatex(0.65,0.80,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex1->DrawLatex(0.65,0.74,centtag.Data()); latex1->DrawLatex(0.25,0.34,"0.3<p_{T}<3 GeV/c"); TLegend* legend = new TLegend(0.2,0.45,0.45,0.7); legend->SetFillStyle(0); legend->SetTextFont(42); legend->AddEntry(gr_ideal,"Ideal Hydro","L"); legend->AddEntry(gr_004,"#eta/s=0.04","L"); legend->AddEntry(gr_008,"#eta/s=0.08","L"); legend->AddEntry(gr_012,"#eta/s=0.12","L"); legend->AddEntry(gr_016,"#eta/s=0.16","L"); // legend->Draw("same"); SaveCanvas(c1,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax)); TGraphErrors* gr_corr_vn0 = new TGraphErrors(15,narray,vn0_corr,narrayerr,vn0err_corr); gr_corr_vn0->SetName("vnn_corr"); TGraph* gr_corr_vn0_sys = new TGraph(28,narray2,vn0_corr_sys); gr_corr_vn0_sys->SetName("vnn_corr_sys"); TCanvas* c1_corr = new TCanvas("c1_corr","",580,500); c1_corr->SetLeftMargin(0.16); htmp1->Draw(""); gr_corr_vn0_sys->SetFillColor(17); gr_corr_vn0_sys->Draw("Fsame"); gr_corr_vn0->Draw("PESAME"); gr_ideal->Draw("LSAME"); gr_004->Draw("LSAME"); gr_008->Draw("LSAME"); gr_012->Draw("LSAME"); gr_016->Draw("LSAME"); line1->Draw("lsame"); latex1->Draw("same"); // legend->Draw("same"); SaveCanvas(c1_corr,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d_corr",tag.Data(),centmin,centmax)); TGraphErrors* gr_ratio_vn0 = new TGraphErrors(15,narray,vn0_ratio,narrayerr,vn0err_ratio); gr_ratio_vn0->SetName("vnn_ratio"); TCanvas* c1_ratio = new TCanvas("c1_ratio","",580,500); c1_ratio->SetLeftMargin(0.16); TH2D* htmp1_ratio = new TH2D("htmp1_ratio",";n;v_{n}",100,0.5,7.9+5,100,0.5,1.5); htmp1_ratio->GetXaxis()->CenterTitle(); htmp1_ratio->GetYaxis()->CenterTitle(); htmp1_ratio->GetXaxis()->SetLabelSize(0.8*htmp1_ratio->GetXaxis()->GetLabelSize()); htmp1_ratio->GetYaxis()->SetLabelSize(0.8*htmp1_ratio->GetYaxis()->GetLabelSize()); htmp1_ratio->GetYaxis()->SetTitleOffset(0.96*htmp1_ratio->GetYaxis()->GetTitleOffset()); htmp1_ratio->GetXaxis()->SetTitleOffset(1.02*htmp1_ratio->GetXaxis()->GetTitleOffset()); htmp1_ratio->GetYaxis()->SetTitleSize(1.1*htmp1_ratio->GetYaxis()->GetTitleSize()); htmp1_ratio->GetXaxis()->SetTitleSize(0.9*htmp1_ratio->GetXaxis()->GetTitleSize()); // c1->SetLogy(); htmp1_ratio->Draw(""); gr_ratio_vn0->Draw("PESAME"); latex1->Draw("same"); TLine* line1_ratio = new TLine(0.5,1.0,7.9+5,1.0); line1_ratio->SetLineStyle(9); line1_ratio->Draw("lsame"); SaveCanvas(c1_ratio,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d_ratio",tag.Data(),centmin,centmax)); TCanvas* c2 = new TCanvas("c2","",580,500); c2->SetLeftMargin(0.18); TH2D* htmp = new TH2D("htmp",";p_{T}(GeV/c);v_{n}{2part, |#Delta#eta| > 2}",100,-0.001,7.3,100,-0.005,0.099); htmp->GetXaxis()->CenterTitle(); htmp->GetYaxis()->CenterTitle(); htmp->GetXaxis()->SetLabelSize(htmp->GetXaxis()->GetLabelSize()); htmp->GetYaxis()->SetLabelSize(htmp->GetYaxis()->GetLabelSize()); htmp->GetYaxis()->SetTitleOffset(0.8*htmp->GetYaxis()->GetTitleOffset()); htmp->GetXaxis()->SetTitleOffset(0.7*htmp->GetXaxis()->GetTitleOffset()); htmp->GetYaxis()->SetTitleSize(1.5*htmp->GetYaxis()->GetTitleSize()); htmp->GetXaxis()->SetTitleSize(1.4*htmp->GetXaxis()->GetTitleSize()); htmp->Draw(); TLine* line = new TLine(0.001,0,7.3,0.0); line->SetLineStyle(9); line->Draw("lsame"); // gr[0]->SetMarkerColor(6); gr[1]->SetMarkerColor(1); gr[2]->SetMarkerColor(2); gr[3]->SetMarkerColor(3); gr[4]->SetMarkerColor(4); gr[5]->SetMarkerColor(6); gr[1]->SetMarkerStyle(20); gr[2]->SetMarkerStyle(22); gr[3]->SetMarkerStyle(21); gr[4]->SetMarkerStyle(29); gr[5]->SetMarkerStyle(3); gr[2]->SetMarkerSize(1.1*gr[2]->GetMarkerSize()); gr[3]->SetMarkerSize(0.8*gr[3]->GetMarkerSize()); gr[4]->SetMarkerSize(1.3*gr[4]->GetMarkerSize()); gr[5]->SetMarkerSize(1.3*gr[5]->GetMarkerSize()); gr[1]->Draw("PESAME"); gr[2]->Draw("PESAME"); gr[3]->Draw("PESAME"); gr[4]->Draw("PESAME"); gr[5]->Draw("PESAME"); TLegend* legend = new TLegend(0.18,0.6,0.47,0.9); legend->SetFillStyle(0); legend->SetTextFont(42); legend->AddEntry(gr[1],"n = 2","P"); legend->AddEntry(gr[2],"n = 3","P"); legend->AddEntry(gr[3],"n = 4","P"); legend->AddEntry(gr[4],"n = 5","P"); legend->AddEntry(gr[5],"n = 6","P"); legend->Draw("same"); TLatex* latex = new TLatex(); latex->SetNDC(1); latex->SetTextSize(latex->GetTextSize()*1.0); latex->DrawLatex(0.66,0.86,"CMS Preliminary"); latex->DrawLatex(0.64,0.80,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex->DrawLatex(0.66,0.74,centtag.Data()); SaveCanvas(c2,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax)); TCanvas* c2_corr = new TCanvas("c2corr","",600,500); c2_corr->SetBottomMargin(0.12); c2_corr->SetLeftMargin(0.15); htmp->Draw(); line->Draw("lsame"); gr_corr[1]->SetMarkerColor(1); gr_corr[2]->SetMarkerColor(2); gr_corr[3]->SetMarkerColor(3); gr_corr[4]->SetMarkerColor(4); gr_corr[5]->SetMarkerColor(6); gr_corr[1]->SetMarkerStyle(20); gr_corr[2]->SetMarkerStyle(22); gr_corr[3]->SetMarkerStyle(21); gr_corr[4]->SetMarkerStyle(29); gr_corr[5]->SetMarkerStyle(3); gr_corr[2]->SetMarkerSize(1.3*gr_corr[2]->GetMarkerSize()); gr_corr[3]->SetMarkerSize(1.0*gr_corr[3]->GetMarkerSize()); gr_corr[4]->SetMarkerSize(1.5*gr_corr[4]->GetMarkerSize()); gr_corr[5]->SetMarkerSize(1.3*gr_corr[5]->GetMarkerSize()); gr_syst[1]->Draw("FSAME"); gr_syst[2]->Draw("FSAME"); gr_syst[3]->Draw("FSAME"); gr_syst[4]->Draw("FSAME"); gr_syst[5]->Draw("FSAME"); gr_corr[1]->Draw("PESAME"); gr_corr[2]->Draw("PESAME"); gr_corr[3]->Draw("PESAME"); gr_corr[4]->Draw("PESAME"); gr_corr[5]->Draw("PESAME"); legend->Draw("same"); TLatex* latex_corr = new TLatex(); latex_corr->SetNDC(1); latex_corr->SetTextSize(latex_corr->GetTextSize()*0.8); // latex_corr->DrawLatex(0.63,0.88,"CMS Preliminary"); latex_corr->DrawLatex(0.54,0.875,"CMS PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex_corr->DrawLatex(0.68,0.815,centtag.Data()); latex_corr->DrawLatex(0.68,0.755,"1 < p_{T}^{ref} < 3 GeV/c"); SaveCanvas(c2_corr,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d_corr",tag.Data(),centmin,centmax)); TCanvas* c2_ratio = new TCanvas("c2_ratio","",580,500); c2_ratio->SetLeftMargin(0.16); TH2D* htmp_ratio = new TH2D("htmp_ratio",";p_{T}(GeV/c);v^{corr}_{n}/v^{raw}_{n}",100,0.001,7.3,100,0.5,1.5); htmp_ratio->GetXaxis()->CenterTitle(); htmp_ratio->GetYaxis()->CenterTitle(); htmp_ratio->GetXaxis()->SetLabelSize(0.8*htmp_ratio->GetXaxis()->GetLabelSize()); htmp_ratio->GetYaxis()->SetLabelSize(0.8*htmp_ratio->GetYaxis()->GetLabelSize()); htmp_ratio->GetYaxis()->SetTitleOffset(0.98*htmp_ratio->GetYaxis()->GetTitleOffset()); htmp_ratio->GetXaxis()->SetTitleOffset(1.02*htmp_ratio->GetXaxis()->GetTitleOffset()); htmp_ratio->GetYaxis()->SetTitleSize(1.1*htmp_ratio->GetYaxis()->GetTitleSize()); htmp_ratio->GetXaxis()->SetTitleSize(0.9*htmp_ratio->GetXaxis()->GetTitleSize()); htmp_ratio->Draw(); TLine* line_ratio = new TLine(0.001,1.0,7.3,1.0); line_ratio->SetLineStyle(9); line_ratio->Draw("lsame"); gr_ratio[1]->SetMarkerColor(1); gr_ratio[2]->SetMarkerColor(2); gr_ratio[3]->SetMarkerColor(3); gr_ratio[4]->SetMarkerColor(4); gr_ratio[5]->SetMarkerColor(6); gr_ratio[1]->SetMarkerStyle(20); gr_ratio[2]->SetMarkerStyle(22); gr_ratio[3]->SetMarkerStyle(21); gr_ratio[4]->SetMarkerStyle(29); gr_ratio[5]->SetMarkerStyle(3); gr_ratio[2]->SetMarkerSize(1.1*gr_ratio[2]->GetMarkerSize()); gr_ratio[3]->SetMarkerSize(0.8*gr_ratio[3]->GetMarkerSize()); gr_ratio[4]->SetMarkerSize(1.3*gr_ratio[4]->GetMarkerSize()); gr_ratio[5]->SetMarkerSize(1.3*gr_ratio[5]->GetMarkerSize()); gr_ratio[1]->Draw("PESAME"); gr_ratio[2]->Draw("PESAME"); gr_ratio[3]->Draw("PESAME"); gr_ratio[4]->Draw("PESAME"); gr_ratio[5]->Draw("PESAME"); legend->Draw("same"); TLatex* latex_ratio = new TLatex(); latex_ratio->SetNDC(1); latex_ratio->SetTextSize(latex_ratio->GetTextSize()*1.0); latex_ratio->DrawLatex(0.65,0.87,"CMS Preliminary"); latex_ratio->DrawLatex(0.65,0.80,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); latex_ratio->DrawLatex(0.65,0.74,centtag.Data()); SaveCanvas(c2_ratio,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d_ratio",tag.Data(),centmin,centmax)); // gr[0]->Draw("PESAME"); /* c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.gif"); c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.pdf"); c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.eps"); c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.C"); */ /* TCanvas* c0 = new TCanvas("c0","",500,500); hsignal_1D[3]->Draw("PE"); hbackground_1D[3]->SetMarkerStyle(24); hbackground_1D[3]->Draw("PESAME"); TCanvas* c = new TCanvas("c","",500,500); hcorr_1D[3]->SetAxisRange(-0.001,0.006,"Y"); hcorr_1D[3]->SetMarkerColor(1); hcorr_1D[3]->Draw("PE"); */ return; TFile* fout = new TFile(Form("gr_%s_centmin%d_centmax%d.root",tag.Data(),centmin,centmax),"recreate"); gr_vn0->SetName("vnn"); gr_vn0->Write(); gr_corr_vn0->SetName("vnn_corr"); gr_corr_vn0->Write(); gr_corr_vn0_sys->SetName("vnn_corr_sys"); gr_corr_vn0_sys->Write(); gr_ratio_vn0->SetName("vnn_ratio"); gr_ratio_vn0->Write(); for(int i=0;i<6;i++) { gr[i]->SetName(Form("v%dpt",i+1)); gr[i]->Write(); gr_corr[i]->SetName(Form("v%dpt_corr",i+1)); gr_corr[i]->Write(); gr_ratio[i]->SetName(Form("v%dpt_ratio",i+1)); gr_ratio[i]->Write(); gr_syst[i]->SetName(Form("v%dpt_syst",i+1)); gr_syst[i]->Write(); } }
void AliTRDanalyzeTestBeam(Int_t run, Int_t begin, Int_t end) { gROOT->SetStyle("Plain"); //gStyle->SetPadTopMargin(0.02); //gStyle->SetPadRightMargin(0.02); //gStyle->SetPadLeftMargin(0.1); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetOptDate(); TGaxis::SetMaxDigits(3); TStopwatch st; st.Start(); const Int_t N = 640; // declare histograms const int nbins = 100; const int nstart = 0; TH1D *mSi1L = new TH1D("mSi1L", ";number of Si1 fired pads", 50, nstart-0.5, nstart+nbins-0.5); TH1D *mSi2L = new TH1D("mS21L", ";number of Si2 fired pads", 50, nstart-0.5, nstart+nbins-0.5); TProfile *mSi1ChP = new TProfile("mSi1ChP",";Si1 pad number;signal", 1280, -0.5, 1279.5, 0, 200, "s"); TProfile *mSi2ChP = new TProfile("mS21ChP",";Si2 pad number;signal", 1280, -0.5, 1279.5, 0, 200, "s"); TH1D *mSi1N = new TH1D("mSi1N", "Noise Dist Si1;ADC", 100, 0, 50); TH1D *mSi2N = new TH1D("mSi2N", "Noise Dist Si2;ADC", 100, 0, 50); TH1D *mSiCh[4]; mSiCh[0] = new TH1D("mSi1ChX", ";Si1X pad amplitude (ADC)", 250, -0.5, 249.5); mSiCh[1] = new TH1D("mSi1ChY", ";Si1Y pad amplitude (ADC)", 250, -0.5, 249.5); mSiCh[2] = new TH1D("mSi2ChX", ";Si2X pad amplitude (ADC)", 250, -0.5, 249.5); mSiCh[3] = new TH1D("mSi2ChY", ";Si2Y pad amplitude (ADC)", 250, -0.5, 249.5); TH1D *mSiFullCh[4]; mSiFullCh[0] = new TH1D("mSi1fChX", "Si1X;max amplitude (ADC)", 300, -0.5, 299.5); mSiFullCh[1] = new TH1D("mSi1fChY", "Si1Y;max amplitude (ADC)", 300, -0.5, 299.5); mSiFullCh[2] = new TH1D("mSi2fChX", "Si2X;max amplitude (ADC)", 300, -0.5, 299.5); mSiFullCh[3] = new TH1D("mSi2fChY", "Si2Y;max amplitude (ADC)", 300, -0.5, 299.5); TH2D *mPos[2]; mPos[0] = new TH2D("posSi1", ";x Si1 (mm);y Si1 (mm)", 128, 0, 32, 128, 0, 32); mPos[1] = new TH2D("posSi2", ";x Si2 (mm);y Si2 (mm)", 128, 0, 32, 128, 0, 32); TH2D *mCor[2]; mCor[0] = new TH2D("corX", ";Si1 X (mm);Si2 X (mm)", 128, 0, 32, 128, 0, 32); mCor[1] = new TH2D("corY", ";Si1 Y (mm);Si2 Y (mm)", 128, 0, 32, 128, 0, 32); TH2D *mChCor[2]; mChCor[0] = new TH2D("ChCorSi1", ";Si1 amp X;Si1 amp Y", 100, 0, 200, 100, 0, 200); mChCor[1] = new TH2D("ChCorSi2", ";Si2 amp X;Si2 amp Y", 100, 0, 200, 100, 0, 200); gStyle->SetOptStat(11); TH1D *mPb = new TH1D("mPb", ";Amp Pb (ADC)", 150, -0.5, 4499.5); TH1D *mCher = new TH1D("mCher", ";Amp Cherenkov (ADC)", 150, -0.5, 4499.5); TH2D *mPbCher = new TH2D("mPbCher", ";amp Cherenkov;amp Pb", 150, -0.5, 4499.5, 150, -0.5, 4599.5); // gStyle->SetOptStat(0); // needed by the AliTRDRawStreamTB AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); AliTRDcalibDB *calib = AliTRDcalibDB::Instance(); calib->SetRun(0); // TRD data monitoring TH1D *mDet = new TH1D("mDet", ";chamber", 20, -0.5, 19.5); TH1D *mROB = new TH1D("mROB", ";rob", 20, -0.5, 19.5); TH1D *mTRDsig = new TH1D("mTRDsig", ";trdSignal", 100, -0.5, 299.5); //AliLog::SetClassDebugLevel("AliTRDRawStreamTB", 10); int counter = 0; // for(Int_t run = 365; run < 386; run++) { //for(Int_t run = 369; run < 382; run++) { //for(int run = 387; run < 389; run++) { // if (run == 389) continue; cout << run << endl; for(Int_t fn=begin; fn<end; fn++) { // connect to data //const char *base="/Users/radomski/data/1GeV/"; const char *base = "./"; const char *filename = Form("%s/run%d_gdc_daq09.%03d.raw",base,run,fn); if (gSystem->AccessPathName(filename)) continue; cout << filename << endl; AliTRDtestBeam *data = new AliTRDtestBeam(filename); // process data while (data->NextEvent()) { if (!(counter%1000)) cout << "Event = " << counter << endl; counter++; /* AliTRDRawStreamTB *tb = data->GetTRDrawStream(); while(tb->Next()) { mROB->Fill(tb->GetROB()); mDet->Fill(tb->GetDet()); int *sig = tb->GetSignals(); mTRDsig->Fill(sig[0]); mTRDsig->Fill(sig[1]); mTRDsig->Fill(sig[2]); } delete tb; */ mCher->Fill(data->GetCher()); mPb->Fill(data->GetPb()); mPbCher->Fill(data->GetCher(), data->GetPb()); mSi1L->Fill(data->GetNSi1()); mSi2L->Fill(data->GetNSi2()); for(int i=0; i<data->GetNSi1(); i++) { Int_t q = data->GetSi1Charge(i); Int_t a = data->GetSi1Address(i); if (a == 0) continue; // noisy channels mSi1ChP->Fill(a, q); if (a < N) mSiCh[0]->Fill(q); else mSiCh[1]->Fill(q); } for(int i=0; i<data->GetNSi2(); i++) { Int_t q = data->GetSi2Charge(i); Int_t a = data->GetSi2Address(i); if (a == 0 || a == 1279) continue; // noisy channels mSi2ChP->Fill(a, q); if (a < N) mSiCh[2]->Fill(q); else mSiCh[3]->Fill(q); } mSiFullCh[0]->Fill(data->GetQx(0)); mSiFullCh[1]->Fill(data->GetQy(0)); mSiFullCh[2]->Fill(data->GetQx(1)); mSiFullCh[3]->Fill(data->GetQy(1)); for(int k=0; k<2; k++) mChCor[k]->Fill(data->GetQx(k), data->GetQy(k)); /* if (data->GetQx(0) < 20) continue; if (data->GetQx(1) < 20) continue; if (data->GetQy(0) < 20) continue; if (data->GetQy(1) < 20) continue; */ for(int k=0; k<2; k++) mPos[k]->Fill(data->GetX(k), data->GetY(k)); mCor[0]->Fill(data->GetX(0), data->GetX(1)); mCor[1]->Fill(data->GetY(0), data->GetY(1)); } delete data; } //} // process histograms for(int i=1; i<1281; i++) mSi1N->Fill(mSi1ChP->GetBinError(i)); for(int i=1; i<1281; i++) mSi2N->Fill(mSi2ChP->GetBinError(i)); // display cout << "Number of Events = " << counter << endl; /**/ TCanvas *c = new TCanvas("siliconSignal", "silicon signal"); c->Divide(2,2, 0.01, 0.01); c->cd(1); mSi1L->Draw(); c->cd(2); mSi2L->Draw(); c->cd(3); mSi1ChP->Draw(); c->cd(4); mSi2ChP->Draw(); /* */ /**/ c = new TCanvas(); c->Divide(2,2,0.01,0.01); c->cd(1); mSi1N->Draw(); c->cd(2); mSi2N->Draw(); /**/ /**/ // pads c = new TCanvas("siPads", "Silicon Pads"); c->Divide(2,2, 0.01, 0.01); for(int i=0; i<4; i++) { c->cd(i+1); gPad->SetLogy(); mSiCh[i]->Draw(); } // clusters c = new TCanvas("siCluster", "silicon clusters"); c->Divide(2,2, 0.01, 0.01); for(int i=0; i<4; i++) { c->cd(i+1); gPad->SetLogy(); mSiFullCh[i]->Draw(); } // position and correlation c = new TCanvas("siPosition", "reconstructed position"); c->Divide(2,2, 0.01, 0.01); for(int i=0; i<2; i++) { c->cd(1+i); mPos[i]->Draw("col"); c->cd(3+i); mCor[i]->Draw("col"); } c = new TCanvas("siCharge", "si charge correlation"); c->Divide(2,2, 0.01, 0.01); c->cd(1); gPad->SetLogz(); mChCor[0]->Draw("col"); c->cd(2); gPad->SetLogz(); mChCor[1]->Draw("col"); /**/ new TCanvas(); gPad->SetLogy(); mCher->Draw(); // electron sample int bin = mCher->FindBin(500.); double ef = (mCher->Integral(bin, 151)/ mCher->GetSum()); TLatex *l = new TLatex(2e3, 0.02*mCher->GetSum(), Form("Electron fraction = %.2f ", ef)); l->Draw(); new TCanvas(); gPad->SetLogy(); mPb->Draw(); new TCanvas(); gPad->SetLogz(); mPbCher->Draw("colz"); /* c = new TCanvas(); c->Divide(2,2,0.01, 0.01); c->cd(1); gPad->SetLogy(); mTRDsig->Draw(); c->cd(2); mROB->Draw(); c->cd(3); mDet->Draw(); */ st.Stop(); st.Print(); }
// ---------------------------------- //======= Doing real fit and producing Fit/RMS resolution histograms ======= void projectAndFit(TH2F* th2, TH1F*& hFit, TH1F*& hRMS,int tailSign,string name, bool variableBinning,bool wait){ TCanvas* canv = new TCanvas("tmp","tmp",500,500); canv->cd(); //static double sigma; int xBins = th2->GetNbinsX(); //cout << "xBins: " << xBins << endl; //for resolution vs pt if(variableBinning){ hFit = new TH1F("tmp","tmp",xBins,th2->GetXaxis()->GetXbins()->GetArray()); hRMS = new TH1F("tmp2","tmp2",xBins,th2->GetXaxis()->GetXbins()->GetArray()); }else{ //for resolution vs eta hFit = new TH1F("tmp","tmp",xBins,th2->GetBinLowEdge(1),th2->GetBinLowEdge(xBins+1)); hRMS = new TH1F("tmp2","tmp2",xBins,th2->GetBinLowEdge(1),th2->GetBinLowEdge(xBins+1)); } for(int i=1;i<=xBins; i++){ cout << "i,xLeft: " << i << " , " << th2->GetBinLowEdge(i) << endl; TH1D* proj = th2->ProjectionY("prova",i,i+1); if(proj->GetEntries()<20){ //cout << "N entries < 20. Should I continue? " << endl; Wait(); hRMS->SetBinContent(i,0); hRMS->SetBinError(i,0); hFit->SetBinContent(i,0); hFit->SetBinError(i,0); delete proj; continue; } double rms = proj->GetRMS(); double tmpMean; double tmpSigma; // quick fit with standard gauss double leftBound,rightBound; if(tailSign<0){ leftBound = -1.5*rms; rightBound = +1.0*rms; cout << "negative tailSign gives: " << leftBound << " , " << rightBound << endl; } else if(tailSign>0){ leftBound = -1.0*rms; rightBound = +1.5*rms; cout << "positive tailSign gives: " << leftBound << " , " << rightBound << endl; }else{ leftBound = -1.0*rms; rightBound = +1.0*rms; cout << "null tailSign gives: " << leftBound << " , " << rightBound << endl; } TF1* f1 = new TF1("f1","gaus",leftBound,rightBound); TFitResultPtr r = proj->Fit(f1,"S M R L"); proj->Draw(); gPad->Update(); stringstream outputName; if(i<10) outputName << name << "_raw_bin_" << "0" << i ; else outputName << name << "_bin" << i ; //printCanvas(canv,outputName.str(),1); if(wait) Wait(); tmpMean = r->Parameter(1); tmpSigma = r->Parameter(2); double xMin,xMax; xMin = tmpMean - tmpSigma*5.; xMax = tmpMean + tmpSigma*5.; RooRealVar x("x","x",xMin,xMax) ; double meanRangeMin; double meanRangeMax; if(tmpMean<0){ meanRangeMin = 1.6*tmpMean; meanRangeMax = 0.1*tmpMean; }else{ meanRangeMin = 0.1*tmpMean; meanRangeMax = 1.6*tmpMean; } RooRealVar meanRoo("mean","mean of gaussian",tmpMean,meanRangeMin,meanRangeMax) ; RooRealVar sigmaRoo("sigma","width of gaussian",tmpSigma,tmpSigma*0.5,tmpSigma*1.5); RooRealVar a("a","a",3.,2.,10.); RooRealVar aDx("aDx","aDx",3.,2.,10.); RooRealVar n("n","n",5.,0.,10.); RooRealVar nDx("nDx","nDx",5.,0.,10.); if(tailSign!=0){ if(tailSign<0){ a.setVal(1); a.setMin(0.5); a.setMax(3.); }else{ aDx.setVal(1); aDx.setMin(0.5); aDx.setMax(3.); } } RooDoubleCB func1("cb","cb PDF",x,meanRoo,sigmaRoo,a,n,aDx,nDx) ; RooPlot* xframe = x.frame(Title("Gaussian p.d.f.")) ; RooDataHist dh("dh","dh",x,Import(*proj)); func1.fitTo(dh); dh.plotOn(xframe); func1.plotOn(xframe) ; // xframe->Draw(); gPad->Update(); stringstream outputName2; if(i<10) outputName2 << name << "_bin" << "0" << i ; else outputName2 << name << "_bin" << i ; //printCanvas(canv,outputName2.str(),1); if(wait) Wait(); tmpMean = meanRoo.getVal(); tmpSigma = sigmaRoo.getVal(); double sigma; double sigmaErr; sigma= sigmaRoo.getVal(); sigmaErr = sigmaRoo.getError(); /* proj->SetAxisRange(-5*sigma,5*sigma); rms = proj->GetRMS(); double rmsErr = proj->GetRMSError(); hFit->SetBinContent(i,sigma); hFit->SetBinError(i,sigmaErr); hRMS->SetBinContent(i,rms); hRMS->SetBinError(i,rmsErr); delete proj; */ // ---- NEW IMPLEMENTATION double fullIntegral = proj->Integral(0,proj->GetNbinsX()+1); //double fullIntegral = proj->Integral(); //double fullAverage = proj->GetMean(); double step = proj->GetBinWidth(1);; int peakBin = proj->FindBin(tmpMean); //double range2nd(0.954); double range2nd(0.90); // bool found68(false); double range68(0), uncert68(0.); double range95(0), uncert95(0.); for(int j=0; j<proj->GetNbinsX()/2 ; j++){ if((peakBin-j)<1 || (peakBin+j) > proj->GetNbinsX()) break; double fraction = proj->Integral(peakBin-j,peakBin+j)/fullIntegral; if(fraction>0.682 && !found68){ //2sigma range found68=true; range68 = step*(2*j+1)*0.5; double averageBinContent = (proj->GetBinContent(peakBin-j) + proj->GetBinContent(peakBin+j))/2.0 ; uncert68 = sqrt(0.682*(1-0.682)/fullIntegral)/(averageBinContent/step/fullIntegral); } if(fraction>range2nd){ //3sigma range range95 = step*(2*j+1)*0.5; double averageBinContent = (proj->GetBinContent(peakBin-j) + proj->GetBinContent(peakBin+j))/2.0 ; uncert95 = sqrt(range2nd*(1-range2nd)/fullIntegral)/(averageBinContent/step/fullIntegral); break; } } // --- OLD IMPLEMENTATION /* double fullIntegral = proj->Integral(); double step = sigma/20.; // double range68(0); for(int j=2; j<20000;j++){ xMin = tmpMean - step*j; xMax = tmpMean + step*j; proj->SetAxisRange(xMin,xMax); double fraction = proj->Integral()/fullIntegral; if(fraction>0.682){ //2sigma range range68 = step*j; break; } } // double range95(0); for(int j=2; j<20000;j++){ xMin = tmpMean - step*j; xMax = tmpMean + step*j; proj->SetAxisRange(xMin,xMax); double fraction = proj->Integral()/fullIntegral; if(fraction>range2nd){ //2sigma range range95 = step*j; break; } } uncert68 = step; uncert95 = step; */ //-------- //hFit->SetBinContent(i,sigma); //hFit->SetBinError(i,sigmaErr); hFit->SetBinContent(i,range68); hFit->SetBinError(i,uncert68); hRMS->SetBinContent(i,range95); hRMS->SetBinError(i,uncert95); delete proj; } hFit->SetDirectory(gROOT); hRMS->SetDirectory(gROOT); delete canv; //hFit->Draw();gPad->Update(); Wait(); }
TH1D * GetTOFRatio(TFile *file, Int_t num, Int_t den, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin_[9] = { 0.5, 0.5, 0.5, 0.45, 0.45, 0.45, 0.5, 0.5, 0.5 }; Double_t ptMax_[9] = { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.5, 4.5, 4.5 }; Double_t ptMin = TMath::Max(ptMin_[num], ptMin_[den]); Double_t ptMax = TMath::Min(ptMax_[num], ptMax_[den]); TH1D *hin = (TH1D *)file->Get(Form("hRatio_cent%d_%s_%s", cent, ratioName[num], ratioName[den])); if (!hin) return NULL; #if 0 /* get matching systematics */ TFile *fsys = TFile::Open(Form("MATCHSYS_TOF_%s.root", TOFChargeName[charge])); TH1 *hsys = fsys->Get(Form("hErr%sMatch", ITSsaPartName[part])); TF1 *ffsys = new TF1("fsys", "[0] + [1] * x + [2] * TMath::Exp(-[3] * x)"); ffsys->SetParameter(0, 0.02); ffsys->FixParameter(1, 0.); ffsys->SetParameter(2, 0.5); ffsys->SetParameter(3, 10.); hsys->Fit(ffsys, "W"); ffsys->ReleaseParameter(1); hsys->Fit(ffsys, "W"); hsys->Fit(ffsys, "W"); hsys->Fit(ffsys, "W"); hsys->Draw(); #endif TH1D *h = new TH1D(Form("hTOF_cent%d_%s_%s", cent, ratioName[num], ratioName[den]), "TOF", NptBins, ptBin); Double_t pt, width, value, error, sys; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin || pt > ptMax)) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); /*** TEMP ADD SYS ***/ // sys = ffsys->Eval(pt) * value; // error = TMath::Sqrt(error * error + sys * sys); // h->SetBinContent(ipt + 1, value); // h->SetBinError(ipt + 1, error); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(23); h->SetMarkerColor(4); h->SetFillStyle(0); h->SetFillColor(0); return h; }
TH1D * GetTPCTOFRatio(TFile *file, Int_t num, Int_t den, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin_[9] = { 0.0, 0.0, 0.0, 0., 0., 0., 0.5, 0.5, 0.5 }; Double_t ptMax_[9] = { 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.8, 1.8, 1.8 }; Double_t ptMin = TMath::Max(ptMin_[num], ptMin_[den]); Double_t ptMax = TMath::Min(ptMax_[num], ptMax_[den]); Int_t part = 0, charge = 0; if (num == kPiMinus && den == kPiPlus) { part = AliPID::kPion; charge = 1; } else if (num == kKaMinus && den == kKaPlus) { part = AliPID::kKaon; charge = 1; } else if (num == kPrMinus && den == kPrPlus) { part = AliPID::kProton; charge = 1; } else if (num == kKaMinus && den == kPiMinus) { part = AliPID::kKaon; charge = 1; } else if (num == kKaPlus && den == kPiPlus) { part = AliPID::kKaon; charge = 0; } else if (num == kPrMinus && den == kPiMinus) { part = AliPID::kProton; charge = 1; } else if (num == kPrPlus && den == kPiPlus) { part = AliPID::kProton; charge = 0; } TH1D *hin = (TH1D *)file->Get(Form("%sFinal%s%d", TPCTOFPartName[part], TPCTOFChargeName[charge], cent)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hTPCTOF_cent%d_%s_%s", cent, ratioName[num], ratioName[den]), "TPCTOF", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin || pt > ptMax)) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TPCTOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(22); h->SetMarkerColor(8); h->SetFillStyle(0); h->SetFillColor(0); return h; }
void validationPlots() { bool isMB = 0; int doCentCut = 0; int doEtaCut = 0; int doPtCut = 1; const char * ptCut = "trkPt>30 && trkPt<300"; int doFake = 0; int doVtx = 1; int nEvt = 40000; bool doFineMVABins = 0; TH1::SetDefaultSumw2(); TLatex * lat = new TLatex(0.5,0.5,"test"); TFile * fMC; TFile * fDa; if(isMB) fMC = TFile::Open("/mnt/hadoop/cms/store/user/dgulhan/hiForest_HydjetMB_2076GeV_FOREST_753p1_merged/HydjetMB_2076GeV_FOREST_753p1_v0_merged.root","read"); if(isMB) fDa = TFile::Open("/mnt/hadoop/cms/store/user/dgulhan/hiForest_HIMinBiasUPC_HIRun2011-v1_7_5_3_patch1/HiForest_HIMinBiasUPC_HIRun2011-v1_merged.root","read"); if(!isMB) fMC = TFile::Open("/mnt/hadoop/cms/store/user/dgulhan/mergedForest/HiForest_HydjetMB_Pyquen_DiJet_pt80to9999_2670GeV_cfi_753_patch1/HiForest_HydjetMB_Pyquen_DiJet_pt80to9999_2670GeV_cfi_753_patch1_run1_mc_v2.root","read"); if(!isMB) fDa = TFile::Open("/mnt/hadoop/cms/store/user/dgulhan/HiForest_HIHighPt_HIRun2011-v1_RECO_753_patch1_Jet80_merged/HiForest_HIHighPt_jet80_HIRun2011-v1_merged.root","read"); TTree * tree[2]; tree[0] = (TTree*)fMC->Get("anaTrack/trackTree"); tree[1] = (TTree*)fDa->Get("anaTrack/trackTree"); TTree * hiBinTree[2]; hiBinTree[0] = (TTree*)fMC->Get("hiEvtAnalyzer/HiTree"); hiBinTree[1] = (TTree*)fDa->Get("hiEvtAnalyzer/HiTree"); TH1D * daVtx = new TH1D("daVtx",";z",30,-15,15); TH1D * mcVtx = new TH1D("mcVtx",";z",30,-15,15); tree[1]->Draw("zVtx[0]>>daVtx","","",100000); tree[0]->Draw("zVtx[0]>>mcVtx","","",100000); daVtx->Scale(1.0/daVtx->Integral(1,30)); mcVtx->Scale(1.0/mcVtx->Integral(1,30)); mcVtx->Divide(daVtx); TH1D * daHiBin = new TH1D("daHiBin",";hiBin",100,0,200); TH1D * mcHiBin = new TH1D("mcHiBin",";hiBin",100,0,200); hiBinTree[1]->Draw("hiBin>>daHiBin",""); hiBinTree[0]->Draw("hiBin>>mcHiBin",""); daHiBin->Scale(1.0/daHiBin->Integral(1,100)); mcHiBin->Scale(1.0/mcHiBin->Integral(1,100)); mcHiBin->Divide(daHiBin); std::cout << "here" << std::endl; int hiBin = 0; float hiBinw = 0; float vz[200] = {0}; float weight = 0; tree[1]->SetBranchAddress("zVtx",&vz); hiBinTree[1]->SetBranchAddress("hiBin",&hiBin); TFile * f = TFile::Open("vertexWeight.root","recreate"); TTree * w = new TTree("w","w"); w->Branch("vtxw",&weight); w->Branch("hiBinw",&hiBinw); for(int i=0; i<nEvt; i++) { if(i%1000==0) std::cout << i << std::endl; tree[1]->GetEntry(i); hiBinTree[1]->GetEntry(i); weight=mcVtx->GetBinContent(mcVtx->FindBin(vz[0])); hiBinw=mcHiBin->GetBinContent(mcHiBin->FindBin(hiBin)); w->Fill(); } w->Write(); tree[1]->AddFriend(w); tree[1]->AddFriend(hiBinTree[1]); tree[0]->AddFriend(w); tree[0]->AddFriend(hiBinTree[0]); std::cout << "done writing vtx tree" << std::endl; TH1D *chi2[6][2][2], *dxy[6][2][2], *dz[6][2][2], *nhit[6][2][2], *nlayer[6][2][2], *eta[6][2][2], *pterr[6][2][2], *mva[6][2][2], *mvaRat[6][2][1]; int algos[5] = {4,5,6,7,11}; const char *algName[5] = {" (Initial)"," (low pt triplet)"," (pixel pair)"," (detached)"," (jet-core)"}; int nTracks[6][2][2]; for(int algo = 0; algo<6; algo++) { for(int purity = 0; purity <2; purity++) { for(int sample = 0; sample<2; sample++) { chi2[algo][purity][sample] = new TH1D(Form("chi2%d%d%d",algo,purity,sample),";chi2/ndof/nlayer;dN/dchi2",100,0,1); chi2[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkChi2/(1.0*trkNlayer*trkNdof)>>chi2%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d)) && ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); chi2[algo][purity][sample]->Scale(1.0/chi2[algo][purity][sample]->Integral(1,100)); chi2[algo][purity][sample]->GetYaxis()->SetRangeUser(0,0.2); std::cout << algo << std::endl; dxy[algo][purity][sample] = new TH1D(Form("dxy%d%d%d",algo,purity,sample),";dxy/dxyerr;dN/(dxy/dxyerr)",100,-100,100); dxy[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkDxy1/(1.0*trkDxyError1)>>dxy%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); dxy[algo][purity][sample]->Scale(1.0/dxy[algo][purity][sample]->Integral(1,100)); dxy[algo][purity][sample]->GetYaxis()->SetRangeUser(10e-7,1); dz[algo][purity][sample] = new TH1D(Form("dz%d%d%d",algo,purity,sample),";dz/dzerr;dN/(dz/dzerr)",100,-100,100); dz[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkDz1/(1.0*trkDzError1)>>dz%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); dz[algo][purity][sample]->Scale(1.0/dz[algo][purity][sample]->Integral(1,100)); dz[algo][purity][sample]->GetYaxis()->SetRangeUser(10e-7,1); nhit[algo][purity][sample] = new TH1D(Form("nhit%d%d%d",algo,purity,sample),";nhit;dN/nhit",28,3,30); nhit[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkNHit>>nhit%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); nhit[algo][purity][sample]->Scale(1.0/nhit[algo][purity][sample]->Integral(1,28)); nhit[algo][purity][sample]->GetYaxis()->SetRangeUser(0,0.25); nlayer[algo][purity][sample] = new TH1D(Form("nlayer%d%d%d",algo,purity,sample),";nlayer;dN/nlayer",22,4,25); nlayer[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkNlayer>>nlayer%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); nlayer[algo][purity][sample]->Scale(1.0/nlayer[algo][purity][sample]->Integral(1,22)); nlayer[algo][purity][sample]->GetYaxis()->SetRangeUser(0.0,0.3); eta[algo][purity][sample] = new TH1D(Form("eta%d%d%d",algo,purity,sample),";eta;dN/eta",50,-2.4,2.4); eta[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkEta>>eta%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); eta[algo][purity][sample]->Scale(1.0/eta[algo][purity][sample]->Integral(1,50)); eta[algo][purity][sample]->GetYaxis()->SetRangeUser(0.0,0.03); pterr[algo][purity][sample] = new TH1D(Form("pterr%d%d%d",algo,purity,sample),";pterr;dN/(pt/pterr)",50,0,0.05); pterr[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkPtError/trkPt>>pterr%d%d%d",algo,purity,sample),Form("(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); pterr[algo][purity][sample]->Scale(1.0/pterr[algo][purity][sample]->Integral(1,50)); pterr[algo][purity][sample]->GetYaxis()->SetRangeUser(0.0,0.15); std::cout << algo << std::endl; mva[algo][purity][sample] = new TH1D(Form("mva%d%d%d",algo,purity,sample),";mva;dN/d(mva)",doFineMVABins?100:30,-1,1); mva[algo][purity][sample]->SetMarkerSize(0.8); tree[sample]->Draw(Form("trkMVA>>mva%d%d%d",algo,purity,sample),Form("(1+0.2*(!(%d) && %d && trkFake))*(1+(vtxw-1)*(%d&&%d))*(1+(hiBinw-1)*(%d))*(((highPurity== 1)||(highPurity==%d)) && (trkEta>-2.4 && trkEta<2.4) && (%d==5 || %d==trkAlgo) && ((%s) || (!%d))&& ((trkEta>0.8 || trkEta<-0.8) || (!%d))&& ((hiBin>=100 && hiBin<200) || (!%d)))",sample,doFake,sample,doVtx,sample,purity,algo,algos[algo],ptCut,doPtCut,doEtaCut,doCentCut),"",nEvt); nTracks[algo][purity][sample]=mva[algo][purity][sample]->Integral(1,doFineMVABins?100:30); mva[algo][purity][sample]->Scale(1.0/mva[algo][purity][sample]->Integral(1,doFineMVABins?100:30)); mva[algo][purity][sample]->GetYaxis()->SetRangeUser(0.0,0.4); std::cout << algo << std::endl; if(sample==1) { mvaRat[algo][purity][0] = (TH1D*)mva[algo][purity][1]->Clone(Form("mvaRat%d%d0",algo,purity)); mvaRat[algo][purity][0]->GetYaxis()->SetTitle("data/MC"); mvaRat[algo][purity][0]->Divide(mva[algo][purity][0]); mvaRat[algo][purity][0]->GetYaxis()->SetRangeUser(0,2); std::cout << algo << std::endl; } } } } TCanvas * c1[2]; TLegend * l1[2]; for(int j = 0; j<2; j++) { c1[j] = new TCanvas(Form("c1_%d",j),Form("c1_%d",j),1800,1000); c1[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c1[j]->cd(i+1); chi2[i][j][0]->Draw("p"); chi2[i][j][1]->SetMarkerColor(kRed+1); chi2[i][j][1]->SetLineColor(kRed+1); chi2[i][j][1]->Draw("p same"); if(i==0) { l1[j] = new TLegend(0.6,0.5,0.9,0.9); l1[j]->AddEntry(chi2[0][j][0],"Monte Carlo"); l1[j]->AddEntry(chi2[0][j][1],"Data"); if(j==1) l1[j]->AddEntry((TObject*)0,"HighPurity",""); l1[j]->Draw("same"); } if(i<5) lat->DrawLatex(0.5,0.04,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(0.5,0.04,"All Algos"); } c1[j]->SaveAs(Form("validationPlots/chi2_%d.png",j)); } TCanvas * c2[2]; TLegend * l2[2]; for(int j = 0; j<2; j++) { c2[j] = new TCanvas(Form("c2_%d",j),Form("c2_%d",j),1800,1000); c2[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c2[j]->cd(i+1); c2[j]->cd(i+1)->SetLogy(); dxy[i][j][0]->Draw("p"); dxy[i][j][1]->SetMarkerColor(kRed+1); dxy[i][j][1]->SetLineColor(kRed+1); dxy[i][j][1]->Draw("p same"); if(i==0) { l2[j] = new TLegend(0.6,0.5,0.9,0.9); l2[j]->AddEntry(dxy[0][j][0],"Monte Carlo"); l2[j]->AddEntry(dxy[0][j][1],"Data"); if(j==1) l2[j]->AddEntry((TObject*)0,"HighPurity",""); l2[j]->Draw("same"); } if(i<5) lat->DrawLatex(-80,0.1,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(-80,0.1,"All Algos"); } c2[j]->SaveAs(Form("validationPlots/dxy_%d.png",j)); } TCanvas * c3[2]; TLegend * l3[2]; for(int j = 0; j<2; j++) { c3[j] = new TCanvas(Form("c3_%d",j),Form("c3_%d",j),1800,1000); c3[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c3[j]->cd(i+1); c3[j]->cd(i+1)->SetLogy(); dz[i][j][0]->Draw("p"); dz[i][j][1]->SetMarkerColor(kRed+1); dz[i][j][1]->SetLineColor(kRed+1); dz[i][j][1]->Draw("p same"); if(i==0) { l3[j] = new TLegend(0.6,0.5,0.9,0.9); l3[j]->AddEntry(dz[0][j][0],"Monte Carlo"); l3[j]->AddEntry(dz[0][j][1],"Data"); if(j==1) l3[j]->AddEntry((TObject*)0,"HighPurity",""); l3[j]->Draw("same"); } if(i<5) lat->DrawLatex(-80,0.1,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(-80,0.1,"All Algos"); } c3[j]->SaveAs(Form("validationPlots/dz_%d.png",j)); } TCanvas * c4[2]; TLegend * l4[2]; for(int j = 0; j<2; j++) { c4[j] = new TCanvas(Form("c4_%d",j),Form("c4_%d",j),1800,1000); c4[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c4[j]->cd(i+1); nhit[i][j][0]->Draw("p"); nhit[i][j][1]->SetMarkerColor(kRed+1); nhit[i][j][1]->SetLineColor(kRed+1); nhit[i][j][1]->Draw("p same"); if(i==0) { l4[j] = new TLegend(0.6,0.5,0.9,0.9); l4[j]->AddEntry(nhit[0][j][0],"Monte Carlo"); l4[j]->AddEntry(nhit[0][j][1],"Data"); if(j==1) l4[j]->AddEntry((TObject*)0,"HighPurity",""); l4[j]->Draw("same"); } if(i<5) lat->DrawLatex(5,0.15,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(5,0.15,"All Algos"); } c4[j]->SaveAs(Form("validationPlots/nhit_%d.png",j)); } TCanvas * c5[2]; TLegend * l5[2]; for(int j = 0; j<2; j++) { c5[j] = new TCanvas(Form("c5_%d",j),Form("c5_%d",j),1800,1000); c5[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c5[j]->cd(i+1); nlayer[i][j][0]->Draw("p"); nlayer[i][j][1]->SetMarkerColor(kRed+1); nlayer[i][j][1]->SetLineColor(kRed+1); nlayer[i][j][1]->Draw("p same"); if(i==0) { l5[j] = new TLegend(0.6,0.5,0.9,0.9); l5[j]->AddEntry(nlayer[0][j][0],"Monte Carlo"); l5[j]->AddEntry(nlayer[0][j][1],"Data"); if(j==1) l5[j]->AddEntry((TObject*)0,"HighPurity",""); l5[j]->Draw("same"); } if(i<5) lat->DrawLatex(5,0.2,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(5,0.2,"All Algos"); } c5[j]->SaveAs(Form("validationPlots/nlayer_%d.png",j)); } TCanvas * c6[2]; TLegend * l6[2]; for(int j = 0; j<2; j++) { c6[j] = new TCanvas(Form("c6_%d",j),Form("c6_%d",j),1800,1000); c6[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c6[j]->cd(i+1); eta[i][j][0]->Draw("p"); eta[i][j][1]->SetMarkerColor(kRed+1); eta[i][j][1]->SetLineColor(kRed+1); eta[i][j][1]->Draw("p same"); if(i==0) { l6[j] = new TLegend(0.5,0.2,0.9,0.5); l6[j]->AddEntry(eta[0][j][0],"Monte Carlo"); l6[j]->AddEntry(eta[0][j][1],"Data"); if(j==1) l6[j]->AddEntry((TObject*)0,"HighPurity",""); l6[j]->Draw("same"); } if(i<5) lat->DrawLatex(-1.5,0.005,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(-1.5,0.005,"All Algos"); } c6[j]->SaveAs(Form("validationPlots/eta_%d.png",j)); } TCanvas * c7[2]; TLegend * l7[2]; for(int j = 0; j<2; j++) { c7[j] = new TCanvas(Form("c7_%d",j),Form("c7_%d",j),1800,1000); c7[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c7[j]->cd(i+1); pterr[i][j][0]->Draw("p"); pterr[i][j][1]->SetMarkerColor(kRed+1); pterr[i][j][1]->SetLineColor(kRed+1); pterr[i][j][1]->Draw("p same"); if(i==0) { l7[j] = new TLegend(0.6,0.5,0.9,0.9); l7[j]->AddEntry(pterr[0][j][0],"Monte Carlo"); l7[j]->AddEntry(pterr[0][j][1],"Data"); if(j==1) l7[j]->AddEntry((TObject*)0,"HighPurity",""); l7[j]->Draw("same"); } if(i<5) lat->DrawLatex(0.03,0.04,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(0.03,0.04,"All Algos"); } c7[j]->SaveAs(Form("validationPlots/pterr_%d.png",j)); } TCanvas * c8[2]; TLegend * l8[2]; for(int j = 0; j<2; j++) { c8[j] = new TCanvas(Form("c8_%d",j),Form("c8_%d",j),1800,1000); c8[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4 && isMB) continue; c8[j]->cd(i+1); mva[i][j][0]->Draw("p"); mva[i][j][1]->SetMarkerColor(kRed+1); mva[i][j][1]->SetLineColor(kRed+1); mva[i][j][1]->Draw("p same"); if(i==0) { l8[j] = new TLegend(0.6,0.5,0.9,0.9); l8[j]->AddEntry(mva[0][j][0],"Monte Carlo"); l8[j]->AddEntry(mva[0][j][1],"Data"); if(j==1) l8[j]->AddEntry((TObject*)0,"HighPurity",""); l8[j]->Draw("same"); } if(i<5) lat->DrawLatex(0.03,0.04,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(0.03,0.04,"All Algos"); } c8[j]->SaveAs(Form("validationPlots/mva_%d.png",j)); } TCanvas * c9[2]; TLegend * l9[2]; for(int j = 0; j<2; j++) { c9[j] = new TCanvas(Form("c9_%d",j),Form("c9_%d",j),1800,1000); c9[j]->Divide(3,2); for(int i = 0; i<6; i++) { if(i==4) continue;// && isMB) continue; c9[j]->cd(i+1); mvaRat[i][j][0]->Draw("p"); // mvaRat[i][j][1]->SetMarkerColor(kRed+1); // mvaRat[i][j][1]->SetLineColor(kRed+1); // mvaRat[i][j][1]->Draw("p same"); if(i==0) { l9[j] = new TLegend(0.6,0.5,0.9,0.9); // l9[j]->AddEntry(mvaRat[0][j][0],"Monte Carlo"); // l9[j]->AddEntry(mvaRat[0][j][1],"Data"); if(j==1) l9[j]->AddEntry((TObject*)0,"HighPurity",""); l9[j]->Draw("same"); } if(i<5) lat->DrawLatex(0.03,0.4,Form("Algo %d%s",algos[i],algName[i])); if(i==5) lat->DrawLatex(0.03,0.4,"All Algos"); } c9[j]->SaveAs(Form("validationPlots/mvaRat_%d.png",j)); } //change in signal by reweighting MVAs for(int i = 0; i<6; i++) { if(i==4) continue; float cut[6] = {-0.77,0.35,0.77,-0.09,0,0}; float dSig = mva[i][0][1]->Integral(mva[i][0][1]->FindBin(cut[i]),mva[i][0][1]->FindBin(1)); mva[i][0][1]->Divide(mvaRat[i][0][0]); float dSig2 = (float)mva[i][0][1]->Integral(mva[i][0][1]->FindBin(cut[i]),mva[i][0][1]->FindBin(1))/mva[i][0][1]->Integral(mva[i][0][1]->FindBin(-1),mva[i][0][1]->FindBin(1)); std::cout << "\n\nAlgo " << algos[i] << "\nSignal Purity before MVA weight: " << dSig << " Signal Purity after MVA weight: " << dSig2 << " Difference (as %): " << dSig-dSig2 << " (" << (dSig-dSig2)*100/dSig<<")" << std::endl; std::cout << "Fraction of tracks w/o highPurity (data): " << (float)nTracks[i][0][1]/nTracks[5][0][1] << std::endl; std::cout << "Fraction of tracks w/o highPurity (MC): " << (float)nTracks[i][0][0]/nTracks[5][0][0] << std::endl; std::cout << "\nFraction of tracks w/ highPurity (data): " << (float)nTracks[i][1][1]/nTracks[5][1][1] << std::endl; std::cout << "Fraction of tracks w/ highPurity (MC): " << (float)nTracks[i][1][0]/nTracks[5][1][0] << std::endl; } }
void hfCentrality(char* fname = "r151878.root", char* trg="anaPixelHitJet50U") { TFile *f1=new TFile(Form("/d101/kimy/macro/pixelTrees/rootFiles/%s",fname),"r"); TTree *trPixMB = (TTree*)f1->Get("anaPixelHitMB/PixelTree"); TTree *trPixJet = (TTree*)f1->Get("anaPixelHitJet50U/PixelTree"); // const int nscEtBin = 10; // double scetBin[nscEtBin+1] = { 15.1,18,21,24,28,32,36,40,48,55,70}; TH1D* hhfMB = new TH1D(Form("hhfMB",trg),";Sum HF Energy (TeV);Fraction of minimum bias events",70,0,160); TH1D* hhfMB1 = (TH1D*)hhfMB->Clone("hhfMB1"); TH1D* hhfMB2 = (TH1D*)hhfMB->Clone("hhfMB2"); TH1D* hhfMB3 = (TH1D*)hhfMB->Clone("hhfMB3"); TH1D* hhfJET = (TH1D*)hhfMB->Clone("hhfJET"); TCanvas* c1 = new TCanvas(Form("c1_%s",trg),"",400,400); trPixMB->Draw("hf/1000.>>hhfMB"); trPixMB->Draw("hf/1000.>>hhfMB1","cBin<=4"); trPixMB->Draw("hf/1000.>>hhfMB2","cBin>=4 && cBin<=12"); trPixMB->Draw("hf/1000.>>hhfMB3","cBin>=12 && cBin<=35"); trPixJet->Draw("hf/1000.>>hhfJET"); handsomeTH1(hhfMB1,1); handsomeTH1(hhfMB2,2); handsomeTH1(hhfMB3,4); hhfMB1->SetFillColor(1); hhfMB2->SetFillColor(2); hhfMB3->SetFillColor(4); hhfMB->Scale(1./hhfMB->GetEntries()); hhfMB->SetAxisRange(1e-5,1,"Y"); hhfJET->Scale(1./hhfJET->GetEntries()); hhfJET->SetAxisRange(1e-5,1,"Y"); hhfMB->SetLineWidth(2); handsomeTH1(hhfMB); hhfMB->DrawCopy(); // TLine* t1 = new TLine(.511,1e-5,.511,hhfMB->GetBinContent(hhfMB->FindBin(0.511))); TLine* t1 = new TLine(0,1e-5,.511,hhfMB->GetBinContent(hhfMB->FindBin(0.511))); TLine* t2 = new TLine(35.397,1e-5,35.397,hhfMB->GetBinContent(hhfMB->FindBin(35.397))); TLine* t3 = new TLine(79.370,1e-5,79.370,hhfMB->GetBinContent(hhfMB->FindBin(79.370))); t1->SetLineWidth(1); t2->SetLineWidth(1); t3->SetLineWidth(1); t1->SetLineStyle(7); t2->SetLineStyle(7); t3->SetLineStyle(7); t1->Draw(); t2->Draw(); t3->Draw(); // hhfMB3->DrawCopy(); // hhfMB2->DrawCopy("same"); // hhfMB1->DrawCopy("same"); gPad->SetLogy(); TLegend* leg0 = new TLegend(0.2813131,0.7115054,0.9,0.8439785,NULL,"brNDC"); TLegend* leg0b =new TLegend(0.3813131,0.7115054,1,0.8439785,NULL,"brNDC"); TLegend* leg1 = new TLegend(0.1767677,0.3826344,0.4467677,0.5875591,NULL,"brNDC"); TLegend* leg2 = new TLegend(0.3611111,0.3876344,0.6111111,0.5865591,NULL,"brNDC"); TLegend* leg3 = new TLegend(0.5606061,0.3876344,0.8106061,0.5865591,NULL,"brNDC"); easyLeg(leg0b,"Centrality, HLT_HIJet50U"); easyLeg(leg1,"30%-100%"); easyLeg(leg2,"10%-30% "); easyLeg(leg3," 0%-10% "); // TCanvas* c2 = new TCanvas(Form("c2_%s",trg),"",400,400); float triggerRatio = 0.29 / 49.; hhfJET->SetLineWidth(2); hhfJET->SetLineColor(2); hhfJET->SetFillColor(2); hhfJET->SetFillStyle(3544); hhfJET->Scale(triggerRatio); hhfJET->DrawCopy("same"); easyLeg(leg0,"Centrality"); leg0->AddEntry(hhfMB,"HLT_MinBiasHForBSC_Core","l"); leg0->AddEntry(hhfJET,"HLT_HiJet50U","l"); leg0->Draw(); // leg1->Draw(); // leg2->Draw(); // leg3->Draw(); TLatex *bint = new TLatex(0.1867677,0.4876344,"30%-100%"); bint->SetTextFont(63); bint->SetTextSize(13); bint->SetNDC(); bint->Draw(); bint = new TLatex(0.4011111,0.4876344,"10%-30% "); bint->SetTextFont(63); bint->SetTextSize(13); bint->SetNDC(); bint->Draw(); bint = new TLatex(0.6006061,0.4876344," 0%-10% "); bint->SetTextFont(63); bint->SetTextSize(13); bint->SetNDC(); bint->Draw(); TLatex *cms = new TLatex(0.6013,0.89,"CMS Preliminary"); cms->SetTextFont(63); cms->SetTextSize(16); cms->SetNDC(); cms->Draw(); c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.eps"); c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.gif"); c1->SaveAs("hf_centrality_distribution_mb_jet50_20101126_v1.C"); // TCanvas* c2 = new TCanvas(Form("c2_%s",trg),"",400,400); // hhfJET->Divide(hhfMB); // hhfJET->Draw(); // c2->SaveAs("ratio.gif"); // TLine* t1j = new TLine(.511,1e-5,.511,hhfJET->GetBinContent(hhfJET->FindBin(0.511))); // TLine* t2j = new TLine(35.397,1e-5,35.397,hhfJET->GetBinContent(hhfJET->FindBin(35.397))); // TLine* t3j = new TLine(79.370,1e-5,79.370,hhfJET->GetBinContent(hhfJET->FindBin(79.370))); // t1j->SetLineWidth(2); // t2j->SetLineWidth(2); // t3j->SetLineWidth(2); // t1j->Draw(); // t2j->Draw(); // t3j->Draw(); // TLegend* leg0 = new TLegend(0.46,0.80, 0.99, 0.95,NULL,"brNDC"); // easyLeg(leg0,"offline cleaned Superlclusters"); // leg0->AddEntry(hetSc,"HLT_HIPhoton15"); // leg0->AddEntry(hetScClean,"HLT_HICleanPhoton15"); // leg0->Draw(); }
void Z0AccEff(int isData = 2, int yieldInt = 1, int iSpec = 3, int Weight =1) { //////// definitions of Switches /////////// // isData = 1 for Data // isData = 2 for Simulation // iSpec = 1 pT spectra // iSpec = 2 Y spectra // iSpec = 3 Centrality Spectra //Weight = 1 for weighted histo //weight = 0 for non weighted histo //////////////////////////////////////////////////////////// gStyle->SetOptStat(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0000); // Fit ranges float mass_low, mass_high, mlow, mhigh; int nrebin; bool isLog, isFit; double MassZ0, WidthZ0; // High Mass range MassZ0 = 91.1876; WidthZ0 = 2.4952; mass_low = 60; mass_high = 120; // Fit ranges Glb Glb //mass_low = 40; mass_high = 140; // Fit ranges STA mlow = 0.0; mhigh = 200.0; nrebin = 80; isLog =0; isFit = 0; // draw ranges int whis = 1; // 1 for full all eta, 2 for barrel //4 for trigger matched PAT //file one is good file TFile *fil1, *fil2; if (isData == 2) fil2 = new TFile("Z0_DataMixPt50_PatDiMuonPlots_All11Dec.root"); //if (isData == 2) fil2 = new TFile("ReReco_DM_DiMuonPlot_All16Dec.root"); if (isData == 2) fil1 = new TFile("Z0HydPt50_PatDiMuonPlots_AllWOSel12Dec.root"); // Pt bin sizes int Nptbin=1; double pt_bound[100] = {0}; if(iSpec == 1) { Nptbin = 3; pt_bound[0] = 0.0; pt_bound[1] = 6.0; pt_bound[2] = 12.0; pt_bound[3] = 100.0; if(isData == 2) { Nptbin = 25; // pt_bound[100] = {0.0,100.0,12.0,100.0}; pt_bound[0] = 0; pt_bound[1] = 2; pt_bound[2] = 4; pt_bound[3] = 6; pt_bound[4] = 8; pt_bound[5] = 10; pt_bound[6] = 12; pt_bound[7] = 14; pt_bound[8] = 16; pt_bound[9] = 18; pt_bound[10] = 20; pt_bound[11] = 22; pt_bound[12] = 24; pt_bound[13] = 26; pt_bound[14] = 28; pt_bound[15] = 30; pt_bound[16] = 32; pt_bound[17] = 34; pt_bound[18] = 36; pt_bound[19] = 38; pt_bound[20] = 40; pt_bound[21] = 42; pt_bound[22] = 44; pt_bound[23] = 46; pt_bound[24] = 48; pt_bound[25] = 50; } } // Y bin sizes if(iSpec == 2) { Nptbin = 10; // pt_bound[100] = {-2.4,-1.0,-0.5,0.5,1.0,2.4}; // pt_bound[100] = {-2.4,-1.0,-0.5,0.5,1.0,2.4}; // pt_bound[100] = {-2.4,-2.1,-1.6,-1.1,-0.6,0,0.6,1.1,1.6,2.1,2.4}; pt_bound[0] = -2.4; pt_bound[1] = -2.1; pt_bound[2] = -1.6; pt_bound[3] = -1.1; pt_bound[4] = -0.6; pt_bound[5] = 0.0; pt_bound[6] = 0.6; pt_bound[7] = 1.1; pt_bound[8] = 1.6; pt_bound[9] = 2.1; pt_bound[10] = 2.4; } if(iSpec == 3) { if(isData == 2) { Nptbin = 9; pt_bound[0] = 0.0; pt_bound[1] = 4.0; pt_bound[2] = 8.0; pt_bound[3] = 12.0; pt_bound[4] = 16.0; pt_bound[5] = 20.0; pt_bound[6] = 24.0; pt_bound[7] = 28.0; pt_bound[8] = 32.0; pt_bound[9] = 40.0; } } double PT[100], DelPT[100], mom_err[100]; for (Int_t ih = 0; ih < Nptbin; ih++) { PT[ih] = (pt_bound[ih] + pt_bound[ih+1])/2.0; DelPT[ih] = pt_bound[ih+1] - pt_bound[ih]; mom_err[ih] = DelPT[ih]/2.0; } float gen_pt[100], gen_ptError[100]; float gen_ptS[100], gen_ptErrorS[100]; if(isData==2){ TH2D *genMass_1, *genMassS_1; if (iSpec == 1 && Weight==1 ) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsPtW"); if (iSpec == 2 && Weight==1) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsYW"); if (iSpec == 3 && Weight==1) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsCenW"); if (iSpec == 1 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsPtW"); if (iSpec == 2 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsYW"); if (iSpec == 3 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsCenW"); if (iSpec == 1 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsPt"); if (iSpec == 2 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsY"); if (iSpec == 3 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsCen"); if (iSpec == 1 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsPt"); if (iSpec == 2 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsY"); if (iSpec == 3 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsCen"); TH1D *ptaxis = (TH1D*)genMass_1->ProjectionY("ptaxis"); for (Int_t ih = 0; ih < Nptbin; ih++) { cout<<pt_bound[ih]<<" "<<pt_bound[ih+1]<<endl; int pt_bin1 = ptaxis->FindBin(pt_bound[ih]+0.0000001); int pt_bin2 = ptaxis->FindBin(pt_bound[ih+1]+0.0000001); cout<< pt_bin1<<" "<< pt_bin2<<endl; TH1D * genMassVsPt = (TH1D*)genMass_1->ProjectionX("genMassVsPt", pt_bin1, pt_bin2-1); TH1D * genMassVsPtS = (TH1D*)genMassS_1->ProjectionX("genMassVsPtS", pt_bin1, pt_bin2-1); //does not work with weight //gen_pt[ih] = genMassVsPt->GetEntries(); double genError,genErrorS; gen_pt[ih] = genMassVsPt->IntegralAndError(1,8000,genError); gen_ptError[ih]= genError; gen_ptS[ih] = genMassVsPtS->IntegralAndError(1,8000,genErrorS); gen_ptErrorS[ih]= genErrorS; cout<<" gen entries : "<< gen_pt[ih]<<endl; cout<<"genErro "<<genError<<" "<< gen_ptError[ih]<<endl<<endl; } } // Efficiency float Eff_cat_1[100]; float Eff_catS_1[100]; float errEff_cat_1[100]; float errEff_catS_1[100]; float errEff_cat_S1[100], errEff_cat_S2[100]; float errEff_catS_S1[100], errEff_catS_S2[100]; char *Xname[100] = {" ", "p_{T}^{Dimuon} (GeV/c)", "rapidity", "centrality"}; double yld_cat_1[100]; double yld_catS_1[100]; double cyld_cat_1[100]; double cyld_catS_1[100]; double eyld_cat_1[100]; double eyld_catS_1[100]; double ceyld_cat_1[100], ceyld_catS_1[100]; char namePt_1[500]; char namePt_1S[500]; //char namePt_1B[500]; char text[100]; ///// Write the spectra char fspectra[500]; sprintf(fspectra,"fileSpecta%d.root", yieldInt); TFile *fileSpectra = new TFile(fspectra, "recreate"); /////////////////////////////////////////////////////////////////////// // Category _1 TLegend *lcat_1; lcat_1 = new TLegend(.1, .82, .50, .93); lcat_1->SetName("lcat_1"); lcat_1->SetBorderSize(0); lcat_1->SetFillStyle(0); lcat_1->SetFillColor(0); lcat_1->SetTextSize(0.032); //lcat_1->AddEntry(RBWPOL," CMS Preliminary", " "); //lcat_1->AddEntry(RBWPOL," PbPb #sqrt{s_{NN}} = 2.76 TeV ", " "); TLegend *legend_1[100]; for(int i=0; i<100; i++) { if(isFit) legend_1[i] = new TLegend(.62, .52, .91, 0.93 ); if(!isFit) legend_1[i] = new TLegend(.62, .68, .91, 0.93 ); legend_1[i]->SetBorderSize(0); legend_1[i]->SetFillStyle(0); legend_1[i]->SetFillColor(0); legend_1[i]->SetTextSize(0.032); } //for no cut //if(whis == 1 && iSpec == 1 ) TH2D *Z0Mass_1 = (TH2D*)fil1->Get("dimu"); //if(whis == 2 && iSpec == 1) TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPtBRL"); //if(whis == 4 && iSpec == 1 ) { //TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsPATInvMassVsPt"); //TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsPATSTAInvMassVsPt"); //} TH2D *Z0Mass_1, *Z0Mass_1S; //with weight if(iSpec == 1 && Weight==1 ) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPtW"); if(iSpec == 2 && Weight==1) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsYW"); if(iSpec == 3 && Weight==1) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsCenW"); //without weight if(iSpec == 1 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPt"); if(iSpec == 2 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsY"); if(iSpec == 3 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsCen"); //with weight fil2 if(iSpec == 1 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsPtW"); if(iSpec == 2 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsYW"); if(iSpec == 3 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsCenW"); //without weight fil2 if(iSpec == 1 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsPt"); if(iSpec == 2 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsY"); if(iSpec == 3 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsCen"); TH1D *service = (TH1D*)Z0Mass_1->ProjectionY("service"); int pt_bin_bound[100]; TH1D *dimuonsGlobalInvMassVsPt[100], *dimuonsGlobalInvMassVsPtS[100]; TCanvas *CanvPt_1 = new TCanvas("CanvPt_1"," Z0 Yield Vs. Pt ", 40,40,1000,700); if (Nptbin == 2) CanvPt_1->Divide(2,1); if (Nptbin == 3 || Nptbin == 4) CanvPt_1->Divide(2,2); if (Nptbin == 5 || Nptbin == 6) CanvPt_1->Divide(3,2); if (Nptbin == 9 || Nptbin == 10) CanvPt_1->Divide(5,2); cout << endl << Xname[iSpec] << " Yield Mass (GeV) Width (GeV) GauWidth chi2/ndf " << endl << endl; //ih loop for (Int_t ih = 0; ih < Nptbin; ih++) { CanvPt_1->cd(ih+1); gPad->SetTickx(); gPad->SetTicky(); // Project 1 D pt_bin_bound[ih] = Z0Mass_1->GetYaxis()->FindBin(pt_bound[ih]+0.0000001); pt_bin_bound[ih+1] = Z0Mass_1->GetYaxis()->FindBin(pt_bound[ih+1]-0.0000001); sprintf(namePt_1,"Z0_1_pt_%d",ih); sprintf(namePt_1S,"Z0_1S_pt_%d",ih); //printf(namePt_1,"Z0_1_pt_%d",ih); //cout<<endl<<endl; //continue; dimuonsGlobalInvMassVsPt[ih] = (TH1D*)Z0Mass_1->ProjectionX(namePt_1, pt_bin_bound[ih], pt_bin_bound[ih+1]-1+1, "e"); dimuonsGlobalInvMassVsPtS[ih] = (TH1D*)Z0Mass_1S->ProjectionX(namePt_1S, pt_bin_bound[ih], pt_bin_bound[ih+1]-1+1,"e"); if(iSpec == 1 || iSpec == 2) {sprintf(text," %s [%.1f, %.1f]", Xname[iSpec], service->GetBinLowEdge(pt_bin_bound[ih]), service->GetBinLowEdge(pt_bin_bound[ih+1])+service->GetBinWidth(pt_bin_bound[ih+1]));} if(iSpec == 3) {sprintf(text," %s [%.1f, %.1f] %s", Xname[iSpec], 2.5*service->GetBinLowEdge(pt_bin_bound[ih]), 2.5*(service->GetBinLowEdge(pt_bin_bound[ih+1])+service->GetBinWidth(pt_bin_bound[ih+1])), "%");} dimuonsGlobalInvMassVsPt[ih]->Rebin(nrebin); dimuonsGlobalInvMassVsPtS[ih]->Rebin(nrebin); float m_low = 60.0; float m_high = 120.0; TAxis *axs = dimuonsGlobalInvMassVsPt[ih]->GetXaxis(); int binlow = axs->FindBin(m_low); int binhi = axs->FindBin(m_high); // Double_t bin_size = (1.0*dimuonsGlobalInvMassVsPt[ih]->GetNbinsX())/(axs->GetXmax() - axs->GetXmin()); // Float_t int_sig = 0.0; //for(Int_t bin = binlow; bin<=binhi;bin++) { //int_sig+ = dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin); //} double recerror,recerrorS; //double yld; double yld_1 = dimuonsGlobalInvMassVsPt[ih]->IntegralAndError(binlow, binhi, recerror); double yldS_1 = dimuonsGlobalInvMassVsPtS[ih]->IntegralAndError(binlow, binhi, recerrorS); eyld_cat_1[ih] =recerror; eyld_catS_1[ih] =recerrorS; cout<< "yld " << yld_1 <<" eyld_cat_1[ih] "<< eyld_cat_1[ih]<<" rec error "<<recerror<<endl; yld_cat_1[ih] = yld_1; yld_catS_1[ih] = yldS_1; if(isLog) gPad->SetLogy(1); TColor *pal = new TColor(); Int_t kblue = pal->GetColor(9,0,200); // Int_t korange = pal->GetColor(101, 42, 0); dimuonsGlobalInvMassVsPt[ih]->SetMarkerStyle(21); dimuonsGlobalInvMassVsPt[ih]->SetMarkerColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetLineColor(kblue); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetTitle("Dimuon mass (GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetYaxis()->SetTitle("Events/(2 GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetRangeUser(mlow,mhigh); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPL"); // fil2 dimuonsGlobalInvMassVsPtS[ih]->SetMarkerStyle(8); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetLineColor(46); //****** dimuonsGlobalInvMassVsPtS[ih]->DrawCopy("EPsame"); //RBWPOL->SetLineColor(kblue); //backfun_1->SetLineColor(46); //backfun_1->SetLineWidth(1); //if(isFit) backfun_1->Draw("same"); lcat_1->Draw("same"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih],"Global-Global", " "); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," |y| < 2.4 ", ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], text, ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Opposite Charge ", "LP"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPtS[ih]," Same Charge ", "LP"); char label_1[512]; // char label_2[512], label_3[512], label_4[512]; sprintf(label_1, "N=%1.2f #pm %1.2f ", yld_cat_1[ih], eyld_cat_1[ih]); // sprintf(label_1, "N_{Z^{0}} = 27"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], label_1, ""); }//ih loop cout << endl << endl; CanvPt_1->Print("Pt_Z0MassCat_1.png"); TGraphErrors *Z0pt_cat_1 = new TGraphErrors(Nptbin, PT, yld_cat_1, mom_err, eyld_cat_1); Z0pt_cat_1->SetMarkerStyle(20); Z0pt_cat_1->SetMarkerColor(2); Z0pt_cat_1->GetXaxis()->SetTitle(Xname[iSpec]); Z0pt_cat_1->GetYaxis()->SetTitle("counts"); new TCanvas; Z0pt_cat_1->SetMinimum(0.0); Z0pt_cat_1->SetName("Z0pt_cat_1"); Z0pt_cat_1->Draw("AP"); lcat_1->Draw("same"); gPad->Print("Pt_Z0YieldCat_1.png"); cout << endl << endl; Z0pt_cat_1->Write(); lcat_1->Write(); // Efficiency correction if(isData==2) { ofstream fileout("correction.txt"); cout << Xname[iSpec] << " Eff_cat_1 " << endl; for (Int_t ih = 0; ih < Nptbin; ih++) { //cout<<"gen_pt[ih]; "<<gen_pt[ih]<<endl; Eff_cat_1[ih] = yld_cat_1[ih]/gen_pt[ih]; Eff_catS_1[ih] = yld_catS_1[ih]/gen_ptS[ih]; //eyld_cat_1[ih]; //gen_ptError[ih]; //cout<<endl<<endl<<endl; //cout<<"Eff_cat_1[ih] "<<Eff_cat_1[ih]<<endl; //cout<<"yld_cat_1[ih] "<< yld_cat_1[ih] <<endl; //cout<<"eyld_cat_1[ih] "<<eyld_cat_1[ih] <<endl; //cout<<"gen_pt[ih] "<< gen_pt[ih] <<endl; //cout<<"gen_ptError[ih] "<< gen_ptError[ih]<<endl; //Error for first graph double errEff_cat_S1_1[100]={0},errEff_cat_S1_2[100]={0}; double errEff_cat_S2_1[100]={0},errEff_cat_S2_2[100]={0}; errEff_cat_S1_1[ih]= ( (Eff_cat_1[ih] * Eff_cat_1[ih]) /(gen_pt[ih] * gen_pt[ih]) ); errEff_cat_S1_2[ih]= (gen_ptError[ih] * gen_ptError[ih] ) - ( eyld_cat_1[ih] * eyld_cat_1[ih] ); errEff_cat_S1[ih]= (errEff_cat_S1_1[ih] * errEff_cat_S1_2[ih]); //cout<<" errEff_cat_S1_1[ih] "<< errEff_cat_S1_1[ih]<< " errEff_cat_S1_2[ih] "<<errEff_cat_S1_2[ih]<<endl; errEff_cat_S2_1[ih]= ( (1 - Eff_cat_1[ih])* (1 - Eff_cat_1[ih]) ) / ( gen_pt[ih] * gen_pt[ih]); errEff_cat_S2_2[ih]= (eyld_cat_1[ih] * eyld_cat_1[ih]); errEff_cat_S2[ih]=errEff_cat_S2_1[ih]*errEff_cat_S2_2[ih]; //cout<<" errEff_cat_S2_1[ih] "<< errEff_cat_S2_1[ih]<< " errEff_cat_S2_2[ih] "<<errEff_cat_S2_2[ih]<<endl; //cout<<"errEff_cat_S1[ih] "<<errEff_cat_S1[ih]<< " errEff_cat_S2[ih] "<< errEff_cat_S2[ih]<<endl; errEff_cat_1[ih]=sqrt(errEff_cat_S1[ih] + errEff_cat_S2[ih]); //Error for second graph double errEff_catS_S1_1[100]={0},errEff_catS_S1_2[100]={0}; double errEff_catS_S2_1[100]={0},errEff_catS_S2_2[100]={0}; errEff_catS_S1_1[ih]= ( (Eff_catS_1[ih] * Eff_catS_1[ih]) /(gen_ptS[ih] * gen_ptS[ih]) ); errEff_catS_S1_2[ih]= (gen_ptErrorS[ih] * gen_ptErrorS[ih] ) - (eyld_catS_1[ih] * eyld_catS_1[ih] ); errEff_catS_S1[ih]= (errEff_catS_S1_1[ih] * errEff_catS_S1_2[ih]); errEff_catS_S2_1[ih]= ( (1 - Eff_catS_1[ih])* (1 - Eff_catS_1[ih]) ) / ( gen_ptS[ih] * gen_ptS[ih]); errEff_catS_S2_2[ih]= (eyld_catS_1[ih] * eyld_catS_1[ih]); errEff_catS_S2[ih]= errEff_catS_S2_1[ih]*errEff_catS_S2_2[ih]; errEff_catS_1[ih]=sqrt(errEff_catS_S1[ih] + errEff_catS_S2[ih]); //Error for no weight //errEff_cat_1[ih] =((Eff_cat_1[ih]*(1- Eff_cat_1[ih]))/gen_pt[ih]); //Prashant error //errEff_cat_1[ih] = eyld_cat_1[ih]/gen_pt[ih]; fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << errEff_cat_1[ih] << endl; cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " +- " << errEff_cat_1[ih] << endl; cyld_cat_1[ih] = Eff_cat_1[ih]; ceyld_cat_1[ih] = errEff_cat_1[ih]; cyld_catS_1[ih] = Eff_catS_1[ih]; ceyld_catS_1[ih] = errEff_catS_1[ih]; } } TGraphErrors *Z0ptC_cat_1 = new TGraphErrors(Nptbin, PT, cyld_cat_1, mom_err, ceyld_cat_1); Z0ptC_cat_1->SetMarkerStyle(20); Z0ptC_cat_1->SetMarkerColor(2); Z0ptC_cat_1->GetXaxis()->SetTitle(Xname[iSpec]); Z0ptC_cat_1->GetYaxis()->SetTitle("Acc #times Eff"); Z0ptC_cat_1->GetYaxis()->SetRangeUser(0,1.0); TGraphErrors *Z0ptC_catS_1 = new TGraphErrors(Nptbin, PT, cyld_catS_1, mom_err, ceyld_catS_1); Z0ptC_catS_1->SetMarkerStyle(8); Z0ptC_catS_1->SetMarkerColor(1); Z0ptC_catS_1->GetYaxis()->SetRangeUser(0,0.8); TLegend *legend_GP = new TLegend( 0.59,0.79,0.88,0.89); legend_GP->SetBorderSize(0); legend_GP->SetFillStyle(0); legend_GP->SetFillColor(0); legend_GP->SetTextSize(0.032); //legend_GP->AddEntry(Z0ptC_catS_1,"Pythia Gun in MB HI Data ", ""); legend_GP->AddEntry(Z0ptC_catS_1,"Pythia Gun in MB Hydjet ", ""); new TCanvas; Z0ptC_cat_1->SetMinimum(0.0); Z0ptC_cat_1->Draw("AP"); //Z0ptC_catS_1->Draw("sameP"); lcat_1->Draw("same"); legend_GP->Draw("same"); cout << endl << endl; Z0ptC_cat_1->Write(); }
void createGlauberTree(Int_t nEvents, const char *outFileName) { AliPDG::AddParticlesToPdgDataBase(); TDatabasePDG::Instance(); // Run loader TFolder *folder = new TFolder("myfolder","myfolder"); AliRunLoader* rl = new AliRunLoader(folder); rl->MakeHeader(); rl->MakeStack(); AliStack* stack = rl->Stack(); //AliHeader* rheader = rl->GetHeader(); AliGenHijing *genHi = new AliGenHijing(-1); genHi->SetStack(stack); genHi->SetEnergyCMS(2760); genHi->SetReferenceFrame("CMS"); genHi->SetProjectile("A", 208, 82); genHi->SetTarget ("A", 208, 82); genHi->SetPtHardMin (2.3); genHi->SetImpactParameterRange(0.,30); genHi->SetJetQuenching(0); // enable jet quenching genHi->SetShadowing(1); // enable shadowing genHi->SetDecaysOff(1); // neutral pion and heavy particle decays switched off genHi->Init(); MyHeader *myheader = new MyHeader; MyResponse *myresp = new MyResponse; TFile *outFile = TFile::Open(outFileName, "RECREATE"); outFile->SetCompressionLevel(5); TDirectory::TContext context(outFile); TTree *tree = new TTree("glaubertree", "Glauber tree"); tree->Branch("header",&myheader, 32*1024, 99); tree->Branch("response",&myresp, 32*1024, 99); TNtuple *ntuple = new TNtuple("gnt", "Glauber ntuple", "npart:ncoll:b"); Double_t etas[] = {-10,-5,-4,-3,-2,-1,0,1,2,3,4,5,10}; TH1D *hNEta = new TH1D("hNeta","",12,etas); TH1D *hEtEta = new TH1D("hEteta","",12,etas); // create events and fill them for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) { cout << "Event " << iEvent+1 << "/" << nEvents << endl;; stack->Reset(); hNEta->Reset(); hEtEta->Reset(); genHi->Generate(); AliStack *s = genHi->GetStack(); const TObjArray *parts = s->Particles(); Int_t nents = parts->GetEntries(); for (Int_t i = 0; i<nents; ++i) { TParticle *p = (TParticle*)parts->At(i); //p->Print(); TParticlePDG *pdg = p->GetPDG(1); Int_t c = (Int_t)(TMath::Abs(pdg->Charge())); if (c!=0) { hNEta->Fill(p->Eta()); hEtEta->Fill(p->Eta(),p->Pt()); } } AliGenHijingEventHeader *h = (AliGenHijingEventHeader*)genHi->CollisionGeometry(); myheader->fNATT = nents; myheader->fEATT = h->TotalEnergy(); myheader->fJATT = h->HardScatters(); myheader->fNT = h->TargetParticipants(); myheader->fNP = h->ProjectileParticipants(); myheader->fN00 = h->NwNw(); myheader->fN01 = h->NwN(); myheader->fN10 = h->NNw(); myheader->fN11 = h->NN(); myheader->fBB = h->ImpactParameter(); myheader->fRP = h->ReactionPlaneAngle(); myheader->fPSn = h->ProjSpectatorsn(); myheader->fPSp = h->ProjSpectatorsp(); myheader->fTSn = h->TargSpectatorsn(); myheader->fTSp = h->TargSpectatorsn(); myresp->fEtch0p = hEtEta->GetBinContent(hEtEta->FindBin(0.5)); myresp->fEtch1p = hEtEta->GetBinContent(hEtEta->FindBin(1.5)); myresp->fEtch2p = hEtEta->GetBinContent(hEtEta->FindBin(2.5)); myresp->fEtch3p = hEtEta->GetBinContent(hEtEta->FindBin(3.5)); myresp->fEtch4p = hEtEta->GetBinContent(hEtEta->FindBin(4.5)); myresp->fEtch5p = hEtEta->GetBinContent(hEtEta->FindBin(5.5)); myresp->fEtchrp = hEtEta->GetBinContent(hEtEta->FindBin(10.5)); myresp->fEtch0n = hEtEta->GetBinContent(hEtEta->FindBin(-0.5)); myresp->fEtch1n = hEtEta->GetBinContent(hEtEta->FindBin(-1.5)); myresp->fEtch2n = hEtEta->GetBinContent(hEtEta->FindBin(-2.5)); myresp->fEtch3n = hEtEta->GetBinContent(hEtEta->FindBin(-3.5)); myresp->fEtch4n = hEtEta->GetBinContent(hEtEta->FindBin(-4.5)); myresp->fEtch5n = hEtEta->GetBinContent(hEtEta->FindBin(-5.5)); myresp->fEtchrn = hEtEta->GetBinContent(hEtEta->FindBin(-10.5)); myresp->fNch0p = hNEta->GetBinContent(hNEta->FindBin(0.5)); myresp->fNch1p = hNEta->GetBinContent(hNEta->FindBin(1.5)); myresp->fNch2p = hNEta->GetBinContent(hNEta->FindBin(2.5)); myresp->fNch3p = hNEta->GetBinContent(hNEta->FindBin(3.5)); myresp->fNch4p = hNEta->GetBinContent(hNEta->FindBin(4.5)); myresp->fNch5p = hNEta->GetBinContent(hNEta->FindBin(5.5)); myresp->fNchrp = hNEta->GetBinContent(hNEta->FindBin(10.5)); myresp->fNch0n = hNEta->GetBinContent(hNEta->FindBin(-0.5)); myresp->fNch1n = hNEta->GetBinContent(hNEta->FindBin(-1.5)); myresp->fNch2n = hNEta->GetBinContent(hNEta->FindBin(-2.5)); myresp->fNch3n = hNEta->GetBinContent(hNEta->FindBin(-3.5)); myresp->fNch4n = hNEta->GetBinContent(hNEta->FindBin(-4.5)); myresp->fNch5n = hNEta->GetBinContent(hNEta->FindBin(-5.5)); myresp->fNchrn = hNEta->GetBinContent(hNEta->FindBin(-10.5)); tree->Fill(); if (ntuple) { Int_t np = h->TargetParticipants() + h->ProjectileParticipants(); Int_t nc = h->NwNw() + h->NwN() + h->NNw() + h->NN(); Double_t b = h->ImpactParameter(); ntuple->Fill(np,nc,b); } } // end of event loop tree->Write(); ntuple->Write(); outFile->Close(); }
PostProcessQAV0(Bool_t lAttemptInvMassFit = kTRUE, Char_t *output = "pdf" // "eps", "png" or "pdf" ){ CustomGStyleSettings(); //============================================================== //Open Output File TFile* file = TFile::Open("AnalysisResults.root"), "READ"); if (!file){ cout<<"Output file not found!"<<endl; return; } file->cd("PWGLFQAV0_QA"); TList* clist = (TList*)file->FindObjectAny("clist"); if (!clist){ cout<<"File does not seem to hold QA list output!"<<endl; return; } //============================================================== //============================================================== //Open Event Histogram: first canvas TH1D* fHistEvent = (TH1D*)clist->FindObject("fHistEvent"); TCanvas *cHistEvent = new TCanvas("cHistEvent","",800,670); cHistEvent->SetTopMargin(0.15); cHistEvent->SetGridx(); cHistEvent->SetGridy(); fHistEvent->Draw(); fHistEvent->SetMarkerSize(1.35); fHistEvent->GetXaxis()->SetTitleOffset(1.2); fHistEvent->GetYaxis()->SetTitleOffset(1.2); fHistEvent->Draw("same text00"); TLatex Tl; Tl.SetNDC(); Tl.SetTextSize(0.05); Tl.DrawLatex(.35, .9277, "Event Counters") ; if (output == "png") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.png"); else if (output == "eps") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.eps"); else if (output == "pdf") cHistEvent->SaveAs("LF_QAanalysis_V0.pdf("); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TH2D *f2dHistInvMassK0Short = (TH2D*)clist->FindObject("f2dHistInvMassK0Short"); TH2D *f2dHistInvMassLambda = (TH2D*)clist->FindObject("f2dHistInvMassLambda"); TH2D *f2dHistInvMassAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassAntiLambda"); f2dHistInvMassK0Short -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassAntiLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); TCanvas *cInvMassK0Short = new TCanvas ( "cInvMassK0Short", "", 1200,800); cInvMassK0Short->Divide(1,2); cInvMassK0Short->cd(2)->Divide(3,1); cInvMassK0Short->cd(1); cInvMassK0Short->cd(1)->SetLogz(); cInvMassK0Short->cd(1)->SetLeftMargin(0.065); cInvMassK0Short->cd(1)->SetTopMargin(0.13); cInvMassK0Short->cd(1)->SetBottomMargin(0.11); f2dHistInvMassK0Short->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassK0Short->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassK0Short->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassK0Short->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassK0Short->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassK0Short->GetMaximum()*1.2 ); f2dHistInvMassK0Short->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, no TPC dE/dx") ; TH1D *fLowPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fLowPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(0.5001), f2dHistInvMassK0Short->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fMidPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(1.5001), f2dHistInvMassK0Short->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fHiPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(5.0001), f2dHistInvMassK0Short->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassK0Short->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassK0Short->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassK0Short->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassK0Short->cd(2)->cd(ic)->SetGridx(); cInvMassK0Short->cd(2)->cd(ic)->SetGridy(); } cInvMassK0Short->cd(2)->cd(1); fLowPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fLowPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fLowPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassK0Short->cd(2)->cd(2); fMidPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fMidPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fMidPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassK0Short->cd(2)->cd(3); fHiPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fHiPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fHiPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.png"); else if (output == "eps") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.eps"); else if (output == "pdf") cInvMassK0Short->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TH2D *f2dHistInvMassWithdEdxK0Short = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxK0Short"); TH2D *f2dHistInvMassWithdEdxLambda = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxLambda"); TH2D *f2dHistInvMassWithdEdxAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxAntiLambda"); f2dHistInvMassWithdEdxK0Short -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassWithdEdxLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassWithdEdxAntiLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); TCanvas *cInvMassK0ShortWithdEdx = new TCanvas ( "cInvMassK0ShortWithdEdx", "", 1200,800); cInvMassK0ShortWithdEdx->Divide(1,2); cInvMassK0ShortWithdEdx->cd(2)->Divide(3,1); cInvMassK0ShortWithdEdx->cd(1); cInvMassK0ShortWithdEdx->cd(1)->SetLogz(); cInvMassK0ShortWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassK0ShortWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassK0ShortWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxK0Short->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxK0Short->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, With TPC dE/dx") ; TH1D *fLowPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fLowPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fMidPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fHiPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassK0ShortWithdEdx->cd(2)->cd(1); fLowPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassK0ShortWithdEdx->cd(2)->cd(2); fMidPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassK0ShortWithdEdx->cd(2)->cd(3); fHiPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); TLatex Tli; Tli.SetNDC(); Tli.SetTextSize(0.05); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *f1 = new TF1("f1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.435, 0.565); //Reasonable first guess f1->SetParameter(0, fLowPtK0ShortSampleWithdEdx -> GetBinContent( fLowPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f1->SetParameter(1, 0 ); f1->SetParameter(2, 0 ); f1->SetParameter(3, 0.5*fLowPtK0ShortSampleWithdEdx->GetMaximum() ); f1->SetParameter(4, 0.497); f1->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fLowPtK0ShortSampleWithdEdx->Fit("f1","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(1); f1->Draw("same"); //Peak Position, Width: printout fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f1->GetParameter(4),f1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.635); //Reasonable first guess f2->SetParameter(0, fMidPtK0ShortSampleWithdEdx -> GetBinContent( fMidPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f2->SetParameter(1, 0 ); f2->SetParameter(2, 0 ); f2->SetParameter(3, 0.5*fMidPtK0ShortSampleWithdEdx->GetMaximum() ); f2->SetParameter(4, 0.497); f2->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fMidPtK0ShortSampleWithdEdx->Fit("f2","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(2); f2->Draw("same"); //Peak Position, Width: printout fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f2->GetParameter(4),f2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *f3 = new TF1("f3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.665); //Reasonable first guess f3->SetParameter(0, fHiPtK0ShortSampleWithdEdx -> GetBinContent( fHiPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f3->SetParameter(1, 0 ); f3->SetParameter(2, 0 ); f3->SetParameter(3, 0.5*fHiPtK0ShortSampleWithdEdx->GetMaximum() ); f3->SetParameter(4, 0.497); f3->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fHiPtK0ShortSampleWithdEdx->Fit("f3","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(3); f3->Draw("same"); //Peak Position, Width: printout fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f3->GetParameter(4),f3->GetParameter(5)) ) ; } if (output == "png") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.png"); else if (output == "eps") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.eps"); else if (output == "pdf") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TCanvas *cInvMassLambda = new TCanvas ( "cInvMassLambda", "", 1200,800); cInvMassLambda->Divide(1,2); cInvMassLambda->cd(2)->Divide(3,1); cInvMassLambda->cd(1); cInvMassLambda->cd(1)->SetLogz(); cInvMassLambda->cd(1)->SetLeftMargin(0.065); cInvMassLambda->cd(1)->SetTopMargin(0.13); cInvMassLambda->cd(1)->SetBottomMargin(0.11); f2dHistInvMassLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassLambda->GetZaxis()->SetRangeUser( f2dHistInvMassLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassLambda->GetMaximum()*1.2 ); f2dHistInvMassLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, no TPC dE/dx") ; TH1D *fLowPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fLowPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fMidPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fHiPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassLambda->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassLambda->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassLambda->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassLambda->cd(2)->cd(ic)->SetGridx(); cInvMassLambda->cd(2)->cd(ic)->SetGridy(); } cInvMassLambda->cd(2)->cd(1); fLowPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fLowPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fLowPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassLambda->cd(2)->cd(2); fMidPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fMidPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fMidPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassLambda->cd(2)->cd(3); fHiPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fHiPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fHiPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.png"); else if (output == "eps") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.eps"); else if (output == "pdf") cInvMassLambda->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TCanvas *cInvMassLambdaWithdEdx = new TCanvas ( "cInvMassLambdaWithdEdx", "", 1200,800); cInvMassLambdaWithdEdx->Divide(1,2); cInvMassLambdaWithdEdx->cd(2)->Divide(3,1); cInvMassLambdaWithdEdx->cd(1); cInvMassLambdaWithdEdx->cd(1)->SetLogz(); cInvMassLambdaWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassLambdaWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassLambdaWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxLambda->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, With TPC dE/dx") ; TH1D *fLowPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fLowPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fMidPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fHiPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassLambdaWithdEdx->cd(2)->cd(1); fLowPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassLambdaWithdEdx->cd(2)->cd(2); fMidPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassLambdaWithdEdx->cd(2)->cd(3); fHiPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *fl1 = new TF1("fl1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14); //Reasonable first guess fl1->SetParameter(0, fLowPtLambdaSampleWithdEdx -> GetBinContent( fLowPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl1->SetParameter(1, 0 ); fl1->SetParameter(2, 0 ); fl1->SetParameter(3, 0.35*fLowPtLambdaSampleWithdEdx->GetMaximum() ); fl1->SetParameter(4, 1.115683); fl1->SetParLimits(4,1.116-0.01,1.116+0.01); fl1->SetParameter(5, 0.002); fl1->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fLowPtLambdaSampleWithdEdx->Fit("fl1","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(1); fl1->Draw("same"); //Peak Position, Width: printout fLowPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl1->GetParameter(4),fl1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fl2 = new TF1("fl2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15); //Reasonable first guess fl2->SetParameter(0, fMidPtLambdaSampleWithdEdx -> GetBinContent( fMidPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl2->SetParameter(1, 0 ); fl2->SetParameter(2, 0 ); fl2->SetParameter(3, 0.6*fMidPtLambdaSampleWithdEdx->GetMaximum() ); fl2->SetParLimits(4,1.116-0.01,1.116+0.01); fl2->SetParameter(4, 1.116); fl2->SetParameter(5, 0.0025); fl2->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fMidPtLambdaSampleWithdEdx->Fit("fl2","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(2); fl2->Draw("same"); //Peak Position, Width: printout fMidPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl2->GetParameter(4),fl2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fl3 = new TF1("fl3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15); //Reasonable first guess fl3->SetParameter(0, fHiPtLambdaSampleWithdEdx -> GetBinContent( fHiPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl3->SetParameter(1, 0 ); fl3->SetParameter(2, 0 ); fl3->SetParameter(3, 0.6*fHiPtLambdaSampleWithdEdx->GetMaximum() ); fl3->SetParameter(4, 1.116); fl3->SetParLimits(4,1.116-0.005,1.116+0.005); fl3->SetParameter(5, 0.0035); fl3->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fHiPtLambdaSampleWithdEdx->Fit("fl3","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(3); fl3->Draw("same"); //Peak Position, Width: printout fHiPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl3->GetParameter(4),fl3->GetParameter(5)) ) ; } if (output == "png") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.png"); else if (output == "eps") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.eps"); else if (output == "pdf") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TCanvas *cInvMassAntiLambda = new TCanvas ( "cInvMassAntiLambda", "", 1200,800); cInvMassAntiLambda->Divide(1,2); cInvMassAntiLambda->cd(2)->Divide(3,1); cInvMassAntiLambda->cd(1); cInvMassAntiLambda->cd(1)->SetLogz(); cInvMassAntiLambda->cd(1)->SetLeftMargin(0.065); cInvMassAntiLambda->cd(1)->SetTopMargin(0.13); cInvMassAntiLambda->cd(1)->SetBottomMargin(0.11); f2dHistInvMassAntiLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassAntiLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassAntiLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassAntiLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassAntiLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassAntiLambda->GetMaximum()*1.2 ); f2dHistInvMassAntiLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, no TPC dE/dx") ; TH1D *fLowPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fLowPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fMidPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fHiPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassAntiLambda->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassAntiLambda->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassAntiLambda->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassAntiLambda->cd(2)->cd(ic)->SetGridx(); cInvMassAntiLambda->cd(2)->cd(ic)->SetGridy(); } cInvMassAntiLambda->cd(2)->cd(1); fLowPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fLowPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fLowPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassAntiLambda->cd(2)->cd(2); fMidPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fMidPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fMidPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassAntiLambda->cd(2)->cd(3); fHiPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fHiPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fHiPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.png"); else if (output == "eps") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.eps"); else if (output == "pdf") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TCanvas *cInvMassAntiLambdaWithdEdx = new TCanvas ( "cInvMassAntiLambdaWithdEdx", "", 1200,800); cInvMassAntiLambdaWithdEdx->Divide(1,2); cInvMassAntiLambdaWithdEdx->cd(2)->Divide(3,1); cInvMassAntiLambdaWithdEdx->cd(1); cInvMassAntiLambdaWithdEdx->cd(1)->SetLogz(); cInvMassAntiLambdaWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassAntiLambdaWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassAntiLambdaWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxAntiLambda->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxAntiLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, With TPC dE/dx") ; TH1D *fLowPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fLowPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fMidPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fHiPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); fLowPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); fMidPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); fHiPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *fal1 = new TF1("fal1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14); //Reasonable first guess fal1->SetParameter(0, fLowPtAntiLambdaSampleWithdEdx -> GetBinContent( fLowPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal1->SetParameter(1, 0 ); fal1->SetParameter(2, 0 ); fal1->SetParameter(3, 0.35*fLowPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal1->SetParameter(4, 1.115683); fal1->SetParLimits(4,1.116-0.01,1.116+0.01); fal1->SetParameter(5, 0.002); fal1->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fLowPtAntiLambdaSampleWithdEdx->Fit("fal1","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); fal1->Draw("same"); //Peak Position, Width: printout fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal1->GetParameter(4),fal1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fal2 = new TF1("fal2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15); //Reasonable first guess fal2->SetParameter(0, fMidPtAntiLambdaSampleWithdEdx -> GetBinContent( fMidPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal2->SetParameter(1, 0 ); fal2->SetParameter(2, 0 ); fal2->SetParameter(3, 0.6*fMidPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal2->SetParLimits(4,1.116-0.01,1.116+0.01); fal2->SetParameter(4, 1.116); fal2->SetParameter(5, 0.0025); fal2->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fMidPtAntiLambdaSampleWithdEdx->Fit("fal2","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); fal2->Draw("same"); //Peak Position, Width: printout fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal2->GetParameter(4),fal2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fal3 = new TF1("fal3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15); //Reasonable first guess fal3->SetParameter(0, fHiPtAntiLambdaSampleWithdEdx -> GetBinContent( fHiPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal3->SetParameter(1, 0 ); fal3->SetParameter(2, 0 ); fal3->SetParameter(3, 0.6*fHiPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal3->SetParameter(4, 1.116); fal3->SetParLimits(4,1.116-0.005,1.116+0.005); fal3->SetParameter(5, 0.0035); fal3->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fHiPtAntiLambdaSampleWithdEdx->Fit("fal3","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); fal3->Draw("same"); //Peak Position, Width: printout fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal3->GetParameter(4),fal3->GetParameter(5)) ) ; } if (output == "png") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.png"); else if (output == "eps") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.eps"); else if (output == "pdf") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== // Strict Lambda Analysis for dE/dx Calibration Check TH2D *f2dHistdEdxSignalPionFromLambda = (TH2D*)clist->FindObject("f2dHistdEdxSignalPionFromLambda"); TH2D *f2dHistdEdxSignalProtonFromLambda = (TH2D*)clist->FindObject("f2dHistdEdxSignalProtonFromLambda"); TH2D *f2dHistResponsePionFromLambda = (TH2D*)clist->FindObject("f2dHistResponsePionFromLambda"); TH2D *f2dHistResponseProtonFromLambda = (TH2D*)clist->FindObject("f2dHistResponseProtonFromLambda"); f2dHistdEdxSignalPionFromLambda->Rebin2D(2,10); f2dHistdEdxSignalProtonFromLambda->Rebin2D(2,10); TH1D *fLowPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fLowPtPionResponse", f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.5001), f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fMidPtPionResponse", f2dHistResponsePionFromLambda->GetXaxis()->FindBin(1.5001), f2dHistResponsePionFromLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fLowPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fLowPtProtonResponse", f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.5001), f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fMidPtProtonResponse", f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(1.5001), f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(2.4999) ); TCanvas *cdEdxPure = new TCanvas("cdEdxPure","",1500,800); cdEdxPure->Divide(4,2); for(Int_t ic = 1; ic<9; ic++){ cdEdxPure->SetLeftMargin(0.15); cdEdxPure->cd(ic)->SetLogz(); //cdEdxPure->cd(ic)->SetTopMargin(0.133); if( ic%4 == 1 || ic%4 == 2){ cdEdxPure->cd(ic)->SetRightMargin(0.133); } if( ic%4 != 1 && ic%4 != 2){ cdEdxPure->cd(ic)->SetGridx(); cdEdxPure->cd(ic)->SetGridy(); } } cdEdxPure->cd(1); f2dHistdEdxSignalPionFromLambda->Draw("colz"); cdEdxPure->cd(2); f2dHistResponsePionFromLambda->Draw("colz"); cdEdxPure->cd(3); fLowPtPionResponse->Draw(); cdEdxPure->cd(4); fMidPtPionResponse->Draw(); cdEdxPure->cd(5); f2dHistdEdxSignalProtonFromLambda->Draw("colz"); cdEdxPure->cd(6); f2dHistResponseProtonFromLambda->Draw("colz"); cdEdxPure->cd(7); fLowPtProtonResponse->Draw(); cdEdxPure->cd(8); fMidPtProtonResponse->Draw(); //Write explanations on canvases cdEdxPure->cd(1); Tl.DrawLatex(.25, .9277, "#pi^{-} from #Lambda: TPC Signal"); cdEdxPure->cd(2); Tl.DrawLatex(.15, .9277, "#pi^{-} from #Lambda: AliPIDResponse Value"); cdEdxPure->cd(3); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 0.5 < p_{T} (GeV/c) < 1.0"); cdEdxPure->cd(4); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 1.5 < p_{T} (GeV/c) < 2.5"); cdEdxPure->cd(5); Tl.DrawLatex(.25, .9277, "p from #Lambda: TPC Signal"); cdEdxPure->cd(6); Tl.DrawLatex(.15, .9277, "p from #Lambda: AliPIDResponse Value"); cdEdxPure->cd(7); Tl.DrawLatex(.21, .9277, "p N#sigma, 0.5 < p_{T} (GeV/c) < 1.0"); cdEdxPure->cd(8); Tl.DrawLatex(.21, .9277, "p N#sigma, 1.5 < p_{T} (GeV/c) < 2.5"); Double_t lLowPtPeakPion = fLowPtPionResponse->GetBinCenter( fLowPtPionResponse->GetMaximumBin() ); Double_t lMidPtPeakPion = fMidPtPionResponse->GetBinCenter( fMidPtPionResponse->GetMaximumBin() ); Double_t lLowPtPeakProton = fLowPtProtonResponse->GetBinCenter( fLowPtProtonResponse->GetMaximumBin() ); Double_t lMidPtPeakProton = fMidPtProtonResponse->GetBinCenter( fMidPtProtonResponse->GetMaximumBin() ); //List Maximal Values cout<<"Maximal Value for pion from Lambda at low pt...............: " <<lLowPtPeakPion<<endl; cout<<"Maximal Value for pion from Lambda at mid pt...............: " <<lMidPtPeakPion<<endl; cout<<"Maximal Value for proton from Lambda at low pt.............: " <<lLowPtPeakProton<<endl; cout<<"Maximal Value for proton from Lambda at mid pt.............: " <<lMidPtPeakProton<<endl; if( TMath::Abs( lLowPtPeakPion ) > 0.3) cout<<"*** WARNING: Check Low Pt pion PID Response! ***"<<endl; if( TMath::Abs( lMidPtPeakPion ) > 0.3) cout<<"*** WARNING: Check Mid Pt pion PID Response! ***"<<endl; if( TMath::Abs( lLowPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Low Pt proton PID Response! ***"<<endl; if( TMath::Abs( lMidPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Mid Pt proton PID Response! ***"<<endl; TLatex Tlq; Tlq.SetNDC(); Tlq.SetTextSize(0.06); //Draw Arrows to be sure! Double_t lFractionHeight = 0.33; cdEdxPure->cd(3); TArrow *ar1 = new TArrow(lLowPtPeakPion,lFractionHeight * fLowPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar1->SetLineWidth(2); ar1->Draw(); if( TMath::Abs( lLowPtPeakPion ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(4); TArrow *ar2 = new TArrow(lMidPtPeakPion,lFractionHeight * fMidPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar2->SetLineWidth(2); ar2->Draw(); if( TMath::Abs( lMidPtPeakPion ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(7); TArrow *ar3 = new TArrow(lLowPtPeakProton,lFractionHeight * fLowPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar3->SetLineWidth(2); ar3->Draw(); if( TMath::Abs( lLowPtPeakProton ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(8); TArrow *ar4 = new TArrow(lMidPtPeakProton,lFractionHeight * fMidPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar4->SetLineWidth(2); ar4->Draw(); if( TMath::Abs( lMidPtPeakProton ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } if (output == "png") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.png"); else if (output == "eps") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.eps"); else if (output == "pdf") cdEdxPure->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Topological variable QA // FIXME: This is still only a rough first version. // Adjustments will be required for easy / long-term operation. TH1D *fHistTopDCAPosToPV = (TH1D*)clist->FindObject("fHistSelectedTopDCAPosToPV"); TH1D *fHistTopDCANegToPV = (TH1D*)clist->FindObject("fHistSelectedTopDCANegToPV"); TH1D *fHistTopDCAV0Daughters = (TH1D*)clist->FindObject("fHistSelectedTopDCAV0Daughters"); TH1D *fHistTopCosinePA = (TH1D*)clist->FindObject("fHistSelectedTopCosinePA"); TH1D *fHistTopV0Radius = (TH1D*)clist->FindObject("fHistSelectedTopV0Radius"); //Zoom in on selection in Cosine of pointing angle... Int_t iLowBin=-1; Int_t iLowBin2 = -1; Int_t iLowBin3 = -1; //Normalize to per-event fHistTopDCAPosToPV -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCANegToPV -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCAV0Daughters -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopCosinePA -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopV0Radius -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCAPosToPV -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCANegToPV -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCAV0Daughters -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopCosinePA -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopV0Radius -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCAPosToPV -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCANegToPV -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCAV0Daughters -> GetYaxis() -> SetTitleSize(0.05); fHistTopCosinePA -> GetYaxis() -> SetTitleSize(0.05); fHistTopV0Radius -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCAPosToPV -> GetXaxis() -> SetTitleSize(0.05); fHistTopDCANegToPV -> GetXaxis() -> SetTitleSize(0.05); fHistTopDCAV0Daughters -> GetXaxis() -> SetTitleSize(0.05); fHistTopCosinePA -> GetXaxis() -> SetTitleSize(0.05); fHistTopV0Radius -> GetXaxis() -> SetTitleSize(0.05); Double_t lMinimumCosPADraw = 1.-1.25*(1.-GetXForMinValue ( fHistTopCosinePA ) ); //assumes monotonically increasing dist cout<<"Function test: "<< lMinimumCosPADraw <<endl; fHistTopCosinePA->GetXaxis()->SetRangeUser(lMinimumCosPADraw,1.001); Double_t lmin[5]; Double_t lminPrecision[5]; lmin[3] = GetXForMinValue ( fHistTopCosinePA ); lmin[4] = GetXForMinValue ( fHistTopV0Radius ); lmin[0] = GetXForMaxValue ( fHistTopDCAPosToPV ); lmin[1] = GetXForMaxValue ( fHistTopDCANegToPV ); lmin[2] = GetXForMinValue ( fHistTopDCAV0Daughters ); lminPrecision[3] = fHistTopCosinePA -> GetBinWidth(1); lminPrecision[4] = fHistTopV0Radius -> GetBinWidth(1); lminPrecision[0] = fHistTopDCAPosToPV -> GetBinWidth(1); lminPrecision[1] = fHistTopDCANegToPV -> GetBinWidth(1); lminPrecision[2] = fHistTopDCAV0Daughters -> GetBinWidth(1); cout<<"Minimum Values Found: "<<endl; cout<<"Cosine of Pointing Angle...........: "<<GetXForMinValue (fHistTopCosinePA )<<" precision = "<<lminPrecision[3]<<endl; cout<<"DCA Neg Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCAPosToPV )<<" precision = "<<lminPrecision[1]<<endl; cout<<"DCA Pos Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCANegToPV )<<" precision = "<<lminPrecision[0]<<endl; cout<<"DCA V0 Daughers....................: "<<GetXForMinValue (fHistTopDCAV0Daughters )<<" precision = "<<lminPrecision[2]<<endl; cout<<"V0 Decay Radius....................: "<<GetXForMinValue (fHistTopV0Radius )<<" precision = "<<lminPrecision[4]<<endl; TCanvas *cTopo = new TCanvas ("cTopo","",1200,800); cTopo->Divide(3,2); for(Int_t ic = 1; ic<7; ic++){ cTopo->cd(ic)->SetLeftMargin(0.15); cTopo->cd(ic)->SetGridx(); cTopo->cd(ic)->SetGridy(); } cTopo->cd(1); fHistTopDCAPosToPV->Draw(); cTopo->cd(2); fHistTopDCANegToPV->Draw(); cTopo->cd(3); fHistTopDCAV0Daughters->Draw(); cTopo->cd(4); fHistTopCosinePA->Draw(); cTopo->cd(5); fHistTopV0Radius->Draw(); TLatex Tlt; Tlt.SetNDC(); Tlt.SetTextSize(0.05); cTopo->cd(6); Tlt.DrawLatex(.22, .9, "Boundary Checks") ; TString lCut[5]; lCut [ 0 ] = "Min DCA Pos D. To PV (cm)"; lCut [ 1 ] = "Min DCA Neg D. To PV (cm)"; lCut [ 2 ] = "Max DCA V0 Daughters (#sigma)"; lCut [ 3 ] = "Min Cosine PA"; lCut [ 4 ] = "Min 2D Decay Radius (cm)"; TString lCutVal[5]; TString lCutValPrec[5]; Tlt.SetTextSize(0.04); Tlt.SetTextFont(42); Tlt.DrawLatex(.01, .80, "Topological Var.") ; Tlt.DrawLatex(.6, .80, "Value") ; Tlt.DrawLatex(.75, .80, "Precision") ; for (Int_t il=0;il<5;il++){ Tlt.DrawLatex(.01,0.72-((double)il)*0.075, lCut[il].Data() ); lCutVal[il] = Form( "%.4f", lmin[il] ); Tlt.DrawLatex(.5925,0.72-((double)il)*0.075, lCutVal[il].Data() ); lCutValPrec[il] = Form( "%.4f", lminPrecision[il] ); Tlt.DrawLatex(.7675,0.72-((double)il)*0.075, lCutValPrec[il].Data() ); } Tlt.SetTextSize(0.05); Tlt.SetTextFont(42); //Try to make a wild guess... if ( TMath::Abs( lmin[0] - 0.100 ) < 2*lminPrecision[0] && TMath::Abs( lmin[1] - 0.100 ) < 2*lminPrecision[1] && TMath::Abs( lmin[2] - 1.000 ) < 2*lminPrecision[2] && TMath::Abs( lmin[3] - 0.998 ) < 2*lminPrecision[3] && TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){ Tlt.DrawLatex( 0.17, 0.275, "#bf{Autodetect Interpretation}: "); Tlt.DrawLatex( 0.1, 0.2, "Typical #bf{Pb-Pb} Reconstruction Cuts"); } if ( TMath::Abs( lmin[0] - 0.020 ) < 2*lminPrecision[0] && TMath::Abs( lmin[1] - 0.020 ) < 2*lminPrecision[1] && TMath::Abs( lmin[2] - 1.500 ) < 2*lminPrecision[2] && TMath::Abs( lmin[3] - 0.98 ) < 2*lminPrecision[3] && TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){ Tlt.DrawLatex( 0.15, 0.29, "#bf{Autodetect Interpretation}: "); Tlt.DrawLatex( 0.1, 0.2, "Typical pp Reconstruction Cuts"); //To be checked } if (output == "png") cTopo->SaveAs("LF_QAanalysis_V0_page6.png"); else if (output == "eps") cTopo->SaveAs("LF_QAanalysis_V0_page6.eps"); else if (output == "pdf") cTopo->SaveAs("LF_QAanalysis_V0.pdf)"); }
void Find_JPsiPt() { double pt_bound[200] = {0.0}; double PT[200], DelPT[200]; double YPT[200], DelYPT[200]; int Nptbin = 120; //int Nptbin = 70; double step =0.1; cout<<" pT Bins "<<endl; for (Int_t ih = 0; ih < Nptbin; ih++) { pt_bound[ih] = 0 + step*ih; pt_bound[ih+1] = 0 + step*(ih+1); PT[ih] = (pt_bound[ih] + pt_bound[ih+1])/2.0; DelPT[ih] = (pt_bound[ih+1] - pt_bound[ih])/2.0; cout<<PT[ih]<<" "<<DelPT[ih]<<endl; } char namePt[500]; //TFile *fpT = new TFile("Psi2s5M_pythia.root"); //TH2D *JPt_BPt = (TH2D*)fpT->Get("Psi2SVsJPsi_Pt"); //TH2D *JPt_BPt = (TH2D*)fpT->Get("Psi2SVsChic0_Pt"); TFile *fpT = new TFile("Psi2S1M_pythia.root"); //TH2D *JPt_BPt = (TH2D*)fpT->Get("Psi2SVsChic1_Pt"); TH2D *JPt_BPt = (TH2D*)fpT->Get("Psi2SVsChic2_Pt"); new TCanvas; JPt_BPt->Draw("colz"); TH1D *service = (TH1D*)JPt_BPt->ProjectionX("service"); TAxis *xaxis = service->GetXaxis(); for(int i=0;i<service->GetSize();i++) { Double_t binCenter = xaxis->GetBinCenter(i); cout<<binCenter<<endl; } //return; //service->Draw(); cout<<" service "<<service<<endl; int pt_bin_bound[200]; TH1D *ProfY_BPt[200]; for (Int_t ih = 0; ih < Nptbin; ih++) { pt_bin_bound[ih] = service->FindBin(pt_bound[ih]); pt_bin_bound[ih+1] = service->FindBin(pt_bound[ih+1]); sprintf(namePt,"BPt_%d",ih); //ProfY_BPt[ih] = (TH1D*)JPt_BPt->ProjectionY(namePt, pt_bin_bound[ih], pt_bin_bound[ih+1]-1,"e"); ProfY_BPt[ih] = (TH1D*)JPt_BPt->ProjectionY(namePt, pt_bin_bound[ih], pt_bin_bound[ih+1],"e"); YPT[ih] = ProfY_BPt[ih]->GetMean(); DelYPT[ih] = ProfY_BPt[ih]->GetRMS(); cout<< YPT[ih] <<" /pm "<< DelYPT[ih]<< endl<<endl; } TGraphErrors *gr_BpTvsJpT = new TGraphErrors(Nptbin, PT, YPT, DelPT, DelYPT); TF1 *func_BpTvsJpT = new TF1("pol1", pol1, 0, 20, 2); func_BpTvsJpT->SetLineColor(2); gr_BpTvsJpT->Fit("pol1","","",0,20); gr_BpTvsJpT->GetXaxis()->SetRangeUser(0,20); gr_BpTvsJpT->GetXaxis()->SetTitle("J/#psi p_{T}"); gr_BpTvsJpT->GetYaxis()->SetTitle("#psi(2S) p_{T}"); new TCanvas; gr_BpTvsJpT->Draw("ap"); func_BpTvsJpT->Draw("same"); }
void JetFragAna::Loop() { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t jetTreeNEntries[10] = {nentries,jetTree_[1]->GetEntries(),0,0,0}; cout << "==============" << endl; cout << " Begin Loop" << endl; cout << "Tree: " << nentries << " jetTree: " << jetTreeNEntries[jetTreeMode_] << endl; cout << "==============" << endl; for (int i=0;i<fileTrackingCorr_.size();++i) { cout << fileTrackingCorr_[i]->GetName() << endl; for (int j=0;j<trackingCentBin_.size();++j) { cout << trackingCentBin_[j]; cout << " Eff: " << trackingEffCorr_[i][j]->GetEntries(); cout << " Fak: " << trackingFakCorr_[i][j]->GetEntries(); cout << " Mul: " << trackingMulCorr_[i][j]->GetEntries(); cout << " Sec: " << trackingSecCorr_[i][j]->GetEntries(); cout << endl; } } // Random Number r3 = new TRandom3(mixOffset_); // ===================================================== // Initialize Counters // ===================================================== numDJ_=0,numDJReWeighted_=0; for (Int_t i=0; i<2; ++i) { numJ_[i]=0; numJReWeighted_[i]=0; } Int_t numTotEvt=0, numDJNoBkgLimit=0; Long64_t nbytes = 0, nb = 0; // Pt Bin TH1D * hPt = (TH1D*)hPtPDR[0]->ProjectionX(); Int_t numPtBins = hPt->GetNbinsX(); // Set Tree Pt bins jc_.resizePtBins(numPtBins); // ===================================================== // Centrality ReWeighting // ===================================================== TH1D *hCent = new TH1D("hCent","",40,0,100); fChain->Project("hCent","cent",""); // no evt sel, assume centrality distribution of bkg is independent of the signal hCent->Scale(1./hCent->GetEntries()); // Centrality Weight hCentralityWeight_->Divide(hCentralityData_,hCent); // ReWeighted Centrality distribution TH1D *hCentReWeighted = new TH1D("hCentReWeighted","",40,0,100); //======================================================================================================================= // Main Loop //======================================================================================================================= for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (jentry%500==0) cout << "jentry: " << jentry << " " << jentry/float(nentries) << endl; if (ientry < 0) break; nb = GetEntry(jentry); nbytes += nb; GetJetEntry(jetTree_[jetTreeMode_],vj_[jetTreeMode_],(jentry+mixOffset_)%jetTreeNEntries[jetTreeMode_]); ++numTotEvt; // Clear counters jettrk_.clear(); jc_.clear(); // ===================================================== // Main Event Selection // ===================================================== if (!doEvtSel_||(Cut(ientry)>=0&&!GetEvtMask())) { ++numDJNoBkgLimit; // ===================================================== // Jet Phase Space Limit (if Bkg Subtraction) // ===================================================== if (cut.BkgSubType=="EtaRefl") { if (fabs(anaJets_[0].eta())<cut.ConeSize||fabs(anaJets_[1].eta())<cut.ConeSize) continue; } if (cut.BkgSubType=="PhiRot") { if (fabs(anaJets_[0].eta()-anaJets_[1].eta())<cut.ConeSize*2) continue; } // If we want to restrict eta for j0,j1 separately // Classify events into j0 events or j1 events bool jetEvt[2] = { true, true }; if (cut.BkgSubType=="EtaReflSingle") { for (Int_t j=0; j<2; ++j) { if (fabs(anaJets_[j].eta())<cut.ConeSize) jetEvt[j]=false; } } // systematic checks on eta regions if (cut.BkgSubType=="EtaReflSingleEtaPos") { for (Int_t j=0; j<2; ++j) { if (fabs(anaJets_[j].eta())<cut.ConeSize||anaJets_[j].eta()<0) jetEvt[j]=false; } } if (cut.BkgSubType=="EtaReflSingleEtaNeg") { for (Int_t j=0; j<2; ++j) { if (fabs(anaJets_[j].eta())<cut.ConeSize||anaJets_[j].eta()>=0) jetEvt[j]=false; } } // ===================================================== // Set Centrality Weight // ===================================================== int cBin = hCent->FindBin(cent); double weight=1; if (doCentralityReweighting_) { if (hCentralityData_->GetBinContent(cBin)==0 || hCent->GetBinContent(cBin)==0) { weight = 0; } else { weight = hCentralityWeight_->GetBinContent(cBin); } } // ===================================================== // Fill Event Level Histograms // ===================================================== hJDPhi->Fill(anaJetDPhi_,weight); hAj->Fill((anaJets_[0].pt()-anaJets_[1].pt())/(anaJets_[0].pt()+anaJets_[1].pt()),weight); hJDEta->Fill(anaJets_[1].eta()-anaJets_[0].eta(),weight); hCentReWeighted->Fill(cent,weight); ++numDJ_; numDJReWeighted_+=weight; jettrk_.cent = cent; jettrk_.centwt = weight; for (Int_t j=0; j<2; ++j) { if (jetEvt[j]) { hJEt[j]->Fill(anaJets_[j].pt(),weight); hJEta[j]->Fill(anaJets_[j].eta(),weight); jettrk_.jtpt[j] = anaJets_[j].pt(); jettrk_.jteta[j] = anaJets_[j].eta(); jettrk_.jtphi[j] = anaJets_[j].phi(); ++numJ_[j]; numJReWeighted_[j]+=weight; } } jettrk_.jdphi = anaJetDPhi_; if (doJetOnly_) continue; // Initialize Counters Double_t conePtSum[2] = { 0,0 }; Double_t conePtBgSum[2] = { 0,0 }; Double_t metx=0,metx0=0,metx1=0,metx2=0,metx3=0,metx4=0,metx5=0; Double_t mety=0,mety0=0,mety1=0,mety2=0,mety3=0,mety4=0,mety5=0; Double_t metConex=0,metConex0=0,metConex1=0,metConex2=0,metConex3=0,metConex4=0,metConex5=0; Double_t metOutOfConex=0,metOutOfConex0=0,metOutOfConex1=0,metOutOfConex2=0,metOutOfConex3=0,metOutOfConex4=0,metOutOfConex5=0; // ===================================================== // Fill Particle Level Histograms // ===================================================== for (Int_t i=0; i<evtnp;++i) { // ------------------------ // Trk Cut // ------------------------ if (anaGenpType_==1 && pch[i]==0) continue; if (anaGenpType_==10 && (psube[i]>0 || pch[i]==0)) continue; if (cut.Name.Contains("PFChHad") && pfid[i]!=1) continue; if (cut.Name.Contains("PFPhoton") && pfid[i]!=4) continue; if (ppt[i]<cut.TrkPtMin||fabs(peta[i])>=2.4) continue; // ------------------------ // Track Efficiency/Fake Correction // ------------------------ Double_t trackWeight=1; Float_t trkcorr[4]={1,1,1,1}; if (doTrackingEffFakeCorr_) { trackWeight = getEffFakeCorrection(ppt[i],peta[i],anaJets_[0].pt(),cent,trkcorr); } // Dead forward pixel xcheck //if (peta[i]>2&&pphi[i]>-0.1&&pphi[i]<0.8) trackWeight=0; jettrk_.ppt.push_back(p_[i].pt()); jettrk_.peta.push_back(p_[i].eta()); jettrk_.pphi.push_back(p_[i].phi()); jettrk_.trkeff.push_back(trkcorr[0]); jettrk_.trkfak.push_back(trkcorr[1]); jettrk_.trkmul.push_back(trkcorr[2]); jettrk_.trksec.push_back(trkcorr[3]); // ------------------------ // calculate particle jet correlations // ------------------------ Double_t pdphi[2]={ 9999,9999 }; Double_t pdr[2]={ 9999,9999 }; Double_t pdrbg[2]={ 9999,9999 }; for (Int_t j=0; j<2; ++j) { // signal pdphi[j] = reco::deltaPhi(p_[i].phi(),anaJets_[j].phi()); pdr[j] = reco::deltaR(p_[i].eta(),p_[i].phi(),anaJets_[j].eta(),anaJets_[j].phi()); // bcksub // * If don't do event selection, make eta reflection the default bkg axis if (cut.BkgSubType.Contains("EtaRefl"||!doEvtSel_)) { pdrbg[j] = reco::deltaR(p_[i].eta(),p_[i].phi(),-1*anaJets_[j].eta(),anaJets_[j].phi()); } // monitor histograms hPJDPhi[j]->Fill(pdphi[j],trackWeight); jettrk_.pdr[j].push_back(pdr[j]); jettrk_.pdrbg[j].push_back(pdrbg[j]); } Float_t trkEnergy=p_[i].pt(); // ------------------------ // met calculation // ------------------------ Float_t pptx=cos(pdphi[0])*trkEnergy*trackWeight; metx+=pptx; Float_t ppty=sin(pdphi[0])*trkEnergy*trackWeight; mety+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex+=pptx; else metOutOfConex+=pptx; //for (int i=0;i<hPt->GetNbinsX()+2;++i) cout << "Bin " << i << " ledge: " << hPt->GetBinLowEdge(i) << endl; if (trkEnergy>=hPt->GetBinLowEdge(1)&&trkEnergy<hPt->GetBinLowEdge(2)) { metx0+=pptx; mety0+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex0+=pptx; else metOutOfConex0+=pptx; } else if (trkEnergy>=hPt->GetBinLowEdge(2)&&trkEnergy<hPt->GetBinLowEdge(3)) { metx1+=pptx; mety1+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex1+=pptx; else metOutOfConex1+=pptx; } else if (trkEnergy>=hPt->GetBinLowEdge(3)&&trkEnergy<hPt->GetBinLowEdge(4)) { metx2+=pptx; mety2+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex2+=pptx; else metOutOfConex2+=pptx; } else if (trkEnergy>=hPt->GetBinLowEdge(4)&&trkEnergy<hPt->GetBinLowEdge(5)) { metx3+=pptx; mety3+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex3+=pptx; else metOutOfConex3+=pptx; } else if (trkEnergy>=hPt->GetBinLowEdge(5)&&trkEnergy<hPt->GetBinLowEdge(6)) { metx4+=pptx; mety4+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex4+=pptx; else metOutOfConex4+=pptx; } else if (trkEnergy>=hPt->GetBinLowEdge(6)&&trkEnergy<hPt->GetBinLowEdge(7)) { metx5+=pptx; mety5+=ppty; if (fabs(pdr[0])<0.8||fabs(pdr[1])<0.8) metConex5+=pptx; else metOutOfConex5+=pptx; } // ===================================================== // Calculate Cone Sums // ===================================================== // cone sum for (Int_t j=0; j<2; ++j) { for (Int_t b=0; b<numPtBins; ++b) { if (trkEnergy>=hPt->GetBinLowEdge(b+1)&&trkEnergy<hPt->GetBinLowEdge(b+2)) { // Signal Cone if (pdr[j]<cut.ConeSize) { jc_.cpt[j][b]+=trkEnergy*trackWeight; jc_.cptpara[j][b]+=cos(reco::deltaPhi(p_[i].phi(),anaJets_[0].phi()))*trkEnergy*trackWeight; } // Bkg Cone if (pdrbg[j]<cut.ConeSize) { jc_.cptbg[j][b]+=trkEnergy*trackWeight; jc_.cptparabg[j][b]+=cos(reco::deltaPhi(p_[i].phi(),anaJets_[0].phi()))*trkEnergy*trackWeight; } break; } } } // ===================================================== // Take the reweighting into account for later histogram // **This should not be applied before the met calculation.** // ===================================================== trackWeight *= weight; // ===================================================== // Fill Jet-Particle Histograms // ===================================================== for (Int_t j=0; j<2; ++j) { if (jetEvt[j]) { // Signal Cone if (pdr[j]<cut.ConeSize) { conePtSum[j]+=trkEnergy*trackWeight; hCPPt[j]->Fill(trkEnergy,trackWeight); hPtPDR[j]->Fill(trkEnergy,pdr[j],trkEnergy*trackWeight); } // Background Cone if (pdrbg[j]<cut.ConeSize) { hCPPtBg[j]->Fill(trkEnergy,trackWeight); conePtBgSum[j]+=trkEnergy*trackWeight; hPtPDRBg[j]->Fill(trkEnergy,pdrbg[j],trkEnergy*trackWeight); } } } } // end of particles loop // ===================================================== // Fill Cone Sums // ===================================================== for (Int_t j=0; j<2; ++j) { if (jetEvt[j]) { hCPt[j]->Fill(conePtSum[j]); hCPtBg[j]->Fill(conePtBgSum[j]); hCPtBgSub[j]->Fill(conePtSum[j]-conePtBgSum[j]); } } // ===================================================== // Fill Ntuple // ===================================================== Float_t var[100]; var[0]=anaJets_[0].pt(); var[1]=anaJets_[0].eta(); var[2]=anaJets_[0].phi(); var[3]=anaJets_[1].pt(); var[4]=anaJets_[1].eta(); var[5]=anaJets_[1].phi(); var[6]=metx; var[7]=metx0; var[8]=metx1; var[9]=metx2; var[10]=metx3; var[11]=metx4; var[12]=metx5; var[13]=mety; var[14]=mety0; var[15]=mety1; var[16]=mety2; var[17]=mety3; var[18]=mety4; var[19]=mety5; var[20]=metConex; var[21]=metConex0; var[22]=metConex1; var[23]=metConex2; var[24]=metConex3; var[25]=metConex4; var[26]=metConex5; var[27]=metOutOfConex; var[28]=metOutOfConex0; var[29]=metOutOfConex1; var[30]=metOutOfConex2; var[31]=metOutOfConex3; var[32]=metOutOfConex4; var[33]=metOutOfConex5; var[34]=GetEvtMask(); var[35]=cent; var[36]=anaJetDPhi_; var[37]=weight; ntjt->Fill(var); // fit ntuple tjttrk->Fill(); tcone->Fill(); } // End of Main Event Selection // if (Cut(ientry) < 0) continue; } // ===================================================== // Summarize Event Loop // ===================================================== cout << "Total Events: " << numTotEvt << endl; cout << "DiJets Selected w/o Bkg Limit: " << numDJNoBkgLimit << " (same as draw cut unless there is jet eta correction)" << endl; cout << "DiJets Selected: " << numDJ_ << " Reweighted: " << numDJReWeighted_ << endl; for (Int_t j=0; j<2; ++j) { cout << "num Jet" << j << " Selected: " << numJ_[j] << " Reweighted: " << numJReWeighted_[j] << endl; } // ===================================================== // Normalize by Number of Selected Events // ===================================================== hJDPhi->Scale(1./(numDJReWeighted_)); hJDEta->Scale(1./(numDJReWeighted_)); hAj->Scale(1./(numDJReWeighted_)); hCentReWeighted->Scale(1./(numDJReWeighted_)); for (Int_t j=0; j<2; ++j) { hJEt[j]->Scale(1./(numJReWeighted_[j])); hJEta[j]->Scale(1./(numJReWeighted_[j])); hCPPt[j]->Scale(1./numJReWeighted_[j]); hCPPtBg[j]->Scale(1./numJReWeighted_[j]); hCPPtBgSub[j]->Add(hCPPt[j],hCPPtBg[j],1,-1); hCPt[j]->Scale(1./(numJReWeighted_[j])); hCPtBg[j]->Scale(1./(numJReWeighted_[j])); hCPtBgSub[j]->Scale(1./(numJReWeighted_[j])); hPtPDR[j]->Scale(1./(numJReWeighted_[j])); hPtPDRBg[j]->Scale(1./(numJReWeighted_[j])); } }
void Find_Bpt() { double BpT[100]={0},BpTEr[100]={0},JpT[100]={0}; double BpTPlus[100]={0},BpTMinus[100]={0}; //double a0 = 0.604865,a0Er = 0.00790439,a1 = 1.03837, a1Er = 0.00381658; //double a0 = 0.680535 ,a0Er =0.00465789 ,a1 =0.978251 , a1Er =0.0010945 ; //pol1 //double a0 =0.767454,a0Er =0.00637919 ,a1 =0.926482, a1Er =0.00281732; // pol2 // Acceptance //double a0 =0.627337,a0Er =0.0049568,a1 =1.02592, a1Er =0.0010564; // pol1 //double a0 =0.742605,a0Er =0.00714768 ,a1 =0.957962, a1Er =0.00321474; // pol2 //New Acceptance //double a0 = 0.718407,a0Er =0.0106664 ,a1 =1.1037, a1Er =0.00138381; //pol1 double a0 =0.491983 ,a0Er =0.0178676 ,a1 =1.1242, a1Er =0.00296712; //pol1 char OutTextFile[100]; sprintf(OutTextFile,"Find_BpT.txt"); ofstream dataFile(Form(OutTextFile),ios::app); for(int i=1;i<=30;i++) { BpT[i] = a0 + a1*i; BpTPlus[i] = a0 + a0Er + (a1+a1Er)*i; BpTMinus[i] = a0 - a0Er + (a1-a1Er)*i; BpTEr[i] = (BpTPlus[i]-BpTMinus[i])/2.0; //dataFile<<setprecision(4); //if(i==1)dataFile<<" J/#psi pT "<<" B pT "<<endl; //dataFile<<i<<" &"<<BpT[i]<<" /pm "<<BpTEr[i]<<endl; //cout<<i<<" &"<<BpT[i]<<" /pm "<<BpTEr[i]<<endl; //cout<<"==============================================="<<endl; } // Pt bin sizes double pt_bound[100] = {0.0}; double PT[100], DelPT[100]; double YPT[100], DelYPT[100]; int Nptbin = 20; double step =0.5; for (Int_t ih = 0; ih < Nptbin; ih++) { pt_bound[ih] = 1 + step*ih; pt_bound[ih+1] = 1 + step*(ih+1); PT[ih] = (pt_bound[ih] + pt_bound[ih+1])/2.0; DelPT[ih] = (pt_bound[ih+1] - pt_bound[ih])/2.0; } char namePt[500]; char text[100],text1[100],text2[100]; TFile *fpT = new TFile("hist1.root"); // TH2D *JPt_BPt = (TH2D*)fpT->Get("JpTBpTAccpt"); TH2D *JPt_BPt = (TH2D*)fpT->Get("JpTBpT"); new TCanvas; JPt_BPt->Draw("colz"); TH1D *service = (TH1D*)JPt_BPt->ProjectionX("service"); //service->Draw(); //cout<<" service "<<service<<endl; int pt_bin_bound[100]; TH1D *ProfY_BPt[100]; cout<<" J/psi pT " << " B pT Mean "<< " BpT RMS " <<endl; dataFile<<" J/psi pT " << " B pT Mean "<< " BpT RMS " <<endl; for (Int_t ih = 0; ih < Nptbin; ih++) { pt_bin_bound[ih] = service->FindBin(pt_bound[ih]); //cout<<" pt_bin_bound[ih] "<<pt_bin_bound[ih]<<endl; pt_bin_bound[ih+1] = service->FindBin(pt_bound[ih+1]); //cout<<" pt_bin_bound[ih+1] "<<pt_bin_bound[ih+1] -1<<endl; sprintf(namePt,"BPt_%d",ih); ProfY_BPt[ih] = (TH1D*)JPt_BPt->ProjectionY(namePt, pt_bin_bound[ih], pt_bin_bound[ih+1]-1); sprintf(text," %.1f-%.1f ", service->GetBinLowEdge(pt_bin_bound[ih]), service->GetBinLowEdge(pt_bin_bound[ih+1]-1)+service->GetBinWidth(pt_bin_bound[ih+1])); dataFile<<setprecision(2); cout<< text <<" "<< ProfY_BPt[ih]->GetMean()<<" /pm "<< ProfY_BPt[ih]->GetRMS()<< endl<<endl; YPT[ih] = ProfY_BPt[ih]->GetMean(); DelYPT[ih] = ProfY_BPt[ih]->GetRMS(); cout<< text <<" "<< YPT[ih] <<" /pm "<< DelYPT[ih]<< endl<<endl; sprintf(text1," %.1f ", YPT[ih]); sprintf(text2," %.1f ", DelYPT[ih]); dataFile<< text <<" &"<< text1<<" /pm "<< text2<< endl<<endl; /* if(ih ==1 || ih ==4 ||ih ==5 ||ih == 9 ||ih ==14 ||ih ==19 || ih ==29) { new TCanvas; ProfY_BPt[ih]->Draw(); } */ } dataFile.close(); /* TGraphErrors *gr_BpTvsJpT = new TGraphErrors(Nptbin, PT, YPT, DelPT, DelYPT); TF1 *func_BpTvsJpT = new TF1("pol1", pol1, 0, 24, 2); func_BpTvsJpT->SetLineColor(2); gr_BpTvsJpT->Fit("pol1","","",0,24); gr_BpTvsJpT->GetXaxis()->SetRangeUser(0,25); // gr_BpTvsJpT->GetYaxis()->SetRangeUser(0,25); gr_BpTvsJpT->Draw("ap"); func_BpTvsJpT->Draw("same"); */ TGraphErrors *gr_BpTvsJpT = new TGraphErrors(Nptbin, PT, YPT, DelPT, DelYPT); TF1 *func_BpTvsJpT = new TF1("pol1", pol1, 0, 10, 2); func_BpTvsJpT->SetLineColor(2); gr_BpTvsJpT->Fit("pol1","","",0,6); gr_BpTvsJpT->GetXaxis()->SetRangeUser(0,10); gr_BpTvsJpT->Draw("ap"); func_BpTvsJpT->Draw("same"); }
void fit(const char *run="428211_429133_5s", int key=1, int bmin=10, bool draw=true, bool pa=false) { int minentries=1000; gSystem->Exec( Form("mkdir -p %s/SEN%03d",run,key/128) ); gSystem->Exec( Form("mkdir -p %s/SEN%03d",run,key/128) ); int state = findstate(key); printf("state %d\n",state); // data TString inname = Form("%s/adc/HI_KEY%05d.root",run,key); TString outname = Form("HI_KEY%05d",key); TFile *file = new TFile( inname.Data() ); cout << inname.Data() << endl; TH1D *out = (TH1D*) file->Get("out"); double xfit_min=out->GetBinLowEdge(bmin); double xfit_max=122.5; int bmax = out->GetXaxis()->FindBin(xfit_max); int entries = out->Integral(bmin,bmax); if(entries<minentries) { cout << "not enough entries: "; cout << entries << endl; return; } // fit TCanvas *main = new TCanvas("main","main"); int pkt=0; if(pa) pkt = (key%(8*4*12*64))/(4*12*64); TF1 *fitH = GetFit( Form("%s/SEN%03d/%s.dat",run,key/128,outname.Data()) ,pkt,xfit_min); out->Fit(fitH,"MELIR","",xfit_min,xfit_max); TF1 *MIPH1 = GetMIP(fitH,1,kCyan-3); TF1 *MIPH2 = GetMIP(fitH,2,kGreen-3); TF1 *MIPH3 = GetMIP(fitH,3,kOrange-3); TF1 *MIPH4 = GetMIP(fitH,4,kMagenta-3); TF1 *BGR = GetBGR(fitH,xfit_min); double amp = fitH->GetParameter(0); double eamp= fitH->GetParError(0); double lda = fitH->GetParameter(1); double elda= fitH->GetParError(1); double sg1 = fitH->GetParameter(2); double esg1= fitH->GetParError(2); double fr2 = fitH->GetParameter(3); double efr2= fitH->GetParError(3); double fr3 = fitH->GetParameter(4); double efr3= fitH->GetParError(4); double fr4 = fitH->GetParameter(5); double efr4= fitH->GetParError(5); double fr1 = 1 - fr2 - fr3 - fr4; double ncs = fitH->GetChisquare()/fitH->GetNDF(); double ba = fitH->GetParameter(6); double eba= fitH->GetParError(6); double bsl = fitH->GetParameter(7); double ebsl= fitH->GetParError(7); // saving fit ofstream outfit; outfit.open( Form("%s/SEN%03d/%s.dat",run,key/128,outname.Data()) ); outfit << amp << " " << eamp << endl; outfit << lda << " " << elda << endl; outfit << sg1 << " " << esg1 << endl; outfit << fr2 << " " << efr2 << endl; outfit << fr3 << " " << efr3 << endl; outfit << fr4 << " " << efr4 << endl; outfit << ba << " " << eba << endl; outfit << bsl << " " << ebsl << endl; outfit << ncs << endl; outfit.close(); cout << "Parameters saved to "; cout << outname.Data() << ".dat" << endl; // draw if(!draw) return; gStyle->SetOptFit(0); gStyle->SetOptStat(0); out->Draw("HE"); double ymax = out->GetBinContent( out->FindBin(xfit_min) )*1.5; out->GetYaxis()->SetRangeUser(0.5,ymax); out->GetXaxis()->SetRangeUser(-5,125); out->Sumw2(); out->SetLineColor(kBlack); out->SetMarkerStyle(20); out->SetTitle(""); out->GetXaxis()->SetTitle("ADC-PED (a.u.)"); BGR->Draw("SAME"); MIPH1->Draw("SAME"); MIPH2->Draw("SAME"); MIPH3->Draw("SAME"); MIPH4->Draw("SAME"); fitH->SetRange(xfit_min,xfit_max); fitH->Draw("SAME"); TLatex *text = new TLatex(); text->DrawLatex(0, (1.03*(ymax)), inname.Data() ); text->DrawLatex(30, (0.83*(ymax)), Form("Entries %d",entries) ); text->DrawLatex(30, (0.73*(ymax)), Form("State %d",state) ); text->DrawLatex(30, (0.53*(ymax)), Form("#lambda %.1f #pm %.1f",lda,elda) ); text->DrawLatex(30, (0.43*(ymax)), Form("#sigma %.1f #pm %.1f",sg1,esg1) ); text->SetTextColor(kRed-3); text->DrawLatex(30, (0.63*(ymax)), Form("#Chi^{2} / NDF %.2f",ncs) ); text->SetTextColor(kBlue-3); text->DrawLatex(75, (0.73*(ymax)), Form("#Alpha %.0f #pm %.0f",fitH->GetParameter(0),fitH->GetParError(0)) ); text->SetTextColor(kCyan-3); text->DrawLatex(75, (0.63*(ymax)), Form("f_{1} %.2f",fr1) ); text->SetTextColor(kGreen-3); text->DrawLatex(75, (0.53*(ymax)), Form("f_{2} %.2f #pm %.2f",fr2,efr2) ); text->SetTextColor(kOrange-3); text->DrawLatex(75, (0.43*(ymax)), Form("f_{3} %.2f #pm %.2f",fr3,efr3) ); text->SetTextColor(kMagenta-3); text->DrawLatex(75, (0.33*(ymax)), Form("f_{4} %.2f #pm %.2f",fr4,efr4) ); text->SetTextColor(kGray); text->DrawLatex(75, (0.83*(ymax)), Form("b %.2f",bsl) ); text->SetTextColor(kBlack); text->SetTextSize(0.035); text->SetTextColor( kRed-3 ); text->DrawLatex(30, (0.93*(ymax)), "e^{bx} + #Alpha ( f_{1} L_{1}(x) + f_{2} L_{2}(x) + f_{3} L_{3}(x) + f_{4} L_{4}(x))"); main->SaveAs( Form("%s/SEN%03d/%s.eps",run,key/128,outname.Data()), "eps" ); return; }
void figureOutpiover2(int ptBin, double ptCutLo, double ptCutHi, int massBin, double mCutLo, double mCutHi, int etaBin, double etaCutLo, double etaCutHi) { //OPTIONS AND CUTS------------ bool useBlueBeam = false; bool useYellowBeam = true; double PI = 3.14159265359; if (useBlueBeam && useYellowBeam) { cout << "using both beams" << endl; } if (useBlueBeam && !useYellowBeam) { cout << "using blue beam" << endl; } if (!useBlueBeam && useYellowBeam) { cout << "using yellow beam" << endl; } //PION PAIR CUTS: /* double ptCutLo = 4; double ptCutHi = 10; double mCutLo = .4; double mCutHi = 1; double etaCutLo = -1.4; double etaCutHi = 1.4; //*/ //double phiCutLo = -.5; //double phiCutHi = .5; //---------------------------- //LOAD LIBS cout << "\n"; gROOT->Macro("StRoot/LoadLibs.C"); gSystem->Load("pionPair"); cout << " loading of pionPair library done" << endl; //SET UP INPUT FILE //TFile* infile = new TFile("/star/u/klandry/ucladisk/2012IFF/all2012dataAll.root"); //TFile* infile = new TFile("/star/u/klandry/ucladisk/2012IFF/schedOutputWithinRad/allWithRadcut.root"); TFile* infile = new TFile("/star/u/klandry/ucladisk/2012IFF/schedOutAllDataTry1/allDataTry1.root"); //SET UP TREE TO RECEIVE INPUT pionPair* pair1 = new pionPair(); TTree* pairTree = infile->Get("pionPairTree"); pairTree->SetBranchAddress("pionPair", &pair1); //SET UP HISTOGRAMS //event variable histograms TH1D* hInvarM = new TH1D("invarM","invarM",80,0,2); TH1D* hEtaTot = new TH1D("etaTot","etaTot",60,-1.5,1.5); TH1D* hPhiR = new TH1D("hPhiR","hPhiR",60,-4,4); TH1D* hPhiS = new TH1D("hPhiS","hPhiS",60,-4,4); TH1D* hPhiSR = new TH1D("hPhiSR","hPhiSR",60,-4,4); TH1D* hTheta = new TH1D("hTheta","hTheta",30,-0.85,4); TH1D* hCosTheta = new TH1D("hCosTheta","hCosTheta",80,-1,1); TH1D* hZ = new TH1D("hZ","hZ",80,0,1); TH1D* hPtot = new TH1D("hPtot","hPtot",80,0,20); TH1D* hPtTOT = new TH1D("hPt","hPt",80,0,15); //histos for asym analysis double histMin = -PI; double histMax = PI; const int binNumber = 16; TH1D * hNumberUp = new TH1D("hNumberUp","hNumberUp",binNumber,histMin,histMax); TH1D * hNumberDown = new TH1D("hNumberDown","hNumberDown",binNumber,histMin,histMax); TH1D * hDiff = new TH1D("hNumberSum","hNumberSum",binNumber,histMin,histMax); TH1D * hAut = new TH1D("Aut","Aut",binNumber,histMin,histMax); //BEAM POLARIZATION ifstream polFile; polFile.open("/star/u/klandry/ucladisk/2012IFF/BeamPolarization2012.txt"); map<int, double> polarizationOfFill_Y; map<int, double> polErrOfFill_Y; map<int, double> polarizationOfFill_B; map<int, double> polErrOfFill_B; int fill; int beamE; int startT; string plusminus; double pAvrgBlue; double pErrAvrgBlue; double pInitialBlue; double pErrInitialBlue; double dPdTBlue; double dPdTErrBlue; double pAvrgYellow; double pErrAvrgYellow; double pInitialYellow; double pErrInitialYellow; double dPdTYellow; double dPdTErrYellow; string header; for (int i=0; i<19; i++) { polFile >> header; } while (!polFile.eof()) { polFile >> fill; polFile >> beamE; polFile >> startT; polFile >> pAvrgBlue; polFile >> plusminus; polFile >> pErrAvrgBlue; polFile >> pInitialBlue; polFile >> plusminus; polFile >> pErrInitialBlue; polFile >> dPdTBlue; polFile >> plusminus; polFile >> dPdTErrBlue; polFile >> pAvrgYellow; polFile >> plusminus; polFile >> pErrAvrgYellow; polFile >> pInitialYellow; polFile >> plusminus; polFile >> pErrInitialYellow; polFile >> dPdTYellow; polFile >> plusminus; polFile >> dPdTErrYellow; polarizationOfFill_B[fill] = pAvrgBlue/100.; polErrOfFill_B[fill] = pErrAvrgBlue/100.; polarizationOfFill_Y[fill] = pAvrgYellow/100.; polErrOfFill_Y[fill] = pErrAvrgYellow/100.; } double avgPolOfBinUp[binNumber]; double polOfBinSumUp[binNumber]; double avgPerrorOfBinUp[binNumber]; double pErrorOfBinUp[binNumber]; double avgPolOfBinDown[binNumber]; double polOfBinSumDown[binNumber]; double avgPerrorOfBinDown[binNumber]; double pErrorOfBinDown[binNumber]; for (int i=0; i<binNumber; i++) { avgPolOfBinUp[i] = 0; polOfBinSumUp[i] = 0; avgPerrorOfBinUp[i] = 0; pErrorOfBinUp[i] = 0; avgPolOfBinDown[i] = 0; polOfBinSumDown[i] = 0; avgPerrorOfBinDown[i] = 0; pErrorOfBinDown[i] = 0; } // ====================================================================== //============================================================================ //START ANALYSIS============================================================== //============================================================================ // ====================================================================== cout << pairTree->GetEntries() << endl; cout << "\n"; cout << "<----STARTING ANALYSIS---->" << endl; cout << "\n"; double blueFillNo; double yellowFillNo; int bin; TLorentzVector sum; TLorentzVector sumY; TLorentzVector sumB; TRandom3 r; int totalPairsFinal = 0; for (int iPair = 0; iPair < pairTree->GetEntries(); iPair++) { if (iPair%10000 == 0) { cout << "processing pair number " << iPair << endl; } //cout << "processing pair number " << iPair << endl; //if (iPair == 80000){break;} pairTree->GetEntry(iPair); if (pair1->withinRadius(0.05, 0.3)) { bool triggerFired = false; bool fromKaon = false; StTriggerId trigId = pair1->triggerIds(); if (trigId.isTrigger(370601) || trigId.isTrigger(370611) || trigId.isTrigger(370621)) { triggerFired = true; } if (trigId.isTrigger(370501) || trigId.isTrigger(370511) || trigId.isTrigger(370522) || trigId.isTrigger(370531)) { triggerFired = true; } if (pair1->invarientMass() > .4921 && pair1->invarientMass() < .4990) { fromKaon = true; } if (triggerFired) { blueFillNo = pair1->runInfo().beamFillNumber(1); //1 = blue beam yellowFillNo = pair1->runInfo().beamFillNumber(0); //0 = yellow beam //cout << blueFillNo << " " << yellowFillNo << endl; if (polarizationOfFill_B[blueFillNo] == 0 || polarizationOfFill_Y[yellowFillNo] == 0) { continue; } hInvarM->Fill(pair1->invarientMass()); TVector3 spinVec; sum = pair1->piPlusLV() + pair1->piMinusLV(); sumB = sum; //blue beam. //yellow beam must rotate around y axis by pi so the eta cut can be the same for both beams. sumY = sum; sumY.RotateY(PI); double randomSpin = r.Uniform(0, 1); int randomSpinBit; if (randomSpin >=0 && randomSpin <0.25) { randomSpinBit = 5; } if (randomSpin >=0.25 && randomSpin <0.5) { randomSpinBit = 6; } if (randomSpin >=0.5 && randomSpin <0.75) { randomSpinBit = 9; } if (randomSpin >=0.75 && randomSpin <1.0) { randomSpinBit = 10; } //CHECK CUTS if (sumB.Pt() > ptCutLo && sumB.Pt() < ptCutHi && sumB.M() > mCutLo && sumB.M() < mCutHi && sumB.Eta() > etaCutLo && sumB.Eta() < etaCutHi && useBlueBeam == true) { //BLUE BEAM SPIN UP: spin bin 9 and 10 if (pair1->spinBit() == 9 || pair1->spinBit() == 10) { bin = hNumberUp->FindBin(pair1->phiSR('b')); //hNumberUp->Fill(pair1->phiSR('b')); polOfBinSumUp[bin] += polarizationOfFill_B[blueFillNo]; pErrorOfBinUp[bin] += polErrOfFill_B[blueFillNo]; } //BLUE BEAM SPIN DOWN: spin bin 5 and 6 if (pair1->spinBit() == 5 || pair1->spinBit() == 6) { bin = hNumberDown->FindBin(pair1->phiSR('b')); hNumberDown->Fill(pair1->phiSR('b')); polOfBinSumDown[bin] += polarizationOfFill_B[blueFillNo]; pErrorOfBinDown[bin] += polErrOfFill_B[blueFillNo]; } }//end blue cuts TVector3 Pa; Pa.SetXYZ(0, 0, 1); //blue is unpolarized beam TVector3 Pb; Pb.SetXYZ(0, 0, -1); //yellow is polarized beam if (sumY.Pt()>ptCutLo && sumY.Pt() < ptCutHi && sumY.M() > mCutLo && sumY.M() < mCutHi && sumY.Eta() > etaCutLo && sumY.Eta() < etaCutHi && useYellowBeam == true) { //YELLOW BEAM SPIN UP: spin bin 6 and 10 //if (pair1->spinBit() == 6 || pair1->spinBit() == 10) if (randomSpinBit == 6 || randomSpinBit == 10) { totalPairsFinal++; spinVec.SetXYZ(0, 1, 0); TVector3 Ph = pair1->piPlusLV().Vect() + pair1->piMinusLV().Vect(); TVector3 Rh = pair1->piPlusLV().Vect() - pair1->piMinusLV().Vect(); double cosPhi_S = -Pb.Unit().Cross(Ph).Unit() * Pb.Unit().Cross(spinVec).Unit(); double cosPhi_R = Ph.Unit().Cross(Pb).Unit() * Ph.Unit().Cross(Rh).Unit(); double sinPhi_S = Ph.Cross(spinVec) * Pb.Unit() / (Pb.Unit().Cross(Ph).Mag() * Pb.Unit().Cross(spinVec).Mag()); double sinPhi_R = Pb.Cross(Rh) * Ph.Unit() / (Ph.Unit().Cross(Pb).Mag() * Ph.Unit().Cross(Rh).Mag()); double sinPhi_S_R = sinPhi_S*cosPhi_R - cosPhi_S*sinPhi_R; double cosPhi_S_R = cosPhi_S*cosPhi_R + sinPhi_S*sinPhi_R; double phi_S_R; if (cosPhi_S_R >= 0) { phi_S_R = asin(sinPhi_S_R); } else if (cosPhi_S_R < 0) { if (sinPhi_S_R >= 0) { phi_S_R = TMath::Pi() - asin(sinPhi_S_R); } if (sinPhi_S_R < 0) { phi_S_R = -TMath::Pi() - asin(sinPhi_S_R); } } //cout << "phisr = " << phi_S_R << endl; bin = hNumberUp->FindBin(phi_S_R); hNumberUp->Fill(phi_S_R); polOfBinSumUp[bin] += polarizationOfFill_Y[yellowFillNo]; pErrorOfBinUp[bin] += polErrOfFill_Y[yellowFillNo]; } //YELLOW BEAM SPIN DOWN: spin bit 5 and 9 if (randomSpinBit == 5 || randomSpinBit == 9) { totalPairsFinal++; spinVec.SetXYZ(0, -1, 0); TVector3 Ph = pair1->piPlusLV().Vect() + pair1->piMinusLV().Vect(); TVector3 Rh = pair1->piPlusLV().Vect() - pair1->piMinusLV().Vect(); double cosPhi_S = -Pb.Unit().Cross(Ph).Unit() * Pb.Unit().Cross(spinVec).Unit(); double cosPhi_R = Ph.Unit().Cross(Pa).Unit() * Ph.Unit().Cross(Rh).Unit(); double sinPhi_S = Ph.Cross(spinVec) * Pb.Unit() / (Pb.Unit().Cross(Ph).Mag() * Pb.Unit().Cross(spinVec).Mag()); double sinPhi_R = Pa.Cross(Rh) * Ph.Unit() / (Ph.Unit().Cross(Pa).Mag() * Ph.Unit().Cross(Rh).Mag()); double sinPhi_S_R = sinPhi_S*cosPhi_R - cosPhi_S*sinPhi_R; double cosPhi_S_R = cosPhi_S*cosPhi_R + sinPhi_S*sinPhi_R; double phi_S_R; if (cosPhi_S_R >= 0) { phi_S_R = asin(sinPhi_S_R); } else if (cosPhi_S_R < 0) { if (sinPhi_S_R >= 0) { phi_S_R = TMath::Pi() - asin(sinPhi_S_R); } if (sinPhi_S_R < 0) { phi_S_R = -TMath::Pi() - asin(sinPhi_S_R); } } // cout << "phisr = " << phi_S_R << endl; bin = hNumberDown->FindBin(phi_S_R); hNumberDown->Fill(phi_S_R); polOfBinSumDown[bin] += polarizationOfFill_Y[yellowFillNo]; pErrorOfBinDown[bin] += polErrOfFill_Y[yellowFillNo]; } }//end yellow cuts }//end triger check }//end radius check }//end pairTree loop //CALCULATE ASYMMETRY BIN BY BIN cout << "\n"; cout << "<----CALCULATING ASYMMETRY---->" << endl; cout << "\n"; //* for (int ibin=1; ibin<=binNumber; ibin++) { if (ibin <= binNumber*0.5) { double nUp = hNumberUp->GetBinContent(ibin); double nUpPi = hNumberUp->GetBinContent(ibin+binNumber*0.5); double nDown = hNumberDown->GetBinContent(ibin); double nDownPi = hNumberDown->GetBinContent(ibin+binNumber*0.5); cout << nUp << " " << nUpPi << " " << nDown << " " << nDownPi << " " << endl; int binIndexPi = ibin+binNumber*0.5; double avgPolA = (polOfBinSumUp[ibin]+polOfBinSumDown[binIndexPi])/(nUp+nDownPi); double avgPolB = (polOfBinSumUp[binIndexPi]+polOfBinSumDown[ibin])/(nUpPi+nDown); double realAvgPol = (polOfBinSumUp[ibin]+polOfBinSumDown[binIndexPi]+polOfBinSumUp[binIndexPi]+polOfBinSumDown[ibin])/(nUp+nUpPi+nDown+nDownPi); } else { double nUp = hNumberUp->GetBinContent(ibin); double nUpPi = hNumberUp->GetBinContent(ibin-binNumber*0.5); double nDown = hNumberDown->GetBinContent(ibin); double nDownPi = hNumberDown->GetBinContent(ibin-binNumber*0.5); int binIndexPi = ibin-binNumber*0.5; cout << nUp << " " << nUpPi << " " << nDown << " " << nDownPi << " " << endl; double avgPolA = (polOfBinSumUp[ibin]+polOfBinSumDown[binIndexPi])/(nUp+nDownPi); double avgPolB = (polOfBinSumUp[binIndexPi]+polOfBinSumDown[ibin])/(nUpPi+nDown); double realAvgPol = (polOfBinSumUp[ibin]+polOfBinSumDown[binIndexPi]+polOfBinSumUp[binIndexPi]+polOfBinSumDown[ibin])/(nUp+nUpPi+nDown+nDownPi); double realAvgPolE = (pErrorOfBinUp[ibin]+pErrorOfBinDown[binIndexPi]+pErrorOfBinUp[binIndexPi]+pErrorOfBinDown[ibin])/(nUp+nUpPi+nDown+nDownPi); } cout << avgPolA << " " << avgPolB << endl; hDiff->SetBinContent(ibin, sqrt(nUp*nDownPi) - sqrt(nDown*nUpPi)); //hAut->SetBinContent(ibin, (1/avgPolA * sqrt(nUp*nDownPi) - 1/avgPolB * sqrt(nDown*nUpPi)) / (sqrt(nUp*nDownPi) + sqrt(nDown*nUpPi)) ); hAut->SetBinContent(ibin, 1/realAvgPol * (sqrt(nUp*nDownPi) - sqrt(nDown*nUpPi)) / (sqrt(nUp*nDownPi) + sqrt(nDown*nUpPi)) ); //error if (realAvgPol*pow(sqrt(nUp*nDownPi)+sqrt(nDown*nUpPi), 2) != 0) { double a = sqrt(nUp*nDownPi); double b = sqrt(nUpPi*nDown); double firstTerm = realAvgPol**2 * (nUpPi*nDown*(nUp+nDownPi) + nDownPi*nUp*(nUpPi+nDown)); //double secondTerm = ((nUp*nDownPi)**2 +(nUpPi*nDown)**2 - 2*nUp*nDown*nUpPi*nDownPi)*realAvgPolE**2; double secondTerm = 0; double binError = 1/realAvgPol**2 * 1/(a+b)**2 * sqrt(firstTerm + secondTerm); } else { double binError = 0.01; cout << "bin " << ibin << " Has problem with error" << endl; } hAut->SetBinError(ibin, binError); }//end Asym calc //*/ //DRAW HISTOGRAMS hInvarM->Draw(); TCanvas* cNup = new TCanvas(); hNumberUp->Draw(); TCanvas* cNdown = new TCanvas(); hNumberDown->Draw(); TCanvas* cAut = new TCanvas(); cAut->SetName("cAut"); TF1* fitFunc = new TF1("fitFunc","[0]*sin(x)+[1]",-PI,PI); //hAut->Fit("fitFunc","R"); hAut->Draw(); hAut->GetXaxis()->SetTitle("#phi_{S} - #phi_{R}"); char title[150]; sprintf(title, "%.1f < P_{T}^{#pi^{+}#pi^{-}} < %.1f %.1f < M_{inv}^{#pi^{+}#pi^{-}} < %.1f %.1f < #eta^{#pi^{+}#pi^{-}} < %.1f", ptCutLo, ptCutHi, mCutLo, mCutHi, etaCutLo, etaCutHi); hAut->SetTitle(title); //SAVE CANVAS stringstream pt; stringstream eta; stringstream mass; string part1 = "_ptBin"; string part2 = "_massBin"; string part3 = "_etaBin"; string ptBinStr; string etaBinStr; string massBinStr; pt << ptBin; eta << etaBin; mass << massBin; if (ptBin == 9) { ptBinStr = "All"; } else { ptBinStr = pt.str(); } if (massBin == 9) { massBinStr = "All"; } else { massBinStr = mass.str(); } if (etaBin == 9) { etaBinStr = "All"; } else { etaBinStr = eta.str(); } cout << "total pairs " << totalPairsFinal << endl; string outFileName = "./resultsTesting/piover2issue"+part1+ptBinStr+part2+massBinStr+part3+etaBinStr+".root"; TFile* outFile = new TFile(outFileName.c_str(),"Recreate"); cout << "---WRITING FILE---" << endl; //cAut->SaveAs(outFileName.c_str()); hAut->Write(); hNumberUp->Write(); hNumberDown->Write(); cout << "---END---" << endl; }