示例#1
0
void FindFuncsLT(){
	TGraph * FNegvsLT = new TGraph();
    FNegvsLT->SetName("FNegvsLT");
	double par[3] = {mtop, MW, mB};
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FNeg(x, par)<<endl;
		FNegvsLT->SetPoint(i, (i*0.001), FNeg(x, par));
	}
	FNegvsLT->SaveAs("FNegvsLT.C");

	TGraph * FPosvsLT = new TGraph();
    FPosvsLT->SetName("FPosvsLT");
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FR(x, par)<<endl;
		FPosvsLT->SetPoint(i, (i*0.001), FR(x, par));
	}
	FPosvsLT->SaveAs("FPosvsLT.C");



	TGraph * FZerovsLT = new TGraph();
    FZerovsLT->SetName("FZerovsLT");
	for(int i = 0; i<1000; i++){
	    double x[4] = {1, 0, i*0.001, 0};
		cout<<x[1]<<"\t"<<FZero(x, par)<<endl;
		FZerovsLT->SetPoint(i, (i*0.001), FZero(x, par));
	}
	FZerovsLT->SaveAs("FZerovsLT.C");
}
示例#2
0
void readValues(){

  TFile *f = new TFile("L1L2Eff_final.root");
 // TDirectory *d = (TDirectory*)f->Get("tpTree/BMuQualSoft_pt_eta_Mu5_Track2/fit_eff_plots");
 // if(!d) std::cout << "directory not available" << std::endl;
  int N = 0;
  //string name;
  //name.Format("gEff_DATA_PT_AETA%i",N);
  TGraph *g = (TGraph*)f->Get("gEff_DATA_PT_AETA0");
  if(!g)std::cout << "TGraph is sunbathing." << std::endl;

  int n = g->GetN();
  std::cout << n << " points in graph" << std::endl;
  const char title = g->GetTitle();
  //const char savename = "Effplots/"+title+".C";  
  //std::cout<<savename<<std::endl;
  g->SaveAs("grph");

  // put loop over points here
 // for(int i = 0; i < n; i++){
    // check which bin the pt is in

 // } //iPT
  f->Close();
}
示例#3
0
TList* getContours(const TH2* hist,double contourLevel,const TString filename)
{
  TH2* h = (TH2*)hist->Clone("_clone");
  double limitValue[1] = {contourLevel};
  h->SetContour(1,limitValue);
  TCanvas* c = new TCanvas("contour_canvas","Contour List",0,0,600,600);
  h->Draw("CONT LIST");
  c->Update();
  TList* contours = (TList*)((TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"))->At(0);
  TGraph* contour = (TGraph*)contours->First();
  if(filename!="") 
    {
      for(unsigned int j = 0; j < contours->GetSize(); j++)
	{
	  TString newFilename = filename+"_";
	  newFilename+=j;
	  contour->SaveAs(newFilename+".C");
	  contour = (TGraph*)contours->After(contour); // Get Next graph
	}
    }
  delete h;
  delete c;
  return contours;
}
示例#4
0
TTree *ToyTree(TString dirname="test/dato/fitres/Hgg_Et-toys/0.01-0.00", TString fname="outProfile-scaleStep2smearing_7-Et_25-trigger-noPF-EB.root", TString opt="", int nSmooth=10){
  TString outDir=dirname; outDir.ReplaceAll("fitres","img");
  outDir="tmp/";
  //std::map<TString, TH2F *> deltaNLL_map;

  //bool smooth=false;
  //if(opt.Contains("smooth")) smooth=true;
  

  /*------------------------------ Plotto */
  TCanvas c("ctoy","c");
  
  
  TTree *toys = new TTree("toys","");
  toys->SetDirectory(0);
  Double_t constTerm_tree, constTermTrue_tree;
  Double_t alpha_tree, alphaTrue_tree;
  char catName[100]; 
  Int_t catIndex;
  toys->Branch("constTerm", &constTerm_tree, "constTerm/D");
  toys->Branch("alpha", &alpha_tree, "alpha/D");
  toys->Branch("constTermTrue", &constTermTrue_tree, "constTermTrue/D");
  toys->Branch("alphaTrue", &alphaTrue_tree, "alphaTrue/D");

  toys->Branch("catName", catName, "catName/C");
  toys->Branch("catIndex", &catIndex, "catIndex/I");
  std::map<TString, Int_t> catIndexMap;

  ///1/
  for(int itoy =2; itoy <= 50; itoy++){
    TString filename=dirname+"/"; filename+=itoy; filename+="/"+fname;
    TString fout=dirname+"/"; fout+=itoy; fout+="/";    
    TFile f_in(filename, "read");
    if(f_in.IsZombie()){
      std::cerr << "File opening error: " << filename << std::endl;
      continue; //return NULL;
    }
    //std::cout << filename << std::endl;
    TList *KeyList = f_in.GetListOfKeys();
    //std::cout << KeyList->GetEntries() << std::endl;
    for(int i =0; i <  KeyList->GetEntries(); i++){
      c.Clear();
      TKey *key = (TKey *)KeyList->At(i);
      if(TString(key->GetClassName())!="RooDataSet") continue;
      RooDataSet *dataset = (RooDataSet *) key->ReadObj();
    
      TString constTermName = dataset->GetName();
      TString alphaName=constTermName; alphaName.ReplaceAll("constTerm","alpha");
      if(constTermName.Contains("scale")) continue;
      if(constTermName.Contains("alpha")) continue;
      if(constTermName.Contains("1.4442-gold")) continue;
      TTree *tree = dataset2tree(dataset);

      TGraph *rhoGraph = GetRho(tree, alphaName, constTermName);

      rhoGraph->SaveAs(fout+"rhoGraph-"+constTermName+".root");


      TGraphErrors bestFit_ = bestFit(tree, alphaName, constTermName);
      //TString binning="(241,-0.0005,0.2405,61,-0.00025,0.03025)"; //"(40,0.00025,0.02025,61,-0.0022975,0.1401475)";
      TString binning="(241,-0.0005,0.2405,301,-0.00005,0.03005)"; 

      TH2F *hist = prof2d(tree, constTermName, alphaName, "nll", binning, true, nSmooth, opt);
      //hist->SaveAs("myhist.root");
      
      Int_t iBinX, iBinY;
      hist->GetBinWithContent2(0.0002,iBinX,iBinY,1,-1,1,-1,0.0000001);
	
      //      if(iBinX!=0 && iBinY!=0 && iBinX < 41 && iBinY < 62){
      {
	TString catName_=constTermName; catName_.ReplaceAll("constTerm_",""); catName_.ReplaceAll("-","_");
	if(catIndexMap.count(catName_)==0) catIndexMap.insert(std::pair<TString,Int_t>(catName_,catIndexMap.size()));
	catIndex=catIndexMap[catName_];	
	constTerm_tree =  hist->GetYaxis()->GetBinCenter(iBinY);
	alpha_tree = hist->GetXaxis()->GetBinCenter(iBinX);
	sprintf(catName,"%s", catName_.Data());
	bestFit_.GetPoint(0, constTermTrue_tree,alphaTrue_tree);
// 	std::cout << constTerm_tree << " " << constTermTrue_tree 
// 		  << "\t" << alpha_tree << " " << alphaTrue_tree 
// 		  << std::endl;

	if(opt.Contains("scandiff")){
	  constTermTrue_tree = getMinimumFromTree(tree, "nll",TString(constTermName).ReplaceAll("-","_"));
	} else       if(opt.Contains("scan")){
	  constTerm_tree = getMinimumFromTree(tree, "nll",TString(constTermName).ReplaceAll("-","_"));
	}
	//std::cout << iBinX << "\t" << iBinY << "\t" << constTerm_tree - getMinimumFromTree(tree, "nll",TString(constTermName).ReplaceAll("-","_")) << std::endl;
	
	toys->Fill();
//       }else{
// 	hist->SaveAs("myhist.root");
// 	exit(0);
      }

      
      delete tree;
      delete hist;
    
    }
    f_in.Close();
  }
  //toys->SaveAs("tmp/toysTree.root");
  

  return toys;
}