Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:24

0001 #include "Settings.h"
0002 void DrawDistributions()
0003 {
0004   PrintMessage();
0005 }
0006 void DrawDistributions(TString type, int ptbin)
0007 {
0008   MainProgram(type,ptbin,0);
0009 }
0010 void DrawDistributions(TString type, int ptbin, int etabin)
0011 {
0012   MainProgram(type,ptbin,etabin);
0013 }
0014 
0015 void MainProgram(TString type, int ptbin, int etabin)
0016 {
0017   if (ptbin>NPtBins || etabin>NETA)
0018     {
0019       cout<<"Choose ptbin < "<<NPtBins<<" and etabin < "<<NETA<<endl;
0020       break;
0021     } 
0022   gROOT->SetStyle("Plain");
0023   gStyle->SetOptStat(0000);
0024   gStyle->SetOptFit(000); 
0025   gStyle->SetPalette(1);
0026   TGaxis::SetMaxDigits(3);
0027   TString fileName,title;
0028   char responseName[1024],histoName[1024],text[1024];
0029   TPaveText *GenTitle,*CaloTitle,*ResponseTitle;
0030   TString Xtitle;
0031   TH1F *hResponse,*hGen,*hCalo;
0032   TFile *f;
0033   GenTitle = new TPaveText(0.65,0.7,0.89,0.85,"NDC");
0034   GenTitle->SetFillColor(0);
0035   GenTitle->SetLineColor(0);
0036   GenTitle->SetBorderSize(0);
0037   GenTitle->AddText("Particle Jets");
0038   ResponseTitle = new TPaveText(0.65,0.7,0.89,0.85,"NDC");
0039   ResponseTitle->SetFillColor(0);
0040   ResponseTitle->SetLineColor(0);
0041   ResponseTitle->SetBorderSize(0);
0042   CaloTitle = new TPaveText(0.65,0.7,0.89,0.85,"NDC");
0043   CaloTitle->SetFillColor(0);
0044   CaloTitle->SetLineColor(0);
0045   CaloTitle->SetBorderSize(0);
0046   TPaveText *pave = new TPaveText(0.11,0.11,0.89,0.89,"NDC");
0047   pave->SetFillColor(0);
0048   pave->SetLineColor(0);
0049   pave->SetBorderSize(0);
0050   pave->AddText(ALGO(Algorithm)); 
0051   sprintf(text,"%d < RefP_{T} < %d GeV",Pt[ptbin],Pt[ptbin+1]);
0052   pave->AddText(text);
0053   sprintf(text,"%1.3f < #eta < %1.3f",eta_boundaries[etabin],eta_boundaries[etabin+1]);
0054   pave->AddText(text);
0055   /////////////////////////////////////////////////////////////
0056   if (type=="Raw")
0057     {   
0058       if (!UseRatioForResponse)
0059         {
0060           title = "CaloJetP_{T}-RefP_{T} (GeV)";
0061           ResponseTitle->AddText("#DeltaP_{T}");
0062         }
0063       else
0064         {
0065           title = "CaloJetP_{T}/RefP_{T}";
0066           ResponseTitle->AddText("CaloJetP_{T}/RefP_{T}");
0067         }
0068       CaloTitle->AddText("Uncorrected Jets");
0069       Xtitle = "CaloJetP_{T} (GeV)";
0070     }
0071   else if (type=="Corrected")
0072     {
0073       title = "CorJetP_{T}/RefP_{T}";
0074       ResponseTitle->AddText("Response");
0075       CaloTitle->AddText("Corrected Jets");
0076       Xtitle = "CorJetP_{T} (GeV)";
0077     }
0078   else
0079     {
0080       cout<<"Wrong type!!! Choose \"Raw\" or \"Corrected\""<<endl;
0081       break;
0082     }
0083   ////////////////////////////////////////////////////////////
0084   f = new TFile(HistoFilename,"R");
0085   if (f->IsZombie()) break;
0086   if (NETA>1)
0087     {   
0088       sprintf(histoName,"Response_RefPt%d_Eta%d",ptbin,etabin); 
0089       hResponse = (TH1F*)f->Get(histoName);
0090       sprintf(histoName,"ptRef_RefPt%d_Eta%d",ptbin,etabin);
0091       hGen = (TH1F*)f->Get(histoName);
0092       sprintf(histoName,"ptCalo_RefPt%d_Eta%d",ptbin,etabin);
0093       hCalo = (TH1F*)f->Get(histoName);
0094     }
0095   else
0096     {    
0097       sprintf(histoName,"Response_RefPt%d",ptbin); 
0098       hResponse = (TH1F*)f->Get(histoName);
0099       sprintf(histoName,"ptRef_RefPt%d",ptbin);
0100       hGen = (TH1F*)f->Get(histoName);
0101       sprintf(histoName,"ptCalo_RefPt%d",ptbin);
0102       hCalo = (TH1F*)f->Get(histoName);
0103     }
0104   if (type=="Raw")
0105     Zoom(hResponse,7.);
0106   Zoom(hGen,7.);
0107   Zoom(hCalo,7.);
0108   ///////////////////////////////////////
0109   TString cname;
0110   char aux[100];
0111   if (etabin>=0)
0112     sprintf(aux,"_Distributions_%d_%d",ptbin,etabin);
0113   else
0114     sprintf(aux,"_Distributions_%d",ptbin);
0115   cname = type+aux;
0116   TCanvas *c1 = new TCanvas(cname,cname,900,600);
0117   c1->Divide(2,2);
0118   c1->cd(2);
0119   hResponse->GetXaxis()->SetTitle(title);
0120   hResponse->GetYaxis()->SetTitle("Matched jets");
0121   hResponse->SetTitle("");
0122   hResponse->Draw();
0123   ResponseTitle->Draw();
0124   c1->cd(3);
0125   hCalo->GetXaxis()->SetTitle(Xtitle);
0126   hCalo->GetYaxis()->SetTitle("Matched jets");
0127   hCalo->SetTitle("");
0128   hCalo->Draw();
0129   CaloTitle->Draw();
0130   c1->cd(1);
0131   hGen->GetXaxis()->SetTitle("RefP_{T} (GeV)");
0132   hGen->GetYaxis()->SetTitle("Matched jets");
0133   hGen->SetTitle("");
0134   hGen->Draw();
0135   GenTitle->Draw();
0136   c1->cd(4);
0137   pave->Draw();
0138 }
0139 
0140 void Zoom(TH1F* h,double a)
0141 {
0142   double m,rms;
0143   m = h->GetMean();
0144   rms = h->GetRMS();
0145   h->SetAxisRange(m-a*rms,m+a*rms,"X");
0146 }
0147 
0148 TString ALGO(TString algorithm)
0149 {
0150   TString tmp;
0151   if (algorithm=="Icone5")
0152     tmp = "Iterative Cone R = 0.5";
0153   else if (algorithm=="Scone5")
0154     tmp = "SIS Cone R = 0.5";
0155   else if (algorithm=="Scone7")
0156     tmp = "SIS Cone R = 0.7";
0157   else if (algorithm=="Kt4")
0158     tmp = "KT D = 0.4";
0159   else if (algorithm=="Kt6")
0160     tmp = "KT D = 0.6";
0161   else
0162     tmp = "Unknown algorithm!!!";
0163   return tmp;
0164 }
0165 
0166 void PrintMessage()
0167 {
0168   cout<<"This ROOT macro draws the basic distributions: RefPt, CaloPt, Response."<<endl;
0169   cout<<"Usage: .X DrawDistributions.C(\"type\",ptbin,etabin) or .X DrawDistributions.C(\"type\",ptbin)"<<endl;
0170 }