Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 08:10:29

0001 #ifndef LAMBDAFEEDDOWNCORRECTION_H
0002 #define LAMBDAFEEDDOWNCORRECTION_H
0003 
0004 #include "CorrectionHistogram1D.h"
0005 
0006 struct LambdaFeedDownCorrection : CorrectionHistogram1D
0007 {
0008   std::shared_ptr<TFile> f;
0009   
0010   LambdaFeedDownCorrection(std::string filename, std::string hname)
0011   {
0012     f = std::make_shared<TFile>(filename.c_str(),"READ");
0013     h_corr = (TH1D*)f->Get(hname.c_str())->Clone();
0014     // preserve histogram on file close
0015     h_corr->SetDirectory(nullptr);
0016     name = "lambdafeeddown";
0017     title = "#Lambda feeddown";
0018   }
0019 
0020   LambdaFeedDownCorrection(const LambdaFeedDownCorrection& c)
0021   {
0022     f = c.f;
0023     h_corr = c.h_corr;
0024     name = c.name;
0025     title = c.title;
0026   }
0027 
0028   void apply_correction(float xlow, float xhigh, TH1F* h, int bin) override
0029   {
0030     std::pair<double,double> corr_and_err = get_val_and_error(xlow,xhigh);
0031     std::cout << "lambda feeddown vals " << corr_and_err.first << " " << corr_and_err.second << std::endl;
0032     float new_val = h->GetBinContent(bin)*(1.-corr_and_err.first);
0033     float new_err = new_val * sqrt(pow(h->GetBinError(bin)/h->GetBinContent(bin),2.)+pow(corr_and_err.second/corr_and_err.first,2.));
0034     h->SetBinContent(bin,new_val);
0035     h->SetBinError(bin,new_err);
0036   }
0037 
0038 };
0039 
0040 #endif