void setGraphTDR() { // TDR Style TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR"); // For the canvas: tdrStyle->SetCanvasBorderMode(0); tdrStyle->SetCanvasColor(kWhite); tdrStyle->SetCanvasDefH(600); // Height of canvas tdrStyle->SetCanvasDefW(600); // Width of canvas tdrStyle->SetCanvasDefX(0); // Position on screen tdrStyle->SetCanvasDefY(0); // For the Pad: tdrStyle->SetPadBorderMode(0); // tdrStyle->SetPadBorderSize(Width_t size = 1); tdrStyle->SetPadColor(kWhite); tdrStyle->SetPadGridX(false); tdrStyle->SetPadGridY(false); tdrStyle->SetGridColor(0); tdrStyle->SetGridStyle(3); tdrStyle->SetGridWidth(1); // For the frame: tdrStyle->SetFrameBorderMode(0); tdrStyle->SetFrameBorderSize(1); tdrStyle->SetFrameFillColor(0); tdrStyle->SetFrameFillStyle(0); tdrStyle->SetFrameLineColor(1); tdrStyle->SetFrameLineStyle(1); tdrStyle->SetFrameLineWidth(1); // For the histo: // tdrStyle->SetHistFillColor(1); // tdrStyle->SetHistFillStyle(0); tdrStyle->SetHistLineColor(1); tdrStyle->SetHistLineStyle(0); tdrStyle->SetHistLineWidth(1); // tdrStyle->SetLegoInnerR(Float_t rad = 0.5); // tdrStyle->SetNumberContours(Int_t number = 20); tdrStyle->SetEndErrorSize(2); // remarked out DLE //tdrStyle->SetErrorMarker(20); tdrStyle->SetErrorX(0.); tdrStyle->SetMarkerStyle(20); //For the fit/function: tdrStyle->SetOptFit(1); tdrStyle->SetFitFormat("5.4g"); tdrStyle->SetFuncColor(2); tdrStyle->SetFuncStyle(1); tdrStyle->SetFuncWidth(1); //For the date: tdrStyle->SetOptDate(0); // tdrStyle->SetDateX(Float_t x = 0.01); // tdrStyle->SetDateY(Float_t y = 0.01); // For the statistics box: //tdrStyle->SetOptFile(0); //tdrStyle->SetOptStat(1); // To display the mean and RMS: SetOptStat("mr"); tdrStyle->SetStatColor(kWhite); tdrStyle->SetStatFont(42); tdrStyle->SetStatFontSize(0.025); tdrStyle->SetStatTextColor(1); tdrStyle->SetStatFormat("6.4g"); tdrStyle->SetStatBorderSize(1); tdrStyle->SetStatH(0.1); tdrStyle->SetStatW(0.15); // tdrStyle->SetStatStyle(Style_t style = 1001); // tdrStyle->SetStatX(Float_t x = 0); // tdrStyle->SetStatY(Float_t y = 0); // Margins: tdrStyle->SetPadTopMargin(0.05); tdrStyle->SetPadBottomMargin(0.13); tdrStyle->SetPadLeftMargin(0.16); tdrStyle->SetPadRightMargin(0.035); // For the Global title: tdrStyle->SetOptTitle(0); tdrStyle->SetTitleFont(42); tdrStyle->SetTitleColor(1); tdrStyle->SetTitleTextColor(1); tdrStyle->SetTitleFillColor(10); tdrStyle->SetTitleFontSize(0.05); // tdrStyle->SetTitleH(0); // Set the height of the title box // tdrStyle->SetTitleW(0); // Set the width of the title box // tdrStyle->SetTitleX(0); // Set the position of the title box // tdrStyle->SetTitleY(0.985); // Set the position of the title box // tdrStyle->SetTitleStyle(Style_t style = 1001); // tdrStyle->SetTitleBorderSize(2); // For the axis titles: tdrStyle->SetTitleColor(1, "XYZ"); tdrStyle->SetTitleFont(42, "XYZ"); tdrStyle->SetTitleSize(0.06, "XYZ"); // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size? // tdrStyle->SetTitleYSize(Float_t size = 0.02); tdrStyle->SetTitleXOffset(1.5); //0.9 tdrStyle->SetTitleYOffset(1.5); //1.25 //tdrStyle->SetTitleZOffset(1.5); //1.25 // tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset // For the axis labels: tdrStyle->SetLabelColor(1, "XYZ"); tdrStyle->SetLabelFont(42, "XYZ"); tdrStyle->SetLabelOffset(0.007, "XYZ"); tdrStyle->SetLabelSize(0.05, "XYZ"); // For the axis: tdrStyle->SetAxisColor(1, "XYZ"); tdrStyle->SetStripDecimals(kTRUE); tdrStyle->SetTickLength(0.03, "XYZ"); tdrStyle->SetNdivisions(505, "XYZ"); // tdrStyle->SetNdivisions(510, "XYZ"); tdrStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame tdrStyle->SetPadTickY(1); // Change for log plots: //tdrStyle->SetOptLogx(0); //tdrStyle->SetOptLogy(0); //tdrStyle->SetOptLogz(0); // Postscript options: tdrStyle->SetPaperSize(20.,20.); // tdrStyle->SetLineScalePS(Float_t scale = 3); // tdrStyle->SetLineStyleString(Int_t i, const char* text); // tdrStyle->SetHeaderPS(const char* header); // tdrStyle->SetTitlePS(const char* pstitle); // tdrStyle->SetBarOffset(Float_t baroff = 0.5); // tdrStyle->SetBarWidth(Float_t barwidth = 0.5); // tdrStyle->SetPaintTextFormat(const char* format = "g"); // tdrStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0); // tdrStyle->SetTimeOffset(Double_t toffset); // tdrStyle->SetHistMinimumZero(kTRUE); //tdrStyle->SetOptLogz(1); tdrStyle->cd(); } void loopdir2() { //Ref:http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=13981 TFile *f1= new TFile("DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_FastSim_muon_brem.root"); TList* tdf_obs = f1->GetDirectory("/DQMData/Run 1/Muons/Run summary/RecoMuonV")->GetListOfKeys(); char *hName1 = new char [80]; /// TFile *f2= new TFile("DQM_V0002_R000000001__RelValSingleMuPt1000__CMSSW_5_2_0_pre6-START52_V2-v3__DQM.root"); TList* tdf_obs = f2->GetDirectory("/DQMData/Run 1/Muons/Run summary/RecoMuonV")->GetListOfKeys(); char *hName2 = new char [80]; TFile *f3= new TFile("DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_FastSim_STD.root"); TList* tdf_obs = f3->GetDirectory("/DQMData/Run 1/Muons/Run summary/RecoMuonV")->GetListOfKeys(); char *hName3 = new char [80]; char *filesave = new char[80]; TList *objlist1 = f1->GetListOfKeys(); TList *objlist2 = f2->GetListOfKeys(); TList *objlist3 = f3->GetListOfKeys(); TIterator *itr = objlist1->MakeIterator(); TIterator *itr = objlist2->MakeIterator(); TIterator *itr = objlist3->MakeIterator(); TKey *key1; TKey *key2; TKey *key3; TString *currentdir; TIter iter(tdf_obs); key3 = static_cast(iter.Next()); key2 = static_cast(iter.Next()); while ((key1 = static_cast(iter.Next())) != 0) { TObject *obj1 = key1->ReadObj(); TObject *obj2 = key2->ReadObj(); TObject *obj3 = key3->ReadObj(); TH1F *h1 = (TH1F*)key1->ReadObj(); TH1F *h2 = (TH1F*)key2->ReadObj(); TH1F *h3 = (TH1F*)key3->ReadObj(); sprintf(filesave,"%s%s.png",h1->GetName(),"Validation"); cout << "This object has name " << obj1->GetName() << " " <GetName() << " " << obj3->GetName()<< endl; if (obj1->IsA()->InheritsFrom("TDirectory") && obj2->IsA()->InheritsFrom("TDirectory")&& obj3->IsA()->InheritsFrom("TDirectory")) { TDirectory *d1 = static_cast(obj1); TDirectory *d2 = static_cast(obj2); TDirectory *d3 = static_cast(obj3); cout << "Dir: " << d1->GetPath() << ""<< d2->GetPath()<< "" << d3->GetPath()<< endl; } // if (h1->GetEntries() != 0 && h2->GetEntries() != 0 && h3->GetEntries() != 0 ){ // Defense if(obj1->IsA()->InheritsFrom("TH1") &&obj2->IsA()->InheritsFrom("TH1")&& obj3->IsA()->InheritsFrom("TH1")){ setGraphTDR(); TCanvas *singleCanvas = new TCanvas("canvas","canvas"); singleCanvas->cd(); //FastSim + Muon Brem h1->SetLineColor(kBlue); h1->SetMarkerColor(4); h1->SetMarkerStyle(25); h1->SetFillColor(kBlue); h1->SetFillStyle(3004); //FullSim h2->SetLineColor(kRed); h2->SetMarkerColor(2); h2->SetMarkerStyle(26); h2->SetFillColor(kRed); h2->SetFillStyle(3005); //Fast Sim STD h3->SetMarkerColor(8); h3->SetMarkerStyle(24); h3->SetFillColor(kSpring+1); h3->SetFillStyle(1005); //Drawing plots h1->Draw("pe");// h2->Draw("samepe"); // h3->Draw("samepe"); TLegend *leg = new TLegend(0.7082137,0.7675351,0.9000574,0.9008016,NULL,"brNDC"); leg->AddEntry(h1,"FastSim+MuonBrem","f"); leg->AddEntry(h2,"FullSim","f"); //leg->AddEntry(h3,"FastSim+EnergyLoss","f"); leg->SetFillColor(0); leg->Draw(); singleCanvas->Update(); singleCanvas->SaveAs(filesave); delete singleCanvas; //} } } //} // } }