Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:46

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // Macro to produce histograms from the GlobalHitsProducer
0003 //
0004 // root -b -q MakePlots.C
0005 ///////////////////////////////////////////////////////////////////////////////
0006 #include "TFile.h"
0007 #include "TTree.h"
0008 #include "TBranch.h"
0009 #include "TString.h"
0010 
0011 void MakePlots(TString filename="GlobalDigisHistogramsAnalyze")
0012 {
0013   gROOT->Reset();
0014   //http://root.cern.ch/root/html/src/TStyle.cxx.html#TStyle:SetOptStat
0015   gStyle->SetOptStat("emruo");
0016 
0017   TString srcname = filename+".root";
0018 
0019   // clear memory of file name
0020   delete gROOT->GetListOfFiles()->FindObject(srcname);
0021 
0022   // open source file
0023   TFile *srcfile = new TFile(srcname);
0024   
0025   // create canvas
0026   Int_t cWidth = 928, cHeight = 1218;
0027   //TCanvas *myCanvas = new TCanvas("globalhits","globalhits",cWidth,cHeight);
0028   TCanvas *myCanvas = new TCanvas("globaldigis","globaldigis");  
0029   //myCanvas->Size(21.59, 27.94);
0030 
0031   // open output ps file
0032   //TString filename = "GlobalHitsHistograms";
0033   TString psfile = filename+".ps";
0034   TString psfileopen = filename+".ps[";
0035   TString psfileclose = filename+".ps]";
0036   myCanvas->Print(psfileopen);
0037 
0038   // create label
0039   TLatex *label = new TLatex();
0040   label->SetNDC();
0041   TString labeltitle;
0042 
0043   // create attributes
0044   Int_t srccolor = kBlue;
0045   Int_t linewidth = 2;
0046 
0047   vector<int> histnames;
0048 
0049 
0050 
0051   vector<string> ecalhistname;
0052   ecalhistname.push_back("hEcalADC0_ES");
0053   ecalhistname.push_back("hEcalADC1_ES");
0054   ecalhistname.push_back("hEcalADC2_ES");
0055   ecalhistname.push_back("hEcaln_EB");
0056   ecalhistname.push_back("hEcaln_EE");
0057   ecalhistname.push_back("hEcaln_ES");
0058   ecalhistname.push_back("hEcalAEE_EB");
0059   ecalhistname.push_back("hEcalAEE_EE");
0060   ecalhistname.push_back("hEcalMaxPos_EB");
0061   ecalhistname.push_back("hEcalMaxPos_EE");
0062   ecalhistname.push_back("hEcalSHE_EB");
0063   ecalhistname.push_back("hEcalSHE_EE");
0064   ecalhistname.push_back("hEcalMultvAEE_EB");
0065   ecalhistname.push_back("hEcalMultvAEE_EE");
0066   ecalhistname.push_back("hEcalSHEvAEESHE_EB");
0067   ecalhistname.push_back("hEcalSHEvAEESHE_EE");
0068   histnames.push_back(0);
0069 
0070 
0071   vector<string> hcalhistname;
0072   hcalhistname.push_back("hHcalAEESHE_HB");
0073   hcalhistname.push_back("hHcalAEESHE_HE");
0074   hcalhistname.push_back("hHcalAEESHE_HF");
0075   hcalhistname.push_back("hHcalAEESHE_HO");
0076   hcalhistname.push_back("hHcalAEE_HB");
0077   hcalhistname.push_back("hHcalAEE_HE");
0078   hcalhistname.push_back("hHcalAEE_HF");
0079   hcalhistname.push_back("hHcalAEE_HO");
0080   hcalhistname.push_back("hHcalSHE_HB");
0081   hcalhistname.push_back("hHcalSHE_HE");
0082   hcalhistname.push_back("hHcalSHE_HF");
0083   hcalhistname.push_back("hHcalSHE_HO");
0084   hcalhistname.push_back("hHcalSHEvAEE_HB");
0085   hcalhistname.push_back("hHcalSHEvAEE_HE");
0086   hcalhistname.push_back("hHcalSHEvAEE_HF");
0087   hcalhistname.push_back("hHcalSHEvAEE_HO");
0088   hcalhistname.push_back("hHcaln_HB");
0089   hcalhistname.push_back("hHcaln_HE");
0090   hcalhistname.push_back("hHcaln_HF");
0091   hcalhistname.push_back("hHcaln_HO");
0092   histnames.push_back(1);
0093 
0094   vector<string> pxlhistname;
0095   string PxlString[7] = {"BRL1", "BRL2", "BRL3", "FWD1n", "FWD1p", "FWD2n", "FWD2p"};
0096   string ResX[7], ResY[7], Count[7];
0097   for(int j = 0; j < 7; ++j)
0098     {
0099       ResX[j] = "hSiPixelADC_"+PxlString[j];
0100       pxlhistname.push_back(ResX[j]);
0101       pxlhistname.push_back("hSiPixelColumn_"+PxlString[j]);
0102       pxlhistname.push_back("hSiPixelRow_"+PxlString[j]);
0103       pxlhistname.push_back("hSiPixeln_"+PxlString[j]);
0104     }
0105 
0106   histnames.push_back(2);
0107   vector<string> sihistname;
0108   string SiString[19] = {"TECW1", "TECW2", "TECW3", "TECW4", "TECW5", "TECW6", "TECW7", "TECW8", "TIBL1", "TIBL2", "TIBL3", "TIBL4", "TIDW1", "TIDW2", "TIDW3", "TOBL1", "TOBL2", "TOBL3", "TOBL4"};
0109   for(int i = 0; i < 19; ++i)
0110     {
0111       sihistname.push_back("hSiStripADC_"+SiString[i]);
0112       sihistname.push_back("hSiStripStripADC_"+SiString[i]);
0113       sihistname.push_back("hSiStripn_"+SiString[i]);
0114     }
0115   histnames.push_back(3);
0116 
0117   vector<string> cschistname;
0118   cschistname.push_back("hCSCStripADC");
0119   cschistname.push_back("hCSCStripn");
0120   cschistname.push_back("hCSCWireTime");
0121   cschistname.push_back("hCSCWiren");
0122   histnames.push_back(4);
0123 
0124   vector<string> dthistname;
0125   dthistname.push_back("hDtLayer_MB1");
0126   dthistname.push_back("hDtLayer_MB2");
0127   dthistname.push_back("hDtLayer_MB3");
0128   dthistname.push_back("hDtLayer_MB4");
0129   dthistname.push_back("hDtMuonTime_MB1");
0130   dthistname.push_back("hDtMuonTime_MB2");
0131   dthistname.push_back("hDtMuonTime_MB3");
0132   dthistname.push_back("hDtMuonTime_MB4");
0133   dthistname.push_back("hDtMuonTimevLayer_MB1");
0134   dthistname.push_back("hDtMuonTimevLayer_MB2");
0135   dthistname.push_back("hDtMuonTimevLayer_MB3");
0136   dthistname.push_back("hDtMuonTimevLayer_MB4");
0137   dthistname.push_back("hDtMuonn_MB1");
0138   dthistname.push_back("hDtMuonn_MB2");
0139   dthistname.push_back("hDtMuonn_MB3");
0140   dthistname.push_back("hDtMuonn_MB4");
0141   histnames.push_back(5);
0142 
0143   //vector<string> rpchistname;
0144   //rpchistname.push_back("hRPCResX");
0145   // rpchistname.push_back("hRPCn");
0146   // histnames.push_back(6);
0147 
0148   //loop through histograms to prepare output
0149   for (Int_t i = 0; i < histnames.size(); ++i) {
0150     
0151     vector<string> names;
0152     
0153     // setup canvas depending on group of plots
0154     TCanvas *Canvas;
0155 
0156     if (i == 0) {
0157       names = ecalhistname;
0158       //Canvas = new TCanvas("ECalHits","ECalHits",cWidth,cHeight);
0159       Canvas = new TCanvas("ECalHits","ECalHits");
0160       //Canvas->Size(21.59, 27.94);
0161       Canvas->Divide(2,4);
0162       myCanvas = Canvas;
0163       myCanvas->cd(0);
0164       //label->DrawLatex(0.5,1.00,"ECal Information");
0165     }
0166     if (i == 1) {
0167       names = hcalhistname;
0168       //Canvas = new TCanvas("HCalHits","HCalHits",cWidth,cHeight);
0169       Canvas = new TCanvas("HCalHits","HCalHits");
0170       //Canvas->Size(21.59, 27.94);
0171       Canvas->Divide(2,4);
0172       myCanvas = Canvas;
0173       myCanvas->cd(0);
0174       //label->DrawLatex(0.5,1.00,"HCal Information");
0175     }
0176     if (i == 2) {
0177       names = pxlhistname;
0178       //Canvas = new TCanvas("PixelHits","PixelHits",cWidth,cHeight);
0179       Canvas = new TCanvas("PixelHits","PixelHits");
0180       //Canvas->Size(21.59, 27.94);
0181       Canvas->Divide(2,4);
0182       myCanvas = Canvas;
0183       myCanvas->cd(0);
0184       //label->DrawLatex(0.5,1.00,"Pixel Information");
0185     }
0186     if (i == 3) {
0187       names = sihistname;
0188       //Canvas = new TCanvas("StripHits","StripHits",cWidth,cHeight);
0189       Canvas = new TCanvas("StripHits","StripHits");
0190       //Canvas->Size(21.59, 27.94);
0191       Canvas->Divide(2,4);
0192       myCanvas = Canvas;
0193       myCanvas->cd(0);
0194       //label->DrawLatex(0.5,1.00,"Strip Information");
0195     }
0196     if (i == 4) {
0197       names = cschistname;
0198       //Canvas = new TCanvas("MuonCscHits","MuonCscHits",cWidth,cWidth);
0199       Canvas = new TCanvas("MuonCscHits","MuonCscHits");
0200       //Canvas->Size(21.59, 27.94);
0201       Canvas->Divide(2,2);
0202       myCanvas = Canvas;
0203       myCanvas->cd(0);
0204       //label->DrawLatex(0.5,1.00,"Muon CSC Information");
0205     }
0206     if (i == 5) {
0207       names = dthistname;
0208       //Canvas = new TCanvas("MuonDtHits","MuonDtHits",cWidth,cWidth);
0209       Canvas = new TCanvas("MuonDtHits","MuonDtHits");
0210       //Canvas->Size(21.59, 27.94);
0211       Canvas->Divide(2,2);
0212       myCanvas = Canvas;
0213       myCanvas->cd(0);
0214       //label->DrawLatex(0.5,1.00,"Muon DT Information");
0215     }
0216     /* if (i == 6) {
0217       names = rpchistname;
0218       //Canvas = new TCanvas("MuonRpcHits","MuonRpcHits",cWidth,cWidth);
0219       Canvas = new TCanvas("MuonRpcHits","MuonRpcHits");
0220       //Canvas->Size(21.59, 27.94);
0221       Canvas->Divide(2,3);
0222       myCanvas = Canvas;
0223       myCanvas->cd(0);
0224       //label->DrawLatex(0.5,1.00,"Muon RPC Information");
0225       }*/
0226 
0227     // loop through plots
0228     for (Int_t j = 0; j < names.size(); ++j) {
0229 
0230       //TH1F *sh = (TH1F*)srcfile->Get(names[j].c_str());
0231       TH1F *sh;
0232 
0233       // set axis info for the histograms
0234    
0235       if (i == 0) {
0236       TString hpath = "DQMData/GlobalDigisV/ECals/"+names[j];
0237       sh = (TH1F*)srcfile->Get(hpath);
0238       cout << "i = 0" << "j =  " << j  << endl ; 
0239        
0240       }
0241       if (i == 1) {
0242     TString hpath = "DQMData/GlobalDigisV/HCals/"+names[j];
0243     sh = (TH1F*)srcfile->Get(hpath);
0244     cout << "i = 1" << endl;
0245             
0246       }
0247       if (i == 2) {
0248     TString hpath = "DQMData/GlobalDigisV/SiPixels/"+names[j];
0249     sh = (TH1F*)srcfile->Get(hpath);
0250      cout << "i = 2" << endl ;
0251 
0252       }
0253       if (i == 3) {
0254     TString hpath = "DQMData/GlobalDigisV/SiStrips/"+names[j];
0255     sh = (TH1F*)srcfile->Get(hpath);
0256      cout << "i = 3" << endl ;
0257       }         
0258       if (i == 4) {
0259     TString hpath = "DQMData/GlobalDigisV/Muons/"+names[j];
0260     sh = (TH1F*)srcfile->Get(hpath);
0261      cout << "i = 3" << endl ;
0262       }
0263       if (i == 5) {
0264     TString hpath = "DQMData/GlobalDigisV/Muons/"+names[j];
0265     sh = (TH1F*)srcfile->Get(hpath);
0266      cout << "i = 5" << endl ;
0267       }
0268       if (i == 6) {
0269     TString hpath = "DQMData/GlobalDigisV/Muons/"+names[j];
0270     sh = (TH1F*)srcfile->Get(hpath);
0271      cout << "i = 6" << endl ;
0272       }
0273       cout << "HELP ME!!!! " << endl;
0274       
0275       sh->SetLineColor(srccolor);
0276       sh->SetLineWidth(linewidth);    
0277 
0278       // make plots
0279       myCanvas->cd(j+1);
0280       //gPad->SetLogy();
0281       sh->Draw();
0282 
0283     } // end loop through plots
0284 
0285     myCanvas->Print(psfile);
0286 
0287   } // end loop through histnames
0288 
0289   // close output ps file
0290   //myCanvas->Print(psfileclose);
0291 
0292   srcfile->Close();
0293 
0294   //convert to pdf
0295   TString cmnd;
0296   cmnd = "ps2pdf "+psfile+" "+filename+".pdf";
0297   gSystem->Exec(cmnd);
0298   cmnd = "rm "+psfile;
0299   gSystem->Exec(cmnd);  
0300 
0301   return;
0302 }