Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:10:24

0001 // include files
0002 
0003 #include "tdrStyle.C"
0004 #include "CMS_lumi.C"
0005 
0006 #include <iostream>
0007 #include <iomanip>
0008 #include <fstream>
0009 #include <cmath>
0010 #include "TStyle.h"
0011 
0012 // data dirs
0013 TString theDirName = "Figures";
0014 
0015 // data files
0016 // All the rootfiles must be present:
0017 //  TkStrct PixBar PixFwdPlus PixFwdMinus TIB TIDF TIDB TOB TEC BeamPipe InnerServices
0018 //
0019 
0020 // histograms
0021 TProfile* prof_x0_BeamPipe;
0022 TProfile* prof_x0_PixBar;
0023 TProfile* prof_x0_PixFwdPlus;
0024 TProfile* prof_x0_PixFwdMinus;
0025 TProfile* prof_x0_TIB;
0026 TProfile* prof_x0_TIDF;
0027 TProfile* prof_x0_TIDB;
0028 TProfile* prof_x0_InnerServices;
0029 TProfile* prof_x0_TOB;
0030 TProfile* prof_x0_TEC;
0031 TProfile* prof_x0_Outside;
0032 //
0033 TProfile* prof_x0_SEN;
0034 TProfile* prof_x0_SUP;
0035 TProfile* prof_x0_ELE;
0036 TProfile* prof_x0_CAB;
0037 TProfile* prof_x0_COL;
0038 TProfile* prof_x0_OTH;
0039 TProfile* prof_x0_AIR;
0040 //
0041 TH1D* hist_x0_BeamPipe;
0042 TH1D* hist_x0_Pixel;
0043 TH1D* hist_x0_IB;
0044 TH1D* hist_x0_TOB;
0045 TH1D* hist_x0_TEC;
0046 TH1D* hist_x0_Outside;
0047 //
0048 TH1D* hist_x0_SEN;
0049 TH1D* hist_x0_SUP;
0050 TH1D* hist_x0_ELE;
0051 TH1D* hist_x0_CAB;
0052 TH1D* hist_x0_COL;
0053 TH1D* hist_x0_OTH;
0054 //
0055 float xmin;
0056 float xmax;
0057 
0058 float ymin;
0059 float ymax;
0060 //
0061 void createPlots(TString plot);
0062 
0063 using namespace std;
0064 
0065 // Main
0066 void MaterialBudgetMtd() {
0067   //TDR style
0068   setTDRStyle();
0069 
0070   // plots
0071   createPlots("x_vs_eta");
0072   createPlots("x_vs_phi");
0073   createPlots("l_vs_eta");
0074   createPlots("l_vs_phi");
0075 }
0076 
0077 void createPlots(TString plot) {
0078   unsigned int plotNumber = 0;
0079   TString abscissaName = "dummy";
0080   TString ordinateName = "dummy";
0081   if (plot.CompareTo("x_vs_eta") == 0) {
0082     plotNumber = 10;
0083     abscissaName = TString("#eta");
0084     ordinateName = TString("t/X_{0}");
0085     ymin = 0.0;
0086     ymax = 0.8;
0087     xmin = -4.0;
0088     xmax = 4.0;
0089   } else if (plot.CompareTo("x_vs_phi") == 0) {
0090     plotNumber = 20;
0091     abscissaName = TString("#varphi [rad]");
0092     ordinateName = TString("t/X_{0}");
0093     ymin = 0.0;
0094     ymax = 0.8;
0095     xmin = -3.2;
0096     xmax = 3.2;
0097   } else if (plot.CompareTo("l_vs_eta") == 0) {
0098     plotNumber = 1010;
0099     abscissaName = TString("#eta");
0100     ordinateName = TString("t/#lambda_{I}");
0101     ymin = 0.0;
0102     ymax = 0.18;
0103     xmin = -4.0;
0104     xmax = 4.0;
0105   } else if (plot.CompareTo("l_vs_phi") == 0) {
0106     plotNumber = 1020;
0107     abscissaName = TString("#varphi [rad]");
0108     ordinateName = TString("t/#lambda_{I}");
0109     ymin = 0.0;
0110     ymax = 0.18;
0111     xmin = -3.2;
0112     xmax = 3.2;
0113   } else {
0114     cout << " error: chosen plot name not known " << plot << endl;
0115     return;
0116   }
0117 
0118   // file name
0119   TString subDetectorFileName = "matbdg_Mtd.root";
0120 
0121   // open file
0122   TFile* subDetectorFile = new TFile(subDetectorFileName);
0123   cout << "*** Open file... " << endl;
0124   cout << subDetectorFileName << endl;
0125   cout << "***" << endl;
0126 
0127   TProfile* prof_x0 = (TProfile*)subDetectorFile->Get(Form("%u", plotNumber));
0128   TH1D* hist_x0 = (TH1D*)prof_x0->ProjectionX();
0129   // category profiles
0130   TProfile* prof_x0_SUP = (TProfile*)subDetectorFile->Get(Form("%u", 100 + plotNumber));
0131   TProfile* prof_x0_SEN = (TProfile*)subDetectorFile->Get(Form("%u", 200 + plotNumber));
0132   TProfile* prof_x0_CAB = (TProfile*)subDetectorFile->Get(Form("%u", 300 + plotNumber));
0133   TProfile* prof_x0_COL = (TProfile*)subDetectorFile->Get(Form("%u", 400 + plotNumber));
0134   TProfile* prof_x0_ELE = (TProfile*)subDetectorFile->Get(Form("%u", 500 + plotNumber));
0135   TProfile* prof_x0_OTH = (TProfile*)subDetectorFile->Get(Form("%u", 600 + plotNumber));
0136   // add to summary histogram
0137   TH1D* hist_x0_SUP = (TH1D*)prof_x0_SUP->ProjectionX();
0138   TH1D* hist_x0_SEN = (TH1D*)prof_x0_SEN->ProjectionX();
0139   TH1D* hist_x0_CAB = (TH1D*)prof_x0_CAB->ProjectionX();
0140   TH1D* hist_x0_COL = (TH1D*)prof_x0_COL->ProjectionX();
0141   TH1D* hist_x0_ELE = (TH1D*)prof_x0_ELE->ProjectionX();
0142   TH1D* hist_x0_OTH = (TH1D*)prof_x0_OTH->ProjectionX();
0143 
0144   // colors
0145 
0146   int ksen = 27;
0147   int kele = 46;
0148   int kcab = kOrange - 8;
0149   int kcol = 30;
0150   int ksup = 38;
0151   int koth = kOrange - 2;
0152 
0153   hist_x0_SEN->SetFillColor(ksen);  // Sensitive   = brown
0154   hist_x0_ELE->SetFillColor(kele);  // Electronics = red
0155   hist_x0_CAB->SetFillColor(kcab);  // Cabling     = dark orange
0156   hist_x0_COL->SetFillColor(kcol);  // Cooling     = green
0157   hist_x0_SUP->SetFillColor(ksup);  // Support     = light blue
0158   hist_x0_OTH->SetFillColor(koth);  // Other+Air   = light orange
0159   //
0160 
0161   TString stackTitle_Materials = Form("Mtd Material Budget;%s;%s", abscissaName.Data(), ordinateName.Data());
0162   THStack stack_x0_Materials("stack_x0", stackTitle_Materials);
0163   stack_x0_Materials.Add(hist_x0_SEN);
0164   stack_x0_Materials.Add(hist_x0_CAB);
0165   stack_x0_Materials.Add(hist_x0_COL);
0166   stack_x0_Materials.Add(hist_x0_ELE);
0167   stack_x0_Materials.Add(hist_x0_OTH);
0168   stack_x0_Materials.Add(hist_x0_SUP);
0169   //
0170 
0171   // canvas
0172 
0173   int W = 800;
0174   int H = 600;
0175   int H_ref = 600;
0176   int W_ref = 800;
0177 
0178   // references for T, B, L, R
0179   float T = 0.08 * H_ref;
0180   float B = 0.12 * H_ref;
0181   float L = 0.12 * W_ref;
0182   float R = 0.04 * W_ref;
0183 
0184   TCanvas* can_Materials = new TCanvas("can_Materials", "can_Materials", 50, 50, W, H);
0185   can_Materials->Range(0, 0, 25, 25);
0186   can_Materials->SetFillColor(kWhite);
0187   can_Materials->SetBorderMode(0);
0188   can_Materials->SetFrameFillStyle(0);
0189   can_Materials->SetFrameBorderMode(0);
0190   can_Materials->SetLeftMargin(L / W);
0191   can_Materials->SetRightMargin(R / W);
0192   can_Materials->SetTopMargin(T / H);
0193   can_Materials->SetBottomMargin(B / H);
0194   can_Materials->SetTickx(0);
0195   can_Materials->SetTicky(0);
0196   gStyle->SetOptStat(0);
0197   //
0198 
0199   // Draw
0200   stack_x0_Materials.SetMinimum(ymin);
0201   stack_x0_Materials.SetMaximum(ymax);
0202   stack_x0_Materials.Draw("HIST");
0203   stack_x0_Materials.GetXaxis()->SetLimits(xmin, xmax);
0204   //
0205 
0206   // Legenda
0207   TLegend* theLegend_Materials = new TLegend(0.14, 0.8, 0.96, 0.92);
0208   theLegend_Materials->SetTextAlign(22);
0209   theLegend_Materials->SetNColumns(3);
0210   theLegend_Materials->SetFillColor(0);
0211   theLegend_Materials->SetFillStyle(0);
0212   theLegend_Materials->SetBorderSize(0);
0213 
0214   theLegend_Materials->AddEntry(hist_x0_SEN, "Sensitive material", "f");
0215   theLegend_Materials->AddEntry(hist_x0_COL, "Support/cooling", "f");
0216   theLegend_Materials->AddEntry(hist_x0_ELE, "Electronics/services", "f");
0217   //  theLegend_Materials->AddEntry(hist_x0_CAB, "Services", "f");
0218   //  theLegend_Materials->AddEntry(hist_x0_SUP, "Support", "f");
0219   //  theLegend_Materials->AddEntry(hist_x0_OTH, "Other", "f");
0220   theLegend_Materials->Draw();
0221 
0222   // writing the lumi information and the CMS "logo"
0223   int iPeriod = 0;
0224   writeExtraText = true;
0225   extraText = "Simulation";
0226 
0227   // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot
0228   // iPos=11 : top-left, left-aligned
0229   // iPos=33 : top-right, right-aligned
0230   // iPos=22 : center, centered
0231   // mode generally :
0232   //   iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right)
0233   int iPos = 0;
0234 
0235   CMS_lumi(can_Materials, iPeriod, iPos);
0236 
0237   // Store
0238   can_Materials->Update();
0239   can_Materials->RedrawAxis();
0240   can_Materials->Draw();
0241   // can_Materials->SaveAs( Form( "%s/Mtd_Materials_%s.eps",  theDirName.Data(), plot.Data() ) );
0242   // can_Materials->SaveAs( Form( "%s/Mtd_Materials_%s.gif",  theDirName.Data(), plot.Data() ) );
0243   can_Materials->SaveAs(Form("%s/Mtd_Materials_%s.pdf", theDirName.Data(), plot.Data()));
0244   // can_Materials->SaveAs( Form( "%s/Mtd_Materials_%s.png",  theDirName.Data(), plot.Data() ) );
0245   can_Materials->SaveAs(Form("%s/Mtd_Materials_%s.root", theDirName.Data(), plot.Data()));
0246   // can_Materials->SaveAs( Form( "%s/Mtd_Materials_%s.C",  theDirName.Data(), plot.Data() ) );
0247   //
0248 
0249   delete can_Materials;
0250 }