예제 #1
0
파일: t_v3tools.cpp 프로젝트: korantu/vx2
int main(){
  V3f x(0,0,1); V3f xr(rot_x(x, 0.87)); same("x rotation", x.dot(xr), cos(0.87));
  V3f y(0,0,1); V3f yr(rot_y(y, 0.23)); same("y rotation", y.dot(yr), cos(0.23));
  V3f z(1,0,0); V3f zr(rot_z(z, 0.19)); same("z rotation", z.dot(zr), cos(0.19));

  V3f nx(3,2,5);
  V3f ny(-2,3,4);
  V3f nz(-4,4,3.8);

  V3f nnx(3,2,5);
  V3f nny(-2,3,4);
  V3f nnz(-4,4,3.8);

  ortoNormalize(nnx, nny, nnz);
  
  same("x unit", nnx.length(), 1.0);
  same("y unit", nny.length(), 1.0);
  same("z unit", nnz.length(), 1.0);

  V3f tmp; tmp.cross(nnx, nx);

  same("x colinear", tmp.length(), 0.0);
  
  tmp.cross(nnx, nny); tmp-=nnz; same("x orto", tmp.length(), 0);
  tmp.cross(nny, nnz); tmp-=nnx; same("y orto", tmp.length(), 0);
  tmp.cross(nnz, nnx); tmp-=nny; same("z orto", tmp.length(), 0);


};
/**
 * Calculate the self-attenutation factor for the given mur value
 * @param muR Single mu*r slice value
 * @return The self-attenuation factor for this sample
 */
double
MayersSampleCorrectionStrategy::calculateSelfAttenuation(const double muR) {
  // Integrate over the cylindrical coordinates
  // Constants for calculation
  const double dyr = muR / to<double>(N_RAD - 1);
  const double dyth = TWOPI / to<double>(N_THETA - 1);
  const double muRSq = muR * muR;
  const double cosaz = cos(m_pars.azimuth);

  // Store values at each point
  std::vector<double> yr(N_RAD), yth(N_THETA);
  for (size_t i = 0; i < N_RAD; ++i) {
    const double r0 = to<double>(i) * dyr;

    for (size_t j = 0; j < N_THETA; ++j) {
      const double theta = to<double>(j) * dyth;
      // distance to vertical axis
      double fact1 = muRSq - std::pow(r0 * sin(theta), 2);
      if (fact1 < 0.0)
        fact1 = 0.0;
      // + final distance to scatter point
      const double mul1 = sqrt(fact1) + r0 * cos(theta);
      // exit distance after scatter
      double fact2 = muRSq - std::pow(r0 * sin(m_pars.twoTheta - theta), 2);
      if (fact2 < 0.0)
        fact2 = 0.0;
      const double mul2 =
          (sqrt(fact2) - r0 * cos(m_pars.twoTheta - theta)) / cosaz;
      yth[j] = exp(-mul1 - mul2);
    }

    yr[i] = r0 * integrate(yth, dyth);
  }
  return integrate(yr, dyr);
}
예제 #3
0
 inline std::string
 Comparator::compare(std::string x_n, IntVar x, IntVar y) {
   IntVarRanges xr(x), yr(y);
   if (!Iter::Ranges::equal(xr,yr)) {
     std::ostringstream ret;
     ret << x_n << "=" << x << " -> " << y;
     return ret.str();
   }
   return "";
 }
예제 #4
0
osg::Quat KeyframeController::getXYZRotation(float time) const
{
    float xrot = 0, yrot = 0, zrot = 0;
    if (!mXRotations.empty())
        xrot = mXRotations.interpKey(time);
    if (!mYRotations.empty())
        yrot = mYRotations.interpKey(time);
    if (!mZRotations.empty())
        zrot = mZRotations.interpKey(time);
    osg::Quat xr(xrot, osg::Vec3f(1,0,0));
    osg::Quat yr(yrot, osg::Vec3f(0,1,0));
    osg::Quat zr(zrot, osg::Vec3f(0,0,1));
    return (xr*yr*zr);
}
예제 #5
0
파일: nq.hpp 프로젝트: MGKhKhD/easy-IP
 ExecStatus
 Distinct<View0,View1>::propagate(Space& home, const ModEventDelta&) {
   assert(x0.assigned()||x1.assigned());
   if (x0.assigned()) {
     GlbRanges<View0> xr(x0);
     IntSet xs(xr);
     ConstSetView cv(home, xs);
     GECODE_REWRITE(*this,(DistinctDoit<View1>::post(home(*this),x1,cv)));
   } else {
     GlbRanges<View1> yr(x1);
     IntSet ys(yr);
     ConstSetView cv(home, ys);
     GECODE_REWRITE(*this,(DistinctDoit<View0>::post(home(*this),x0,cv)));
   }
 }
예제 #6
0
파일: nq.hpp 프로젝트: MGKhKhD/easy-IP
 ExecStatus
 Distinct<View0,View1>::post(Home home, View0 x, View1 y) {
   if (x.assigned()) {
     GlbRanges<View0> xr(x);
     IntSet xs(xr);
     ConstSetView cv(home, xs);
     GECODE_ES_CHECK((DistinctDoit<View1>::post(home,y,cv)));
   }
   if (y.assigned()) {
     GlbRanges<View1> yr(y);
     IntSet ys(yr);
     ConstSetView cv(home, ys);
     GECODE_ES_CHECK((DistinctDoit<View0>::post(home,x,cv)));
   }
   (void) new (home) Distinct<View0,View1>(home,x,y);
   return ES_OK;
 }
예제 #7
0
    void Player::setRot(float x, float y, float z)
    {
            Ogre::SceneNode *sceneNode = mNode;
            Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
            Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();

            // we are only interested in X and Y rotation

            // Rotate around X axis
            Ogre::Quaternion xr(Ogre::Radian(x), Ogre::Vector3::UNIT_X);

            // Rotate around Y axis
            Ogre::Quaternion yr(Ogre::Radian(-z), Ogre::Vector3::UNIT_Y);

            pitchNode->setOrientation(xr);
            yawNode->setOrientation(yr);
    }
예제 #8
0
파일: object.cpp 프로젝트: a-zer0/openmw
void CSVRender::Object::adjustTransform()
{
    if (mReferenceId.empty())
        return;

    const CSMWorld::CellRef& reference = getReference();

    // position
    mBaseNode->setPosition(mForceBaseToZero ? osg::Vec3() : osg::Vec3f(reference.mPos.pos[0], reference.mPos.pos[1], reference.mPos.pos[2]));

    // orientation
    osg::Quat xr (-reference.mPos.rot[0], osg::Vec3f(1,0,0));
    osg::Quat yr (-reference.mPos.rot[1], osg::Vec3f(0,1,0));
    osg::Quat zr (-reference.mPos.rot[2], osg::Vec3f(0,0,1));
    mBaseNode->setAttitude(zr*yr*xr);

    mBaseNode->setScale(osg::Vec3(reference.mScale, reference.mScale, reference.mScale));
}
예제 #9
0
void fmsBitShiftGain_db(char* opt="", char* year="15ofl", char* filename="bitshift/fmsBitShiftGain_all0.txt"){
    TString option(opt), yr(year), f1(filename);
    TString storeTime;     // storetime is begin time for validity range for WRITING DB
    time_t starttime=0;    //unix time for writing, if reading from file
    int date=0,time=0;     // time for READING DB
    int flag=0;
    
    std::cout << "Opt =" << opt << "\n";  
    std::cout << "write = " << option.Contains("writedb")   << "\n";
    
    gROOT->Macro("loadlib.C");
    
    const Int_t MAX_DB_INDEX = 1732;
    fmsBitShiftGain_st table[MAX_DB_INDEX];
    memset(table,0,sizeof(table));
    
    int idx=f1.Index("run");
    TString f2=f1(idx+3,8);
    int run=f2.Atoi();
    printf("%s idx=%d f2=%s run=%d\n",f1.Data(),idx,f2.Data(),run);

    if(run>0){
	char *onlserver="onldb",*bakserver="dbbak",*server=0;
	int  port;
	int y=run/1000000 -1;
	if(y == 17){
	    server=onlserver;
	    port=3501;
	}else{
	    server=bakserver;
	    port=3400+y-1;
	}
	char cmd[300]=Form("mysql -h %s.starp.bnl.gov --port=%d -N -s -e \"SELECT startRunTime FROM RunLog.runDescriptor WHERE runNumber=%d LIMIT 1\"",
			   server,port,run);
	TString st=gSystem->GetFromPipe(cmd);
	starttime=st.Atoi();

	date=gSystem->GetFromPipe(Form("date -u -d \@%d +%%Y%%m%%d",starttime)).Atoi();
	time=gSystem->GetFromPipe(Form("date -u -d \@%d +%%H%%M%%S",starttime)).Atoi();
	cout << cmd << endl;
	cout << "start time="<<starttime<<" date="<<date<<" time="<<time<< endl;    
    }
예제 #10
0
파일: object.cpp 프로젝트: Fynjyfun/openmw
void CSVRender::Object::adjustTransform()
{
    if (mReferenceId.empty())
        return;

    ESM::Position position = getPosition();

    // position
    mRootNode->setPosition(mForceBaseToZero ? osg::Vec3() : osg::Vec3f(position.pos[0], position.pos[1], position.pos[2]));

    // orientation
    osg::Quat xr (-position.rot[0], osg::Vec3f(1,0,0));
    osg::Quat yr (-position.rot[1], osg::Vec3f(0,1,0));
    osg::Quat zr (-position.rot[2], osg::Vec3f(0,0,1));
    mBaseNode->setAttitude(zr*yr*xr);

    float scale = getScale();

    mBaseNode->setScale(osg::Vec3(scale, scale, scale));
}
예제 #11
0
 forceinline void
 IntTraceView::prune(Space& home, IntView y, const Delta& d) {
   if (y.range() && (dom->next() == NULL)) {
     dom->min(y.min()); dom->max(y.max());
   } else if (!y.any(d) && (y.max(d)+1 == y.min())) {
     // The lower bound has been adjusted
     if (y.min() > dom->max()) {
       RangeList* p = dom;
       RangeList* l = p->next();
       while ((l != NULL) && (l->max() < y.min())) {
         p=l; l=l->next();
       }
       dom->dispose(home,p);
       dom = l;
     }
     dom->min(y.min());
   } else if (!y.any(d) && (y.max()+1 == y.min(d))) {
     // upper bound has been adjusted
     if ((y.max() <= dom->max()) && (dom->next() == NULL)) {
       dom->max(y.max());
     } else {
       RangeList* p = dom;
       RangeList* l = p->next();
       while ((l != NULL) && (l->min() <= y.max())) {
         p=l; l=l->next();
       }
       p->max(y.max());
       if (p->next() != NULL)
         p->next()->dispose(home);
       p->next(NULL);
     }
   } else {
     // Just copy the domain
     ViewRanges<IntView> yr(y);
     RangeList::overwrite(home,dom,yr);
   }
 }
예제 #12
0
void initialize_new_objects(mpi::communicator& world,
			    parameter_t const& P,  directory_structure_t const& ds,
			    geometric_info_t const& gi, object_info_t& oi,
			    vector<std::vector<std::string> > const &seq, int tt,
			    vector<CImg<unsigned char> > const& images,
			    vector<matrix<float> > const& grd,
			    vector<matrix<float> >& detected_rects)
{
    int Ncam = seq.size();
    vector<object_trj_t> & trlet_list=oi.trlet_list;
    int nobj = trlet_list.size();
    int num_new_obj = detected_rects(0).size1();
    int T = seq[0].size();
    int np = oi.model.size();

    int num_scales = P.scales.size();

    //std::cout<<"detected_rects="<<detected_rects<<std::endl;

    for(int oo=0; oo<num_new_obj; ++oo)
    {
	int nn = oi.curr_num_obj + oo;

	trlet_list(nn).startt = tt;
	trlet_list(nn).endt = tt;
	trlet_list(nn).state = 1;
	trlet_list(nn).trj = vector<matrix<float> >(Ncam);
	for(int cam=0; cam<Ncam; ++cam)
	{
	    trlet_list(nn).trj(cam) = scalar_matrix<float>(T, 4, 0);
	}
	trlet_list(nn).trj_3d = scalar_matrix<float>(T, 2, 0);

	trlet_list(nn).hist_p = vector<matrix<float> >(Ncam);
	trlet_list(nn).hist_q = vector<matrix<float> >(Ncam);

	trlet_list(nn).fscores = vector<matrix<float> >(Ncam);
	trlet_list(nn).scores = scalar_matrix<float>(Ncam, T, 0);

	vector<candidate_array<Float> > cand_array(Ncam);
	for(int cam=0; cam<Ncam; ++cam)
	{

	    trlet_list(nn).fscores(cam) = scalar_matrix<float>(np*2, T, 0);

	    float w = detected_rects(cam)(oo, 2)-detected_rects(cam)(oo, 0);
	    float h = detected_rects(cam)(oo, 3)-detected_rects(cam)(oo, 1);
	    row(trlet_list(nn).trj(cam), tt) = row(detected_rects(cam), oo);

	    matrix<float> rects;
	    compute_part_rects(detected_rects(cam)(oo, 0), detected_rects(cam)(oo, 1),
			  w, h, oi.model, rects);

	    pmodel_t pmodel;

	    vector<float> br(row(detected_rects(cam), oo));
	    rects_to_pmodel_geom(br, gi.horiz_mean, pmodel);
	    oi.pmodel_list(cam, nn) = pmodel;

	    //collect_sift(grd(cam), );
	    matrix<float> hist_p, hist_q;
	    collect_hist(images(cam), rects, hist_p, hist_q);
	    trlet_list(nn).hist_p(cam) = hist_p;
	    trlet_list(nn).hist_q(cam) = hist_q;

	    matrix<Float> cand_rects;
	    vector<Float> cand_scale;
	    matrix<int> cand_ijs;

	    if(0==world.rank())
	    {

		std::vector<float> sxr, syr;
		for(float v=-P.xrange/2; v<=P.xrange/2; v+=P.xstep)
		{
		    sxr.push_back(v);
		}
		for(float v=-P.yrange/2; v<=P.yrange/2; v+=P.ystep)
		{
		    syr.push_back(v);
		}
		vector<float> xr(sxr.size()), yr(syr.size());
		std::copy(sxr.begin(), sxr.end(), xr.begin());
		std::copy(syr.begin(), syr.end(), yr.begin());

		float feetx = (trlet_list(nn).trj(cam)(tt, 0)
			       +trlet_list(nn).trj(cam)(tt, 2))/2;
		float feety = trlet_list(nn).trj(cam)(tt, 3);


		enumerate_rects_inpoly(images(cam), oi.pmodel_list(cam, nn),
				       feetx, feety,
				       xr, yr, P.scales, gi.horiz_mean, gi.horiz_sig,
				       gi.polys_im(tt, cam),
				       cand_rects, cand_scale,
				       cand_ijs, cand_array(cam));

	    }

	    mpi::broadcast(world, cand_rects, 0);

	    real_timer_t timer;
	    vector<Float> cand_hist_score(cand_rects.size1());
	    matrix<Float> hist_fscores;

	    range rrank(world.rank()*cand_rects.size1()/world.size(), 
			(world.rank()+1)*cand_rects.size1()/world.size());
	    matrix<Float> cand_rects_rank(project(cand_rects, rrank, range(0, 4)));
	    vector<Float> cand_hist_score_rank;
	    matrix<Float> hist_fscores_rank;
	    get_cand_hist_score(images(cam), oi.model, P.logp1, P.logp2,
				trlet_list(nn).hist_p(cam),
				trlet_list(nn).hist_q(cam),
				cand_rects_rank,
				cand_hist_score_rank, hist_fscores_rank);
	    if(world.rank()==0)
	    {
		std::vector<vector<Float> > v1;
		std::vector<matrix<Float> > v2;
		mpi::gather(world, cand_hist_score_rank, v1, 0);
		mpi::gather(world, hist_fscores_rank, v2, 0);
		hist_fscores = matrix<Float>(cand_rects.size1(),
					     hist_fscores_rank.size2());
		for(int r=0; r<world.size(); ++r)
		{
		    int start = r*cand_rects.size1()/world.size();
		    for(int vv=0; vv<v1[r].size(); ++vv)
		    {
			cand_hist_score(start+vv) = v1[r](vv);
		    }
		    for(int vv=0; vv<v2[r].size1(); ++vv)
		    {
			row(hist_fscores, start+vv) = row(v2[r], vv);
		    }
		}
	    }
	    else
	    {
		mpi::gather(world, cand_hist_score_rank, 0);
		mpi::gather(world, hist_fscores_rank, 0);
	    }

	    mpi::broadcast(world, cand_hist_score, 0);
	    mpi::broadcast(world, hist_fscores, 0);


	    vector<Float> cand_score=cand_hist_score;
	    if(0==world.rank())
	    std::cout<<"\t\t"<<cand_rects.size1()<<" rects, \tget_cand_hist_score time:"
		     <<timer.elapsed()/1000.0f<<"s."<<std::endl;

	    if(0==world.rank())
	    {
		int idx_max = std::max_element(cand_score.begin(), cand_score.end())
		    - cand_score.begin();

		column(trlet_list(nn).fscores(cam), tt) = row(hist_fscores, idx_max);
		trlet_list(nn).scores(cam, tt) = cand_score(idx_max);
		cand_array(cam).fill_score(cand_score, cand_ijs);
	    }
	    mpi::broadcast(world, cand_array(cam), 0);
	    mpi::broadcast(world, trlet_list(nn).scores(cam, tt), 0);
	    vector<Float> fscore_col;
	    if(0==world.rank())
	    {
		fscore_col = column(trlet_list(nn).fscores(cam), tt);
	    }
	    mpi::broadcast(world, fscore_col, 0);
	    if(0!=world.rank())
	    {
		column(trlet_list(nn).fscores(cam), tt) = fscore_col;
	    }


	}//end for cam

	int best_y, best_x, best_s;
	if(0==world.rank())
	{
	    ground_scoremap_t<Float> grd_scoremap;
	    combine_ground_score(tt, cand_array, grd_scoremap, gi);
	    grd_scoremap.peak(best_y, best_x, best_s);	
	}
	mpi::broadcast(world, best_y, 0);
	mpi::broadcast(world, best_x, 0);

	trlet_list(nn).trj_3d(tt, 0) = best_x;
	trlet_list(nn).trj_3d(tt, 1) = best_y;

	for(int cam=0; cam<Ncam; ++cam)
	{
	    vector<Float> trj_row(4);

	    if(0==world.rank())
	    {
		vector<double> bx(1), by(1), ix, iy;
		bx <<= best_x; by <<= best_y;
		apply_homography(gi.grd2img(tt, cam), bx, by, ix, iy);
		float hpre = oi.pmodel_list(cam, nn).hpre;
		float cur_fy = iy(0);
		float cur_fx = ix(0);
		float cur_hy = gi.horiz_mean+hpre*(cur_fy-gi.horiz_mean);
		float ds = P.scales(best_s)*(cur_fy-cur_hy)/oi.pmodel_list(cam, nn).bh;
		float ww = ds*oi.pmodel_list(cam, nn).bw;
		float hh = cur_fy - cur_hy;

		trj_row <<= (cur_fx-ww/2), cur_hy, (cur_fx+ww/2), cur_fy;
	    }
	    mpi::broadcast(world, trj_row, 0);
	    row(trlet_list(nn).trj(cam), tt) = trj_row;


	}//endfor cam

    }//endfor oo

    oi.curr_num_obj += num_new_obj;
}
예제 #13
0
void fpsGain_db(char* opt="", char* year="15sim") {
  TString option(opt), yr(year);  
  TString storeTime; // storetime is begin time for validity range for WRITING DB
  int date,time;     // time for READING DB
  std::cout << "year = " << year << "\n";
  if(yr.Contains("15ofl")){
    storeTime="2014-12-20 00:00:01";
    date = 20141225; time = 0;
  }else if(yr.Contains("15sim")){
    storeTime="2014-12-10 00:00:02";
    date = 20141215; time = 0;
  }else{
    std::cout << "Please specify valid year tag\n"; exit;
  }
  std::cout << "Opt =" << opt << "\n";
  std::cout << "write = " << option.Contains("writedb")   << "\n";
  std::cout << "storetime =" << storeTime << "\n";
  std::cout << "date,time =" << date <<" "<< time << "\n";
  
  gROOT->Macro("loadlib.C");
  
  const Int_t MAX_DB_INDEX = 252;
  fpsGain_st table[MAX_DB_INDEX];

  if(option.Contains("writedb")) {
    gSystem->Setenv("DB_ACCESS_MODE","write");
    StDbManager* mgr = StDbManager::Instance();
    StDbConfigNode* node = mgr->initConfig("Calibrations_fps");
    StDbTable* dbtable = node->addDbTable("fpsGain");
    mgr->setStoreTime(storeTime.Data());
    
    int id=0;
    for (Int_t q = 1; q <= 4; q++) {
      for (Int_t l = 1; l <= 3; l++) {
	for (Int_t s = 1; s <= 21; s++) {
	  table[id].slatid = id; 
	  int flag=0;
	  if(q==2 || q==4){
	    if(s>=20) flag=1;
	  }	    
	  float mip=100.0;
	  if(l==3) mip=50.0;
	  if(flag==0){table[id].slatid = id; table[id].MIP=mip;} 
	  else       {table[id].slatid = id; table[id].MIP=0;} 
	  printf("id=%3d Q%1dL%1dS%2d mip=%f\n",id,q,l,s,table[id].MIP);
	  id++;
	}
      }
    }

    dbtable->SetTable((char*)&table, MAX_DB_INDEX);
    if(yr.Contains("sim")) dbtable->setFlavor("sim");
    mgr->storeDbTable(dbtable);    
    std::cout << "INFO: table saved to database" << std::endl;
  }

  std::cout << "INFO: Reading database" << std::endl;  
  gSystem->Unsetenv("DB_ACCESS_MODE");
  //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG");
  St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
  dbMk->SetDebug();
  dbMk->SetDateTime(date,time); // event or run start time, set to your liking
  if(yr.Contains("ofl"))      {dbMk->SetFlavor("ofl");}
  else if(yr.Contains("sim")) {dbMk->SetFlavor("sim");}
  dbMk->Init();
  dbMk->Make();
  TDataSet *DB = 0;
  DB = dbMk->GetDataBase("Calibrations/fps/fpsGain");
  if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl;
  St_fpsGain *dataset = 0;
  dataset = (St_fpsGain*) DB->Find("fpsGain");
  if (!dataset) {
    td::cout << "ERROR: dataset does not contain requested table" << std::endl;
    return;
  }
  Int_t rows = dataset->GetNRows();
  if (rows > 1) {
    std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl;
  }
  TDatime val[2];
  dbMk->GetValidity((TTable*)dataset,val);
  std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " 
	    << val[1].GetDate() << "." << val[1].GetTime() << " ] "
	    << std::endl;    
  fpsGain_st *tbl = dataset->GetTable();
  for (Int_t i = 0; i < rows; i++) {
    std::cout << Form("Row=%4d slatid=%3d MIP=%8.4f\n",i,
		      tbl[i].slatid,tbl[i].MIP);
  }
}
예제 #14
0
 forceinline
 IntTraceView::IntTraceView(Space& home, IntView y) {
   ViewRanges<IntView> yr(y);
   RangeList::copy(home, dom, yr);
 }
예제 #15
0
void fpsChannelGeometry_db(char* opt="", char* year="15sim") {
  TString option(opt), yr(year);  
  TString storeTime; // storetime is begin time for validity range for WRITING DB
  int date,time;     // time for READING DB
  std::cout << "year = " << year << "\n";
  if(yr.Contains("15ofl")){
    storeTime="2014-12-20 00:00:01";
    date = 20141220; time = 1;
  }else if(yr.Contains("15sim")){
    storeTime="2014-12-10 00:00:01";
    date = 20141210; time = 1;
  }else if (yr.Contains("17ofl")){      
      storeTime="2016-12-20 00:00:00";
      date = 20161220; time = 0;
  }else if(yr.Contains("17sim")){
      storeTime="2016-12-10 00:00:00";
      date = 20161210; time = 0;      
  }else{
    std::cout << "Please specify valid year tag\n"; exit;
  }
  std::cout << "Opt =" << opt << "\n";
  std::cout << "write = " << option.Contains("writedb")   << "\n";
  std::cout << "storetime =" << storeTime << "\n";
  std::cout << "date,time =" << date <<" "<< time << "\n";
  
  gROOT->Macro("loadlib.C");
  
  const Int_t MAX_DB_INDEX = 12;
  fpsChannelGeometry_st table[MAX_DB_INDEX];

  if(option.Contains("writedb")) {
    gSystem->Setenv("DB_ACCESS_MODE","write");
    StDbManager* mgr = StDbManager::Instance();
    StDbConfigNode* node = mgr->initConfig("Geometry_fps");
    StDbTable* dbtable = node->addDbTable("fpsChannelGeometry");
    mgr->setStoreTime(storeTime.Data());

    table[ 0].quad = 1; table[ 0].layer = 1; table[ 0].nslat = 21; 
    table[ 1].quad = 1; table[ 1].layer = 2; table[ 1].nslat = 21; 
    table[ 2].quad = 1; table[ 2].layer = 3; table[ 2].nslat = 21; 
    table[ 3].quad = 2; table[ 3].layer = 1; table[ 3].nslat = 19; 
    table[ 4].quad = 2; table[ 4].layer = 2; table[ 4].nslat = 19; 
    table[ 5].quad = 2; table[ 5].layer = 3; table[ 5].nslat = 19; 
    table[ 6].quad = 3; table[ 6].layer = 1; table[ 6].nslat = 21; 
    table[ 7].quad = 3; table[ 7].layer = 2; table[ 7].nslat = 21; 
    table[ 8].quad = 3; table[ 8].layer = 3; table[ 8].nslat = 21; 
    table[ 9].quad = 4; table[ 9].layer = 1; table[ 9].nslat = 19; 
    table[10].quad = 4; table[10].layer = 2; table[10].nslat = 19; 
    table[11].quad = 4; table[11].layer = 3; table[11].nslat = 19; 

    dbtable->SetTable((char*)&table, MAX_DB_INDEX);
    if(yr.Contains("sim")) dbtable->setFlavor("sim");
    mgr->storeDbTable(dbtable);    
    std::cout << "INFO: table saved to database" << std::endl;
  }

  std::cout << "INFO: Reading database" << std::endl;  
  gSystem->Unsetenv("DB_ACCESS_MODE");
  //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG");
  St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
  dbMk->SetDebug();
  dbMk->SetDateTime(date,time); // event or run start time, set to your liking
  if(yr.Contains("ofl"))      {dbMk->SetFlavor("ofl");}
  else if(yr.Contains("sim")) {dbMk->SetFlavor("sim");}
  dbMk->Init();
  dbMk->Make();
  TDataSet *DB = 0;
  DB = dbMk->GetDataBase("Geometry/fps/fpsChannelGeometry");
  if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl;
  St_fpsChannelGeometry *dataset = 0;
  dataset = (St_fpsChannelGeometry*) DB->Find("fpsChannelGeometry");
  if (!dataset) {
    td::cout << "ERROR: dataset does not contain requested table" << std::endl;
    return;
  }
  Int_t rows = dataset->GetNRows();
  if (rows > 1) {
    std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl;
  }
  TDatime val[2];
  dbMk->GetValidity((TTable*)dataset,val);
  std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " 
	    << val[1].GetDate() << "." << val[1].GetTime() << " ] "
	    << std::endl;    
  fpsChannelGeometry_st *tbl = dataset->GetTable();
  for (Int_t i = 0; i < rows; i++) {
    std::cout << Form("Row=%4d quad=%1d layer=%1d nslat=%2d\n",i,
		      tbl[i].quad,tbl[i].layer,tbl[i].nslat);
  }
}
예제 #16
0
double runGraphicHistos(TString ifile = "tmpfitdirc.root", bool verbose_out=true, double ienergy = 5, int iupdown = 0)
{
	TCanvas *c1 = new TCanvas("myc1","myc1",1000,1200);

	if (verbose_out == false)
	{
		//supresses canvas message 
		//gErrorIgnoreLevl=kInfo;
		gROOT->ProcessLine( "gErrorIgnoreLevel = kWarning;");
	}

	double hmin = -100;
	double hmax = 100;

	hmin = -25;
	hmax = 25;

	double energy = ienergy;

	double pi_mass = .13957;
	double k_mass = .49367;

	double pi_beta = sqrt(1-pi_mass*pi_mass/(energy*energy));
	double k_beta = sqrt(1-k_mass*k_mass/(energy*energy));

	double quartz_index = 1.47;

	double pi_mrad = 1000*acos(1/(pi_beta*quartz_index));
	double k_mrad = 1000*acos(1/(k_beta*quartz_index));

	//double seperation = 5.2;
	double seperation = pi_mrad - k_mrad;
	double mean_pion = 0;
	double mean_kaon = mean_pion + seperation;
	if (verbose_out == true)
	{
		printf("Energy: %4.02f\n",energy);
		printf("Mrad Seperation: %8.03f\n",seperation);
	}
	//denominator pf spread

	TRandom3* randgen = new TRandom3();

	TFile *f1 = new TFile(ifile);
	TH1F *hpion;
	TH1F *hkaon;
	TH1F *phots_pion;
	if (iupdown == 0)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon");
		phots_pion = (TH1F*) f1->Get("phot_found_pion");
	}
	else if (iupdown == 1)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion_up");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon_up");
		phots_pion = (TH1F*) f1->Get("phot_found_pion_up");
	}
	else if (iupdown == -1)
	{
		hpion = (TH1F*) f1->Get("ll_diff_pion_down");
		hkaon = (TH1F*) f1->Get("ll_diff_kaon_down");
		phots_pion = (TH1F*) f1->Get("phot_found_pion_down");
	}
	else
	{
		printf("Unrecognize updown arguement: %d \nFailing....\n",iupdown);
		return -1;
	}
	if (verbose_out == true)
	{
		printf("pion_ll mean, spread: %12.04f, %12.04f\n",hpion->GetMean(),hpion->GetRMS());
		printf("kaon_ll mean, spread: %12.04f, %12.04f\n",hkaon->GetMean(),hkaon->GetRMS());
	}
	double spread = seperation/2;
	double spreadsq2 = 2*spread*spread;
	//Swap kaon and pion numbers

	for (int i = 1; i < hpion->GetNbinsX()/2; i++)
	{
		double t_swap = hpion->GetBinContent(i);
		hpion->SetBinContent(i,hpion->GetBinContent(hpion->GetNbinsX() - i + 1));
		hpion->SetBinContent(hpion->GetNbinsX() - i + 1, t_swap);
	}
	for (int i = 1; i < hkaon->GetNbinsX()/2; i++)
	{
		double t_swap = hkaon->GetBinContent(i);
		hkaon->SetBinContent(i,hkaon->GetBinContent(hkaon->GetNbinsX() - i + 1));
		hkaon->SetBinContent(hkaon->GetNbinsX() - i + 1, t_swap);
	}

	double titlesize=1.2*.04;

	int rebin = 20;
	rebin = 160;
	hpion->Rebin(rebin);
	hkaon->Rebin(rebin);

	hpion->SetAxisRange(hmin,hmax);
	hkaon->SetAxisRange(hmin,hmax);

	hkaon->GetXaxis()->SetTitle("Loglikelihood difference");
	hkaon->GetYaxis()->SetTitle("A.U.");
	hkaon->GetXaxis()->SetTitleSize(titlesize);
	hkaon->GetYaxis()->SetTitleSize(titlesize);

	hpion->SetStats(false);
	hkaon->SetStats(false);

	hpion->SetLineColor(kCyan);
	//hpion->SetFillColorAlpha(kRed,.5);

	hkaon->SetLineColor(kBlue);
	//hkaon->SetFillColorAlpha(kBlue,.5);

	TLegend *leg_ll = new TLegend(.6,.6,.8,.8);
	leg_ll->AddEntry(hpion,"Pion");
	leg_ll->AddEntry(hkaon,"Kaon");
	leg_ll->SetBorderSize(0);


	hkaon->SetTitle("log(P(Pi)/P(K)) for actual Pi (red) and K (blue) at 5 GeV");



	TH1F *pion_veto_eff = new TH1F(*hpion);
	TH1F *kaon_missid = new TH1F(*hkaon);

	pion_veto_eff->SetName("pion_veto_eff");
	pion_veto_eff->SetTitle("");

	kaon_missid->SetName("kaon_missid");
	kaon_missid->SetTitle("");



	for (int i = 0; i < pion_veto_eff->GetNbinsX(); i++)
	{
		pion_veto_eff->SetBinContent(i,hpion->Integral(0,i));
		kaon_missid->SetBinContent(i,hkaon->Integral(i,kaon_missid->GetNbinsX()));
		//	printf("%12.04f %12.04f %d\n",1,1,i);
	}

	pion_veto_eff->SetAxisRange(0,10000,"Y");

	double scale_int = 1/hpion->Integral(0,pion_veto_eff->GetNbinsX());
	pion_veto_eff->Scale(scale_int);
	scale_int = 1/hkaon->Integral(0,kaon_missid->GetNbinsX());
	kaon_missid->Scale(scale_int);

	hkaon->SetTitle("");
	hpion->SetTitle("");


	if (verbose_out == true)
	{
		hkaon->Draw();
		hpion->Draw("SAME H");
		leg_ll->Draw("SAME");
		c1->SetWindowSize(1000,800);

		c1->Print("overlap.pdf");
	}

	if (verbose_out == true)
	{
		pion_veto_eff->Draw("");
		kaon_missid->Draw("SAME H");

		c1->SetWindowSize(1000,800);
		c1->Print("overlap_integral.pdf");
	}

	double linewidth=6;
	TGraph* roc_graph;
	int roc_n = pion_veto_eff->GetNbinsX();
	TVectorF xr(roc_n);//gross
	TVectorF yr(roc_n);
	double ival = 0;

	for (int i = 0; i < pion_veto_eff->GetNbinsX(); i++)
	{
		xr[i] = pion_veto_eff->GetBinContent(i);
		yr[i] = kaon_missid->GetBinContent(i);

		//	printf("%8.04f %8.04f\n",xr[i],yr[i]);	
	}

	double y1,y2,x1,x2;
	x1 = pion_veto_eff->GetBinContent(0);
	double last_x = pion_veto_eff->GetBinContent(0);
	double last_y = kaon_missid->GetBinContent(0);

	for (int i = 0; i < pion_veto_eff->GetNbinsX()-1; i++)
	{
		ival += (yr[i]+last_y)*(xr[i] - last_x)/2;
                //printf("%6d %12.09f %12.04f %12.04f %12.04f %12.04f\n",i,ival,xr[i],yr[i],last_x,last_y);
		last_x = xr[i];
		last_y = yr[i];
		
	}

	if (verbose_out == true)
	{
		printf("ROC integral: %12.04f\n",ival);
	}

	roc_graph = new TGraph(xr,yr);
	roc_graph->SetLineColor(2);
	roc_graph->SetLineWidth(4);
	//roc_graph->SetMarkerColor(4);
	//roc_graph->SetMarkerStyle(21);
	roc_graph->SetTitle("");
	roc_graph->GetXaxis()->SetTitle("Kaon Efficiency");
	roc_graph->GetYaxis()->SetTitle("Pion Rejection");
	roc_graph->GetXaxis()->SetTitleSize(titlesize);
	roc_graph->GetYaxis()->SetTitleSize(titlesize);
	roc_graph->GetXaxis()->SetLimits(0,1.01);
	roc_graph->SetMinimum(0);
	roc_graph->SetMaximum(1.01);
	roc_graph->SetLineWidth(linewidth);

	if (verbose_out == true)
	{
		roc_graph->Draw("ACP");
		c1->Print("roc_curve.gif");
	}
	spread = find_sig_val(seperation,ival,spread); 


	//FAKE version stuff below
	/*---------------------------------------------------------------------------------------------------------------------------*/




	TH1F *fhpion = (TH1F*) f1->Get("ll_diff_pion");
	TH1F *fhkaon = (TH1F*) f1->Get("ll_diff_kaon");

	fhpion->Reset();
	fhkaon->Reset();

	fhpion->SetBins(1000,hmin,hmax);
	fhkaon->SetBins(1000,hmin,hmax);

	double pion_obs, kaon_obs;
	double pion_ll_diff, kaon_ll_diff;

	for (int ii = 0; ii < 10000; ii++)
	{
		pion_obs = randgen->Gaus(mean_pion,spread);
		kaon_obs = randgen->Gaus(mean_kaon,spread);

		pion_ll_diff = -1*(pion_obs - mean_pion)*(pion_obs - mean_pion);
		pion_ll_diff += (pion_obs - mean_kaon)*(pion_obs - mean_kaon);
		pion_ll_diff /= spreadsq2;

		kaon_ll_diff = - (kaon_obs - mean_pion)*(kaon_obs - mean_pion);
		kaon_ll_diff += (kaon_obs - mean_kaon)*(kaon_obs - mean_kaon);
		kaon_ll_diff /= spreadsq2;

		fhpion->Fill(pion_ll_diff);
		fhkaon->Fill(kaon_ll_diff);
	}


	fhpion->SetAxisRange(hmin,hmax);
	fhkaon->SetAxisRange(hmin,hmax);

	fhpion->SetLineColor(kRed);
	//hpion->SetFillColorAlpha(kRed,.5);

	fhkaon->SetLineColor(kBlue);
	//hkaon->SetFillColorAlpha(kBlue,.5);

	fhkaon->SetTitle("");

	TH1F *fpion_veto_eff = new TH1F(*fhpion);
	TH1F *fkaon_missid = new TH1F(*fhkaon);

	fpion_veto_eff->SetName("pion_veto_eff");
	fpion_veto_eff->SetTitle("");

	fkaon_missid->SetName("kaon_missid");
	fkaon_missid->SetTitle("");

	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{
		fpion_veto_eff->SetBinContent(i,fhpion->Integral(i,fpion_veto_eff->GetNbinsX()));
		fkaon_missid->SetBinContent(i,fhkaon->Integral(0,i));
	}

	fpion_veto_eff->SetAxisRange(0,10000,"Y");

	double fscale_int = 1/fhpion->Integral(0,fpion_veto_eff->GetNbinsX());
	fpion_veto_eff->Scale(fscale_int);
	fscale_int = 1/fhkaon->Integral(0,fkaon_missid->GetNbinsX());
	fkaon_missid->Scale(fscale_int);




	TGraph* froc_graph;
	int froc_n = fpion_veto_eff->GetNbinsX();
	TVectorF fxr(froc_n);
	TVectorF fyr(froc_n);

	double fival = 0;
	double flast_x = fpion_veto_eff->GetBinContent(0);
	double flast_y = fkaon_missid->GetBinContent(0);
	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{
		fxr[i] = fpion_veto_eff->GetBinContent(i);
		fyr[i] = fkaon_missid->GetBinContent(i);


		fival -= (fyr[i]+flast_y)*(fxr[i] - flast_x)/2;
		flast_x = fxr[i];
		flast_y = fyr[i];
	}
	ival = 0;
	flast_x = fpion_veto_eff->GetBinContent(0);
	flast_y = fkaon_missid->GetBinContent(0);
	for (int i = 0; i < fpion_veto_eff->GetNbinsX(); i++)
	{

		//Why oh why is Erf not the standard definition
		double t = hmin + i*(hmax-hmin)/fpion_veto_eff->GetNbinsX();
		fxr[i] = .5 + TMath::Erf(t/(sqrt(2)*spread))/2;
		fyr[i] = .5 - TMath::Erf((t-seperation)/(sqrt(2)*spread))/2;

		fival -= (fyr[i]+flast_y)*(fxr[i] - flast_x)/2;
		flast_x = fxr[i];
		flast_y = fyr[i];
	}	
	//printf("Fake ROC integral: %12.04f\n",fival);


	froc_graph = new TGraph(fxr,fyr);
	if (verbose_out == true)
	{
		froc_graph->SetLineColor(4);
		froc_graph->SetLineWidth(linewidth);
		froc_graph->SetLineStyle(2);
		froc_graph->SetTitle("");
		froc_graph->GetXaxis()->SetTitle("\"Kaon Efficiency\"");
		froc_graph->GetYaxis()->SetTitle("\"Pion Rejection\"");
		froc_graph->GetXaxis()->SetTitleSize(titlesize);
		froc_graph->GetYaxis()->SetTitleSize(titlesize);
		froc_graph->GetXaxis()->SetLimits(0,1.01);
		froc_graph->SetMinimum(0);
		froc_graph->SetMaximum(1.01);


		roc_graph->SetFillColorAlpha(kWhite,1);
		froc_graph->SetFillColorAlpha(kWhite,1);
		TLegend *leg_roc = new TLegend(.3,.5,.7,.7);
		leg_roc->AddEntry(roc_graph,"ROC Curve");
		leg_roc->AddEntry(froc_graph,"Matched Gaussian ROC Curve");
		leg_roc->SetBorderSize(0);
		leg_roc->SetTextSize(0.04*1.1);

		froc_graph->Draw("SAME");
		leg_roc->Draw("SAME");
		c1->Print("roc_curve_overlay.pdf");
	}



	if (verbose_out == true)
	{
		printf("Matching resolution: %6.03f\n",spread);
		printf("Matching resolution per photon: %6.03f\n",spread*sqrt(phots_pion->GetMean()));
	}
	else
	{
		printf("%6.04f\n",spread);
	}
	return spread;

}
예제 #17
0
Transformation Boonas:: parseParams(int start, int argc, char** argv, Transformation matrix) 
{
	QString currIn;
	
	for(int i = start; i < (argc - 1); i += 2) // iterate through parameters skiping every other
	{
		if(strcmp(argv[i], "XT") == 0)
		{
			currIn = argv[i + 1];
			matrix = xt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YT") == 0)
		{
			currIn = argv[i + 1];
			matrix = yt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZT") == 0)
		{
			currIn = argv[i + 1];
			matrix = zt(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XS") == 0)
		{
			currIn = argv[i + 1];
			matrix = xs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YS") == 0)
		{
			currIn = argv[i + 1];
			matrix = ys(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZS") == 0)
		{
			currIn = argv[i + 1];
			matrix = zs(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "US") == 0)
		{
			currIn = argv[i + 1];
			matrix = us(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XD") == 0)
		{
			currIn = argv[i + 1];
			matrix = xd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YD") == 0)
		{
			currIn = argv[i + 1];
			matrix = yd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "ZD") == 0)
		{
			currIn = argv[i + 1];
			matrix = zd(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "XR") == 0)
		{
			currIn = argv[i + 1];
			matrix = xr(currIn.toFloat(), matrix);
		}
		else if(strcmp(argv[i], "YR") == 0)
		{
			currIn = argv[i + 1];
			matrix = yr(currIn.toFloat(), matrix);
		}
		else // MUST BE ZR
		{
			currIn = argv[i + 1];
			matrix = zr(currIn.toFloat(), matrix);
		}
	}
	
	return matrix;
}
예제 #18
0
void fpsMap_db(char* opt="", char* year="15sim", char* input="fpsmap.txt") {
  TString option(opt), yr(year);  
  TString storeTime; // storetime is begin time for validity range for WRITING DB
  int date,time;     // time for READING DB
  std::cout << "year = " << year << "\n";
  if(yr.Contains("15ofl")){
    storeTime="2014-12-20 00:00:3";
    date = 20141221; time = 0;
  }else if(yr.Contains("15sim")){
    storeTime="2014-12-10 00:00:01";
    date = 20141210; time = 1;
  }else if(yr.Contains("17ofl")){
      storeTime="2016-12-20 00:00:00";
      date = 20161220; time = 0;
  }else if(yr.Contains("17sim")){
      storeTime="2016-12-10 00:00:00";
      date = 20161210; time = 0;
  }else{
    std::cout << "Please specify valid year tag\n"; exit;
  }
  std::cout << "Opt =" << opt << "\n";
  std::cout << "write = " << option.Contains("writedb")   << "\n";
  std::cout << "storetime =" << storeTime << "\n";
  std::cout << "date,time =" << date <<" "<< time << "\n";
  
  gROOT->Macro("./loadlib.C");
  
  const Int_t MAX_DB_INDEX = 252;
  fpsMap_st in[MAX_DB_INDEX];
  for(int i=0; i<MAX_DB_INDEX; i++){
    in[i].slatid=i;
    in[i].QTaddr=-1;
    in[i].QTch=-1;
  }
  
  FILE *FP = fopen(input,"r");
  if(!FP) { printf("Could not open %s\n",input); exit;}
  printf("Reading %s\n",input);
  char line[1000], nw[10], dc[10], posi[10];
  int id,q,l,s,sipm,sipmbd,feebd,tbox,tgrp,qtaddr,qtch,cbl;
  int n=0;
  while(fgets(line,1000,FP)!=NULL){
    sscanf(line,"%d %d %d %d %d %s %d %d %d %d",
	   &id,&q,&l,&s,
	   &sipm,nw,
	   &tbox,&tgrp,
	   &qtaddr,&qtch);
    //printf("Id=%3d Q=%3d L=%3d S=%3d QTaddr=%1d QTch=%2d\n",id,q,l,s,qtaddr,qtch);
    in[id].QTaddr=qtaddr;
    in[id].QTch=qtch;
    n++;
  }    
  for(int i=0; i<MAX_DB_INDEX; i++){
    printf("Id=%3d QTaddr=%1d QTch=%2d\n",in[i].slatid,in[i].QTaddr,in[i].QTch);
  }
  printf("Found %d entries\n",n);
  
  if(option.Contains("writedb")) {
    gSystem->Setenv("DB_ACCESS_MODE","write");
    StDbManager* mgr = StDbManager::Instance();
    StDbConfigNode* node = mgr->initConfig("Geometry_fps");
    StDbTable* dbtable = node->addDbTable("fpsMap");
    mgr->setStoreTime(storeTime.Data());    
    dbtable->SetTable((char*)&in, MAX_DB_INDEX);
    if(yr.Contains("sim")) dbtable->setFlavor("sim");
    mgr->storeDbTable(dbtable);    
    std::cout << "INFO: table saved to database" << std::endl;
  }
  
  std::cout << "INFO: Reading database" << std::endl;  
  gSystem->Unsetenv("DB_ACCESS_MODE");
  //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG");
  St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
  dbMk->SetDebug();
  dbMk->SetDateTime(date,time); // event or run start time, set to your liking
  if(yr.Contains("ofl"))      {dbMk->SetFlavor("ofl");}
  else if(yr.Contains("sim")) {dbMk->SetFlavor("sim");}
  dbMk->Init();
  dbMk->Make();
  TDataSet *DB = 0;
  DB = dbMk->GetDataBase("Geometry/fps/fpsMap");
  if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl;
  St_fpsMap *dataset = 0;
  dataset = (St_fpsMap*) DB->Find("fpsMap");
  if (!dataset) {
    td::cout << "ERROR: dataset does not contain requested table" << std::endl;
    return;
  }
  Int_t rows = dataset->GetNRows();
  if (rows > 1) {
    std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl;
  }
  TDatime val[2];
  dbMk->GetValidity((TTable*)dataset,val);
  std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " 
	    << val[1].GetDate() << "." << val[1].GetTime() << " ] "
	    << std::endl;    
  fpsMap_st *table = dataset->GetTable();
  for (Int_t i = 0; i < rows; i++) {
    std::cout << Form("Row=%4d slatid=%3d QTaddr=%2d QTch=%2d\n",i,
		      table[i].slatid,
		      table[i].QTaddr,table[i].QTch);
  }
}
예제 #19
0
파일: re-prop.hpp 프로젝트: MGKhKhD/easy-IP
  ExecStatus
  ReProp<View,rm>::propagate(Space& home, const ModEventDelta& med) {
    // Add assigned views to value set
    if (View::me(med) == ME_INT_VAL)
      add(home,vs,x);

    if (b.one()) {
      if (rm == RM_PMI)
        return home.ES_SUBSUMED(*this);
      ValSet vsc(vs);
      vs.flush();
      GECODE_REWRITE(*this,Prop<View>::post(home,vsc,x,y));
    }

    if (b.zero()) {
      if (rm != RM_IMP) {
        ValSet::Ranges vsr(vs);
        GECODE_ME_CHECK(y.minus_r(home,vsr,false));
        for (int i=x.size(); i--; )
          GECODE_ES_CHECK(Rel::Nq<View>::post(home,x[i],y));
      }
      return home.ES_SUBSUMED(*this);
    }

    // Eliminate views from x
    eliminate(home);
    
    switch (vs.compare(y)) {
    case Iter::Ranges::CS_SUBSET:
      if (rm != RM_IMP)
        GECODE_ME_CHECK(b.one(home));
      return home.ES_SUBSUMED(*this);
    case Iter::Ranges::CS_DISJOINT:
      if (x.size() == 0) {
        if (rm != RM_PMI)
          GECODE_ME_CHECK(b.zero(home));
        return home.ES_SUBSUMED(*this);
      }
      break;
    case Iter::Ranges::CS_NONE:
      break;
    default:
      GECODE_NEVER;
    }

    // Check whether y is in union of x and value set
    if (x.size() > 0) {
      Region r(home);

      ValSet::Ranges vsr(vs);
      ViewRanges<View> xsr(x[x.size()-1]);
      Iter::Ranges::NaryUnion  u(r,vsr,xsr);
      for (int i=x.size()-1; i--; ) {
        ViewRanges<View> xir(x[i]);
        u |= xir;
      }

      ViewRanges<View> yr(y);
      
      if (Iter::Ranges::disjoint(u,yr)) {
        if (rm != RM_PMI)
          GECODE_ME_CHECK(b.zero(home));
        return home.ES_SUBSUMED(*this);
      }
    }

    return ES_FIX;
  }
예제 #20
0
void Tri2dFCBlockSolver::gradSetupQuadratic()
{
  // form quadratic sub elements
  int nElemQ = 3*nElem;
  int nneQ   = 6; //quadratic elements
  int nngQ   = 4; //quadratic elements
  Array2D<int> elemQ(nElemQ,nneQ),gNode(nElemQ,nngQ);
  int m=0;
  for (int n=0; n<nElem; n++){
    elemQ(m  ,0) = elem(n,0);
    elemQ(m  ,1) = elem(n,4);
    elemQ(m  ,2) = elem(n,7);
    elemQ(m  ,3) = elem(n,3);
    elemQ(m  ,4) = elem(n,9);
    elemQ(m  ,5) = elem(n,8);
    gNode(m  ,0) = 0;
    gNode(m  ,1) = 3;
    gNode(m  ,2) = 4;
    gNode(m++,3) = 5;
    elemQ(m  ,0) = elem(n,3);
    elemQ(m  ,1) = elem(n,1);
    elemQ(m  ,2) = elem(n,6);
    elemQ(m  ,3) = elem(n,4);
    elemQ(m  ,4) = elem(n,5);
    elemQ(m  ,5) = elem(n,9);
    gNode(m  ,0) = 1;
    gNode(m  ,1) = 4;
    gNode(m  ,2) = 5;
    gNode(m++,3) = 3;
    elemQ(m  ,0) = elem(n,8);
    elemQ(m  ,1) = elem(n,5);
    elemQ(m  ,2) = elem(n,2);
    elemQ(m  ,3) = elem(n,9);
    elemQ(m  ,4) = elem(n,6);
    elemQ(m  ,5) = elem(n,7);
    gNode(m  ,0) = 2;
    gNode(m  ,1) = 5;
    gNode(m  ,2) = 3;
    gNode(m++,3) = 4;
  }

  /*
  for (int n=0; n<nElemQ; n++){
    cout << n << " ";
    for (int j=0; j<nneQ; j++) cout << elemQ(n,j) << " ";
    cout << endl;
  }
  exit(0);
  */


  // Jacobian terms
  Array2D <double> xr(nElemQ,nngQ),yr(nElemQ,nngQ),xs(nElemQ,nngQ),
    ys(nElemQ,nngQ),jac(nElemQ,nngQ),rs(nneQ,3),lc(nneQ,nneQ);
  xr.set(0.);
  yr.set(0.);
  xs.set(0.);
  ys.set(0.);
  jac.set(0.);

  int orderE=2; //quadratic elements 
  solutionPoints(orderE,
		 spacing,
		 &rs(0,0));

  bool test=true;
  lagrangePoly(test,
	       orderE,
	       &rs(0,0),
	       &lc(0,0));

  int j,km,lm;
  double lrm,lsm,ri,si;
  for (int n=0; n<nElemQ; n++){

    // evaluate the Jacobian terms at the mesh points
    for (int i=0; i<nngQ; i++){ //ith mesh point
      ri = rs(gNode(n,i),0);
      si = rs(gNode(n,i),1);
      for (int m=0; m<nneQ; m++){ //mth Lagrange polynomial
	j   = 0;
	lrm = 0.;
	lsm = 0.;
	for (int k=0; k<=orderE; k++)
	  for (int l=0; l<=orderE-k; l++){
	    km   = max(0,k-1);
	    lm   = max(0,l-1);
	    lrm +=((double)k)*pow(ri,km)*pow(si,l )*lc(m,j  );
	    lsm +=((double)l)*pow(ri,k )*pow(si,lm)*lc(m,j++);
	  }
	xr(n,i) += lrm*x(elemQ(n,m),0);
	yr(n,i) += lrm*x(elemQ(n,m),1);
	xs(n,i) += lsm*x(elemQ(n,m),0);
	ys(n,i) += lsm*x(elemQ(n,m),1);
      }
      jac(n,i) = xr(n,i)*ys(n,i)-yr(n,i)*xs(n,i);
    }}


  // lr(i,j) = (dl_j/dr)_i (a row is all Lagrange polynomials (derivatives)
  // evaluated at a single mesh point i, same with the other derivatives)
  Array2D<double> lr(nneQ,nneQ),ls(nneQ,nneQ),lrr(nneQ,nneQ),
    lss(nneQ,nneQ),lrs(nneQ,nneQ);
  lr.set(0.);
  ls.set(0.);
  lrr.set(0.);
  lss.set(0.);
  lrs.set(0.);
  int kmm,lmm;
  for (int n=0; n<nneQ; n++) // nth Lagrange polynomial
    for (int i=0; i<nneQ; i++){ // ith mesh point
      j  = 0;
      ri = rs(i,0);
      si = rs(i,1);
      for (int k=0; k<=orderE; k++)
	for (int l=0; l<=orderE-k; l++){
	  km        = max(0,k-1);
	  lm        = max(0,l-1);
	  kmm       = max(0,k-2);
	  lmm       = max(0,l-2);
	  lr (i,n) +=((double)k)*pow(ri,km)*pow(si,l )*lc(n,j);
	  ls (i,n) +=((double)l)*pow(ri,k )*pow(si,lm)*lc(n,j);
	  lrr(i,n) +=((double)(k*km))*pow(ri,kmm)*pow(si,l  )*lc(n,j  );
	  lss(i,n) +=((double)(l*lm))*pow(ri,k  )*pow(si,lmm)*lc(n,j  );
	  lrs(i,n) +=((double)(k*l ))*pow(ri,km )*pow(si,lm )*lc(n,j++);
	}}


  // compute averaged quadratic FEM gradient coefficients
  Array1D<double> sumj(nNode);
  sumj.set(0.);
  for (int n=0; n<nElemQ; n++)
    for (int i=0; i<nngQ; i++){
      m                 = gNode(n,i);
      sumj(elemQ(n,m)) += jac(n,i);
    }
  for (int n=0; n<nNode; n++) sumj(n) = 1./sumj(n);

  int k1,k2;
  double xri,yri,xsi,ysi;
  Array2D<double> ax(nNode,2);
  ax.set(0.);
  gxQ.set(0.);
  for (int n=0; n<nElemQ; n++)
    for (int i=0; i<nngQ; i++){
      m   = gNode(n,i);
      k1  = elemQ(n,m);
      xri = xr(n,i);
      yri = yr(n,i);
      xsi = xs(n,i);
      ysi = ys(n,i);
      for (int j=0; j<nneQ; j++){
	k2       = elemQ(n,j);
	ax(k2,0) = lr(m,j)*ysi-ls(m,j)*yri;
	ax(k2,1) =-lr(m,j)*xsi+ls(m,j)*xri;
      }
      for(int j=psp2(k1); j<psp2(k1+1); j++){
	k2        = psp1(j);
	gxQ(j,0) += ax(k2,0);
	gxQ(j,1) += ax(k2,1);
      }
      for (int j=0; j<nneQ; j++){
	k2       = elemQ(n,j);
	ax(k2,0) = 0.;
	ax(k2,1) = 0.;
      }}

  for (int n=0; n<nNode; n++)
    for (int i=psp2(n); i<psp2(n+1); i++){
      gxQ(i,0) *= sumj(n);
      gxQ(i,1) *= sumj(n);
    }


  // deallocate work arrays
  elemQ.deallocate();
  gNode.deallocate();
  xr.deallocate();
  yr.deallocate();
  xs.deallocate();
  ys.deallocate();
  jac.deallocate();
  rs.deallocate();
  lc.deallocate();
  lr.deallocate();
  ls.deallocate();
  lrr.deallocate();
  lss.deallocate();
  lrs.deallocate();
  sumj.deallocate();
  ax.deallocate();
}
예제 #21
0
void initialize_new_objects(parameter_t const& P,  directory_structure_t const& ds,
			    geometric_info_t const& gi, object_info_t& oi,
			    vector<std::vector<std::string> > const &seq, int tt,
			    vector<CImg<unsigned char> > const& images,
			    vector<matrix<float> > const& grd,
			    vector<matrix<float> >& detected_rects)
{
    int Ncam = seq.size();
    vector<object_trj_t> & trlet_list=oi.trlet_list;
    int nobj = trlet_list.size();
    int num_new_obj = detected_rects(0).size1();
    int T = seq[0].size();
    int np = oi.model.size();

    int num_scales = P.scales.size();

    for(int oo=0; oo<num_new_obj; ++oo)
    {
	int nn = oi.curr_num_obj + oo;


	trlet_list(nn).startt = tt;
	trlet_list(nn).endt = tt;
	trlet_list(nn).state = 1;
	trlet_list(nn).trj = vector<matrix<float> >(Ncam);
	for(int cam=0; cam<Ncam; ++cam)
	{
	    trlet_list(nn).trj(cam) = scalar_matrix<float>(T, 4, 0);
	}
	trlet_list(nn).trj_3d = scalar_matrix<float>(T, 2, 0);

	trlet_list(nn).hist_p = vector<matrix<float> >(Ncam);
	trlet_list(nn).hist_q = vector<matrix<float> >(Ncam);

	trlet_list(nn).fscores = vector<matrix<float> >(Ncam);
	trlet_list(nn).scores = scalar_matrix<float>(Ncam, T, 0);

	vector<candidate_array<Float> > cand_array(Ncam);

	for(int cam=0; cam<Ncam; ++cam)
	{

	    trlet_list(nn).fscores(cam) = scalar_matrix<float>(np*2, T, 0);

	    float w = detected_rects(cam)(oo, 2)-detected_rects(cam)(oo, 0);
	    float h = detected_rects(cam)(oo, 3)-detected_rects(cam)(oo, 1);
	    row(trlet_list(nn).trj(cam), tt) = row(detected_rects(cam), oo);

	    matrix<float> rects;
	    compute_part_rects(detected_rects(cam)(oo, 0), detected_rects(cam)(oo, 1),
			  w, h, oi.model, rects);

	    pmodel_t pmodel;

	    vector<float> br(row(detected_rects(cam), oo));
	    rects_to_pmodel_geom(br, gi.horiz_mean, pmodel);
	    oi.pmodel_list(cam, nn) = pmodel;

	    //collect_sift(grd(cam), );
	    matrix<float> hist_p, hist_q;
	    collect_hist(images(cam), rects, hist_p, hist_q);
	    trlet_list(nn).hist_p(cam) = hist_p;
	    trlet_list(nn).hist_q(cam) = hist_q;


	    std::vector<float> sxr, syr;
	    for(float v=-P.xrange/2; v<=P.xrange/2; v+=P.xstep)
	    {
		sxr.push_back(v);
	    }
	    for(float v=-P.yrange/2; v<=P.yrange/2; v+=P.ystep)
	    {
		syr.push_back(v);
	    }
	    vector<float> xr(sxr.size()), yr(syr.size());
	    std::copy(sxr.begin(), sxr.end(), xr.begin());
	    std::copy(syr.begin(), syr.end(), yr.begin());

	    float feetx = (trlet_list(nn).trj(cam)(tt, 0)
			   +trlet_list(nn).trj(cam)(tt, 2))/2;
	    float feety = trlet_list(nn).trj(cam)(tt, 3);

	    matrix<Float> cand_rects;
	    vector<Float> cand_scale;
	    matrix<int> cand_ijs;

	    enumerate_rects_inpoly(images(cam), oi.pmodel_list(cam, nn),
				   feetx, feety,
				   xr, yr, P.scales, gi.horiz_mean, gi.horiz_sig,
				   gi.polys_im(cam),
				   cand_rects, cand_scale,
				   cand_ijs, cand_array(cam));


	    vector<Float> cand_hist_score;
	    matrix<Float> hist_fscores;

	    real_timer_t timer;
	    get_cand_hist_score(images(cam), oi.model, P.logp1, P.logp2,
				trlet_list(nn).hist_p(cam),
				trlet_list(nn).hist_q(cam),
				cand_rects,
				cand_hist_score, hist_fscores);

	    vector<Float> cand_score=cand_hist_score;
	    std::cout<<"\t\t"<<cand_rects.size1()<<" rects, \tget_cand_hist_score time:"
		     <<timer.elapsed()/1000.0f<<"s."<<std::endl;

	    int idx_max = std::max_element(cand_score.begin(), cand_score.end())
		- cand_score.begin();

	    column(trlet_list(nn).fscores(cam), tt) = row(hist_fscores, idx_max);
	    trlet_list(nn).scores(cam, tt) = cand_score(idx_max);
	    cand_array(cam).fill_score(cand_score, cand_ijs);


	}//end for cam

	real_timer_t timer;

	ground_scoremap_t<Float> grd_scoremap;
	combine_ground_score(cand_array, grd_scoremap, gi);
	int best_y, best_x, best_s;

	grd_scoremap.peak(best_y, best_x, best_s);	


	for(int cam=0; cam<Ncam; ++cam)
	{
	    vector<double> bx(1), by(1), ix, iy;
	    bx <<= best_x; by <<= best_y;
	    apply_homography(gi.grd2img(cam), bx, by, ix, iy);
	    float hpre = oi.pmodel_list(cam, nn).hpre;
	    float cur_fy = iy(0);
	    float cur_fx = ix(0);
	    float cur_hy = gi.horiz_mean+hpre*(cur_fy-gi.horiz_mean);
	    float ds = P.scales(best_s)*(cur_fy-cur_hy)/oi.pmodel_list(cam, nn).bh;
	    float ww = ds*oi.pmodel_list(cam, nn).bw;
	    float hh = cur_fy - cur_hy;

	    vector<Float> tmp(4);
	    tmp <<= (cur_fx-ww/2), cur_hy, (cur_fx+ww/2), cur_fy;
	    row(trlet_list(nn).trj(cam), tt) = tmp;

	    //std::cout<<"trlet_list(nn).trj(cam)(tt, :)="
	    //     <<row(trlet_list(nn).trj(cam), tt)<<std::endl;

	}//endfor cam

    }//endfor oo

    oi.curr_num_obj += num_new_obj;
}
static void test_quant_solve1() {
    ast_manager m;
    arith_util ar(m);
    reg_decl_plugins(m);
    sort* i = ar.mk_int();
    app_ref xr(m.mk_const(symbol("x"),i), m);
    app_ref yr(m.mk_const(symbol("y"),i), m);
    app* x = xr.get();
    app* y = yr.get();
    app* xy[2] = { x, y };


    test_quant_solver(m, x, "(and (<= x y) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(and (<= (* 2 x) y) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(and (>= x y) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(and (>= (* 2 x) y) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(and (<= (* 2 x) y) (>= x z) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(and (<= (* 2 x) y) (>= (* 3 x) z) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(>= (* 2 x) a)");
    test_quant_solver(m, x, "(<= (* 2 x) a)");
    test_quant_solver(m, x, "(< (* 2 x) a)");
    test_quant_solver(m, x, "(= (* 2 x) a)");
    test_quant_solver(m, x, "(< (* 2 x) a)");
    test_quant_solver(m, x, "(> (* 2 x) a)");
    test_quant_solver(m, x, "(and (<= a x) (<= (* 2 x) b))");
    test_quant_solver(m, x, "(and (<= a x) (<= x b))");
    test_quant_solver(m, x, "(and (<= (* 2 a) x) (<= x b))");
    test_quant_solver(m, x, "(and (<= (* 2 a) x) (<= (* 2 x) b))");
    test_quant_solver(m, x, "(and (<= a x) (<= (* 3 x) b))");
    test_quant_solver(m, x, "(and (<= (* 3 a) x) (<= x b))");
    test_quant_solver(m, x, "(and (<= (* 3 a) x) (<= (* 3 x) b))");
    test_quant_solver(m, x, "(and (< a (* 3 x)) (< (* 3 x) b))");    
    test_quant_solver(m, x, "(< (* 3 x) a)");
    test_quant_solver(m, x, "(= (* 3 x) a)");
    test_quant_solver(m, x, "(< (* 3 x) a)");
    test_quant_solver(m, x, "(> (* 3 x) a)");
    test_quant_solver(m, x, "(<= (* 3 x) a)");
    test_quant_solver(m, x, "(>= (* 3 x) a)");
    test_quant_solver(m, x, "(<= (* 2 x) a)");
    test_quant_solver(m, x, "(or (= (* 2 x) y) (= (+ (* 2 x) 1) y))");
    test_quant_solver(m, x, "(= x a)");
    test_quant_solver(m, x, "(< x a)");
    test_quant_solver(m, x, "(> x a)");
    test_quant_solver(m, x, "(and (> x a) (< x b))");
    test_quant_solver(m, x, "(and (> x a) (< x b))");
    test_quant_solver(m, x, "(<= x a)");
    test_quant_solver(m, x, "(>= x a)");
    test_quant_solver(m, x, "(and (<= (* 2 x) y) (= (mod x 2) 0))");
    test_quant_solver(m, x, "(= (* 2 x) y)");
    test_quant_solver(m, x, "(or (< x 0) (> x 1))");
    test_quant_solver(m, x, "(or (< x y) (> x y))");
    test_quant_solver(m, x, "(= x y)");
    test_quant_solver(m, x, "(<= x y)");
    test_quant_solver(m, x, "(>= x y)");
    test_quant_solver(m, x, "(and (<= (+ x y) 0) (<= (+ x z) 0))");
    test_quant_solver(m, x, "(and (<= (+ x y) 0) (<= (+ (* 2 x) z) 0))");
    test_quant_solver(m, x, "(and (<= (+ (* 3 x) y) 0) (<= (+ (* 2 x) z) 0))");
    test_quant_solver(m, x, "(and (>= x y) (>= x z))");
    test_quant_solver(m, x, "(< x y)");
    test_quant_solver(m, x, "(> x y)");
    test_quant_solver(m, 2, xy, "(and (<= (- (* 2 y) b) (+ (* 3 x) a)) (<= (- (* 2 x) a) (+ (* 4 y) b)))");

    test_quant_solver(m, "(exists ((c Cell)) (= c null))");
    test_quant_solver(m, "(exists ((c Cell)) (= c (cell null c1)))");

    test_quant_solver(m, "(exists ((c Cell)) (not (= c null)))", false);
    test_quant_solver(m, "(exists ((c Cell)) (= (cell c c) c1))", false);
    test_quant_solver(m, "(exists ((c Cell)) (= (cell c (cdr c1)) c1))", false);

    test_quant_solver(m, "(exists ((t Tuple)) (= (tuple a P r1) t))");
    test_quant_solver(m, "(exists ((t Tuple)) (= a (first t)))");
    test_quant_solver(m, "(exists ((t Tuple)) (= P (second t)))");
    test_quant_solver(m, "(exists ((t Tuple)) (= r2 (third t)))");
    test_quant_solver(m, "(exists ((t Tuple)) (not (= a (first t))))");
    test_quant_solver(m, "(exists ((t Tuple)) (not (= P (second t))))");
    test_quant_solver(m, "(exists ((t Tuple)) (not (= r2 (third t))))");
}
예제 #23
0
void fPostStatus_db(
		const char* opt   = "",
		const char* year  = "17sim",
		const char* input = "fPostStatus.txt",
		int readdate = 0,
		int readtime = 0)
{
    // storeTime is beginning time for validity range in case of WRITING DB
    TString option(opt), yr(year), storeTime;
    int date, time; // time for READING DB
    
    std::cout <<"year = " <<year <<std::endl;
    if (yr.Contains("17sim"))
	{
	    storeTime = "2016-12-10 00:00:00";
	    date = 20161210;
	    time = 0;
	}
    else if (yr.Contains("17ofl"))
	{
	    storeTime = "2016-12-20 00:00:00";
	    date = 20161220;
	    time = 0;
	}
    else { std::cout << "Please specify valid year tag\n"; exit; }

	if (readdate > 0) date = readdate;
	if (readtime > 0) time = readtime;

    std::cout << "Opt ="         << opt << "\n";
    std::cout << "write = "      << option.Contains("writedb") << "\n";
    std::cout << "storetime = "  << storeTime << "\n";
    std::cout << "date, time = " << date <<" "<< time << "\n";
    
    gROOT->Macro("./loadlib.C");
    
    //-------------------------------------------
    
    const Int_t MAX_DB_INDEX = 241;
    fpostStatus_st in[MAX_DB_INDEX];
    
    FILE *FP = fopen(input, "r");
    if (!FP) { printf("Could not open %s\n", input); exit; }
    printf("\nReading %s\n", input);
    
    char line[1000];
    int n = 0;
    while (fgets(line, 1000, FP) != NULL)
    {	
        sscanf(line,"%hu %hu", &in[n].slatid, &in[n].status);
        printf("slatId=%3d status=%1d\n", in[n].slatid, in[n].status);
        n++;
    }
    printf("Found %d entries\n", n);
    fclose(FP);
    printf("File Closed\n", n);
    
    //-------------------------------------------
    
	#if 1
    if (option.Contains("writedb"))
	{
	    gSystem->Setenv("DB_ACCESS_MODE", "write");
	    StDbManager*    mgr     = StDbManager::Instance();
	    StDbConfigNode* node    = mgr->initConfig("Calibrations_fps");
	    StDbTable*      dbtable = node->addDbTable("fpostStatus");
	    mgr->setStoreTime(storeTime.Data());
	    dbtable->SetTable((char*)&in, MAX_DB_INDEX);
	    if (yr.Contains("sim")) dbtable->setFlavor("sim");
	    mgr->storeDbTable(dbtable);
	    std::cout << "INFO: table saved to database" << std::endl;
	}

	//-------------------------------------------

    if (option.Contains("readdb"))
	{
	    std::cout << "INFO: Reading database" << std::endl;
	    gSystem->Unsetenv("DB_ACCESS_MODE");
	    //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG");
	    
	    St_db_Maker* dbMk = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
	    dbMk->SetDebug();
	    dbMk->SetDateTime(date, time); // event or run start time, set to your liking
	    if      (yr.Contains("ofl")) { dbMk->SetFlavor("ofl"); }
	    else if (yr.Contains("sim")) { dbMk->SetFlavor("sim"); }
	    dbMk->Init();
	    dbMk->Make();
	    
	    TDataSet *DB = 0;
	    DB = dbMk->GetDataBase("Calibrations/fps/fpostStatus");
	    if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl;
	    
	    St_fpostStatus *dataset = 0;
	    dataset = (St_fpostStatus*) DB->Find("fpostStatus");
	    if (!dataset) { std::cout << "ERROR: dataset does not contain requested table" << std::endl; return; }
	    Int_t rows = dataset->GetNRows();
	    if (rows > 1) std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl;
	    
	    TDatime val[2];
	    dbMk->GetValidity((TTable*)dataset, val);
	    std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - "
		      << val[1].GetDate() << "." << val[1].GetTime() << " ] " << std::endl;
	    
	    fpostStatus_st *table = (fpostStatus_st*)dataset->GetTable();
	    for (Int_t i = 0; i < rows; i++)
		{
		    std::cout << Form("Row=%3d slatid=%3d status=%1d\n", i, table[i].slatid, table[i].status);
		}
	}
	#endif

    return;
}//Main
예제 #24
0
void Boonas::doRotate(QString outfile, QString vectx, QString vecty, QString vectz, QString px, QString py, QString pz, QString divisions, QString degrees) 
{
	Point centerP(px.toFloat(), py.toFloat(), pz.toFloat());
	Vector centerV(vectx.toFloat(), vecty.toFloat(), vectz.toFloat());
	Transformation matrix;
	float theta;
	float phi;
	float angleOfRot = degrees.toFloat() / divisions.toFloat();
	
	// translate to x
	matrix = xt(-px.toFloat(), matrix);
	matrix = yt(-py.toFloat(), matrix);
	matrix = zt(-pz.toFloat(), matrix);
	
	
	if(vectz.toFloat() == 0)
	{
		if((vectx.toFloat() == 1) && (vectz.toFloat() == 0))
		{
			theta = 1.57079633;
		}
		else
		{
			theta = 0.0;
		}
	}
	else
	{
		theta = atan(vectx.toFloat() / vectz.toFloat());
	}
	
	matrix = yr(-theta, matrix);
	phi = atan(vecty.toFloat() / (sqrt((vectx.toFloat() * vectx.toFloat()) + (vectz.toFloat() * vectz.toFloat()))));
	matrix = xr(phi, matrix);
	
	// apply matrix
	doMult(matrix);
	
	// do rotates and divisions along Z
	doZrm(outfile, angleOfRot, divisions.toFloat());
	
	// have to re-read from a temp file after this
	delete orig;
	orig = new LNHHolder();
	readTfile(outfile);
	
	//unrotate
	matrix = Transformation();
	matrix = xr(-phi, matrix);
	matrix = yr(theta, matrix);
	
	// untranslate
	matrix = xt(px.toFloat(), matrix);
	matrix = yt(py.toFloat(), matrix);
	matrix = zt(pz.toFloat(), matrix);
	
	// apply matrix
	doMult(matrix);
	
	return;
}
예제 #25
0
 forceinline void
 IntTraceView::update(Space& home, bool, IntTraceView y) {
   Iter::Ranges::RangeList yr(y.dom);
   RangeList::copy(home,dom,yr);
 }