Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:14

0001 void plotter()
0002 {
0003 
0004   //set the style
0005   setStyle();
0006 
0007   // Open the file
0008   TFile *data = new TFile("gctAnalyzer_1.root");
0009 
0010   // Canvas
0011   TCanvas *c1 = new TCanvas("c1","c1",800,700);
0012 
0013   c1->SetLogy(1);
0014   //Iso e/gamma
0015   Plot(data,"analyzer/DataHistograms/IsoEm/isoEgD_Rank","analyzer/EmulatorHistograms/IsoEm/isoEgE_Rank","E_{T}","Iso EM candidates",0,0); c1->Print("TriggerMeetingTalk171109/isoEgRank.png");
0016   Plot(data,"analyzer/DataHistograms/IsoEm/isoEgD_EtEtaPhi","analyzer/EmulatorHistograms/IsoEm/isoEgE_EtEtaPhi","#eta","Iso EM candidates",0,0,"eta"); c1->Print("TriggerMeetingTalk171109/isoEgEta.png");
0017   Plot(data,"analyzer/DataHistograms/IsoEm/isoEgD_EtEtaPhi","analyzer/EmulatorHistograms/IsoEm/isoEgE_EtEtaPhi","#phi","Iso EM candidates",0,0,"phi"); c1->Print("TriggerMeetingTalk171109/isoEgPhi.png");
0018   PlotErrors(data,"analyzer/ErrorHistograms_Flags/isoEg_errorFlag"); c1->Print("TriggerMeetingTalk171109/isoEg_errorFlag.png");
0019 
0020   //Non Iso e/gamma
0021   Plot(data,"analyzer/DataHistograms/NonIsoEM/nonIsoEgD_Rank","analyzer/EmulatorHistograms/NonIsoEM/nonIsoEgE_Rank","E_{T}","Non Iso EM candidates",0,0); c1->Print("TriggerMeetingTalk171109/nonIsoEgRank.png");
0022   Plot(data,"analyzer/DataHistograms/NonIsoEM/nonIsoEgD_EtEtaPhi","analyzer/EmulatorHistograms/NonIsoEM/nonIsoEgE_EtEtaPhi","#eta","Non Iso EM candidates",0,0,"eta"); c1->Print("TriggerMeetingTalk171109/nonIsoEgEta.png");
0023   Plot(data,"analyzer/DataHistograms/NonIsoEM/nonIsoEgD_EtEtaPhi","analyzer/EmulatorHistograms/NonIsoEM/nonIsoEgE_EtEtaPhi","#phi","Non Iso EM candidates",0,0,"phi"); c1->Print("TriggerMeetingTalk171109/nonIsoEgPhi.png");
0024   PlotErrors(data,"analyzer/ErrorHistograms_Flags/nonIsoEg_errorFlag"); c1->Print("TriggerMeetingTalk171109/nonIsoEg_errorFlag.png");
0025 
0026   //Central Jets
0027   Plot(data,"analyzer/DataHistograms/CenJets/cenJetD_Rank","analyzer/EmulatorHistograms/CenJets/cenJetE_Rank","E_{T}","Jet candidates",0,0); c1->Print("TriggerMeetingTalk171109/cenJetsRank.png");
0028   Plot(data,"analyzer/DataHistograms/CenJets/cenJetD_EtEtaPhi","analyzer/EmulatorHistograms/CenJets/cenJetE_EtEtaPhi","#eta","Jet candidates",0,0,"eta"); c1->Print("TriggerMeetingTalk171109/cenJetsEta.png");
0029   Plot(data,"analyzer/DataHistograms/CenJets/cenJetD_EtEtaPhi","analyzer/EmulatorHistograms/CenJets/cenJetE_EtEtaPhi","#phi","Jet candidates",0,0,"phi"); c1->Print("TriggerMeetingTalk171109/cenJetsPhi.png");
0030   PlotErrors(data,"analyzer/ErrorHistograms_Flags/cenJet_errorFlag"); c1->Print("TriggerMeetingTalk171109/cenJet_errorFlag.png");
0031 
0032   //Tau Jets
0033   Plot(data,"analyzer/DataHistograms/TauJets/tauJetD_Rank","analyzer/EmulatorHistograms/TauJets/tauJetE_Rank","E_{T}","Jet candidates",0,0); c1->Print("TriggerMeetingTalk171109/tauJetsRank.png");
0034   Plot(data,"analyzer/DataHistograms/TauJets/tauJetD_EtEtaPhi","analyzer/EmulatorHistograms/TauJets/tauJetE_EtEtaPhi","#eta","Jet candidates",0,0,"eta"); c1->Print("TriggerMeetingTalk171109/tauJetsEta.png");
0035   Plot(data,"analyzer/DataHistograms/TauJets/tauJetD_EtEtaPhi","analyzer/EmulatorHistograms/TauJets/tauJetE_EtEtaPhi","#phi","Jet candidates",0,0,"phi"); c1->Print("TriggerMeetingTalk171109/tauJetsPhi.png");
0036   PlotErrors(data,"analyzer/ErrorHistograms_Flags/tauJet_errorFlag"); c1->Print("TriggerMeetingTalk171109/tauJet_errorFlag.png");
0037 
0038   //Forward Jets
0039   //There were no forward jets in CRUZET'09...
0040   //Plot(data,"analyzer/DataHistograms/ForJets/forJetD_Rank","analyzer/EmulatorHistograms/ForJets/forJetE_Rank","E_{T}","Jet candidates",0,0); c1->Print("TriggerMeetingTalk171109/forJetsRank.png");
0041   //Plot(data,"analyzer/DataHistograms/ForJets/forJetD_EtEtaPhi","analyzer/EmulatorHistograms/ForJets/forJetE_EtEtaPhi","#eta","Jet candidates",0,0,"eta"); c1->Print("TriggerMeetingTalk171109/forJetsEta.png");
0042   //Plot(data,"analyzer/DataHistograms/ForJets/forJetD_EtEtaPhi","analyzer/EmulatorHistograms/ForJets/forJetE_EtEtaPhi","#phi","Jet candidates",0,0,"phi"); c1->Print("TriggerMeetingTalk171109/forJetsPhi.png");
0043   //PlotErrors(data,"analyzer/ErrorHistograms_Flags/forJet_errorFlag"); c1->Print("TriggerMeetingTalk171109/forJet_errorFlag.png");
0044 
0045   //HF Ring Sums
0046   //...and hence no Ring Sums
0047   //Plot(data,"analyzer/DataHistograms/HFRingSums/hfRingSumD_1+","analyzer/EmulatorHistograms/HFRingSums/hfRingSumE_1+","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfRingSum1+.png");
0048   //Plot(data,"analyzer/DataHistograms/HFRingSums/hfRingSumD_1-","analyzer/EmulatorHistograms/HFRingSums/hfRingSumE_1-","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfRingSum1-.png");
0049   //Plot(data,"analyzer/DataHistograms/HFRingSums/hfRingSumD_2+","analyzer/EmulatorHistograms/HFRingSums/hfRingSumE_2+","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfRingSum2+.png");
0050   //Plot(data,"analyzer/DataHistograms/HFRingSums/hfRingSumD_2-","analyzer/EmulatorHistograms/HFRingSums/hfRingSumE_2-","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfRingSum2-.png");
0051   //PlotErrors(data,"analyzer/ErrorHistograms_Flags/hfRingSum_errorFlag"); c1->Print("TriggerMeetingTalk171109/hfRingSum_errorFlag.png");
0052 
0053   //HF Bit Counts
0054   Plot(data,"analyzer/DataHistograms/HFBitCounts/hfBitCountD_1+","analyzer/EmulatorHistograms/HFBitCounts/hfBitCountE_1+","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfBitCount1+.png");
0055   Plot(data,"analyzer/DataHistograms/HFBitCounts/hfBitCountD_1-","analyzer/EmulatorHistograms/HFBitCounts/hfBitCountE_1-","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfBitCount1-.png");
0056   Plot(data,"analyzer/DataHistograms/HFBitCounts/hfBitCountD_2+","analyzer/EmulatorHistograms/HFBitCounts/hfBitCountE_2+","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfBitCount2+.png");
0057   Plot(data,"analyzer/DataHistograms/HFBitCounts/hfBitCountD_2-","analyzer/EmulatorHistograms/HFBitCounts/hfBitCountE_2-","E_{T}","Ring Sums",0,0); c1->Print("TriggerMeetingTalk171109/hfBitCount2-.png");
0058   PlotErrors(data,"analyzer/ErrorHistograms_Flags/hfBitCount_errorFlag"); c1->Print("TriggerMeetingTalk171109/hfBitCount_errorFlag.png");
0059 
0060   //Total ET
0061   Plot(data,"analyzer/DataHistograms/TotalESums/totalEtD","analyzer/EmulatorHistograms/TotalESums/totalEtE","E_{T}","Events",16,0); c1->Print("TriggerMeetingTalk171109/totalEt.png");
0062   PlotErrors(data,"analyzer/ErrorHistograms_Flags/totalEt_errorFlag"); c1->Print("TriggerMeetingTalk171109/totalEt_errorFlag.png");  
0063 
0064   //Total HT
0065   Plot(data,"analyzer/DataHistograms/TotalESums/totalHtD","analyzer/EmulatorHistograms/TotalESums/totalHtE","H_{T}","Events",16,0); c1->Print("TriggerMeetingTalk171109/totalHt.png");
0066   PlotErrors(data,"analyzer/ErrorHistograms_Flags/totalHt_errorFlag"); c1->Print("TriggerMeetingTalk171109/totalHt_errorFlag.png");  
0067 
0068   //Missing ET
0069   Plot(data,"analyzer/DataHistograms/MissingESums/missingEtD","analyzer/EmulatorHistograms/MissingESums/missingEtE","ME_{T}","Events",16,0); c1->Print("TriggerMeetingTalk171109/missingEt.png");
0070   Plot(data,"analyzer/DataHistograms/MissingESums/missingEtD_Phi","analyzer/EmulatorHistograms/MissingESums/missingEtE_Phi","ME_{T} #phi","Events",0,0); c1->Print("TriggerMeetingTalk171109/missingEt_phi.png");
0071   PlotErrors(data,"analyzer/ErrorHistograms_Flags/missingEt_errorFlag"); c1->Print("TriggerMeetingTalk171109/missingEt_errorFlag.png");  
0072 
0073   //Missing HT
0074   Plot(data,"analyzer/DataHistograms/MissingESums/missingHtD","analyzer/EmulatorHistograms/MissingESums/missingHtE","MH_{T}","Events",2,128); c1->Print("TriggerMeetingTalk171109/missingHt.png");
0075   Plot(data,"analyzer/DataHistograms/MissingESums/missingHtD_Phi","analyzer/EmulatorHistograms/MissingESums/missingHtE_Phi","MH_{T} #phi","Events",0,17); c1->Print("TriggerMeetingTalk171109/missingHt_phi.png");
0076   PlotErrors(data,"analyzer/ErrorHistograms_Flags/missingHt_errorFlag"); c1->Print("TriggerMeetingTalk171109/missingHt_errorFlag.png");
0077   
0078   data->Close();
0079 
0080 }
0081 
0082 void Plot(TFile* data, TString Hist_data, TString Hist_emu, TString XAxisLabel, TString YAxisLabel="Events", int rebin, int xAxisRange, TString Opt="")
0083 {
0084 
0085   // Get the histograms from the files
0086 
0087   if(Opt == "eta" || Opt == "phi")
0088   {
0089     if(Opt == "eta") {
0090     TH2F *Data2 = (TH2F*)data->Get(Hist_data);  
0091     TH1D *Data = Data2->ProjectionX();
0092     if(rebin>0) Data->Rebin(rebin);
0093     if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);
0094 
0095     TH2F *Emu2 = (TH2F*)data->Get(Hist_emu);
0096     TH1D *Emu = Emu2->ProjectionX();
0097     if(rebin>0) Emu->Rebin(rebin);
0098     if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
0099     }
0100     if(Opt == "phi") {
0101     TH2F *Data2 = (TH2F*)data->Get(Hist_data);  
0102     TH1D *Data = Data2->ProjectionY();
0103     if(rebin>0) Data->Rebin(rebin);
0104     if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);
0105 
0106     TH2F *Emu2 = (TH2F*)data->Get(Hist_emu);
0107     TH1D *Emu = Emu2->ProjectionY();
0108     if(rebin>0) Emu->Rebin(rebin);
0109     if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
0110     }
0111   }
0112   else
0113   {
0114     TH1D *Data = (TH1D*)data->Get(Hist_data);
0115     if(rebin>0) Data->Rebin(rebin);
0116     if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);
0117 
0118     TH1D *Emu = (TH1D*)data->Get(Hist_emu);
0119     if(rebin>0) Emu->Rebin(rebin);
0120     if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
0121   }
0122 
0123   // Add the X axis label
0124   Emu->GetXaxis()->SetTitle(XAxisLabel);
0125   Emu->GetYaxis()->SetTitle(YAxisLabel);
0126   Emu->SetTitleOffset(1.5,"y");
0127 
0128   // Marker type for data
0129   Data->SetMarkerStyle(20);
0130   Data->SetMarkerColor(kRed);
0131 
0132   // plot them
0133   if (gPad->GetLogy()){
0134     Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*5);
0135   } else {
0136     Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*1.75);
0137   }
0138   Emu->DrawCopy("hist");
0139   Data->DrawCopy("psame");
0140 
0141   gPad->RedrawAxis();
0142 }
0143 
0144 void PlotErrors(TFile* data, TString Hist, TString Opt="")
0145 {
0146 
0147   // Get the histograms from the files
0148   TH1D *Data = (TH1D*)data->Get(Hist);
0149 
0150   //check to make sure there are some events before setting the log scale
0151   if(Data->Integral() == 0 ) c1->SetLogy(0);
0152   else  c1->SetLogy(1);
0153 
0154   // Fill for histogram
0155   Data->SetFillColor(kBlue);
0156 
0157   // plot them
0158   Data->DrawCopy("hist");
0159 
0160   gPad->RedrawAxis();
0161 
0162 }
0163 
0164 void setStyle() {
0165 
0166   TStyle *setStyle = new TStyle("setStyle","Style for GCT Analyzer");
0167 
0168   // Stuff from plain style
0169   setStyle->SetCanvasColor(kWhite);
0170   setStyle->SetFrameBorderMode(0);
0171   setStyle->SetCanvasBorderMode(0);
0172   setStyle->SetFrameFillColor(0);
0173   setStyle->SetPadBorderMode(0);
0174   setStyle->SetPadColor(kWhite); 
0175 
0176   setStyle->SetOptStat(0);
0177   setStyle->SetOptTitle(0);
0178   setStyle->SetOptFit(0);
0179   setStyle->SetOptDate(0);
0180 
0181   // Labels and borders
0182   
0183   setStyle->SetLabelSize(0.055,"x");
0184   setStyle->SetLabelSize(0.06,"y");
0185   setStyle->SetLabelOffset(0.00,"x");
0186   setStyle->SetLabelOffset(0.00,"y");
0187   setStyle->SetTitleOffset(0.05,"x");
0188   setStyle->SetTitleOffset(0.50,"y");
0189   //setStyle->SetLabelFont(22,"x");
0190   //setStyle->SetLabelFont(22,"y");
0191   //setStyle->SetErrorX(0.0000);
0192   //setStyle->SetTickLength(0.05,"x");
0193   //setStyle->SetTickLength(0.05,"y");
0194   //setStyle->SetLineWidth(0.8);
0195   //setStyle->SetPadTickX(1);
0196   //setStyle->SetPadTickY(1);
0197   setStyle->SetPadLeftMargin(0.15);
0198   //setStyle->SetPadBottomMargin(0.2);
0199   
0200   setStyle->cd();
0201 }