本文整理汇总了C++中TFitResultPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TFitResultPtr类的具体用法?C++ TFitResultPtr怎么用?C++ TFitResultPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TFitResultPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dExpFunc
Double_t dExpFunc(const TF1 *fcn, const Double_t x, const TFitResultPtr fs) {
Double_t df[3];
Double_t a = fcn->GetParameter(0);
Double_t b = fcn->GetParameter(1);
Double_t c = fcn->GetParameter(2);
TF1 *deriv_par0 = new TF1("dfdp0",df_dParExp,130,1500,4);
deriv_par0->SetParameters(0,a,b,c); // This will set the derivative for the first parameter.
TF1 *deriv_par1 = new TF1("dfdp1",df_dParExp,130,1500,4);
deriv_par1->SetParameters(1,a,b,c); // This will set the derivative for the second parameter
TF1 *deriv_par2 = new TF1("dfdp2",df_dParExp,130,1500,4);
deriv_par2->SetParameters(2,a,b,c); // This will set the derivative for the 3rd parameter
df[0] = deriv_par0->Eval(x);
df[1] = deriv_par1->Eval(x);
df[2] = deriv_par2->Eval(x);
Double_t err2=0;
for(Int_t i=0; i<3; i++) {
err2 += df[i]*df[i]*(fs->GetCovarianceMatrix()[i][i]);
for(Int_t j=i+1; j<3; j++) {
err2 += 2.0*df[i]*df[j]*(fs->GetCovarianceMatrix()[i][j]);
}
}
assert(err2>=0);
return sqrt(err2);
}
开发者ID:d4space,项目名称:HWW,代码行数:25,代码来源:ratiofit_vbf.C
示例2: LowEdge
std::pair<double,double> CalibTree::fitMean(TH1D* hist, int mode) {
std::pair<double,double> results = std::pair<double,double>(1,0);
if (hist != 0) {
double mean = hist->GetMean(), rms = hist->GetRMS();
double LowEdge(0.7), HighEdge(1.3);
char option[20];
if (mode == 1) {
LowEdge = mean - 1.5*rms;
HighEdge = mean + 1.5*rms;
int nbin = hist->GetNbinsX();
if (LowEdge < hist->GetBinLowEdge(1)) LowEdge = hist->GetBinLowEdge(1);
if (HighEdge > hist->GetBinLowEdge(nbin)+hist->GetBinWidth(nbin))
HighEdge = hist->GetBinLowEdge(nbin)+hist->GetBinWidth(nbin);
}
if (hist->GetEntries() > 100) sprintf (option, "+QRLS");
else sprintf (option, "+QRWLS");
double value(mean);
double error = rms/sqrt(hist->GetEntries());
if (hist->GetEntries() > 20) {
TFitResultPtr Fit = hist->Fit("gaus",option,"",LowEdge,HighEdge);
value = Fit->Value(1);
error = Fit->FitResult::Error(1);
/*
LowEdge = value - 1.5*error;
HighEdge = value + 1.5*error;
value = Fit->Value(1);
error = Fit->FitResult::Error(1);
Fit = hist->Fit("gaus",option,"",LowEdge,HighEdge);
*/
}
results = std::pair<double,double>(value,error);
}
return results;
}
开发者ID:mkiani,项目名称:cmssw,代码行数:34,代码来源:CalibTree.C
示例3: dpol1Func
Double_t dpol1Func(const TF1 *fcn, const Double_t x, const TFitResultPtr fs) {
Double_t df[2];
Double_t a = fcn->GetParameter(0);
Double_t b = fcn->GetParameter(1);
df[0] = 1;
df[1] = x;
Double_t err2 = df[0]*df[0]*(fs->GetCovarianceMatrix()[0][0])
+ df[1]*df[1]*(fs->GetCovarianceMatrix()[1][1])
+ 2.0*df[0]*df[1]*(fs->GetCovarianceMatrix()[0][1]);
assert(err2>=0);
return sqrt(err2);
}
开发者ID:d4space,项目名称:HWW,代码行数:13,代码来源:ratiofit_vbf.C
示例4:
void CalibTree::fitPol0(TH1D* hist, bool debug) {
hist->GetXaxis()->SetTitle("i#eta");
hist->GetYaxis()->SetTitle("<E_{HCAL}/(p-E_{ECAL})>");
hist->GetYaxis()->SetRangeUser(0.4,1.6);
TFitResultPtr Fit = hist->Fit("pol0","+QRWLS");
if (debug) {
std::cout << "Fit to Pol0 to " << hist->GetTitle() << ": "
<< Fit->Value(0) << " +- " << Fit->FitResult::Error(0)
<< std::endl;
}
hist->Write();
}
开发者ID:mkiani,项目名称:cmssw,代码行数:13,代码来源:CalibTree.C
示例5: ExtractCalCurve
TGraphErrors* ExtractCalCurve(vector<calData>& FitPositions, vector<Float_t>& Energies)
//void ExtractCalCurve(vector<Float_t>& FitPositions, vector<Float_t>& Energies)
{
//TF1* calFit = new TF1("calFit","[0]*x + [1]",0,800E3);
TGraphErrors* calCurve = new TGraphErrors(Energies.size());
//Get highest energy peak and estimate [0]
std::vector<calData>::iterator pit;
std::vector<Float_t>::iterator eit;
pit = max_element(FitPositions.begin(),FitPositions.end(),CompareByadc);
eit = max_element(Energies.begin(),Energies.end());
//Extrapolate coefficient and place first point
int currPoint = 1;
calCurve->SetPoint(currPoint,(*pit).fadc,*eit);
calCurve->SetPointError(currPoint,(*pit).efadc,0.0);
TFitResultPtr r = calCurve->Fit("pol1","SQ");
Float_t a = r->Parameter(1);
Float_t CurrentPeak = 0.0;
Float_t CurrentEnergy = 0.0;
Float_t CurrentEnergyEst = 0.0;
// Loop through found peaks and locate closest estimated energy
// Assume fitted peaks are already ordered from lowest to highest
for(std::vector<calData>::iterator i = --(FitPositions.end()); i!=FitPositions.begin(); --i)
{
currPoint++;
CurrentPeak = (*i).fadc;
CurrentEnergyEst = CurrentPeak*a;
Float_t CurrentDelta = 800E3;
for(std::vector<Float_t>::iterator j = Energies.begin(); j!=Energies.end(); j++)
{
if( abs(*j - CurrentEnergyEst) < CurrentDelta)
{
CurrentDelta = abs(*j - CurrentEnergyEst);
CurrentEnergy = *j;
}
}
calCurve->SetPoint(currPoint,CurrentPeak,CurrentEnergy);
calCurve->SetPointError(currPoint,(*i).efadc,CurrentDelta);
r = calCurve->Fit("pol1","SQ");
a = r->Parameter(1);
}
r->Print("V");
return calCurve;
}
开发者ID:goett,项目名称:MAJORANA,代码行数:48,代码来源:PreampStudy.C
示例6: dsqrtFunc
Double_t dsqrtFunc(const TF1 *fcn, const Double_t x, const TFitResultPtr fs) {
Double_t df[2];
Double_t a = fcn->GetParameter(0);
Double_t b = fcn->GetParameter(1);
TF1 *deriv_par0 = new TF1("dfdp0",df_dParsqrt,130,1620,3);
deriv_par0->SetParameters(0,a,b); // This will set the derivative for the first parameter.
TF1 *deriv_par1 = new TF1("dfdp1",df_dParsqrt,130,1620,3);
deriv_par1->SetParameters(1,a,b); // This will set the derivative for the second parameter
df[0] = deriv_par0->Eval(x);
df[1] = deriv_par1->Eval(x);
Double_t err2 = df[0]*df[0]*(fs->GetCovarianceMatrix()[0][0])
+ df[1]*df[1]*(fs->GetCovarianceMatrix()[1][1])
+ 2.0*df[0]*df[1]*(fs->GetCovarianceMatrix()[0][1]);
assert(err2>=0);
return sqrt(err2);
}
开发者ID:d4space,项目名称:HWW,代码行数:17,代码来源:ratiofit_vbf.C
示例7: PlotERes
void PlotERes(string FilterSet){
stringstream name;
name<<FilterSet<<"_vsEnergy";
TH2F* thePlot = (TH2F*)gDirectory->Get(name.str().c_str());
if (thePlot==NULL){
cout<<"No plot"<<endl;
return;
}
int numYBins = thePlot->GetNbinsY();
TF1 * myFunc = new TF1("myFunc","gaus",-0.3,0.3);
double * x = (double*)malloc(numYBins*sizeof(double));
double * y = (double*)malloc(numYBins*sizeof(double));
double * ey = (double*)malloc(numYBins*sizeof(double));
for (int i=0;i<numYBins;i++){
TH1D* proj=thePlot->ProjectionX("_px",i,numYBins-1);
if (proj->GetEntries()>40){
TFitResultPtr result = proj->Fit("myFunc","RQS");
Int_t status = result;
if (status==0){
cout<<result->Value(2)*2.35*4<<endl;
x[i]=i;
y[i]=result->Value(2)*2.35*4;
ey[i]=result->UpperError(2)*2.35*4;
}
}
}
TGraphErrors * graph = new TGraphErrors(numYBins,x,y,0,ey);
graph->GetHistogram()->SetMarkerStyle(5);
graph->Draw("AP");
}
开发者ID:soam5515,项目名称:R00TLe,代码行数:45,代码来源:PlotERes.C
示例8: hw
hw()
{
Float_t data;
TFile *f=new TFile("data.root");
TTree* tree = f->Get("mytree");
TBranch* branch = tree->GetBranch("data");
branch->SetAddress(&data);
TH1F* h1 = new TH1F("h1","h1",200,0.0,5.0);
for(Int_t i= 0 ; i< tree->GetEntries() ; i++) {
tree->GetEntry(i);
h1->Fill( data) ;
}
TF1 *f2 = new TF1("f2", "[0]*x+[1]+gaus(2)", 0.0, 5.0);
f2->SetParameter(3,3.7);
TVirtualFitter *min = TVirtualFitter::Fitter(0,2);
TVirtualFitter::SetDefaultFitter("Minuit");
TFitResultPtr fitresult = h1->Fit("f2", "MES");
cout<< "Parameter 0" << fitresult->Parameter(0) << "+-" << fitresult->ParError(0) << endl;
cout<< "Parameter 1" <<fitresult->Parameter(1) << "+-" << fitresult->ParError(1) << endl;
cout << "Chi2 " << fitresult->Chi2() << endl;
cout << "NDF " << fitresult->Ndf() << endl;
cout << "Chi2 probability " << fitresult->Prob() << endl;
TMatrixD covmat(fitresult->GetCovarianceMatrix());
cout << "Covariance matrix" << endl;
covmat.Print();
TCanvas *c1 = new TCanvas("c1", "binned line fit", 600, 600);
c1->Draw();
h1->Draw();
}
开发者ID:geonmo,项目名称:HepClass,代码行数:35,代码来源:hw.C
示例9: makehist
TH1F* makehist( string id, int ndf )
{
int hits_count = ndf + 2;
TString hist_name, cut, title;
hist_name += id;
hist_name += "_chisq_";
hist_name += hits_count;
hist_name += "hits";
cut += id;
cut += "_hits_count == ";
cut += hits_count;
float min_x = 0;
float max_x = (ndf == 2) ? 2.0 : 0.5;
TH1F *hist = new TH1F(hist_name.Data(), cut, 1000, min_x, max_x);
events->Draw(Form("%s_chisq >> %s", id.c_str(), hist_name.Data()), cut);
if (hits_count > 3)
{
TF1 *func = new TF1("func", "[0]*exp([1]*x)+[2]");
TFitResultPtr fit = hist->Fit(func, "SQ", "", 0.0, 0.5); // S - return fit result, Q - quiet
std::cout << hist_name << "\tslope: " << fit->Parameter(1) << "\tadd const: " << fit->Parameter(2) << std::endl;
}
if (id[1] == '3')
{
title += "Left ";
}
else
{
title += "Right ";
}
title += id[2];
title += " (";
title += cut;
title += ")";
hist->SetTitle(title);
hist->SetLabelSize(0.04, "X");
hist->SetLabelSize(0.04, "Y");
hist->SetTitleSize(0.05, "X");
hist->SetTitleSize(0.05, "Y");
hist->SetTitleOffset(0.9, "X");
hist->SetTitleOffset(1.1, "Y");
hist->GetXaxis()->SetTitle("#chi^2, [mm]");
hist->GetYaxis()->SetTitle("N");
return hist;
}
开发者ID:veprbl,项目名称:libepecur,代码行数:45,代码来源:drift_chisq.C
示例10: choleskyUncertainty
double FitConfidence::choleskyUncertainty( double xx, TFitResultPtr fitResult, TF1 * f, int nSamples ){
int nP = f->GetNpar();
TMatrixDSym cov = fitResult->GetCovarianceMatrix();
double *covArray = new double[ nP * nP ]; // number of parameters x number of parameters
covArray = cov.GetMatrixArray();
return choleskyUncertainty( xx, covArray, f, nSamples );
}
开发者ID:jdbrice,项目名称:boiler,代码行数:9,代码来源:FitConfidence.cpp
示例11: estimateEfficiencyAndPurity
void estimateEfficiencyAndPurity(TH1* fraction,double cut,double& efficiency, double& purity, double& efferror, double& purerror, TFitResultPtr fitRes) {
// efficiency loss is defined as the estimated signal below the cut over the estimated total signal
double rangeLow, rangeHigh;
TF1* expo = fraction->GetFunction("expo");
expo->GetRange(rangeLow, rangeHigh);
double signalLoss = expo->Integral(0,cut)/fraction->GetBinWidth(1);
double signalLossError = expo->IntegralError(0,cut,fitRes->GetParams(),fitRes->GetCovarianceMatrix().GetMatrixArray())/fraction->GetBinWidth(1);
double signal_expopart = expo->Integral(cut,fraction->GetBinLowEdge(fraction->FindBin(rangeHigh)+1))/fraction->GetBinWidth(1);
double signal_expopartError = expo->IntegralError(cut, fraction->GetBinLowEdge(fraction->FindBin(rangeHigh)+1),fitRes->GetParams(),fitRes->GetCovarianceMatrix().GetMatrixArray())/fraction->GetBinWidth(1);
double signal_toppoart = fraction->Integral(fraction->FindBin(rangeHigh)+1,fraction->FindBin(1.)+1);
efficiency = (signal_expopart+signal_toppoart)/(signal_expopart+signal_toppoart+signalLoss);
efferror = TMath::Sqrt( pow(signalLoss,2)*pow(signal_expopartError,2) + pow(signal_toppoart+signal_expopart,2)*pow(signalLossError,2) )/pow(signal_expopart+signal_toppoart+signalLoss,2);
// purity is defined as the signal above the cut (signal_expopart+signal_toppoart)
// over the total data above that cut
double data_kept = fraction->Integral(fraction->FindBin(cut),fraction->FindBin(1.)+1);
double allBeforeRangeHigh = fraction->Integral(fraction->FindBin(cut),fraction->FindBin(rangeHigh));
purity = (signal_expopart+signal_toppoart)/data_kept;
purerror = signal_expopartError/data_kept;
if(purity > 1.){
std::cout << "#################################################"<<std::endl;
std::cout << "cut: "<<cut<<" purity:" << purity <<std::endl;
std::cout << "signalLoss: " << signalLoss << " signalExtrapolated: " << signal_expopart << " signalTop: " << signal_toppoart << std::endl;
std::cout << "all b.r.h.: " << allBeforeRangeHigh << std::endl;
std::cout << "total signal with expo: "<< (signal_expopart+signal_toppoart)<< std::endl;
std::cout << "total signal integrating: "<< (allBeforeRangeHigh+signal_toppoart)<< std::endl;
std::cout << "data kept: " << data_kept << std::endl;
std::cout << "ratio: " << allBeforeRangeHigh/signal_expopart << std::endl;
std::cout << "#################################################"<<std::endl;
}
// std::cout << "estimateEfficiencyAndPurity for cut=" << cut << std::endl;
// std::cout << "signal: " << signalLoss << " " << signal_expopart << " " << signal_toppoart << std::endl;
// std::cout << "data kept: " << data_kept << std::endl;
// std::cout << "eff: " << efficiency << "+/- " << efferror << " pur: " << purity << " +/- " << purerror << std::endl;
}
开发者ID:mmusich,项目名称:usercode,代码行数:42,代码来源:vertexAssociationFit.C
示例12: dpol2Func
Double_t dpol2Func(const TF1 *fcn, const Double_t x, const TFitResultPtr fs) {
Double_t df[3];
Double_t a = fcn->GetParameter(0);
Double_t b = fcn->GetParameter(1);
Double_t c = fcn->GetParameter(2);
df[0] = 1;
df[1] = x;
df[2] = x*x;
Double_t err2=0;
for(Int_t i=0; i<3; i++) {
err2 += df[i]*df[i]*(fs->GetCovarianceMatrix()[i][i]);
for(Int_t j=i+1; j<3; j++) {
err2 += 2.0*df[i]*df[j]*(fs->GetCovarianceMatrix()[i][j]);
}
}
assert(err2>=0);
return sqrt(err2);
}
开发者ID:d4space,项目名称:HWW,代码行数:21,代码来源:ratiofit_vbf.C
示例13: make_drift_efficiency_hist
TH1F* make_drift_efficiency_hist(char arm, char axis, TTree *events)
{
if ((arm != 'l') && (arm != 'r'))
{
throw "make_drift_efficiency_hist: Invalid arm value";
}
if ((axis != 'X') && (axis != 'Y'))
{
throw "make_drift_efficiency_hist: Invalid axis value";
}
char arm_chamber = (arm == 'l') ? '3' : '4';
int canvas_cell = 1 + (int)(arm == 'l') + 2 * (int)(axis == 'X');
TH2F *four_hit_theta_x = new TH2F(
Form("%c%c_four_hit_theta_x", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX,
X_BINS, X_MIN, X_MAX
);
four_hit_theta_x->SetOption("zcol");
TH2F *any_theta_x = new TH2F(
Form("%c%c_any_theta_x", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX,
X_BINS, X_MIN, X_MAX
);
any_theta_x->SetOption("zcol");
TH1F *four_hit_theta = new TH1F(
Form("%c%c_four_hit_theta", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX
);
TH1F *any_theta = new TH1F(
Form("%c%c_any_theta", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX
);
c1.cd();
TH2F *beam_profile = new TH2F("beam_profile", ";Z, [mm];Y, [mm]", 100, -20, 20, 100, -20, 20);
beam_profile->SetOption("zcol");
events->Draw("RL_y:RL_z >> beam_profile", "", "ZCOL");
TF2 *xygaus = new TF2("xygaus", "xygaus");
TFitResultPtr fit = beam_profile->Fit(xygaus, "S"); // S - return fit result
const double *params = fit->GetParams();
if (!params)
{
throw "Error determining beam profile parameters.";
}
const char *cut = Form(
"(abs(RL_z - (%f)) < %f) && "
"(abs(RL_y - (%f)) < %f) && "
"(RL_x < %f) && "
"(RL_x > %f) && "
"(abs(LR_z - (%f)) < %f) && "
"(abs(LR_y - (%f)) < %f) && "
"(LR_x < %f) && "
"(LR_x > %f)",
params[1], params[2] * 2,
params[3], params[4] * 2,
X_MAX, X_MIN,
params[1], params[2] * 2,
params[3], params[4] * 2,
X_MAX, X_MIN
);
c2.cd(canvas_cell);
events->Draw(
Form("RL_x:theta_%c >> %s", arm, any_theta_x->GetName()),
cut
);
events->Draw(
Form("RL_x:theta_%c >> %s", arm, four_hit_theta_x->GetName()),
Form("(t%c%c_hits_count[0] == 4) && %s", arm_chamber, axis, cut)
);
TH2F *u_tx = new TH2F(
Form("%c%c_efficiency_theta_x", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX,
X_BINS, X_MIN, X_MAX
);
u_tx->Divide(four_hit_theta_x, any_theta_x);
u_tx->GetXaxis()->SetTitle("\\Theta, rad");
u_tx->GetYaxis()->SetTitle("X coordinate on target, mm");
u_tx->SetOption("zcol");
u_tx->Draw("zcol");
c3.cd(canvas_cell);
events->Draw(
Form("theta_%c >> %s", arm, any_theta->GetName()),
cut
);
events->Draw(
Form("theta_%c >> %s", arm, four_hit_theta->GetName()),
Form("(t%c%c_hits_count[0] == 4) && %s", arm_chamber, axis, cut)
);
TH1F *u_t = new TH1F(
Form("%c%c_efficiency_theta", arm, axis), "",
ANGLE_BINS, 0, ANGLE_MAX
);
u_t->Divide(four_hit_theta, any_theta);
u_t->GetXaxis()->SetTitle("\\Theta, rad");
u_t->GetYaxis()->SetTitle("Efficiency, 1");
u_t->GetYaxis()->SetRangeUser(0.0, 1.0);
//.........这里部分代码省略.........
开发者ID:veprbl,项目名称:libepecur,代码行数:101,代码来源:drift_efficiency.C
示例14: main
//.........这里部分代码省略.........
c[iCat] -> cd();
g[iCat] -> Draw("P,same");
c_all -> cd(iCat+1);
g[iCat] -> Draw("P,same");
}
}
char funcName[150];
sprintf(funcName,"f_prefit_%s_%d",methods.at(iMeth).c_str(),iCat);
TF1* f_prefit;
if( fitMethod == "pol0")
{
f_prefit = new TF1(funcName,"[0]",55., 230.);
f_prefit -> SetParameter(0,1.);
}
if( fitMethod == "pol1")
{
f_prefit = new TF1(funcName,"[0]+[1]*(x-90.)",55., 210.);
f_prefit -> SetParameters(1.,0.00002);
}
if( fitMethod == "exp3par")
{
f_prefit = new TF1(funcName,"1.+[0]*(1.-exp(-1.*[1]*(x-90.)))+[2]",55., 230.);
f_prefit -> SetParameters(0.005,0.02,0.);
}
if( fitMethod == "exp")
{
f_prefit = new TF1(funcName,"1.+[0]*(1.-exp(-1.*[1]*(x-90.)) )",55., 230.);
f_prefit -> SetParameters(0.005,0.02);
f_prefit -> SetParLimits(0,0.,1.);
f_prefit -> SetParLimits(1,0.,0.05);
}
TFitResultPtr fitResult1;
int fitStatus1 = -1;
gClone[iCat] -> Fit(funcName,"QRHNS");
//g[iCat] -> Fit(funcName,"QRHNS");
fitStatus1 = fitResult1;
//std::cout << " fitStatus1 = " << fitStatus1 << std::endl;
//std::cout << " f_prefit->GetParameter(0) = " << f_prefit->GetParameter(0) << std::endl;
//std::cout << " f_prefit->GetParameter(1) = " << f_prefit->GetParameter(1) << std::endl;
std::cout << " f_prefit->GetChisquare()/f_prefit->GetNDF() = " << f_prefit->GetChisquare()/f_prefit->GetNDF() << std::endl;
if( drawFitFunc == true && rescaleErrors == true )
{
for(int point = 0; point < g[iCat]->GetN(); ++point)
{
double ey = g[iCat] -> GetErrorY(point);
if(addSyst == false){
g[iCat] -> SetPointEYhigh(point,ey*sqrt(f_prefit->GetChisquare()/f_prefit->GetNDF()));
g[iCat] -> SetPointEYlow (point,ey*sqrt(f_prefit->GetChisquare()/f_prefit->GetNDF()));
if(point == 4 || point == 5 || point == 6 || point == 7){
g[iCat] -> SetPointEYhigh(point, sqrt(pow(g[iCat] -> GetErrorY(point),2)+pow(0.0005,2)) );
g[iCat] -> SetPointEYlow(point, sqrt(pow(g[iCat] -> GetErrorY(point),2)+pow(0.0005,2)) );
}
}
//std::cout << " >>> prima ey = " << ey << std::endl;
if(SysError[iCat][point] != 0. && addSyst == true){
double statE2 = (pow(ey,2) - pow(0.01*SysError[iCat][point], 2));
//double statE2 = pow(ey,2);
double sysE2 = pow(SysError[iCat][point], 2);
//double sysE2 = pow(SysError[iCat][point], 2);
开发者ID:Bicocca,项目名称:Linearity,代码行数:67,代码来源:linearityPlots_MZ.cpp
示例15: analyzeInclusivejet
//.........这里部分代码省略.........
TTree* ic5t = (TTree*)inf->Get("icPu5JetAnalyzer/t");
TTree* t = (TTree*)inf->Get("hltanalysis/HltTree");
ic5t->SetBranchAddress("jtpt",jtpt_ic5);
ic5t->SetBranchAddress("jteta",jteta_ic5);
ic5t->SetBranchAddress("jtphi",jtphi_ic5);
ic5t->SetBranchAddress("nref",&njets_ic5);
TTree* ak3t = (TTree*)inf->Get("akPu3PFJetAnalyzer/t");
ak3t->SetBranchAddress("jtpt",jtpt_ak3);
ak3t->SetBranchAddress("jteta",jteta_ak3);
ak3t->SetBranchAddress("jtphi",jtphi_ak3);
ak3t->SetBranchAddress("nref",&njets_ak3);
t->SetBranchAddress("Run",&run);
t->SetBranchAddress("Event",&evt);
t->SetBranchAddress("hiBin",&bin);
TString outname = "JetSkimTree.root";
int Nevents = t->GetEntries();
for(int iev = 0; iev < Nevents; ++iev){
t->GetEntry(iev);
ic5t->GetEntry(iev);
ak3t->GetEntry(iev);
for(int i = 0; i < njets_ak3; ++i){
//if(jtpt_ak3[i] < cutPtJet) continue;
if(fabs(jteta_ak3[i]) > cutEtaJet) continue;
hak3pujet->Fill(jtpt_ak3[i]);
}//1st for loop
int id=0;
for(int i = 0; i < njets_ak3; ++i){
if(fabs(jteta_ic5[i]) < cutEtaJet)
id =1;
}// 2nd for loop
if(id == 1){
for(int i = 0; i < njets_ak3; ++i){
if(jtpt_ic5[i] < cutPtJet) continue;
//if(jtpt_ak3[i] < cutPtJet) continue;
if(fabs(jteta_ak3[i]) > cutEtaJet) continue;
hak3pujet_cut->Fill(jtpt_ak3[i]);
}
}// if loop
}//evt loop
TCanvas *c1 = new TCanvas("c1", "",46,477,700,509);
c1->Range(-125,-11.1492,1125,3.24528);
c1->SetBorderSize(0);
c1->SetBorderMode(0);
c1->SetLeftMargin(0.16);
c1->SetTopMargin(0.06);
c1->SetBottomMargin(0.17);
c1->SetTicks(1,1);
gROOT->LoadMacro("erf.C");
TGraphAsymmErrors *dividedthingy= new TGraphAsymmErrors;
dividedthingy->BayesDivide(hak3pujet_cut,hak3pujet);
float xstart=20.0;
float xend=300.0;
TF1 *fitfcn = new TF1("fitfcn",erf,xstart,xend,2); //<============
fitfcn->SetParameter(0,40); //<=============
TFitResultPtr results =dividedthingy->Fit("fitfcn","VSR");
cout << "Chi2: " << results->Chi2() << " / " << results->Ndf() << " NDF" << endl;
float turnon=fitfcn->GetX(0.99,10,300);
cout << "99% at: " << turnon << endl;
char turnontext[50]="";
sprintf(turnontext," ak5pu at %4.1f",turnon);
dividedthingy->GetFunction("fitfcn")->SetLineColor(3);
dividedthingy->SetLineColor(1);
dividedthingy->Draw("Ap");
TText *t2 = new TText(95,0.08,turnontext);
t2->SetTextSize(0.055);
t2->SetTextColor(1);
t2->Draw();
}
开发者ID:CmsHI,项目名称:CVS_yinglu,代码行数:101,代码来源:AK5pu_CutEff.C
示例16: FitPeak
bool FitPeak(Double_t *par, TH1 *h, Float_t &area, Float_t &darea){
Double_t binWidth = h->GetXaxis()->GetBinWidth(1000);//Need to find the bin widths so that the integral makes sense
Int_t rw = binWidth*20; //This number may change depending on the source used
//Set the number of iterations. The code is pretty quick, so having a lot isn't an issue
TVirtualFitter::SetMaxIterations(4999);
Int_t xp = par[1];
//Define the fit function and the range of the fit
TF1 *pp = new TF1("photopeak",fitFunction,xp-rw,xp+rw,10);
//Name the parameters so it is easy to see what the code is doing
pp->SetParName(0,"Height");
pp->SetParName(1,"centroid");
pp->SetParName(2,"sigma");
pp->SetParName(3,"beta");
pp->SetParName(4,"R");
pp->SetParName(5,"step");
pp->SetParName(6,"A");
pp->SetParName(7,"B");
pp->SetParName(8,"C");
pp->SetParName(9,"bg offset");
//Set some physical limits for parameters
pp->SetParLimits(1,xp-rw,xp+rw);
pp->SetParLimits(3,0,30);
pp->SetParLimits(4,0,10);
pp->SetParLimits(5,0.000,1000000);
pp->SetParLimits(9,xp-20,xp+20);
//Actually set the parameters in the photopeak function
pp->SetParameters(par);
// pp->FixParameter(4,0);
// pp->FixParameter(5,0);
pp->SetNpx(1000); //Draws a nice smooth function on the graph
TFitResultPtr fitres = h->Fit("photopeak","RFS");
pp->Draw("same");
pp->GetParameters(&par[0]);
TF1 *photopeak = new TF1("photopeak",photo_peak,xp-rw,xp+rw,10);
photopeak->SetParameters(par);
Double_t integral = photopeak->Integral(xp-rw,xp+rw)/binWidth;
std::cout << "FIT RESULT CHI2 " << fitres->Chi2() << std::endl;
std::cout << "FWHM = " << 2.35482*fitres->Parameter(2)/binWidth <<"(" << fitres->ParError(2)/binWidth << ")" << std::endl;
std::cout << "NDF: " << fitres->Ndf() << std::endl;
std::cout << "X sq./v = " << fitres->Chi2()/fitres->Ndf() << std::endl;
TVirtualFitter *fitter = TVirtualFitter::GetFitter();
assert(fitter != 0); //make sure something was actually fit
Double_t * covMatrix = fitres->GetCovarianceMatrix(); //This allows us to find the uncertainty in the integral
Double_t sigma_integral = photopeak->IntegralError(xp-rw,xp+rw)/binWidth;
std::cout << "Integral = " << integral << " +/- " << sigma_integral << std::endl;
area = integral;
darea = sigma_integral;
if(fitres->Chi2()/fitres->Ndf() > 5.0)
return false;
return true;
// myFitResult.fIntegral = integral;
// return photopeak;
}
开发者ID:atlaffoley,项目名称:GRSISort,代码行数:75,代码来源:autoeffic.C
示例17: bToDRawYield
//.........这里部分代码省略.........
leg2->SetTextSize(0.06);
leg2->SetTextFont(42);
leg2->SetFillStyle(0);
leg2->AddEntry(hD0DcaMCPSignal,"MC Prompt D^{0}","pl");
leg2->AddEntry(hD0DcaMCNPSignal,"MC Non-prompt D^{0}","pl");
leg2->Draw("same");
c4->cd(2);
gPad->SetLogy();
TH1D* hD0DcaData = hD0DcaDataFit;
if(pts[i-1]>20) hD0DcaData = hD0DcaDataSubSideBand;
setColorTitleLabel(hD0DcaData, 1);
double integralTotalYield = hD0DcaData->Integral(1,hD0DcaData->GetXaxis()->GetNbins(),"width");
cout<<"integralTotalYield: "<<integralTotalYield<<endl;
TF1* fMix = new TF1("fMix",&funMix, 0., 0.5, 2);
fMix->SetParameters(0.5*integralTotalYield,0.5*integralTotalYield);
fMix->SetParLimits(0,0,2*integralTotalYield);
fMix->SetParLimits(1,0,2*integralTotalYield);
fMix->SetLineColor(2);
fMix->SetFillColor(kRed-9);
fMix->SetFillStyle(1001);
float fitRangeL = 0;
float fitRangeH = 0.08;
hD0DcaData->GetXaxis()->SetRangeUser(0,0.07);
hD0DcaData->Draw();
int fitStatus = 1;
TFitResultPtr fitResult;
double fitPrecision = 1.e-6;
while(fitStatus)
{
TFitter::SetPrecision(fitPrecision);
fMix->SetParameters(0.5*integralTotalYield,0.5*integralTotalYield);
fMix->SetParError(0,0.1*integralTotalYield);
fMix->SetParError(1,0.1*integralTotalYield);
fitResult = hD0DcaData->Fit("fMix","E SNQ0", "", fitRangeL, fitRangeH);
fitStatus = fitResult->Status();
cout<<"fit precision: "<<TFitter::GetPrecision()<<" status: "<<fitStatus<<endl;
if(fitStatus)
fitPrecision *= 10;
}
cout<<"============== do main fit ============"<<endl;
fMix->SetParameters(integralTotalYield,0.9);
fMix->SetParError(0,0.1*integralTotalYield);
fMix->SetParError(1,0.1);
fMix->SetNpx(10000);
fitResult = hD0DcaData->Fit("fMix","E S0", "", fitRangeL, fitRangeH);
hD0DcaData->GetFunction("fMix")->Draw("flsame");
fitStatus = fitResult->Status();
cout<<"fit precision: "<<TFitter::GetPrecision()<<" status: "<<fitStatus<<endl;
TF1* fNP = new TF1("fNP",&funNonPrompt, 0., 0.5, 2);
fNP->SetParameters(fMix->GetParameter(0),fMix->GetParameter(1));
fNP->SetRange(fitRangeL,fitRangeH);
fNP->SetLineColor(4);
fNP->SetFillStyle(1001);
fNP->SetFillColor(kBlue-9);
fNP->SetNpx(10000);
fNP->Draw("same");
开发者ID:Jelov,项目名称:BtoD,代码行数:66,代码来源:bToDRawYield.C
示例18: makePlots_vdm_ls
//.........这里部分代码省略.........
//GENERAL LOOP OVER SECTIONS
for(int n=0; n<int(type.size()); n++)
{
can1->cd(type[n]=="X"?1:2);
vector<double>& sectionBegin = type[n]=="X"?sectionXBegin:sectionYBegin;
vector<double>& sectionEnd = type[n]=="X"?sectionXEnd:sectionYEnd;
vector<double>& sectionTruth = type[n]=="X"?sectionXTruth:sectionYTruth;
vector<double>& sectionMean = type[n]=="X"?sectionXMean:sectionYMean;
vector<double>& sectionMeanE = type[n]=="X"?sectionXMeanE:sectionYMeanE;
vector<TGraphErrors*>& sectionChi = type[n]=="X"?sectionXChi:sectionYChi;
const int nSec = int(sectionBegin.size());
sectionMean.resize(nSec);
sectionMeanE.resize(nSec);
TH2D* h_length_scale = (TH2D*)file->Get((string("pp/h_length_scale_") + type[n]).c_str());
// for(int i= 0; i<h_length_scale->GetNbinsX()+1;i++) cout << h_length_scale->Print
TGraphErrors* h_truth_fit_up = new TGraphErrors(0);
TGraphErrors* h_truth_fit_down = new TGraphErrors(0);
TGraphErrors* h_truth_fit_crosscheck_up = new TGraphErrors(0);
TGraphErrors* h_truth_fit_crosscheck_down = new TGraphErrors(0);
ostringstream profiletitle; profiletitle << "truth_fit_" << type[n];
ostringstream crosschecktitle; crosschecktitle << "truth_fit_crosscheck_" << type[n];
h_truth_fit_down->SetName(profiletitle.str().c_str());
h_truth_fit_crosscheck_down->SetName(crosschecktitle.str().c_str());
profiletitle << "_down";
crosschecktitle << "_down";
h_truth_fit_up->SetName(profiletitle.str().c_str());
h_truth_fit_crosscheck_up->SetName(crosschecktitle.str().c_str());
vector<TF1*> sectionFunc; sectionFunc.resize(nSec);
vector<TFitResultPtr> sectionFuncPtr; sectionFuncPtr.resize(nSec);
ostringstream histotitle; histotitle << ";orbit number; vertex " << type[n] << " position [cm]";
h_length_scale->SetTitle(histotitle.str().c_str());
h_length_scale->SetMarkerSize(0.5);
h_length_scale->GetXaxis()->SetNdivisions(505);
h_length_scale->GetYaxis()->SetTitleOffset(h_length_scale->GetYaxis()->GetTitleOffset()*0.7);
if(type[n]=="X")
h_length_scale->GetXaxis()->SetRangeUser(BEGINX,ENDX);
else
h_length_scale->GetXaxis()->SetRangeUser(BEGINY,ENDY);
// if(type[n]=="X")
// h_length_scale->GetXaxis()->SetRangeUser(193000000,202000000);
// else
// h_length_scale->GetXaxis()->SetRangeUser(203000000,211000000);
// h_length_scale->GetYaxis()->SetRangeUser(0.00,0.15);
h_length_scale->Draw("COLZ");
#ifdef __CINT__
CMSText(1,1,1,string("#Delta")+type[n]+string(" length scale"),"","pp, #sqrt{s}=2.76 TeV");
#endif
//FIT EACH SECTION
TCanvas* canFit = new TCanvas;
canFit->Divide(TMath::Nint(nSec/2.),2);
for (int i=0; i<nSec; i++)
{
int binStartNotSkipped,binStart, binEnd, helper;
double x1,x2,xend;
h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionBegin[i]),binStartNotSkipped,helper,helper); binStartNotSkipped++;
h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionBegin[i]+skip),binStart,helper,helper); binStart++;
h_length_scale->GetBinXYZ(h_length_scale->FindBin(sectionEnd[i]),binEnd,helper,helper); binEnd--;
x1=h_length_scale->GetBinLowEdge(binStartNotSkipped);
开发者ID:cbaus,项目名称:pPbCrossSection,代码行数:67,代码来源:makePlots_vdm_ls.C
示例19: PrintCorFile
void PrintCorFile(Int_t runNumber){
Int_t num = gDirectory->GetListOfKeys()->GetSize();
TString user =gSystem->Getenv("R00TLe_User");
TString install =gSystem->Getenv("R00TLeInstall");
ifstream InCorrectionsFile;
stringstream ss1;
ss1<<install<<"/prm/Corrections"<<runNumber<<".txt";
InCorrectionsFile.open(ss1.str().c_str());
if (!InCorrectionsFile.is_open()){
cout<<"File not found"<<endl;
return;
}
std::map<TString,Double_t> timingOffsetsFromFile;
TString NameInFile;
Double_t trash,T_Offset;
while (true){
InCorrectionsFile>>NameInFile>>trash>>trash>>T_Offset;
if (InCorrectionsFile.eof()){
break;
}
timingOffsetsFromFile[NameInFile]=T_Offset;
}
TF1 * aFunc = new TF1("aFunc","pol1");
aFunc->SetParLimits(0,-20,20);
aFunc->SetParLimits(1,0,2);
for (int i=0;i<num;i++){
TString name = gDirectory->GetListOfKeys()->At(i)->GetName();
TGraphErrors* graph = (TGraphErrors*)gDirectory->Get(name);
if (name[0]== 'S'||name[0]=='N'){
TFitResultPtr result = graph->Fit("aFunc","QS");
Int_t status = result;
if (status == 0){
printf("%s %8.4lf %8.4lf %8.4lf\n",name.Data(),result->Value(1),result->Value(0),timingOffsetsFromFile[name]);
// cout<<name<<" "<<result->Value(1)<<" "<<result->Value(0)<<" "<<timingOffsetsFromFile[name]<<endl;
}
}
}
}
开发者ID:soam5515,项目名称:R00TLe,代码行数:76,代码来源:PrintCorFile.C
示例20: checkForHit
void WaveformAna3Tcell::analyze3TCellWaveform(bool &hit, float &stepSize, float &timeConstant, float &hitDetectionTime, float &offset, float &slope, float &chi2)
{
if(!_wave)
return;
// filter data
if (!_wave->isFiltered())
_wave->applyLowPassFilter(_avgBufLen);
// check for hit
_hit = checkForHit(_cutSimpleThreshold);
int hitStartTime = 0;
if(_hit){
hitStartTime = getHitStartTime(_cutTime, _cutTimeThreshold);
if(!_hit && (hitStartTime == 0))
{ //no hit, go out!
return;
}
else
{
stepSize = 0;
timeConstant = 0;
// cout << "\tDetected " << hitCnt << " hits" << endl;
stepSize = 0.04;
timeConstant = hitStartTime;
|
请发表评论