pyPolynomialLoads(int nodes, const Vector &nP_np, const Matrix &Px_np, const Matrix &Py_np, const Matrix &Pz_np, const Vector &Fx_np, const Vector &Fy_np, const Vector &Fz_np, const Vector &Mx_np, const Vector &My_np, const Vector &Mz_np){ loads.nodes = nodes; loads.Px.resize(loads.nodes-1); loads.Py.resize(loads.nodes-1); loads.Pz.resize(loads.nodes-1); loads.Fx = Fx_np; loads.Fy = Fy_np; loads.Fz = Fz_np; loads.Mx = Mx_np; loads.My = My_np; loads.Mz = Mz_np; for (int i = 0; i < loads.nodes-1; i++){ int nP = nP_np[i]; loads.Px[i] = Poly(nP, Px_np.row(i)); loads.Py[i] = Poly(nP, Py_np.row(i)); loads.Pz[i] = Poly(nP, Pz_np.row(i)); } }
/* operator- Subtracts the right poly object from the left poly object Math rule a-b != b-a Right poly object must always be subtracted from the left poly object */ Poly Poly::operator-(const Poly& param) const { //Is exponents are equal or param is lower //Copy current object and subtract same indexes if(largestExpo >= param.largestExpo) { Poly temp = Poly(*this); for(int i = 0; i <= param.largestExpo; i++) { temp.polynomial[i] -= param.polynomial[i]; } //In event subtraction causes largest index to become zero //get new largest exponent temp.getLargestExpo(); return temp; } else { //Copy parameter object since it has a larger exponent Poly temp = Poly(param); //Multiply each index to -1 and then add the current object //Math proof a-b is equal to -b+a for(int i = 0; i <= temp.largestExpo; i++) { temp.polynomial[i] *= -1; } for(int i = 0; i <= largestExpo; i++) { temp.polynomial[i] += polynomial[i]; } //in event that largest exponent becomes zero temp.getLargestExpo(); return temp; } }
TEST(LazardEvaluation, Test) { using Poly = carl::MultivariatePolynomial<Rational>; carl::Variable x = carl::freshRealVariable("x"); carl::Variable y = carl::freshRealVariable("y"); carl::Variable z = carl::freshRealVariable("z"); Poly p = (Poly(x)-Poly(y))*z; carl::LazardEvaluation<Rational,Poly> le(p); { carl::UnivariatePolynomial<Rational> p(x, std::initializer_list<Rational>{-2, 0, 1}); carl::Interval<Rational> i(Rational(1), carl::BoundType::STRICT, Rational(2), carl::BoundType::STRICT); carl::RealAlgebraicNumber<Rational> ran(p, i); le.substitute(x, ran); } { carl::UnivariatePolynomial<Rational> p(y, std::initializer_list<Rational>{-2, 0, 1}); carl::Interval<Rational> i(Rational(1), carl::BoundType::STRICT, Rational(2), carl::BoundType::STRICT); carl::RealAlgebraicNumber<Rational> ran(p, i); le.substitute(y, ran); } EXPECT_EQ(-Poly(z), le.getLiftingPoly()); }
TEST_F(LazardTest, Proper1) { auto ax = getRAN({-2, 0, 1}, 1, 2); auto ay = getRAN({-2, 0, 1}, 1, 2); auto q = (Poly(x)-y)*z; carl::LazardEvaluation<Rational,Poly> le(q); le.substitute(x, ax); le.substitute(y, ay); EXPECT_EQ(-Poly(z), le.getLiftingPoly()); }
/* operator+ Add two Poly objects together Math rule a+b = b+a, we can take the largest poly object and add the other poly object to it and return */ Poly Poly::operator+(const Poly& param) const { Poly temp; if(largestExpo >= param.largestExpo) { temp = Poly(*this); for(int i = 0; i <= param.largestExpo; i++) { temp.polynomial[i] += param.polynomial[i]; } } else { temp = Poly(param); for(int i = 0; i <= largestExpo; i++) { temp.polynomial[i] += polynomial[i]; } } return temp; }
Poly Poly::operator*(const Poly& p) { int newTerms = this->terms + p.terms - 1; Poly output = Poly(0, newTerms - 1); int c, t; //iterate over the outside array for (int i = 0; i < this->terms; i++) { if (this->coeffs[i] == 0) { continue; } //iterate over the inside array for (int j = 0; j < p.terms; j++) { if (p.coeffs[j] == 0) { continue; } //get values c = this->coeffs[i] * p.coeffs[j]; t = i + j; //assign values for new poly output.setCoeff(c, t); } } return output; }
void startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { start.x = x; start.y = y; last.x = x; last.y = y; switch (activeTool) { case TOOL_FREESEL: case TOOL_TEXT: case TOOL_LINE: case TOOL_RECT: case TOOL_ELLIPSE: case TOOL_RRECT: newReversible(); break; case TOOL_RUBBER: newReversible(); Replace(hdc, x, y, x, y, fg, bg, rubberRadius); break; case TOOL_FILL: newReversible(); Fill(hdc, x, y, bg); break; case TOOL_PEN: newReversible(); SetPixel(hdc, x, y, bg); break; case TOOL_BRUSH: newReversible(); Brush(hdc, x, y, x, y, bg, brushStyle); break; case TOOL_AIRBRUSH: newReversible(); Airbrush(hdc, x, y, bg, airBrushWidth); break; case TOOL_BEZIER: pointStack[pointSP].x = x; pointStack[pointSP].y = y; if (pointSP == 0) { newReversible(); pointSP++; } break; case TOOL_SHAPE: pointStack[pointSP].x = x; pointStack[pointSP].y = y; if (pointSP + 1 >= 2) Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE); if (pointSP == 0) { newReversible(); pointSP++; } break; } }
void createIrredPolys (Poly* irredPolys) { // Use the following map for Eratosthenes' sieve int mapSize = 100; bool* map = 0; int count; do { mapSize *= 2; // dump old table and create a new one delete[] map; map = new bool [mapSize]; // find irreducible polynomials eratosthenes (map, mapSize, Poly (0)); // Count irreducible polynomials in this map count = 0; for (int i = 0; i < mapSize; i++) if (map [i]) count++; } while (count < NiederreiterMatrix::MAX_DIM); // do we have enough? // Copy the first MAX_DIM irreducible polynomials to irredPolys bool* p = map; for (int i = 0; i < NiederreiterMatrix::MAX_DIM; i++) { while (! *p) p++; irredPolys [i] = Poly (p++ - map); } // Free the memory used for the map delete[] map; }
Poly compose(Poly const & a, Poly const & b) { Poly result; for(unsigned i = a.size(); i > 0; i--) { result = Poly(a[i-1]) + result * b; } return result; }
pyPolynomialLoads(int nodes, const bpn::array &nP_np, const bp::list &Px_list, const bp::list &Py_list, const bp::list &Pz_list, const bpn::array &Fx_np, const bpn::array &Fy_np, const bpn::array &Fz_np, const bpn::array &Mx_np, const bpn::array &My_np, const bpn::array &Mz_np) { loads.nodes = nodes; loads.Px.resize(loads.nodes-1); loads.Py.resize(loads.nodes-1); loads.Pz.resize(loads.nodes-1); loads.Fx.resize(loads.nodes); loads.Fy.resize(loads.nodes); loads.Fz.resize(loads.nodes); loads.Mx.resize(loads.nodes); loads.My.resize(loads.nodes); loads.Mz.resize(loads.nodes); for (int i = 0; i < loads.nodes; i++) { loads.Fx(i) = bp::extract<double>(Fx_np[i]); loads.Fy(i) = bp::extract<double>(Fy_np[i]); loads.Fz(i) = bp::extract<double>(Fz_np[i]); loads.Mx(i) = bp::extract<double>(Mx_np[i]); loads.My(i) = bp::extract<double>(My_np[i]); loads.Mz(i) = bp::extract<double>(Mz_np[i]); } for (int i = 0; i < loads.nodes-1; i++) { int nP = bp::extract<double>(nP_np[i]); double Px_poly[nP]; double Py_poly[nP]; double Pz_poly[nP]; for (int j = 0; j < nP; j++) { Px_poly[j] = bp::extract<double>(Px_list[i][j]); Py_poly[j] = bp::extract<double>(Py_list[i][j]); Pz_poly[j] = bp::extract<double>(Pz_list[i][j]); } loads.Px(i) = Poly(nP, Px_poly); loads.Py(i) = Poly(nP, Py_poly); loads.Pz(i) = Poly(nP, Pz_poly); } }
vector<ExPoly> Clipping::getExPolys(const vector<Poly> &polys, double z, double extrusionfactor) { vector<Poly> ppolys(polys.size()); for (uint i = 0; i<polys.size(); i++) { ppolys[i]= Poly(polys[i],z); ppolys[i].setExtrusionFactor(extrusionfactor); } return getExPolys(ppolys); }
Poly derivative(Poly const & p) { Poly result; if(p.size() <= 1) return Poly(0); result.reserve(p.size()-1); for(unsigned i = 1; i < p.size(); i++) { result.push_back(i*p[i]); } return result; }
pyPolynomialSectionData(int nodes, const Vector &z_np, const Vector &nA_np, const Vector &nI_np, const Matrix &EA_np, const Matrix &EIxx_np, const Matrix &EIyy_np, const Matrix &GJ_np, const Matrix &rhoA_np, const Matrix &rhoJ_np){ sec.nodes = nodes; sec.z = z_np; sec.EA.resize(sec.nodes-1); sec.EIxx.resize(sec.nodes-1); sec.EIyy.resize(sec.nodes-1); sec.GJ.resize(sec.nodes-1); sec.rhoA.resize(sec.nodes-1); sec.rhoJ.resize(sec.nodes-1); for (int i = 0; i < sec.nodes-1; i++){ int nA = nA_np[i]; int nI = nI_np[i]; sec.EA[i] = Poly(nA, EA_np.row(i)); sec.rhoA[i] = Poly(nA, rhoA_np.row(i)); sec.EIxx[i] = Poly(nI, EIxx_np.row(i)); sec.EIyy[i] = Poly(nI, EIyy_np.row(i)); sec.GJ[i] = Poly(nI, GJ_np.row(i)); sec.rhoJ[i] = Poly(nI, rhoJ_np.row(i)); } }
int main (void) { int a[11]; //maximum coeficient// int i, N; do { //A do-while loop for the programme to repeat itself if it isnt self-reciprocal// printf("\nPlease enter the maximum degree of the polynomial\n"); //Asks user for input// scanf("%d", &N); printf("Please enter the coefficients\n"); //Read the coefficients into an array// for (i=0;i <= N;i++) //A For loop to that will ask the user for 1 more number than the maximum degree // { scanf("%d",&a[i]); } //this terminates the programme when the user enters a order of less than 0// if(N<0) { return 0; } Poly(a,N); //prints out the polynomial function// printf("\n"); Reciprocal(a,N); //prints out the recirocal polynomial function// printf("\n"); Testself(a,N); //determines and prints wether the polynomial is self or none self-reciprocal function// if(Testself(a,N)==1) printf("\nThe polynomial is self-reciprocal\n"); //this is the if statement to test wether the polynomial is self or non self-reciprocal// else printf("\nThe polynomial is not self-reciprocal\n"); } while(Testself(a,N)!=1); //part of the do-while loop to repeat programme when it itsnt self-reciprocal, and terminates the programme when it is sel-reciprocal// getch(); }
pyPolynomialSectionData(int nodes, const bpn::array &z_np, const bpn::array &nA_np, const bpn::array &nI_np, const bp::list &EA_list, const bp::list &EIxx_list, const bp::list &EIyy_list, const bp::list &GJ_list, const bp::list &rhoA_list, const bp::list &rhoJ_list) { sec.nodes = nodes; sec.z.resize(sec.nodes); sec.EA.resize(sec.nodes-1); sec.EIxx.resize(sec.nodes-1); sec.EIyy.resize(sec.nodes-1); sec.GJ.resize(sec.nodes-1); sec.rhoA.resize(sec.nodes-1); sec.rhoJ.resize(sec.nodes-1); for (int i = 0; i < sec.nodes; i++) { sec.z(i) = bp::extract<double>(z_np[i]); } for (int i = 0; i < sec.nodes-1; i++) { int nA = bp::extract<double>(nA_np[i]); int nI = bp::extract<double>(nI_np[i]); double EA_poly[nA]; double rhoA_poly[nA]; for (int j = 0; j < nA; j++) { EA_poly[j] = bp::extract<double>(EA_list[i][j]); rhoA_poly[j] = bp::extract<double>(rhoA_list[i][j]); } sec.EA(i) = Poly(nA, EA_poly); sec.rhoA(i) = Poly(nA, rhoA_poly); double EIxx_poly[nI]; double EIyy_poly[nI]; double GJ_poly[nI]; double rhoJ_poly[nI]; for (int j = 0; j < nI; j++) { EIxx_poly[j] = bp::extract<double>(EIxx_list[i][j]); EIyy_poly[j] = bp::extract<double>(EIyy_list[i][j]); GJ_poly[j] = bp::extract<double>(GJ_list[i][j]); rhoJ_poly[j] = bp::extract<double>(rhoJ_list[i][j]); } sec.EIxx(i) = Poly(nI, EIxx_poly); sec.EIyy(i) = Poly(nI, EIyy_poly); sec.GJ(i) = Poly(nI, GJ_poly); sec.rhoJ(i) = Poly(nI, rhoJ_poly); } }
// calc convex hull and Min and Max of layer // Monotone chain algo // http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain void Layer::calcConvexHull() { hullPolygon.clear(); hullPolygon=Poly(Z); vector<struct sortable_point> P; for (uint i = 0; i<polygons.size(); i++) for (uint j = 0; j<polygons[i].size(); j++) { struct sortable_point point; point.v = polygons[i].vertices[j]; P.push_back(point); } int n = P.size(); vector<Vector2d> H(2*n); //cerr << n << " points"<< endl; if (n<2) return; if (n<4) { for (int i = 0; i < n; i++) hullPolygon.addVertex(P[i].v); return; } sort(P.begin(), P.end()); // for (int i = 0; i < n; i++) { // cerr <<P[i].v<< endl; // } // Build lower hull int k=0; for (int i = 0; i < n; i++) { while (k >= 2 && cross(H[k-2], H[k-1], P[i].v) <= 0) k--; H[k++] = P[i].v; } // Build upper hull for (int i = n-2, t = k+1; i >= 0; i--) { while (k >= t && cross(H[k-2], H[k-1], P[i].v) <= 0) k--; H[k++] = P[i].v; } H.resize(k); hullPolygon.vertices = H; vector<Vector2d> minmax = hullPolygon.getMinMax(); Min = minmax[0]; Max = minmax[1]; }
Poly Poly::operator+(const Poly& p) { //get maximum number of terms int newTerms = p.terms > this->terms ? p.terms : this->terms; //create output polynomial Poly output = Poly(0, newTerms - 1); //walk through coefficients for (int t = 0; t < newTerms; t++) { int c = 0; c += (t < this->terms) ? this->coeffs[t] : 0; c += (t < p.terms) ? p.coeffs[t] : 0; output.setCoeff(c, t); } return output; }
Type Poly(size_t k, const Vector &a, const Type &z) { size_t i; size_t d = a.size() - 1; Type tmp; // check Vector is Simple Vector class with Type elements CheckSimpleVector<Type, Vector>(); // case where derivative order greater than degree of polynomial if( k > d ) { tmp = 0; return tmp; } // case where we are evaluating a derivative if( k > 0 ) { // initialize factor as (k-1) ! size_t factor = 1; for(i = 2; i < k; i++) factor *= i; // set b to coefficient vector corresponding to derivative Vector b(d - k + 1); for(i = k; i <= d; i++) { factor *= i; tmp = factor; b[i - k] = a[i] * tmp; factor /= (i - k + 1); } // value of derivative polynomial return Poly(0, b, z); } // case where we are evaluating the original polynomial Type sum = a[d]; i = d; while(i > 0) { sum *= z; sum += a[--i]; } return sum; }
void __fastcall TfrmMarkParam::ListKindsDrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State) { HDC dc = ((TListBox *)Control)->Canvas->Handle; ((TListBox *)Control)->Canvas->FillRect(Rect); TTextPropRec *prec=(TTextPropRec*)ListKinds->Items->Objects[Index]; int pid=prec->Id; int drwcls=FDict->SelectDrwParam(ROADMARKCODE,pid,1); String s=prec->ShortText; DrawText(dc,s.c_str(),s.Length(),&TRect(Rect.left,Rect.top+2,Rect.right-64,Rect.bottom-2),DT_WORDBREAK); if (drwcls>0) { TDrwClassesRec *Cls=FDict->DrwClasses->Items[drwcls]; TDrawContents *Cont=new TDrawBitmap(); int w=Rect.Right-Rect.Left-64; int h=Rect.Bottom-Rect.Top-4; Cont->SetSize(w,h); Cont->SetParam(0,1,0,0,1,0,1); SetBkMode(dc,TRANSPARENT); TExtPolyline Poly(2,0); Poly[0].x=2; Poly[0].y=h>>1; Poly[1].x=w-2; Poly[1].y=h>>1; Poly.Codes[1]=1; Cont->PrepareUpdating(); for (int i=0;i<MAXDRWPARAM;i++) if (Cls->DrwParamId[i]>0) { TDrwParamRec *Rec=FDict->DrwParams->Items[Cls->DrwParamId[i]]; TRect MRect; FDrawMan->CallDrawFunc(Cont,&Poly,Rec,&MRect,2000,500,pkGorizontal,pdDirect,PixelsPerInch/2.54,i==0); } Cont->FinishUpdating(); Cont->DrawTo(((TListBox *)Control)->Canvas,Rect.Left+62,Rect.Top+2); delete Cont; }
/* operator* Multiplies two poly objects together math rule a(b+c) = ab + ac Check if either object is zero (largestExpo is 0 and coefficient is 0) this automatically means the answer will be zero */ Poly Poly::operator*(const Poly& param) const { //If either objects are only a zero subscript with zero as the int //Return a Poly object of 0 if(largestExpo == 0 || param.largestExpo == 0) { if(polynomial[0] == 0 || param.polynomial[0] == 0) { return Poly(0,0); } } //Create poly object with size equal to the sum of both objects //largest exponent Poly temp(0,largestExpo+param.largestExpo); //Multiple each coefficient together and add to proper location //x^a * x^b is equal to x^(a+b) for(int i = 0; i <= largestExpo; i++) { for(int j = 0; j <= param.largestExpo; j++) { temp.polynomial[i+j] += polynomial[i]*param.polynomial[j]; } } //determine the largest non zero exponent since it's possible to //have coefficients cancel each other out temp.getLargestExpo(); return temp; }
// computes FEM matrices for one 12-dof beam element void beamMatrix(double L, const Poly &EIx, const Poly &EIy, const Poly &EA, const Poly &GJ, const Poly &rhoA, const Poly &rhoJ, const Poly &Px, const Poly &Py, const Poly &FzfromPz, Matrix &K, Matrix &M, Matrix &Ndist, Matrix &Nconst, Vector &F){ //using namespace boost::numeric::ublas; // initialize F.setZero(); K.setZero(); M.setZero(); Ndist.setZero(); Nconst.setZero(); int i; // ------- bending (x-dir) --------------- const int ns = 4; // number of shape functions // define the shape functions Poly f[ns] = { Poly(4, 2.0, -3.0, 0.0, 1.0), Poly(4, 1.0*L, -2.0*L, 1.0*L, 0.0*L), Poly(4, -2.0, 3.0, 0.0, 0.0), Poly(4, 1.0*L, -1.0*L, 0.0*L, 0.0*L) }; Poly fp[ns]; Poly fpp[ns]; for (i = 0; i < ns; i++) { fp[i] = f[i].differentiate(); fpp[i] = fp[i].differentiate(); } // stiffness matrix Matrix KbendX(ns, ns); matrixAssembly(EIx, ns, fpp, 1.0/pow(L,3), KbendX); // inertia matrix Matrix Mbend(ns, ns); matrixAssembly(rhoA, ns, f, L, Mbend); // incremental stiffness matrix from distributed loads Matrix Nbend_dist(ns, ns); matrixAssembly(-FzfromPz, ns, fp, 1.0/L, Nbend_dist); // compression loads positive // incremental stiffness matrix from constant loads Matrix Nbend_const(ns, ns); Poly one(1, 1.0); matrixAssembly(one, ns, fp, 1.0/L, Nbend_const); // distributed applied loads Vector FbendX(ns); vectorAssembly(Px, ns, f, L, FbendX); // put into global matrix std::vector<int> idx = {0, 1, 6, 7}; //idx(0) = 0; idx(1) = 1; idx(2) = 6; idx(3) = 7; for (int ii=0; ii<ns; ii++) { F(idx[ii]) = FbendX(ii); for (int jj=0; jj<ns; jj++) { K(idx[ii], idx[jj]) = KbendX(ii,jj); M(idx[ii], idx[jj]) = Mbend(ii,jj); Ndist(idx[ii], idx[jj]) = Nbend_dist(ii,jj); Nconst(idx[ii], idx[jj]) = Nbend_const(ii,jj); } } //project(K, idx, idx) = KbendX; //project(M, idx, idx) = Mbend; //project(Ndist, idx, idx) = Nbend_dist; //project(Nconst, idx, idx) = Nbend_const; //project(F, idx) = FbendX; // ---------- bending (y-dir) --------------- // stiffness matrix Matrix KbendY(ns, ns); matrixAssembly(EIy, ns, fpp, 1.0/pow(L,3), KbendY); // distributed applied loads Vector FbendY(ns); vectorAssembly(Py, ns, f, L, FbendY); // put into global matrix (mass and incremental stiffness are same in x an y) idx = {2, 3, 8, 9}; //idx(0) = 2; idx(1) = 3; idx(2) = 8; idx(3) = 9; for (int ii=0; ii<ns; ii++) { F(idx[ii]) = FbendY(ii); for (int jj=0; jj<ns; jj++) { K(idx[ii], idx[jj]) = KbendY(ii,jj); M(idx[ii], idx[jj]) = Mbend(ii,jj); Ndist(idx[ii], idx[jj]) = Nbend_dist(ii,jj); Nconst(idx[ii], idx[jj]) = Nbend_const(ii,jj); } } //project(K, idx, idx) = KbendY; //project(M, idx, idx) = Mbend; //project(Ndist, idx, idx) = Nbend_dist; //project(Nconst, idx, idx) = Nbend_const; //project(F, idx) = FbendY; // ----------- axial ---------------- const int nsz = 2; // number of shape functions Poly fz[nsz] = { Poly(2, -1.0, 1.0), Poly(2, 1.0, 0.0) }; // derivatives of the shape function Poly fzp [nsz]; Poly fzpp [nsz]; for (i = 0; i < nsz; i++) { fzp[i] = fz[i].differentiate(); fzpp[i] = fzp[i].differentiate(); } // stiffness matrix Matrix Kaxial(nsz, nsz); matrixAssembly(EA, nsz, fzp, 1.0/L, Kaxial); // inertia matrix Matrix Maxial(nsz, nsz); matrixAssembly(rhoA, nsz, fz, L, Maxial); // axial loads already given (work equivalent approach not appropriate for distributed axial loads) Vector Faxial(nsz); Faxial(0) = FzfromPz.eval(0.0); Faxial(1) = FzfromPz.eval(1.0); // put into global matrix std::vector<int> idx_z = {4, 10}; //idx_z(0) = 4; idx_z(1) = 10; for (int ii=0; ii<nsz; ii++) { F(idx_z[ii]) = Faxial(ii); for (int jj=0; jj<nsz; jj++) { K(idx_z[ii], idx_z[jj]) = Kaxial(ii,jj); M(idx_z[ii], idx_z[jj]) = Maxial(ii,jj); } } //project(K, idx_z, idx_z) = Kaxial; //project(M, idx_z, idx_z) = Maxial; //project(F, idx_z) = Faxial; // --------- torsion ------------- // same shape functions as axial // stiffness matrix Matrix Ktorsion(nsz, nsz); matrixAssembly(GJ, nsz, fzp, 1.0/L, Ktorsion); // inertia matrix Matrix Mtorsion(nsz, nsz); matrixAssembly(rhoJ, nsz, fz, L, Mtorsion); // put into global matrix idx_z = {5, 11}; //idx_z(0) = 5; idx_z(1) = 11; for (int ii=0; ii<nsz; ii++) { for (int jj=0; jj<nsz; jj++) { K(idx_z[ii], idx_z[jj]) = Ktorsion(ii,jj); M(idx_z[ii], idx_z[jj]) = Mtorsion(ii,jj); } } //project(K, idx_z, idx_z) = Ktorsion; //project(M, idx_z, idx_z) = Mtorsion; }
void endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { switch (activeTool) { case TOOL_FREESEL: { POINT *ptStackCopy; int i; rectSel_src[0] = rectSel_src[1] = 0x7fffffff; rectSel_src[2] = rectSel_src[3] = 0; for (i = 0; i <= ptSP; i++) { if (ptStack[i].x < rectSel_src[0]) rectSel_src[0] = ptStack[i].x; if (ptStack[i].y < rectSel_src[1]) rectSel_src[1] = ptStack[i].y; if (ptStack[i].x > rectSel_src[2]) rectSel_src[2] = ptStack[i].x; if (ptStack[i].y > rectSel_src[3]) rectSel_src[3] = ptStack[i].y; } rectSel_src[2] += 1 - rectSel_src[0]; rectSel_src[3] += 1 - rectSel_src[1]; rectSel_dest[0] = rectSel_src[0]; rectSel_dest[1] = rectSel_src[1]; rectSel_dest[2] = rectSel_src[2]; rectSel_dest[3] = rectSel_src[3]; if (ptSP != 0) { DeleteObject(hSelMask); hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL); DeleteObject(SelectObject(hSelDC, hSelMask)); ptStackCopy = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * (ptSP + 1)); for (i = 0; i <= ptSP; i++) { ptStackCopy[i].x = ptStack[i].x - rectSel_src[0]; ptStackCopy[i].y = ptStack[i].y - rectSel_src[1]; } Poly(hSelDC, ptStackCopy, ptSP + 1, 0x00ffffff, 0x00ffffff, 1, 2, TRUE); HeapFree(GetProcessHeap(), 0, ptStackCopy); SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3])); resetToU1(); MaskBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0], rectSel_src[1], hSelMask, 0, 0, MAKEROP4(SRCCOPY, WHITENESS)); Poly(hdc, ptStack, ptSP + 1, bg, bg, 1, 2, TRUE); newReversible(); MaskBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND)); placeSelWin(); ShowWindow(hSelection, SW_SHOW); /* force refresh of selection contents */ SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0); SendMessage(hSelection, WM_MOUSEMOVE, 0, 0); SendMessage(hSelection, WM_LBUTTONUP, 0, 0); } HeapFree(GetProcessHeap(), 0, ptStack); ptStack = NULL; break; } case TOOL_RECTSEL: resetToU1(); if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0)) { DeleteObject(hSelMask); hSelMask = CreateBitmap(rectSel_src[2], rectSel_src[3], 1, 1, NULL); DeleteObject(SelectObject(hSelDC, hSelMask)); Rect(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], 0x00ffffff, 0x00ffffff, 1, 2); SelectObject(hSelDC, hSelBm = CreateDIBWithProperties(rectSel_src[2], rectSel_src[3])); resetToU1(); BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0], rectSel_src[1], SRCCOPY); Rect(hdc, rectSel_src[0], rectSel_src[1], rectSel_src[0] + rectSel_src[2], rectSel_src[1] + rectSel_src[3], bgColor, bgColor, 0, TRUE); newReversible(); BitBlt(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[2], rectSel_src[3], hSelDC, 0, 0, SRCCOPY); placeSelWin(); ShowWindow(hSelection, SW_SHOW); /* force refresh of selection contents */ SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0); SendMessage(hSelection, WM_MOUSEMOVE, 0, 0); SendMessage(hSelection, WM_LBUTTONUP, 0, 0); } break; case TOOL_RUBBER: Erase(hdc, last.x, last.y, x, y, bg, rubberRadius); break; case TOOL_PEN: Line(hdc, last.x, last.y, x, y, fg, 1); SetPixel(hdc, x, y, fg); break; case TOOL_LINE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) roundTo8Directions(start.x, start.y, &x, &y); Line(hdc, start.x, start.y, x, y, fg, lineWidth); break; case TOOL_BEZIER: pointSP++; if (pointSP == 4) pointSP = 0; break; case TOOL_RECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; case TOOL_SHAPE: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, &pointStack[pointSP].x, &pointStack[pointSP].y); pointSP++; if (pointSP >= 2) { if ((pointStack[0].x - x) * (pointStack[0].x - x) + (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1) { Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE); pointSP = 0; } else { Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE); } } if (pointSP == 255) pointSP--; break; case TOOL_ELLIPSE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; case TOOL_RRECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; } }
int PrincipalAxis::computeShapeFuncCoeff() { int numOfPoints = this->getExperimentalPointRule()->getNumberOfPoints(); if (shapeFuncCoeff !=0) { if (shapeFuncCoeff[0] !=0){ for (int i =0; i< numOfPoints; i++){ delete shapeFuncCoeff[i]; shapeFuncCoeff[i]=0; } } delete shapeFuncCoeff; shapeFuncCoeff =0; } // -- alloc mem shapeFuncCoeff =new Vector * [numOfPoints]; for (int i =0; i< numOfPoints; i++){ shapeFuncCoeff[i] = new Vector(numOfPoints); shapeFuncCoeff[i]->Zero(); } // -- compute coeff // refer paper by Rahman. "Decomposition methods for structural reliability analysis" /* Shape Function at point j is coeff of, Fj = (x-x[1])*(x-x[2])*...*(x-x[j-1])*(x-x[j+1])...(x-x[n])/Denominator where Denominator = (x[j]-x[1])*(x[j]-x[2])*...*(x[j]-x[j-1])*(x[j]-x[j+1])...(x[j]-x[n]) rearrange it to get Fj = (a[0]*x^(n-1)+a[1]*x^(n-2)+...+a[n-1]*x^0) / Denominator *shapeFuncCoeff[j] = {a[0], a[1] ...a[n-1]}/Denominator Note a[0]=1.0 */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !! int size = numOfPoints; Vector temp(size-1); temp.Zero(); Vector x( *(this->getExperimentalPointRule()->getPointCoordinates())); double denominator; for (int jj =0; jj<size; jj++){ // for each point jj on axis int kk; for(kk=0; kk<jj; kk++) temp(kk) = x(kk); for( kk=jj+1; kk<size; kk++) temp(kk-1) = x(kk); denominator = 1.0; for ( kk=0; kk<size; kk++){ if (kk !=jj) denominator *= (x(jj)-x(kk)); } // double theValue = thePrincipalAxes[ii]->getValueOnAxis(jj); // opserr<<"theValue:"<<theValue<<" denom:"<<denominator<<endln; // Vector coeff(*Poly(&temp)); shapeFuncCoeff[jj]->addVector(0.0, *Poly(&temp), 1.0/denominator); } // for each point jj on this axis return 0; }
void PlotTheta( TString inputfilename, TString outputfilename = "output.root"){ // infile= new TFile("../PATGrid.SM.10k.root","READ"); infile = new TFile(inputfilename, "READ"); tree = (TTree*)infile->Get("Event"); outputFile = new TFile(outputfilename, "RECREATE"); outTree = new TTree("MyTree","Untersuchung der RekoObjekte"); //TH2::SetDefaultSumw2(); histogram__CosThetaDiff = new TH1D("histogram__CosThetaDiff", "Differenz CosTheta gen-reko", 400, -2, 2); histogram__CosTheta_GenReko = new TH2D("histogram__CosTheta_GenReko", "Reko-cos(theta) gegen Gen-cos(theta)", 50, -1, 1, 50, -1, 1); histogram__gen_A = new TH2D("histogram__gen_A", "histogram__gen_A", 5, -1, 1, 5, -1, 1); histogram__gen_N = new TH2D("histogram__gen_N", "histogram__gen_N", 5, -1, 1, 5, -1, 1); histogram__gen_LL = new TH2D("histogram__gen_LL", "histogram__gen_LL", 5, -1, 1, 5, -1, 1); histogram__gen_LR = new TH2D("histogram__gen_LR", "histogram__gen_LR", 5, -1, 1, 5, -1, 1); histogram__gen_RR = new TH2D("histogram__gen_RR", "histogram__gen_RR", 5, -1, 1, 5, -1, 1); histogram__gen_RL = new TH2D("histogram__gen_RL", "histogram__gen_RL", 5, -1, 1, 5, -1, 1); histogram__gen_Correlation = new TH2D("histogram__gen_Correlation", "histogram__gen_Correlation", 5, -1, 1, 5, -1, 1); histogram__A = new TH2D("histogram__A", "histogram__A", 5, -1, 1, 5, -1, 1); histogram__N = new TH2D("histogram__N", "histogram__N", 5, -1, 1, 5, -1, 1); histogram__Correlation = new TH2D("histogram__Correlation", "histogram__Correlation", 5, -1, 1, 5, -1, 1); histogram__Correlation_L15_B50_T1 = new TH2D("histogram__Correlation_L15_B50_T1", "histogram__Correlation_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__A_L15_B50_T1 = new TH2D("histogram__A_L15_B50_T1", "histogram__A_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__N_L15_B50_T1 = new TH2D("histogram__N_L15_B50_T1", "histogram__N_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20 = new TH2D("histogram__Correlation_L20", "histogram__Correlation_L20", 5, -1, 1, 5, -1, 1); histogram__A_L20 = new TH2D("histogram__A_L20", "histogram__A_L20", 5, -1, 1, 5, -1, 1); histogram__N_L20 = new TH2D("histogram__N_L20", "histogram__N_L20", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B40 = new TH2D("histogram__Correlation_L20_B40", "histogram__Correlation_L20_B40", 5, -1, 1, 5, -1, 1); histogram__A_L20_B40 = new TH2D("histogram__A_L20_B40", "histogram__A_L20_B40", 5, -1, 1, 5, -1, 1); histogram__N_L20_B40 = new TH2D("histogram__N_L20_B40", "histogram__N_L20_B40", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B30_T1 = new TH2D("histogram__Correlation_L20_B30_T1", "histogram__Correlation_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__A_L20_B30_T1 = new TH2D("histogram__A_L20_B30_T1", "histogram__A_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__N_L20_B30_T1 = new TH2D("histogram__N_L20_B30_T1", "histogram__N_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B40_T1 = new TH2D("histogram__Correlation_L20_B40_T1", "histogram__Correlation_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__A_L20_B40_T1 = new TH2D("histogram__A_L20_B40_T1", "histogram__A_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__N_L20_B40_T1 = new TH2D("histogram__N_L20_B40_T1", "histogram__N_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_T1 = new TH2D("histogram__Correlation_T1", "histogram__Correlation_T1", 5, -1, 1, 5, -1, 1); histogram__A_T1 = new TH2D("histogram__A_T1", "histogram__A_T1", 5, -1, 1, 5, -1, 1); histogram__N_T1 = new TH2D("histogram__N_T1", "histogram__N_T1", 5, -1, 1, 5, -1, 1); histogram__CosThetaDiff_TTbarPt = new TH2D("histogram__CosThetaDiff_TTbarPt", "histogram__CosThetaDiff_TTbarPt", 100, 0, 1000, 400, -2, 2); histogram__LeptonRelIso = new TH1D("histogram__LeptonRelIso", "histogram__LeptonRelIso", 101, 0, 1.01); histogram__semilepton_BLeptonMinus = new TH1D("histogram__semilepton_BLeptonMinus","histogram__semilepton_BLeptonMinus", 200, -1, 1); histogram__semilepton_BLeptonPlus = new TH1D("histogram__semilepton_BLeptonPlus","histogram__semilepton_BLeptonPlus", 200, -1, 1); histogram_nupx_gen_reco = new TH2D(" histogram_nupx_gen_reco", " histogram_nupx_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nupy_gen_reco = new TH2D(" histogram_nupy_gen_reco", " histogram_nupy_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nupz_gen_reco = new TH2D(" histogram_nupz_gen_reco", " histogram_nupz_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpx_gen_reco = new TH2D(" histogram_nubpx_gen_reco", " histogram_nubpx_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpy_gen_reco = new TH2D(" histogram_nubpy_gen_reco", " histogram_nubpy_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpz_gen_reco = new TH2D(" histogram_nubpz_gen_reco", " histogram_nubpz_gen_reco", 600, -300, 300, 600, -300, 300); outTree->Branch("EventIsGood", &EventIsGood, "Event ist rekonstruiert/I"); outTree->Branch("numberOfJets", &numberOfJets, "Anzahl der Jets/I"); outTree->Branch("numberOfGoodJets", &numberOfGoodJets, "Anzahl der guten Jets/I"); outTree->Branch("CosThetaDiff" ,&CosThetaDiff ,"Differenz im cosTheta Reko zu Gen/D"); outTree->Branch("CosThetaPlus" ,&CosThetaPlus ,"cosTheta LeptonPlus/D"); outTree->Branch("CosThetaMinus" ,&CosThetaMinus ,"cosTheta LeptonMinus/D"); outTree->Branch("RekoCosThetaPlus" ,&RekoCosThetaPlus ,"cosTheta RekoLeptonPlus/D"); outTree->Branch("RekoCosThetaMinus" ,&RekoCosThetaMinus ,"cosTheta RekoLeptonMinus/D"); outTree->Branch("CosLeptonAngleD", &CosLeptonAngleD, "CosinusLeptonWinkel D/D"); outTree->Branch("CosRekoLeptonAngleD", &CosRekoLeptonAngleD, "CosinusRekoLeptonWinkel D/D"); outTree->Branch("TTbar_Pt", &TTbar_Pt, "Pt des TTbarsystems Generator/D"); outTree->Branch("RekoTTbar_Pt", &RekoTTbar_Pt, "Pt des TTbarsystems Reko/D"); outTree->Branch("TTbar_M", &TTbar_M, "Masse des TTbarsystems Generator/D"); outTree->Branch("RekoTTbar_M", &RekoTTbar_M, "Masse des TTbarsystems Reko/D"); outTree->Branch("Top_Pt", &Top_Pt, "Pt des Tops Generator/D"); outTree->Branch("Top_M", &Top_M, "M des Tops Generator/D"); outTree->Branch("AntiTop_Pt", &AntiTop_Pt, "Pt des AntiTops Generator/D"); outTree->Branch("AntiTop_M", &AntiTop_M, "M des AntiTops Generator/D"); outTree->Branch("RekoTop_Pt", &RekoTop_Pt, "Pt des Tops Reko/D"); outTree->Branch("RekoAntiTop_Pt", &RekoAntiTop_Pt, "Pt des AntiTops Reko/D"); outTree->Branch("RekoTop_M", &RekoTop_M, "M des Tops Reko/D"); outTree->Branch("RekoAntiTop_M", &RekoAntiTop_M, "M des AntiTops Reko/D"); outTree->Branch("Nu_Px", &Nu_Px, "Px des Neutrinos Generator/D"); outTree->Branch("Nu_Py", &Nu_Py, "Py des Neutrinos Generator/D"); outTree->Branch("Nu_Pz", &Nu_Pz, "Pz des Neutrinos Generator/D"); outTree->Branch("AntiNu_Px", &AntiNu_Px, "Px des AntiNeutrinos Generator/D"); outTree->Branch("AntiNu_Py", &AntiNu_Py, "Py des AntiNeutrinos Generator/D"); outTree->Branch("AntiNu_Pz", &AntiNu_Pz, "Pz des AntiNeutrinos Generator/D"); outTree->Branch("RekoNu_Px", &RekoNu_Px, "Px des Neutrinos Reko/D"); outTree->Branch("RekoNu_Py", &RekoNu_Py, "Py des Neutrinos Reko/D"); outTree->Branch("RekoNu_Pz", &RekoNu_Pz, "Pz des Neutrinos Reko/D"); outTree->Branch("RekoAntiNu_Px", &RekoAntiNu_Px, "Px des AntiNeutrinos Reko/D"); outTree->Branch("RekoAntiNu_Py", &RekoAntiNu_Py, "Py des AntiNeutrinos Reko/D"); outTree->Branch("RekoAntiNu_Pz", &RekoAntiNu_Pz, "Pz des AntiNeutrinos Reko/D"); outTree->Branch("BestNu_Px", &BestNu_Px, "Px des Neutrinos Best/D"); outTree->Branch("BestNu_Py", &BestNu_Py, "Py des Neutrinos Best/D"); outTree->Branch("BestNu_Pz", &BestNu_Pz, "Pz des Neutrinos Best/D"); outTree->Branch("BestAntiNu_Px", &BestAntiNu_Px, "Px des AntiNeutrinos Best/D"); outTree->Branch("BestAntiNu_Py", &BestAntiNu_Py, "Py des AntiNeutrinos Best/D"); outTree->Branch("BestAntiNu_Pz", &BestAntiNu_Pz, "Pz des AntiNeutrinos Best/D"); outTree->Branch("Lepton_Pt", &Lepton_Pt, "kleineres Pt der beiden gewaehlten Leptonen/D"); outTree->Branch("BJet_Et", &BJet_Et,"niedrigieres Et der BJets/D"); outTree->Branch("BJet_Tag_TrkCount", &BJet_Tag_TrkCount,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Tag_SVsimple", &BJet_Tag_SVsimple,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Tag_SVcomb", &BJet_Tag_SVcomb,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Disc", &BJet_Disc,"niedrigierer Discriminator der BJets/D"); outTree->Branch("Lepton1_Id", &Lepton1_Id, "PdgId des ersten Leptons/I"); outTree->Branch("Lepton2_Id", &Lepton2_Id, "PdgId des zweiten Leptons/I"); outTree->Branch("Lepton_Mass", &Lepton_Mass, "inv. Masse der beiden Leptonen/D"); outTree->Branch("BJet_Angle", &BJet_Angle, "Winkel bJet zu Quark/D"); outTree->Branch("BbarJet_Angle", &BbarJet_Angle, "Winkel bbarJet zu Quark/D"); outTree->Branch("LeptonPlus_Angle", &LeptonPlus_Angle, "Winkel LeptonPlus zu Lepton Gen /D"); outTree->Branch("LeptonMinus_Angle", &LeptonMinus_Angle, "Winkel LeptonMinus zu Lepton Gen /D"); outTree->Branch("RekoNu_Angle", &RekoNu_Angle, "Winkel RekoNu zu GenNu/D"); outTree->Branch("RekoAntiNu_Angle", &RekoAntiNu_Angle, "Winkel RekoAntiNu zu GenAntiNu/D"); outTree->Branch("BestNu_Angle", &BestNu_Angle, "Winkel BestNu zu GenNu/D"); outTree->Branch("BestAntiNu_Angle", &BestAntiNu_Angle, "Winkel BestAntiNu zu GenAntiNu/D"); histogram__gen_Correlation->Sumw2(); histogram__Correlation->Sumw2(); histogram__gen_A->Sumw2(); histogram__A->Sumw2(); histogram__gen_N->Sumw2(); histogram__N->Sumw2(); double PatJetsPx[50]; double PatJetsPy[50]; double PatJetsPz[50]; double PatJetsE[50]; double PatJetsEt[50]; double PatLeptonsPx[20]; double PatLeptonsPy[20]; double PatLeptonsPz[20]; double PatLeptonsPt[20]; double PatLeptonsE[20]; int PatLeptonsCharge[20]; int PatLeptonsPdgId[20]; double PatLeptonsTrkIso[20]; double PatLeptonsCaloIso[20]; double PatJetsBTag_TrkCount[50]; double PatJetsBTag_SVsimple[50]; double PatJetsBTag_SVcomb[50]; double PatJetsCharge[50]; double PatJetsBQuarkDeltaR[50]; double PatJetsBbarQuarkDeltaR[50]; int numberOfPatMuons; int numberOfPatElectrons; int numberOfPatLeptons; int numberOfPatJets; int numberOfLeptons; TLorentzVector *pTop; //FROM TREE TLorentzVector *pAntiTop; //FROM TREE TLorentzVector *pLeptonPlus; //FROM TREE TLorentzVector *pLeptonMinus; //FROM TREE TLorentzVector *pBQuark; //FROM TREE TLorentzVector *pBbarQuark; //FROM TREE TLorentzVector* pGenNu; //FROM TREE TLorentzVector* pGenAntiNu; //FROM TREE TLorentzVector *pTTbar; TLorentzVector *pTopBoosted; TLorentzVector *pAntiTopBoosted; TLorentzVector *pLeptonPlusBoosted; TLorentzVector *pLeptonMinusBoosted; TLorentzVector *pJet[50]; TLorentzVector *pBJet1; TLorentzVector *pBJet2; TLorentzVector *pRekoNu1; TLorentzVector *pRekoAntiNu1; TLorentzVector *pRekoNu2; TLorentzVector *pRekoAntiNu2; TLorentzVector *pRekoLeptonPlus; TLorentzVector *pRekoLeptonMinus; TLorentzVector *pBJet; TLorentzVector *pBbarJet; TLorentzVector *pRekoNu; TLorentzVector *pRekoAntiNu; TLorentzVector *pBestNu; TLorentzVector *pBestAntiNu; TLorentzVector *pBestNu2; TLorentzVector *pBestAntiNu2; TLorentzVector *pRekoTop; TLorentzVector *pRekoAntiTop; TLorentzVector *pRekoTTbar; TLorentzVector *pRekoTopBoosted; TLorentzVector *pRekoAntiTopBoosted; TLorentzVector *pRekoLeptonPlusBoosted; TLorentzVector *pRekoLeptonMinusBoosted; TLorentzVector *pNu; TLorentzVector *pAntiNu; TLorentzVector *pBBoosted; TLorentzVector *pBbarBoosted; pTop = new TLorentzVector(0,0,0,0); pAntiTop = new TLorentzVector(0,0,0,0); pLeptonPlus = new TLorentzVector(0,0,0,0); pLeptonMinus = new TLorentzVector(0,0,0,0); pBQuark = new TLorentzVector(0,0,0,0); pBbarQuark = new TLorentzVector(0,0,0,0); pGenNu = new TLorentzVector(0,0,0,0); pGenAntiNu = new TLorentzVector(0,0,0,0); pTTbar = new TLorentzVector(0,0,0,0); pTopBoosted = new TLorentzVector(0,0,0,0); pAntiTopBoosted = new TLorentzVector(0,0,0,0); pLeptonPlusBoosted = new TLorentzVector(0,0,0,0); pLeptonMinusBoosted = new TLorentzVector(0,0,0,0); pRekoTop = new TLorentzVector(0,0,0,0); pRekoAntiTop = new TLorentzVector(0,0,0,0); pRekoLeptonPlus = new TLorentzVector(0,0,0,0); pRekoLeptonMinus = new TLorentzVector(0,0,0,0); pRekoNu = new TLorentzVector(0,0,0,0); pRekoAntiNu = new TLorentzVector(0,0,0,0); pBestNu = new TLorentzVector(0,0,0,0); pBestAntiNu = new TLorentzVector(0,0,0,0); pBestNu2 = new TLorentzVector(0,0,0,0); pBestAntiNu2 = new TLorentzVector(0,0,0,0); pRekoTTbar = new TLorentzVector(0,0,0,0); pRekoTopBoosted = new TLorentzVector(0,0,0,0); pRekoAntiTopBoosted = new TLorentzVector(0,0,0,0); pRekoLeptonPlusBoosted = new TLorentzVector(0,0,0,0); pRekoLeptonMinusBoosted = new TLorentzVector(0,0,0,0); pNu = new TLorentzVector(0,0,0,0); pAntiNu = new TLorentzVector(0,0,0,0); pBJet1 = new TLorentzVector(0,0,0,0); pBJet2 = new TLorentzVector(0,0,0,0); pRekoNu1 = new TLorentzVector(0,0,0,0); pRekoAntiNu1 = new TLorentzVector(0,0,0,0); pRekoNu2 = new TLorentzVector(0,0,0,0); pRekoAntiNu2 = new TLorentzVector(0,0,0,0); pBJet = new TLorentzVector(0,0,0,0); pBbarJet = new TLorentzVector(0,0,0,0); pBBoosted = new TLorentzVector(0,0,0,0); pBbarBoosted = new TLorentzVector(0,0,0,0); for(int i=0; i<50;i++) pJet[i] = new TLorentzVector(0,0,0,0); double mass_a = 170.0; double mass_b = 175.0; calc Poly(mass_a, mass_b, outputFile); tree->SetBranchAddress("pTop", &pTop); tree->SetBranchAddress("pAntiTop", &pAntiTop); tree->SetBranchAddress("pLeptonPlus", &pLeptonPlus); tree->SetBranchAddress("pLeptonMinus", &pLeptonMinus); tree->SetBranchAddress("pBQuark", &pBQuark); tree->SetBranchAddress("pBbarQuark", &pBbarQuark); tree->SetBranchAddress("PatLeptonsPx", PatLeptonsPx); tree->SetBranchAddress("PatLeptonsPy", PatLeptonsPy); tree->SetBranchAddress("PatLeptonsPz", PatLeptonsPz); tree->SetBranchAddress("PatLeptonsPt", PatLeptonsPt); tree->SetBranchAddress("PatLeptonsE", PatLeptonsE); tree->SetBranchAddress("PatLeptonsCharge", PatLeptonsCharge); tree->SetBranchAddress("PatLeptonsPdgId", PatLeptonsPdgId); tree->SetBranchAddress("PatLeptonsTrkIso", PatLeptonsTrkIso); tree->SetBranchAddress("PatLeptonsCaloIso", PatLeptonsCaloIso); tree->SetBranchAddress("PatJetsPx", PatJetsPx); tree->SetBranchAddress("PatJetsPy", PatJetsPy); tree->SetBranchAddress("PatJetsPz", PatJetsPz); tree->SetBranchAddress("PatJetsE", PatJetsE); tree->SetBranchAddress("PatJetsEt", PatJetsEt); tree->SetBranchAddress("PatJetsCharge", PatJetsCharge); tree->SetBranchAddress("PatJetsBTag_TrkCount", PatJetsBTag_TrkCount); tree->SetBranchAddress("PatJetsBTag_SVsimple", PatJetsBTag_SVsimple); tree->SetBranchAddress("PatJetsBTag_SVcomb", PatJetsBTag_SVcomb); tree->SetBranchAddress("PatJetsBQuarkDeltaR", PatJetsBQuarkDeltaR); tree->SetBranchAddress("PatJetsBbarQuarkDeltaR", PatJetsBbarQuarkDeltaR); tree->SetBranchAddress("numberOfPatMuons", &numberOfPatMuons); tree->SetBranchAddress("numberOfPatElectrons", &numberOfPatElectrons); tree->SetBranchAddress("numberOfPatLeptons", &numberOfPatLeptons); tree->SetBranchAddress("numberOfPatJets", &numberOfPatJets); tree->SetBranchAddress("numberOfLeptons", &numberOfLeptons); tree->SetBranchAddress("pGenNu", &pGenNu); tree->SetBranchAddress("pGenAntiNu", &pGenAntiNu); int nEvents = (int)tree->GetEntries(); //nEvents = 5000; int EventCounter = 0; cout << "Anzahl Ereignisse: " << nEvents << endl; for(int iEvent=1; iEvent<nEvents;iEvent++){ tree->GetEntry(iEvent); EventCounter++; if(iEvent%10000 == 1) { cout << "Event " << iEvent << endl; } EventIsGood = 0; // GENERATOR THETA w_A = 0; w_N = 0; *pTTbar=(*pTop+*pAntiTop); *pTopBoosted = *pTop; *pAntiTopBoosted = *pAntiTop; *pLeptonPlusBoosted = *pLeptonPlus; *pLeptonMinusBoosted = *pLeptonMinus; *pBBoosted = *pBQuark; *pBbarBoosted = *pBbarQuark; pAntiTopBoosted->Boost(-pTTbar->BoostVector()); pTopBoosted->Boost(-pTTbar->BoostVector()); pLeptonPlusBoosted->Boost(-pTop->BoostVector()); pLeptonMinusBoosted->Boost(-pAntiTop->BoostVector()); CosThetaPlus = cos(pLeptonPlusBoosted->Angle(pTopBoosted->Vect())); CosThetaMinus = cos(pLeptonMinusBoosted->Angle(pAntiTopBoosted->Vect())); pBBoosted->Boost(-pTop->BoostVector()); pBbarBoosted->Boost(-pAntiTop->BoostVector()); CosLeptonAngleD = cos(pLeptonPlusBoosted->Angle(pLeptonMinusBoosted->Vect())); double Nenner = 1 - 0.256*CosThetaPlus*CosThetaMinus; w_A = (-CosThetaPlus*CosThetaMinus)/Nenner; w_N = 1./Nenner; w_LL = (1-CosThetaPlus*CosThetaMinus-CosThetaPlus+CosThetaMinus)/Nenner; w_LR = (1+CosThetaPlus*CosThetaMinus-CosThetaPlus-CosThetaMinus)/Nenner; w_RR = (1-CosThetaPlus*CosThetaMinus+CosThetaPlus-CosThetaMinus)/Nenner; w_RL = (1+CosThetaPlus*CosThetaMinus+CosThetaPlus+CosThetaMinus)/Nenner; histogram__gen_A->Fill(CosThetaPlus, CosThetaMinus, w_A); histogram__gen_N->Fill(CosThetaPlus, CosThetaMinus, w_N); histogram__gen_LL->Fill(CosThetaPlus, CosThetaMinus, w_LL); histogram__gen_LR->Fill(CosThetaPlus, CosThetaMinus, w_LR); histogram__gen_RR->Fill(CosThetaPlus, CosThetaMinus, w_RR); histogram__gen_RL->Fill(CosThetaPlus, CosThetaMinus, w_RL); histogram__gen_Correlation->Fill(CosThetaPlus, CosThetaMinus); if(numberOfLeptons == 2) { if(pLeptonMinus->Px() != 0) histogram__semilepton_BLeptonMinus->Fill( cos(pLeptonMinusBoosted->Angle(pBBoosted->Vect())) ); if(pLeptonPlus->Px() != 0) histogram__semilepton_BLeptonPlus->Fill( cos(pLeptonPlusBoosted->Angle(pBbarBoosted->Vect())) ); } numberOfJets = numberOfPatJets; if(numberOfPatLeptons>=2 && numberOfPatJets >=2) { RekoNu_Px = -10000; RekoNu_Py= -10000; RekoNu_Pz= -10000; RekoAntiNu_Px= -10000; RekoAntiNu_Py= -10000; RekoAntiNu_Pz= -10000; RekoTop_M = -10; RekoAntiTop_M = -10; RekoTop_Pt = -10; RekoAntiTop_Pt = -10; // REKO THETA pBJet1->SetPxPyPzE(0.,0.,0.,0.); pBJet2->SetPxPyPzE(0.,0.,0.,0.); pRekoLeptonPlus->SetPxPyPzE(0.,0.,0.,0.); pRekoLeptonMinus->SetPxPyPzE(0.,0.,0.,0.); pBJet->SetPxPyPzE(0.,0.,0.,0.); pBbarJet->SetPxPyPzE(0.,0.,0.,0.); pRekoNu->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu->SetPxPyPzE(0.,0.,0.,-10000.); pBestNu->SetPxPyPzE(0.,0.,0.,-10000.); pBestAntiNu->SetPxPyPzE(0.,0.,0.,-10000.); pRekoNu1->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu1->SetPxPyPzE(0.,0.,0.,-10000.); pRekoNu2->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu2->SetPxPyPzE(0.,0.,0.,-10000.); int LeptonIndex[20]; int BTagTrkCountIndex[50]; int BTagSVsimpleIndex[50]; int BTagSVcombIndex[50]; int BJetsEIndex[50]; int BJetDeltaRIndex[50]; int BbarJetDeltaRIndex[50]; TMath::Sort(20,PatLeptonsE,LeptonIndex); TMath::Sort(50,PatJetsBTag_TrkCount, BTagTrkCountIndex); TMath::Sort(50,PatJetsBTag_SVsimple, BTagSVsimpleIndex); TMath::Sort(50,PatJetsBTag_SVcomb, BTagSVcombIndex); TMath::Sort(50, PatJetsE, BJetsEIndex); TMath::Sort(50, PatJetsBQuarkDeltaR, BJetDeltaRIndex); TMath::Sort(50, PatJetsBbarQuarkDeltaR, BbarJetDeltaRIndex); // Leptonen auswaehlen int OtherLepton = -1; for(int j=0; PatLeptonsCharge[LeptonIndex[0]]==PatLeptonsCharge[LeptonIndex[j]] && j<20; j++){ OtherLepton=j+1; } // if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==0) std::cout<<"Only Leptons of same Charge in Event " << iEvent << "!!"<<std::endl; if(PatLeptonsCharge[LeptonIndex[OtherLepton]]!=0){ // Leptonen zuordnen if(PatLeptonsCharge[LeptonIndex[0]]==-1){ pRekoLeptonMinus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[0]], PatLeptonsPy[LeptonIndex[0]], PatLeptonsPz[LeptonIndex[0]], PatLeptonsE[LeptonIndex[0]] ); } if(PatLeptonsCharge[LeptonIndex[0]]==+1){ pRekoLeptonPlus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[0]], PatLeptonsPy[LeptonIndex[0]], PatLeptonsPz[LeptonIndex[0]], PatLeptonsE[LeptonIndex[0]] ); } if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==-1){ pRekoLeptonMinus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[OtherLepton]], PatLeptonsPy[LeptonIndex[OtherLepton]], PatLeptonsPz[LeptonIndex[OtherLepton]],PatLeptonsE[LeptonIndex[OtherLepton]] ); } if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==+1){ pRekoLeptonPlus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[OtherLepton]], PatLeptonsPy[LeptonIndex[OtherLepton]], PatLeptonsPz[LeptonIndex[OtherLepton]], PatLeptonsE[LeptonIndex[OtherLepton]] ); } //cout << "Leptonen ausgewaehlt" << endl; Lepton_Mass = ((*pRekoLeptonPlus) + (*pRekoLeptonMinus)).M(); if( TMath::Abs( Lepton_Mass - 90.0 ) > 10 || PatLeptonsPdgId[LeptonIndex[0]] + PatLeptonsPdgId[LeptonIndex[OtherLepton]] !=0 ) { double JetDisc[50]; numberOfGoodJets = 0; for(int j=0; j<50; j++){ JetDisc[j] = 0.; if(j<numberOfPatJets){ //JetDisc[j] = PatJetsBTag_TrkCount[j] * PatJetsEt[j]; if(PatJetsBTag_TrkCount[j]>1. && PatJetsEt[j]>20){ pJet[j]->SetPxPyPzE(PatJetsPx[j],PatJetsPy[j], PatJetsPz[j], PatJetsE[j]); if(TMath::Min(pJet[j]->Angle(pRekoLeptonPlus->Vect()), pJet[j]->Angle(pRekoLeptonMinus->Vect())) >0.1){ numberOfGoodJets++; JetDisc[j] = PatJetsBTag_TrkCount[j] * PatJetsEt[j]; } } if(j<numberOfPatLeptons){ histogram__LeptonRelIso->Fill(PatLeptonsPt[j]/(PatLeptonsPt[j]+PatLeptonsTrkIso[j]+PatLeptonsCaloIso[j])); } } } int JetDiscIndex[50]; TMath::Sort(50, JetDisc, JetDiscIndex); // Jets auswaehlen // verbesserte Auswahl (BTag*ET) pBJet1->SetPxPyPzE(PatJetsPx[JetDiscIndex[0]],PatJetsPy[JetDiscIndex[0]],PatJetsPz[JetDiscIndex[0]],PatJetsE[JetDiscIndex[0]]); pBJet2->SetPxPyPzE(PatJetsPx[JetDiscIndex[1]],PatJetsPy[JetDiscIndex[1]],PatJetsPz[JetDiscIndex[1]],PatJetsE[JetDiscIndex[1]]); //pBJet1->SetPxPyPzE(PatJetsPx[BTagTrkCountIndex[0]],PatJetsPy[BTagTrkCountIndex[0]],PatJetsPz[BTagTrkCountIndex[0]],PatJetsE[BTagTrkCountIndex[0]]); //pBJet2->SetPxPyPzE(PatJetsPx[BTagTrkCountIndex[1]],PatJetsPy[BTagTrkCountIndex[1]],PatJetsPz[BTagTrkCountIndex[1]],PatJetsE[BTagTrkCountIndex[1]]); //cout << "Jets gewaehlt" << endl; // Neutrinos berechnen //Generator-Werte setzen fuer Vergleich mit Berechnung pNu->SetPxPyPzE(pGenNu->Px(),pGenNu->Py(),pGenNu->Pz(),pGenNu->E()); pAntiNu->SetPxPyPzE(pGenAntiNu->Px(),pGenAntiNu->Py(),pGenAntiNu->Pz(),pGenAntiNu->E()); Poly.Init(pRekoLeptonPlus, pRekoLeptonMinus, pBJet1, pBJet2, pNu, pAntiNu); // BJet1 = b, BJet2 = bbar Poly.Solve(170.0,171.0 , iEvent, pRekoNu1, pRekoAntiNu1, pBestNu, pBestAntiNu); Poly.Init(pRekoLeptonPlus, pRekoLeptonMinus, pBJet2, pBJet1, pNu, pAntiNu); // BJet1 = bbar, BJet2 = b Poly.Solve(170.0,171.0 , iEvent, pRekoNu2, pRekoAntiNu2, pBestNu2, pBestAntiNu2); //cout << "Neutrinos berechnet" << endl; // Abfrage, ob Neutrinoloesung ungleich -10000 !!! if(pRekoAntiNu1->Pz() != -10000 && pRekoAntiNu2->Pz() != -10000){ if(TMath::Abs( ((*pRekoLeptonPlus)+(*pRekoNu1)+(*pBJet1)).M() + ((*pRekoLeptonMinus)+(*pRekoAntiNu1)+(*pBJet2)).M() - 2*173.2) < TMath::Abs(((*pRekoLeptonPlus)+(*pRekoNu2)+(*pBJet2)).M() + ((*pRekoLeptonMinus)+(*pRekoAntiNu2)+(*pBJet1)).M() - 2*173.2) ){ *pBJet = *pBJet1; *pBbarJet = *pBJet2; *pRekoNu = *pRekoNu1; *pRekoAntiNu = *pRekoAntiNu1; } else { *pBJet = *pBJet2; *pBbarJet = *pBJet1; *pRekoNu = *pRekoNu2; *pRekoAntiNu = *pRekoAntiNu2; *pBestNu = *pBestNu2; *pBestAntiNu = *pBestAntiNu2; } } else if(pRekoAntiNu1->Pz() != -10000){ *pBJet = *pBJet1; *pBbarJet = *pBJet2; *pRekoNu = *pRekoNu1; *pRekoAntiNu = *pRekoAntiNu1; } else if(pRekoAntiNu2->Pz() != -10000){ *pBJet = *pBJet2; *pBbarJet = *pBJet1; *pRekoNu = *pRekoNu2; *pRekoAntiNu = *pRekoAntiNu2; *pBestNu = *pBestNu2; *pBestAntiNu = *pBestAntiNu2; } else{ pRekoNu->SetPxPyPzE(0,0,-10000, 10000); pRekoAntiNu->SetPxPyPzE(0,0,-10000, 10000); pBestNu->SetPxPyPzE(0,0,-10000, 10000); pBestAntiNu->SetPxPyPzE(0,0,-10000, 10000); pBJet->SetPxPyPzE(0,0,-10000, 10000); pBbarJet->SetPxPyPzE(0,0,-10000, 10000); } TTbar_Pt = pTTbar->Pt(); TTbar_M = pTTbar->M(); Top_Pt = pTop->Pt(); AntiTop_Pt = pAntiTop->Pt(); Top_M = pTop->M(); AntiTop_M = pAntiTop->M(); Nu_Px = pNu->Px(); Nu_Py = pNu->Py(); Nu_Pz = pNu->Pz(); AntiNu_Px = pAntiNu->Px(); AntiNu_Py = pAntiNu->Py(); AntiNu_Pz = pAntiNu->Pz(); Lepton_Pt = TMath::Min(pRekoLeptonPlus->Pt(), pRekoLeptonMinus->Pt()); BJet_Et = TMath::Min(pBJet->Et(), pBbarJet->Et()); BJet_Tag_SVsimple = PatJetsBTag_SVsimple[BTagSVsimpleIndex[1]]; BJet_Tag_SVcomb = PatJetsBTag_SVcomb[BTagSVcombIndex[1]]; BJet_Tag_TrkCount = PatJetsBTag_TrkCount[BTagTrkCountIndex[1]]; BJet_Disc = JetDisc[JetDiscIndex[1]]; Lepton1_Id = PatLeptonsPdgId[LeptonIndex[0]]; Lepton2_Id = PatLeptonsPdgId[LeptonIndex[OtherLepton]]; LeptonPlus_Angle = -10.; LeptonMinus_Angle = -10.; BJet_Angle = -10.; BbarJet_Angle = -10.; RekoNu_Angle = -10.; RekoAntiNu_Angle = -10.; BestNu_Angle = -10.; BestAntiNu_Angle = -10.; //cout << "Werte gesetzt" << endl; if(pRekoAntiNu->Pz() > -10000){ histogram_nupx_gen_reco->Fill(pGenNu->Px(), pRekoNu->Px()); histogram_nubpx_gen_reco->Fill(pGenAntiNu->Px(), pRekoAntiNu->Px()); histogram_nupy_gen_reco->Fill(pGenNu->Py(), pRekoNu->Py()); histogram_nubpy_gen_reco->Fill(pGenAntiNu->Py(), pRekoAntiNu->Py()); histogram_nupz_gen_reco->Fill(pGenNu->Pz(), pRekoNu->Pz()); histogram_nubpz_gen_reco->Fill(pGenAntiNu->Pz(), pRekoAntiNu->Pz()); if(pLeptonPlus->E() != 0 && pLeptonMinus->E() != 0 && pBQuark->E() != 0 ){ BJet_Angle = pBJet->DeltaR(*pBQuark); BbarJet_Angle = pBbarJet->DeltaR(*pBbarQuark); LeptonPlus_Angle = pRekoLeptonPlus->DeltaR(*pLeptonPlus); LeptonMinus_Angle = pRekoLeptonMinus->DeltaR(*pLeptonMinus); RekoNu_Angle = pRekoNu->DeltaR(*pNu); RekoAntiNu_Angle = pRekoAntiNu->DeltaR(*pAntiNu); BestNu_Angle = pBestNu->DeltaR(*pNu); BestAntiNu_Angle = pBestAntiNu->DeltaR(*pAntiNu); } RekoNu_Px = pRekoNu->Px(); RekoNu_Py = pRekoNu->Py(); RekoNu_Pz = pRekoNu->Pz(); RekoAntiNu_Px = pRekoAntiNu->Px(); RekoAntiNu_Py = pRekoAntiNu->Py(); RekoAntiNu_Pz = pRekoAntiNu->Pz(); BestNu_Px = pBestNu->Px(); BestNu_Py = pBestNu->Py(); BestNu_Pz = pBestNu->Pz(); BestAntiNu_Px = pBestAntiNu->Px(); BestAntiNu_Py = pBestAntiNu->Py(); BestAntiNu_Pz = pBestAntiNu->Pz(); if(pRekoLeptonPlus->E()!=0 && pRekoLeptonMinus->E()!=0 && pBJet->E()!=0 && pBbarJet->E()!=0){ EventIsGood = 1; *pRekoTop = (*pRekoLeptonPlus) + (*pBJet) + (*pRekoNu); *pRekoAntiTop = (*pRekoLeptonMinus) + (*pBbarJet) + (*pRekoAntiNu); *pRekoTTbar = (*pRekoTop) + (*pRekoAntiTop); *pRekoTopBoosted = *pRekoTop; *pRekoAntiTopBoosted = *pRekoAntiTop; *pRekoLeptonPlusBoosted = *pRekoLeptonPlus; *pRekoLeptonMinusBoosted = *pRekoLeptonMinus; pRekoAntiTopBoosted->Boost(-pRekoTTbar->BoostVector()); pRekoTopBoosted->Boost(-pRekoTTbar->BoostVector()); pRekoLeptonPlusBoosted->Boost(-pRekoTop->BoostVector()); pRekoLeptonMinusBoosted->Boost(-pRekoAntiTop->BoostVector()); RekoCosThetaPlus = cos(pRekoLeptonPlusBoosted->Angle(pRekoTopBoosted->Vect())); RekoCosThetaMinus = cos(pRekoLeptonMinusBoosted->Angle(pRekoAntiTopBoosted->Vect())); //cout << "Cos(Theta) Gen-Reko: " << CosThetaPlus - RekoCosThetaPlus << endl; CosThetaDiff = RekoCosThetaPlus - CosThetaPlus; CosRekoLeptonAngleD = cos(pRekoLeptonPlusBoosted->Angle(pRekoLeptonMinusBoosted->Vect())); RekoTTbar_Pt = pRekoTTbar->Pt(); RekoTTbar_M = pRekoTTbar->M(); RekoTop_Pt = pRekoTop->Pt(); RekoAntiTop_Pt = pRekoAntiTop->Pt(); RekoTop_M = pRekoTop->M(); RekoAntiTop_M = pRekoAntiTop->M(); histogram__A->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); histogram__Correlation->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__CosThetaDiff->Fill( CosThetaPlus - RekoCosThetaPlus ); histogram__CosThetaDiff->Fill( CosThetaMinus - RekoCosThetaMinus ); histogram__CosTheta_GenReko->Fill(CosThetaPlus, RekoCosThetaPlus); histogram__CosThetaDiff_TTbarPt->Fill(pTTbar->Pt(), CosThetaPlus - RekoCosThetaPlus); if(BJet_Tag_TrkCount > 1.0){ histogram__Correlation_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pRekoLeptonPlus->Pt()>15 && pRekoLeptonMinus->Pt()>15 && pBJet->Et()>50 && pBbarJet->Et()>50 && PatJetsBTag_TrkCount[BTagTrkCountIndex[1]]>1 ){ histogram__Correlation_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pRekoLeptonPlus->Pt()>20 && pRekoLeptonMinus->Pt()>20){ histogram__Correlation_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); if(pBJet->Et() > 30 && pBbarJet->Et() > 30 && PatJetsBTag_TrkCount[BTagTrkCountIndex[1]] > 1){ histogram__Correlation_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pBJet->Et() > 40 && pBbarJet->Et() > 40){ histogram__Correlation_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); if(PatJetsBTag_TrkCount[BTagTrkCountIndex[1]] > 1 ){ histogram__Correlation_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } } } } // Leptonen und B != 0 } // Neutrino-Pz != -10000 } // inv. Masse der Leptonen != Z-Masse+-10 }// abfrage auf 2 Leptonen unterschiedlicher Ladung //cout << "Tree wird gefuellt: "; //cout << " und ist fertig" << endl; } outTree->Fill(); } // EventLoop cout << "gezaehlte Ereignisse: " << EventCounter << endl; cout << "Rekonstruierte Ereignisse: " << histogram__Correlation->Integral() << endl; outputFile->cd(""); outputFile->Write(); outputFile->Close(); delete outputFile; }
void whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { switch (activeTool) { case TOOL_RUBBER: Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius); break; case TOOL_PEN: Line(hdc, last.x, last.y, x, y, bg, 1); break; case TOOL_BRUSH: Brush(hdc, last.x, last.y, x, y, bg, brushStyle); break; case TOOL_AIRBRUSH: Airbrush(hdc, x, y, bg, airBrushWidth); break; case TOOL_LINE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) roundTo8Directions(start.x, start.y, &x, &y); Line(hdc, start.x, start.y, x, y, bg, lineWidth); break; case TOOL_BEZIER: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; switch (pointSP) { case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg, lineWidth); break; case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], bg, lineWidth); break; case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], bg, lineWidth); break; } break; case TOOL_RECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; case TOOL_SHAPE: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, &pointStack[pointSP].x, &pointStack[pointSP].y); if (pointSP + 1 >= 2) Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE); break; case TOOL_ELLIPSE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; case TOOL_RRECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; } last.x = x; last.y = y; }
int main(void) { PolyInfrastructure pi; Poly f1, f2, f3, f4; vector<string> wuvar; vector<Poly> wupoly; Poly wuconc; WuMethod wm = WuMethod(); vector <string> var_names; cout << "/*** Q1 ***/" << endl; var_names.clear(); var_names.push_back("a"); var_names.push_back("b"); var_names.push_back("c"); var_names.push_back("d"); var_names.push_back("e"); pi = PolyInfrastructure(var_names); f1 = Poly(&pi); f1 = f1 + MonoPoly(&pi, "e", 1, 1.0) + MonoPoly(&pi, "a", 1, -2.0); f2 = Poly(&pi); f2 = f2 + MonoPoly(&pi, "a", 1, 2.0) + MonoPoly(&pi, "b", 1, -1.0) - MonoPoly(&pi, "d", 1, -1.0); wuconc = Poly(&pi); wuconc = wuconc + calcSQ(calcMP(&pi, "a") - calcMP(&pi, "b")) - calcSQ(calcMP(&pi, "a") - calcMP(&pi, "d")); wuvar.clear(); wuvar.push_back("a"); wuvar.push_back("b"); wupoly.clear(); wupoly.push_back(f1); wupoly.push_back(f2); wm = WuMethod(&pi, wuvar, wupoly, wuconc); wm.Print(); cout << (wm.Run() ? "TRUE" : "FALSE") << endl; cout << "/*** Q2 ***/" << endl; var_names.clear(); var_names.push_back("a"); var_names.push_back("b"); var_names.push_back("c"); var_names.push_back("d"); var_names.push_back("e"); pi = PolyInfrastructure(var_names); f1 = Poly(&pi); f1 = f1 + MonoPoly(&pi, "e", 1, 1.0) + MonoPoly(&pi, "a", 1, -2.0); f2 = Poly(&pi); f2 = f2 + MonoPoly(&pi, "d", 1, 1.0) + MonoPoly(&pi, "b", 1, -1.0); wuconc = Poly(&pi); wuconc = wuconc + calcSQ(calcMP(&pi, "a") - calcMP(&pi, "b")) - calcSQ(calcMP(&pi, "a") - calcMP(&pi, "d")); wuvar.clear(); wuvar.push_back("a"); wuvar.push_back("b"); wupoly.clear(); wupoly.push_back(f1); wupoly.push_back(f2); wm = WuMethod(&pi, wuvar, wupoly, wuconc); wm.Print(); cout << (wm.Run() ? "TRUE" : "FALSE") << endl; return 0; }
void whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { switch (activeTool) { case TOOL_FREESEL: if (ptSP == 0) newReversible(); ptSP++; if (ptSP % 1024 == 0) ptStack = HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, ptStack, sizeof(POINT) * (ptSP + 1024)); ptStack[ptSP].x = max(0, min(x, imgXRes)); ptStack[ptSP].y = max(0, min(y, imgYRes)); resetToU1(); Poly(hdc, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE); break; case TOOL_RECTSEL: { POINT temp; resetToU1(); temp.x = max(0, min(x, imgXRes)); temp.y = max(0, min(y, imgYRes)); rectSel_dest[0] = rectSel_src[0] = min(start.x, temp.x); rectSel_dest[1] = rectSel_src[1] = min(start.y, temp.y); rectSel_dest[2] = rectSel_src[2] = max(start.x, temp.x) - min(start.x, temp.x); rectSel_dest[3] = rectSel_src[3] = max(start.y, temp.y) - min(start.y, temp.y); RectSel(hdc, start.x, start.y, temp.x, temp.y); break; } case TOOL_RUBBER: Erase(hdc, last.x, last.y, x, y, bg, rubberRadius); break; case TOOL_PEN: Line(hdc, last.x, last.y, x, y, fg, 1); break; case TOOL_BRUSH: Brush(hdc, last.x, last.y, x, y, fg, brushStyle); break; case TOOL_AIRBRUSH: Airbrush(hdc, x, y, fg, airBrushWidth); break; case TOOL_LINE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) roundTo8Directions(start.x, start.y, &x, &y); Line(hdc, start.x, start.y, x, y, fg, lineWidth); break; case TOOL_BEZIER: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; switch (pointSP) { case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg, lineWidth); break; case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth); break; case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth); break; } break; case TOOL_RECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; case TOOL_SHAPE: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, &pointStack[pointSP].x, &pointStack[pointSP].y); if (pointSP + 1 >= 2) Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE); break; case TOOL_ELLIPSE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; case TOOL_RRECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle); break; } last.x = x; last.y = y; }
// Convert to Printlines void Layer::MakePrintlines(Vector3d &lastPos, //GCodeState &state, vector<PLine3> &lines3, double offsetZ, Settings &settings) const { const double linewidth = settings.GetExtrudedMaterialWidth(thickness); const double cornerradius = linewidth*settings.get_double("Slicing","CornerRadius"); const bool clipnearest = settings.get_boolean("Slicing","MoveNearest"); const uint supportExtruder = settings.GetSupportExtruder(); const double minshelltime = settings.get_double("Slicing","MinShelltime"); const double maxshellspeed = settings.get_double("Extruder","MaxShellSpeed"); const bool ZliftAlways = settings.get_boolean("Extruder","ZliftAlways"); Vector2d startPoint(lastPos.x(),lastPos.y()); const double extr_per_mm = settings.GetExtrusionPerMM(thickness); //vector<PLine3> lines3; Printlines printlines(this, &settings, offsetZ); vector<PLine2> lines; vector<Poly> polys; // intermediate collection // polys to keep line movements inside //const vector<Poly> * clippolys = &polygons; const vector<Poly> * clippolys = GetOuterShell(); // 1. Skins, all but last, because they are the lowest lines, below layer Z if (skins > 1) { for(uint s = 0; s < skins; s++) { // z offset from bottom to top: double skin_z = Z - thickness + (s+1)*thickness/skins; if ( skin_z < 0 ){ cerr << "Skin Z<0! " << s << " -- " << Z << " -- "<<skin_z <<" -- " << thickness << endl; continue; } // skin infill polys: if (skinFullInfills[s]) polys.insert(polys.end(), skinFullInfills[s]->infillpolys.begin(), skinFullInfills[s]->infillpolys.end()); // add skin infill to lines printlines.addPolys(INFILL, polys, false); polys.clear(); // make polygons at skin_z: for(size_t p = 0; p < skinPolygons.size(); p++) { polys.push_back(Poly(skinPolygons[p], skin_z)); } // add skin to lines printlines.addPolys(SKIN, polys, (s==0), // displace at first skin maxshellspeed * 60, minshelltime); if (s < skins-1) { // not on the last layer, this handle with all other lines // have to get all these separately because z changes printlines.makeLines(startPoint, lines); if (!ZliftAlways) printlines.clipMovements(*clippolys, lines, clipnearest, linewidth); printlines.optimize(linewidth, minshelltime, cornerradius, lines); printlines.getLines(lines, lines3, extr_per_mm); printlines.clear(); lines.clear(); } polys.clear(); } } // last skin layer now still in lines lines.clear(); // 2. Skirt printlines.addPolys(SKIRT, skirtPolygons, false, maxshellspeed * 60, minshelltime); // 3. Support if (supportInfill) { uint extruderbefore = settings.selectedExtruder; settings.SelectExtruder(supportExtruder); printlines.addPolys(SUPPORT, supportInfill->infillpolys, false); settings.SelectExtruder(extruderbefore); } // 4. all other polygons: // Shells for(int p=shellPolygons.size()-1; p>=0; p--) { // inner to outer printlines.addPolys(SHELL, shellPolygons[p], (p==(int)(shellPolygons.size())-1), maxshellspeed * 60, minshelltime); } // Infill if (normalInfill) printlines.addPolys(INFILL, normalInfill->infillpolys, false); if (thinInfill) printlines.addPolys(INFILL, thinInfill->infillpolys, false); if (fullInfill) printlines.addPolys(INFILL, fullInfill->infillpolys, false); if (skirtInfill) printlines.addPolys(INFILL, skirtInfill->infillpolys, false); if (decorInfill) printlines.addPolys(INFILL, decorInfill->infillpolys, false); for (uint b=0; b < bridgeInfills.size(); b++) if (bridgeInfills[b]) printlines.addPolys(INFILL, bridgeInfills[b]->infillpolys, false); double polyspeedfactor = printlines.makeLines(startPoint, lines); // FINISH Command lchange(LAYERCHANGE, LayerNo); lchange.where = Vector3d(0.,0.,Z); lchange.comment += info(); lines3.push_back(PLine3(lchange)); if (!ZliftAlways) printlines.clipMovements(*clippolys, lines, clipnearest, linewidth); printlines.optimize(linewidth, settings.get_double("Slicing","MinLayertime"), cornerradius, lines); if ((guint)LayerNo < (guint)settings.get_integer("Slicing","FirstLayersNum")) printlines.setSpeedFactor(settings.get_double("Slicing","FirstLayersSpeed"), lines); double slowdownfactor = printlines.getSlowdownFactor() * polyspeedfactor; if (settings.get_boolean("Slicing","FanControl")) { int fanspeed = settings.get_integer("Slicing","MinFanSpeed"); if (slowdownfactor < 1 && slowdownfactor > 0) { double fanfactor = 1-slowdownfactor; fanspeed += int(fanfactor * (settings.get_integer("Slicing","MaxFanSpeed")-settings.get_integer("Slicing","MinFanSpeed"))); fanspeed = CLAMP(fanspeed, settings.get_integer("Slicing","MinFanSpeed"), settings.get_integer("Slicing","MaxFanSpeed")); //cerr << slowdownfactor << " - " << fanfactor << " - " << fanspeed << " - " << endl; } Command fancommand(FANON, fanspeed); lines3.push_back(PLine3(fancommand)); } printlines.getLines(lines, lines3, extr_per_mm); if (lines3.size()>0) lastPos = lines3.back().to; }
void startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { start.x = x; start.y = y; last.x = x; last.y = y; switch (activeTool) { case TOOL_FREESEL: ShowWindow(hSelection, SW_HIDE); if (ptStack != NULL) HeapFree(GetProcessHeap(), 0, ptStack); ptStack = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * 1024); ptSP = 0; ptStack[0].x = x; ptStack[0].y = y; break; case TOOL_TEXT: case TOOL_LINE: case TOOL_RECT: case TOOL_ELLIPSE: case TOOL_RRECT: newReversible(); break; case TOOL_RECTSEL: newReversible(); ShowWindow(hSelection, SW_HIDE); rectSel_src[2] = rectSel_src[3] = 0; break; case TOOL_RUBBER: newReversible(); Erase(hdc, x, y, x, y, bg, rubberRadius); break; case TOOL_FILL: newReversible(); Fill(hdc, x, y, fg); break; case TOOL_PEN: newReversible(); SetPixel(hdc, x, y, fg); break; case TOOL_BRUSH: newReversible(); Brush(hdc, x, y, x, y, fg, brushStyle); break; case TOOL_AIRBRUSH: newReversible(); Airbrush(hdc, x, y, fg, airBrushWidth); break; case TOOL_BEZIER: pointStack[pointSP].x = x; pointStack[pointSP].y = y; if (pointSP == 0) { newReversible(); pointSP++; } break; case TOOL_SHAPE: pointStack[pointSP].x = x; pointStack[pointSP].y = y; if (pointSP + 1 >= 2) Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE); if (pointSP == 0) { newReversible(); pointSP++; } break; } }
void endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) { switch (activeTool) { case TOOL_RUBBER: Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius); break; case TOOL_PEN: Line(hdc, last.x, last.y, x, y, bg, 1); SetPixel(hdc, x, y, bg); break; case TOOL_LINE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) roundTo8Directions(start.x, start.y, &x, &y); Line(hdc, start.x, start.y, x, y, bg, lineWidth); break; case TOOL_BEZIER: pointSP++; if (pointSP == 4) pointSP = 0; break; case TOOL_RECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; case TOOL_SHAPE: resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, &pointStack[pointSP].x, &pointStack[pointSP].y); pointSP++; if (pointSP >= 2) { if ((pointStack[0].x - x) * (pointStack[0].x - x) + (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1) { Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE); pointSP = 0; } else { Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE); } } if (pointSP == 255) pointSP--; break; case TOOL_ELLIPSE: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; case TOOL_RRECT: resetToU1(); if (GetAsyncKeyState(VK_SHIFT) < 0) regularize(start.x, start.y, &x, &y); RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle); break; } }