int main(void) { static const struct st3 a = {1, 2, 3, 4, 5, 6}; l1(100); l2(100, 200); l3(100, 200, 300); l4(100, 200, 300, 400); l5(100, 200, 300, 400, 500); l6(100, 200, 300, 400, 500, 600); l7(100, 200, 300, 400, 500, 600, 700); l8(100, 200, 300, 400, 500, 600, 700, 800); d1(); d2(43); d3(100, 200); d4(a); d5('a', 43, a); d6('a', 1); c1(44); c2(100, 'a', 3.4); c3(200, 2.777, 'q'); c4(200, 1); c5(1.1, 2.2); c6(1.23, 45.6); c7('z', 0x200); a1('a'); a2(10); a3(20); a4(102030405060LL); b1('a', 20); b2(30, 'b'); b3(10, 20, 30, 40, 50, 60); s1(sx); s1p(&sx); s2(sy); s3(sz); s4(sq); s5(sa); s6(sb); r1(); r3(); r4(); q1(200, sx); q2(300, 't', sx); q3(400, 410, sy); q4(500, 510, sq); q5(600, 610, 'z', 'q', sq); real1("fresh air"); real2(); return 0; }
void initB() { this->clearAppend(this->m_csB); R1Variable<T> d1(1), d2(2), d3(3), d4(4), d5(5), d6(6); this->m_csB.addConstraint(d1 * d2 == d5); this->m_csB.addConstraint(d1 * d3 == d6); this->m_csB.addConstraint(d5 * d6 == d4); this->m_csB.swap_AB_if_beneficial(); // witness always consistent this->m_witnessB.assignVar(d1, T(m_d1)); this->m_witnessB.assignVar(d2, T(m_d2)); this->m_witnessB.assignVar(d3, T(m_d3)); this->m_witnessB.assignVar(d4, T(m_d1 * m_d1 * m_d2 * m_d3)); this->m_witnessB.assignVar(d5, T(m_d1 * m_d2)); this->m_witnessB.assignVar(d6, T(m_d1 * m_d3)); // public inputs may be inconsistent this->m_inputB.assignVar(d1, T(m_d1)); this->m_inputB.assignVar(d2, T(m_d2)); this->m_inputB.assignVar(d3, T(m_d3)); this->m_inputB.assignVar(d4, T(m_d4)); this->finalize(this->m_csB); }
//Testing Suite for Dice Class void unit1(){ ofstream fout; fout.open("P2_Lee_Output.txt", ios::out | ios::app); Dice d1; //default of 6 sides, 2 dice Dice d2(4, 1); //4 sides , 1 dice in set Dice d3(8, 4); //8 sides, 4 dice in set Dice d4(6,0); //No dice in the set cout <<"Testing the Dice class" << endl; cout <<"outputting to file......" << endl; d1.roll(); fout <<"Test Suite 1: Default parameters of 6 sides and 4 dice in the set." << endl << "Values: " << right << setw(7) << d1; d2.roll(); fout <<"Test Suite 2: Parameters of 4 sides and 1 di in the set." << endl << "Values: " << right << setw(7) << d2; d3.roll(); fout <<"Test Suite 3: Parameters of 8 sides and 4 dice in the set." << endl << "Values: " << right << setw(7) << d3; d4.roll(); fout <<"Test Suite 4: Parameters of 6 sides and 0 dice in the set." << endl << "Values: " << right << setw(7) << d4; fout << "Test Suite 5: Random Range Test, using 6-sided dice " << endl; for (int j = 0; j < 5; ++j){ d1.roll(); fout << "Values: " << right << setw(7) << d1; } }
std::auto_ptr<cpunit::TestRunner> cpunit::TestExecutionFacade::get_test_runner(const bool robust, const double max_time) const { std::auto_ptr<TestRunner> leaf(new BasicTestRunner); if (robust) { CPUNIT_ITRACE("TestExecutionFacade::get_test_runner - Returning robust TestRunner"); // For handling of extra, custom exceptions, insert your handler here, // and remember to modify the next decorator insertion... // std::auto_ptr<TestRunnerDecorator> d1(new MyCustomHandler); // d1->set_inner(leaf.release()); // Add a layer of exception handling over the executing test runner std::auto_ptr<TestRunnerDecorator> d2(new RunAllTestRunner); d2->set_inner(leaf.release()); // Add a layer of time taking std::auto_ptr<TestRunnerDecorator> d3(new TimeGuardRunner(max_time)); d3->set_inner(d2.release()); // Add a new layer of exception handling in case the max-time is exceeded std::auto_ptr<TestRunnerDecorator> d4(new RunAllTestRunner); d4->set_inner(d3.release()); return std::auto_ptr<TestRunner>(d4.release()); } else { CPUNIT_ITRACE("TestExecutionFacade::get_test_runner - Returning BasicTestRunner"); // Add a layer of time taking over the executing test runner std::auto_ptr<TestRunnerDecorator> d1(new TimeGuardRunner(max_time)); d1->set_inner(leaf.release()); return std::auto_ptr<TestRunner>(d1.release()); } }
void shot_image_cross(sf_complex *wld_s,sf_complex *wld_r,float *image_z,int nx,int ny,struct shot_image_par_type image_par){ sf_complex ws,wr; int ihx,ihy,ix,iy,iihx,iihy,iohx,iohy; int shift_ix_s,shift_iy_s,shift_ix_r,shift_iy_r; int nimg[3]; d4(nx,image_par.nhy,image_par.nhx,nimg); iohy=(int)(image_par.ohy/image_par.dy); iohx=(int)(image_par.ohx/image_par.dx); for(iy=0;iy<ny;iy++){ for(ix=0;ix<nx;ix++){ for(ihy=0; ihy<image_par.nhy;ihy++){ //hy=ihy*image_par.dy+image_par.ohy; iihy=(int)(hy/image_par.dy); iihy=ihy+iohy; for(ihx=0;ihx<image_par.nhx;ihx++){ //hx=ihx*image_par.dx+image_par.ohx; iihx=(int)(hx/image_par.dx); iihx=ihx+iohx; shift_ix_s=ix-iihx; shift_iy_s=iy-iihy; shift_ix_r=ix+iihx; shift_iy_r=iy+iihy; if (shift_ix_s <0) shift_ix_s=0; if (shift_ix_s >=nx) shift_ix_s=nx-1; if (shift_ix_r <0) shift_ix_r=0; if (shift_ix_r >=nx) shift_ix_r=nx-1; if (shift_iy_s <0) shift_iy_s=0; if (shift_iy_s >=ny) shift_iy_s=ny-1; if (shift_iy_r <0) shift_iy_r=0; if (shift_iy_r >=ny) shift_iy_r=ny-1; ws=wld_s[i2(shift_iy_s,shift_ix_s,nx)]; wr=wld_r[i2(shift_iy_r,shift_ix_r,nx)]; image_z[i4(iy,ix,ihy,ihx,nimg)]+=crealf( conjf(ws)*wr); } } } } }
int main() { Sales_data d1; Sales_data d2("0-201-78345-X"); Sales_data d3("0-201-78345-X", 5, 2.5); Sales_data d4(std::cin); print(std::cout, d1) << std::endl; print(std::cout, d2) << std::endl; print(std::cout, d3) << std::endl; print(std::cout, d4) << std::endl; Sales_data total(std::cin); if (std::cin) { Sales_data trans(std::cin); while (std::cin) { if (total.isbn() == trans.isbn()) { total.combine(trans); } else { print(std::cout, total) << std::endl; total = trans; // Use default copy constructor } read(std::cin, trans); } print(std::cout, total) << std::endl; } else { std::cerr << "No data!" << std::endl; return -1; } return 0; }
void testCompare() { // Date1 = Date2 vmime::datetime d1(2005, 4, 22, 14, 6, 0, vmime::datetime::GMT2); vmime::datetime d2(2005, 4, 22, 10, 6, 0, vmime::datetime::GMT_2); VASSERT_EQ("1.1", true, d1 == d2); VASSERT_EQ("1.2", false, d1 != d2); VASSERT_EQ("1.3", true, d1 <= d2); VASSERT_EQ("1.4", false, d1 < d2); VASSERT_EQ("1.5", true, d1 >= d2); VASSERT_EQ("1.6", false, d1 > d2); // Date1 < Date2 vmime::datetime d3(2005, 4, 22, 14, 6, 0); vmime::datetime d4(2005, 4, 22, 15, 6, 0); VASSERT_EQ("2.1", false, d3 == d4); VASSERT_EQ("2.2", true, d3 != d4); VASSERT_EQ("2.3", true, d3 <= d4); VASSERT_EQ("2.4", true, d3 < d4); VASSERT_EQ("2.5", false, d3 >= d4); VASSERT_EQ("2.6", false, d3 > d4); // Date1 > Date2 vmime::datetime d5(2005, 4, 22, 15, 6, 0); vmime::datetime d6(2005, 4, 22, 14, 6, 0); VASSERT_EQ("3.1", false, d5 == d6); VASSERT_EQ("3.2", true, d5 != d6); VASSERT_EQ("3.3", false, d5 <= d6); VASSERT_EQ("3.4", false, d5 < d6); VASSERT_EQ("3.5", true, d5 >= d6); VASSERT_EQ("3.6", true, d5 > d6); }
TEST(ArrayTest, getNumRows) { TwoDArray<int> i4(10, 5, 42); TwoDArray<double> d4(2, 9, 9.9); TwoDArray<std::string> s4(6, 8, "e"); EXPECT_EQ(10, i4.access(8,2)); EXPECT_EQ(2, d4.access(0,0)); EXPECT_EQ(6, s4.access(5,7)); }
int main() { LinearGenerator linearGen(0,20,2); RandomGenerator randomGen(10); FibonacciGenerator fibGen(10); // MOCK 1 std::vector<double> myVector; myVector.push_back(15); myVector.push_back(20); myVector.push_back(35); myVector.push_back(40); myVector.push_back(50); MockGenerator mockGen(myVector); // MOCK 2 std::vector<double> myVector2; myVector2.push_back(1); myVector2.push_back(10); myVector2.push_back(50); MockGenerator mockGen2(myVector2); LinearInterpolationCalculator linInterCalc; NearestRankCalculator nearestRankCalc; DistributionTester mock0(&mockGen, &nearestRankCalc); DistributionTester mock1(&mockGen, &linInterCalc); DistributionTester mock2(&mockGen2, &linInterCalc); DistributionTester d1(&linearGen, &linInterCalc); DistributionTester d2(&linearGen, &nearestRankCalc); DistributionTester d3(&randomGen, &linInterCalc); DistributionTester d4(&randomGen, &nearestRankCalc); DistributionTester d5(&fibGen, &linInterCalc); DistributionTester d6(&fibGen, &nearestRankCalc); std::cout << "d1: " << d1.getPercentile(50) << std::endl; std::cout << "d2: " << d2.getPercentile(50) << std::endl; std::cout << "mock0: " << mock0.getPercentile(30) << std::endl; std::cout << "mock0: " << mock0.getPercentile(40) << std::endl; std::cout << "mock0: " << mock0.getPercentile(50) << std::endl; std::cout << "mock0: " << mock0.getPercentile(100) << std::endl; std::cout << "mock1: " << mock1.getPercentile(10) << std::endl; std::cout << "mock1: " << mock1.getPercentile(30) << std::endl; std::cout << "mock1: " << mock1.getPercentile(40) << std::endl; std::cout << "mock1: " << mock1.getPercentile(90) << std::endl; std::cout << "mock2: " << mock2.getPercentile(10) << std::endl; std::cout << "mock2: " << mock2.getPercentile(20) << std::endl; std::cout << "mock2: " << mock2.getPercentile(30) << std::endl; std::cout << "mock2: " << mock2.getPercentile(40) << std::endl; std::cout << "mock2: " << mock2.getPercentile(50) << std::endl; std::cout << "mock2: " << mock2.getPercentile(60) << std::endl; std::cout << "mock2: " << mock2.getPercentile(70) << std::endl; std::cout << "mock2: " << mock2.getPercentile(80) << std::endl; std::cout << "mock2: " << mock2.getPercentile(90) << std::endl; }
TEST(Decimal128Test, TestDecimal128IsInfinite) { Decimal128 d1("NaN"); Decimal128 d2("10.5"); Decimal128 d3("Inf"); Decimal128 d4("-Inf"); ASSERT_FALSE(d1.isInfinite()); ASSERT_FALSE(d2.isInfinite()); ASSERT_TRUE(d3.isInfinite()); ASSERT_TRUE(d4.isInfinite()); }
unsigned int DiceBox::d4(const unsigned short int n) { unsigned int result = 0; unsigned int i; for (i=0; i<n; i=i+1) { result += d4(); } return result; }
int main() { Datum d1(02, 12, 2014); Datum d2(02, 01, 2014); Datum d3(31, 12, 2014); Datum d4(02, 12, 2014); std::cout << d1 << d2 << d3 << d4; return 0; }
void shot_image_stack(float *img,float mig_min_x,float mig_min_y,int mig_nx,int mig_ny,sf_file tag, struct shot_image_par_type image_par) /*< stack image >*/ { float *tmp_img; float img_min_x,img_max_x,img_min_y,img_max_y,img_dx,img_dy; float mig_max_x,rite_min_x,rite_max_x; int img_ny,img_nx,rite_nx; int n_hy_hx,img_nhx,img_nhy,nz; int ntmp_img[2],nimg[3]; int rite_ix_b,array_ix_b; int block_size,block_i; int iy,rite_iy,ix,i_hy_hx,iz; img_min_x=image_par.min_x; img_max_x=image_par.max_x; img_min_y=image_par.min_y; img_max_y=image_par.max_y; img_dx=image_par.dx; img_dy=image_par.dy; img_ny=image_par.ny; img_nx=image_par.nx; img_nhx=image_par.nhx; img_nhy=image_par.nhy; nz=image_par.nz; mig_max_x=((float)(mig_nx-1))*img_dx+mig_min_x; rite_min_x=SF_MAX(img_min_x,mig_min_x); rite_max_x=SF_MIN(img_max_x,mig_max_x); rite_nx=(rite_max_x-rite_min_x)/img_dx+1; n_hy_hx= img_nhy*img_nhx; d3(n_hy_hx,nz,ntmp_img); d4(mig_ny,mig_nx,n_hy_hx,nimg); if (rite_nx >=1){ rite_ix_b= (rite_min_x-img_min_x)/img_dx; array_ix_b=(rite_min_x-mig_min_x)/img_dx; tmp_img=sf_floatalloc(rite_nx*n_hy_hx*nz); block_size=4*n_hy_hx*nz; for(iy=0;iy<mig_ny;iy++){ vector_value_f(tmp_img,0.0,rite_nx*n_hy_hx*nz); rite_iy= iy+(mig_min_y-img_min_y)/img_dy; if (rite_iy < img_ny && rite_iy>= 0){ block_i=rite_iy*img_nx+rite_ix_b; sf_seek(tag,block_i*block_size,SEEK_SET); sf_floatread(tmp_img,rite_nx*n_hy_hx*nz,tag); for(ix=0;ix<rite_nx;ix++){ for(i_hy_hx=0;i_hy_hx<n_hy_hx;i_hy_hx++){ for(iz=0;iz<nz;iz++){ tmp_img[i3(ix,i_hy_hx,iz,ntmp_img)]+=img[i4(iz,iy,array_ix_b+ix,i_hy_hx,nimg)]; } } } sf_seek(tag,block_i*block_size,SEEK_SET); sf_floatwrite(tmp_img,rite_nx*n_hy_hx*nz,tag); } } free(tmp_img); } }
int main() { Sales_data d1("CppPrimer"), d2("JavaCore"), d3("PythonCookBook"), d4("CppCore"), d5("AwesomeCPP"); std::vector<Sales_data> v{d1, d2, d3, d4, d5}; //! @note the elements the iterators pointing to //! must match the parameters of the predicate. std::sort(v.begin(), v.end(), compareIsbn); for (const auto& element : v) std::cout << element.isbn() << " "; std::cout << std::endl; }
void shot_image_cross_tilt(sf_complex *wld_s,sf_complex *wld_r,float *image_z,int nx,int ny, struct shot_image_par_type image_par,int nx_iz) /*< cross correlation >*/ { sf_complex ws,wr; int ihx,ihy,ix,iy,iihx,iihy,iohx,iohy; int shift_ix_s,shift_iy_s,shift_ix_r,shift_iy_r; float eps; int nimg[3]; int nsmooth; nsmooth=200; eps=1200; d4(nx,image_par.nhy,image_par.nhx,nimg); iohy=(int)(image_par.ohy/image_par.dy); iohx=(int)(image_par.ohx/image_par.dx); for(iy=0;iy<ny;iy++){ for(ix=0;ix<nx_iz;ix++){ for(ihy=0; ihy<image_par.nhy;ihy++){ //hy=ihy*image_par.dy+image_par.ohy; iihy=(int)(hy/image_par.dy); iihy=ihy+iohy; for(ihx=0;ihx<image_par.nhx;ihx++){ //hx=ihx*image_par.dx+image_par.ohx; iihx=(int)(hx/image_par.dx); iihx=ihx+iohx; shift_ix_s=ix-iihx; shift_iy_s=iy-iihy; shift_ix_r=ix+iihx; shift_iy_r=iy+iihy; if (shift_ix_s <0) shift_ix_s=0; if (shift_ix_s >=nx_iz) shift_ix_s=nx_iz-1; if (shift_ix_r <0) shift_ix_r=0; if (shift_ix_r >=nx_iz) shift_ix_r=nx_iz-1; if (shift_iy_s <0) shift_iy_s=0; if (shift_iy_s >=ny) shift_iy_s=ny-1; if (shift_iy_r <0) shift_iy_r=0; if (shift_iy_r >=ny) shift_iy_r=ny-1; ws=wld_s[i2(shift_iy_s,shift_ix_s,nx)]; wr=wld_r[i2(shift_iy_r,shift_ix_r,nx)]; // wait for nx /* de=0.0; for (ismooth=1;ismooth<=nsmooth;ismooth++){ ixsmooth=shift_ix_s-nsmooth/2+ismooth; if (ixsmooth<0) ixsmooth=0; if (ixsmooth>=nx_iz) ixsmooth=nx_iz-1; de=de+wld_s[i2(shift_iy_s,ixsmooth,nx)]*conjg(wld_s[i2(shift_iy_s,ixsmooth,nx)]); } de=de/nsmooth; */ //image_z[i4(iy,ix,ihy,ihx,nimg)]+=real( conjg(ws)*wr/(conjg(ws)*ws+eps) ); //image_z[i4(iy,ix,ihy,ihx,nimg)]+=real( conjg(ws)*wr/(de) ); image_z[i4(iy,ix,ihy,ihx,nimg)]+=crealf( conjf(ws)*wr); //image_z[i4(iy,ix,ihy,ihx,nimg)]+=real( conjg(ws)*ws); } } } } }
TEST(Decimal128Test, TestDecimal128IsNegative) { Decimal128 d1("NaN"); Decimal128 d2("-NaN"); Decimal128 d3("10.5"); Decimal128 d4("-10.5"); Decimal128 d5("Inf"); Decimal128 d6("-Inf"); ASSERT_FALSE(d1.isNegative()); ASSERT_FALSE(d3.isNegative()); ASSERT_FALSE(d5.isNegative()); ASSERT_TRUE(d2.isNegative()); ASSERT_TRUE(d4.isNegative()); ASSERT_TRUE(d6.isNegative()); }
/// Test the overlapped by function void TextChangeTest::testBoundaryMethods() { // INSERT TESTS TextChange s1(4,4,""); // [ ] TextChange s2(0,2,""); // [ ] TextChange s3(5,2,""); // [ ] TextChange s4(1,2,""); // [ ] TextChange s5(2,2,""); // [ ] // test non overlap touch testFalse( s1.isOverlappedBy(&s2) ); testFalse( s1.isTouchedBy(&s2) ); testFalse( s2.isOverlappedBy(&s1) ); testFalse( s2.isTouchedBy(&s1) ); // test overlap (fully included) testTrue( s1.isOverlappedBy(&s3) ); testFalse( s1.isTouchedBy(&s3) ); testTrue( s3.isOverlappedBy(&s1) ); testFalse( s3.isTouchedBy(&s1) ); // test overlap not fully included testTrue( s4.isOverlappedBy(&s5)); testFalse( s4.isTouchedBy(&s5)); testTrue( s5.isOverlappedBy(&s4)); testFalse( s5.isTouchedBy(&s5)); // test touching items testTrue( s2.isTouchedBy(&s5)); testFalse( s2.isOverlappedBy(&s5)); testTrue( s5.isTouchedBy(&s2)); testFalse( s5.isOverlappedBy(&s2)); // BACKSPACE TEST TextChange d1(0,0,"Y"); TextChange d2(1,0,"X"); testFalse( d1.isTouchedBy(&d2) ); testFalse( d1.isOverlappedBy(&d2) ); testTrue( d2.isTouchedBy(&d1) ); testFalse( d2.isOverlappedBy(&d1) ); TextChange d3(0,0,"X"); TextChange d4(0,0,"Y"); testTrue( d3.isTouchedBy(&d4) ); testFalse( d3.isOverlappedBy(&d4) ); testTrue( d4.isTouchedBy(&d3) ); testFalse( d4.isOverlappedBy(&d3) ); }
int main() { Sales_data d1("aa"), d2("aaa"), d3("aaa"), d4("z"), d5("aaaz"); std::vector<Sales_data> v{ d1, d2, d3, d4, d5 }; std::sort(v.begin(), v.end(), [](const Sales_data &sd1, const Sales_data &sd2) {return sd1.isbn().size() < sd2.isbn().size();}); for (auto &element : v) std::cout << element.isbn() << " "; std::cout << std::endl; return 0; }
int main() { wy_Sales_data d1("aa"), d2("aaaa"), d3("aaa"), d4("z"), d5("aaaaz"); std::vector<wy_Sales_data> v = {d1,d2,d3,d4,d5}; //! @note the elements the iterators pointing to //! must match the parameters of the predicate. std::sort(v.begin(), v.end(), compareIsbn); for(const auto &element : v) std::cout << element.isbn() << " "; std::cout <<"\n"; return 0; }
int main(void) { animal a(std::string("아름이")); dog d(std::string("쫑"), 3); dog_ptr d2(new dog("메리", 2)); dog_ptr d3 = d2; dog_ptr d4(d2); // dog_ptr d4 = dog_ptr(&d); dog_list_t dogarr; std::cout << "hello vladimir" << std::endl; std::cout << a.get_name() << std::endl; std::cout << d.get_age() << std::endl; std::cout << d2->get_name() << std::endl; std::cout << d3->get_name() << std::endl; std::cout << d4->get_name() << std::endl; dogarr.push_back(&d); dogarr.push_back(d2.get()); dogarr.push_back(d3.get()); dogarr.push_back(d4.get()); std::cout << "------" << std::endl; for (int i = 0; i < dogarr.size(); i++) std::cout << dogarr[i]->get_name() << std::endl; std::cout << "------" << std::endl; dog_ptr_array_t dogs; dogs.push_back(d2); dogs.push_back(d3); dogs.push_back(d4); dogs.push_back(dog_ptr(new dog("방울이", 1))); while (!dogs.empty()) { dog_ptr ddd = dogs.front(); std::cout << "[ARRAY] " << ddd->get_name() << ", " << ddd->get_age() << ", " << ddd->get_species() << std::endl; dogs.pop_front(); } std::cout << "------" << std::endl; return 0; }
void constructionTest() { csvsqldb::Duration d1(1, 2, 5); MPF_TEST_ASSERTEQUAL(1, d1.years()); MPF_TEST_ASSERTEQUAL(2, d1.months()); MPF_TEST_ASSERTEQUAL(5, d1.days()); MPF_TEST_ASSERTEQUAL(0, d1.hours()); MPF_TEST_ASSERTEQUAL(0, d1.minutes()); MPF_TEST_ASSERTEQUAL(0, d1.seconds()); MPF_TEST_ASSERTEQUAL(csvsqldb::Duration::Positive, d1.sign()); csvsqldb::Duration d2(1, 2, 5, 17, 6, 45); MPF_TEST_ASSERTEQUAL(1, d2.years()); MPF_TEST_ASSERTEQUAL(2, d2.months()); MPF_TEST_ASSERTEQUAL(5, d2.days()); MPF_TEST_ASSERTEQUAL(17, d2.hours()); MPF_TEST_ASSERTEQUAL(6, d2.minutes()); MPF_TEST_ASSERTEQUAL(45, d2.seconds()); MPF_TEST_ASSERTEQUAL(csvsqldb::Duration::Positive, d2.sign()); csvsqldb::Duration d3; MPF_TEST_ASSERTEQUAL(0, d3.years()); MPF_TEST_ASSERTEQUAL(0, d3.months()); MPF_TEST_ASSERTEQUAL(0, d3.days()); MPF_TEST_ASSERTEQUAL(0, d3.hours()); MPF_TEST_ASSERTEQUAL(0, d3.minutes()); MPF_TEST_ASSERTEQUAL(0, d3.seconds()); MPF_TEST_ASSERTEQUAL(csvsqldb::Duration::Positive, d3.sign()); csvsqldb::Duration d4(1, 2, 3, csvsqldb::Duration::Negative); MPF_TEST_ASSERTEQUAL(1, d4.years()); MPF_TEST_ASSERTEQUAL(2, d4.months()); MPF_TEST_ASSERTEQUAL(3, d4.days()); MPF_TEST_ASSERTEQUAL(0, d4.hours()); MPF_TEST_ASSERTEQUAL(0, d4.minutes()); MPF_TEST_ASSERTEQUAL(0, d4.seconds()); MPF_TEST_ASSERTEQUAL(csvsqldb::Duration::Negative, d4.sign()); MPF_TEST_ASSERTEQUAL(-1, d4.yearsWithSign()); MPF_TEST_ASSERTEQUAL(-2, d4.monthsWithSign()); MPF_TEST_ASSERTEQUAL(-3, d4.daysWithSign()); MPF_TEST_ASSERTEQUAL(0, d4.hoursWithSign()); MPF_TEST_ASSERTEQUAL(0, d4.minutesWithSign()); MPF_TEST_ASSERTEQUAL(0, d4.secondsWithSign()); }
TEST(test_drone_lo_basico, igualdad_drone_funciona_ok) { Drone d1(1, algunos_productos()); Drone d2(1, algunos_productos_pero_en_otro_orden()); EXPECT_TRUE(d1 == d2); Drone d3(2, algunos_productos()); EXPECT_FALSE(d1 == d3); Drone d4(1, otros_productos()); EXPECT_FALSE(d1 == d4); Posicion p = d1.posicionActual(); p.x++; p.y++; Drone d5(1, algunos_productos()); d5.cambiarPosicionActual(p); EXPECT_FALSE(d1 == d5); }
int compile_test() { funptr f = (funptr) gen->cp; printf("Compiling...\n"); d1(gen, 0xB8); // MOV EAX, 1234 d1(gen, 0xD2); d1(gen, 0x04); d1(gen, 0x00); d1(gen, 0x00); d1(gen, 0xB8); // MOV EAX, 0x12345678 d4(gen, 0x12345678); d1(gen, 0xC3); // RET disasm(gen); printf("Execute...\n"); printf( "f() returned: %ld\n", f() ); // should say 305419896 return 0; }
static void test1() { WCValSList<String> list; WCValSList<String> list2; String d1("svstr#1"); String d2("svstr#2"); String d3("svstr#3"); String d4("svstr#4"); String d5("srover:1#1"); String d6("srover:1#2"); list.append( d1 ); list.append( d2 ); list.append( d3 ); list.append( d4 ); list2.append( d3 ); list2.append( d2 ); list2.append( d1 ); WCValSListIter<String> liter(list); String data; for(;;) { if( !liter() ) break; data = liter.current(); cout << "[" << data << "]\n"; }; cout << "\ndo a reset\n\n"; liter.reset(); if( liter() ) { cout << "[" << liter.current() << "]\n"; } if( liter() ) { cout << "[" << liter.current() << "]\n"; } cout << "\ndo a reset to list 2\n\n"; liter.reset( list2 ); for(;;) { if( !liter() ) break; data = liter.current(); cout << "[" << data << "]\n"; }; cout << "\n"; cout.flush(); }
static void tst0() { std::cout << "--------------------------------\n"; imdd_manager m; imdd_ref d1(m), d2(m), d3(m), d4(m); d1 = m.mk_empty(1); d2 = m.mk_empty(1); m.insert_dupdt(d1, 10, 20); m.insert_dupdt(d1, 31, 50); m.insert_dupdt(d2, 1, 5); m.insert_dupdt(d2, 11, 13); m.mk_product(d1, d2, d4); m.mk_product(d4, d2, d4); m.mk_product_dupdt(d1, d2); std::cout << "d1:\n" << mk_ll_pp(d1, m) << "\n-------\n"; m.mk_product_dupdt(d1, d2); std::cout << "d4:\n" << mk_ll_pp(d4, m) << "\nd1:\n" << mk_ll_pp(d1, m) << "\nd2:\n" << mk_ll_pp(d2, m) << "\n"; std::cout << d1 << "\n" << d2 << "\n"; m.mk_product_dupdt(d1, d1); std::cout << "d1 X d1:\n" << mk_ll_pp(d1, m) << "\n"; }
Rcpp::List CEnv::GetTrace() { Rcpp::List result = Rcpp::List::create(); std::vector< std::string > list_ = t->GetTracedList(); for (unsigned int p = 0; p < list_.size(); p++) { if (list_[p] == "index") { result("index") = std::vector<double>(t->trace[p],t->trace[p]+t->mnindex); } if (list_[p] == "alpha") { result("alpha") = std::vector<double>(t->trace[p],t->trace[p]+t->mnindex); } if (list_[p] == "k_star") { result("k_star") = std::vector<double>(t->trace[p],t->trace[p]+t->mnindex); } if (list_[p] == "Nmis") { result("Nmis") = std::vector<double>(t->trace[p],t->trace[p]+t->mnindex); } if (list_[p] == "nu") { Rcpp::NumericMatrix NU(t->mnindex, m->par->K); for ( int i = 0; i < t->mnindex; i++) { for (int j = 0; j < m->par->K; j++) { NU(i,j) = t->trace[p][i*m->par->K+ j]; } } result("nu") = NU; } if (list_[p] == "z") { Rcpp::IntegerMatrix Z(t->mnindex, m->par->n); for ( int i = 0; i < t->mnindex; i++) { for (int j = 0; j < m->par->n; j++) { Z(i,j) = (int)t->trace[p][i*m->par->n+ j]; } } result("z") = Z; } if (list_[p] == "ImputedX") { int size = m->par->n*m->par->J; Rcpp::IntegerMatrix ImputedX(t->mnindex,size); for (int i = 0; i < t->mnindex; i++) { for (int j = 0; j < size; j++) { ImputedX(i,j) = t->trace[p][i*size+ j]; } } result("ImputedX") = ImputedX; } if (list_[p] == "psi") { int size = m->par->K * m->par->cumLevelsJ[m->par->J]; Rcpp::Dimension d(m->par->J*m->par->K*m->par->L,t->mnindex); Rcpp::NumericVector psi4d(d); int size_new = m->par->J*m->par->K*m->par->L; for (int s = 0; s < t->mnindex; s++) { for (int k = 0; k < m->par->K; k++) { for (int j= 0; j < m->par->J; j++) { for (int l = 0; l < m->par->levelsJ[j]; l++) { psi4d[l + k * m->par->L + j * m->par->L * m->par->K + s*size_new] = t->trace[p][size * s + (m->par->cumLevelsJ[j]+l) * m->par->K + k]; } for (int l = m->par->levelsJ[j]; l <m->par->L;l++) { psi4d[l + k * m->par->L + j * m->par->L * m->par->K + s*size_new] = NA_REAL; } } } } Rcpp::NumericVector d4(4); d4[0] = m->par->L; d4[1] = m->par->K; d4[2]= m->par->J; d4[3] =t->mnindex; psi4d.attr("dim") = d4; result("psi") = psi4d; } } return result; }
void dpps::Pattern_random::generate () { // We have do declare them all. We cannot do a switch of if, // because distributions would get out of scope. // The only other possibility would be to place the switch inside // the loop, but it would be very inefficient to call the constructor // everytime. // So we have to pay for overhead and initialize them all in te beginning. // It's probably a negligible amount of time and memory as compared to the // loop. // signification of parametres depends on the engine. Some engines // need only one parametre. // For all user-changeable values (p1 and p2), 1.0 would have been the // default if we had not specified it, so it is an acceptable value for the // user as well. const double p1 {pattern_settings. p1} ; const double p2 {pattern_settings. p2} ; std::uniform_real_distribution<double> d0 (-p1, p1) ; // min, max // Normal-type std::normal_distribution<double> d1 (0.0, p1) ; // average = 0, sigma std::lognormal_distribution<double> d2 (0.0, p1) ; // average = 0, m std::chi_squared_distribution<double> d3 (p1) ; // n std::cauchy_distribution<double> d4 (p1, p2) ; // a, b std::fisher_f_distribution<double> d5 (p1, p2) ; // m, n std::student_t_distribution<double> d6 (p1) ; // n // Poisson-type std::exponential_distribution<double> d7 (p1) ; // lambda std::gamma_distribution<double> d8 (p1, p2) ; // alpha, beta std::weibull_distribution<double> d9 (p1, p2) ; // a, b Polyline p ; p. closed = true ; double x {0.0}, y {0.0} ; long_unsigned_int i {0}, attempts {0} ; //const double s {pattern_settings. side / 2.0} ; if (pattern_settings. max_attempts < pattern_settings. number) pattern_settings. max_attempts = std::numeric_limits<long_unsigned_int>::max () ; //std::cout << "hello" << i << " " << pattern_settings. number << " " << attempts << " " << pattern_settings. max_attempts << std::endl ; while ((i < pattern_settings. number) && (attempts < pattern_settings. max_attempts)) { bool overlap = false ; switch (pattern_settings. type) { case type_uniform_real_distribution: // 0 x = d0 (pseudorandom_generator) ; y = d0 (pseudorandom_generator) ; //std::cout << "alea 0 : " << x << " " << y << std::endl ; break ; case type_normal_distribution: // 1 x = d1 (pseudorandom_generator) ; y = d1 (pseudorandom_generator) ; break ; case type_lognormal_distribution: // 2 x = d2 (pseudorandom_generator) ; y = d2 (pseudorandom_generator) ; break ; case type_chi_squared_distribution: // 3 x = d3 (pseudorandom_generator) ; y = d3 (pseudorandom_generator) ; break ; case type_cauchy_distribution: // 4 x = d4 (pseudorandom_generator) ; y = d4 (pseudorandom_generator) ; break ; case type_fisher_f_distribution: // 5 x = d5 (pseudorandom_generator) ; y = d5 (pseudorandom_generator) ; break ; case type_student_t_distribution: // 6 x = d6 (pseudorandom_generator) ; y = d6 (pseudorandom_generator) ; break ; case type_exponential_distribution: // 7 x = d7 (pseudorandom_generator) ; y = d7 (pseudorandom_generator) ; break ; case type_gamma_distribution: // 8 x = d8 (pseudorandom_generator) ; y = d8 (pseudorandom_generator) ; break ; case type_weibull_distribution: // 9 x = d9 (pseudorandom_generator) ; y = d9 (pseudorandom_generator) ; break ; default: break ; } if (pattern_settings. avoid_overlap) { for (long_unsigned_int j = 0 ; j < polylines. size () ; j++) { if ((polylines[j]. vertices[0] - Vertex(x, y)).norm2_square() < pattern_settings. diametre*pattern_settings. diametre) { overlap = true ; break ; } } } bool within_limits = (((fabs (x - pattern_settings. x0) < pattern_settings. lx / 2.0) || (pattern_settings. lx <= 0)) && ((fabs (y - pattern_settings. y0) < pattern_settings. ly / 2.0) || (pattern_settings. ly <= 0))) ; // Either we are inside lx, or user set it to negative to disable it. if (within_limits && !overlap) { p. push_back (Vertex (x, y)) ; p. dose = pattern_settings. diametre ; polylines. push_back (p) ; p. vertices. clear () ; // does not change that p. closed == true ; i++ ; } attempts++ ; } }
void analyze(Int_t step){ // TOF propagation factors (TOF efficiencies) fEfficiencyPiTOF = new TF1("fEfficiencyPiTOF","(x > 0.3)*0.7",0,10); fEfficiencyKaTOF = new TF1("fEfficiencyKaTOF","(x > 0.3)*(x-0.3)*(x<1) + (x>1)*0.7",0,10); fEfficiencyPrTOF = new TF1("fEfficiencyPrTOF","(x > 0.3)*(x-0.3)*(x<1) + (x>1)*0.7",0,10); // teoretical separation (perfect if equal to the one simualted in sim.C) fseparation = new TF1("f","[0]+[1]/x",0,100); fseparation->SetParameter(0,0.); fseparation->SetParameter(1,7.); fseparationPiKa = new TF1("fPiKa","[0]+[1]/TMath::Power(x,2.5)",0,100); fseparationPiKa->SetParameter(0,2.34); fseparationPiKa->SetParameter(1,10); fseparationKaPr = new TF1("fKaPr","[0]+[1]/TMath::Power(x,2.5)",0,100); fseparationKaPr->SetParameter(0,1); fseparationKaPr->SetParameter(1,56); // x=p, y=pt/p (normalized at the number of sigma assuming 80 ps resolution) fTOFpi = new TF2("fTOFpi","3.7/y*(sqrt(x*x+0.0193210)/x-1)*37.47405725",0.3,10,0.5,1); fTOFka = new TF2("fTOFka","3.7/y*(sqrt(x*x+0.243049)/x-1)*37.47405725",0.3,10,0.5,1); fTOFpr = new TF2("fTOFpr","3.7/y*(sqrt(x*x+0.879844)/x-1)*37.47405725",0.3,10,0.5,1); // x=p, already normalized in number of sigma (sigma assumed 3.5=7% of the MIP) fTPCpi = new TF1("fTPCpi",BetheBlochAleph,0,10,6); fTPCpi->SetParameter(0,fKp1); fTPCpi->SetParameter(1,fKp2); fTPCpi->SetParameter(2,fKp3); fTPCpi->SetParameter(3,fKp4); fTPCpi->SetParameter(4,fKp5); fTPCpi->SetParameter(5,0.139); fTPCka = new TF1("fTPCka",BetheBlochAleph,0,10,6); fTPCka->SetParameter(0,fKp1); fTPCka->SetParameter(1,fKp2); fTPCka->SetParameter(2,fKp3); fTPCka->SetParameter(3,fKp4); fTPCka->SetParameter(4,fKp5); fTPCka->SetParameter(5,0.493); fTPCpr = new TF1("fTPCpr",BetheBlochAleph,0,10,6); fTPCpr->SetParameter(0,fKp1); fTPCpr->SetParameter(1,fKp2); fTPCpr->SetParameter(2,fKp3); fTPCpr->SetParameter(3,fKp4); fTPCpr->SetParameter(4,fKp5); fTPCpr->SetParameter(5,0.938); Float_t width = 1.0; addshift =0; invwidth = 1./width; Float_t widthTOF = 1.0; addshiftTOF =0; invwidthTOF = 1./widthTOF; TH1D *priorsPt[6]; TH1D *newpriorsPt[6]; TH1D *truePt[6]; TH1D *allPtPos = new TH1D("allPtP","All positive;p_{T} (GeV/#it{c});N",100,0,10); TH1D *allPtNeg = new TH1D("allPtN","All negative;p_{T} (GeV/#it{c});N",100,0,10); TH3D *priorsKs[3][3]; TH3D *newpriorsKs[3][3]; TH3D *truePidKs[3][3]; TH3D *trueKs; TH2D *priorsPhi[3][3]; TH2D *newpriorsPhi[3][3]; TH2D *truePidPhi[3][3]; TH2D *truePhi; TH3D *priorsLc[3][3][3]; TH3D *newpriorsLc[3][3][3]; TH3D *truePidLc[3][3][3]; TH3D *trueLc,*mypidLc; TH3D *priorsLcbar[3][3][3]; TH3D *newpriorsLcbar[3][3][3]; TH3D *truePidLcbar[3][3][3]; TH3D *trueLcbar,*mypidLcbar; Int_t nbinPtFrKa = 8; Int_t nbinPtFrPi = 8; Int_t nbinY = 1; Int_t nbinpol=nbinPtFrKa*nbinPtFrPi*nbinY; Double_t normbin = 1./nbinpol; Int_t nbinmlc = 100; Int_t nbinptlc = 10; const char *spec[3] = {"Pi","Ka","Pr"}; if(step==0){ priorsPt[0] = new TH1D("oldpriorsPtPiP","Pion (+) priors;p_{T} (GeV/#it{c});N",100,0,10); for(Int_t i=1;i<=100;i++) priorsPt[0]->SetBinContent(i,1); priorsPt[1] = new TH1D("oldpriorsPtKaP","Kaon (+) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[2] = new TH1D("oldpriorsPtPrP","Proton (+) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[3] = new TH1D("oldpriorsPtPiM","Pion (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[4] = new TH1D("oldpriorsPtKaM","Kaon (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[5] = new TH1D("oldpriorsPtPrM","Proton (-) priors;p_{T} (GeV/#it{c});N",100,0,10); priorsPt[1]->Add(priorsPt[0]); priorsPt[2]->Add(priorsPt[0]); priorsPt[3]->Add(priorsPt[0]); priorsPt[4]->Add(priorsPt[0]); priorsPt[5]->Add(priorsPt[0]); // Ks and phi priors for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ priorsKs[i][j] = new TH3D(Form("oldpriorsKs%s%s",spec[i],spec[j]),Form("K^{0*} priors for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); priorsPhi[i][j] = new TH2D(Form("oldpriorsPhi%s%s",spec[i],spec[j]),Form("#phi priors for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); if(i==0 && j==0){ for(Int_t ibx=1;ibx<=200;ibx++) for(Int_t iby=1;iby<=40;iby++){ for(Int_t ibz=1;ibz <= nbinpol;ibz++) priorsKs[i][j]->SetBinContent(ibx,iby,ibz,1); priorsPhi[i][j]->SetBinContent(ibx,iby,1); } } else{ priorsKs[i][j]->Add(priorsKs[0][0]); priorsPhi[i][j]->Add(priorsPhi[0][0]); } for(Int_t k=0; k< 3;k++){ priorsLc[i][j][k] = new TH3D(Form("oldpriorsLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); priorsLcbar[i][j][k] = new TH3D(Form("oldpriorsLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); if(i==0 && j==0 && k==0){ for(Int_t ibx=1;ibx<=nbinmlc;ibx++) for(Int_t iby=1;iby<=nbinptlc;iby++){ for(Int_t ibz=1;ibz <= nbinpol;ibz++){ priorsLc[i][j][k]->SetBinContent(ibx,iby,ibz,1); priorsLcbar[i][j][k]->SetBinContent(ibx,iby,ibz,1); } } } else{ priorsLc[i][j][k]->Add(priorsLc[0][0][0]); priorsLcbar[i][j][k]->Add(priorsLc[0][0][0]); } } } } } else{ TFile *fin = new TFile(Form("step%i.root",step)); priorsPt[0] = (TH1D *) fin->Get("priorsPtPiP"); priorsPt[0]->SetName("oldpriorsPtPiP"); priorsPt[1] = (TH1D *) fin->Get("priorsPtKaP"); priorsPt[1]->SetName("oldpriorsPtPiP"); priorsPt[2] = (TH1D *) fin->Get("priorsPtPrP"); priorsPt[2]->SetName("oldpriorsPtPiP"); priorsPt[3] = (TH1D *) fin->Get("priorsPtPiM"); priorsPt[3]->SetName("oldpriorsPtPiM"); priorsPt[4] = (TH1D *) fin->Get("priorsPtKaM"); priorsPt[4]->SetName("oldpriorsPtKaM"); priorsPt[5] = (TH1D *) fin->Get("priorsPtPrM"); priorsPt[5]->SetName("oldpriorsPtPrM"); // Ks and phi priors for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ priorsKs[i][j] = (TH3D *) fin->Get(Form("priorsKs%s%s",spec[i],spec[j])); priorsKs[i][j]->SetName(Form("oldpriorsKs%s%s",spec[i],spec[j])); priorsPhi[i][j] = (TH2D *) fin->Get(Form("priorsPhi%s%s",spec[i],spec[j])); priorsPhi[i][j]->SetName(Form("oldpriorsPhi%s%s",spec[i],spec[j])); for(Int_t k=0; k< 3;k++){ priorsLc[i][j][k] = (TH3D *) fin->Get(Form("priorsLc%s%s%s",spec[i],spec[j],spec[k])); priorsLc[i][j][k]->SetName(Form("oldpriorsLc%s%s%s",spec[i],spec[j],spec[k])); priorsLcbar[i][j][k] = (TH3D *) fin->Get(Form("priorsLcbar%s%s%s",spec[i],spec[j],spec[k])); priorsLcbar[i][j][k]->SetName(Form("oldpriorsLcbar%s%s%s",spec[i],spec[j],spec[k])); } } } } newpriorsPt[0] = new TH1D("priorsPtPiP","Pion (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[1] = new TH1D("priorsPtKaP","Kaon (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[2] = new TH1D("priorsPtPrP","Proton (+) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[3] = new TH1D("priorsPtPiM","Pion (-) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[4] = new TH1D("priorsPtKaM","Kaon (-) priors;p_{T} (GeV/#it{c});N",100,0,10); newpriorsPt[5] = new TH1D("priorsPtPrM","Proton (-) priors;p_{T} (GeV/#it{c});N",100,0,10); // Ks and phi priors distributions for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ newpriorsKs[i][j] = new TH3D(Form("priorsKs%s%s",spec[i],spec[j]),Form("K^{0*} priors for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); newpriorsPhi[i][j] = new TH2D(Form("priorsPhi%s%s",spec[i],spec[j]),Form("#phi priors for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); for(Int_t k=0; k< 3;k++){ newpriorsLc[i][j][k] = new TH3D(Form("priorsLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); newpriorsLcbar[i][j][k] = new TH3D(Form("priorsLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} priors for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); } } } truePt[0] = new TH1D("truePtPiP","Pion (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[1] = new TH1D("truePtKaP","Kaon (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[2] = new TH1D("truePtPrP","Proton (+) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[3] = new TH1D("truePtPiM","Pion (-) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[4] = new TH1D("truePtKaM","Kaon (-) truth;p_{T} (GeV/#it{c});N",100,0,10); truePt[5] = new TH1D("truePtPrM","Proton (-) truth;p_{T} (GeV/#it{c});N",100,0,10); // Ks and phi truePid distributions for(Int_t i=0; i< 3;i++){ for(Int_t j=0; j< 3;j++){ truePidKs[i][j] = new TH3D(Form("truePidKs%s%s",spec[i],spec[j]),Form("K^{0*} truePid for %s-%s;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); truePidPhi[i][j] = new TH2D(Form("truePidPhi%s%s",spec[i],spec[j]),Form("#phi truePid for %s-%s;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j]),100,0.98,1.05,40,0,10); for(Int_t k=0; k< 3;k++){ truePidLc[i][j][k] = new TH3D(Form("truePidLc%s%s%s",spec[i],spec[j],spec[k]),Form("#Lambda_{c}^{+} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); truePidLcbar[i][j][k] = new TH3D(Form("truePidLcbar%s%s%s",spec[i],spec[j],spec[k]),Form("#overline{#Lambda}_{c}^{-} truePid for %s-%s-%s;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N",spec[i],spec[j],spec[k]),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); } } } trueKs = new TH3D(Form("trueKs"),Form("K^{0*} true;m_{#piK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),200,0.4,1.4,40,0,10,nbinpol,-1.001,1.001); truePhi = new TH2D(Form("truePhi"),Form("#phi true;m_{KK} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),100,0.98,1.05,40,0,10); trueLc = new TH3D(Form("trueLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); trueLcbar = new TH3D(Form("trueLcbar"),Form("#overline{#Lambda}_{c}^{-} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1); mypidLc = new TH3D(Form("mypidLc"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); mypidLcbar = new TH3D(Form("mypidLcbar"),Form("#Lambda_{c}^{+} true;m_{#piKp} (GeV/#it{c}^2);p_{T} (GeV/#it{c});N"),nbinmlc,2.1,2.5,nbinptlc,7,27,nbinpol,0,1.); // define particle types (particle type array) particle::AddParticleType("pi+",0.139,1); // 0 particle::AddParticleType("pi-",0.139,-1); // 1 particle::AddParticleType("K+",0.493,1); // 2 particle::AddParticleType("K-",0.493,-1); // 3 particle::AddParticleType("p+",0.938,1); // 4 particle::AddParticleType("p-",0.938,-1); // 5 particle::AddParticleType("K0*",0.896,0,5.05e-02); // 6 particle::AddParticleType("K0bar*",0.896,0,5.05e-02); // 7 particle::AddParticleType("Phi",1.02,0,0.00426); // 8 particle::AddParticleType("Delta++",1.232,2,0.118); // 9 particle::AddParticleType("Delta--",1.232,-2,0.118); // 10 particle::AddParticleType("Lambdac+",2.28646,1,0.008); // 11 particle::AddParticleType("Lambdacbar-",2.28646,-1,0.008); // 12 particle::AddParticleType("Lambda1520",1.5195,-1,0.0000156); // 12 particle d1("pi+"); particle d2("K+"); particle d3("p+"); particle d4("pi-"); particle d5("K-"); particle d6("p-"); particle prong1; particle prong2; particle prong3; particle polarKs("K0*"); particle polarLc("Lambdac+"); Int_t charge[] = {1,-1,1,-1,1,-1,0,0,0,2,-2,1,-1}; particle ppos[20000]; particle pneg[20000]; Float_t weightsPos[20000][3]; Float_t weightsNeg[20000][3]; Int_t passMyPIDPos[20000][3]; Int_t passMyPIDNeg[20000][3]; Int_t npos=0; Int_t nneg=0; Float_t signal,signalTOF,signalTPC,pt,pz,phi,ptComb,ptComb3prong,invmass; Float_t ptd,pzd,phid; Float_t priors[3],prob[3]; Float_t priors2[3][3],prob2[3][3]; Float_t priors3[3][3][3],prob3[3][3][3]; Int_t iev=-1,id,mother; Int_t cev; TFile *fout = new TFile(Form("step%i.root",step+1),"RECREATE"); // TTree *treeKs = new TTree("treeKs","treeKs"); // Float_t ptPair,massPair,ptD1,ptD2,weightD1[3],weightD2[3],weightFill; // Int_t isTrue,isTruePid; // treeKs->Branch("ptPair",&ptPair,"ptPair/F"); // treeKs->Branch("massPair",&massPair,"massPair/F"); // treeKs->Branch("ptPi",&ptD1,"ptPi/F"); // treeKs->Branch("ptKa",&ptD2,"ptKa/F"); // treeKs->Branch("weightPi",weightD1,"wightPi[3]/F"); // treeKs->Branch("weightKa",weightD2,"wightKa[3]/F"); // treeKs->Branch("weightFill",&weightFill,"wightFill/F"); // treeKs->Branch("isTruePid",&isTruePid,"isTruePid/I"); // treeKs->Branch("isTrue",&isTrue,"isTrue/I"); TH1F *hcentr = new TH1F("hcentr","",100,0,100); FILE *flist = fopen("lista","r"); char namefile[100]; Float_t weight1[3],weight2[3],weight3[3]; Float_t ptPi,ptKa,ptPr; TH1F *htemp; while(fscanf(flist,"%s",namefile)==1){ TFile *fin = new TFile(namefile); printf("file = %s\n",namefile); TList *l = (TList *) fin->Get("TOFpid"); htemp = (TH1F *) l->At(0); if(!hcentr) hcentr = new TH1F(*htemp); else hcentr->Add(htemp); TTree *t = (TTree *) l->At(1); Int_t n = t->GetEntries(); for(Int_t i=0;i < n;i++){ t->GetEvent(i); ptPi = t->GetLeaf("ptPi")->GetValue(); ptKa = t->GetLeaf("ptPi")->GetValue(); ptPr = t->GetLeaf("ptPi")->GetValue(); pt = t->GetLeaf("pt")->GetValue(); invmass = t->GetLeaf("mass")->GetValue(); weight1[0] = t->GetLeaf("weightPi")->GetValue(0); weight1[1] = t->GetLeaf("weightPi")->GetValue(1); weight1[2] = t->GetLeaf("weightPi")->GetValue(2); weight2[0] = t->GetLeaf("weightKa")->GetValue(0); weight2[1] = t->GetLeaf("weightKa")->GetValue(1); weight2[2] = t->GetLeaf("weightKa")->GetValue(2); weight3[0] = t->GetLeaf("weightPr")->GetValue(0); weight3[1] = t->GetLeaf("weightPr")->GetValue(1); weight3[2] = t->GetLeaf("weightPr")->GetValue(2); Float_t pt1 = Int_t(ptPi/(ptPi+ptKa+ptPr)*nbinPtFrPi); Float_t pt2 = Int_t(ptKa/(ptPi+ptKa+ptPr)*nbinPtFrKa); Float_t polar = 0;//TMath::Abs(polarLc.GetY());//ptComb3prong/ptot;//(pt2*nbinpol + pt1)*invpollc; polar = ((pt1*nbinPtFrKa + pt2 + polar)*nbinY)*normbin; Int_t ibinx = priorsLc[0][0][0]->GetXaxis()->FindBin(invmass); Int_t ibiny = priorsLc[0][0][0]->GetYaxis()->FindBin(pt); Int_t ibinz = priorsLc[0][0][0]->GetZaxis()->FindBin(polar); for(Int_t ipr=0;ipr<3;ipr++) for(Int_t jpr=0;jpr<3;jpr++) for(Int_t kpr=0;kpr<3;kpr++) priors3[ipr][jpr][kpr] = priorsLc[ipr][jpr][kpr]->GetBinContent(ibinx,ibiny,ibinz); GetProb3(weight1,weight2,weight3,priors3,prob3); for(Int_t ipr=0;ipr<3;ipr++) for(Int_t jpr=0;jpr<3;jpr++) for(Int_t kpr=0;kpr<3;kpr++){ newpriorsLc[ipr][jpr][kpr]->Fill(invmass,pt,polar,prob3[ipr][jpr][kpr]); } } t->Delete(); fin->Close(); } printf("Write output\n"); fout->cd(); hcentr->Write(); //if(step==0) treeKs->Write(); for(Int_t i=0;i<6;i++){ newpriorsPt[i]->Write(); truePt[i]->Write(); } for(Int_t i=0;i<3;i++){ for(Int_t j=0;j<3;j++){ priorsPhi[i][j]->Write(); newpriorsKs[i][j]->Write(); newpriorsPhi[i][j]->Write(); truePidKs[i][j]->Write(); truePidPhi[i][j]->Write(); for(Int_t k=0;k<3;k++){ newpriorsLc[i][j][k]->Write(); truePidLc[i][j][k]->Write(); newpriorsLcbar[i][j][k]->Write(); truePidLcbar[i][j][k]->Write(); } } } trueKs->Write(); truePhi->Write(); trueLc->Write(); trueLcbar->Write(); mypidLc->Write(); mypidLcbar->Write(); fout->Close(); }
int main() { // E X T E N D I D O . . . assert ( mtk::fnExt(mtk::fnDec(5), mtk::fnInc(5) ) != mtk::fnExt(mtk::fnDec(2), mtk::fnInc(5) ) ); assert ( mtk::fnExt(mtk::fnDec(2), mtk::fnInc(10) ) != mtk::fnExt(mtk::fnDec(1), mtk::fnInc(1) ) ); //--------------------------------------------------------------------------- // f n D o u b l e //--------------------------------------------------------------------------- // the same.. mtk::fnDouble d1 (3.4); mtk::fnDouble d2 (3.4, mtk::fnRoundArithmetic ); mtk::fnDouble d3 (3.4, mtk::fnRoundFloor ); mtk::fnDouble d4 (3.4, mtk::fnRoundCeil ); mtk::fnDouble d5 (3.4, mtk::fnRoundNotAllowed ); //--------------------------------------------------------------------------- // F i x e d N u m b e r //--------------------------------------------------------------------------- // CONSTRUCTORES ____________________________________________________ // double assert ( mtk::FixedNumber( mtk::fnDouble (3.1415926535 ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) == mtk::FixedNumber( mtk::fnDouble (3.1415926535 , mtk::fnRoundArithmetic ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) ); assert ( mtk::FixedNumber( mtk::fnDouble (3.1415926535 , mtk::fnRoundCeil ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) == mtk::FixedNumber( mtk::fnDouble (3.1415926535 , mtk::fnRoundCeil ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) ); // integer assert ( mtk::FixedNumber( mtk::fnIntCode (31416 ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) == mtk::FixedNumber( mtk::fnDouble (3.1415926535 , mtk::fnRoundArithmetic ), mtk::fnDec (4 ), mtk::fnInc (1 ) ) ); // error en tiempo de ejecución // redondeo por defecto para enteros... notallowed /* mtk::FixedNumber( mtk::fnIntCode (31416 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ); */ assert ( mtk::FixedNumber( mtk::fnIntCode (31415 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ) == mtk::FixedNumber( mtk::fnIntCode (31416 , mtk::fnRoundArithmetic ), mtk::fnDec (4 ), mtk::fnInc (5 ) ) ); // fnExt assert ( mtk::FixedNumber( mtk::fnIntCode (31416 ), mtk::fnExt ( mtk::fnDec (4 ), mtk::fnInc (1 ) ) ) == mtk::FixedNumber( mtk::fnDouble (3.1415926535 , mtk::fnRoundArithmetic ), mtk::fnExt ( mtk::fnDec (4 ), mtk::fnInc (1 ) ) ) ); // Métodos de acceso ________________________________________________ // lectura assert ( mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) .GetDouble() > 3.14 // == 3.15 ); { mtk::FixedNumber fn1 (mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)); assert ( fn1.GetExt().GetDec() == 2 ); assert ( fn1.GetDouble() > 3.14 ); assert ( fn1.d() > 3.14 ); assert ( fn1.GetExt().GetFormat() == mtk::fnFNormal ); // escritura fn1.SetDouble(3.11); assert ( fn1.GetIntCode() == 310 ); assert ( fn1.GetDouble () < 3.11); fn1.SetIntCode(39); assert ( fn1.GetIntCode() == 40 ); assert ( fn1.GetDouble () > 0.39); mtk::FixedNumber fn2 = fn1; assert ( fn1.SetDouble(3.10) == fn2.SetIntCode(310) ); assert ( mtk::FixedNumber( mtk::fnIntCode (0 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ).SetIntCode (31415) == mtk::FixedNumber( mtk::fnIntCode (0 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ).SetIntCode (31416, mtk::fnRoundArithmetic ) ); // error en tiempo de ejecución, // default round for integers, not allowed /* mtk::FixedNumber fnp = mtk::FixedNumber( mtk::fnIntCode (0 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ).SetIntCode (31416); mtk::FixedNumber fnp2( mtk::fnIntCode (0 ), mtk::fnDec (4 ), mtk::fnInc (5 ) ); fnp2.SetIntCode (31416); */ } // OPERADORES ____________________________________________________ // relacionales assert ( mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) >= mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) && mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) > mtk::FixedNumber(mtk::fnDouble(3.0) , mtk::fnDec(2), mtk::fnInc(5)) && mtk::FixedNumber(mtk::fnDouble(3.0) , mtk::fnDec(2), mtk::fnInc(5)) != mtk::FixedNumber(mtk::fnDouble(3.14) , mtk::fnDec(2), mtk::fnInc(5)) && mtk::FixedNumber(mtk::fnDouble(3.14) , mtk::fnDec(2), mtk::fnInc(5)) < mtk::FixedNumber(mtk::fnDouble(20.0) , mtk::fnDec(2), mtk::fnInc(5)) ); // error en tiempo de ejecución, no son comparables /* assert ( mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(1)) >= mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) ); assert ( mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(1), mtk::fnInc(5)) >= mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(5)) ); */ // aritméticos mtk::FixedNumber fna (mtk::fnDouble(3.20), mtk::fnDec(2), mtk::fnInc(1)); assert ( ++mtk::FixedNumber(mtk::fnDouble(3.14), mtk::fnDec(2), mtk::fnInc(1)) == mtk::FixedNumber (mtk::fnDouble(3.15), mtk::fnDec(2), mtk::fnInc(1)) && mtk::FixedNumber (mtk::fnDouble(3.15), mtk::fnDec(2), mtk::fnInc(1)) == --mtk::FixedNumber(mtk::fnDouble(3.16), mtk::fnDec(2), mtk::fnInc(1)) && --mtk::FixedNumber(mtk::fnDouble(3.16), mtk::fnDec(2), mtk::fnInc(1)) == mtk::FixedNumber (mtk::fnDouble(3.10), mtk::fnDec(2), mtk::fnInc(1)) +mtk::fnTicks(5) && mtk::FixedNumber (mtk::fnDouble(3.10), mtk::fnDec(2), mtk::fnInc(1)) +mtk::fnTicks(5) == (fna-=mtk::fnTicks(5)) ); { mtk::FixedNumber fn1(mtk::fnIntCode(0), mtk::fnDec(3), mtk::fnInc(5) ); fn1.SetDouble(3.14); mtk::FixedNumber fn2(mtk::fnDouble(3.14), mtk::fnDec(3), mtk::fnInc(5) ); mtk::FixedNumber fn3(mtk::fnIntCode(0), mtk::fnDec(3), mtk::fnInc(5) ); fn3.SetIntCode(3140); assert (fn1 == fn2 && fn2 == fn3); assert ( fn3 == mtk::FixedNumber( mtk::fnIntCode(0), mtk::fnDec(3), mtk::fnInc(5) ).SetIntCode(3140) ); } #include "support/release_on_exit.hpp" return 0; }
int ZmumuAnalysis(HEPParticle *mother,HEPParticleList *stableDaughters, int nparams, double *params) { // THIS IS EXAMPLE of userTreeAnalysis. It acts on list of particle X (under our MC-test) final // daughters. Of course in real life many options may need to be introduced by the user. // PARAMETERS: // params[0] threshold on Energy (or p_T) of particle expressed as a fraction of mother's // Energy (or p_T) in mother's frame. If not specified - default is 0.05 // Note that setting it to zero is possible. // params[1] maximum number of left soft-suspected particles. // 0: (default) all listed particles are removed, even if hard // 1: 2: one two etc removable particles are kept (at most) // -1: this option is off, all hard particles stay. // params[2] control tag on discriminating particles, // 0: (default) Energy in decaying particle rest frame // 1: Energy in lab frame // 2: p_T with respect to beam direction in lab frame. // params[3] type of action to be applied on removed daughters // 0: (default) nothing is done, they are lost // 1: algorithm as in studies on PHOTOS is used, see papers P. Golonka and Z. Was. // params[4] from this paramter on PDG id-s of particles to be removed can be added. // Default is that only photons are removed. // To get to origin of our particle (mother) one need to go after UserEventAnalysis, // instructive example will be given later. assert(mother!=0); assert(stableDaughters!=0); double threshold=0.05, leftmax=0.0, selector=0.0, actLost=0.0; if (nparams>0 && params==0) return -1; if (nparams>0) threshold=params[0]; if (nparams>1) leftmax =params[1]; if (nparams>2) selector =params[2]; if (nparams>3) actLost =params[3]; HEPParticleList *lostDaughters=new HEPParticleList; double pt_limit=threshold*mother->GetM(); HEPParticleListIterator daughters (*stableDaughters); int nphot=0; double ephot=pow(10,22); bool redo=false; for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) { if(redo) redo=false; MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM()); // boost to mother's frame: d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM()); double p_t=d4.GetX0(); // default switch ((int) selector) { case 1: p_t=part->GetE(); break; case 2: p_t=d4.Xt(); break; } if(ifSofty(part->GetPDGId(),nparams,params)) nphot++; if ( ifSofty(part->GetPDGId(),nparams,params) && p_t < pt_limit) { // printf("Odrzucamy! %i\n",count++); nphot=0; lostDaughters->push_back(part); stableDaughters->remove(part); part=daughters.first(); redo=true; continue; } if( ifSofty(part->GetPDGId(),nparams,params) && ephot>p_t) ephot=p_t; } while(nphot>(int) leftmax) { double ephot1=pow(10,22); redo=false; for (HEPParticle *part=daughters.first(); part!=0; (redo)? part=part:part=daughters.next() ) { if(redo) redo=false; MC4Vector d4(part->GetE(),part->GetPx(),part->GetPy(),part->GetPz(),part->GetM()); // boost to mother's frame: d4.Boost(mother->GetPx(),mother->GetPy(),mother->GetPz(),mother->GetE(),mother->GetM()); double p_t=d4.GetX0(); // default switch ((int) selector) { case 1: p_t=part->GetE(); break; case 2: p_t=d4.Xt(); break; } if ( ifSofty(part->GetPDGId(),nparams,params) && p_t == ephot) { nphot--; lostDaughters->push_back(part); stableDaughters->remove(part); ephot1=pow(10,22); part=daughters.first(); redo=true; continue; } if( ifSofty(part->GetPDGId(),nparams,params) && ephot1>p_t) ephot1=p_t; } ephot=ephot1; } // ############################################################## // SPECIAL CASE - ordered or symmetrical photons // This code changes order of photons // ############################################################## HEPParticleListIterator symmetry (*stableDaughters); HEPParticle *phot1 = NULL; HEPParticle *phot2 = NULL; for (HEPParticle *part=symmetry.first(); part!=0; part=symmetry.next() ) { if(part->GetPDGId()==22) { if(!phot1) phot1=part; else { phot2=part; break; } } } if(phot1 && phot2) { if(phot1->GetE()<phot2->GetE()) // for ordered photons //if( rand()*1.0/RAND_MAX > 0.5) // for photon symmetrization { double buf_x = phot1->GetPx(); double buf_y = phot1->GetPy(); double buf_z = phot1->GetPz(); double buf_e = phot1->GetE(); phot1->SetPx(phot2->GetPx()); phot1->SetPy(phot2->GetPy()); phot1->SetPz(phot2->GetPz()); phot1->SetE (phot2->GetE() ); phot2->SetPx(buf_x); phot2->SetPy(buf_y); phot2->SetPz(buf_z); phot2->SetE (buf_e); } } // ############################################################## // here functionality of removig some daughters is finished // now we reconsider what to do with them // ############################################################## // delete lostDaughters; // return 1; // ############################################################## // Now: What to do with lost daughters? // ############################################################## // lostDaughters->ls(); int version=(int) actLost; switch(version) { case 1: // add lost to charged { HEPParticleListIterator lost (*lostDaughters); for (HEPParticle *lostpart=lost.first(); lostpart!=0; lostpart=lost.next() ) { HEPParticle* Best=0; double searchvirt=pow(10.0,22); MC4Vector VV; for( HEPParticle *part=daughters.first(); part!=0; part=daughters.next() ){ if(part->GetCharge()==0) continue; VV=lostpart->GetP4()+part->GetP4(); VV.AdjustM(); if (VV.GetM()<searchvirt) {searchvirt=VV.GetM(); Best=part;} } if(Best) { Best->SetPx(Best->GetPx()+lostpart->GetPx()); Best->SetPy(Best->GetPy()+lostpart->GetPy()); Best->SetPz(Best->GetPz()+lostpart->GetPz()); Best->SetE (Best->GetE ()+lostpart->GetE ()); } } break; } default: break; // do nothing } delete lostDaughters; bool activateUserHist=true; if(!activateUserHist) return 1; // segmet of user defined histograms double X=mother->GetPx(), Y=mother->GetPy(), Z=mother->GetPz(); // double E=mother->GetE(), MM=mother->GetM(); double pt=sqrt(X*X+Y*Y); double eta=log((sqrt(pt*pt+Z*Z)+TMath::Abs(Z))/pt); if(Z<0 && eta>0) eta=-eta; if(Z>0 && eta<0) eta=-eta; double phi=angle(X,Y); char hist1[] = "mother-PT"; char hist2[] = "mother-eta"; char hist3[] = "mother-phi"; fillUserHisto(hist1,pt,1.0,0.0,100.0); fillUserHisto(hist2,eta,1.0,-8.0,8.0); fillUserHisto(hist3,phi,1.0,-PI,PI); return 1; }