File indexing completed on 2024-04-06 12:22:46
0001 #include "TFile.h"
0002 #include "TH2D.h"
0003 #include "TH1D.h"
0004 #include <iostream>
0005 #include <sstream>
0006
0007 void ProbabilitySlice()
0008 {
0009 TFile * file = new TFile("limitedSigma2.root", "READ");
0010 TH2D * hist;
0011 file->GetObject("GLh", hist);
0012 hist->SetTitle("J/Psi shape");
0013
0014 TFile * outputFile = new TFile("Projections2.root", "RECREATE");
0015 outputFile->cd();
0016 int binsX = hist->GetNbinsX();
0017 for( int i = 1; i <= binsX; ++i ) {
0018 std::cout << "projecting bin " << i << std::endl;
0019 std::stringstream ss;
0020 ss << i;
0021 TH1D * projX = hist->ProjectionX((ss.str()+"_"+hist->GetName()).c_str(), i, i);
0022 projX->Write();
0023 }
0024 outputFile->Write();
0025 outputFile->Close();
0026 }