Esempio n. 1
0
void drawROC(TString& type, TString& ytitle, TString& xtitle, TString& head, TString &leg1, TString& leg2, TString& leg3, TString & leg4){
  TCanvas *c = new TCanvas(Form("%s",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
  SetStyleCanvas(c);

  TGraphAsymmErrors *grae1ROCdetrel = new TGraphAsymmErrors();
  TGraphAsymmErrors *grae1ROCdettrk = new TGraphAsymmErrors();
  TGraphAsymmErrors *grae1ROCpf = new TGraphAsymmErrors();
  TGraphErrors *grae1ROCLKT = new TGraphErrors();
  
  ROCDetectorRelIsoData(grae1ROCdetrel);
  ROCDetectorTrkIsoData(grae1ROCdettrk);
  ROCParticleIsoData(grae1ROCpf);

  TGraphErrors *graeTbkgData = new TGraphErrors();
  TGraphErrors *graeTsigData = new TGraphErrors();
  EffLKTIsoData(graeTsigData);
  SetDataQCDEffLKT(graeTbkgData);
  grae1ROCLKT = getROC(graeTsigData, graeTbkgData);

  //ROCLKTIsoData(grae1ROCLKT);
 
  //limit trk ROC to 10 points 
  grae1ROCdettrk = getModifiedROC(grae1ROCdettrk, 10);
 
  TGraphAsymmErrors *temp = new TGraphAsymmErrors();
  temp=getTemp(1, 14);
  SetStyleGraphErrors(temp, 2, 23, 0, 0.0,  ytitle, xtitle, 0.77, 1.02);

  SetStyleGraphErrors(grae1ROCdetrel, 2, 23, 0, 0.8,  ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCdettrk, 3, 22, 0, 0.8, ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCpf, 4, 20, 0, 0.8, ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCLKT, 6, 20, 0, 0.8, ytitle, xtitle, 0.8, 1.1);

  //draw error band *****
  grae1ROCdetrel->SetFillColor(2);
  grae1ROCdetrel->SetFillStyle(3001);

  grae1ROCdettrk->SetFillColor(3);
  grae1ROCdettrk->SetFillStyle(3001);

  grae1ROCpf->SetFillColor(4);
  grae1ROCpf->SetFillStyle(3001);
  //end draw error band *****

  temp->Draw("APC");
  grae1ROCdetrel->Draw("3CPSame");
  grae1ROCdettrk->Draw("3CPSame");
  grae1ROCpf->Draw("3CPSame");
  grae1ROCLKT->Draw("PSame");

  SetLegend(grae1ROCpf, grae1ROCdetrel, grae1ROCdettrk, grae1ROCLKT, "Data", leg1, leg2, leg3, leg4, "PL","PL","PL","P",0.6, 0.20, 0.9,0.50);
  SetLabel(0.19,0.88,36);

  c->Print(Form("%s.eps",type.Data()));
}
Esempio n. 2
0
void draw(TString& type, TString& ytitle, TString& xtitle, TString& head,  double min, double max, TString &leg1, TString& leg2, TString &leg3 = ""){
   TCanvas *c = new TCanvas(Form("%s",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
   SetStyleCanvas(c);

   TGraphAsymmErrors *grae1data = new TGraphAsymmErrors();
   TGraphAsymmErrors *grae1mc = new TGraphAsymmErrors();
   TGraphAsymmErrors *grae2data = new TGraphAsymmErrors();
   TGraphAsymmErrors *grae2mc = new TGraphAsymmErrors();
   TGraphAsymmErrors *grae1sf = new TGraphAsymmErrors();
   TGraphAsymmErrors *grae2sf = new TGraphAsymmErrors();

   TGraphErrors *grae1LKTdata = new TGraphErrors();
   TGraphErrors *grae1LKTmc = new TGraphErrors();
   TGraphErrors *grae1LKTsf = new TGraphErrors();

   int datacolor1 = 1;
   int datacolor2 = 1;

   //ISO
   if( type.Contains("cEffPFBaseISO") ){
     EffParticleIsoData(grae1data);
     EffParticleIsoMC(grae1mc);
     grae1sf = getSF(grae1data, grae1mc);
   }else if ( type.Contains("cEffDETBaseISOrel")){
     EffDetectorRelIsoData(grae1data);
     EffDetectorRelIsoMC(grae1mc);
     EffLKTIsoData(grae1LKTdata);
     EffLKTIsoMC(grae1LKTmc);
     grae1LKTmc->RemovePoint(0);
     grae1LKTdata->RemovePoint(0);
     grae1sf = getSF(grae1data, grae1mc);
     grae1LKTsf = getSF(grae1LKTdata, grae1LKTmc);
   }else if ( type.Contains("cEffDETBaseISOtrk")){
     EffDetectorTrkIsoData(grae1data);
     EffDetectorTrkIsoMC(grae1mc);
     grae1data->RemovePoint(0);
     grae1mc->RemovePoint(0);
     EffLKTTrkIsoData(grae1LKTdata);
     EffLKTTrkIsoMC(grae1LKTmc);
     grae1sf = getSF(grae1data, grae1mc);
     grae1LKTsf = getSF(grae1LKTdata, grae1LKTmc);
   }

  //PT
   if( type.Contains("cEffPFBasePT") ){
     datacolor1 = 2;
     datacolor2 = 4;
     SetEffPFPt(grae1data, grae1mc);
     SetEffPFPt3(grae2data, grae2mc);
     grae1sf = getSF(grae1data, grae1mc);
     grae2sf = getSF(grae2data, grae2mc);
   }else if( type.Contains("cEffDETBasePTrel") ){
     datacolor1 = 2;
     datacolor2 = 4;
     SetEffDetPtRel10(grae1data, grae1mc);
     SetEffDetPtRel15(grae2data, grae2mc);
     SetEffLKTPt(grae1LKTmc, grae1LKTdata);
     grae1sf = getSF(grae1data, grae1mc);
     grae2sf = getSF(grae2data, grae2mc);
     grae1LKTsf = getSF(grae1LKTdata, grae1LKTmc);
   }else if( type.Contains("cEffDETBasePTtrk") ){
     datacolor1 = 2;
     datacolor2 = 4;
     SetEffDetPtTrk05(grae1data, grae1mc);
     SetEffDetPtTrk10(grae2data, grae2mc);
     SetEffLKTTrkPt(grae1LKTmc, grae1LKTdata);
     grae1sf = getSF(grae1data, grae1mc);
     grae2sf = getSF(grae2data, grae2mc);
     grae1LKTsf = getSF(grae1LKTdata, grae1LKTmc);
   }

   //ROC
   if( type.Contains("cROCPFBaseIso")){
     ROCParticleIsoData(grae1data);
     ROCParticleIsoMC(grae1mc);
   }else if ( type.Contains("cROCDETBaseIsorel")){
     ROCDetectorRelIsoData(grae1data);
     ROCDetectorRelIsoMC(grae1mc);
     //data LKT
     //ROCLKTIsoData(grae1LKTdata);
     TGraphErrors *graeTbkgData = new TGraphErrors();
     TGraphErrors *graeTsigData = new TGraphErrors();
     EffLKTIsoData(graeTsigData);
     SetDataQCDEffLKT(graeTbkgData);
     grae1LKTdata = getROC(graeTsigData, graeTbkgData);
     //mc LKT
     TGraphErrors *graeTbkg = new TGraphErrors();
     TGraphErrors *graeTsig = new TGraphErrors();
     EffLKTIsoMC(graeTsig);
     SetMCQCDEffLKT(graeTbkg);
     grae1LKTmc = getROC(graeTsig, graeTbkg);
   }else if ( type.Contains("cROCDETBaseIsotrk")){
     ROCDetectorTrkIsoData(grae1data);
     ROCDetectorTrkIsoMC(grae1mc);
   }

   SetStyleGraphErrors(grae1data, datacolor1, 20, 0, 0.9, ytitle, xtitle, min, max);
   SetStyleGraphErrors(grae2data, datacolor2, 20, 0, 0.9, ytitle, xtitle, min, max);
   SetStyleGraphErrors(grae1mc, 2, 21, 0, 0.9, ytitle, xtitle, min, max);
   SetStyleGraphErrors(grae1LKTdata, 4, 24, 0, 0.9, ytitle, xtitle, min, max);
   SetStyleGraphErrors(grae1LKTmc, 6, 20, 0, 0.9, ytitle, xtitle, min, max);

   TGraphAsymmErrors *temp = new TGraphAsymmErrors();
   temp = getTemp(1,27);

   //ISO draw
   if( type.Contains("cEffPFBaseISO") || type.Contains("cEffDETBaseISO") ){
     SetStyleGraphErrors(temp, 2, 23, 0, 0.0,  ytitle, xtitle, min, max);
     temp->Draw("APC");
     if( type.Contains("cEffPFBaseISO") ){
       grae1data->Draw("PCSame");
       grae1mc->Draw("PCSame");
       SetLegend(grae1data, grae1mc, head, leg1, leg2, "PL", "PL");
     }else if ( type.Contains("cEffDETBaseISO") ) {
       grae1data->Draw("PCSame");
       grae1mc->Draw("PCSame");
       grae1LKTdata->Draw("PSame");
       grae1LKTmc->Draw("PSame");
       clearXErrorBar(grae1LKTdata);
       clearXErrorBar(grae1LKTmc);
       SetLegend(grae1data, grae1mc, grae1LKTdata, grae1LKTmc, head, leg1, leg2, "LKT Data", "LKT MC", "PL","PL","P","P",0.6, 0.20, 0.9,0.50);
     }
   }

   //PT draw
   if( type.Contains("cEffPFBasePT") ){
     grae1data->Draw("AP");
     grae2data->Draw("PSame");
     SetLegend(grae1data, grae2data, head, leg1, leg2, "PL", "PL");
   }else if( type.Contains("cEffDETBasePT") ){
     grae1data->Draw("APSame");
     grae2data->Draw("PSame");
     grae1LKTdata->Draw("PSame");
     SetLegend(grae1data, grae2data, grae1LKTdata, head, leg1, leg2, leg3, "PL", "PL", "P");
   }

   //ROC draw
   if( type.Contains("ROC") ){
     SetStyleGraphErrors(temp, 2, 23, 0, 0.0,  ytitle, xtitle, min, max);
     if( type.Contains("cROCPFBaseIso") || type.Contains("cROCDETBaseIsotrk") ){
       grae1data->Draw("APC");
       grae1mc->Draw("PCSame");
       SetLegend(grae1data, grae1mc, head, leg1, leg2, "PL", "PL");
     }else if ( type.Contains("cROCDETBaseIsorel") ) {
       grae1data->Draw("APC");
       grae1mc->Draw("PCSame");
       grae1LKTdata->Draw("PSame");
       grae1LKTmc->Draw("PSame");
       clearXErrorBar(grae1LKTdata);
       clearXErrorBar(grae1LKTmc);
       SetLegend(grae1data, grae1mc, grae1LKTdata, grae1LKTmc, head, leg1, leg2, "LKT Data", "LKT MC", "PL","PL","P","P",0.6, 0.20, 0.9,0.50);
     }
   }
   SetLabel(0.6,0.6,36);
   c->Print(Form("%s.eps",type.Data()));

   //SF for pt
   if (type.Contains("cEffPFBasePT") || type.Contains("cEffDETBasePT") ){ 
     TCanvas *c_sf = new TCanvas(Form("%sSF",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
     SetStyleCanvas(c_sf);

     min = 0.75;
     max = 1.2;
     SetStyleGraphErrors(grae1sf, 2, 20, 0, 0.9, "Data/MC", xtitle, min, max);
     SetStyleGraphErrors(grae2sf, 4, 20, 0, 0.9, "Data/MC", xtitle, min, max);
     SetStyleGraphErrors(grae1LKTsf, 4, 24, 0, 0.9, "Data/MC", xtitle, min, max);

     if( type.Contains("cEffPFBasePT") ){
       grae1sf->Draw("AP");
       grae2sf->Draw("PSame");
       SetLegend(grae1sf, grae2sf, head, leg1, leg2, "PL", "PL");
     }else if( type.Contains("cEffDETBasePT") ){
       grae1sf->Draw("APSame");
       grae2sf->Draw("PSame");
       grae1LKTsf->Draw("PSame");
       SetLegend(grae1sf, grae2sf, grae1LKTsf, head, leg1, leg2, leg3, "PL", "PL", "P");
     }
     SetLabel(0.6,0.88,36);
     c_sf->Print(Form("%sSF.eps",type.Data()));
   }

   //SF for efficiency
   if ( type.Contains("cEffPFBaseISO") || type.Contains("cEffDETBaseISO") ){
     TCanvas *c_sf = new TCanvas(Form("%sSF",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
     SetStyleCanvas(c_sf);
     min = 0.93;
     max = 1.07;
     SetStyleGraphErrors(grae1sf, 2, 20, 0, 0.9, "Data/MC", xtitle, min, max);
     SetStyleGraphErrors(grae1LKTsf, 4, 24, 0, 0.9, "Data/MC", xtitle, min, max);

     SetStyleGraphErrors(temp, 2, 23, 0, 0.0,  "Data/MC", xtitle, min, max);
     temp->Draw("AP");

     if( type.Contains("cEffPFBaseISO") ){
       grae1sf->Draw("PSame");
       SetLegend(grae1sf, head, "T&P",  "PL");
     }else if( type.Contains("cEffDETBaseISO") ){
       grae1sf->Draw("PSame");
       grae1LKTsf->Draw("PSame");
       SetLegend(grae1sf, grae1LKTsf, head, "T&P", "LKT", "PL", "P");
     }
     SetLabel(0.6,0.88,36);
     c_sf->Print(Form("%sSF.eps",type.Data()));
   }
}
Esempio n. 3
0
	void OutputInfo::outputROC(InputData* pData, BaseLearner* pWeakHypothesis)
	{
		const int numClasses = pData->getNumClasses();
		const int numExamples = pData->getNumExamples();

		vector< int > fp( numClasses );   
		fill( fp.begin(), fp.end(), 0 );

		table& g = _gTableMap[pData];
		vector<Label>::const_iterator lIt;

		//// Building the strong learner (discriminant function)
		//for (int i = 0; i < numExamples; ++i)
		//{
		//	const vector<Label>& labels = pData->getLabels(i);
		//
		//	for (lIt = labels.begin(); lIt != labels.end(); ++lIt )
		//	{
		//		g[i][lIt->idx] += pWeakHypothesis->getAlpha() * // alpha
		//			pWeakHypothesis->classify( pData, i, lIt->idx ); 
		//	}
		//}

		//vector< double > scores( numExamples );
		//vector< int > labels( numExamples );

		vector< pair< int, float > > data( numExamples );

		vector< double > ROCscores( numClasses );
		fill( ROCscores.begin(), ROCscores.end(), 0.0 );
		double ROCsum = 0.0;

		for( int i=0; i < numClasses; i++ ) {
			if ( 0 < pData->getNumExamplesPerClass( i ) ) {
				
				//fill( labels.begin(), labels.end(), 0 );
				double mn = numeric_limits< double >::max();
				double mx = numeric_limits< double >::min();
				
				

				for( int j = 0; j < numExamples; j++ ) {
					data[j].second = g[j][i];
					
					if ( mn > data[j].second ) mn = data[j].second;
					if ( mx < data[j].second ) mx = data[j].second;					

					if ( pData->hasPositiveLabel( j, i ) ) data[j].first = 1;
					else data[j].first = 0;
				}
				
				mx -= mn;
				if ( mx > numeric_limits<double>::epsilon() ) {
					for( int j = 0; j < numExamples; j++ ) {
						data[j].second -= mn;
						data[j].second /= mx; 
					}
				}

				ROCscores[i] = getROC( data );
			} else {
				ROCscores[i] = 0.0;
			}

			ROCsum += ROCscores[i];
		}
		ROCsum /= (double) numClasses;
		
		_outStream << '\t' << ROCsum; // mean of AUC
		for( int i=0; i < numClasses; i++ ) {
			_outStream << '\t' << ROCscores[i];
		}

	}