Esempio n. 1
0
bool CodeStack::validate(const Code& cf)
{
	TypeFilter tf;
	// returns r, i, or j
	switch (tf.Get(cf.name))
	{
		// r requires 
		// rs, rd, rt
		case 'r':
			if (cf.rs!="" && cf.rd!="" && cf.rt!="")
				return true;
			setErr("rs or rt or rd not set");
			return false;
		// i requires
		// rs, rt, imd(or lb)
		case 'i':
			if (cf.rs!="" && cf.rt!="" && cf.dirt())
				return true;
			setErr("rs or rt or immediate not set");
			return false;
		// j requires
		// imd
		case 'j':
			if (cf.dirt())
				return true;
			setErr("immediate not set");
			return false;
		default:
			// ÕâÊÇɶ
			return false;
	}
	return true;
}
Esempio n. 2
0
depsRef depsScanForHeaders(const char *path)
{
	PATHSPLIT f;
	char buf[MAXJPATH];
	time_t time;
	HEADER *h;

	if (!inState(DEPS_STATE_INIT | DEPS_STATE_SEARCH))
	{
		if (!inState(DEPS_STATE_SEARCH)) setErr(DEPS_ERROR_NOT_SEARCH);
		if (!inState(DEPS_STATE_INIT)) setErr(DEPS_ERROR_NOT_INIT);
		return NULL;
	}
	setErr(0);

	path_split(path, &f);
	path_normalize(&f, NULL);
	path_tostring(&f, buf);

	timestamp(buf, &time);
	if (!time)
		return NULL;

	h = headers(buf, time);
	return (depsRef) h;
}
uidsize_t SessionServer::validAuth(char* username, char* password)
{
	class EmptyAuth
	{
	public:
		int operator () (SafeInfo* info, fdtype_t type) { return 0; }
	};

	int fd = manager->open("/sys/user.d", OPTYPE_READ | OPTYPE_RAD_SHR_LOCK, EmptyAuth());
	if(fd == 0)
	{
		setErr(manager->getErrno());
		return 0;
	}
	FileGuard<XHYFileManager, int> fgrd(*manager, fd);
	manager->seek(fd, 0, XHYFileManager::end);
	int fileSize = manager->tell(fd);
	manager->seek(fd, 0, XHYFileManager::beg);
	if(fileSize < 0)
	{
		setErr(manager->getErrno());
		return 0;
	}
	char buf[_MAXUNAMESIZE > _MAXPSDSIZE ? _MAXUNAMESIZE : _MAXPSDSIZE];
	while(true)
	{
		uidsize_t uid;
		int curPos = manager->tell(fd);
		if(curPos < 0)
		{
			setErr(manager->getErrno());
			return 0;
		}
		if(curPos == fileSize)
		{
			setErr(ERR_UNAME_OR_PSD_ERROR);
			return 0;
		}
		if(!readFBuf(fd, (char*) &uid, sizeof(uid)))
			return 0;
		if(!readFBuf(fd, buf, _MAXUNAMESIZE))
			return 0;
		if(strcmp(buf, username) != 0)
		{
			manager->seek(fd, _MAXPSDSIZE, XHYFileManager::cur);
			continue;
		}
		if(!readFBuf(fd, buf, _MAXPSDSIZE))
			return 0;
		if(strcmp(buf, password) == 0)
			return uid;
		else
		{
			setErr(ERR_AUTH_ERR);
			return 0;
		}
	}
}
Esempio n. 4
0
void depsSetCWD(const char *cwd)
{
	if (!inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	setErr(0);
	path_setcwd(cwd);
}
Esempio n. 5
0
void depsStart(void)
{
	if (inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_ALREADY_INIT);
		return;
	}
	setErr(0);
	memset((char *) &g_stats, 0, sizeof(g_stats));
	g_state |= DEPS_STATE_INIT;
}
Esempio n. 6
0
void depsAddSearchDir(const char *path)
{
	if (!inState(DEPS_STATE_INIT | DEPS_STATE_SEARCH))
	{
		if (!inState(DEPS_STATE_SEARCH)) setErr(DEPS_ERROR_NOT_SEARCH);
		if (!inState(DEPS_STATE_INIT)) setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	setErr(0);
	search_adddir(path);
}
Esempio n. 7
0
void depsGetStats(struct depsStats *stats)
{
	if (!inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	setErr(0);

	*stats = g_stats;
}
Esempio n. 8
0
void depsSearchStart(void)
{
	if (!inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	search_init();
	g_state |= DEPS_STATE_SEARCH;
	setErr(0);
}
Esempio n. 9
0
int SqliteDatabase::connect(bool create) {
  if (host.empty() || db.empty())
    return DB_CONNECTION_NONE;

  //CLog::Log(LOGDEBUG, "Connecting to sqlite:%s:%s", host.c_str(), db.c_str());

  std::string db_fullpath = URIUtils::AddFileToFolder(host, db);

  try
  {
    disconnect();
    int flags = SQLITE_OPEN_READWRITE;
    if (create)
      flags |= SQLITE_OPEN_CREATE;
    if (sqlite3_open_v2(db_fullpath.c_str(), &conn, flags, NULL)==SQLITE_OK)
    {
      sqlite3_busy_handler(conn, busy_callback, NULL);
      char* err=NULL;
      if (setErr(sqlite3_exec(getHandle(),"PRAGMA empty_result_callbacks=ON",NULL,NULL,&err),"PRAGMA empty_result_callbacks=ON") != SQLITE_OK)
      {
        throw DbErrors(getErrorMsg());
      }
      active = true;
      return DB_CONNECTION_OK;
    }

    return DB_CONNECTION_NONE;
  }
  catch(...)
  {
  }
  return DB_CONNECTION_NONE;
}
void RoboState::messageCallback(const nav_simple::mymsg::ConstPtr& msg)
{
  // only accept message if movement is not in progress
  if(getCurrentState()==NEUTRAL)
    {
      if(msg->x==0 && msg->y==0)
	ROS_INFO("No reason to move a distance of 0. Message not sent.");
      else{	  
	ROS_INFO("X and Y coordinates sent were: x:%f y:%f", msg->x, msg->y);
	setX(msg->x);
	setY(msg->y);
	ROS_INFO("xCoord is: %f. yCoord is: %f", getX(), getY());
	
	// we don't need to face backward since initial movement is forward
	if(getX() >= 0){
	  setCurrentState(TURN_LEFT_90);
	}
	// need to face backward since initial movement is backward
	// (want bumper sensors to be useful)
       	else{
	  //setCurrentState(TURN_NEG_X);
	  setCurrentState(TURN_LEFT_90);
	}
	//setErr(sqrt(pow(getX(),2)+pow(getY(),2))*.1);
	setErr(.1);
      }
      // need to determine what direction we will ultimately face
      setYawGoal(90);
      //      determineYawGoal();

    }
  else
    ROS_INFO("Cannot accept message. Movement still in progress.");
}
Esempio n. 11
0
void LoggerReader_byte::recFrame()                                /*{{{*/
{
  if (outBufWr + inBufFrameLen >= outBufSize)
  {
    // Pufferüberlauf
    setErr("Buffer overflow");
  }
  else
  {
    outBuf[outBufWr++] = inBufFrameLen;
    
#if DEBUG == 1  
    printf(" ->");
#endif  
#if SHOWREC == 2
    printf(" Frame:");
#endif
    for (int n=inBufFrameLen-1; n>0; n--)
    {
#if ((DEBUG == 1) || (SHOWREC == 2))
      printf(" %i", inBuf[n]);
#endif
      outBuf[outBufWr++] = inBuf[n];
    }
#if ((DEBUG == 1) || (SHOWREC == 2))
    printf("\n");
#endif  
    
    if (inBuf[inBufFrameLen-1] != DaLoConst::ID_ts)
      outBufFrames++;    
  }
}
Esempio n. 12
0
struct _client *newClient(int sockfd){
    int i = 0;
    if(m_ClientManager.nClients >= MAX_CLIENTS){
        CLIENT_DEBUG("new a client failed1!");
        setErr(ERR_CLIENT_FULL);
        return 0;
    }
    for(i=0; i<MAX_CLIENTS; i++){
        if(!m_ClientManager.clients[i].used){
            initClient(&m_ClientManager.clients[i],sockfd);
            CLIENT_DEBUG("new a client ok!fd:%d\r\n",sockfd);
            return &m_ClientManager.clients[i];
        }
    }
    CLIENT_DEBUG("new a client failed!");
    setErr(ERR_CLIENT_FULL);
    return 0;
}
Esempio n. 13
0
void depsTimeStamp(const char *path, time_t *time)
{
	PATHSPLIT f;
	char buf[MAXJPATH];

	if (!inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	setErr(0);

	path_split(path, &f);
	path_normalize(&f, NULL);
	path_tostring(&f, buf);

	timestamp(buf, time);
}
Esempio n. 14
0
bool insertLabel(const std::string& label) {
	// label name exist
	if (labels.find(label)) {
		setErr("label name "+label+" exist");
		return false;
	}
	// size-1 = index of current
	labels.insert(pair<string, int>(label, origin.size()-1));
}
Esempio n. 15
0
struct _client *findClientById(const char* id){
    int i=0;
    for(i=0; i<MAX_CLIENTS; i++){
        if(m_ClientManager.clients[i].used  && strcmp(m_ClientManager.clients[i].m_data.id,id) == 0 ){
            return &m_ClientManager.clients[i];
        }
    }
    setErr(ERR_CLIENT_NOFIND);
    return 0;
}
bool SessionServer::writeFBuf(int fd, const char* buf, size_t len)
{
	size_t pos = 0;
	while(pos != len)
	{
		int rs = manager->write(fd, buf + pos, len - pos);
		if(rs < 0)
		{
			setErr(ERR_SYS_ERROR);
			return false;
		}
		if(rs == 0)
		{
			setErr(ERR_SYS_ERROR);
			return false;
		}
		pos += rs;
	}
	return true;
}
bool SessionServer::readFBuf(int fd, char* buf, size_t len)
{
	size_t pos = 0;
	while(pos != len)
	{
		int rs = manager->read(fd, buf + pos, len - pos);
		if(rs < 0)
		{
			setErr(ERR_SYS_ERROR);
			return false;
		}
		if(rs == 0)
		{
			setErr(ERR_FEAD_FILE_EOF);
			return false;
		}
		pos += rs;
	}
	return true;
}
Esempio n. 18
0
struct _client *findClientByFd(int fd){
    int i=0;
    for(i=0; i<MAX_CLIENTS; i++){
        if(m_ClientManager.clients[i].used  &&  m_ClientManager.clients[i].socket == fd ){
            return &m_ClientManager.clients[i];
        }
    }
    setErr(ERR_CLIENT_NOFIND);
    CLIENT_DEBUG("not find this client, fd:%d\r\n",fd);
    return (struct _client *)0;
}
bool SessionServer::validHeader()
{
	char tmp;
	int rs = read(socket, &tmp, 1);
	if(rs < 0)
	{
		setErr(ERR_SOCKET_EXCEPTION);
		return false;
	}
	if(rs == 0)
	{
		setExit();
		return false;
	}
	if(tmp != 'X')
	{
		setErr(ERR_VALIDATE_HEAD);
		return false;
	}
	return true;
}
Esempio n. 20
0
void depsDone(void)
{
	if (!inState(DEPS_STATE_INIT))
	{
		setErr(DEPS_ERROR_NOT_INIT);
		return;
	}
	setErr(0);

	donestamps();
	donestr();
	donelist();
	donehdrs();
	donesearch();
	donepath();
#ifdef USE_CACHE
	donecache();
#endif

	g_state = DEPS_STATE_DONE;
}
Esempio n. 21
0
int SqliteDatabase::connect() {
  disconnect();
  if (conn = sqlite_open(db.c_str(),0,NULL)) {
    //cout << "Connected!\n";
    char* err=NULL;
    if (setErr(sqlite_exec(getHandle(),"PRAGMA empty_result_callbacks=ON",NULL,NULL,&err),"PRAGMA empty_result_callbacks=ON") != SQLITE_OK) {
      return DB_CONNECTION_NONE;
    }
    active = true;
    return DB_CONNECTION_OK;
  }
  return DB_CONNECTION_NONE;
};
Esempio n. 22
0
//Проверка величины fifo->head по отношению к fifo->size
//errCode 0x3302, 0x3303
void checkFifoPos(int size, int head)
{
	setErr(0);
	if (head > size)
	{
		setErr_code_str(0x3102, "checkFifoPos");//выход за границу массива
		return;
	}
	if (head<0)
	{
		setErr_code_str( 0x3103, "checkFifoPos");//отрицательный номер элемента массива
		return;
	}
}
void SessionServer::readFolder()
{
	unsigned short pathLen;
	if(!readSBuf((char*) &pathLen, sizeof(pathLen)))
		return;
	std::unique_ptr<char> path(new char[pathLen + 1]);
	if(!readSBuf(path.get(), pathLen))
		return;
	path.get()[pathLen] = '\0';
	SafeInfo sfInfo;
	int rss = pathValidateR(path.get(), 0, &sfInfo);
	if(rss == 0)
	{
		std::unique_ptr<FileNode> fnodes(new FileNode[20]);
		if(!writeSBuf((char*) &rss, sizeof(rss)))
			return;
		int len, start = 0;
		while(true)
		{
			len = manager->readFolder(path.get(), start, 20, fnodes.get());
			if(len == 0)
			{
				char tmp = 0;
				writeSBuf(&tmp, sizeof(tmp));
			}
			else if(len < 0)
				setErr(ERR_SYS_ERROR);
			else
			{
				start += len;
				for(int i = 0; i < len; ++i)
				{
					char nlen = strlen(fnodes.get()[i].name);
					writeSBuf(&nlen, sizeof(nlen));
					writeSBuf(fnodes.get()[i].name, nlen);
				}
				continue;
			}
			break;
		}
	}
	else
		writeSBuf((char*) &rss, sizeof(rss));
}
Esempio n. 24
0
void LoggerReader_byte::recErr(unsigned char byte0, 
                               unsigned char byte1)               /*{{{*/
{
  if (outBufWr + 4 >= outBufSize)
  {
    // Pufferüberlauf
    setErr("Buffer overflow");
  }
  else
  {
#if SHOWREC == 2
    printf(" ErrFrame: %i %i\n", byte0, byte1);
#endif
    outBuf[outBufWr++] = 4;
    outBuf[outBufWr++] = DaLoConst::ID_err;
    outBuf[outBufWr++] = byte0;
    outBuf[outBufWr++] = byte1;
    outBufFrames++;
  }
}
bool SessionServer::writeSBuf(const char* buf, size_t len)
{
	size_t pos = 0;
	while(pos != len)
	{
		int rs = write(socket, buf + pos, len - pos);
		if(rs < 0)
		{
			setErr(ERR_SOCKET_EXCEPTION);
			return false;
		}
		if(rs == 0)
		{
			setExit();
			return false;
		}
		pos += rs;
	}
	return true;
}
Esempio n. 26
0
int SqliteDatabase::connect() {
  try {
    disconnect();
    if (sqlite3_open(db.c_str(),&conn/*,NULL*/)==SQLITE_OK) {
      //cout << "Connected!\n";
      sqlite3_busy_handler(conn, busy_callback,NULL);
      char* err=NULL;
      if (setErr(sqlite3_exec(getHandle(),"PRAGMA empty_result_callbacks=ON",NULL,NULL,&err),"PRAGMA empty_result_callbacks=ON") != SQLITE_OK) {
        throw DbErrors(getErrorMsg());
      }
      active = true;
      return DB_CONNECTION_OK;
    }
    CLog::Log(LOGERROR, "unable to open database:%s (%u)",
              db.c_str(), GetLastError());
    return DB_CONNECTION_NONE;
  }
  catch(...)
  {
    CLog::Log(LOGERROR, "unable to open database:%s (%u)",
              db.c_str(), GetLastError());
  }
  return DB_CONNECTION_NONE;
}
Esempio n. 27
0
void mk_sigaccanplots(string flavor = "112", bool tdrstyle = false)
{
	setTDRStyle(tdrstyle);
	// gStyle->SetOptFit(1100); // chi2 and prob, not parameters
	gStyle->SetOptFit(0); // chi2 and prob, not parameters
	// gStyle->SetOptStat("irme"); // integral, RMS, mean, # of entries
	gStyle->SetStatFontSize(0.005);
	gStyle->SetStatY(0.4);
	float unused = 0.9, simtxt_y = 0.97;
	if (tdrstyle == false) {
		simtxt_y = 0.93;
	}
	TLatex *tex = new TLatex(unused, simtxt_y, "CMS simulation at #sqrt{s} = 8 TeV");
	tex->SetNDC();
	tex->SetTextAlign(12); // Left-adjusted
	tex->SetTextFont(42);
	float textsiz = 0.06;
	tex->SetTextSize(0.05);
	tex->SetLineWidth(2);
  // for(int k=0; k<3; k++){	
  // for(int k=0; k<2; k++){	
  for(int k=2; k<3; k++){	
  //Which plots to make
  //define input variables
  vector <TFile* > filelist_kin;

  // string uncert="btagup";
  // if(k==1) uncert="btagdown";
  string uncert="up";
  if(k==1) uncert="down";
  if(k==2) uncert="";
  
  // filelist_kin.push_back(TFile::Open(("Acc_Gluino_NoLumi_pt110_8TeVxsec_BtagMap_2500GeV"+uncert+".root").c_str()));
  // filelist_kin.push_back(TFile::Open("Acc_Gluino_NoLumi_pt60_pt110_8TeVxsec_BtagMap.root"));
  // filelist_kin.push_back(TFile::Open(("Acc_RPV112" + uncert + ".root").c_str()));
  filelist_kin.push_back(TFile::Open(("Acc_RPV" + flavor + uncert + "_Sph4.root").c_str()));
//   filelist_kin.push_back(TFile::Open(("Acc_Gluino_NoLumi_pt60_pt110_8TeVxsec_BtagMap" + uncert + ".root").c_str()));
  
  TFile f1(("RPV_" + flavor + "_accandwdithtest"+uncert+".root").c_str(), "recreate");
  f1.cd();
  
  
  
  string nameIN;
  string cuts;
  string prefix;
  string postfix;
  string folder;
  string ptcut;
  folder="plots_paper/";
  postfix=".pdf";
  /////////////Plots for each Mass separatly//////////////
  /////////////----------------------------------------/////////////
  
  for (int p = 0; p < 2; p++) {
    // ptcut="112";
    // if(p==1) ptcut="" + flavor;
     ptcut="60";
    if (p==1) {
		ptcut="110";
		textsiz = 0.045;
    }
    // string histname = string("GausWidth_vs_Mass_112") + ptcut;
      string histname = string("GausWidth_vs_Mass_" + flavor) + "_" + ptcut;
      cout<< histname << endl;
      TGraphErrors *h_GluinoHist_Fit = (TGraphErrors*) filelist_kin[0]->Get(histname.c_str())->Clone();
      histname = string("GausAcceptance_vs_Mass_" + flavor) + "_" + ptcut;
      // histname = string("GausAcceptance_vs_Mass_112") + ptcut;
      cout<< histname << endl;
      TGraphErrors *h_GluinoHist_MCcomb = (TGraphErrors*) filelist_kin[0]->Get(histname.c_str())->Clone();
      
      // histname = string("FullAcceptance_vs_Mass_" + flavor) + "_" + ptcut;
      histname = string("GausMean_vs_Mass_" + flavor) + "_" + ptcut;
      // histname = string("GausAcceptance_vs_Mass_112") + ptcut;
      cout<< histname << endl;
      // TGraphErrors *h_FullAccept = (TGraphErrors*) filelist_kin[0]->Get(histname.c_str())->Clone();
      TGraph *h_FullAccept = (TGraph*) filelist_kin[0]->Get(histname.c_str())->Clone();
     
      histname = string("GausMeanOffset_vs_Mass_" + flavor) + "_" + ptcut;
      cout<< histname << endl;
      TGraph *h_MeanOffset = (TGraph*) filelist_kin[0]->Get(histname.c_str())->Clone();
     
      TCanvas * cGluinoFitsOpti = new TCanvas(("RPV_"+flavor +ptcut).c_str(), ("RPV_" + ptcut+"_"+cuts).c_str(), 800, 600);
      //h_GluinoHist_Fit->SetFillColor(kOrange-2);
      // h_GluinoHist_Fit->SetLineColor(kBlack);
		string title;
		string systematic = "pile-up";
		// title="Gaussian Width vs. Mass for Light-ptcut RPV";
		string tag = "qqb", sphericity = " Sphericity #geq 0.4";
		if (flavor.compare("112") == 0)
			tag = "qqq";
		else if (ptcut.compare("60") == 0)
			sphericity = "";
		string titlepart = "Hadronic RPV #tilde{g} #rightarrow " + tag;
		string titleln2 = "\\Delta = 110 GeV";
		string titleln3 = "6^{th}-jet p_{T} #geq " + ptcut + " GeV";
		title = titlepart;
		// title = "Width for " + titlepart;
		/*
		if(k==0){
		title="RPV gluino #bf{" + systematic + " up} m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 60 GeV}";
      if (i>=5 || p==0) title="RPV gluino #bf{" + systematic + " up} m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 110 GeV}";
		}
		
				if(k==1){
		title="RPV gluino #bf{" + systematic + " down} m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 60 GeV}";
      if (i>=5 || p==0) title="RPV gluino #bf{" + systematic + " down} m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 110 GeV}";
				}
		
						if(k==2){
		title="RPV gluino m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 60 GeV}";
      if (i>=5 || p==0) title="RPV gluino m="+to_string(masses[i])+", ptcut = "+ptcut+", #Delta = 110 GeV, #bf{6^{th} Jet p_{T} = 110 GeV}";
						}
						*/
      h_GluinoHist_Fit->SetTitle(title.c_str());
      float titpos = 0.2, titly = 0.89, headpos = 0.64;
	  if (tdrstyle == false) {
	  	titpos -= 0.05;
	  	titly -= 0.05;
	  	headpos = 0.45;
	  }
			TLatex *tex2 = new TLatex(titpos, titly, title.c_str());
			tex2->SetNDC();
			tex2->SetTextAlign(12); // Left-adjusted
			tex2->SetTextFont(42);
			tex2->SetTextSize(textsiz);
			tex2->SetLineWidth(2);
			TLatex *tex3 = new TLatex(titpos, titly - 0.07, titleln2.c_str());
			tex3->SetNDC();
			tex3->SetTextAlign(12);
			tex3->SetTextFont(42);
			tex3->SetTextSize(textsiz);
			tex3->SetLineWidth(2);
			TLatex *tex3a = new TLatex(titpos, titly - 0.14, titleln3.c_str());
			tex3a->SetNDC();
			tex3a->SetTextAlign(12);
			tex3a->SetTextFont(42);
			tex3a->SetTextSize(textsiz);
			tex3a->SetLineWidth(2);
			TLatex *tex4 = NULL;
			if (sphericity.size() > 0) {
				tex4 = new TLatex(titpos - 0.01, titly - 0.22, sphericity.c_str());
				tex4->SetNDC();
				tex4->SetTextAlign(12);
				tex4->SetTextFont(42);
				tex4->SetTextSize(textsiz);
				tex4->SetLineWidth(2);
			}
			float legx = 0.65;
			 if (tdrstyle == false) {
			 	 legx = 0.56;
			 }
			TLegend *leg = new TLegend(legx, 0.2, legx + 0.3, 0.4);
			leg->SetBorderSize(1);
			leg->SetTextFont(62);
			leg->SetLineColor(kBlack);
			leg->SetLineStyle(1);
			leg->SetLineWidth(1);
			leg->SetFillColor(0);
			leg->SetFillStyle(1001);
			//leg->SetHeader();


			// leg->AddEntry(h_GluinoHist_Fit, "#splitline{Acceptance as function}{of gluino mass}","l");	
      h_GluinoHist_Fit->SetMarkerStyle(1);
      h_GluinoHist_Fit->SetMarkerColor(kWhite);
      // h_GluinoHist_Fit->SetMarkerColor(kGreen + 3);
      h_GluinoHist_Fit->SetMarkerSize(0.004);
     // h_GluinoHist_Fit->SetTitleSize(0.01);
      TF1 *fitfunc = h_GluinoHist_Fit->GetFunction("GausWidth");
      string fitnamew = "fitcopy" + ptcut;
      TF1* fitfunccopy = (TF1 *) fitfunc->Clone(fitnamew.c_str());
      if (fitfunc == NULL)
     	 cout << "Can't get fit func\n";
      else {
      	fitfunc->Delete();
      	fitfunccopy->SetLineWidth(3);
      	fitfunccopy->SetLineColor(kGreen + 3);
		// fitfunc->SetLineStyle(3); // Dotted
      }
	 float labsiz = 0.055;
      h_GluinoHist_Fit->GetXaxis()->SetLabelFont(62);
      h_GluinoHist_Fit->GetXaxis()->SetTitleFont(62);
      h_GluinoHist_Fit->GetYaxis()->SetLabelFont(62);
      h_GluinoHist_Fit->GetYaxis()->SetTitleFont(62);
      h_GluinoHist_Fit->GetYaxis()->SetTitle("Gaussian width [GeV]");
      float offset = 0.8;
	  if (tdrstyle == false) {
		h_GluinoHist_Fit->GetXaxis()->SetTitleOffset(offset);
		h_GluinoHist_Fit->GetYaxis()->SetTitleOffset(offset);
	 }
      h_GluinoHist_Fit->GetXaxis()->SetTitle("Gluino mass [GeV]");
      h_GluinoHist_Fit->GetXaxis()->SetTitleSize(labsiz);
      h_GluinoHist_Fit->GetYaxis()->SetTitleSize(labsiz);
	  if (tdrstyle == false) {
		float axsize = 0.04;
		h_GluinoHist_Fit->GetXaxis()->SetLabelSize(axsize);
		h_GluinoHist_Fit->GetYaxis()->SetLabelSize(axsize);
     }
     if (flavor.compare("113_223") == 0 && ptcut == "60")
		h_GluinoHist_Fit->GetYaxis()->SetRangeUser(14.0,  50.0);
       h_GluinoHist_Fit->Draw("APX");	// X eliminates error bars
       // h_GluinoHist_Fit->Draw("AP");	
      // TH1 *fithist = (TH1 *) fitfunccopy->GetHistogram()->Clone(fitnamew.c_str());
      TH1 *fithist = (TH1 *) fitfunccopy->GetHistogram()->Clone();
      int fillcolor = kGreen + 2;
      int fillstyle = 3013;
      if (fithist != NULL) {
      	int numBins = fithist->GetNbinsX();
      	for (int cnt = 1; cnt <= numBins; ++cnt) {
      		setErr(fithist, cnt, flavor, "width");
      	}
      	fithist->SetFillColor(fillcolor);
      	fithist->SetFillStyle(fillstyle);
      	fithist->Draw("CE3SAME");
      }
      fitfunccopy->Draw("CSAME");
      // h_GluinoHist_Fit->Draw("P");	// Draw points over fit line
      leg->AddEntry(fitfunccopy, "Gaussian width", "L");
      leg->AddEntry(fithist, "Uncertainty", "F");
	 leg->Draw();
      tex->SetX(headpos);
      tex->Draw();
      tex2->Draw();
      tex3->Draw();
      tex3a->Draw();
      if (tex4 != NULL)
		tex4->Draw();
      cGluinoFitsOpti->Write();
      cGluinoFitsOpti->SaveAs((folder + "RPVwidth" +flavor + ptcut+uncert+postfix).c_str());

      TCanvas * cGluinoFitsOpt2 = new TCanvas(("RPVacc_"+flavor +ptcut).c_str(), ("RPV_" + ptcut+"_"+cuts).c_str(), 800, 600);
	 // title="Acc. x Eff. for " + titlepart;
	 title= titlepart;
	 tex2->SetText(titpos,titly, title.c_str());
	 TLegend *leg2 = new TLegend(legx, 0.2, legx + 0.3, 0.4);
	 leg2->SetBorderSize(1);
	 leg2->SetTextFont(62);
	 leg2->SetTextSize(0.04);
	 leg2->SetLineColor(kBlack);
	 leg2->SetLineStyle(1);
	 leg2->SetLineWidth(1);
	 leg2->SetFillColor(0);
	 leg2->SetFillStyle(1001);

      TF1 *fitfuncA = h_GluinoHist_MCcomb->GetFunction("total");
      string fitname = "fitcopyA" + ptcut;
      TF1* fitfunccopyA = (TF1 *) fitfuncA->Clone(fitname.c_str());
      if (fitfuncA == NULL)
     	 cout << "Can't get fit func\n";
      else {
      	fitfuncA->Delete();
      	fitfunccopyA->SetLineWidth(3);
      	fitfunccopyA->SetLineColor(kGreen + 3);
		// fitfunc->SetLineStyle(3); // Dotted
      }
      h_GluinoHist_MCcomb->SetMarkerStyle(1);
      // h_GluinoHist_MCcomb->SetMarkerColor(kBlack);
      h_GluinoHist_MCcomb->SetMarkerColor(kWhite);
      h_GluinoHist_MCcomb->SetTitle(title.c_str());
      h_GluinoHist_MCcomb->GetXaxis()->SetLabelFont(62);
      h_GluinoHist_MCcomb->GetXaxis()->SetTitleFont(62);
      h_GluinoHist_MCcomb->GetYaxis()->SetLabelFont(62);
      // h_GluinoHist_MCcomb->GetYaxis()->SetLabelSize(62);
h_GluinoHist_MCcomb->GetYaxis()->SetTitleFont(62);
      h_GluinoHist_MCcomb->GetYaxis()->SetTitle("Acceptance x Efficiency");
	  if (tdrstyle == false) {
		h_GluinoHist_MCcomb->GetXaxis()->SetTitleOffset(offset);
		h_GluinoHist_MCcomb->GetYaxis()->SetTitleOffset(offset + 0.35);
	  }
      // h_GluinoHist_MCcomb->GetYaxis()->SetTitleOffset(1.4);
      h_GluinoHist_MCcomb->GetXaxis()->SetTitle("Gluino mass [GeV]");
      h_GluinoHist_MCcomb->GetXaxis()->SetTitleSize(labsiz);
	  if (tdrstyle == false)
	  	labsiz -= 0.01;
      h_GluinoHist_MCcomb->GetYaxis()->SetTitleSize(labsiz);
	  if (tdrstyle == false) {
		float axsize = 0.035;
		 h_GluinoHist_MCcomb->GetXaxis()->SetLabelSize(axsize);
		 h_GluinoHist_MCcomb->GetYaxis()->SetLabelSize(axsize);
	  }
      if (flavor.compare("113_223") == 0) {
		float ylimit = 0.05;
		if ( ptcut == "110")
			ylimit = 0.022;
		// gStyle->SetStatY(0.8);
		h_GluinoHist_MCcomb->GetYaxis()->SetRangeUser(0.0, ylimit);
	}

      // h_GluinoHist_MCcomb->Draw("AL");	
      h_GluinoHist_MCcomb->Draw("APX");
      // fitfunccopyA->Draw("C same");
      // TH1 *fithistA = (TH1 *) fitfunccopyA->GetHistogram()->Clone(fitname.c_str());
      TH1 *fithistA = (TH1 *) fitfunccopyA->GetHistogram()->Clone();
      if (fithistA != NULL) {
      	int numBins = fithistA->GetNbinsX();
      	for (int cnt = 1; cnt <= numBins; ++cnt) {
      		setErr(fithistA, cnt, flavor, "acceptance");
      	}
      	fithistA->SetFillColor(fillcolor);
      	fithistA->SetFillStyle(fillstyle);
      	fithistA->Draw("CE3SAME");
      }
      fitfunccopyA->Draw("CSAME");
      // h_GluinoHist_MCcomb->Draw("P");	// Draw points over fit line
      tex->SetX(headpos);
      tex->Draw();
      tex2->Draw();
      tex3->Draw();
      tex3a->Draw();
      leg2->AddEntry(fitfunccopyA, "Acc. x Eff.", "L");
      leg2->AddEntry(fithistA, "Uncertainty", "F");
	 leg2->Draw();
       if (tex4 != NULL)
		tex4->Draw();
 
      cGluinoFitsOpt2->Write();
      cGluinoFitsOpt2->SaveAs((folder + "RPVacc" +flavor + ptcut+uncert+postfix).c_str());

			/*
      gStyle->SetStatY(0.4);
      TCanvas * cGluinoFitsOpt3 = new TCanvas(("RPVfullacc_"+flavor +ptcut).c_str(), ("RPVfull_" + ptcut+"_"+cuts).c_str(), 800, 600);
			title="Gaussian Mean for " + titlepart;
			tex2->SetText(titpos, 0.89, title.c_str());
			// title="Full Acceptance for " + titlepart;
      h_FullAccept->SetMarkerStyle(1);
      // h_FullAccept->SetMarkerColor(kWhite);
      h_FullAccept->SetLineColor(kRed);
      h_FullAccept->SetLineWidth(2.0);
      // h_FullAccept->SetTitle(title.c_str());
      // h_FullAccept->GetYaxis()->SetTitle("Acceptance");
      h_FullAccept->GetYaxis()->SetTitle("Gaussian Mean [GeV]");
      h_FullAccept->GetXaxis()->SetTitleOffset(1.3);
      h_FullAccept->GetXaxis()->SetTitle("Gluino Mass [GeV]");
      h_FullAccept->GetXaxis()->SetTitleSize(labsiz);
      h_FullAccept->GetYaxis()->SetTitleSize(labsiz);
      h_FullAccept->GetXaxis()->SetLabelSize(axsize);
      h_FullAccept->GetYaxis()->SetLabelSize(axsize);
      h_FullAccept->Draw("AL");	
      // h_FullAccept->Draw("APX");	
			// leg->Draw();
      
      // h_GluinoHist_MCcomb->SetFillColor(10);
      // h_GluinoHist_MCcomb->SetLineColor(kBlack);
      //   h_GluinoHist_MCcomb->Draw("samehist");
      // f_GluinoGauss->SetLineColor(kRed);
      //f_GluinoGauss->Draw("same");
      
      //f_GluinoP4->Draw("same");
      tex->SetX(titpos);
      tex->Draw();
      tex2->Draw();
      tex3->Draw();
      tex3a->Draw();
      if (tex4 != NULL)
		tex4->Draw();
      f1.cd();
      cGluinoFitsOpt3->Write();
      cGluinoFitsOpt3->SaveAs((folder + "RPVmean" +flavor + ptcut+uncert+postfix).c_str());

      gStyle->SetStatY(0.4);
      TCanvas *cMeanOffset = new TCanvas(("RPVMeanOffset_"+flavor +ptcut).c_str(),
      	("RPVMeanOffset_" + ptcut + "_" + cuts).c_str(), 800, 600);
      axsize = 0.035;
			title="Mass Deviation for " + titlepart;
			titpos = 0.35;
			tex2->SetText(titpos, 0.89, title.c_str());
      h_MeanOffset->SetMarkerStyle(1);
      h_MeanOffset->SetLineColor(kRed);
      h_MeanOffset->SetLineWidth(2.0);
      h_MeanOffset->GetYaxis()->SetTitleOffset(1.3);
      h_MeanOffset->GetYaxis()->SetTitle("Fractional Mass Deviation");
      h_MeanOffset->GetXaxis()->SetTitleOffset(1.3);
      h_MeanOffset->GetXaxis()->SetTitle("Gluino Mass [GeV]");
      h_MeanOffset->GetXaxis()->SetTitleSize(labsiz);
      h_MeanOffset->GetYaxis()->SetTitleSize(labsiz);
      h_MeanOffset->GetXaxis()->SetLabelSize(axsize);
      h_MeanOffset->GetYaxis()->SetLabelSize(axsize);
      TLine *max = new TLine(0.5, 0.1, 0.5, 0.9);
			max->SetLineColor(kGreen + 2);
			max->SetLineWidth(3);
      h_MeanOffset->Draw("AL");	
			max->DrawLineNDC(0.16, 0.49, 0.98, 0.49);
      tex->SetX(titpos);
      tex->Draw();
      tex2->Draw();
      tex3->SetX(titpos);
      tex3->Draw();
      tex3a->SetX(titpos);
      tex3a->Draw();
      if (tex4 != NULL) {
      	tex4->SetX(titpos);
				tex4->Draw();
			 }
      f1.cd();
      cMeanOffset->Write();
      cMeanOffset->SaveAs((folder + "RPVmassdev" +flavor + ptcut+uncert+postfix).c_str());
			*/
      }
  }
}
Esempio n. 28
0
int main( int argc, char **argv )
{
	int n, i;
	char *com;

	fp_err = stderr;

	init_conf();

	com = argv[0];
	--argc;  ++argv;
	while( argc > 0 && argv[0][0] == '-' )  {
		switch( argv[0][1] )  {
		case 'C':
			if( argc < 2 )  usage( com );
			read_conf( argv[1] );
			--argc;  ++argv;
			break;
		/*******↓for server mode *******/
		case 'p':
   		        /* 引数が不正な場合はエラー出力 */
			if( argc < 2 )  usage( com );
			/* ポート番号の読み込み */
			i = atoi( argv[1] );
			if (i > 1024) {
			        nPort = i;
			}
			s_mode = 1;
			--argc;  ++argv;
			break;
		/*******↑***********************/
		case 'v':
			printf( "%s\n", moduleVersion );
			printf( "%s\n", protocolVersion );
			exit(0);
		default:
			usage( com );
		}
		--argc;  ++argv;
	}
	set_default_conf();

	initialize();

	n = setjmp( ebuf );

	if( n > 0 )  chasen_process = 0;	/* to restart 'chasen' process */

	for( ;; )  {
#ifdef PRINTDATA
		TmpMsg( "> " );
#endif
		n_arg = read_command( v_arg );

#ifdef PRINTDATA
		{
			int i;
			TmpMsg( "command is \n" );
			for( i=0; i<n_arg; ++i )  {
				TmpMsg( "  %d: %s\n", i+1, v_arg[i] );
			}
		}
#endif

		/* 「o」 で set Speak = NOW のショートカット */
		if( strcmp(v_arg[0],"o")==0 )  {
			setSpeak( "=", "NOW" );
			continue;
		}

		if( n_arg < 2 )  { unknown_com();  continue; }

		switch( commandID( v_arg[0] ) )  {
		  case C_set:
			if( n_arg < 4 )  { unknown_com();  break; }
			switch( slotID( v_arg[1] ) )  {
			  case S_Run:   setRun( v_arg[2], v_arg[3] );  break;
			  case S_Speaker:  setSpeaker( v_arg[2], v_arg[3] );  break;
			  case S_Alpha: setAlpha( v_arg[2], v_arg[3] );  break;
			  case S_Postfilter_coef: setPostfilter_coef( v_arg[2], v_arg[3] );  break;
			  case S_Text:  setText( v_arg[2], v_arg[3] );  break;
			  case S_Speak: setSpeak( v_arg[2], v_arg[3] );  break;

			  case S_SaveRAW: setSave( v_arg[2], v_arg[3] );  break;
			  case S_Save:    setSave( v_arg[2], v_arg[3] );  break;
			  case S_LoadRAW: setSpeechFile( v_arg[2], v_arg[3], RAW );  break;
			  case S_SpeechFile: setSpeechFile( v_arg[2], v_arg[3], RAW );  break;
			  case S_SaveWAV: setSaveWAV( v_arg[2], v_arg[3] );  break;
			  case S_LoadWAV: setSpeechFile( v_arg[2], v_arg[3], WAV );  break;

			  case S_SavePros:  setSavePros( v_arg[2], v_arg[3] );  break;
			  case S_LoadPros:  setProsFile( v_arg[2], v_arg[3] );  break;
			  case S_ProsFile:  setProsFile( v_arg[2], v_arg[3] );  break;

			  case S_ParsedText: setParsedText( v_arg[2], v_arg[3] );  break;
			  case S_Speak_syncinterval: setSpeakSyncinterval( v_arg[2], v_arg[3] );  break;
			  case S_AutoPlay: 
				slot_Auto_play = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_AutoPlayDelay: 
				slot_Auto_play_delay = atoi( v_arg[3] ); break;
			  case S_Log:   setLog( v_arg[2], v_arg[3] ); break;
			  case S_Log_conf:
				slot_Log_conf = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_text:
				slot_Log_text = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_arranged_text:
				slot_Log_arranged_text = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_chasen:
				slot_Log_chasen = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_tag:
				slot_Log_tag = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_phoneme:
				slot_Log_phoneme = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_mora:
				slot_Log_mora = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_morph:
				slot_Log_morph = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_aphrase:
				slot_Log_aphrase = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_breath:
				slot_Log_breath = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Log_sentence:
				slot_Log_sentence = setLogYesNo( v_arg[2], v_arg[3] ); break;
			  case S_Err:          setErr( v_arg[2], v_arg[3] ); break;
			  default:
				unknown_com();
			}
			break;
		  case C_inq:
			switch( slotID( v_arg[1] ) ) {
			  case S_Run:        inqRun();  break;
			  case S_ModuleVersion: inqModuleVersion();  break;
			  case S_ProtocolVersion: inqProtocolVersion();  break;
			  case S_SpeakerSet: inqSpeakerSet();  break;
			  case S_Speaker:    inqSpeaker();  break;
			  case S_SpeechFile: inqSpeechFile();  break;
			  case S_ProsFile:   inqProsFile();  break;
			  case S_AutoPlay:   inqAutoPlay();  break;
			  case S_AutoPlayDelay:   inqAutoPlayDelay();  break;
			  case S_Text_text:  inqTextText();  break;
			  case S_Text_pho:   inqTextPho();  break;
			  case S_Text_dur:   inqTextDur();  break;
			  case S_Speak_text: inqSpeakText();  break;
			  case S_Speak_pho:  inqSpeakPho();  break;
			  case S_Speak_dur:  inqSpeakDur();  break;
			  case S_Speak_utt:  inqSpeakUtt();  break;
			  case S_Speak_len:  inqSpeakLen();  break;
			  case S_Speak_stat: inqSpeakStat();  break;
			  case S_Speak_syncinterval: inqSpeakSyncinterval();  break;
			  case S_Log:
				RepMsg( "rep Log = %s\n", slot_Log_file );  break;
			  case S_Log_conf:
				RepMsg( "rep Log.conf = %s\n", YesNoSlot(S_Log_conf) );  break;
			  case S_Log_text:
				RepMsg( "rep Log.text = %s\n", YesNoSlot(S_Log_text) );  break;
			  case S_Log_arranged_text:
				RepMsg( "rep Log.arranged_text = %s\n", YesNoSlot(S_Log_arranged_text) );  break;
			  case S_Log_chasen:
				RepMsg( "rep Log.chasen = %s\n", YesNoSlot(S_Log_chasen) );  break;
			  case S_Log_tag:
				RepMsg( "rep Log.tag = %s\n", YesNoSlot(S_Log_tag) );  break;
			  case S_Log_phoneme:
				RepMsg( "rep Log.phoneme = %s\n", YesNoSlot(S_Log_phoneme) );  break;
			  case S_Log_mora:
				RepMsg( "rep Log.mora = %s\n", YesNoSlot(S_Log_mora) );  break;
			  case S_Log_morph:
				RepMsg( "rep Log.morph = %s\n", YesNoSlot(S_Log_morph) );  break;
			  case S_Log_aphrase:
				RepMsg( "rep Log.aphrase = %s\n", YesNoSlot(S_Log_aphrase) );  break;
			  case S_Log_breath:
				RepMsg( "rep Log.breath = %s\n", YesNoSlot(S_Log_breath) );  break;
			  case S_Log_sentence:
				RepMsg( "rep Log.sentence = %s\n", YesNoSlot(S_Log_sentence) );  break;
			  case S_Err:
				RepMsg( "rep Err = %s\n", slot_Err_file );  break;
			  default:
				unknown_com();
			}
			break;
		  case C_prop:
			{ SlotProp prop;
			if( strcmp(v_arg[2],"=")!=0 )  { unknown_com(); break; }
			if( strcmp(v_arg[3],"AutoOutput")==0 )  {
				prop = AutoOutput;
			} else if(strcmp(v_arg[3],"NoAutoOutput")==0 )  {
				prop = NoAutoOutput;
			} else {
				unknown_com(); break;
			}
			switch( slotID( v_arg[1] ) ) {
			  case S_Run:        prop_Run = prop;  break;
			  case S_ModuleVersion: prop_ModuleVersion = prop;  break;
			  case S_ProtocolVersion: prop_ProtocolVersion = prop;  break;
			  case S_SpeakerSet: prop_SpeakerSet = prop;  break;
			  case S_Speaker:    prop_Speaker = prop;  break;
			  case S_SpeechFile: prop_SpeechFile = prop;  break;
			  case S_ProsFile:   prop_ProsFile = prop;  break;
			  case S_Text:       prop_Text = prop;  break;
			  case S_Text_text:  prop_Text_text = prop;  break;
			  case S_Text_pho:   prop_Text_pho = prop;  break;
			  case S_Text_dur:   prop_Text_dur = prop;  break;
			  case S_Speak:      prop_Speak = prop;  break;
			  case S_Speak_text: prop_Speak_text = prop;  break;
			  case S_Speak_pho:  prop_Speak_pho = prop;  break;
			  case S_Speak_dur:  prop_Speak_dur = prop;  break;
			  case S_Speak_utt:  prop_Speak_utt = prop;  break;
			  case S_Speak_len:  prop_Speak_len = prop;  break;
			  case S_Speak_stat: prop_Speak_stat = prop;  break;
			  case S_Speak_syncinterval: prop_Speak_syncinterval = prop;  break;
			  default:
				unknown_com();
			}
			}
			break;
		  default:
			unknown_com();
		}
	}
	
	if( s_mode ) {
	        server_destroy ();
	}
	exit(0);
}