int main() { F1 f(7); TEST((x_ >>2*x_ +1)(10)); triqs::clef::function<double(double,double)> f2; f2(x_,y_) = x_ + y_; TEST(f2(2,3)); f2(x_,y_) = x_ + 2*y_; TEST(f2(2,3)); boost::function<double(double,double)> ff2(f2); TEST(ff2(2,3)); triqs::clef::function<double(double)> f1 ( f(x_) + 2*x_ ,x_); TEST(f1(3)); triqs::clef::function<double(double,double)> g2; g2(x_,y_) = x_ - y_ + f2(x_,2*y_); TEST(g2(2,3)); boost::function<double(double,double)> ff8 = make_function( x_ + y_, x_, y_); TEST(ff8(2,3)); boost::function<double(double)> f3; f3 = x_>> f(x_) + 2*x_; TEST(f3(3)); BOOST_AUTO (h , make_function( 2*x_ + y_ + 1, x_)); // is a lazy expression expression with placeholder y_, returning a function... std::cout << tql::eval(h, y_=1) << std::endl; TEST(tql::eval( h, y_=1) (10)); TEST(h); }
void TestQgsGeometrySnapper::snapPolygonToPoint() { QgsVectorLayer* rl = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsGeometry refGeom = QgsGeometry::fromWkt( QStringLiteral( "Point(0 0)" ) ); QgsFeature ff( 0 ); ff.setGeometry( refGeom ); QgsGeometry refGeom2 = QgsGeometry::fromWkt( QStringLiteral( "Point(10 0)" ) ); QgsFeature ff2( 2 ); ff2.setGeometry( refGeom2 ); QgsFeatureList flist; flist << ff << ff2; rl->dataProvider()->addFeatures( flist ); QgsGeometry polygonGeom = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 10.1 0, 10 10, 0 10, 0.1 -0.1))" ) ); QgsGeometrySnapper snapper( rl ); QgsGeometry result = snapper.snapGeometry( polygonGeom, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))" ) ); QgsGeometry polygonGeom2 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 10.1 0, 0 10, 0.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom2, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 0 10, 0 0))" ) ); // insert new vertex QgsGeometry polygonGeom3 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 20.0 0.0, 20 10, 0 10, 0.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom3, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 20 0, 20 10, 0 10, 0 0))" ) ); }
void TestQgsGeometrySnapper::snapPolygonToLine() { QgsVectorLayer* rl = new QgsVectorLayer( QStringLiteral( "Linestring" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); // closed linestring QgsGeometry refGeom = QgsGeometry::fromWkt( QStringLiteral( "LineString(0 0, 10 0, 10 10, 0 10, 0 0)" ) ); QgsFeature ff( 0 ); ff.setGeometry( refGeom ); // unclosed linestring QgsGeometry refGeom2 = QgsGeometry::fromWkt( QStringLiteral( "LineString(100 0, 110 0, 110 10, 100 10)" ) ); QgsFeature ff2( 2 ); ff2.setGeometry( refGeom2 ); QgsFeatureList flist; flist << ff << ff2; rl->dataProvider()->addFeatures( flist ); // snapping to closed linestring QgsGeometry polygonGeom = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 10.1 0, 9.9 10.1, 0 10, 0.1 -0.1))" ) ); QgsGeometrySnapper snapper( rl ); QgsGeometry result = snapper.snapGeometry( polygonGeom, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))" ) ); QgsGeometry polygonGeom2 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 10.1 0, 0 10, 0.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom2, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 0 10, 0 0))" ) ); // insert new vertex QgsGeometry polygonGeom3 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 20.5 0.5, 20 10, 0 9.9, 0.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom3, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 20.5 0.5, 20 10, 10 10, 0 10, 0 0))" ) ); // remove vertex QgsGeometry polygonGeom4 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0.1 -0.1, 10.1 0, 9.9 10.1, 5 10, 0 10, 0.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom4, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))" ) ); // snapping to unclosed linestring QgsGeometry polygonGeom5 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((100.1 -0.1, 110.1 0, 109.9 10.1, 100 10, 100.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom5, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((100 0, 110 0, 110 10, 100 10, 100 0))" ) ); QgsGeometry polygonGeom6 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((100.1 -0.1, 110.1 0, 100 10, 100.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom6, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((100 0, 110 0, 100 10, 100 0))" ) ); // insert new vertex QgsGeometry polygonGeom7 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((100.1 -0.1, 120.5 0.5, 120 10, 100 9.9, 100.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom7, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((100 0, 110 0, 120.5 0.5, 120 10, 110 10, 100 10, 100 0))" ) ); // remove vertex QgsGeometry polygonGeom8 = QgsGeometry::fromWkt( QStringLiteral( "Polygon((100.1 -0.1, 110.1 0, 109.9 10.1, 105 10, 100 10, 100.1 -0.1))" ) ); result = snapper.snapGeometry( polygonGeom8, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Polygon ((100 0, 110 0, 110 10, 100 10, 100 0))" ) ); }
int main() { int a, b, c, d, r; scanf("%d", &a); if (a >= 0) { a++; b = ff3(a); c = ff2(a); d = f2(a); r = b / c + a / d; } else { b = ff3(a); c = ff2(a); d = f2(a); r = b / c + a / d; } printf("%d\n", r); return 0; }
int main(void) { float f1; float f2 = 0.0; float f3 = 1.0; ff1(f1); ff1(f2); ff2(&f2, &f3); assert(f2 == f3); return 0; }
/* * GPT2 callback. */ static void gpt2cb(GPTDriver *gptp) { float f1, f2, f3, f4, f5; (void)gptp; f1 = ff1(2.0f); f2 = ff1(3.0f); f3 = ff1(4.0f); f5 = f1 + f2 + f3; f4 = ff1(5.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 196.0f) chSysHalt(); }
/* * GPT3 callback. */ static void gpt3cb(GPTDriver *gptp) { float f1, f2, f3, f4, f5; (void)gptp; f1 = ff1(1.0f); f2 = ff1(2.0f); f3 = ff1(3.0f); f5 = f1 + f2 + f3; f4 = ff1(4.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 100.0f) chSysHalt("float corrupion #4"); }
static msg_t WorkerThread(void *arg) { (void)arg; while(1) { float f1, f2, f3, f4, f5; f1 = ff1(3.0f); f2 = ff1(4.0f); f3 = ff1(5.0f); f5 = f1 + f2 + f3; f4 = ff1(6.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 324.0f) chSysHalt(); } }
static THD_FUNCTION(WorkerThread, arg) { (void)arg; while(1) { float f1, f2, f3, f4, f5; f1 = ff1(3.0f); f2 = ff1(4.0f); f3 = ff1(5.0f); f5 = f1 + f2 + f3; f4 = ff1(6.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 324.0f) chSysHalt("float corrupion #1"); } }
static msg_t PeriodicThread(void *arg) { (void)arg; while(1) { float f1, f2, f3, f4, f5; f1 = ff1(4.0f); f2 = ff1(5.0f); f3 = ff1(6.0f); f5 = f1 + f2 + f3; f4 = ff1(7.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 484.0f) chSysHalt(); chThdSleepSeconds(1); } }
static THD_FUNCTION(PeriodicThread, arg) { (void)arg; while(1) { float f1, f2, f3, f4, f5; f1 = ff1(4.0f); f2 = ff1(5.0f); f3 = ff1(6.0f); f5 = f1 + f2 + f3; f4 = ff1(7.0f); f5 = ff2(f5, f4, f5, f4); if (f5 != 484.0f) chSysHalt("float corrupion #2"); chThdSleepSeconds(1); } }
void TestQgsGeometrySnapper::snapPointToPoint() { QgsVectorLayer* rl = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsGeometry refGeom = QgsGeometry::fromWkt( QStringLiteral( "Point(0 0)" ) ); QgsFeature ff( 0 ); ff.setGeometry( refGeom ); QgsGeometry refGeom2 = QgsGeometry::fromWkt( QStringLiteral( "Point(1 0)" ) ); QgsFeature ff2( 2 ); ff2.setGeometry( refGeom2 ); QgsFeatureList flist; flist << ff << ff2; rl->dataProvider()->addFeatures( flist ); QgsGeometry pointGeom = QgsGeometry::fromWkt( QStringLiteral( "Point(0.1 -0.1)" ) ); QgsGeometrySnapper snapper( rl ); QgsGeometry result = snapper.snapGeometry( pointGeom, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Point (0 0)" ) ); pointGeom = QgsGeometry::fromWkt( QStringLiteral( "Point(0.6 -0.1)" ) ); result = snapper.snapGeometry( pointGeom, 1 ); QCOMPARE( result.exportToWkt(), QStringLiteral( "Point (1 0)" ) ); }
int main (int argc, char** argv) { UnitTest test (30); // Ensure environment has no influence. unsetenv ("TASKDATA"); unsetenv ("TASKRC"); test.is ((int)Task::textToStatus ("pending"), (int)Task::pending, "textToStatus pending"); test.is ((int)Task::textToStatus ("completed"), (int)Task::completed, "textToStatus completed"); test.is ((int)Task::textToStatus ("deleted"), (int)Task::deleted, "textToStatus deleted"); test.is ((int)Task::textToStatus ("recurring"), (int)Task::recurring, "textToStatus recurring"); test.is (Task::statusToText (Task::pending), "pending", "statusToText pending"); test.is (Task::statusToText (Task::completed), "completed", "statusToText completed"); test.is (Task::statusToText (Task::deleted), "deleted", "statusToText deleted"); test.is (Task::statusToText (Task::recurring), "recurring", "statusToText recurring"); // Round-trip testing. Task t3; t3.set ("name", "value"); std::string before = t3.composeF4 (); t3.parse (before); std::string after = t3.composeF4 (); t3.parse (after); after = t3.composeF4 (); t3.parse (after); after = t3.composeF4 (); test.is (before, after, "Task::composeF4 -> parse round trip 4 iterations"); // Legacy Format 1 (no longer supported) // [tags] [attributes] description\n // X [tags] [attributes] description\n std::string sample = "[tag1 tag2] [att1:value1 att2:value2] Description"; sample = "X " "[one two] " "[att1:value1 att2:value2] " "Description"; bool good = true; try { Task ff1 (sample); } catch (...) { good = false; } test.notok (good, "Support for ff1 removed"); // Legacy Format 2 (no longer supported) // uuid status [tags] [attributes] description\n sample = "00000000-0000-0000-0000-000000000000 " "- " "[tag1 tag2] " "[att1:value1 att2:value2] " "Description"; good = true; try { Task ff2 (sample); } catch (...) { good = false; } test.notok (good, "Support for ff2 removed"); // Legacy Format 3 // uuid status [tags] [attributes] [annotations] description\n sample = "00000000-0000-0000-0000-000000000000 " "- " "[tag1 tag2] " "[att1:value1 att2:value2] " "[123:ann1 456:ann2] Description"; Task ff3 (sample); std::string value = ff3.get ("uuid"); test.is (value, "00000000-0000-0000-0000-000000000000", "ff3 uuid"); value = ff3.get ("status"); test.is (value, "pending", "ff3 status"); test.ok (ff3.hasTag ("tag1"), "ff3 tag1"); test.ok (ff3.hasTag ("tag2"), "ff3 tag2"); test.is (ff3.getTagCount (), 2, "ff3 # tags"); value = ff3.get ("att1"); test.is (value, "value1", "ff3 att1"); value = ff3.get ("att2"); test.is (value, "value2", "ff3 att2"); value = ff3.get ("description"); test.is (value, "Description", "ff3 description"); // Current Format 4 // [name:"value" ...]\n sample = "[" "uuid:\"00000000-0000-0000-0000-000000000000\" " "status:\"pending\" " "tags:\"tag1,tag2\" " "att1:\"value1\" " "att2:\"value2\" " "description:\"Description\"" "]"; Task ff4 (sample); value = ff4.get ("uuid"); test.is (value, "00000000-0000-0000-0000-000000000000", "ff4 uuid"); value = ff4.get ("status"); test.is (value, "pending", "ff4 status"); test.ok (ff4.hasTag ("tag1"), "ff4 tag1"); test.ok (ff4.hasTag ("tag2"), "ff4 tag2"); test.is (ff4.getTagCount (), 2, "ff4 # tags"); value = ff4.get ("att1"); test.is (value, "value1", "ff4 att1"); value = ff4.get ("att2"); test.is (value, "value2", "ff4 att2"); value = ff4.get ("description"); test.is (value, "Description", "ff4 description"); /* TODO Task::composeCSV TODO Task::composeYAML TODO Task::id TODO Task::*Status TODO Task::*Tag* TODO Task::*Annotation* TODO Task::addDependency TODO Task::addDependency TODO Task::removeDependency TODO Task::removeDependency TODO Task::getDependencies TODO Task::getDependencies TODO Task::urgency */ // Task::operator== Task left ("[one:1 two:2 three:3]"); Task right (left); test.ok (left == right, "left == right -> true"); left.set ("one", "1.0"); test.notok (left == right, "left == right -> false"); // Task::validate Task bad ("[entry:1000000001 start:1000000000]"); good = true; try { bad.validate (); } catch (...) { good = false; } test.notok (good, "Task::validate entry <= start"); return 0; }
// Determine sensitivity to tracker dynamic inefficiency // by studying ratio of jet responses in Runs G and F (and BCD / F, E / F) void drawAvsB() { setTDRStyle(); string epocha = "BCD";//"BCD";//"H";//"F";//"BCD";//"F";//"E";//"BCD";//"F"; string epochb = "GH";//"G";//"BCD";//"G";//"E";//"E";//"F";//"G"; // Add the rest as well string epocha2 = "";//"EF"; string epochb2 = "";//"G"; string type = "data"; vector<string> methods; methods.push_back("mpfchs1"); methods.push_back("ptchs"); bool nozjptb = false; bool nogjmpf = false; bool nogjptb = true; bool mjvsjes = false; vector<string> samples; samples.push_back("zeejet"); samples.push_back("zmmjet"); samples.push_back("gamjet"); //samples.push_back("multijet"); cout << "draw"<<epocha<<"vs"<<epochb<<endl; const char *ct = type.c_str(); const char *pa = epocha.c_str(); const char *pb = epochb.c_str(); const char *pa2 = epocha2.c_str(); const char *pb2 = epochb2.c_str(); TFile *fg = new TFile(Form("rootfiles/jecdata%s.root",pb),"READ"); assert(fg && !fg->IsZombie()); TFile *ff = new TFile(Form("rootfiles/jecdata%s.root",pa),"READ"); assert(ff && !ff->IsZombie()); TFile *fg2(0), *ff2(0); if (epochb2!="") fg2 = new TFile(Form("rootfiles/jecdata%s.root",pb2),"READ"); if (epocha2!="") ff2 = new TFile(Form("rootfiles/jecdata%s.root",pa2),"READ"); TH1D *h = new TH1D("h", Form(";p_{T,ref} (GeV);%s ratio (%s / %s)", (type=="ratio" ? "Data/MC" : type=="data" ? "Data/data" : "MC/MC"), (epocha + (epocha2!="" ? "+"+epocha2 : "")).c_str(), (epochb + (epochb2!="" ? "+"+epochb2 : "")).c_str()), 3470,30,3500); h->SetMinimum(0.90); h->SetMaximum(1.15); h->GetXaxis()->SetMoreLogLabels(); h->GetXaxis()->SetNoExponent(); if (epocha=="F" && epochb=="G") lumi_13TeV = "Run2016F+G, 3.1+7.1 fb^{-1}"; if (epocha=="BCD" && epochb=="G") lumi_13TeV = "Run2016BCD+H, 12.9+8.8 fb^{-1}"; if (epocha=="BCD" && epochb=="G") lumi_13TeV = "Run2016BCD+FearlyGH, 12.9+16.8 fb^{-1}"; if (epocha=="BCD" && epochb=="F") lumi_13TeV = "Run2016BCD+F, 13+3.1 fb^{-1}"; if (epocha=="BCD" && epochb=="E") lumi_13TeV = "Run2016BCD+E, 13+4.0 fb^{-1}"; if (epocha=="E" && epochb=="F") lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}"; if (epocha=="F" && epochb=="E") lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}"; if ((epocha=="BCDEF" && epochb=="GH") || (epocha=="BCD" && epocha2=="EF" && epochb=="H" && epochb2=="G")) lumi_13TeV = "Run2016BCDEF+GH, 19.7+16.8 fb^{-1}"; if (epocha=="EF" && epochb=="BCD") lumi_13TeV = "Run2016BCD+EF, 12.9+6.8 fb^{-1}"; if (epocha=="H" && epochb=="G") lumi_13TeV = "Run2016G+H, 8.0+8.8 fb^{-1}"; if ((epocha=="BCD" && epocha2=="EF" && epochb=="G" && epochb2=="H")) lumi_13TeV = "Run2016BCDFearly+FlateGH, 19.7+16.8 fb^{-1}"; if ((epocha=="BCD" && epocha2=="" && ((epochb=="GH" && epochb2=="") || (epochb=="G" && epochb2=="H")))) lumi_13TeV = "Run2016BCD+FlateGH, 12.9+16.8 fb^{-1}"; if ((epocha=="EF" && epocha2=="" && ((epochb=="GH" && epochb2=="") || (epochb=="G" && epochb2=="H")))) lumi_13TeV = "Run2016EF+FlateGH, 6.8+16.8 fb^{-1}"; if ((epocha=="EF" && epocha2=="" && epochb=="G" && epochb2=="H")) lumi_13TeV = "Run2016EFearly+FlateGH, 6.8+16.8 fb^{-1}"; TCanvas *c1 = tdrCanvas("c1",h,4,11,true); c1->SetLogx(); TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); TMultiGraph *mg = new TMultiGraph(); string s = "draw"+epocha+(epocha2!="" ? "p" + epocha2 : "") +"vs"+epochb+(epochb2!="" ? "p" + epochb2 : ""); TGraphErrors *gmjb(0), *gmpf(0); for (unsigned int im = 0; im != methods.size(); ++im) { const char *cm = methods[im].c_str(); tex->DrawLatex(0.20,0.75-0.06*im,cm); s += "_" + methods[im]; for (unsigned int is = 0; is != samples.size(); ++is) { const char *cs = samples[is].c_str(); TGraphErrors *gg = (TGraphErrors*)fg->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); cout << cm << " " << cs << endl << flush; assert(gg); if (fg2) { TGraphErrors *gg2 = (TGraphErrors*)fg2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gg2); gg = addGraph(gg,gg2); } TGraphErrors *gf = (TGraphErrors*)ff->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gf); if (ff2) { TGraphErrors *gf2 = (TGraphErrors*)ff2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gf2); gf = addGraph(gf,gf2); } if (!(gf->GetN()==gg->GetN())) { // Remove highest pT point is that is the offender (BCD vs GH) if (gg->GetN()>gf->GetN() && fabs(gg->GetX()[gg->GetN()-1]/gf->GetX()[gf->GetN()-1]-1)>0.1 && fabs(gg->GetX()[gg->GetN()-2]/gf->GetX()[gf->GetN()-1]-1)<0.1) { cout << "Remove point B(N-1)" << endl; gg->RemovePoint(gg->GetN()-1); } else { cout << "sample " << samples[is] << " method " << methods[im] << " gf->N: " << gf->GetN() << " gg->N: " << gg->GetN() << endl; cout << " x_gf(N-1)=" << gf->GetX()[gf->GetN()-1] << " x_gg(N-1)=" << gg->GetX()[gg->GetN()-1] << " x_gg(N-2)=" << gg->GetX()[gg->GetN()-2] << endl; } assert(gf->GetN()==gg->GetN()); } TGraphErrors *g = (TGraphErrors*)gg->Clone(Form("ge_%s_%s",cm,cs)); for (int i = 0; i != g->GetN(); ++i) { double yg = gg->GetY()[i]; double yf = gf->GetY()[i]; g->SetPoint(i, gg->GetX()[i], yf / yg); double ex = gg->GetEX()[i]; double eg = gg->GetEY()[i]; double ef = gf->GetEY()[i]; g->SetPointError(i, ex, yf/yg*sqrt(pow(eg/yg,2)+pow(ef/yf,2))); } //g->Draw(is==0 ? "AP" : "SAMEP"); g->SetLineWidth(1+is); g->Draw("SAMEPZ"); if (samples[is]=="gamjet" && methods[im]=="mpfchs1" && nogjmpf) { tex->SetTextColor(kBlue); tex->DrawLatex(0.20,0.63,"#gamma+jet MPF excl. from fit"); tex->SetTextColor(kBlack); } else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) { tex->SetTextColor(kBlue); tex->DrawLatex(0.20,0.63,"#gamma+jet p_{T}^{bal} excl. from fit"); tex->SetTextColor(kBlack); } else if ((samples[is]=="zmmjet" || samples[is]=="zeejet") && methods[im]=="ptchs" && nozjptb) { tex->SetTextColor(kRed); tex->DrawLatex(0.20,0.63,"Z+jet p_{T}^{bal} excl. from fit"); tex->SetTextColor(kBlack); } else if (samples[is]=="multijet") { g->SetMarkerColor(kGray+1); g->SetLineColor(kGray+1); if (methods[im]=="ptchs") gmjb = g; if (methods[im]=="mpfchs1") gmpf = g; } else mg->Add(g); } // for is } // for im if (nogjmpf) s += "_nogjmpf"; if (nogjptb) s += "_nogptb"; if (nozjptb) s += "_nozptb"; if (mjvsjes) { s += "_mjvsjes"; tex->SetTextColor(kBlack); tex->DrawLatex(0.20,0.58,"Multijet vs JES fit"); } TF1 *fjes = new TF1("fjes",jesFit,30,2200,2); fjes->SetParameters(0.99,0.05); mg->Fit(fjes,"RN"); fjes->SetLineColor(kBlack); fjes->SetLineStyle(kDashed); fjes->SetLineWidth(2); fjes->SetRange(10.,3500.); fjes->Draw("SAME"); //TF1 *ft = new TF1("ft","1-[0]-[1]*pow(x,[2]) + ([3]+[4]*log(x))/x",30,2200); //ft->SetParameters(0,0.05,-0.5,1,0.1); //ft->FixParameter(3,0); // Logarithmic sigmoid //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-log(abs([1])))" // "/(log(abs([2])+abs([1]))-log(abs([1])))))", 30,2200); //ft->SetParameters(0.98, 150, 50); TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))",30,2200); //ft->SetParameters(0.98,log(145),log(190)-log(145)); //ft->SetParameters(0.982,4.967,0.271); //ft->SetParameters(0.976,5.040,0.370); // ENDCAP //ft->SetParameters(0.985,5.0,0.3); ft->SetParameters(0.985,5.025,0.3); //ft->FixParameter(1,5.03); // semi-weighted average of BCD and EF //ft->FixParameter(2,0.395); // combined fit to BCD+EF / G+H // ( 12.9*5.055+6.8*5.000)/(12.9+6.8) ft->FixParameter(1,5.036); // semi-weighted average of BCD/GH and EF/GH // ( 12.9*0.344 + 6.8*0.455)/(12.9+6.8) ft->FixParameter(2,0.391); // combined fit to BCD+EF / GH // Log-sigmoid + powerlaw //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))" // "*(1-[3]*pow(x,[4]))",30,2200); //ft->SetParameters(0.982,4.967,0.271,0.1,-0.2); // Double powerlaw //TF1 *ft = new TF1("ft","[4]-[0]*pow(x,[1])-[2]*pow(x,[3])",30,2200); //ft->SetParameters(0.05,-0.15,0.01,-0.3,1); mg->Fit(ft,"RN"); ft->SetLineColor(kBlue); ft->SetLineWidth(2); ft->SetRange(10.,3500.); ft->Draw("SAME"); // Map multijet with response ratio if (gmpf) { // we have multijet available TGraphErrors *gmpf2 = (TGraphErrors*)gmpf->Clone("gmpf2"); gmpf2->SetMarkerColor(kBlack);//kGray+1); gmpf2->SetLineColor(kBlack);//kGray+1); for (int i = 0; i != gmpf->GetN(); ++i) { if (mjvsjes) { gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i], fjes->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]); gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i], gmpf->GetEY()[i]); } else { gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i], ft->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]); gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i], gmpf->GetEY()[i]); } } gmpf2->Draw("SAMEPz"); } // multijet tex->SetTextColor(kBlue); tex->DrawLatex(0.50,0.85,Form("#chi^{2} / NDF = %1.1f / %d", ft->GetChisquare(), ft->GetNDF())); tex->SetTextColor(kBlack); tex->SetTextSize(0.040); tex->DrawLatex(0.50,0.80,Form("(#chi^{2} / NDF = %1.1f / %d)", fjes->GetChisquare(), fjes->GetNDF())); tex->SetTextColor(kBlue-9); tex->SetTextSize(0.030); tex->DrawLatex(0.20,0.25,ft->GetExpFormula()); tex->DrawLatex(0.20,0.20, Form("p_{0}=%1.3f#pm%1.3f" ", p_{1}=%1.3f#pm%1.3f" ", p_{2}=%1.3f#pm%1.3f", ft->GetParameter(0),ft->GetParError(0), ft->GetParameter(1),ft->GetParError(1), ft->GetParameter(2),ft->GetParError(2))); if (ft->GetNpar()>3) tex->DrawLatex(0.20,0.17, Form("p_{3}=%1.3f#pm%1.3f" ", p_{4}=%1.3f#pm%1.3f", ft->GetParameter(3),ft->GetParError(3), ft->GetParameter(4),ft->GetParError(4))); c1->SaveAs(Form("pdf/%s.pdf",s.c_str())); for (int i = 0; i != ft->GetNpar(); ++i) { cout << Form("%s%1.4g",i==0 ? "{" : ", ",ft->GetParameter(i)); } cout << "}" << endl; }