Ejemplo n.º 1
0
main() {
   Model m;
   FP1 f;
   assert(!f);
   f = 0; assert(!f);
   f = functor(&m, &Model::enter1);
   assert(f);
   FP1 f2;
   f = f2; assert(f==0);
   f = functor(&m, &Model::enter1); assert(f);
   f = functor((Model*)0, &Model::enter1); assert(!f);
   f = functor(&m, (int(Model::*)(const char*))0); assert(!f);
   f = functor(&m, &Model::enter1); assert(f);
   f = functor((Model*)0, (int(Model::*)(const char*))0); assert(!f);
   FP1 f3(0);
   assert(!f3);
   View v(functor(&m, &Model::enter1), functorv(&m, &Model::enter2),
         functor(&m, &Model::save1), functorv(&m, &Model::save2),
         functor(&m, &Model::enterat1), functorv(&m, &Model::enterat2));
   v.input();
   View vz(FP1(0), FP2(0), FP3(0), FP4(0), FP5(0), FP6(0));
   vz.input();

   f3 = f2;
   FP1 f4 = f3;
   if (!f4) f4=functor(&m, &Model::enter1);
   cout << f4("Hello");

   return 0;
}
Ejemplo n.º 2
0
int main(void) {
	int a,b=1;
	vz(b);
	while(scanf("%d%d",&a,&b)!=EOF) {
		printf("%d\n",a+b);
	}
	return 0;
}
Ejemplo n.º 3
0
const bool R3Matrix::HasMirror(void) const
{
    // Return whether matrix matrix has mirror operator
    R3Vector vx(m[0][0], m[1][0], m[2][0]);
    R3Vector vy(m[0][1], m[1][1], m[2][1]);
    R3Vector vz(m[0][2], m[1][2], m[2][2]);
    return (vz.Dot(vx % vy) < 0);
}
Ejemplo n.º 4
0
// Changed from setVelocity: by inamura on 2013-12-30
void SimObjBase::setLinearVelocity(double vx_,double vy_,double vz_)
{
	// Set is not permitted in dynamics on mode
	if (!dynamics()) { return; }
	vx(vx_);
	vy(vy_);
	vz(vz_);
}
Ejemplo n.º 5
0
const RNBoolean R4Matrix::
HasMirror(void) const
{
    // Return whether matrix transformation has mirror operator
    R3Vector vx(m[0][0], m[1][0], m[2][0]);
    R3Vector vy(m[0][1], m[1][1], m[2][1]);
    R3Vector vz(m[0][2], m[1][2], m[2][2]);
    return RNIsNegative(vz.Dot(vx % vy));
}
Ejemplo n.º 6
0
Eigen::Matrix<T,4,1> rotate_to_xy(Eigen::Matrix<T,4,1> norm, 
				  Eigen::Matrix<T,4,1> cen, 
				  Eigen::Matrix<T,4,1> vec){
  Eigen::Matrix<T,4,1> vz(0,0,1);
  norm.normalize();
  Eigen::Matrix<T,4,1> xe = cross(norm,vz).normalize();
  T r1 = norm.mag();
  T o = acos(dot(vz,norm)/r1);
  Eigen::Quaternion<T> dq(cos(o/2.), sin(o/2.)*xe[0], sin(o/2.)*xe[1], sin(o/2.)*xe[2]);	
  Eigen::Matrix<T,4,1> c = dq.rotate(vec - cen);
  return c;
}
Ejemplo n.º 7
0
Vector<Real, STATE_NF> State::vector_z_flux(const _3Vec& X, const _3Vec& V) const {
	Vector<Real, STATE_NF> flux = 0.0;
	Real v, v0, p;
	v = vz(X);
	v0 = v - V[2];
	p = pg(X);
	for (int i = 0; i < STATE_NF; i++) {
		flux[i] = (*this)[i] * v0;
	}
	flux[sz_index] += p;
	flux[et_index] += v * p;
	return flux;
}
Ejemplo n.º 8
0
// [[Rcpp::export]]
Rcpp::List worstcase_l1(Rcpp::NumericVector z, Rcpp::NumericVector q, double t){
    // resulting probability
    craam::numvec p;
    // resulting objective value
    double objective;

    craam::numvec vz(z.begin(), z.end()), vq(q.begin(), q.end());
    std::tie(p,objective) = craam::worstcase_l1(vz,vq,t);

    Rcpp::List result;
    result["p"] = Rcpp::NumericVector(p.cbegin(), p.cend());
    result["obj"] = objective;

    return result;
}
Ejemplo n.º 9
0
void TestStelSphericalGeometry::testPlaneIntersect2()
{
	Vec3d p1,p2;
	Vec3d vx(1,0,0);
	Vec3d vz(0,0,1);
	SphericalCap hx(vx, 0);
	SphericalCap hz(vz, 0);
	QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane intersect failed");
	QVERIFY(p1==Vec3d(0,-1,0));
	QVERIFY(p2==Vec3d(0,1,0));
	QVERIFY2(SphericalCap::intersectionPoints(hx, hx, p1, p2)==false, "Plane non-intersecting failure");

	hx.d = std::sqrt(2.)/2.;
	QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane/convex intersect failed");
	Vec3d res(p1-Vec3d(hx.d,-hx.d,0));
	QVERIFY2(res.length()<0.0000001, QString("p1 wrong: %1").arg(p1.toString()).toUtf8());
	res = p2-Vec3d(hx.d,hx.d,0);
	QVERIFY2(res.length()<0.0000001, QString("p2 wrong: %1").arg(p2.toString()).toUtf8());
}
Ejemplo n.º 10
0
uint8_t ADMVideoMosaic::configure(AVDMGenericVideoStream * instream)
{
    UNUSED_ARG(instream);

#define PX(x) &(_param->x)
        
    diaElemUInteger   hz(PX(hz),QT_TR_NOOP("_Horizontal stacking:"),0,10);
    diaElemUInteger   vz(PX(vz),QT_TR_NOOP("_Vertical stacking:"),0,10);
    diaElemUInteger   shrink(PX(shrink),QT_TR_NOOP("_Shrink factor:"),0,10);
    diaElemToggle     show(PX(show),QT_TR_NOOP("Show _frame"));
    
    
       diaElem *elems[]={&hz,&vz,&shrink,&show};
  
   if(  diaFactoryRun(QT_TR_NOOP("Mosaic"),sizeof(elems)/sizeof(diaElem *),elems))
   {
        reset();
        return 1;
    }
    return 0;

}
Ejemplo n.º 11
0
  void System::Problem_generate_IC(const int param)
  {
    if (thisIndex == 0)
    {
      CkPrintf(" ********* Cloud capture ************* \n");
      CkPrintf(" **** MAGNETISATION=%g     \n", MAGNETISATION);
      CkPrintf(" **** H/R          =%g     \n", HoR  );
      CkPrintf(" **** GRAVITY_MASS= %g     \n", GM);
      CkPrintf(" **** GRAVITY_EPS=  %g     \n", GM_EPS);
      CkPrintf(" ---  \n");	
    }

    gamma_gas  = 1.0;
    courant_no = 0.8;

    t_global  = 0;
    iteration = 0;

    const real xcl = XCL;
    const real ycl = YCL;

    const real vx_cl = VX0/VUNIT;
    const real vy_cl = VY0/VUNIT;

    const real vorb  = std::sqrt(sqr(vx_cl) + sqr(vy_cl));
    const real Rinit = std::sqrt(sqr(xcl)   + sqr(ycl)  );

    const real tinfall = Rinit/vorb;

    const real dcl = (DCLOUD/DUNIT);
    const real cs2 = get_cs2(vec3(xcl, ycl, 0.0)); //TCLOUD*Tunit/sqr(vunit);

    if (thisIndex == 0)
    {
      CkPrintf("Ro= %g pc, x= %g  y= %g; vx= %g vy= %g vt= %g  tinfall= %g Myr [%g]\n",
          Rinit,
          xcl, ycl,
          vx_cl, vy_cl,
          vorb,
          tinfall * TIMEUNIT, tinfall);
    }


    for (int i = 0; i < local_n; i++) 
    {
      const Particle &pi = ptcl_list[i];

      const vec3 &pos = pi.get_pos();

      if (pos.abs() < BND_RADIUS || pos.abs() > RoutBND)
        mesh_pnts[i].boundary = MeshPoint::DIOD;
      else  
        mesh_pnts[i].boundary = MeshPoint::NO_BOUNDARY;

      const real Rdist = (pos - vec3(xcl, ycl, 0.0)).abs();
      const real inv_beta = MAGNETISATION;

      real dens = dcl;
      real pres = dcl * cs2;
      real b0   = std::sqrt(2.0*pres * inv_beta);

      real bx(0), by(0), bz(0);

#if 0
      bx = by = b0/sqrt(2.0);
#else
      bx = by = bz = b0/sqrt(3.0);
#endif

      real vx(vx_cl), vy(vy_cl), vz(0.0);

      real scalar = 1.0;
      if (Rdist > RCLOUD)
      {
        dens = DENSvac/DUNIT;
        const real csig = std::sqrt(get_cs2(pos));
        vx = (1 - 2.0*drand48()) * csig;
        vy = (1 - 2.0*drand48()) * csig;
        vz = (1 - 2.0*drand48()) * csig;
        scalar = -1.0;
      }
      Fluid m;

      m[Fluid::DENS] = dens;
      m[Fluid::ETHM] = get_cs2(pos)*dens;
      m[Fluid::VELX] = vx;
      m[Fluid::VELY] = vy;
      m[Fluid::VELZ] = vz;
      m[Fluid::BX  ] = bx;
      m[Fluid::BY  ] = by;
      m[Fluid::BZ  ] = bz;
      m[Fluid::PSI ] = 0.0;
      m[Fluid::ENTR] = 1.0;

      Wrec_list[i] = Fluid_rec(m);

      mesh_pnts[i].idx  = thisIndex*1000000 + i+1;

    }
  }
Ejemplo n.º 12
0
Archivo: VEF.cpp Proyecto: Raegon/MARS
// we use a tree architecture to build the subzones
int VEF::divideIntoZones(Zone z, int nbZones){

    TreeZone tz(z);
    TreeZone *father;
    int flag, flag2, depth; // used to determine the cutting axis
    flag = flag2 = depth = 0;
    Vertex bottom, middle_bottom, middle_top, top;
    bottom = middle_bottom = z.getZoneBottomVertex();
    top = middle_top = z.getZoneTopVertex();
    int id = 0;
    int rootFlag = 0;

    std::vector<TreeZone> parents; // store the parent trees relative to the one we manipulate

    for (int i = 0; i < nbZones; i++){
        if (!(i % 2)){
            if (flag % 3 == 0) // we cut along the x axis
            {
                Vertex vx(middle_top.getX() - (middle_top.getX() / 2), middle_top.getY(), middle_top.getZ());
                Zone zl(bottom, vx, -1);
                TreeZone *l = new TreeZone(zl);

                tz.addLeftChild(l);
                //top.setX(vx.getX());
                middle_top = vx;
            }

            if (flag % 3 == 1) // we cut along the y axis
            {
                Vertex vy(middle_top.getX(), middle_top.getY() - middle_top.getY() / 2, middle_top.getZ());
                Zone zl(bottom, vy, -1);
                TreeZone *l = new TreeZone(zl);

                tz.addLeftChild(l);
                //top.setY(vy.getY());
                middle_top = vy;
            }

            if (flag % 3 == 2) // we cut along the z axis
            {
                Vertex vz(middle_top.getX(), middle_top.getY(), middle_top.getZ() - middle_top.getZ() / 2);
                Zone zl(bottom, vz, -1);
                TreeZone *l = new TreeZone(zl);

                tz.addLeftChild(l);
                //top.setZ(vz.getZ());
                middle_top = vz;
            }
        }
        else
        {
            if (flag2 % 3 == 0) // we cut along the x axis
            {
                Vertex vx(middle_bottom.getX() + (middle_bottom.getX() / 2), middle_bottom.getY(), middle_bottom.getZ());
                Zone zr(vx, top, -1);
                TreeZone *r = new TreeZone(zr);

                tz.addRightChild(r);
                middle_bottom = vx;
            }

            if (flag2 % 3 == 1) // we cut along the y axis
            {
                Vertex vy(middle_bottom.getX(), middle_bottom.getY() + (middle_bottom.getY() / 2), middle_bottom.getZ());
                Zone zr(vy, top, -1);
                TreeZone *r = new TreeZone(zr);

                tz.addRightChild(r);
                middle_bottom = vy;
            }

            if (flag2 % 3 == 2) // we cut along the z axis
            {
                Vertex vz(middle_bottom.getX(), middle_bottom.getY(), middle_bottom.getZ() + (middle_bottom.getZ() / 2));
                Zone zr(vz, top, -1);
                TreeZone *r = new TreeZone(zr);

                tz.addRightChild(r);
            }

            if (depth){
                if (!(*(father->getRightChild()) == tz))
                {
                    if (father->getRightChild()->getLeftChild() == NULL)
                    { // the brother of t doesn't exist yet
                        tz = *(father->getRightChild());
                        father = &(parents.back());
                        parents.pop_back();
                    }
                }
            }

            parents.push_back(*father);
            father = &tz;
            tz = *(tz.getLeftChild());
            depth++;

        }
    }

    // depth-first search to add the zones we created (the leaves) into the zone vector
    while (tz.hasLeftChild()){
        father = &tz;
        tz = *(tz.getLeftChild());
    }

    tz.getRoot().setZoneId(id);
    m_zones.push_back(tz.getRoot());
    id++;

    // we stop when we reach the root for the second time, i.e, when all the leaves have been found
    /*while(rootFlag != 1){
        if (father->hasRightChild()){
            father->getRightChild()->getRoot().setZoneId(id);
            m_zones.push_back(father->getRightChild()->getRoot());
        }

        tz = father;
        if (depth){
            father = parents.back();
            parents.pop_back();
        }
        depth--;
    }*/


    return 0;
}
Ejemplo n.º 13
0
void buildtupledata(TString code)//(TString collision = "PbPbBJet", TString jetalgo = "akVs4PFJetAnalyzer")
{
  if (!dt(code)) { cout<<"Not data: "<<code<<", exiting..."<<endl; return;}
  
  bool PbPb = isPbPb(code);
  TString sample = getSample(code);
  jettree = getjettree(code);
  subTag = subTagging(code);

  Init(PbPb, sample);

  TString outputfilenamedj = outputfolder+"/"+code+"_djt.root";
  TString outputfilenameinc = outputfolder+"/"+code+"_inc.root";
  TString outputfilenameevt = outputfolder+"/"+code+"_evt.root";

  TString djvars = TString("run:lumi:event:prew:triggermatched:bin:vz:hiHF:hltCSV60:hltCSV80:hltCaloJet40:hltCaloJet60:hltCaloJet80:hltPFJet60:hltPFJet80:dijet:")+
      "hltCalo60jtpt:hltCalo60jtphi:hltCalo60jteta:hltCalo80jtpt:hltCalo80jtphi:hltCalo80jteta:hltCSV60jtpt:hltCSV60jtphi:hltCSV60jteta:hltCSV80jtpt:hltCSV80jtphi:hltCSV80jteta:"+
      "rawpt1:jtpt1:jtphi1:jteta1:discr_csvV1_1:svtxm1:discr_prob1:svtxdls1:svtxpt1:svtxntrk1:nsvtx1:nselIPtrk1:"+
      "rawpt2:jtpt2:jtphi2:jteta2:discr_csvV1_2:svtxm2:discr_prob2:svtxdls2:svtxpt2:svtxntrk2:nsvtx2:nselIPtrk2:dphi21:"+
      "rawpt3:jtpt3:jtphi3:jteta3:discr_csvV1_3:svtxm3:discr_prob3:svtxdls3:svtxpt3:svtxntrk3:nsvtx3:nselIPtrk3:dphi31:dphi32:"+
      "SLord:rawptSL:jtptSL:jtphiSL:jtetaSL:discr_csvV1_SL:svtxmSL:discr_probSL:svtxdlsSL:svtxptSL:svtxntrkSL:nsvtxSL:nselIPtrkSL:dphiSL1";





  for (auto w:weights) cout<<w<<"\t";
  cout<<endl;

  int totentries = 0;

  //now fill histos
  TFile *foutdj = new TFile(outputfilenamedj,"recreate");
  TNtuple *ntdj = new TNtuple("nt","ntdj",djvars);

  TFile *foutinc = new TFile(outputfilenameinc,"recreate");
  TNtuple *ntinc = new TNtuple("nt","ntinc","prew:goodevent:bin:vz:hiHF:hltCSV60:hltCSV80:hltCaloJet40:hltCaloJet60:hltCaloJet80:hltPFJet60:hltPFJet80:rawpt:jtpt:jtphi:jteta:discr_csvV1:svtxm:discr_prob:svtxdls:svtxpt:svtxntrk:nsvtx:nselIPtrk");
  TFile *foutevt = new TFile(outputfilenameevt,"recreate");
  TNtuple *ntevt = new TNtuple("nt","ntinc","prew:bin:vz:hiHF:hltCSV60:hltCSV80");
  
  for (unsigned i=0;i<subfoldernames.size();i++) {
    //get all files for unmerged forests
    auto files = list_files(TString::Format("%s/%s/",samplesfolder.Data(),subfoldernames[i].Data()));

    for (auto filename:files) {
    cout<<endl<<"Processing file "<<filename<<endl;

    TFile *f = new TFile(filename);
    TString treename = jettree;//f->Get(jettree) != 0 ? jettree : "ak3PFJetAnalyzer";
    TTreeReader reader(treename,f);
    TTreeReaderValue<int> nref(reader, "nref");
    TTreeReaderArray<float> rawpt(reader, "rawpt");
    TTreeReaderArray<float> jtpt(reader, "jtpt");
    TTreeReaderArray<float> jteta(reader, "jteta");
    TTreeReaderArray<float> jtphi(reader, "jtphi");
    TTreeReaderArray<float> discr_csvV1(reader, "discr_csvV1");

    TTreeReaderArray<float> discr_prob(reader, "discr_prob");
    TTreeReaderArray<float> svtxm(reader, "svtxm");
    TTreeReaderArray<float> svtxdls(reader, "svtxdls");
    TTreeReaderArray<float> svtxpt(reader, "svtxpt");

    TTreeReaderArray<int> svtxntrk(reader, "svtxntrk");
    TTreeReaderArray<int> nsvtx(reader, "nsvtx");
    TTreeReaderArray<int> nselIPtrk(reader, "nselIPtrk");

    TTreeReaderArray<float> *muMax=0, *muMaxTRK=0, *muMaxGBL=0;
    if (PbPb) {
      muMax = new TTreeReaderArray<float> (reader, "muMax");
      muMaxTRK = new TTreeReaderArray<float>(reader, "muMaxTRK");
      muMaxGBL = new TTreeReaderArray<float>(reader, "muMaxGBL");
    }


    //HLT_HIPuAK4CaloBJetCSV80_Eta2p1_v1 HLT_HIPuAK4CaloJet80_Eta5p1_v1

    TString calojet40trigger = !PbPb ? "HLT_AK4CaloJet40_Eta5p1_v1" : "HLT_HIPuAK4CaloJet40_Eta5p1_v1";
    TString calojet40triggerv2 = !PbPb ? "HLT_AK4CaloJet40_Eta5p1_v1" : "HLT_HIPuAK4CaloJet40_Eta5p1_v2";
    TString calojet60trigger = !PbPb ? "HLT_AK4CaloJet60_Eta5p1_v1" : "HLT_HIPuAK4CaloJet60_Eta5p1_v1";
    TString calojet80trigger = !PbPb ? "HLT_AK4CaloJet80_Eta5p1_v1" : "HLT_HIPuAK4CaloJet80_Eta5p1_v1";
    //dummy vars in PbPb case
    TString pfjet60trigger = !PbPb ? "HLT_AK4PFJet60_Eta5p1_v1" : "LumiBlock";
    TString pfjet80trigger = !PbPb ? "HLT_AK4PFJet80_Eta5p1_v1" : "LumiBlock";
    TString csv60trigger = !PbPb ? "HLT_AK4PFBJetBCSV60_Eta2p1_v1"  : "HLT_HIPuAK4CaloBJetCSV60_Eta2p1_v1";
    TString csv80trigger = !PbPb ? "HLT_AK4PFBJetBCSV80_Eta2p1_v1"  : "HLT_HIPuAK4CaloBJetCSV80_Eta2p1_v1";

    //PbPb pprimaryVertexFilter && pclusterCompatibilityFilter do nothing
    vector<TString> filterNames;
    if (PbPb) filterNames = {"pcollisionEventSelection", "HBHENoiseFilterResultRun2Loose"};
    else filterNames = {"pPAprimaryVertexFilter", "HBHENoiseFilterResultRun2Loose", "pBeamScrapingFilter"}; 

    TTreeReader readerhlt("hltanalysis/HltTree",f);
    TTreeReaderValue<int> PFJet60(readerhlt, pfjet60trigger);
    TTreeReaderValue<int> PFJet80(readerhlt, pfjet80trigger);


    TTreeReaderValue<int> CaloJet40(readerhlt, calojet40trigger);
    TTreeReaderValue<int> CaloJet40v2(readerhlt, calojet40triggerv2);
    TTreeReaderValue<int> CaloJet60(readerhlt, calojet60trigger);
    TTreeReaderValue<int> CaloJet80(readerhlt, calojet80trigger);

    TTreeReaderValue<int> CSV60(readerhlt, csv60trigger);
    TTreeReaderValue<int> CSV80(readerhlt, csv80trigger);

    TTreeReader readercsv60object("hltobject/HLT_HIPuAK4CaloBJetCSV60_Eta2p1_v",f);
    TTreeReaderValue<vector<Double_t> > csv60pt(readercsv60object, "pt");
    TTreeReaderValue<vector<Double_t> > csv60eta(readercsv60object, "eta");
    TTreeReaderValue<vector<Double_t> > csv60phi(readercsv60object, "phi");
    
    TTreeReader readercsv80object("hltobject/HLT_HIPuAK4CaloBJetCSV80_Eta2p1_v",f);
    TTreeReaderValue<vector<Double_t> > csv80pt(readercsv80object, "pt");
    TTreeReaderValue<vector<Double_t> > csv80eta(readercsv80object, "eta");
    TTreeReaderValue<vector<Double_t> > csv80phi(readercsv80object, "phi");
    
    TTreeReader readerCalo60object("hltobject/HLT_HIPuAK4CaloJet60_Eta5p1_v",f);
    TTreeReaderValue<vector<Double_t> > calo60pt(readerCalo60object, "pt");
    TTreeReaderValue<vector<Double_t> > calo60eta(readerCalo60object, "eta");
    TTreeReaderValue<vector<Double_t> > calo60phi(readerCalo60object, "phi");
    
    TTreeReader readerCalo80object("hltobject/HLT_HIPuAK4CaloJet80_Eta5p1_v",f);
    TTreeReaderValue<vector<Double_t> > calo80pt(readerCalo80object, "pt");
    TTreeReaderValue<vector<Double_t> > calo80eta(readerCalo80object, "eta");
    TTreeReaderValue<vector<Double_t> > calo80phi(readerCalo80object, "phi");


    TTreeReader readerevt("hiEvtAnalyzer/HiTree",f);
    TTreeReaderValue<float> vz(readerevt, "vz");
    TTreeReaderValue<int> bin(readerevt, "hiBin");
    TTreeReaderValue<float> hiHF(readerevt, "hiHF");
    
    TTreeReaderValue<unsigned int> run(readerevt, "run");
    TTreeReaderValue<unsigned int> lumi(readerevt, "lumi");
    TTreeReaderValue<unsigned long long> event(readerevt, "evt");

    TTreeReader readerskim("skimanalysis/HltTree",f);

    vector<TTreeReaderValue<int> *>filters;
    for (auto f:filterNames)
      filters.push_back(new TTreeReaderValue<int>(readerskim, f));
      
    cout<<"added filters"<<endl;
    
    int nev = reader.GetEntries(true); cout<<nev<<endl;
    totentries+=nev;
    int onep = nev/100;
    int evCounter = 0;
    TTimeStamp t0;
    
    //for testing - only 10% of data
    //while (evCounter<2*onep && reader.Next()) {
    //go full file
    while (reader.Next()) {
      readerhlt.Next();
      readerevt.Next();
      readerskim.Next();
      readercsv60object.Next();
      readercsv80object.Next();
      readerCalo60object.Next();
      readerCalo80object.Next();

      evCounter++;
      if (evCounter%onep==0) {
        std::cout << std::fixed;
        TTimeStamp t1; 
        cout<<" \r"<<evCounter/onep<<"%   "<<" total time "<<(int)round((t1-t0)*nev/(evCounter+.1))<<" s "<<flush;
      }


      int bPFJet60 = !PbPb ? *PFJet60 : 1;
      int bPFJet80 = !PbPb ? *PFJet80 : 1;

      //int jet40 = *CaloJet40 || *CaloJet40v2;

      float weight = 1;

      if (!PbPb)
        weight = getweight(subfoldernames[i], bPFJet60, bPFJet80);


      if (PbPb && sample=="j60")
        weight = *CaloJet60;//only calojet 40

      ntevt->Fill(weight, *bin, *vz, *hiHF, *CSV60, *CSV80);

      if (weight==0) continue;

      //good event is vertex cut and noise cuts
      bool goodevent = abs(*vz)<15;
      for (auto f:filters) 
        goodevent&=*(*f);

      int ind1=-1, ind2=-1, ind3=-1, indSL=-1; //indices of leading/subleading jets in jet array
      int indTrigCSV60=-1, indTrigCSV80=-1, indTrigCalo60=-1, indTrigCalo80=-1;
      int SLord = 0;
      bool foundJ1=false, foundJ2 = false, foundJ3 = false, foundSL = false; //found/not found yet, for convenience

      bool triggermatched = false;

      if (goodevent)
        for (int j=0;j<*nref;j++) {
          //acceptance selection
          if (abs(jteta[j])>1.5) continue;
          //muon cuts
          if (PbPb) {
            if((*muMax)[j]/rawpt[j]>0.95) continue;
            if( ((*muMaxTRK)[j]-(*muMaxGBL)[j]) / ((*muMaxTRK)[j]+(*muMaxGBL)[j]) > 0.1) continue;
          }
  
          if (!foundJ1) { //looking for the leading jet
              ind1 = j;
              foundJ1=true;

	      if (PbPb) {
		indTrigCSV60 = triggeredLeadingJetCSV(jtphi[j], jteta[j], *csv60pt, *csv60phi, *csv60eta);
		indTrigCSV80 = triggeredLeadingJetCSV(jtphi[j], jteta[j], *csv80pt, *csv80phi, *csv80eta);
		indTrigCalo60 = triggeredLeadingJetCalo(jtphi[j], jteta[j], *calo60pt, *calo60phi, *calo60eta);
		indTrigCalo80 = triggeredLeadingJetCalo(jtphi[j], jteta[j], *calo80pt, *calo80phi, *calo80eta);
	      }
             
	      triggermatched = !PbPb || indTrigCSV60!=-1 || indTrigCSV80!=-1;
	  } else
            if (foundJ1 && !foundJ2) {
              ind2 = j;
              foundJ2 = true;
            } else
            if (foundJ1 && foundJ2 && !foundJ3) {
              ind3 = j;
              foundJ3 = true;
            }

          //we need ordinal number of SL jets, so counting until found
          //indSL != SLord because some jets are not in acceptance region
            if (!foundSL) SLord++;

          //ind1!=j otherwise SL will be = J1
            if (foundJ1 && ind1!=j && !foundSL && discr_csvV1[j]>0.9) {
              indSL = j;
              foundSL = true;
            }  




          //at this point foundLJ = true always, so triggermatched is determined
          vector<float> vinc = {weight, (float)triggermatched, (float) *bin, *vz, *hiHF,(float)*CSV60, (float)*CSV80,(float)*CaloJet40, (float)*CaloJet60, (float)*CaloJet80,
            (float)bPFJet60,(float)bPFJet80, rawpt[j], jtpt[j], jtphi[j], jteta[j], discr_csvV1[j],svtxm[j],discr_prob[j],
            svtxdls[j],svtxpt[j],(float)svtxntrk[j],(float)nsvtx[j],(float)nselIPtrk[j]};
  
          ntinc->Fill(&vinc[0]);
        }

      //fill dijet ntuple
      vector<float> vdj;

      vdj = {(float)*run, (float)*lumi, (float)*event, weight, (float)triggermatched, (float)*bin, *vz,*hiHF,
        (float)*CSV60, (float)*CSV80,(float)*CaloJet40,(float)*CaloJet60, (float)*CaloJet80,(float)bPFJet60,(float)bPFJet80, 
        foundJ1 && foundJ2 ? (float)1 : (float)0,

        indTrigCalo60!=-1 ? (float)(*calo60pt)[indTrigCalo60] : NaN,
        indTrigCalo60!=-1 ? (float)(*calo60phi)[indTrigCalo60] : NaN,
        indTrigCalo60!=-1 ? (float)(*calo60eta)[indTrigCalo60] : NaN,

        indTrigCalo80!=-1 ? (float)(*calo80pt)[indTrigCalo80] : NaN,
        indTrigCalo80!=-1 ? (float)(*calo80phi)[indTrigCalo80] : NaN,
        indTrigCalo80!=-1 ? (float)(*calo80eta)[indTrigCalo80] : NaN,

        indTrigCSV60!=-1  ? (float)(*csv60pt)[indTrigCSV60] : NaN,
        indTrigCSV60!=-1  ? (float)(*csv60phi)[indTrigCSV60] : NaN,
        indTrigCSV60!=-1  ? (float)(*csv60eta)[indTrigCSV60] : NaN,

        indTrigCSV80!=-1  ? (float)(*csv80pt)[indTrigCSV80] : NaN,
        indTrigCSV80!=-1  ? (float)(*csv80phi)[indTrigCSV80] : NaN,
        indTrigCSV80!=-1  ? (float)(*csv80eta)[indTrigCSV80] : NaN,
                                
        foundJ1 ? rawpt[ind1] : NaN,
        foundJ1 ? jtpt[ind1] : NaN,
        foundJ1 ? jtphi[ind1] : NaN,
        foundJ1 ? jteta[ind1] : NaN,
        foundJ1 ? discr_csvV1[ind1] : NaN,
        foundJ1 ? svtxm[ind1] : NaN,
        foundJ1 ? discr_prob[ind1] : NaN,
        foundJ1 ? svtxdls[ind1] : NaN,
        foundJ1 ? svtxpt[ind1] : NaN,
        foundJ1 ? (float)svtxntrk[ind1] : NaN,
        foundJ1 ? (float)nsvtx[ind1] : NaN,
        foundJ1 ? (float)nselIPtrk[ind1] : NaN,

        foundJ2 ? rawpt[ind2] : NaN,
        foundJ2 ? jtpt[ind2] : NaN,
        foundJ2 ? jtphi[ind2] : NaN,
        foundJ2 ? jteta[ind2] : NaN,
        foundJ2 ? discr_csvV1[ind2] : NaN,
        foundJ2 ? svtxm[ind2] : NaN,
        foundJ2 ? discr_prob[ind2] : NaN,
        foundJ2 ? svtxdls[ind2] : NaN, 
        foundJ2 ? svtxpt[ind2] : NaN,
        foundJ2 ? (float)svtxntrk[ind2] : NaN,
        foundJ2 ? (float)nsvtx[ind2] : NaN,
        foundJ2 ? (float)nselIPtrk[ind2] : NaN,
        foundJ2 && foundJ1 ? acos(cos(jtphi[ind2]-jtphi[ind1])) : NaN,
    
        foundJ3 ? rawpt[ind3] : NaN,
        foundJ3 ? jtpt[ind3] : NaN,
        foundJ3 ? jtphi[ind3] : NaN,
        foundJ3 ? jteta[ind3] : NaN,
        foundJ3 ? discr_csvV1[ind3] : NaN,
        foundJ3 ? svtxm[ind3] : NaN,
        foundJ3 ? discr_prob[ind3] : NaN,
        foundJ3 ? svtxdls[ind3] : NaN, 
        foundJ3 ? svtxpt[ind3] : NaN,
        foundJ3 ? (float)svtxntrk[ind3] : NaN,
        foundJ3 ? (float)nsvtx[ind3] : NaN,
        foundJ3 ? (float)nselIPtrk[ind3] : NaN,
        foundJ3 && foundJ1 ? acos(cos(jtphi[ind3]-jtphi[ind1])) : NaN,
        foundJ3 && foundJ2 ? acos(cos(jtphi[ind3]-jtphi[ind2])) : NaN,

        foundSL ? (float)SLord : NaN,
        foundSL ? rawpt[indSL] : NaN,
        foundSL ? jtpt[indSL] : NaN,
        foundSL ? jtphi[indSL] : NaN,
        foundSL ? jteta[indSL] : NaN,
        foundSL ? discr_csvV1[indSL] : NaN,
        foundSL ? svtxm[indSL] : NaN,
        foundSL ? discr_prob[indSL] : NaN,
        foundSL ? svtxdls[indSL] : NaN, 
        foundSL ? svtxpt[indSL] : NaN,
        foundSL ? (float)svtxntrk[indSL] : NaN,
        foundSL ? (float)nsvtx[indSL] : NaN,
        foundSL ? (float)nselIPtrk[indSL] : NaN,
        foundSL && foundJ1 ? acos(cos(jtphi[indSL]-jtphi[ind1])) : NaN};


      ntdj->Fill(&vdj[0]);



    }

    f->Close();
    }
  }
  
  foutevt->cd();
  ntevt->Write();
  foutevt->Close();

  foutdj->cd();
  ntdj->Write();
  foutdj->Close();

  foutinc->cd();
  ntinc->Write();
  foutinc->Close();

  cout<<endl;
  cout<<"Total input entries "<<totentries<<endl;

  //making centrality-dependent ntuples
  //PutInCbins(outputfolder, code, {{0,40}, {80,200}});

  if (PbPb && sample=="bjt"){
    auto w = calculateWeightsBjet(outputfilenamedj);

    updatePbPbBtriggerweight(outputfilenamedj,w);
    updatePbPbBtriggerweight(outputfilenameinc,w);
    updatePbPbBtriggerweight(outputfilenameevt,w);
  } else {
    updateweight(outputfilenamedj);
    updateweight(outputfilenameinc);
    updateweight(outputfilenameevt);
    }

}
Ejemplo n.º 14
0
int main()
{
	//Stel onderstaande poorten in op Output en laad allemaal enen in
	DDRA=0xFF;
	DDRB=0xFF;
	DDRC=0xFF;
	PORTA=0xFF;
	PORTB=0xFF;
	PORTC=0xFF;

	//Stel de timer in die een interrupt genereert bij en overflow
	TCCR0=0x05;
	TIMSK=0x01;
	
	//Stel odnerstaande poorten in op Input en laad allemaal enen in
	DDRE=0x00;
	PINE=0xFF;

	serial.init();

	// Aanmaken van de verschillende autolichtobjecten
	AutoLicht azl(0xFE, 0xFD, 0xFB, ADRESPORTB);
	AutoLicht azr(0xF7, 0xEF, 0xDF, ADRESPORTB);
	AutoLicht ahl(0xFE, 0xFD, 0xFB, ADRESPORTC);
	AutoLicht ahr(0xF7, 0xEF, 0xDF, ADRESPORTC);

	// Aanmaken van de verschillende voetgangerlichtobjecten
	VoetgangerLicht vhr(0xFE, 0xFD, ADRESPORTA);
	VoetgangerLicht vz(0xBF, 0x7F, ADRESPORTB);
	VoetgangerLicht vhl(0xBF, 0x7F, ADRESPORTC);

	List<VoetgangerLicht*> l1, l2, l3;
	List<Scenario*> s;

	//Lijst l1 vullen
	l1.push_back(&azl);
	l1.push_back(&azr);

	//Lijst l2 vullen
	l2.push_back(&ahl);
	l2.push_back(&ahr);

	//Lijst l3 vullen
	l3.push_back(&vhr);
	l3.push_back(&vz);
	l3.push_back(&vhl);
	
	//Scenario's definieren
	Scenario s1(&l1, &variabelebeheerder);
	Scenario s2(&l2, &variabelebeheerder);
	Scenario s3(&l3, &variabelebeheerder);
	s.push_back(&s1);
	s.push_back(&s2);
	s.push_back(&s3);

	variabelebeheerder.zetAantalScenarios(3);

	//Scenario's toekennen aan sensoren
	svz.kenScenarioToe(&s3);
	svhr.kenScenarioToe(&s3);
	svhl.kenScenarioToe(&s3);
	sahr.kenScenarioToe(&s2);
	sahl.kenScenarioToe(&s2);
	sazl.kenScenarioToe(&s1);
	sazr.kenScenarioToe(&s1);

	VerkeersRegelaar vr(&s, &wachtrijbeheerder, &variabelebeheerder);
	
	sei(); //Zet interrupts aan

	while(1) {
		vr.kiesFunctie();
	}
}
Ejemplo n.º 15
0
Real State::max_abs_z_eigen(const _3Vec& X, const _3Vec& V) const {
	return fabs(vz(X) - V[2]) + cs(X);
}
Ejemplo n.º 16
0
int vz(int a) {
	vz(a+1);
}
Ejemplo n.º 17
0
	bool AnisotropyShiftProcessor::finish()
	{
		// Abort if the parameters were not initialized correctly.
		if (!isValid())
		{
			return false;
		}

		// Abort if there's nothing to do (no protons).
		if (proton_list_.empty())
		{
			return true;
		}

		// Some constants.
		const float dX1   = -13.0;
		const float dX2   =  -4.0;
		const float dXN1  = -11.0;
		const float dXN2  =  -5.0;
		const float ndX1  = -11.0;
		const float ndX2  =   1.4;
		const float ndXN1 =  -7.0;
		const float ndXN2 =   1.0;

	  
		// Iterate over all protons affected.
		std::list<const Atom*>::const_iterator proton_it(proton_list_.begin());
		for (; proton_it != proton_list_.end(); ++proton_it)
		{
			// Total shift is zero initially
			float total_shift = 0.0;

			// Iterate over all effector bonds (all anisotropic bonds).
			std::list<const Bond*>::const_iterator eff_iter(eff_list_.begin());
			for (; eff_iter != eff_list_.end(); ++eff_iter)
			{
				// Iterate over all bonds of each effector atom.
				const Bond* bond = *eff_iter;
				const Atom* c_atom = bond->getFirstAtom();
				const Atom* o_atom = bond->getSecondAtom();
				if (c_atom->getElement() != PTE[Element::C])
				{
					o_atom = bond->getFirstAtom();
					c_atom = bond->getSecondAtom();
				}
				
				// Make surethe proton and the effector are from different residues.
				const Atom* x_atom = 0;
				if ((*proton_it)->getFragment() != c_atom->getFragment())
				{
					String name = c_atom->getName();
					if (name == "C")
					{
						name = "CA";
					}
					else 
					{
						if (name == "CG")
						{
							name = "CB";
						}
						else 
						{
							if (name == "CD")
							{
								name = "CG";
							}
						}
					}
					for (Position pos = 0; pos < c_atom->countBonds(); pos++)
					{
						const Bond& hbond = *c_atom->getBond(pos);
						if (hbond.getBoundAtom(*c_atom)->getName() == name)
						{
							x_atom = hbond.getBoundAtom(*c_atom);
							break;
						}
					}
					for (Position pos = 0; (x_atom == 0) && (pos < o_atom->countBonds()); pos++)
					{
						const Bond& hbond = *o_atom->getBond(pos);
						if (hbond.getBoundAtom(*o_atom)->getName() == name)
						{
							x_atom = hbond.getBoundAtom(*o_atom);
							break;
						}
					}
					// ??? What happens if x_atom is not set.

					if ((c_atom == 0) || (o_atom == 0) || (x_atom == 0))	
					{
						Log.error() << "Could not set all atoms in ASP! c_atom = " << c_atom << "  o_atom = " << o_atom << "  x_atom = " << x_atom << endl;
						Log.error() << "c_atom->getName() = "<< c_atom->getFullName() << "    o_atom->getName() = " << o_atom->getFullName() << endl;
						continue;
					}
					else 
					{
						const Vector3& c_pos = c_atom->getPosition();
						const Vector3& o_pos = o_atom->getPosition();
						const Vector3& x_pos = x_atom->getPosition();

						// Construct an orthogonal coordinate system.
						Vector3 vz(o_pos - c_pos);
						vz.normalize();
						Vector3 vy(vz % (x_pos - c_pos));
						vy.normalize();
						Vector3 vx (vz % vy);
						vx.normalize();
						const Vector3 cen(c_pos + (vz * 1.1));
						const Vector3 v1((*proton_it)->getPosition() - cen);
						const Vector3 v2(v1 % vy);
						const Vector3 v3(v2 % vx);

						const float distance = v1.getLength();
						const float stheta = v2.getLength() / (v1.getLength() * vy.getLength());
						const float sgamma = v3.getLength() / (v2.getLength() * vx.getLength());
						float calc1;
						float calc2;
						if ((*proton_it)->getName() == "H")
						{
							calc1 = dXN1 * ((3.0 * stheta * stheta) - 2.0);
							calc2 = dXN2 * (1.0 - (3.0 * stheta * stheta * sgamma * sgamma));
						}
						else
						{
							calc1 = dX1 * ((3.0 * stheta * stheta) - 2.0);
							calc2 = dX2 * (1.0 - (3.0 * stheta * stheta * sgamma * sgamma));
						}

						float shift = (calc1 + calc2) / (3.0 * distance * distance * distance);
						// ?????
						// check whether effector and nucleus are in the same chain
						if ((ignore_other_chain_) && ((*proton_it)->getResidue() != 0) && (c_atom->getResidue() != 0))
						{
							if ((*proton_it)->getResidue()->getChain() == c_atom->getResidue()->getChain())
							{
								shift = 0.0;
							}
						}
						total_shift += shift;	
					}
				}
			}

			for (eff_iter = eff_list_2_.begin(); eff_iter != eff_list_2_.end(); ++eff_iter)
			{
				const Bond* bond = *eff_iter;
				const Atom* c_atom = bond->getFirstAtom();
				const Atom* n_atom = bond->getSecondAtom();
				
				if (c_atom->getElement() != PTE[Element::C])
				{
					n_atom = bond->getFirstAtom();
					c_atom = bond->getSecondAtom();
				}
				const Atom* o_atom = 0;

				// Skip the H atom of this residue.
				if ((*proton_it)->getName() == "H" && (*proton_it)->getFragment() == n_atom->getFragment())
				{
					continue;
				}

				for (Position pos = 0; pos < c_atom->countBonds(); pos++)
				{
					const Bond& hbond = *c_atom->getBond(pos);
					if (hbond.getBoundAtom(*c_atom)->getName() == "O")
					{
						o_atom = hbond.getBoundAtom(*c_atom);
						break;
					}
				}
				
				if (o_atom != 0)
				{
					Vector3 c_pos = c_atom->getPosition();
					Vector3 o_pos = o_atom->getPosition();
					Vector3 n_pos = n_atom->getPosition();

					// baue rechtwinkliges Koordinatensystem auf
					Vector3 vz = n_pos - c_pos;
					const float vz_scalar = vz.getLength();
					vz.normalize();
					Vector3 vy = vz % (o_pos - c_pos);
					vy.normalize();
					Vector3 vx = vz % vy;
					vx.normalize();
					const Vector3 cen = c_pos + (vz * (0.85 * vz_scalar));
					const Vector3 v1 = (*proton_it)->getPosition() - cen;
					const Vector3 v2 = v1 % vy;
					const Vector3 v3 = v2 % vx;

					const float distance = v1.getLength();
					const float stheta = v2.getLength() / (v1.getLength() * vy.getLength());
					const float sgamma = v3.getLength() / (v2.getLength() * vx.getLength());
					float calc1, calc2;
					if ((*proton_it)->getName() == "H")
					{
						calc1 = ndXN1 * ((3.0 * stheta * stheta) - 2.0);
						calc2 = ndXN2 * (1.0 - (3.0 * stheta * stheta * sgamma * sgamma));
					}
					else
					{
						calc1 = ndX1 * ((3.0 * stheta * stheta) - 2.0);
						calc2 = ndX2 * (1.0 - (3.0 * stheta * stheta * sgamma * sgamma));
					}

					// ?????
					float shift = (calc1 + calc2) / (3.0 * distance * distance * distance);	
					// check whether effector and nucleus are in the same chain
					if (ignore_other_chain_ && ((*proton_it)->getResidue() != 0) && (c_atom->getResidue() != 0))
					{
						if ((*proton_it)->getResidue()->getChain() == c_atom->getResidue()->getChain())
						{
							shift = 0.0;
						}
					}
					total_shift += shift;
				}
				else 
				{
					Log.error() << "O atom not found for " << c_atom->getFullName() << "-" << n_atom->getFullName() << endl;
				}
			}
			float shift = (*proton_it)->getProperty(ShiftModule::PROPERTY__SHIFT).getFloat();
			shift -= total_shift;
			(const_cast<Atom*>(*proton_it))->setProperty(ShiftModule::PROPERTY__SHIFT, shift);
			(const_cast<Atom*>(*proton_it))->setProperty(PROPERTY__ANISOTROPY_SHIFT, -total_shift);
		}

		return true;
	}
Ejemplo n.º 18
0
  //! Calculate the signed volume for an atom.  If the atom has a valence of 3
  //! the coordinates of an attached hydrogen are calculated
  //! Puts attached Hydrogen last at the moment, like mol V3000 format.
  //! If ReZero=false (the default is true) always make pseudo z coords and leave them in mol
  double CalcSignedVolume(OBMol &mol,OBAtom *atm, bool ReZeroZ)
  {
    vector3 tmp_crd;
    vector<unsigned int> nbr_atms;
    vector<vector3> nbr_crds;
    bool use_central_atom = false,is2D=false;
    //   double hbrad = etab.CorrectedBondRad(1,0);
           
    if (!ReZeroZ || !mol.Has3D()) //give pseudo Z coords if mol is 2D
      {
        vector3 v,vz(0.0,0.0,1.0);
        is2D = true;
        OBAtom *nbr;
        OBBond *bond;
        vector<OBBond*>::iterator i;
        for (bond = atm->BeginBond(i);bond;bond = atm->NextBond(i))
          {
            nbr = bond->GetEndAtom();
            if (nbr != atm)
              {
                v = nbr->GetVector();
                if (bond->IsWedge())
                  v += vz;
                else
                  if (bond->IsHash())
                    v -= vz;

                nbr->SetVector(v);
              }
            else
              {
                nbr = bond->GetBeginAtom();
                v = nbr->GetVector();
                if (bond->IsWedge())
                  v -= vz;
                else
                  if (bond->IsHash())
                    v += vz;

                nbr->SetVector(v);
              }
          }
      }
    
    if (atm->GetHvyValence() < 3)
      {
        stringstream errorMsg;
        errorMsg << "Cannot calculate a signed volume for an atom with a heavy atom valence of " << atm->GetHvyValence() << endl;
        obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obInfo);
        return(0.0);
      }

    // Create a vector with the coordinates of the neighbor atoms
    // Also make a vector with Atom IDs
    OBAtom *nbr;
    vector<OBBond*>::iterator bint;
    for (nbr = atm->BeginNbrAtom(bint);nbr;nbr = atm->NextNbrAtom(bint))
      {
        nbr_atms.push_back(nbr->GetIdx());
      }
    // sort the neighbor atoms to insure a consistent ordering
    sort(nbr_atms.begin(),nbr_atms.end());
    for (unsigned int i = 0; i < nbr_atms.size(); ++i)
      {
        OBAtom *tmp_atm = mol.GetAtom(nbr_atms[i]);
        nbr_crds.push_back(tmp_atm->GetVector());
      }
    /*
    // If we have three heavy atoms we need to calculate the position of the fourth
    if (atm->GetHvyValence() == 3)
    {
    double bondlen = hbrad+etab.CorrectedBondRad(atm->GetAtomicNum(),atm->GetHyb());
    atm->GetNewBondVector(tmp_crd,bondlen);
    nbr_crds.push_back(tmp_crd);
    }
    */
    for(unsigned int j=0;j < nbr_crds.size();++j) // Checks for a neighbour having 0 co-ords (added hydrogen etc)
      {
        // are the coordinates zero to 6 or more significant figures
        if (nbr_crds[j].IsApprox(VZero, 1.0e-6) && use_central_atom==false)
          use_central_atom=true;
        else if (nbr_crds[j].IsApprox(VZero, 1.0e-6))
          {
            obErrorLog.ThrowError(__FUNCTION__, "More than 2 neighbours have 0 co-ords when attempting 3D chiral calculation", obInfo);
          }
      }

    // If we have three heavy atoms we can use the chiral center atom itself for the fourth
    // will always give same sign (for tetrahedron), magnitude will be smaller.
    if(nbr_atms.size()==3 || use_central_atom==true)
      {
        nbr_crds.push_back(atm->GetVector());
        nbr_atms.push_back(mol.NumAtoms()+1); // meed to add largest number on end to work
      }
    OBChiralData* cd=(OBChiralData*)atm->GetData(OBGenericDataType::ChiralData); //Set the output atom4refs to the ones used
    if(cd==NULL)
      {
        cd = new OBChiralData;
        cd->SetOrigin(perceived);
        atm->SetData(cd);
      }
    cd->SetAtom4Refs(nbr_atms,calcvolume);
    
    //re-zero psuedo-coords
    if (is2D && ReZeroZ)
      {
        vector3 v;
        OBAtom *atom;
        vector<OBAtom*>::iterator k;
        for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k))
          {
            v = atom->GetVector();
            v.SetZ(0.0);
            atom->SetVector(v);
          }
      }
    
    return(signed_volume(nbr_crds[0],nbr_crds[1],nbr_crds[2],nbr_crds[3]));
  }
Ejemplo n.º 19
0
int main() {
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ > 4)
  std::cout << "gcc " << __GNUC__ << "." << __GNUC_MINOR__ << std::endl;
#endif
#ifdef USE_SSEVECT
  std::cout << "sse vector enabled in cmssw" << std::endl;
#endif

  std::cout << sizeof(Basic2DVectorF) << std::endl;
  std::cout << sizeof(Basic2DVectorD) << std::endl;
  std::cout << sizeof(Basic3DVectorF) << std::endl;
  std::cout << sizeof(Basic3DVectorD) << std::endl;
  std::cout << sizeof(Basic3DVectorLD) << std::endl;

  Basic3DVectorF  x(2.0f,4.0f,5.0f);
  Basic3DVectorF  y(-3.0f,2.0f,-5.0f);
  Basic3DVectorD  xd(2.0,4.0,5.0);
  Basic3DVectorD  yd = y;

  Basic3DVectorLD  xld(2.0,4.0,5.0);
  Basic3DVectorLD  yld = y;


  Basic2DVectorF  x2(2.0f,4.0f);
  Basic2DVectorF  y2 = y.xy();
  Basic2DVectorD  xd2(2.0,4.0);
  Basic2DVectorD  yd2 = yd.xy();

  {
    std::cout << dotV(x,y) << std::endl; 
    std::cout << normV(x) << std::endl; 
    std::cout << norm(x) << std::endl; 
    std::cout << min(x.mathVector(),y.mathVector()) << std::endl;
    std::cout << max(x.mathVector(),y.mathVector()) << std::endl;

    std::cout << dotV(x,yd) << std::endl; 
    std::cout << dotV(xd,y) << std::endl; 
    std::cout << dotV(xd,yd) << std::endl; 
    std::cout << normV(xd) << std::endl; 
    std::cout << norm(xd) << std::endl; 
    std::cout << dotV(xld,yld) << std::endl; 
    std::cout << normV(xld) << std::endl; 
    std::cout << norm(xld) << std::endl; 
    
    
    Basic3DVectorF  z = x.cross(y);
    std::cout << z << std::endl;
    std::cout << -z << std::endl;
    Basic3DVectorD  zd = x.cross(yd);
    std::cout << zd << std::endl;
    std::cout << -zd << std::endl;
    std::cout << xd.cross(y)<< std::endl;
    std::cout << xd.cross(yd)<< std::endl;

    Basic3DVectorLD  zld = x.cross(yld);
    std::cout << zld << std::endl;
    std::cout << -zld << std::endl;
    std::cout << xld.cross(y)<< std::endl;
    std::cout << xld.cross(yld)<< std::endl;

    std::cout << z.eta() << " " << (-z).eta() << std::endl;
    std::cout << zd.eta()  << " " << (-zd).eta() << std::endl;
    std::cout << zld.eta()  << " " << (-zld).eta() << std::endl;
    
#if defined( __GXX_EXPERIMENTAL_CXX0X__)
    auto s = x+xd - 3.1*z;
    std::cout << s << std::endl;
    auto s2 = x+xld - 3.1*zd;
    std::cout << s2 << std::endl;

#endif
  }

 {
    std::cout << dotV(x2,y2) << std::endl; 
    std::cout << normV(x2) << std::endl; 
    std::cout << norm(x2) << std::endl; 
    std::cout << min(x2.mathVector(),y2.mathVector()) << std::endl;
    std::cout << max(x2.mathVector(),y2.mathVector()) << std::endl;

    std::cout << dotV(x2,yd2) << std::endl; 
    std::cout << dotV(xd2,y2) << std::endl; 
    std::cout << dotV(xd2,yd2) << std::endl; 
    std::cout << normV(xd2) << std::endl; 
    std::cout << norm(xd2) << std::endl; 
    
    
    Basic2DVectorF  z2(x2); z2-=y2;
    std::cout << z2 << std::endl;
    std::cout << -z2 << std::endl;
    Basic2DVectorD zd2 = x2-yd2;
    std::cout << zd2 << std::endl;
    std::cout << -zd2 << std::endl;
    std::cout << x2.cross(y2) << std::endl;
    std::cout << x2.cross(yd2) << std::endl;
    std::cout << xd2.cross(y2)<< std::endl;
    std::cout << xd2.cross(yd2)<< std::endl;
    
#if defined( __GXX_EXPERIMENTAL_CXX0X__)
    auto s2 = x2+xd2 - 3.1*z2;
    std::cout << s2 << std::endl;
#endif
  }



  {
    std::cout << "f" << std::endl;
    Basic3DVectorF  vx(2.0f,4.0f,5.0f);
    Basic3DVectorF  vy(-3.0f,2.0f,-5.0f);
    vx+=vy;
    std::cout << vx << std::endl;
    
    Basic3DVectorF vz(1.f,1.f,1.f);
    addScaleddiff(vz,0.1f,vx,vy);
    std::cout << vz << std::endl;
  }

 {
    std::cout << "d" << std::endl;
    Basic3DVectorD  vx(2.0,4.0,5.0);
    Basic3DVectorD  vy(-3.0,2.0,-5.0);
    vx+=vy;
    std::cout << vx << std::endl;
    
    Basic3DVectorD vz(1.,1.,1);
    addScaleddiff(vz,0.1,vx,vy);
    std::cout << vz << std::endl;
 }

 std::cout << "std::vector" << std::endl;
 std::vector<Basic3DVectorF> vec1; vec1.reserve(50);
 std::vector<float> vecf(21);
 std::vector<Basic3DVectorF> vec2(51);
 std::vector<Basic3DVectorF> vec3; vec3.reserve(23456);
}
Ejemplo n.º 20
0
void vHavokShapeFactory::ExtractScaling(const hkvMat4 &mat, hkvVec3& destScaling)
{
  hkvVec3 vx(hkvNoInitialization),vy(hkvNoInitialization),vz(hkvNoInitialization);
  mat.getAxisXYZ (&vx, &vy, &vz);
  destScaling.set(vx.getLength(),vy.getLength(),vz.getLength());
}