Example #1
0
//______________________________________________________________________________
void HighlightFragment()
{
  // TODO templates: what and how highlighing
  if (!gPad || !gr) return;

  // not correct
  TVirtualPad *ph = (TVirtualPad *)gPad->FindObject("ph");
  if (!ph) {
    ph = new TPad("ph", "ph", 0.0, 0.2, 1.0, 1.0);
    ph->SetFillColor(kBlue-10);
    ph->Draw();
  }

  Int_t ih = gr->GetHighlightPoint();
  if (ih == -1) return;
  TRsnFragment *frag = group->FragmentAt(ih);
  if (!frag) return;

  TVirtualPad *save = gPad;
  ph->cd();
  TObject *element = frag->FindElement(tagname);
  if (!element) ph->Clear();
  else element->Draw();
  save->cd();
}
Example #2
0
void validation()
{
	msglvl[DBG] = SILENT;
	msglvl[INF] = VISUAL;
	msglvl[WRN] = VISUAL;
	msglvl[ERR] = VISUAL;
	msglvl[FAT] = VISUAL;

	TDirectory* oldDir = gDirectory; // remember old directory

	style();

	Int_t g4bin = (ng4bins/g4max+1); //==> g^4=1 ==> SSM !
	
	TString suffix = "";
	if(doTruth) suffix = "_truth";
	
	TString mctype  = (isMC11c) ? "mc11c" : "mc11a";
	
	// TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_overallEWkF_noInAmpSigEWkF_noHighMbins_wthOfficialZP_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_wthOfficialZP_treeLevelMass_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_mc11c_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_wthOfficialZP_fixedBWwidth_treeLevelMass_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_mc11c_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root";
	// TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_fixedBWwidth_treeLevelMass_Xmass2000.root";

	TLegend* legR = new TLegend(0.15,0.75,0.35,0.85,NULL,"brNDC");
	legR->SetFillStyle(4000); //will be transparent
	legR->SetFillColor(0);
	legR->SetTextFont(42);
	TH1D* hDummy = new TH1D("","",1,0.,1.);
	hDummy->SetMarkerStyle(20);
	hDummy->SetMarkerSize(0.8);
	hDummy->SetMarkerColor(kBlack);
	if(!doResiduals) legR->AddEntry(hDummy,"#frac{template}{official}","lep");
	else             legR->AddEntry(hDummy,"#frac{template - official}{#sqrt{#delta^{2}template + #delta^{2}official}}","lep");
	
	TPaveText* ptxt = new TPaveText(0.145,0.35,0.245,0.55,"NDC");
	TText* txt;
	ptxt->SetTextSize(0.03);
	ptxt->SetBorderSize(0);
	ptxt->SetFillStyle(4000); //will be transparent
	ptxt->SetFillColor(0);
	ptxt->SetTextAlign(12);
	txt = ptxt->AddText("This range");
	txt = ptxt->AddText("is chopped");
	txt = ptxt->AddText("before the");
	txt = ptxt->AddText("template is");
	txt = ptxt->AddText("handed to");
	txt = ptxt->AddText("BAT (limit).");
	
	oldDir->cd();

	TString fBGname = "plots/validation/ZP_2dtemplates_mc11c_33st_noKKtmplates_wthOfficialZP_treeLevelMass_Xmass2000.root";
	TFile* fD = new TFile(fBGname,"READ");
	TH1D* hDY = NULL;
	if(doTruth) hDY = (TH1D*)fD->Get("hMass_DYmumu_truth")->Clone();
	else        hDY = (TH1D*)fD->Get("hMass_DYmumu")->Clone();
	hDY->SetLineColor(kMagenta-5);
	hDY->SetMarkerColor(kMagenta-5);

	oldDir->cd();

	TFile* fDYrozmin    = new TFile("plots/mass_plot_tables_3st.root","READ");
	TH1D* hDYrozmin = (TH1D*)fDYrozmin->Get("mass_log_dy")->Clone();
	hDYrozmin = (TH1D*)hGeV2TeV(hDYrozmin)->Clone();
	hDYrozmin = (TH1D*)hChopper(hDYrozmin,bins2chop)->Clone();
	oldDir->cd();
	TFile* f1dTemplates = new TFile("plots/ZpSignal_MM_MC11c_5points.root","READ");
	TObjArray* toarr1d = new TObjArray();
	toarr1d->Read("template");
	TMapTSP2TH1D h1dBrandeisTmpltMap;
	double Nflat = 399948;
	double sigmaflat = 4.3988E+07*nb2fb;
	double Lmcflat = Nflat/sigmaflat;
	double scale = luminosity/Lmcflat;
	TH1D* h1dTmp = NULL;
	h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(0/*22*/))->Clone();
	h1dTmp->Scale(scale);
	h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone();
	h1dTmp->Add(hDYrozmin);
	h1dBrandeisTmpltMap.insert( make_pair("1000",(TH1D*)resetErrors(h1dTmp)->Clone("1000")) );
	h1dTmp = NULL;
	h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(1/*28*/))->Clone();
	h1dTmp->Scale(scale);
	h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone();
	h1dTmp->Add(hDYrozmin);
	h1dBrandeisTmpltMap.insert( make_pair("1250",(TH1D*)resetErrors(h1dTmp)->Clone("1250")) );
	h1dTmp = NULL;
	h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(2/*34*/))->Clone();
	h1dTmp->Scale(scale);
	h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone();
	h1dTmp->Add(hDYrozmin);
	h1dBrandeisTmpltMap.insert( make_pair("1500",(TH1D*)resetErrors(h1dTmp)->Clone("1500")) );
	h1dTmp = NULL;
	h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(3/*40*/))->Clone();
	h1dTmp->Scale(scale);
	h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone();
	h1dTmp->Add(hDYrozmin);
	h1dBrandeisTmpltMap.insert( make_pair("1750",(TH1D*)resetErrors(h1dTmp)->Clone("1750")) );
	h1dTmp = NULL;
	h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(4/*47*/))->Clone();
	h1dTmp->Scale(scale);
	h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone();
	h1dTmp->Add(hDYrozmin);
	h1dBrandeisTmpltMap.insert( make_pair("2000",(TH1D*)resetErrors(h1dTmp)->Clone("2000")) );

	oldDir->cd();

	TMapTSP2TH1D h1Map;
	h1Map.insert( make_pair("1000o", (TH1D*)fD->Get("hMass_Zprime_SSM1000"+suffix)->Clone()) );
	h1Map.insert( make_pair("1000t", (TH1D*)fD->Get("hMass_Zprime_SSM1000_template"+suffix)->Clone()) );
	if(isMC11c)
	{
		h1Map.insert( make_pair("1250o", (TH1D*)fD->Get("hMass_Zprime_SSM1250"+suffix)->Clone()) );
		h1Map.insert( make_pair("1250t", (TH1D*)fD->Get("hMass_Zprime_SSM1250_template"+suffix)->Clone()) );
	}
	h1Map.insert( make_pair("1500o", (TH1D*)fD->Get("hMass_Zprime_SSM1500"+suffix)->Clone()) );
	h1Map.insert( make_pair("1500t", (TH1D*)fD->Get("hMass_Zprime_SSM1500_template"+suffix)->Clone()) );
	h1Map.insert( make_pair("1750o", (TH1D*)fD->Get("hMass_Zprime_SSM1750"+suffix)->Clone()) );
	h1Map.insert( make_pair("1750t", (TH1D*)fD->Get("hMass_Zprime_SSM1750_template"+suffix)->Clone()) );
	h1Map.insert( make_pair("2000o", (TH1D*)fD->Get("hMass_Zprime_SSM2000"+suffix)->Clone()) );
	h1Map.insert( make_pair("2000t", (TH1D*)fD->Get("hMass_Zprime_SSM2000_template"+suffix)->Clone()) );

	TMapTSP2TH1D h1rMap;
	h1rMap.insert( make_pair("1000", (TH1D*)fD->Get("hMass_Zprime_SSM1000"+suffix)->Clone()) );
	if(isMC11c) h1rMap.insert( make_pair("1250", (TH1D*)fD->Get("hMass_Zprime_SSM1250"+suffix)->Clone()) );
	h1rMap.insert( make_pair("1500", (TH1D*)fD->Get("hMass_Zprime_SSM1500"+suffix)->Clone()) );
	h1rMap.insert( make_pair("1750", (TH1D*)fD->Get("hMass_Zprime_SSM1750"+suffix)->Clone()) );
	h1rMap.insert( make_pair("2000", (TH1D*)fD->Get("hMass_Zprime_SSM2000"+suffix)->Clone()) );
	for(TMapTSP2TH1D::iterator it=h1rMap.begin() ; it!=h1rMap.end() ; ++it)
	{
		it->second->Reset();
		if(!doResiduals) it->second->Divide(h1Map[it->first+"o"],h1Map[it->first+"t"],1.,1.,"B");
		else             residuals(h1Map[it->first+"o"], h1Map[it->first+"t"], it->second);
		
		// for(Int_t i=0 ; i<=it->second->GetNbinsX()+1 ; i++) it->second->SetBinError(i,0);
		it->second->SetMarkerStyle(20);
		it->second->SetMarkerSize(0.5);
		it->second->GetXaxis()->SetLabelSize(0.073);
		it->second->GetYaxis()->SetLabelSize(0.073);
		it->second->GetXaxis()->SetTitleSize(0.073);
		it->second->GetYaxis()->SetTitleSize(0.073);
		it->second->SetTitleSize(0.075);
		it->second->GetYaxis()->SetTitleOffset(0.5);
		if(!doResiduals)
		{
			it->second->SetMinimum(0.2);
			it->second->SetMaximum(1.8);
		}
		else
		{
			it->second->SetMinimum(-5.);
			it->second->SetMaximum(+5.);
		}
		it->second->SetTitle("");
		if(!doResiduals) it->second->GetYaxis()->SetTitle("ratio");
		else             it->second->GetYaxis()->SetTitle("residuals");
	}

	TMapTSP2TGAE poissonGraphMap;
	TMapTSP2TLeg legMap;


	_INFO("");

	oldDir->cd();

	fD->cd();	
	TH1D* h1Template = (TH1D*)fD->Get("hMass_DYmumu"+suffix)->Clone();
	h1Template->Reset();
	TObjArray* toarr = new TObjArray();
	if(doTruth) toarr->Read("truth_template2d");
	else        toarr->Read("template2d");
	TH2D* h2SSM2000 = (TH2D*)((TObjArray*)toarr->At(0))->Clone("hMass"+suffix+"_Zprime_SSM2000_template2d");
	for(Int_t bin=1 ; bin<=h2SSM2000->GetNbinsX() ; bin++)
	{
		h1Template->SetBinContent(bin, h2SSM2000->GetBinContent(bin,g4bin));
		h1Template->SetBinError(bin, h2SSM2000->GetBinError(bin,g4bin));
	}
	h1Template->SetLineColor(kViolet);
	h1Template->SetLineWidth(1);
	h1Template->SetMarkerStyle(20);
	h1Template->SetMarkerSize(0.3);
	h1Template->SetMarkerColor(kViolet);
	// the functions
	h2Template = (TH2D*)h2SSM2000->Clone();
	vector<TF1*> vfunc;
	unsigned int nmllbins = h2Template->GetNbinsX();
	for(unsigned int mll=1 ; mll<=(nmllbins-bins2chop) ; mll++) // 1...(56-9 = 47)
	{
		TString mllname = (TString)_s(mll);
		TString mllval  = (TString)_s(h2Template->GetXaxis()->GetBinCenter(mll+bins2chop));
		
		TF1* f = new TF1("fNominal_mll"+mllname,fTH1toTF1,g4min,g4max,1);
		f->SetParameter(0,mll);
		f->SetParNames("mll");
		// f->SetLineColor(kBlue);
		// f->SetLineWidth(1);
		f->SetNpx(400);
		vfunc.push_back(f);
	}
	TGraph* graphDY = new TGraph();
	graphDY->SetMarkerStyle(25);
	graphDY->SetMarkerSize(0.6);
	graphDY->SetMarkerColor(kGreen+2);
	TGraph* graphSSM = new TGraph();
	graphSSM->SetMarkerStyle(24);
	graphSSM->SetMarkerSize(0.6);
	graphSSM->SetMarkerColor(kOrange+8);
	for(unsigned int i=0 ; i<vfunc.size() ; i++)
	{
		double DY = vfunc[i]->Eval(0.0);
		double SSM = vfunc[i]->Eval(1.0);
		graphDY->SetPoint(i,h2Template->GetXaxis()->GetBinCenter(bins2chop+i+1),DY);
		graphSSM->SetPoint(i,h2Template->GetXaxis()->GetBinCenter(bins2chop+i+1),SSM);
	}
	
	
	oldDir->cd();

	TObjArray* toarr1dTLV = new TObjArray();
	TMapTSP2TH1D h1dTlvTmpltMap;
	TFile* fT = NULL;
	TString fTname = "plots/validation/ZP_2dtemplates_mc11c_33st_noInterference_noKKtmplates_noOverallEWkF_wthOfficialZP_treeLevelMass_Xmass";
	
	fT = new TFile(fTname+"1000.root","READ");
	toarr1dTLV->Read("template");
	h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone();
	h1dTmp->Add(hDY);
	h1dTlvTmpltMap.insert( make_pair("1000",(TH1D*)resetErrors(h1dTmp)->Clone("1000")) );
	fT = new TFile(fTname+"1250.root","READ");
	toarr1dTLV->Read("template");
	h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone();
	h1dTmp->Add(hDY);
	h1dTlvTmpltMap.insert( make_pair("1250",(TH1D*)resetErrors(h1dTmp)->Clone("1250")) );
	fT = new TFile(fTname+"1500.root","READ");
	toarr1dTLV->Read("template");
	h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone();
	h1dTmp->Add(hDY);
	h1dTlvTmpltMap.insert( make_pair("1500",(TH1D*)resetErrors(h1dTmp)->Clone("1500")) );
	fT = new TFile(fTname+"1750.root","READ");
	toarr1dTLV->Read("template");
	h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone();
	h1dTmp->Add(hDY);
	h1dTlvTmpltMap.insert( make_pair("1750",(TH1D*)resetErrors(h1dTmp)->Clone("1750")) );
	fT = new TFile(fTname+"2000.root","READ");
	toarr1dTLV->Read("template");
	h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone();
	h1dTmp->Add(hDY);
	h1dTlvTmpltMap.insert( make_pair("2000",(TH1D*)resetErrors(h1dTmp)->Clone("2000")) );

	oldDir->cd();
	
	
	for(TMapTSP2TH1D::iterator it=h1Map.begin() ; it!=h1Map.end() ; ++it)
	{
		if(it->first.Contains("o"))
		{
			TString name = it->first;
			name.ReplaceAll("o","");
			it->second->SetFillColor(kAzure-9);
			if(doTruth) it->second->SetTitle("m_{Z'} = "+name+" GeV (truth)");
			else        it->second->SetTitle("m_{Z'} = "+name+" GeV");
		}
		if(it->first.Contains("t"))
		{
			//TGraphAsymmErrors* poisson(TH1D* h)
			it->second->SetLineColor(kBlue);
			it->second->SetMarkerStyle(20);
			it->second->SetMarkerSize(0.4);
			it->second->SetMarkerColor(kBlue);
			it->second->SetLineWidth(1);
			
			TString name = it->first;
			name.ReplaceAll("t","");
			poissonGraphMap.insert( make_pair(name, (TGraphAsymmErrors*)poisson(it->second)->Clone()) );
			poissonGraphMap[name]->SetMarkerStyle(20);
			poissonGraphMap[name]->SetMarkerSize(0.3);
			poissonGraphMap[name]->SetMarkerColor(kBlue);
			poissonGraphMap[name]->SetLineWidth(1);
			poissonGraphMap[name]->SetLineColor(kBlue);
		}
	}	

	Double_t yLine = (!doResiduals) ? 1. : 0.;

	TLine* line = new TLine(0.07,yLine,3.,yLine);	
	line->SetLineColor(kRed);
	line->SetLineWidth(2);
	
	TMapTSP2TCNV cnvMap;
	cnvMap.insert( make_pair("1000", new TCanvas("1000","1000",600,550)) );
	if(isMC11c) cnvMap.insert( make_pair("1250", new TCanvas("1250","1250",600,550)) );
	cnvMap.insert( make_pair("1500", new TCanvas("1500","1500",600,550)) );
	cnvMap.insert( make_pair("1750", new TCanvas("1750","1750",600,550)) );
	cnvMap.insert( make_pair("2000", new TCanvas("2000","2000",600,550)) );
	for(TMapTSP2TCNV::iterator it=cnvMap.begin() ; it!=cnvMap.end() ; ++it)
	{
		_INFO("starting "+(string)it->first);
		if(it->first=="2000") legMap.insert( make_pair(it->first, new TLegend(0.35,0.55,0.83,0.84,NULL,"brNDC")) );
		else                  legMap.insert( make_pair(it->first, new TLegend(0.35,0.60,0.83,0.84,NULL,"brNDC")) );
		legMap[it->first]->SetFillStyle(4000); //will be transparent
		legMap[it->first]->SetFillColor(0);
		legMap[it->first]->SetTextFont(42);
		legMap[it->first]->AddEntry(h1Map[it->first+"o"],"Official Z'_{SSM}","F");
		legMap[it->first]->AddEntry(hDY,"Official DY#mu#mu","lep");
		legMap[it->first]->AddEntry(h1Map[it->first+"t"],"ME^{2} method: Template w/o couplings scale","lep");
		if(it->first=="2000")
		{
			legMap[it->first]->AddEntry(h1Template,"ME^{2} method: Template histogram at  #it{g=1} (SSM)","lep");
			legMap[it->first]->AddEntry(graphSSM,  "ME^{2} method: Template function  at  #it{g=1} (SSM)","p");
			legMap[it->first]->AddEntry(graphDY,   "ME^{2} method: Template function  at  #it{g=0} (DY)","p");
		}
		if(!doTruth)
		{
			h1dTlvTmpltMap[it->first]->SetLineColor(kCyan+2);
			h1dTlvTmpltMap[it->first]->SetMarkerColor(kCyan+2);
			h1dTlvTmpltMap[it->first]->SetMarkerStyle(5);
			h1dTlvTmpltMap[it->first]->SetMarkerSize(0.5);
			legMap[it->first]->AddEntry(h1dTlvTmpltMap[it->first],"ME^{2} method: DY+Template (no interference)","p");
		
			h1dBrandeisTmpltMap[it->first]->SetLineColor(kRed);
			h1dBrandeisTmpltMap[it->first]->SetMarkerColor(kRed);
			h1dBrandeisTmpltMap[it->first]->SetMarkerStyle(27);
			h1dBrandeisTmpltMap[it->first]->SetMarkerSize(0.5);
			legMap[it->first]->AddEntry(h1dBrandeisTmpltMap[it->first],"Flat Z' method: DY+Template (no interference)","p");
		}

		it->second->Divide(1,2);
		TVirtualPad* ph = it->second->cd(1);
		TVirtualPad* pr = it->second->cd(2);	
		ph->SetPad(0.00, 0.35, 1.00, 1.00);
		pr->SetPad(0.00, 0.00, 1.00, 0.35);
		ph->SetBottomMargin(0.012);
		pr->SetBottomMargin(0.20);
		pr->SetTopMargin(0.012);
		
		ph->cd();
		ph->Draw();
		ph->SetTicks(1,1);
		ph->SetLogy();
		ph->SetLogx();
		// h1Map[it->first+"o"]->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 );
		// h1Map[it->first+"o"]->Draw();
		TH1D* hTmpNoErr = (TH1D*)resetErrors(h1Map[it->first+"o"])->Clone();
		hTmpNoErr->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 );
		hTmpNoErr->SetLineStyle(1);
		hTmpNoErr->SetLineColor(kBlack);
		hTmpNoErr->SetFillColor(kAzure-9);
		hTmpNoErr->Draw();
		TH1D* hTmpErr = (TH1D*)ShiftLog(h1Map[it->first+"o"],0.2)->Clone();
		hTmpErr->SetFillStyle(4000); //will be transparent
		hTmpErr->SetFillColor(0);
		hTmpErr->DrawCopy("epx0SAMES");
		hDY->Draw("SAMES");
		h1Map[it->first+"t"]->Draw("epSAMES");
		//poissonGraphMap[it->first]->Draw("pSAMES");
		if(it->first=="2000")
		{
			graphDY->Draw("SAMESp");
			graphSSM->Draw("SAMESp");
			h1Template->Draw("epSAMES");
		}
		_INFO("");
		h1dTlvTmpltMap[it->first]->Draw("SAMESp");
		h1dBrandeisTmpltMap[it->first]->Draw("SAMESp");
		
		TLine* chopline = new TLine(0.12805,getYmin(h1Map[it->first+"o"]),0.12805,7.e5);
		chopline->SetLineStyle(2);
		chopline->SetLineColor(kBlack);
		chopline->Draw("SAMES");
		ptxt->Draw("SAMES");
		
		legMap[it->first]->Draw("SAMES");
		ph->RedrawAxis();
		ph->Update();

		_INFO("");

		pr->cd();
		pr->Draw();
		pr->SetTicks(1,1);
		pr->SetGridy();
		pr->SetLogx();
		h1rMap[it->first]->Draw("ep");
		line->Draw("SAMES");
		h1rMap[it->first]->Draw("epSAMES");
		legR->Draw("SAMES");
		pr->RedrawAxis();
		pr->Update();

		unsigned int savestate = 1;
		if(it->first=="1000")      savestate = 0;
		else if(it->first=="2000") savestate = 2;
		else                       savestate = 1;
		TString testType = (doResiduals) ? "_residuals" : "_ratio";
		mutype   = (doTruth)     ? "_truth"     : "_recon";
		savemultipdf(it->second, "plots/validation/validation"+mutype+testType+"_"+mctype+"_all.pdf", savestate);
		saveas(it->second, "plots/validation/validation"+mutype+testType+"_"+mctype+"_"+it->first);
		
		TCanvas* c = new TCanvas(it->first,"",600,400);
		c->cd();
		c->Draw();
		c->SetTicks(1,1);
		c->SetLogy();
		c->SetLogx();
		hTmpNoErr->Draw();
		hTmpErr->DrawCopy("epx0SAMES");
		hDY->Draw("SAMES");
		h1Map[it->first+"t"]->Draw("epSAMES");
		//poissonGraphMap[it->first]->Draw("pSAMES");
		if(it->first=="2000")
		{
			graphDY->Draw("SAMESp");
			graphSSM->Draw("SAMESp");
			h1Template->Draw("epSAMES");
		}
		h1dTlvTmpltMap[it->first]->Draw("SAMESp");
		h1dBrandeisTmpltMap[it->first]->Draw("SAMESp");
		legMap[it->first]->Draw("SAMES");
		chopline->Draw("SAMES");
		ptxt->Draw("SAMES");
		c->RedrawAxis();
		c->Update();
		saveas(c,"plots/validation/validation_"+it->first+"_"+mutype+testType);
		
		_INFO("done "+(string)it->first);
	}
}
Example #3
0
void plot(char* v, int run, int cut, TCanvas* cvs, int fit=0, int bin1=-1, int bin2=-1, float ymax=0.0, int rebin=0){   
    int bin0=1;
    char c[100];
    char c2[100];
    readfile(OPT,run);
    gStyle->SetOptStat(0);
    gStyle->SetOptFit(0);
    gStyle->SetOptTitle(0);
    cvs->Clear();
    int b1=bin1, b2=bin1+1, b3=bin2, b4=b3;
    if(bin1<0) {cvs->Divide(kNPtBin-bin0,kNPtBin-bin0); b1=bin0; b2=kNPtBin; b3=bin0;}
    float ptcut[kNPtBin+1]={0.5,1.0,1.5,2.0,2.5,3.0,10.0};
    memset(PAR,0,sizeof(PAR));
    TText* t;
    for(int i=b1; i<b2; i++){
	if(bin1<0) b4=i;
	for(int j=b3; j<=b4; j++){
	    int cc=cut;
	    if(cut==99 && (v=="m1" || v=="m2")) cc=0;
	    if(cut==99 && v=="dphi") cc=1;
	    TH1F *h,*h2,*h3,*h4;
	    TH2F *h2d;

	    //get normalizations
	    float norm0=1.0;
	    float norm1=1.0;
	    float norm2=1.0;
	    float norm3=1.0;
	    if(v=="m0" || v=="phi0"){}
	    else{
		sprintf(c,"m0_%1d_c%d",i,cc);
		TH1F* h0 = (TH1F*)mTFile->Get(c);
		norm0 = h0->GetEntries();
		sprintf(c,"m2_%1d%1d_c%d",i,j,cc);
		TH1F* h1 = (TH1F*)mTFile->Get(c);
		norm1 = h1->GetEntries();
		printf("n0=%d n1=%d\n",norm0,norm1);
		norm2=norm1/norm0;
		norm3=norm2/ZggCut;
	    }

	    int opt=1, log=0;
	    if(v=="mix"){
		h3=mix(run,cc,i,j,0,1,h,h2);
		h1->SetLineColor(1);
		h2->SetLineColor(6);
	    }else if(v=="corr"){
		h = mix(run,cc,i,j,0,1);
		if(rebin>0) h->Rebin(rebin);
		if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0);
		int nbin = h->GetNbinsX();
                h->Sumw2();
                if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);}
                else       {h->Scale(1.0/norm0*nbin/2.0/PI);}
	    }else if(v=="norm"){
		sprintf(c,"dphi_%1d%1d_c%d",i,j,cc);
                h = (TH1F*)mTFile->Get(c);
		if(rebin>0) h->Rebin(rebin);
		if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0);
		int nbin = h->GetNbinsX();
		h->Sumw2();
		if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);}
		else       {h->Scale(1.0/norm0*nbin/2.0/PI);}
	    }else if(v=="mall"){
		sprintf(c,"m0_%1d_c%d",i,0);
		sprintf(c2,"m0_%1d%1d_c%d",i,j,0);
		h4 = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2);
		float norm4 = h4->Integral(h4->GetXaxis()->FindBin(MassCut0),h4->GetXaxis()->FindBin(MassCut1));
		h4->Scale(norm1/norm4);
		h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2);
		sprintf(c,"m0_%1d_c%d",i,cc);
		sprintf(c2,"m0_%1d%1d_c%d",i,j,cc);
		h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2); h->SetLineColor(6);
		h->Scale(norm2); 
		sprintf(c,"m1_%1d%1d_c%d",i,j,cc);
                h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(2);
		sprintf(c,"m2_%1d%1d_c%d",i,j,cc); 
                h3 = (TH1F*)mTFile->Get(c); h3->SetLineColor(4);	   
	    }else if(v=="z12"){
		sprintf(c,"z1_%1d%1d_c%d",i,j,cc);
                h = (TH1F*)mTFile->Get(c); h->SetLineColor(2);
		sprintf(c,"z2_%1d%1d_c%d",i,j,cc); 
                h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(4);
	    }else if(v=="m0" || v=="phi0"){
		sprintf(c,"%s_%1d_c%d",v,i,cc);
		printf("%s\n",c);
		h = (TH1F*)mTFile->Get(c);		
	    }else if(v=="bbce"){
		opt=1;
		log=1;
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
		printf("%s\n",c);
		h = (TH1F*)mTFile->Get(c);		
		h->SetMinimum(0.1);
	    }else if(v=="phi1" || v=="phi2"){
		opt=1;
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
		printf("%s\n",c);
		h = (TH1F*)mTFile->Get(c);		
	    }else if(v=="phi1dphi"){
		opt=2;
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
		printf("%s\n",c);
		h = (TH1F*)mTFile->Get(c);		
	    }else{
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
		printf("%s\n",c);
		h = (TH1F*)mTFile->Get(c);		
	    }
	    if(bin1<0){
		TVirtualPad *pad = cvs->cd((i-bin0)*(kNPtBin-bin0)+(j-bin0)+1);
		pad->SetRightMargin(0.01);
		pad->SetLeftMargin(0);
		pad->SetTopMargin(0);
		pad->SetBottomMargin(0.01);
		pad->Draw();		
	    }
	    h->SetMinimum(0.0);
	    if(ymax>0.0) h->SetMaximum(ymax);
	    if(opt==0) h->Draw("e");
	    if(opt==1) h->Draw();
	    if(opt==2) h->Draw("colz");
	    if(v=="mall"){
		h4->Draw("same");
		h2->Draw("same");
		h3->Draw("same");
	    }
	    if(v=="z12" || v=="mix") h2->Draw("same");
	    TF1* f;
	    if((v=="norm" || v=="corr") && fit==1){
		f=new TF1("oneGaus",oneGaus,+PI/2.0,+PI*3.0/2.0,3);
		f->SetParameters(norm3/10.0,norm3/2.0,0.3);
		f->SetParNames("Const","IntFar","SigFar");
		f->SetParLimits(0,0.0,1.0);
		f->SetParLimits(1,0.0,1.0);
		f->SetParLimits(2,0.0,3.0);
		f->SetLineColor(2); f->SetLineWidth(1);
		h->Fit("oneGaus","Q");
		PAR[i][j][0]=f->GetParameter(0);
		PAR[i][j][1]=f->GetParameter(1);
		PAR[i][j][2]=f->GetParameter(2);
		printf("norm=%8.6f Int=%8.6f IntFar=%8.6 SigFar=%6.3f C=%8.6f\n",
		       norm3,PAR[i][j][1]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][2],PAR[i][j][0]);
	    }
	    if((v=="norm" || v="corr") && fit==2){
		f=new TF1("twoGaus",twoGaus,-PI/2.0,+PI*3.0/2.0,5);
		f->SetParameters(norm3/10.0,norm3/2.0,0.3,norm3/2.0,0.3);
		f->SetParNames("Const","IntNear","SigNear","IntFar","SigFar");
		f->SetParLimits(0,0.0,1.0);
		f->SetParLimits(1,0.0,1.0);
		f->SetParLimits(2,0.0,3.0);
		f->SetParLimits(3,0.0,1.0);
		f->SetParLimits(4,0.0,3.0);
		f->SetLineColor(2); f->SetLineWidth(1);
		h->Fit("twoGaus","Q");
		PAR[i][j][0]=f->GetParameter(0);
		PAR[i][j][1]=f->GetParameter(1);
		PAR[i][j][2]=f->GetParameter(2);
		PAR[i][j][3]=f->GetParameter(3);
		PAR[i][j][4]=f->GetParameter(4);
		printf("norm=%8.6f Int=%8.6f IntNear=%8.6f IntFar=%8.6f SigNear=%6.3f  SigFar=%6.3f C=%8.6f\n",
		       norm3,PAR[i][j][1]+PAR[i][j][3]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][3],
		       PAR[i][j][2],PAR[i][j][4],PAR[i][j][0]);
	    }

	    float xx=0.60, yy=0.85, dy=0.04, size=0.04;
	    if(bin1<0){xx=0.45, yy=0.90, dy=0.08, size=0.08;}
	    if(v=="z12") {xx=0.1; yy=0.35;}
	    t = new TText(xx, yy,    Form("pT1=%3.1f-%3.1f",ptcut[i],ptcut[i+1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
	    t = new TText(xx, yy-dy, Form("pT2=%3.1f-%3.1f",ptcut[j],ptcut[j+1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
	    if(norm3>0.0){
		t = new TText(xx, yy-dy*2, Form("P=%7.5f",norm3)); t->SetNDC(); t->SetTextSize(size); t->Draw();
	    }
	    if((v=="norm" || v="corr")  && fit==1){
		t = new TText(xx, yy-dy*3, Form("PBg=%7.5f",  PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*5, Form("Saway=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw();
	    }
	    if((v=="norm" || v="corr")  && fit==2){
		t = new TText(xx, yy-dy*3, Form("Pnear=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][3])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*5, Form("PBg=%7.5f",  PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*6, Form("Snear=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw();
		t = new TText(xx, yy-dy*7, Form("Saway=%4.2f",PAR[i][j][4])); t->SetNDC(); t->SetTextSize(size); t->Draw();
	    }
	    if(cut==88) h->SetLineColor(2);
	    if(cut==99 && (v=="m1"|| v=="m2")){
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,1);
		h = (TH1F*)mTFile->Get(c);
		h->SetLineColor(4);
		h->Draw("same");
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,2);
		h = (TH1F*)mTFile->Get(c);
		h->SetLineColor(2);
		h->Draw("same");
	    }
	    if(cut==99 && v=="dphi"){
		h->SetLineColor(4);
		sprintf(c,"%s_%1d%1d_c%d",v,i,j,2);
                h = (TH1F*)mTFile->Get(c);
                h->SetLineColor(2);
                h->Draw("same");		
	    }
	    if(bin1>0){
		t = new TText(0.1, 0.92,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(1); t->Draw();
		if     (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d_bin%d%d.png",v,cut,i,j);}
		else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d_bin%d%d.png",v,cut,i,j);}
		else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d_bin%d%d.png",v,cut,i,j);}
		else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d_bin%d%d.png",v,cut,i,j);}
		else                       {sprintf(c,"plot/dipi0_%d_%s_c%d_bin%d%d.png",run,v,cut,i,j);}
		printf("Saving %s\n",c);
		cvs->SaveAs(c);	       
	    }
	}
    }
    if(bin1<0){
	cvs->cd(2);
	t = new TText(0.0, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(1); t->Draw();
    }
    if(v=="mall"){
	t = new TText(0.05, 0.65,"M1(no mass, scaled)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(1); t->Draw();
	t = new TText(0.05, 0.55,"M1(without M2)/P"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(6); t->Draw();
	t = new TText(0.05, 0.45,"M1(with M2)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw();
	t = new TText(0.05, 0.35,"M2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw();
    }
    if(v=="z12"){
	t = new TText(0.05, 0.65,"Zgg1"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw();
	t = new TText(0.05, 0.55,"Zgg2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw();
    }
    if(cut==99) {
	t = new TText(0.0, 0.65, "Inclusive Pair");  t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(4); t->Draw();
	t = new TText(0.0, 0.45, "Exclusive Pair");  t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(2); t->Draw();
    }
    if(bin1<0){
	if     (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d.png",v,cut);}
	else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d.png",v,cut);}
	else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d.png",v,cut);}
	else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d.png",v,cut);}
	else                       {sprintf(c,"plot/dipi0_%d_%s_c%d.png",run,v,cut);}
	printf("Saving %s\n",c);
	cvs->SaveAs(c);
    }
}