Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-01 23:53:46

0001 #include "TROOT.h"
0002 #include "TFile.h"
0003 #include "TCanvas.h"
0004 #include "TH1F.h"
0005 #include "TH2F.h"
0006 #include "TTree.h"
0007 #include "TBranch.h"
0008 #include "TTree.h"
0009 #include "TChain.h"
0010 #include "TLegend.h"
0011 #include "TGaxis.h"
0012 
0013 #include <iostream>
0014 #include <algorithm>
0015 #include <vector>
0016 #include <map>
0017 #include <iostream>
0018 #include <iomanip>  // std::setw
0019 
0020 /*--------------------------------------------------------------------*/
0021 void makeNicePlotStyle(TH1* hist)
0022 /*--------------------------------------------------------------------*/
0023 {
0024   hist->SetStats(kFALSE);
0025   hist->SetLineWidth(2);
0026   hist->GetXaxis()->CenterTitle(true);
0027   hist->GetYaxis()->CenterTitle(true);
0028   hist->GetXaxis()->SetTitleFont(42);
0029   hist->GetYaxis()->SetTitleFont(42);
0030   hist->GetXaxis()->SetTitleSize(0.05);
0031   hist->GetYaxis()->SetTitleSize(0.05);
0032   hist->GetXaxis()->SetTitleOffset(0.9);
0033   hist->GetYaxis()->SetTitleOffset(1.3);
0034   hist->GetXaxis()->SetLabelFont(42);
0035   hist->GetYaxis()->SetLabelFont(42);
0036   hist->GetYaxis()->SetLabelSize(.05);
0037   hist->GetXaxis()->SetLabelSize(.05);
0038 }
0039 
0040 /*--------------------------------------------------------------------*/
0041 void makeNoisePedestalScatterPlot() {
0042   /*--------------------------------------------------------------------*/
0043 
0044   TGaxis::SetMaxDigits(4);
0045 
0046   TFile* file = new TFile("idealNoise.root");
0047 
0048   TH2F* h2_NoiseVsPedestal = (TH2F*)file->Get("h2_NoiseVsPedestal");
0049 
0050   TH2F* h2_NoiseVsPedestalTIB = (TH2F*)file->Get("h2_NoiseVsPedestalTIB");
0051   TH2F* h2_NoiseVsPedestalTOB = (TH2F*)file->Get("h2_NoiseVsPedestalTOB");
0052   TH2F* h2_NoiseVsPedestalTID = (TH2F*)file->Get("h2_NoiseVsPedestalTID");
0053   TH2F* h2_NoiseVsPedestalTEC = (TH2F*)file->Get("h2_NoiseVsPedestalTEC");
0054 
0055   std::map<std::string, TH2F*> scatters;
0056 
0057   scatters["TIB"] = h2_NoiseVsPedestalTIB;
0058   scatters["TOB"] = h2_NoiseVsPedestalTOB;
0059   scatters["TID"] = h2_NoiseVsPedestalTID;
0060   scatters["TEC"] = h2_NoiseVsPedestalTEC;
0061 
0062   std::map<std::string, int> colormap;
0063   std::map<std::string, int> markermap;
0064   colormap["TIB"] = kRed;
0065   markermap["TIB"] = kFullCircle;
0066   colormap["TOB"] = kGreen;
0067   markermap["TOB"] = kFullTriangleUp;
0068   colormap["TID"] = kCyan;
0069   markermap["TID"] = kFullSquare;
0070   colormap["TEC"] = kBlue;
0071   markermap["TEC"] = kFullTriangleDown;
0072 
0073   std::vector<std::string> parts = {"TEC", "TID", "TOB", "TIB"};
0074 
0075   TCanvas* canvas = new TCanvas("c1", "c1", 1000, 800);
0076   canvas->cd();
0077 
0078   auto legend2 = new TLegend(0.75, 0.85, 0.95, 0.97);
0079   legend2->SetTextSize(0.03);
0080   canvas->cd();
0081   canvas->cd()->SetTopMargin(0.03);
0082   canvas->cd()->SetLeftMargin(0.13);
0083   canvas->cd()->SetRightMargin(0.05);
0084 
0085   for (const auto& part : parts) {
0086     makeNicePlotStyle(scatters[part]);
0087     scatters[part]->SetTitle("");
0088     scatters[part]->SetStats(false);
0089     scatters[part]->SetMarkerColor(colormap[part]);
0090     scatters[part]->SetMarkerStyle(markermap[part]);
0091     scatters[part]->SetMarkerSize(0.2);
0092 
0093     auto temp = (TH2F*)(scatters[part]->Clone());
0094     temp->SetMarkerSize(1.3);
0095 
0096     if (part == "TEC")
0097       scatters[part]->Draw("P");
0098     else
0099       scatters[part]->Draw("Psame");
0100 
0101     legend2->AddEntry(temp, part.c_str(), "P");
0102   }
0103 
0104   legend2->Draw("same");
0105 
0106   canvas->SaveAs("NoiseVsPedestals_subdet.png");
0107 
0108   TCanvas* canvas2 = new TCanvas("c2", "c2", 1000, 800);
0109   canvas2->cd();
0110   canvas2->cd();
0111   canvas2->cd()->SetTopMargin(0.03);
0112   canvas2->cd()->SetLeftMargin(0.13);
0113   canvas2->cd()->SetRightMargin(0.13);
0114 
0115   makeNicePlotStyle(h2_NoiseVsPedestal);
0116   h2_NoiseVsPedestal->SetTitle("");
0117   h2_NoiseVsPedestal->SetStats(false);
0118   h2_NoiseVsPedestal->Draw("colz");
0119 
0120   canvas2->SaveAs("NoiseVsPedestals.png");
0121 }