void collectContours(map<string,TGraph2D *>& m_graphs, const vector<string>& keys, map<string,double>& m_contourlevels, map<string,TList *>& m_contours) { cout << "CollectContours" << endl; TCanvas *canv = new TCanvas("dummy","dummy",100,100); //canv->Divide(3,2); std::cout << "keys.size() = " << keys.size() << std::endl; //process TGraph2Ds into contours at levels m_contourlevels for (size_t i=0; i<keys.size(); i++) { double clev = m_contourlevels[keys[i]]; TGraph2D *gr2d = m_graphs[keys[i]]; std::cout << "gr2d = " << gr2d << std::endl; std::cout << "gr2d->GetN() = " << gr2d->GetN() << std::endl; if (gr2d && (gr2d->GetN() > 0)) { gr2d->GetHistogram()->SetContour(1, &clev); //canv->cd(i+1); cout << "drawing... " << endl; gr2d->Draw("CONT LIST"); // it's stupid, but only "CONT" will generate the list gPad->Update(); TObjArray *contours = (TObjArray *)gROOT->GetListOfSpecials()->FindObject("contours"); assert(contours); TList *newlist = 0; for (int ci=0; ci<contours->GetEntriesFast(); ci++) { TList *contLevel = (TList*)contours->At(ci); printf("%s: Contour %d has %d Graphs\n", keys[i].c_str(), ci, contLevel->GetSize()); if (contLevel->GetSize()) { assert(contLevel->First()); if (!newlist) newlist = new TList(); TGraph *curv = (TGraph*)(contLevel->First()); for (int j=0; j<contLevel->GetSize(); j++) { newlist->Add((TGraph *)(curv->Clone())); curv=(TGraph *)(contLevel->After(curv)); } } } // contour loop cout << "Inserting contour list for "<< keys[i] << " newlist="<<newlist<<endl; m_contours[keys[i]] = newlist; } // if (gr2d) } // key loop //delete canv; } // collectContours
void compareHistos( char *Current, char *Reference=0 ) { TText* te = new TText(); te->SetTextSize(0.1); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/Mixing"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects std::cout << " object :" << object->GetName() << std::endl; TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName())); TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile"); std::cout << " isHisto = " << isHisto << std::endl; if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare std::cout << " Start draw and compare" << std::endl; TCanvas c1; TProfile htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); h1->SetMarkerColor(3); htemp2.SetLineStyle(5); htemp2.SetMarkerColor(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); sprintf(title,"%s%s", object->GetName(),".gif"); c1.Print(title); } // go to next object object = list->After(object); } }
TList PlotAlignmentValidation::getTreeList() { TList treeList = new TList(); TFile *first_source = (TFile*)sourcelist->First(); std::cout<<first_source->GetName()<<std::endl; TDirectoryFile *d=(TDirectoryFile*)first_source->Get( treeBaseDir.c_str() ); treeList.Add( (TTree*)(*d).Get("TkOffVal") ); if( moreThanOneSource ==true ){ TFile *nextsource = (TFile*)sourcelist->After( first_source ); while ( nextsource ) { std::cout<<nextsource->GetName()<<std::endl; d=(TDirectoryFile*)nextsource->Get("TrackerOfflineValidation"); treeList.Add((TTree*)(*d).Get("TkOffVal")); nextsource = (TFile*)sourcelist->After( nextsource ); } }return treeList; }
void DoCompare( char *Current, char *Reference=0 ){ TText* te = new TText(); te->SetTextSize(0.1); gROOT->ProcessLine(".x HistoCompare.C"); HistoCompare * myPV = new HistoCompare(); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName())); TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F"); if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare TCanvas c1; TH1F htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); htemp2.SetLineStyle(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); myPV->PVCompute(h1,&htemp2, te); sprintf(title,"%s%s", object->GetName(),".eps"); c1.Print(title); } // go to next object object = list->After(object); } }
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; }
void plotMSSM(const TString& what="(ggA+bbA)*BRAZh*BRhbb"){ const double BRZll=0.06726; const double fb2pb=1000; //TString scale(Form("*%f*%f",BRZll,fb2pb)); TString scale(""); TString cname(what); cname.ReplaceAll("*","x"); cname.ReplaceAll("(","U"); cname.ReplaceAll(")","U"); cname+="_MSSM_mhmax"; // TString goodName(what); goodName.ReplaceAll("mh","m_{h}"); goodName.ReplaceAll("ggA","#sigma_{gg#rightarrowA}"); goodName.ReplaceAll("bbA","#sigma_{bb#rightarrowA}"); goodName.ReplaceAll("BRAZh","B(A#rightarrowZh)"); goodName.ReplaceAll("BRhbb","B(h#rightarrowbb)"); //goodName+=("*B(Z#rightarrowll)"); //goodName+=("[pb] "); goodName+=("[GeV] "); TString goodType("MSSM m_{h}^{max}"); //goodName=("#sigma*B(pp#rightarrowA#rightarrowZh#rightarrowllbb) [fb]"); //goodName=("#sigma*B(pp#rightarrowA) [fb]"); //goodName=("BR(A#rightarrowZh)"); //goodName=("BR(h#rightarrowbb)"); //if (m>0) mass=(Form(" * (mA==%d)",m)); //TString ok(" * validity * stability * perturbativity * unitarity "); //TString ok(" * unitarity"); TString ok(""); TChain* ch=new TChain("TreeMSSM"); ch->Add("lsf_working_dir_M225_20636539/parameter_MSSM.root"); ch->Add("lsf_working_dir_M250_20636540/parameter_MSSM.root"); ch->Add("lsf_working_dir_M275_20636541/parameter_MSSM.root"); ch->Add("lsf_working_dir_M300_20636542/parameter_MSSM.root"); ch->Add("lsf_working_dir_M325_20636543/parameter_MSSM.root"); ch->Add("lsf_working_dir_M350_20636544/parameter_MSSM.root"); ch->Add("lsf_working_dir_M400_20636545/parameter_MSSM.root"); ch->Add("lsf_working_dir_M500_20636546/parameter_MSSM.root"); ch->Add("lsf_working_dir_M600_20636547/parameter_MSSM.root"); //double tanbeta[30]={1,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,400,500,600,700,800,900,1000,1100,10000}; //double tanbeta[51]={0,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,480,500,550,600,650,700,750,800,850,900,950,1000,1100,1200,1300,1400,1500,2000,3000,4000,5000,6000}; double tanbeta[51]={0,10,20,30,40,50,60,70,80,90,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,420,440,460,500,550,580,600,650,700,750,800,850,900,950,1000,1100,1200,1300,1400,1500,2000,3000,4000,5000,6000}; Double_t bin_tb[50]; for (unsigned int i=0; i<50; i++) { bin_tb[i]=0.005*(tanbeta[i]+tanbeta[i+1]); //cout << "bin_tb[" << i << "]=" << bin_tb[i] << " " << tanbeta[i+1]/100. << endl; } double mA[11]={200,225,250,275,300,325,350,400,500,600,700}; Double_t bin_mA[10]; for (unsigned int i=0; i<=10; ++i) { bin_mA[i]=0.5*(mA[i]+mA[i+1]); //cout << "bin_mA["<<i<<"]=" << bin_mA[i] << endl; } bin_mA[10]=650; TH2F* hggA=new TH2F("hggA","ggA cross section vs tan#beta,m_{A}; m_{A} GeV; tan#beta",9,bin_mA,49,bin_tb); hggA->Sumw2(); //hggA->Draw(); TString cut=what+scale+ok; cout << "CUT: " << cut << endl; ch->Project("hggA","tb:mA",cut); TStyle *tdrStyle = gROOT->GetStyle("tdrStyle"); // Double_t level[15]={.01,.02,.05,.1,.2,.5,1.,2.,5.,10.,20.,50.,100.,200.,500.}; // hggA->SetContour(14,level); // hggA->SetMinimum(level[0]); // //Double_t level[10]={1.,5.,10.,20.,50.,100.,200.,500.,800.,1000.}; // for x-section //Double_t level[10]={100,105,110.,115.,120.,123,125.7,127,130.,135.}; // for mh Double_t level[10]={1,2,3.,4.,120.,123,125.7,127,130.,135.}; // for mh //Double_t level[10]={.01,.1,.2,0.5,0.6,0.65,0.7,0.75,0.8,0.9}; // for BR //Double_t level[10]={.01,.02,.05,.07,.1,.15,0.2,0.5,0.75,1.}; // for BR hggA->SetContour(9,level); hggA->SetMinimum(level[0]); Double_t level[7]={122.7.,123.7,125.4,126.0,127.7,128.7.,150}; // for mh hggA->SetContour(6,level); hggA->SetMinimum(90); Int_t colors[7] = {kWhite,kGreen,kGreen+2,kBlack,kGreen+2,kGreen,kWhite}; tdrStyle->SetPalette((sizeof(colors)/sizeof(Int_t)), colors); // DRAW tdrStyle->SetOptStat(0); // tdrStyle->SetPadGridX(true); // tdrStyle->SetPadGridY(true); // tdrStyle->SetPadTopMargin(0.05); // tdrStyle->SetPadBottomMargin(0.13); tdrStyle->SetTitleYOffset(1.3); tdrStyle->SetTitleXOffset(1.6); tdrStyle->SetTitleOffset(1.3,"Z"); // tdrStyle->SetOptLogz(1); // tdrStyle->SetOptLogy(1); tdrStyle->SetPadRightMargin(0.14); //tdrStyle->SetPalette(1); tdrStyle->cd(); gROOT->ForceStyle(); cout << "Creating canvas " << cname << endl; TCanvas* c1=new TCanvas(cname,goodName,1200,600); cout << " done " << c1->GetName() << endl; c1->Divide(2); c1->cd(1); hggA->DrawCopy("lego2"); gPad->SetLogz(); gPad->SetLogy(); //gPad->SetPhi(120); gPad->SetPhi(-150); //gPad->SetTheta(30); gPad->UseCurrentStyle(); gPad->Update(); TLatex tl; tl.SetTextSize(0.04); tl.SetNDC(); tl.DrawLatex(0.1,0.95,goodName); tl.SetTextAlign(11); tl.DrawLatex(0.1,0.89,goodType); c1->cd(2); // tdrStyle->SetPadLeftMargin(0.25); gPad->UseCurrentStyle(); gPad->Update(); hggA->GetXaxis()->SetTitleOffset(1.1); hggA->GetYaxis()->SetTitleOffset(1.1); hggA->GetZaxis()->SetTitleOffset(100); //hggA->Smooth(); gPad->SetLogy(kFALSE); hggA->DrawCopy("zcont1"); tl.DrawLatex(0.15,0.97,goodName); tl.SetTextAlign(11); tl.DrawLatex(0.2,0.9,goodType); TCanvas* ctmp=new TCanvas(cname,goodName,600,600); hggA->GetYaxis()->SetRangeUser(0.1,10.); hggA->DrawCopy("zcont1"); tl.DrawLatex(0.83,0.97,goodName); tl.SetTextAlign(11); tl.DrawLatex(0.2,0.9,goodType); pCan(ctmp,cname+"_Lin"); // TH1F* test=new TH1F("test","ggA cross section vs tan#beta; tan#beta",27,bin_tb); // ch->Project("test","tb",what); // test->Draw(); TCanvas* c2=new TCanvas(cname+"Obs",goodName,800,800); gPad->UseCurrentStyle(); gPad->Update(); hggA->GetXaxis()->SetTitleOffset(1.1); hggA->GetYaxis()->SetTitleOffset(1.1); hggA->DrawCopy("cont list"); gPad->Update(); //return; // Get Contours TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); TList* contLevel = NULL; TGraph* curv = NULL; TGraph* gc = NULL; Int_t nGraphs = 0; Int_t TotalConts = 0; if (conts == NULL){ printf("*** No Contours Were Extracted!\n"); TotalConts = 0; return; } else { TotalConts = conts->GetSize(); } printf("TotalConts = %d\n", TotalConts); for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); printf("Contour %d has %d Graphs\n", i, contLevel->GetSize()); nGraphs += contLevel->GetSize(); } nGraphs = 0; TH2F *hr = new TH2F("hr", ";m_{A};tan#beta", 2, 225, 600, 2, 0.1, 100); hr->GetXaxis()->SetTitleOffset(1.1); hr->GetXaxis()->SetRangeUser(200,650); hr->GetYaxis()->SetTitleOffset(1.2); hr->GetYaxis()->SetNdivisions(110,kFALSE); hr->GetXaxis()->SetNdivisions(20205,kFALSE); hr->Draw(); Double_t x0, y0, z0; TLatex l; l.SetTextSize(0.03); l.SetTextAlign(32); char val[20]; for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); z0 = level[i]; printf("Z-Level Passed in as: Z = %f\n", z0); // Get first graph from list on curves on this level curv = (TGraph*)contLevel->First(); for(j = 0; j < contLevel->GetSize(); j++){ // last point //curv->GetPoint(curv->GetN()-1, x0, y0); // first point curv->GetPoint(2, x0, y0); // if (z0<0) curv->SetLineColor(kRed); // if (z0>0) curv->SetLineColor(kBlue); nGraphs ++; printf("\tGraph: %d -- %d Elements\n", nGraphs,curv->GetN()); // Draw clones of the graphs to avoid deletions in case the 1st // pad is redrawn. gc = (TGraph*)curv->Clone(); gc->Draw("C"); if (z0>=.01) sprintf(val,"%0.2f",z0); if (z0>=.1) sprintf(val,"%0.2f",z0); if (z0>=1) sprintf(val,"%0.0f",z0); l.DrawLatex(x0*0.99,y0,val); curv = (TGraph*)contLevel->After(curv); // Get Next graph } } gPad->SetLogy(); gPad->SetGridx(); gPad->SetGridy(); gPad->SetRightMargin(0.05); gPad->SetTopMargin(0.10); c2->Update(); printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs ); tl.SetTextAlign(31); tl.DrawLatex(0.8,0.85,goodName); tl.SetTextAlign(31); tl.DrawLatex(0.8,0.77,goodType); pCan(c2,cname+"_BW"); c1->cd(1); gPad->SetLogy(); gPad->SetLogz(); c1->cd(2); gPad->SetLogy(); c1->Update(); pCan(c1,cname); }
void ttreesToHistograms() { //******************************************************************** //**** Variables ****// cout << "Loading variables into vectors..." << endl; vector<TString> fileName; fileName.push_back( "rootfiles0/PhotonJetPt15_Summer09.root" );//file0 fileName.push_back( "rootfiles0/PhotonJetPt30_Summer09.root" );//file1 fileName.push_back( "rootfiles0/PhotonJetPt80_Summer09.root" );//file2 fileName.push_back( "rootfiles0/PhotonJetPt170_Summer09.root" );//file3 fileName.push_back( "rootfiles0/PhotonJetPt300_Summer09.root" );//file4 fileName.push_back( "rootfiles0/PhotonJetPt470_Summer09.root" );//file5 fileName.push_back( "rootfiles0/PhotonJetPt800_Summer09.root" );//file6 TString treeName = "TreePhotonJet"; TString outputFileName = "PhotonJetHists-2009-09-02-matchesReco.root"; //********************************* //**** Set Scale // The following 4 number set the scale // example: // scale = (integrated luminosity (1/pb))*(cross section (pb))*(filter eff)/(events analyzed) float invLuminosityToScaleTo = 200; // in pb-1 vector<float> crossSection; crossSection.push_back( 2.887E5 -3.222E4 ); // in pb crossSection.push_back( 3.222E4 -1.010E3 ); crossSection.push_back( 1.010E3 -5.143E1 ); crossSection.push_back( 5.143E1 -4.193E0 ); crossSection.push_back( 4.193E0 -4.515E-1 ); crossSection.push_back( 4.515E-1 -2.003E-2 ); crossSection.push_back( 2.003E-2 ); vector<float> filterEffeciency; filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); filterEffeciency.push_back( 1.0 ); vector<float> eventsAnalyzied; eventsAnalyzied.push_back( 1073270 ); eventsAnalyzied.push_back( 1088546 ); eventsAnalyzied.push_back( 993509 ); eventsAnalyzied.push_back( 1483940 ); eventsAnalyzied.push_back( 1024589 ); eventsAnalyzied.push_back( 1014413 ); eventsAnalyzied.push_back( 1216320 ); // END of setting scale //********************************* //********************************* //**** Set Cuts ****// // Variables will be plotted for each "location" vector<TString> locationCut; locationCut.push_back( "abs(hardGenPhoton_eta)>1.55&&abs(hardGenPhoton_eta)<2.5" ); locationCut.push_back( "abs(hardGenPhoton_eta)<1.45" ); vector<TString> locationName; locationName.push_back( "Endcap" ); locationName.push_back( "Barrel" ); // These cuts will be merged into one giant cut, applied to all plots for all files vector<TString> cuts; cuts.push_back( "hardGenPhoton_et>15.0&&photon_et>15.0&&photon_matches_hardGen>0.5" ); // These cuts will be applied only to corresponding file vector<TString> fileCuts; fileCuts.push_back( "event_genEventScale>15&&event_genEventScale<30" ); //file0 fileCuts.push_back( "event_genEventScale>30&&event_genEventScale<80" ); //file1 fileCuts.push_back( "event_genEventScale>80&&event_genEventScale<170" ); //file2 fileCuts.push_back( "event_genEventScale>170&&event_genEventScale<300" ); //file3 fileCuts.push_back( "event_genEventScale>300&&event_genEventScale<470" ); //file4 fileCuts.push_back( "event_genEventScale>470&&event_genEventScale<800" ); //file5 fileCuts.push_back( "event_genEventScale>800&&event_genEventScale<1400" ); //file6 //**** END of setting cuts //********************************* //********************************* int locationVariablesToPlot[2][2]; // [a][b], a=number of locations, b=2 (for min,max range of variables to plot) locationVariablesToPlot[0][0] = 16; // Endcap locationVariablesToPlot[0][1] = 35; locationVariablesToPlot[1][0] = 16; // Barrel locationVariablesToPlot[1][1] = 35; /*locationVariablesToPlot[2][0] = 0; locationVariablesToPlot[2][1] = 4; locationVariablesToPlot[3][0] = 0; locationVariablesToPlot[3][1] = 4; locationVariablesToPlot[4][0] = 0; locationVariablesToPlot[4][1] = 4; locationVariablesToPlot[5][0] = 0; locationVariablesToPlot[5][1] = 4; locationVariablesToPlot[6][0] = 0; locationVariablesToPlot[6][1] = 4; locationVariablesToPlot[7][0] = 0; locationVariablesToPlot[7][1] = 4;*/ // Variables you want plotted vector<TString> variableToPlot; // --- the following require gen level info variableToPlot.push_back( "hardGenPhoton_et" ); // 0 variableToPlot.push_back( "hardGenPhoton_eta" ); variableToPlot.push_back( "hardGenPhoton_phi" ); variableToPlot.push_back( "fmod(hardGenPhoton_phi+3.141592,20.0*3.141592/180.0)-10.0*3.141592/180.0" ); variableToPlot.push_back( "abs(hardGenPhoton_eta)" ); // 4 variableToPlot.push_back( "(recPhoton.energy-hardGenPhoton_energy)/hardGenPhoton_energy" ); variableToPlot.push_back( "(recPhoton.energy-hardGenPhoton_energy)/hardGenPhoton_energy:hardGenPhoton_energy" ); variableToPlot.push_back( "(recPhoton.energy-hardGenPhoton_energy)/hardGenPhoton_energy:abs(hardGenPhoton_eta)" ); variableToPlot.push_back( "(recPhoton.energy-hardGenPhoton_energy)/hardGenPhoton_energy:hardGenPhoton_phiMod" ); variableToPlot.push_back( "photon_hadronicOverEm:hardGenPhoton_et" ); variableToPlot.push_back( "photon_hadronicOverEm:abs(hardGenPhoton_eta)" ); // 10 variableToPlot.push_back( "photon_hadronicOverEm:hardGenPhoton_phiMod" ); variableToPlot.push_back( "photon_eta-hardGenPhoton_eta" ); variableToPlot.push_back( "photon_eta-hardGenPhoton_eta:hardGenPhoton_et" ); variableToPlot.push_back( "photon_eta-hardGenPhoton_eta:abs(hardGenPhoton_eta)" ); variableToPlot.push_back( "deltaPhiGenRecPhoton" ); // 15 // --- the following require only rec photons variableToPlot.push_back( "photon_et" ); // 16 variableToPlot.push_back( "photon_eta" ); variableToPlot.push_back( "photon_phi" ); variableToPlot.push_back( "fmod(photon_phi+3.141592,20.0*3.141592/180.0)-10.0*3.141592/180.0" ); variableToPlot.push_back( "abs(photon_eta)" ); // 20 variableToPlot.push_back( "photon_r9" ); variableToPlot.push_back( "photon_ecalRecHitSumEtConeDR03" ); variableToPlot.push_back( "photon_hcalTowerSumEtConeDR03" ); variableToPlot.push_back( "photon_trkSumPtSolidConeDR03" ); variableToPlot.push_back( "photon_trkSumPtHollowConeDR03" ); //25 variableToPlot.push_back( "photon_nTrkSolidConeDR03" ); variableToPlot.push_back( "photon_nTrkHollowConeDR03" ); variableToPlot.push_back( "photon_hadronicOverEm" ); variableToPlot.push_back( "photon_r2x5" ); variableToPlot.push_back( "photon_ecalRecHitSumEtConeDR03/photon_et" ); // 30 variableToPlot.push_back( "photon_hcalTowerSumEtConeDR03/photon_et" ); variableToPlot.push_back( "photon_trkSumPtSolidConeDR03/photon_et" ); variableToPlot.push_back( "photon_trkSumPtHollowConeDR03/photon_et" ); // --- the following require jets /*variableToPlot.push_back( "calcDeltaPhi(photon_phi,jet_phi)" ); variableToPlot.push_back( "calcDeltaPhi(photon_phi,jet2_phi)" ); // 35 variableToPlot.push_back( "calcDeltaPhi(jet_phi,jet2_phi)" );*/ variableToPlot.push_back( "(photon_et-jet_et)/photon_et" ); variableToPlot.push_back( "jet2_et/photon_et" ); // Histograms for the above variables vector<TH1*> histogram; // --- the following require gen level info histogram.push_back( new TH1F("photonGenEt", "Photon E_{T} ;E_{T} (GeV);entries per 15 GeV", 50, 0, 750) ); // 0 histogram.push_back( new TH1F("photonGenEta", "Photon #eta ;#eta;entries per 0.1 bin", 61, -3.05, 3.05) ); histogram.push_back( new TH1F("photonGenPhi", "Photon #phi ;#phi;entries per bin", 62, (-1.-1./30.)*TMath::Pi(), (1.+1./30.)*TMath::Pi()) ); histogram.push_back( new TH1F("photonGenPhiMod", "Photon #phi_{mod} ", 42, (-1.-1./20)*0.1745329, (1.+1./20.)*0.1745329) ); histogram.push_back( new TH1F("photonGenAbsEta", "Photon |#eta| ", 51, 0.00, 2.55) ); histogram.push_back( new TH1F("photonDeltaE", "(E(#gamma_{rec})-E(#gamma_{gen}))/E(#gamma_{gen}) ", 50, -0.8, 0.3) ); histogram.push_back( new TH2F("photonDeltaE_vs_E","(E(#gamma_{rec})-E(#gamma_{gen}))/E(#gamma_{gen}) vs E(#gamma_{gen}) ", 50, 0, 3000, 50, -0.8, 0.3) ); histogram.push_back( new TH2F("photonDeltaE_vs_AbsEta","(E(#gamma_{rec})-E(#gamma_{gen}))/E(#gamma_{gen}) vs |#eta(#gamma_{gen}|) ", 51, 0.0, 2.5, 50, -0.8, 0.3) ); histogram.push_back( new TH2F("photonDeltaE_vs_PhiMod","(E(#gamma_{rec})-E(#gamma_{gen}))/E(#gamma_{gen}) vs #phi_{mod}(#gamma_{gen}) ", 42, (-1.-1./20)*0.1745329, (1.+1./20.)*0.1745329, 50, -0.9, 0.2) ); histogram.push_back( new TH2F("photonHoverE_vs_Et", "H/E vs E_{T}(#gamma_{gen}) ", 50, 0, 1000, 50, 0.0, 0.2) ); histogram.push_back( new TH2F("photonHoverE_vs_AbsEta", "H/E vs |#eta(#gamma_{gen})| ", 51, 0.0, 2.5, 50, 0.0, 0.2) ); histogram.push_back( new TH2F("photonHoverE_vs_PhiMod", "H/E vs #phi_{mod}(#gamma_{gen}) ", 42, (-1.-1./20)*0.1745329, (1.+1./20.)*0.1745329, 50, 0.0, 0.2) ); histogram.push_back( new TH1F("photonDeltaEta", "#Delta#eta(#gamma_{rec},#gamma_{gen}) ;#Delta#eta(#gamma_{rec},#gamma_{gen});entries/bin", 41, -0.01, 0.01) ); histogram.push_back( new TH2F("photonDeltaEta_vs_Et", "#Delta#eta(#gamma_{rec},#gamma_{gen}) vs E_{T}(#gamma_{gen}) ", 50, 0, 1000, 41, -0.1, 0.1) ); histogram.push_back( new TH2F("photonDeltaEta_vs_AbsEta","#Delta#eta(#gamma_{rec},#gamma_{gen}) vs #eta(#gamma_{gen})", 51, 0.0, 2.55, 41, -0.1, 0.1) ); histogram.push_back( new TH1F("photonDeltaPhi", "#Delta#phi(#gamma_{rec},#gamma_{gen}) ;#Delta#phi(#gamma_{rec},#gamma_{gen});entries/bin", 41, 0.0, 0.01) ); // 15 // --- the following require only rec photons histogram.push_back( new TH1F("photonEt", "Photon E_{T} ;E_{T} (GeV);entries per 15 GeV", 50, 0, 750 ) ); // 16 histogram.push_back( new TH1F("photonEta", "Photon #eta ;#eta;entries per 0.1" , 61, -3.05, 3.05) ); histogram.push_back( new TH1F("photonPhi", "Photon #phi ;#phi;entries per bin" , 62, (-1.-1./30.)*TMath::Pi(), (1.+1./30.)*TMath::Pi()) ); histogram.push_back( new TH1F("photonPhiMod", "Photon #phi_{mod} " , 42, (-1.-1./20)*0.1745329, (1.+1./20.)*0.1745329) ); histogram.push_back( new TH1F("photonAbsEta", "Photon |#eta| " , 51, 0.00, 2.55) ); // 20 histogram.push_back( new TH1F("photonR9", "R9 = E(3x3) / E(SuperCluster) ;R9;entries/bin" , 50, 0.6, 1.0) ); histogram.push_back( new TH1F("photonEcalIso", "#SigmaEcal Rec Hit E_{T} in Hollow #DeltaR cone " , 50, 0 , 15) ); histogram.push_back( new TH1F("photonHcalIso", "#SigmaHcal Rec Hit E_{T} in Hollow #DeltaR cone " , 50, 0 , 15) ); histogram.push_back( new TH1F("photonTrackSolidIso", "#Sigmatrack p_{T} in Solid #DeltaR cone " , 50, 0 , 15) ); histogram.push_back( new TH1F("photonTrackHollowIso", "#Sigmatrack p{T} in Hollow #DeltaR cone " , 50, 0 , 15) ); // 25 histogram.push_back( new TH1F("photonTrackCountSolid", "Number of tracks in Solid #DeltaR cone ;Number of Tracks;entries/bin" , 25, -0.5, 24.5) ); histogram.push_back( new TH1F("photonTrackCountHollow", "Number of tracks in Hollow #DeltaR cone ;Number of Tracks;entries/bin", 25, -0.5, 24.5) ); histogram.push_back( new TH1F("photonHoverE", "Hadronic / EM ", 50, 0.0, 0.2) ); histogram.push_back( new TH1F("photonScSeedE2x5over5x5", "E2x5/E5x5 " , 50, 0.6, 1.0) ); histogram.push_back( new TH1F("photonEcalIsoOverE", "#SigmaEcal Rec Hit E_{T} in #DeltaR cone / Photon E_{T} " , 50, -0.1, 1.0) ); // 30 histogram.push_back( new TH1F("photonHcalIsoOverE", "#SigmaHcal Rec Hit E_{T} in #DeltaR cone / Photon E_{T} " , 50, -0.1, 1.0) ); histogram.push_back( new TH1F("photonTrackSolidIsoOverE" , "#SigmaTrack p_{T} in #DeltaR cone / Photon E_{T} " , 50, -0.1, 1.0) ); histogram.push_back( new TH1F("photonTrackHollowIsoOverE", "#SigmaTrack p_{T} in Hollow #DeltaR cone / Photon E_{T} " , 50, -0.1, 1.0) ); // --- the following require jets /*histogram.push_back( new TH1F("h_deltaPhi_photon_jet", "#Delta#phi between Highest E_{T} #gamma and jet;#Delta#phi(#gamma,1^{st} jet)" , 50, 0, 3.1415926) ); histogram.push_back( new TH1F("h_deltaPhi_photon_jet2","#Delta#phi between Highest E_{T} #gamma and 2^{nd} highest jet;#Delta#phi(#gamma,2^{nd} jet)", 50, 0, 3.1415926) ); histogram.push_back( new TH1F("h_deltaPhi_jet_jet2" , "#Delta#phi between Highest E_{T} jet and 2^{nd} jet;#Delta#phi(1^{st} jet,2^{nd} jet)" , 50, 0, 3.1415926) );*/ histogram.push_back( new TH1F("h_deltaEt_photon_jet" , "(E_{T}(#gamma)-E_{T}(jet))/E_{T}(#gamma) when #Delta#phi(#gamma,1^{st} jet) > 2.8;#DeltaE_{T}(#gamma,1^{st} jet)/E_{T}(#gamma)", 20, -1.0, 1.0) ); histogram.push_back( new TH1F("h_jet2_etOverPhotonEt", "E_{T}(2^{nd} highest jet) / E_{T}(#gamma);E_{T}(2^{nd} Jet)/E_{T}(#gamma)", 20, 0.0, 4.0) ); //**** END of Variables ****// //******************************************************************** //******************************************************************** //**** Main part of Program ****// // Human error checking if (variableToPlot.size() != histogram.size() ) { cout << "Should have equal entries in histogram and variableToPlot vector." << endl; return; } if (fileName.size() > crossSection.size() ) { cout << "Should have equal entries in fileName and crossSection vetor." << endl; return; } if (fileName.size() > fileCuts.size() ) { cout << "Should have equal entries in fileName and fileCuts vector." << endl; return; } // Combine all the cuts into one cout << endl << "Cuts that will be applied to everything: " << endl << " "; TCut allCuts = ""; for (int i =0; i<cuts.size(); i++) { allCuts += cuts[i]; if (i>0) cout << "&&"; cout << "(" << cuts[i] << ")"; } cout << endl << endl; // Open the files & set their scales cout << endl << "Histograms will be scaled to " << invLuminosityToScaleTo << "pb-1 " << endl; cout << "Looking for TTree named \"" << treeName << "\" in files..." << endl; vector<float> fileScale; TList *fileList = new TList(); for (int i=0; i < fileName.size(); i++) { TFile* currentFile = TFile::Open(fileName[i]); fileList->Add(currentFile); float currentScale = crossSection[i]*invLuminosityToScaleTo*filterEffeciency[i]/eventsAnalyzied[i]; fileScale.push_back( currentScale ); // Display entries in that file's TTree TTree* tree; currentFile->GetObject(treeName, tree); cout << "file" << i <<": " << fileName[i] << " contains " << tree->GetEntries(allCuts) << " entries, and will be scaled by " << currentScale << endl; } cout << endl << endl; //Create output file TFile *outputFile = TFile::Open( outputFileName, "RECREATE" ); //************************************************************ // Core of the Script // // Loop over locations for (int l=0; l<locationName.size(); l++) { TString currentLocation = locationName[l]; TCut currentCuts = allCuts; currentCuts += locationCut[l]; cout << "Creating plots for " << currentLocation << ", " << locationCut[l] << endl; // Loop over variables to plot for (int i=0; i<variableToPlot.size(); i++) { // should we plot this variable for this location? if (i<locationVariablesToPlot[l][0] || i>locationVariablesToPlot[l][1]) continue; TString currentHistType = histogram[i]->IsA()->GetName(); TString currentHistName = TString(histogram[i]->GetName()) + "_" + currentLocation; TString currentHistTitle = TString(histogram[i]->GetTitle()) + "(" + currentLocation + ")"; cout << " " << variableToPlot[i] << " >> " << currentHistName; TString currentHistDrawOpt; if (currentHistType=="TH2F") { currentHistDrawOpt="goffbox"; } else { currentHistDrawOpt="egoff"; } TH1* currentHist = (TH1*)histogram[i]->Clone(currentHistName); // Creates clone with name currentHistName currentHist->Sumw2(); // store errors currentHist->SetTitle(currentHistTitle); //cout << " from file"; // Plot from the first file int f = 0; //cout << f; TTree *tree; TFile *current_file = (TFile*)fileList->First(); current_file->cd(); current_file->GetObject(treeName, tree); tree->Draw(variableToPlot[i]+">>"+currentHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt); currentHist->Scale(fileScale[f]); f++; // Loop over files current_file = (TFile*)fileList->After( current_file ); while ( current_file ) { current_file->cd(); //cout << ", file" << f; current_file->GetObject(treeName, tree); TString tempHistName = currentHistName+"Temp"; TH1* tempHist = (TH1*)currentHist->Clone(tempHistName); tree->Draw(variableToPlot[i]+">>"+tempHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt); tempHist->Scale(fileScale[f]); currentHist->Add(tempHist); tempHist->Delete(); current_file = (TFile*)fileList->After( current_file ); f++; } // End of loop over files outputFile->cd(); currentHist->Write(); cout << endl; } // End of loop over variabls to plot } // End of loop over locations // END of Core of Script // //************************************************************ cout << endl; cout << "Wrote file " << outputFileName << endl; cout << endl; outputFile->Close(); }
void draw2DLimitContours(map<string,TList *>& m_contours, const TString& par1, const TString& par2, const TString& plotprefix, TLegend *legend) { //from here we build the two-dimensional aTGC limit TCanvas *finalPlot = new TCanvas("final","limits",500,500); finalPlot->cd(); cout << "Drawing expected 68%" << endl; TList *contLevel = m_contours["exp68"]; TGraph *curv; std::cout << "m_contours.size() = " << m_contours.size() << std::endl; for (map<string,TList *>::const_iterator iter = m_contours.begin(); iter != m_contours.end(); iter++ ){ std::cout << "iter->first = " << iter->first << std::endl; std::cout << "iter->second = " << iter->second << std::endl; } std::cout << "contLevel = " << contLevel << std::endl; assert(contLevel); curv = (TGraph*)(contLevel->First()); curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1)); curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2)); curv->SetTitle(); curv->GetXaxis()->SetTitle(par2latex(par1)); curv->GetXaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitle(par2latex(par2)); curv->GetYaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitleOffset(1.20); for (int i=0; i<contLevel->GetSize(); i++) { assert(curv); curv->SetLineColor(kBlue); curv->SetLineWidth(2); curv->SetLineStyle(9); if (!i) { curv->Draw("AC"); legend->AddEntry(curv,"Expected 68% C.L.","L"); } else curv->Draw("SAME C"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing expected 95%" << endl; contLevel = m_contours["exp95"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kGreen); curv->SetLineWidth(2); curv->SetLineStyle(9); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Expected 95% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing expected 99%" << endl; contLevel = m_contours["exp99"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kRed); curv->SetLineWidth(2); curv->SetLineStyle(9); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Expected 99% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } contLevel = m_contours["obs95"]; if (contLevel) { cout << "Drawing obs95" << endl; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->Draw("SAME C"); curv->SetLineWidth(2); if (!i) legend->AddEntry(curv,"Observed 95% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } } TGraph *SMpoint = new TGraph(1); SMpoint->SetPoint(1,0,0); //SMpoint->Draw("SAME Po"); //smLabel = TPaveText(0, // m_contours["-2s"]->GetYaxis()->GetXmax()/8, // m_contours["-2s"]->GetXaxis()->GetXmax()/3->5, // -m_contours["-2s"]->GetYaxis()->GetXmax()/8); //smLabel->SetFillStyle(0); //smLabel->SetBorderSize(0); //smLabel->AddText(" SM"); //smLabel->Draw(); legend->Draw(); TPaveText *text = new TPaveText(0.566,0.87,0.965,1.101,"NDC"); text->SetFillStyle(0); text->SetBorderSize(0); //text->AddText(Form("95%% CL Limit on %s and %s",par2latex(par1).Data(),par2latex(par2).Data())); text->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV",intlumifbinv,beamcometev)); text->Draw(); // text2 = TPaveText(0.155,0.199,0.974,0.244,"NDC"); // text2->SetFillStyle(0); // text2->SetBorderSize(0); // text2->AddText("Values outside contour excluded"); // text2->Draw(); //text3 = TPaveText(0.506,0.699,0.905,0.758,"NDC"); //text3->SetFillStyle(0); //text3->SetBorderSize(0); //text3->AddText(options.flavorText); //text3->Draw(); gPad->SetGrid(1,1); finalPlot->RedrawAxis(); finalPlot->ResetAttPad(); finalPlot->Update(); finalPlot->Draw(); finalPlot->Update(); finalPlot->Modified(); finalPlot->Update(); finalPlot->Print(Form("%s.pdf",plotprefix.Data())); finalPlot->Print(Form("%s.eps",plotprefix.Data())); //finalPlot->Print(Form("%s.png",plotprefix.Data())); } // draw2DlimitContours
void draw2DLimitBFstyle(map<string,TList *>& m_contours, const TString& par1, const TString& par2, const TString& plotprefix, TLegend *legend) { //from here we build the two-dimensional aTGC limit TCanvas *finalPlot = new TCanvas("final","limits",500,500); finalPlot->cd(); cout << "Drawing +2s" << endl; TList *contLevel = m_contours["+2s"]; TGraph *curv; assert(contLevel); curv = (TGraph*)(contLevel->First()); //curv->GetYaxis()->SetRangeUser(-1.25*curv->GetYaxis()->GetXmax(), //+2.0*curv->GetYaxis()->GetXmax()); //curv->GetYaxis()->SetRangeUser(-0.1,0.15); curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2)); curv->SetTitle(); curv->GetXaxis()->SetTitle(par2latex(par1)); curv->GetXaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitle(par2latex(par2)); curv->GetYaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitleOffset(1.20); for (int i=0; i<contLevel->GetSize(); i++) { assert(curv); curv->SetLineColor(kYellow); curv->SetFillColor(kYellow); curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1)); if (!i) { curv->Draw("ACF"); legend->AddEntry(curv,"#pm 2#sigma","F"); } else curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing +1s" << endl; contLevel = m_contours["+1s"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kGreen); curv->SetFillColor(kGreen); curv->Draw("SAME CF"); if (!i) legend->AddEntry(curv,"#pm 1#sigma","F"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing -1s" << endl; contLevel = m_contours["-1s"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kYellow); curv->SetFillColor(kYellow); curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing -2s" << endl; contLevel = m_contours["-2s"]; if (!contLevel) // this can happen more often for this contour if there is insufficient // sensitivity close to the SM cerr << "No contour level for +2s, have to fill in the central region" << endl; else { curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetFillColor(kWhite); curv->SetLineColor(kYellow); curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } } cout << "Drawing median" << endl; curv = (TGraph*)(m_contours["median"]->First()); curv->SetLineColor(kBlack); curv->SetLineWidth(2); curv->SetLineStyle(2); curv->Draw("SAME C"); legend->AddEntry(curv,"Expected","L"); cout << "Drawing obs" << endl; contLevel = m_contours["obs"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kBlack); curv->SetLineWidth(2); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Observed","L"); curv=(TGraph *)(contLevel->After(curv)); } TGraph *SMpoint = new TGraph(1); SMpoint->SetPoint(1,0,0); SMpoint->Draw("SAME Po"); // smLabel = TPaveText(0, // m_contours["-2s"]->GetYaxis()->GetXmax()/8, // m_contours["-2s"]->GetXaxis()->GetXmax()/3->5, // -m_contours["-2s"]->GetYaxis()->GetXmax()/8); // smLabel->SetFillStyle(0); // smLabel->SetBorderSize(0); // smLabel->AddText(" SM"); // smLabel->Draw(); legend->Draw(); TPaveText *text = new TPaveText(0.566,0.87,0.965,1.101,"NDC"); text->SetFillStyle(0); text->SetBorderSize(0); text->AddText(Form("95%% CL Limit on %s and %s",par2latex(par1).Data(),par2latex(par2).Data())); text->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV",intlumifbinv,beamcometev)); text->Draw(); // text2 = TPaveText(0.155,0.199,0.974,0.244,"NDC"); // text2->SetFillStyle(0); // text2->SetBorderSize(0); // text2->AddText("Values outside contour excluded"); // text2->Draw(); //text3 = TPaveText(0.506,0.699,0.905,0.758,"NDC"); //text3->SetFillStyle(0); //text3->SetBorderSize(0); //text3->AddText(options.flavorText); //text3->Draw(); finalPlot->RedrawAxis(); finalPlot->ResetAttPad(); finalPlot->Update(); finalPlot->Draw(); finalPlot->Update(); finalPlot->Modified(); finalPlot->Update(); finalPlot->Print(Form("%s.pdf",plotprefix.Data())); finalPlot->Print(Form("%s.eps",plotprefix.Data())); finalPlot->Print(Form("%s.png",plotprefix.Data())); } // draw2DlimitBFstyle
TCanvas *ContourList(){ const Double_t PI = TMath::Pi(); TCanvas* c = new TCanvas("c","Contour List",0,0,600,600); c->SetRightMargin(0.15); c->SetTopMargin(0.15); Int_t i, j, TotalConts; Int_t nZsamples = 80; Int_t nPhiSamples = 80; Double_t HofZwavelength = 4.0; // 4 meters Double_t dZ = HofZwavelength/(Double_t)(nZsamples - 1); Double_t dPhi = 2*PI/(Double_t)(nPhiSamples - 1); TArrayD z(nZsamples); TArrayD HofZ(nZsamples); TArrayD phi(nPhiSamples); TArrayD FofPhi(nPhiSamples); // Discretized Z and Phi Values for ( i = 0; i < nZsamples; i++) { z[i] = (i)*dZ - HofZwavelength/2.0; HofZ[i] = SawTooth(z[i], HofZwavelength); } for(Int_t i=0; i < nPhiSamples; i++){ phi[i] = (i)*dPhi; FofPhi[i] = sin(phi[i]); } // Create Histogram TH2D *HistStreamFn = new TH2D("HstreamFn", "#splitline{Histogram with negative and positive contents. Six contours are defined.}{It is plotted with options CONT LIST to retrieve the contours points in TGraphs}", nZsamples, z[0], z[nZsamples-1], nPhiSamples, phi[0], phi[nPhiSamples-1]); // Load Histogram Data for (Int_t i = 0; i < nZsamples; i++) { for(Int_t j = 0; j < nPhiSamples; j++){ HistStreamFn->SetBinContent(i,j, HofZ[i]*FofPhi[j]); } } gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitleW(0.99); gStyle->SetTitleH(0.08); Double_t contours[6]; contours[0] = -0.7; contours[1] = -0.5; contours[2] = -0.1; contours[3] = 0.1; contours[4] = 0.4; contours[5] = 0.8; HistStreamFn->SetContour(6, contours); // Draw contours as filled regions, and Save points HistStreamFn->Draw("CONT Z LIST"); c->Update(); // Needed to force the plotting and retrieve the contours in TGraphs // Get Contours TObjArray *conts = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"); TList* contLevel = NULL; TGraph* curv = NULL; TGraph* gc = NULL; Int_t nGraphs = 0; Int_t TotalConts = 0; if (conts == NULL){ printf("*** No Contours Were Extracted!\n"); TotalConts = 0; return; } else { TotalConts = conts->GetSize(); } printf("TotalConts = %d\n", TotalConts); for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); printf("Contour %d has %d Graphs\n", i, contLevel->GetSize()); nGraphs += contLevel->GetSize(); } nGraphs = 0; TCanvas* c1 = new TCanvas("c1","Contour List",610,0,600,600); c1->SetTopMargin(0.15); TH2F *hr = new TH2F("hr", "#splitline{Negative contours are returned first (highest to lowest). Positive contours are returned from}{lowest to highest. On this plot Negative contours are drawn in red and positive contours in blue.}", 2, -2, 2, 2, 0, 6.5); hr->Draw(); Double_t x0, y0, z0; TLatex l; l.SetTextSize(0.03); char val[20]; for(i = 0; i < TotalConts; i++){ contLevel = (TList*)conts->At(i); if (i<3) z0 = contours[2-i]; else z0 = contours[i]; printf("Z-Level Passed in as: Z = %f\n", z0); // Get first graph from list on curves on this level curv = (TGraph*)contLevel->First(); for(j = 0; j < contLevel->GetSize(); j++){ curv->GetPoint(0, x0, y0); if (z0<0) curv->SetLineColor(kRed); if (z0>0) curv->SetLineColor(kBlue); nGraphs ++; printf("\tGraph: %d -- %d Elements\n", nGraphs,curv->GetN()); // Draw clones of the graphs to avoid deletions in case the 1st // pad is redrawn. gc = (TGraph*)curv->Clone(); gc->Draw("C"); sprintf(val,"%g",z0); l.DrawLatex(x0,y0,val); curv = (TGraph*)contLevel->After(curv); // Get Next graph } } c1->Update(); printf("\n\n\tExtracted %d Contours and %d Graphs \n", TotalConts, nGraphs ); gStyle->SetTitleW(0.); gStyle->SetTitleH(0.); return c1; }