Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:32

0001 #include "DPGAnalysis/SiStripTools/bin/BSvsBPIX.h"
0002 #include "TFile.h"
0003 #include "TH1F.h"
0004 #include "TProfile.h"
0005 #include "TGraphErrors.h"
0006 #include "TCanvas.h"
0007 #include "TDirectory.h"
0008 #include <iostream>
0009 
0010 void BSvsBPIXPlot(TFile* ff, const char* bsmodule, const char* occumodule, const int run) {
0011   TGraphErrors* bspos = new TGraphErrors();
0012   TGraphErrors* bpixpos = new TGraphErrors();
0013 
0014   if (ff) {
0015     char bsfolder[200];
0016     sprintf(bsfolder, "%s/run_%d", bsmodule, run);
0017     if (ff->cd(bsfolder)) {
0018       TH1F* bsx = (TH1F*)gDirectory->Get("bsxrun");
0019       TH1F* bsy = (TH1F*)gDirectory->Get("bsyrun");
0020       if (bsx && bsy) {
0021         std::cout << "beam spot position (" << bsx->GetMean() << "+/-" << bsx->GetMeanError() << "," << bsy->GetMean()
0022                   << "+/-" << bsy->GetMeanError() << ")" << std::endl;
0023         bspos->SetPoint(0, bsx->GetMean(), bsy->GetMean());
0024         bspos->SetPointError(0, bsx->GetMeanError(), bsy->GetMeanError());
0025       }
0026     }
0027     char occufolder[200];
0028     sprintf(occufolder, "%s/run_%d", occumodule, run);
0029     if (ff->cd(occufolder)) {
0030       TProfile* xmean = (TProfile*)gDirectory->Get("avex");
0031       TProfile* ymean = (TProfile*)gDirectory->Get("avey");
0032       if (xmean && ymean) {
0033         for (int i = 1; i <= xmean->GetNbinsX(); ++i) {
0034           if (xmean->GetBinEntries(i) > 0) {
0035             std::cout << "ladder position " << i << " : (" << xmean->GetBinContent(i) << "+/-" << xmean->GetBinError(i)
0036                       << "," << ymean->GetBinContent(i) << "+/-" << ymean->GetBinError(i) << ")" << std::endl;
0037             int point = bpixpos->GetN();
0038             bpixpos->SetPoint(point, xmean->GetBinContent(i), ymean->GetBinContent(i));
0039             bpixpos->SetPointError(point, xmean->GetBinError(i), ymean->GetBinError(i));
0040           }
0041         }
0042       }
0043     }
0044   }
0045   new TCanvas("bsbpix", "bsbpix", 500, 500);
0046   bpixpos->Draw("ap");
0047   bspos->Draw("p");
0048 }