/** This Macro 1. plots the final trim bit results Need to specify 1. See "Declare Constants" Notes */ ///// // To run: root -l -q -b plotsFinalTrimBit.cc+ ///// ///// // Prepare Root and Roofit ///// #include "TFile.h" #include "TH1F.h" #include "TH2F.h" #include "THStack.h" #include "TLegend.h" #include "TTree.h" #include "TTreePlayer.h" #include "TStyle.h" #include "TGaxis.h" #include "TPaveLabel.h" #include "TCanvas.h" #include "TGraphErrors.h" #include "TGraphAsymmErrors.h" #include "TEfficiency.h" #include "TBranch.h" #include "TLatex.h" #include "TROOT.h" #include "Math/DistFunc.h" #include #include #include #include using namespace std; ///// // Declare constants ///// const string channel = "mFar21"; const string pathFile = "/cmsnfsbrilpro/brilpro/plt/cmsplt/interface/trimCalib/"+channel+"/trimBits/FinalTrimBits_doFindTrimBits.root"; const char *histNameTH1S[] = { "TrimBitDist_Channel_10_ROC_01", "TrimBitDist_Channel_10_ROC_02", "TrimBitDist_Channel_10_ROC_03" }; const char *histNameTH2S[] = { "TrimBitMap_Channel_10_ROC_01", "TrimBitMap_Channel_10_ROC_02", "TrimBitMap_Channel_10_ROC_03" }; const char *histNameTH1I[] = { "TrimmedThresholdsDist_Channel_10_ROC_01", "TrimmedThresholdsDist_Channel_10_ROC_02", "TrimmedThresholdsDist_Channel_10_ROC_03" }; const char *histNameTH2I[] = { "TrimmedThresholds_Channel_10_ROC_01", "TrimmedThresholds_Channel_10_ROC_02", "TrimmedThresholds_Channel_10_ROC_03" }; //PLT specific const int rocIdIni = 0; const int rocIdFin = 3; const int maxValCalDel = 151; const int maxValVcThr = 161; const int numTriggers = 5; ///// // Declare functions ///// TFile* Call_TFile(); void setTDRStyle(); ///// // Main function ///// void plotsFinalTrimBit(){ setTDRStyle(); TFile* file = Call_TFile(); cout< histNamesTH1S(histNameTH1S, histNameTH1S + sizeof(histNameTH1S)/sizeof(histNameTH1S[0])); int numHistsTH1S = histNamesTH1S.size(); for(int nh=0; nhGetListOfKeys()->Contains(histNamesTH1S[nh].c_str())){ TCanvas* can = new TCanvas(histNamesTH1S[nh].c_str(),histNamesTH1S[nh].c_str(),100,100,2100,1600); TH1S* h = (TH1S*)file->Get(histNamesTH1S[nh].c_str()); h->Draw(); can->SaveAs((histNamesTH1S[nh]+".png").c_str()); delete h; delete can; } } cout< histNamesTH2S(histNameTH2S, histNameTH2S + sizeof(histNameTH2S)/sizeof(histNameTH2S[0])); int numHistsTH2S = histNamesTH2S.size(); for(int nh=0; nhGetListOfKeys()->Contains(histNamesTH2S[nh].c_str())){ TCanvas* can = new TCanvas(histNamesTH2S[nh].c_str(),histNamesTH2S[nh].c_str(),100,100,2100,1600); TH2S* h = (TH2S*)file->Get(histNamesTH2S[nh].c_str()); h->Draw("COLZ"); /* cout<<"nbins X Y is "<GetNbinsX()<<" "<GetNbinsY()<GetNbinsY(); ynb++){//to match the bin content of TrimBitMap --> ynb=1,xnb=1 (i.e. the first bin) //for numZeros to match the bin content of TrimBitDist --> ynb=2,xnb=1 (i.e. first column/row have entry 0 and are not counted in TrimBitDist) for(int xnb=2; xnb<=h->GetNbinsX(); xnb++){ cout<GetBinContent(xnb,ynb)<GetBinContent(xnb,ynb)==0) numZeros++; } } cout<<"Num zeros is "<SaveAs((histNamesTH2S[nh]+".png").c_str()); delete h; delete can; } } cout< histNamesTH2I(histNameTH2I, histNameTH2I + sizeof(histNameTH2I)/sizeof(histNameTH2I[0])); int numHistsTH2I = histNamesTH2I.size(); for(int nh=0; nhGetListOfKeys()->Contains(histNamesTH2I[nh].c_str())){ TCanvas* can = new TCanvas(histNamesTH2I[nh].c_str(),histNamesTH2I[nh].c_str(),100,100,2100,1600); TH2I* h = (TH2I*)file->Get(histNamesTH2I[nh].c_str()); h->Draw("COLZ"); can->SaveAs((histNamesTH2I[nh]+".png").c_str()); delete h; delete can; } } cout< histNamesTH1I(histNameTH1I, histNameTH1I + sizeof(histNameTH1I)/sizeof(histNameTH1I[0])); int numHistsTH1I = histNamesTH1I.size(); for(int nh=0; nhGetListOfKeys()->Contains(histNamesTH1I[nh].c_str())){ TCanvas* can = new TCanvas(histNamesTH1I[nh].c_str(),histNamesTH1I[nh].c_str(),100,100,2100,1600); TH1I* h = (TH1I*)file->Get(histNamesTH1I[nh].c_str()); gStyle->SetOptStat("mr"); gStyle->SetStatColor(kWhite); gStyle->SetStatFont(42); gStyle->SetStatTextColor(1); gStyle->SetStatFormat("6.4g"); gStyle->SetStatBorderSize(0); gStyle->SetStatX(0.8); //Starting position on X axis gStyle->SetStatY(0.8); //Starting position on Y axis gStyle->SetStatFontSize(0.025); //Vertical Size gStyle->SetStatW(0.25); //Horizontal size h->Draw(); can->SaveAs((histNamesTH1I[nh]+".png").c_str()); delete h; delete can; } } // delete file; } ///// // Declare functions ///// ///// // Call TFile to be read ///// TFile* Call_TFile() { string fN = pathFile; TFile* file = new TFile(fN.c_str()); return file; } ///// // Set setTDRStyle_modified (from link https://twiki.cern.ch/twiki/pub/CMS/TRK10001/setTDRStyle_modified.C) ///// void setTDRStyle(){ 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(0); // 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(0); tdrStyle->SetErrorX(0.); // tdrStyle->SetErrorMarker(20); tdrStyle->SetMarkerStyle(20); //For the fit/function: tdrStyle->SetOptFit(1); tdrStyle->SetFitFormat("5.4g"); //tdrStyle->SetFuncColor(1); 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(""); // To display the mean and RMS: SetOptStat("mr"); //tdrStyle->SetStatColor(kWhite); tdrStyle->SetStatColor(kGray); tdrStyle->SetStatFont(42); tdrStyle->SetStatTextColor(1); tdrStyle->SetStatFormat("6.4g"); tdrStyle->SetStatBorderSize(0); tdrStyle->SetStatX(0.9); //Starting position on X axis tdrStyle->SetStatY(1.); //Starting position on Y axis tdrStyle->SetStatFontSize(0.025); //Vertical Size tdrStyle->SetStatW(0.15); //Horizontal size // tdrStyle->SetStatStyle(Style_t style = 1001); // Margins: tdrStyle->SetPadTopMargin(0.1); tdrStyle->SetPadBottomMargin(0.125); tdrStyle->SetPadLeftMargin(0.115); tdrStyle->SetPadRightMargin(0.135); // For the Global title: // tdrStyle->SetOptTitle(0); tdrStyle->SetTitleFont(50); tdrStyle->SetTitleColor(1); tdrStyle->SetTitleTextColor(1); tdrStyle->SetTitleFillColor(10); tdrStyle->SetTitleFontSize(0.06); //center position tdrStyle->SetTitleX(0.1f); tdrStyle->SetTitleW(0.8f); // 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(0); // 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(0.9); tdrStyle->SetTitleYOffset(0.9); // 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(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(15.,15.); // 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(0,0); // tdrStyle->SetTimeOffset(Double_t toffset); // tdrStyle->SetHistMinimumZero(kTRUE); tdrStyle->SetPaintTextFormat("3.1f"); tdrStyle->cd(); }