void extract1DHists47() { //output in channel units TString outputFile = "objects/histOutput47.root"; TString histName = "fhAdcAllWoBaselineNLcorr"; TString location = "../data/WPT_tests"; // TString suffix = ""; //// TString suffix = "_HV1000"; TString f0, f1; f0.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0000.root", location.Data()); f1.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0001.root", location.Data()); TFile *fr0 = new TFile(f0.Data()); TFile *fr1 = new TFile(f1.Data()); if (fr0->IsZombie() || fr1->IsZombie()) { Error("extract1DHists47.cxx", "One of files was not open."); return; } TH2D *hraw0 = (TH2D*)fr0->Get(histName.Data()); TH2D *hraw1 = (TH2D*)fr1->Get(histName.Data()); if (!hraw0 || !hraw1) { Error("extract1DHists47.cxx", "At least one of histograms was not found."); return; } TH2D *hSum = new TH2D(*hraw0); hSum->Add(hraw1); TCanvas *c1 = new TCanvas(); c1->Divide(2,2); c1->cd(1); hSum->GetXaxis()->SetRangeUser(0, 64); hSum->Draw(); c1->cd(2); TFile *fw = new TFile(outputFile.Data(), "RECREATE"); TH1D *hch[64]; for (Int_t i = 0; i < 64; i++) { hch[i] = extractHist(hSum, i); fw->cd(); hch[i]->Write(); } fw->Close(); return; } TH1D* extractHist(TH2D *hInput, Int_t channel) { TH1D *hTemp; TString hName; TString hTitle; hName.Form("ch%d", channel); hTitle.Form("channel %d", channel); hTemp = hInput->ProjectionY(hName.Data(), channel+1, channel+1); hTemp->SetTitle(hTitle.Data()); return hTemp; }