Back to home page

sPhenix code displayed by LXR

 
 

    


Warning, file /analysis/LightFlavorRatios/yield_and_ratios/linearSidebandFit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef TF1_SIDEBAND_FIT_H
0002 #define TF1_SIDEBAND_FIT_H
0003 
0004 #include "TF1.h"
0005 #include "kinematicThreshold.h"
0006 
0007 Double_t linear_sidebandonly(Double_t* v, Double_t* par)
0008 {
0009   Double_t x = v[0];
0010   Double_t slope = par[0];
0011   Double_t c = par[1];
0012   Double_t left_sideband_low = par[2];
0013   Double_t left_sideband_high = par[3];
0014   Double_t right_sideband_low = par[4];
0015   Double_t right_sideband_high = par[5];
0016 
0017   if((x<left_sideband_low || x>left_sideband_high) && (x<right_sideband_low || x>right_sideband_high))
0018   {
0019     TF1::RejectPoint();
0020   }
0021 
0022   return std::max(slope*x+c,0.);
0023 }
0024 
0025 Double_t linear_threshold(Double_t* v, Double_t* par)
0026 {
0027 
0028   Double_t x = v[0];
0029   Double_t slope = par[0];
0030   Double_t c = par[1];
0031   Double_t mother_pt = par[2];
0032   Double_t daughter_pt_cutoff = par[3];
0033   Double_t daughter1_mass = par[4];
0034   Double_t daughter2_mass = par[5];
0035 
0036   Double_t turnon_pars[4] = {mother_pt,daughter_pt_cutoff,daughter1_mass,daughter2_mass};
0037 
0038   Double_t val = (slope*x+c)*kinematic_threshold_turnon(v,turnon_pars);
0039 
0040   return std::max(val,0.);
0041 }
0042 
0043 Double_t linear_sidebandonly_threshold(Double_t* v, Double_t* par)
0044 {
0045   Double_t x = v[0];
0046   Double_t left_sideband_low = par[6];
0047   Double_t left_sideband_high = par[7];
0048   Double_t right_sideband_low = par[8];
0049   Double_t right_sideband_high = par[9];
0050 
0051   if((x<left_sideband_low || x>left_sideband_high) && (x<right_sideband_low || x>right_sideband_high))
0052   {
0053     TF1::RejectPoint();
0054   }
0055   return linear_threshold(v,par);
0056 }
0057 
0058 TF1* linear_sideband_TF1(double xlow, double xhigh, std::pair<float,float> left_sideband, std::pair<float,float> right_sideband)
0059 {
0060   TF1* f = new TF1("linear_sidebandonly",&linear_sidebandonly,xlow,xhigh,6);
0061   f->FixParameter(2,left_sideband.first);
0062   f->FixParameter(3,left_sideband.second);
0063   f->FixParameter(4,right_sideband.first);
0064   f->FixParameter(5,right_sideband.second);
0065 
0066   return f;
0067 }
0068 
0069 TF1* linear_sideband_TF1_threshold(double xlow, double xhigh, double mother_pt, double daughter_pt_cutoff, int daughter1_pdgid, int daughter2_pdgid, std::pair<float,float> left_sideband, std::pair<float,float> right_sideband)
0070 {
0071   double daughter1_mass = TDatabasePDG::Instance()->GetParticle(daughter1_pdgid)->Mass();
0072   double daughter2_mass = TDatabasePDG::Instance()->GetParticle(daughter2_pdgid)->Mass();
0073 
0074   TF1* f = new TF1("linear_sidebandonly_threshold",&linear_sidebandonly_threshold,xlow,xhigh,10);
0075   f->FixParameter(2,mother_pt);
0076   f->FixParameter(3,daughter_pt_cutoff);
0077   f->FixParameter(4,daughter1_mass);
0078   f->FixParameter(5,daughter2_mass);
0079   f->FixParameter(6,left_sideband.first);
0080   f->FixParameter(7,left_sideband.second);
0081   f->FixParameter(8,right_sideband.first);
0082   f->FixParameter(9,right_sideband.second);
0083 
0084   return f;
0085 }
0086 
0087 TF1* linear_background(TF1* sideband_fit)
0088 {
0089   double xlow, xhigh;
0090   sideband_fit->GetRange(xlow,xhigh);
0091   TF1* f = new TF1("linear_background","[0]*x+[1]",xlow,xhigh);
0092   for(int i=0;i<6;i++)
0093   {
0094     f->SetParameter(i,sideband_fit->GetParameter(i));
0095   }
0096   return f;
0097 }
0098 
0099 TF1* linear_background_threshold(TF1* sideband_fit)
0100 {
0101   double xlow, xhigh;
0102   sideband_fit->GetRange(xlow,xhigh);
0103   TF1* f = new TF1("linear_background_threshold",&linear_threshold,xlow,xhigh,6);
0104   for(int i=0;i<6;i++)
0105   {
0106     f->SetParameter(i,sideband_fit->GetParameter(i));
0107   }
0108   return f;
0109 }
0110 
0111 #endif