Exemplo n.º 1
0
MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node& node, const std::string& relativeTo)
{
	MetaDataList mdl(type);

	const std::vector<MetaDataDecl>& mdd = mdl.getMDD();

	for(auto iter = mdd.cbegin(); iter != mdd.cend(); iter++)
	{
		pugi::xml_node md = node.child(iter->key.c_str());
		if(md)
		{
			// if it's a path, resolve relative paths
			std::string value = md.text().get();
			if (iter->type == MD_PATH)
			{
				value = Utils::FileSystem::resolveRelativePath(value, relativeTo, true);
			}
			mdl.set(iter->key, value);
		}else{
			mdl.set(iter->key, iter->defaultValue);
		}
	}

	return mdl;
}
Exemplo n.º 2
0
bool ExtractSingleModel(std::string& fname, StringSet& failedPaths)
{
    char* ext = GetExtension(GetPlainName((char*)fname.c_str()));

    // < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
    if (!strcmp(ext, ".mdx"))
    {
        // replace .mdx -> .m2
        fname.erase(fname.length() - 2, 2);
        fname.append("2");
    }
    // >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
    // nothing do

    std::string output(szWorkDirWmo);                       // Stores output filename (possible changed)
    output += "/";
    output += GetPlainName(fname.c_str());


    if (FileExists(output.c_str()))
        return true;

    Model mdl(fname);                                       // Possible changed fname
    if (!mdl.open(failedPaths))
        return false;

    return mdl.ConvertToVMAPModel(output.c_str());
}
Exemplo n.º 3
0
bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet& failedPaths, int iCoreNumber, const void *szRawVMAPMagic)
{
    string ext = GetExtension(origPath);

    // < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
    if ((ext == "mdx") || (ext=="mdl"))
    {
        // replace .md[l,x] -> .m2
        origPath.erase(origPath.length() - 2, 2);
        origPath.append("2");
    }
    // >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
    // nothing do

    fixedName = GetUniformName(origPath);
    std::string output(szWorkDirWmo);                       // Stores output filename
    output += "/";
    output += fixedName;

    if (FileExists(output.c_str()))
        { return true; }

    Model mdl(origPath);                                    // Possible changed fname
    if (!mdl.open(failedPaths, iCoreNumber))
        { return false; }

    return mdl.ConvertToVMAPModel(output, iCoreNumber, szRawVMAPMagic);
}
Exemplo n.º 4
0
bool ExtractSingleModel(std::string& fname)
{
    if (fname.substr(fname.length() - 4, 4) == ".mdx")
    {
        fname.erase(fname.length() - 2, 2);
        fname.append("2");
    }

    std::string originalName = fname;

    char* name = GetPlainName((char*)fname.c_str());
    FixNameCase(name, strlen(name));
    FixNameSpaces(name, strlen(name));

    std::string output(szWorkDirWmo);
    output += "/";
    output += name;

    if (FileExists(output.c_str()))
        return true;

    Model mdl(originalName);
    if (!mdl.open())
        return false;

    return mdl.ConvertToVMAPModel(output.c_str());
}
Exemplo n.º 5
0
int main(int, const char * []) {
  IloEnv env;
  try {
    IloIntVarArray x(env);
    for (IloInt i = 0; i < 10; i++) {
      char name[6];
      sprintf(name, "X%ld", i);
      x.add(IloIntVar(env, 0, 100 - 2*(i / 2), name));
    }
    IloModel mdl(env);
    mdl.add(IloAllDiff(env, x));
    mdl.add(x);

    IloIntVarChooser varChooser   = ChooseSmallestCentroid(env);
    IloIntValueChooser valChooser = ChooseSmallestDistanceFromCentroid(env);
    IloSearchPhase sp1(env, x, varChooser, valChooser);

    IloIntVarEval   varEval       = Centroid(env);
    IloIntValueEval valEval       = DistanceFromCentroid(env);
    IloSearchPhase sp2(env, x, IloSelectSmallest(varEval),
                               IloSelectSmallest(valEval));

    // sp2 can have ties as two variable or values could evaluate
    // to the same values.  sp3 shows how to break these ties
    // choosing, for equivalent centroid and distance-to-centroid
    // evaluations, the lowest indexed variable in x and the
    // lowest value.
    IloVarSelectorArray selVar(env);
    selVar.add(IloSelectSmallest(varEval));
    selVar.add(IloSelectSmallest(IloVarIndex(env, x))); // break ties on index

    IloValueSelectorArray selValue(env);
    selValue.add(IloSelectSmallest(valEval));
    selValue.add(IloSelectSmallest(IloValue(env))); // break ties on smallest

    IloSearchPhase sp3(env, x, selVar, selValue);

    IloCP cp(mdl);
    cp.setParameter(IloCP::Workers, 1);
    cp.setParameter(IloCP::SearchType, IloCP::DepthFirst);
    cp.setParameter(IloCP::LogPeriod, 1);
    cp.out() << "Choosers" << std::endl;
    cp.solve(sp1);
    cp.out() << cp.domain(x) << std::endl;

    cp.out() << "Evaluators" << std::endl;
    cp.solve(sp2);
    cp.out() << cp.domain(x) << std::endl;
    cp.out() << "Evaluators (with tie-break)" << std::endl;
    cp.solve(sp3);
    cp.out() << cp.domain(x) << std::endl;

    cp.end();
  } catch (IloException & ex) {
    env.out() << "Caught: " << ex << std::endl;
  }
  env.end();
  return 0;
}
Exemplo n.º 6
0
void DBlockHeader::load(std::istream &stream, size_t blockid)
{
    mUnknown1 = VFS::read_le32(stream);
    mWidth = VFS::read_le32(stream);
    mHeight = VFS::read_le32(stream);
    mObjectRootOffset = VFS::read_le32(stream);
    mUnknown2 = VFS::read_le32(stream);
    stream.read(mModelData[0].data(), sizeof(mModelData));
    for(uint32_t &val : mUnknown3)
        val = VFS::read_le32(stream);

    stream.seekg(mObjectRootOffset);

    std::vector<int32_t> rootoffsets(mWidth*mHeight);
    for(int32_t &val : rootoffsets)
        val = VFS::read_le32(stream);

    for(int32_t offset : rootoffsets)
    {
        while(offset > 0)
        {
            stream.seekg(offset);
            int32_t next = VFS::read_le32(stream);
            /*int32_t prev =*/ VFS::read_le32(stream);

            int32_t x = VFS::read_le32(stream);
            int32_t y = VFS::read_le32(stream);
            int32_t z = VFS::read_le32(stream);
            uint8_t type = stream.get();
            uint32_t objoffset = VFS::read_le32(stream);

            if(type == ObjectType_Model)
            {
                stream.seekg(objoffset);
                ref_ptr<ModelObject> mdl(new ModelObject(blockid|offset, x, y, z));
                mdl->load(stream, mModelData);

                mObjects.insert(blockid|offset, mdl);
            }
            else if(type == ObjectType_Flat)
            {
                stream.seekg(objoffset);
                ref_ptr<FlatObject> flat(new FlatObject(blockid|offset, x, y, z));
                flat->load(stream);

                mObjects.insert(blockid|offset, flat);
            }

            offset = next;
        }
    }

    for(ref_ptr<ObjectBase> &obj : mObjects)
        obj->loadAction(stream, *this);
}
Exemplo n.º 7
0
static void test_maximize(opt::model_based_opt& mbo, ast_manager& m, unsigned num_vars, expr_ref_vector const& fmls, app* t) {
    qe::arith_project_plugin plugin(m);
    model mdl(m);    
    arith_util a(m);
    for (unsigned i = 0; i < num_vars; ++i) {
        app_ref var(m);
        mk_var(i, var);
        rational val = mbo.get_value(i);
        mdl.register_decl(var->get_decl(), a.mk_numeral(val, false));
    }
    expr_ref ge(m), gt(m);
    opt::inf_eps value1 = plugin.maximize(fmls, mdl, t, ge, gt);
    opt::inf_eps value2 = mbo.maximize();    
    std::cout << "optimal: " << value1 << " " << value2 << "\n";
    mbo.display(std::cout);
}
Exemplo n.º 8
0
model decode_omdl(const path_t& path
	, const void* buffer, size_t size
	, const layout_t& desired_layout
	, const allocator& subsets_alloc
	, const allocator& mesh_alloc
	, const allocator& temp_alloc)
{
	if (!is_omdl(buffer, size))
		return model();

	auto hdr = (const file_header*)buffer;
	auto chk = hdr->find_chunk(omdl_info_signature);

	if (!chk)
		oThrow(std::errc::invalid_argument, "invalid omdl: no info section");

	auto info = *chk->data<info_t>();
	
	model mdl(info, subsets_alloc, mesh_alloc);

	chk = chk->next();
	
	if (chk->fourcc != omdl_subsets_signature)
		oThrow(std::errc::invalid_argument, "invalid omdl: no subsets section");

	memcpy(mdl.subsets(), chk->data<subset_t>(), chk->uncompressed_bytes);

	chk = chk->next();

	if (chk->fourcc != omdl_indices_signature)
		oThrow(std::errc::invalid_argument, "invalid omdl: no indices section");

	memcpy(mdl.indices(), chk->data<uint16_t>(), chk->uncompressed_bytes);

	const uint32_t nslots = info.num_slots;
	for (uint32_t slot = 0; slot < nslots; slot++)
	{
		chk = chk->next();

		if (chk->fourcc != omdl_vertex_slot_signature)
			oThrow(std::errc::invalid_argument, "invalid omdl: no vertices slot section");

		memcpy(mdl.vertices(slot), chk->data<void>(), chk->uncompressed_bytes);
	}

	return mdl;
}
Exemplo n.º 9
0
/**
 * \brief Load a model.
 * \param path The path to the model to load.
 */
void bf::main_frame::load_model( const wxString& path )
{
  wxLogNull no_log;

  gui_model* mdl(NULL);

  try
    {
      xml::model_file reader;
      mdl = reader.load(path);

      add_model_view( new model_frame(*m_windows_layout, mdl, path) );
    }
  catch( std::exception& e )
    {
      delete mdl;
      throw;
    }
} // main_frame::load_model()
Exemplo n.º 10
0
 lbool gia_pareto::operator()() {
     expr_ref fml(m);
     lbool is_sat = m_solver->check_sat(0, 0);
     if (is_sat == l_true) {
         {
             solver::scoped_push _s(*m_solver.get());
             while (is_sat == l_true) {
                 if (m.canceled()) {
                     return l_undef;
                 }
                 m_solver->get_model(m_model);
                 m_solver->get_labels(m_labels);
                 IF_VERBOSE(1,
                            model_ref mdl(m_model);
                            cb.fix_model(mdl); 
                            model_smt2_pp(verbose_stream() << "new model:\n", m, *mdl, 0););
                 // TBD: we can also use local search to tune solution coordinate-wise.
                 mk_dominates();
                 is_sat = m_solver->check_sat(0, 0);
             }
Exemplo n.º 11
0
vpz::BaseModel* ModelFactory::createModelFromClass(Coordinator& coordinator,
                                                 vpz::CoupledModel* parent,
                                                 const std::string& classname,
                                                 const std::string& modelname)
{
    vpz::Class& classe(mClasses.get(classname));
    vpz::BaseModel* mdl(classe.model()->clone());
    vpz::AtomicModelVector atomicmodellist;
    vpz::BaseModel::getAtomicModelList(mdl, atomicmodellist);
    parent->addModel(mdl, modelname);

    for (vpz::AtomicModelVector::iterator it = atomicmodellist.begin();
         it != atomicmodellist.end(); ++it) {
        createModel(coordinator,
                    *it,
                    (*it)->dynamics(),
                    (*it)->conditions(),
                    (*it)->observables());
    }

    return mdl;
}
Exemplo n.º 12
0
	Client::Client(const std::string & configfile, int32_t coreID)
	{
		/* creates the configuration object from the configuration file */
		DBG("Starting Damaris client");
		try {
			std::auto_ptr<Model::simulation_mdl> 
				mdl(Model::simulation(configfile.c_str(),
						xml_schema::flags::dont_validate));
			DBG("Model initialized successfuly");

			config = Configuration::getInstance();
			config->initialize(mdl,configfile);
			DBG("Configuration intialized successfuly");

			env = config->getEnvironment();
			env->setID(coreID);
			DBG("Environment initialized succesfuly");
			init(config);
		} catch(xml_schema::exception &e) {
			ERROR(e.what());
			exit(-1);
		}
	}
Exemplo n.º 13
0
	/* constructor for embedded mode */
Server::Server(const std::string &cf, int id)
{
	try {
		std::auto_ptr<Model::simulation_mdl> 
			mdl(Model::simulation(cf.c_str(),xml_schema::flags::dont_validate));

		DBG("Model build successfuly from configuration file");		

		config = Configuration::getInstance();
		config->initialize(mdl,cf);
		DBG("Configuration initialized successfuly");

		env = config->getEnvironment();
		env->setID(id);
		DBG("Environment initialized successfuly");
	
		init();

	} catch(xml_schema::exception &e) {
                ERROR(e.what());
                exit(-1);
        }
}
Exemplo n.º 14
0
Client* start_mpi_entity(const std::string& configFile, MPI_Comm globalcomm)
{
	/* Global rank and size in the passed communicator */
	int size, rank;
	MPI_Comm_size(globalcomm,&size);
	MPI_Comm_rank(globalcomm,&rank);

	Configuration* config = Configuration::getInstance();
	
	try {
		std::auto_ptr<Model::simulation_mdl> 
			mdl(Model::simulation(configFile.c_str(),xml_schema::flags::dont_validate));

		config->initialize(mdl,configFile);	
	} catch (xml_schema::exception &e) {
		ERROR(e.what());
		MPI_Abort(MPI_COMM_WORLD,-1);
	}

	Environment* env = config->getEnvironment();
	env->setGlobalComm(globalcomm);

	/* The name of the processor is used to compute communicators */
	char procname[MPI_MAX_PROCESSOR_NAME];
	int len;
	MPI_Get_processor_name(procname,&len);

	/* Compute the node identifier from the name */
	uint64_t nhash = (uint64_t)(14695981039346656037ULL);
	uint64_t fnv =  ((uint64_t)1 << 40) + (1 << 8) + 0xb3;
	for(int i=0; i < len; i++) {
		uint64_t c = (uint64_t)(procname[i]);
		nhash = nhash xor c;
		nhash *= fnv;
	}

	/* Create a new communicator gathering processes of the same node */
	int color = ((int)nhash >= 0) ? (int)nhash : - ((int)nhash);
	MPI_Comm nodecomm;
	MPI_Comm_split(globalcomm,color,rank,&nodecomm);
	env->setNodeComm(nodecomm);
	
	/* Get the size and rank in the node */
	int rankInNode;
	int sizeOfNode;
	MPI_Comm_rank(nodecomm,&rankInNode);
	MPI_Comm_size(nodecomm,&sizeOfNode);
	
	/* Get the number of clients and cores provided in configuration */
	int clpn = env->getClientsPerNode();
	int copn = env->getCoresPerNode();

	if(copn - clpn > 1) {
		ERROR("The number of dedicated cores per node must be either 0 or 1 in this version. Aborting...");
		MPI_Abort(MPI_COMM_WORLD,-1);
	}

	/* Check that the values match */
	if(sizeOfNode != copn) {
		ERROR("The number of cores detected in node does not match the number" 
			<< " provided in configuration."
			<< " This may be due to a configuration error or a (unprobable)"
			<< " hash colision in the algorithm. Aborting...");
		MPI_Abort(MPI_COMM_WORLD,-1);
	}

	/* Compute the communcator for clients and servers */
	int is_client = (rankInNode >= clpn) ? 0 : 1;
	MPI_Comm entitycomm;
	MPI_Comm_split(globalcomm,is_client,rank,&entitycomm);
	env->setEntityComm(entitycomm);
	
	/* Get rank and size in the entity communicator */
	int rankInEnComm, sizeOfEnComm;
	MPI_Comm_rank(entitycomm,&rankInEnComm);
	MPI_Comm_size(entitycomm,&sizeOfEnComm);

	/* Set the rank of the entity */
	env->setID(rankInEnComm);

	if(not (copn == clpn)) {
		// dedicated core mode : the number of servers to create is strictly positive
		if(is_client) {
			DBG("Client starting, rank = " << rank);
			// the following barrier ensures that the client
			// won't be created before the servers are started.
			MPI_Barrier(globalcomm);
			return new Client(config);
		} else {
			DBG("Server starting, rank = " << rank);
			Server server(config);
			MPI_Barrier(globalcomm);
			server.run();
			return NULL;
		}
	} else {
		// synchronous mode : the servers are attached to each client
		if(rankInNode != 0) {
			MPI_Barrier(globalcomm);
			return new SecondaryServer(config);
		} else {
			Server* s = new Server(config);
			MPI_Barrier(globalcomm);
			return s;
		}
	}
}	
Exemplo n.º 15
0
static void test_project() {
    ast_manager m;
    reg_decl_plugins(m);    
    qe::arith_project_plugin plugin(m);    
    arith_util a(m);
    app_ref_vector vars(m);
    expr_ref_vector lits(m), ds(m);
    model mdl(m);    
    app_ref x(m), y(m), z(m), u(m);
    x = m.mk_const(symbol("x"), a.mk_int());
    y = m.mk_const(symbol("y"), a.mk_int());
    z = m.mk_const(symbol("z"), a.mk_int());
    u = m.mk_const(symbol("u"), a.mk_int());
    func_decl_ref f(m);
    sort* int_sort = a.mk_int();
    f = m.mk_func_decl(symbol("f"), 1, &int_sort, int_sort);

    // test non-projection
    mdl.register_decl(x->get_decl(), a.mk_int(0));
    mdl.register_decl(y->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(2));
    mdl.register_decl(u->get_decl(), a.mk_int(3));
    func_interp* fi = alloc(func_interp, m, 1);
    expr_ref_vector nums(m);
    nums.push_back(a.mk_int(0));
    nums.push_back(a.mk_int(1));
    nums.push_back(a.mk_int(2));
    fi->insert_new_entry(nums.c_ptr(),   a.mk_int(1));
    fi->insert_new_entry(nums.c_ptr()+1, a.mk_int(2));
    fi->insert_new_entry(nums.c_ptr()+2, a.mk_int(3));
    fi->set_else(a.mk_int(10));
    mdl.register_decl(f, fi);
    vars.reset();
    lits.reset();
    vars.push_back(x);
    lits.push_back(x <= app_ref(m.mk_app(f, (expr*)x), m));
    lits.push_back(x < y);
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // test not-equals
    vars.reset();
    lits.reset();
    vars.push_back(x);
    lits.push_back(m.mk_not(m.mk_eq(x, y)));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // test negation of distinct using bound variables
    mdl.register_decl(x->get_decl(), a.mk_int(0));
    mdl.register_decl(y->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(0));
    mdl.register_decl(u->get_decl(), a.mk_int(6));
    vars.reset();
    lits.reset();
    ds.reset();
    vars.push_back(x);
    vars.push_back(y);
    ds.push_back(x);
    ds.push_back(y);
    ds.push_back(z + 2);
    ds.push_back(u);
    ds.push_back(z);
    lits.push_back(m.mk_not(m.mk_distinct(ds.size(), ds.c_ptr())));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // test negation of distinct, not using bound variables
    mdl.register_decl(x->get_decl(), a.mk_int(0));
    mdl.register_decl(y->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(0));
    mdl.register_decl(u->get_decl(), a.mk_int(6));
    vars.reset();
    lits.reset();
    ds.reset();
    vars.push_back(x);
    vars.push_back(y);
    ds.push_back(x);
    ds.push_back(y);
    ds.push_back(z + 2);
    ds.push_back(u);
    ds.push_back(z + 10);
    ds.push_back(u + 4);
    lits.push_back(m.mk_not(m.mk_distinct(ds.size(), ds.c_ptr())));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";


    // test distinct
    mdl.register_decl(x->get_decl(), a.mk_int(0));
    mdl.register_decl(y->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(0));
    mdl.register_decl(u->get_decl(), a.mk_int(6));
    vars.reset();
    lits.reset();
    ds.reset();
    vars.push_back(x);
    vars.push_back(y);
    ds.push_back(x);
    ds.push_back(y);
    ds.push_back(z + 2);
    ds.push_back(u);
    lits.push_back(m.mk_distinct(ds.size(), ds.c_ptr()));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // equality over modulus
    mdl.register_decl(y->get_decl(), a.mk_int(4));
    mdl.register_decl(z->get_decl(), a.mk_int(8));
    lits.reset();
    vars.reset();
    vars.push_back(y);
    lits.push_back(m.mk_eq(a.mk_mod(y, a.mk_int(3)), a.mk_int(1)));
    lits.push_back(m.mk_eq(2*y, z));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // inequality test
    mdl.register_decl(x->get_decl(), a.mk_int(0));
    mdl.register_decl(y->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(0));
    mdl.register_decl(u->get_decl(), a.mk_int(6));
    vars.reset();
    lits.reset();
    vars.push_back(x);
    vars.push_back(y);
    lits.push_back(z <= (x + (2*y)));
    lits.push_back(2*x < u + 3);
    lits.push_back(2*y <= u);
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";

    // non-unit equalities
    mdl.register_decl(x->get_decl(), a.mk_int(1));
    mdl.register_decl(z->get_decl(), a.mk_int(2));
    mdl.register_decl(u->get_decl(), a.mk_int(3));
    mdl.register_decl(y->get_decl(), a.mk_int(4));
    lits.reset();
    vars.reset();
    vars.push_back(x);
    lits.push_back(m.mk_eq(2*x, z));
    lits.push_back(m.mk_eq(3*x, u));
    plugin(mdl, vars, lits);
    std::cout << lits << "\n";


}
Exemplo n.º 16
0
Arquivo: plotFit.C Projeto: jxi24/GAPP
void plotFit(TString filename = "fp-d", TString pltmd = "tph") {

// CHECK FOR RIGHT INPUT ////////////////////////////////////////////////

   string strpltmd = pltmd;

   if( strpltmd.compare("tph")  != 0 &&
       strpltmd.compare("s2b")  != 0 &&
       strpltmd.compare("mmp") != 0 ) {error(4);};
   
// OPEN THE ROOT FILE  //////////////////////////////////////////////////

   gROOT->Reset();
   gROOT->SetStyle("Plain");
   gStyle->SetTitleBorderSize(0);
   gStyle->SetPalette(1);

   TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit",200,10,700,500);

// Still to do: Automate the frame boundaries. 
   
   string strfile = filename, rootname = strfile + ".root";

   TFile *rootfile = TFile::Open(rootname.c_str());
      
   if(rootfile == NULL) error(1);
      
   TTree *tree = (TTree*)rootfile->Get(strfile.c_str());
   
   if(tree == NULL) error(2);
   
   TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b");
   
   TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph");
   
   TBranch *fitxbranch   = (TBranch*)tree->GetBranch("fitx");
   
   if( (fits2bbranch == NULL) || (fittphbranch == NULL) || (fitxbranch == NULL) ) error(3);
   
   Float_t fits2b, fittph, fitx;
      
   tree->SetBranchAddress("fits2b",&fits2b);

   tree->SetBranchAddress("fittph",&fittph);
   
   tree->SetBranchAddress("fitx",  &fitx);
   
   
// GET GRID /////////////////////////////////////////////////////////////

   Int_t Npoints = (Int_t)tree->GetEntries();

   Int_t point, zSteps = 0, ySteps = 0;

   Float_t fitxMin = 100000, fitxMax = -1.0, s2bMin = 100000, tphMin = 100000;

   Float_t s2bMax = -1.0, tphMax = -1.0;

   for(point=0; point<Npoints; point++) {
      
      tree->GetEntry(point);
      
      if( fits2b > s2bMax ) {zSteps++; s2bMax = fits2b;}

      if( fittph > tphMax ) {ySteps++; tphMax = fittph;}
      
   };

   const int s2bSteps = zSteps, tphSteps = ySteps, mmpSteps = Npoints;

   Float_t s2bValues[s2bSteps], tphValues[tphSteps];

   s2bMax = -1.0, tphMax = -1.0;

   int s2bStep = 0, tphStep = 0;

   for(point=0; point<Npoints; point++) {
      
      tree->GetEntry(point);
      
      if( fits2b > s2bMax ) {s2bValues[s2bStep] = fits2b; s2bStep++; s2bMax = fits2b;}

      if( fittph > tphMax ) {tphValues[tphStep] = fittph; tphStep++; tphMax = fittph;}
      
   };

// PREPARE PLOT /////////////////////////////////////////////////////////

   string plottitle = "Model: " + strfile + "  |  Plot: ";

   if( strpltmd.compare("tph") == 0 ) {

      plottitle += "tan^{2}(#phi) over x for fixed sin^{2}(2#beta)";

   }

   if( strpltmd.compare("s2b") == 0 ) {

      plottitle += "sin^{2}(2#beta) over x for fixed tan^{2}(#phi)";

   }

   if( strpltmd.compare("mmp") == 0 ) {

      plottitle += "Masses of the new heavy gauge bosons";

   }

//  PLOT DATA ///////////////////////////////////////////////////////////

   if (strpltmd.compare("tph") == 0) {

      tphMax = -1.0;

//    TGraph *tphplots[s2bSteps];
      TGraph *tphplots[s2bSteps-30];

//    for(s2bStep=0; s2bStep<s2bSteps; s2bStep++) {
      for(s2bStep=0; s2bStep<s2bSteps-30; s2bStep++) {

         Float_t tphArray[tphSteps], fitxArray[tphSteps];

         tphStep = 0;

         for(point=0; point<Npoints; point++) {
      
            tree->GetEntry(point);
      
            if(fits2b == s2bValues[s2bStep]) {

//             tphArray[tphStep]  = fittph;
               tphArray[tphStep]  = sqrt(1.0/(1.0+fittph));

               if (fittph < tphMin) tphMin = fittph;

               if (fittph > tphMax) tphMax = fittph;

               fitxArray[tphStep] = fitx;

               if (fitx < fitxMin) fitxMin = fitx;

               if (fitx > fitxMax) fitxMax = fitx;

               tphStep++;


              TMarker *m = new TMarker(fitxArray[tphStep],tphArray[tphStep],20);
              m->SetMarkerSize(2);
              m->SetMarkerColor(31+tphStep);
              m->Draw();



            }
         }

         if (s2bStep == 0) {

            TH1F* frame = MyC->DrawFrame(0.0,0.0,1.1*fitxMax,1.1);
//          TH1F* frame = MyC->DrawFrame(0.7*fitxMin,0.7*tphMin,1.1*fitxMax,1.1*tphMax);

            TAxis *xaxis = frame->GetXaxis();
            TAxis *yaxis = frame->GetYaxis();
   
            xaxis->SetTitle("x = u^{2}/v^{2}");
            xaxis->CenterTitle();
            xaxis->SetTitleOffset(1.);
            xaxis->SetDecimals();
            xaxis->SetLabelSize(0.03);
            xaxis->SetLabelOffset(0.01);
        
            yaxis->SetTitle("tan^{2}(#phi)");
            yaxis->CenterTitle();
            yaxis->SetTitleOffset(1.);
            yaxis->SetDecimals();
            yaxis->SetLabelSize(0.03);
            yaxis->SetLabelOffset(0.01);

            frame->SetTitle(plottitle.c_str());

         }

         tphplots[s2bStep] = new TGraph(tphSteps,fitxArray,tphArray);

         tphplots[s2bStep]->SetMarkerStyle(20);

         tphplots[s2bStep]->SetMarkerSize(0.4);
   
         tphplots[s2bStep]->Draw("CP");

      }
   }

   else if (strpltmd.compare("s2b") == 0) {

      s2bMax = -1.0;

      TGraph *s2bplots[tphSteps-100];

      for(tphStep=0; tphStep<tphSteps-100; tphStep++) {

         Float_t s2bArray[s2bSteps], fitxArray[s2bSteps];

         s2bStep = 0;

         for(point=0; point<Npoints; point++) {
      
            tree->GetEntry(point);
      
            if(fittph == tphValues[tphStep+20]) {

               s2bArray[s2bStep]  = fits2b;

               if (fits2b < s2bMin) s2bMin = fits2b;

               if (fits2b > s2bMax) s2bMax = fits2b;

               fitxArray[s2bStep] = fitx;

               if (fitx < fitxMin) fitxMin = fitx;

               if (fitx > fitxMax) fitxMax = fitx;

               s2bStep++;              

            }
         }

         if (tphStep == 0) {

            TH1F* frame = MyC->DrawFrame(0.8*fitxMin,0.95*s2bMin,1.2*fitxMax,1.05*s2bMax);

            TAxis *xaxis = frame->GetXaxis();
            TAxis *yaxis = frame->GetYaxis();
   
            xaxis->SetTitle("x = u^{2}/v^{2}");
            xaxis->CenterTitle();
            xaxis->SetTitleOffset(1.);
            xaxis->SetDecimals();
            xaxis->SetLabelSize(0.03);
            xaxis->SetLabelOffset(0.01);

            yaxis->SetTitle("sin^{2}(2#beta)");
            yaxis->CenterTitle();
            yaxis->SetTitleOffset(1.25);
            yaxis->SetDecimals();
            yaxis->SetLabelSize(0.03);
            yaxis->SetLabelOffset(0.01);

            frame->SetTitle(plottitle.c_str());

         }

         s2bplots[tphStep] = new TGraph(s2bSteps,fitxArray,s2bArray);

         s2bplots[tphStep]->SetMarkerStyle(20);

         s2bplots[tphStep]->SetMarkerSize(0.4);

         s2bplots[tphStep]->Draw("C");

      }
   }

   else if (strpltmd.compare("mmp") == 0) {

      Float_t mzpArray[mmpSteps], mwpArray[mmpSteps];

      Float_t mzpMin = 100000, mzpMax = -1.0, mwpMin = 100000, mwpMax = -1.0;

      Float_t fitsph, fitcph; 

      Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2;

      string mdl(strfile,0,2);

      if ( (mdl.compare("lr") == 0) ||
           (mdl.compare("lp") == 0) ||
           (mdl.compare("hp") == 0) ||
           (mdl.compare("fp") == 0) ) {

         string Higgs(strfile,3,1);

         if (Higgs.compare("d") == 0) {

            Cz1 = 11.95349795785275;
            Cz2 = 30.63269990028513;
            Cz3 = 42.58619785813789;
            Cw1 = 21.29309892906894;
            Cw2 = 9.339600971216193;
            Cw3 = 30.63269990028513;
            Cw4 = 42.58619785813789;

         }

         else if (Higgs.compare("t") == 0) {

            Cz1 = 5.976748978926375;
            Cz2 = 30.63269990028513;
            Cz3 = 85.17239571627579;
            Cw1 = 15.05649464522066;
            Cw2 = 3.302047590161717;
            Cw3 = 21.66058982554409;
            Cw4 = 60.22597858088265;

         } else {error(6);}

         for(point=0; point<Npoints; point++) {
      
            tree->GetEntry(point);

            fitsph = fittph / (1.0 + fittph);

            fitcph = 1.0 - fitsph;

            if (fitsph != 0.0) {

               mzpArray[point] = (0.001/sqrt(fitsph*fitcph*fitx)) * (Cz1*fitcph*fitcph + Cz2*fits2b + Cz3*fitx);

               if (mzpArray[point] < mzpMin) mzpMin = mzpArray[point];

               if (mzpArray[point] > mzpMax) mzpMax = mzpArray[point];

               mwpArray[point] = (0.001/sqrt(fitsph*fitx))  * (Cw1 - Cw2*fitcph*fitcph + Cw3*fits2b + Cw4*fitx);

               if (mwpArray[point] < mwpMin) mwpMin = mwpArray[point];

               if (mwpArray[point] > mwpMax) mwpMax = mwpArray[point];

            } else {

               mzpArray[point] = 0.0;

               mwpArray[point] = 0.0;

            }
         }
      } 

      else if ( (mdl.compare("uu") == 0) ||
                (mdl.compare("nu") == 0) ) {

         C1 = 94.0397928463607
         C2 = 77.1253849720165

         for(point=0; point<Npoints; point++) {
      
            tree->GetEntry(point);

            fitsph = fittph / (1.0+fittph);

            fitcph = 1.0 - fitsph;

            if (fitsph != 0.0) {

               mzpArray[point] = (0.001/sqrt(fitsph*fitcph*fitx)) * (C1*fitsph*fitsph + C2*fitx);

               if (mzpArray[point] < mzpMin) mzpMin = mzpArray[point];

               if (mzpArray[point] > mzpMax) mzpMax = mzpArray[point];

               mwpArray[point] = (0.001/sqrt(fitsph*fitcph*fitx)) * (C1*fitsph*fitsph + C2*fitx);

               if (mwpArray[point] < mwpMin) mwpMin = mwpArray[point];

               if (mwpArray[point] > mwpMax) mwpMax = mwpArray[point];

            } else {

               mzpArray[point] = 0.0;

               mwpArray[point] = 0.0;

            }
         }
      }
Exemplo n.º 17
0
Arquivo: plot3.C Projeto: jxi24/GAPP
void plot3(TString infile = "fp-d", TString pltmd = "cos") {

// CHECK FOR RIGHT INPUT ////////////////////////////////////////////////

   string strpltmd = pltmd, filename = infile, strfile = infile;

   if( (strpltmd.compare("cos") != 0 ) &&
       (strpltmd.compare("sin") != 0 ) &&
       (strpltmd.compare("tan") != 0 ) &&
       (strpltmd.compare("mmp") != 0 ) ) {error(4);};

// GLOBAL VARIABLES  ////////////////////////////////////////////////////

   Int_t file, point, color, style;

   Float_t fits2b, fittph, tphold, fitsph, fitcph, fitx, fitxmin, fitxmax = -1.0;

   Float_t xVal, yVal;

   Float_t xMin = 100000, xMax = -1.0, yMin = 100000, yMax = -1.0;

   Float_t MZ, MW, Mmin = 100000;

   Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2;

   Float_t phiMin, phiMax, cphmin, cphmax, sphmin, sphmax;

// CUSTOMIZE PLOT ///////////////////////////////////////////////////////

   gROOT->Reset();
   gROOT->SetStyle("Plain");
   gStyle->SetTitleBorderSize(0);
   gStyle->SetPalette(1);

   TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit results",200,10,700,500);

   Float_t mmlegxmin, mmlegxmax, mmlegymin, mmlegymax;

   Float_t s2blegxmin, s2blegymin, s2blegxmax, s2blegymax;

   Float_t lblxmin, lblxmax, lblymin, lblymax;

   string plottitle = "Model: " + infile + "  |  Plot: ";

   string xtitle, ytitle, NPleg, SMleg, display;

   NPleg = "#font[52]{M_{H}^{(NP)}, #bar{m}_{t}^{(NP)}}";
   SMleg = "#font[52]{M_{H}^{(SM)}, #bar{m}_{t}^{(SM)}}";

   if (strpltmd.compare("tan") == 0) { 

      plottitle += "#font[42]{tan^{2}(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{tan^{2}(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.15;
      s2blegxmax = 0.40;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.88;
      lblxmax = 0.88;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("cos") == 0) { 

      plottitle += "#font[42]{cos(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{cos(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.70;
      mmlegxmax = 0.85;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.15;
      s2blegxmax = 0.40;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.65;
      lblxmax = 0.80;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("sin") == 0) {

      plottitle += "#font[42]{sin(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{sin(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.60;
      s2blegxmax = 0.85;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.65;
      lblxmax = 0.80;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("mmp") == 0) {

      plottitle += "#font[42]{Masses of the new heavy gauge bosons.}";
      xtitle = "#font[52]{M_{Z'}}#font[42]{ (TeV)}";
      ytitle = "#font[52]{M_{W'}}#font[42]{ (TeV)}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.60;
      s2blegxmax = 0.85;
      s2blegymin = 0.45;
      s2blegymax = 0.65;

      lblxmin = 0.35;
      lblxmax = 0.50;
      lblymin = 0.45;
      lblymax = 0.50;

   };
   
// PREPARE BOSON MASSES AND PHI BOUNDS //////////////////////////////////

   string mdl(filename,0,2);

   if ( (mdl.compare("lr") == 0) ||
        (mdl.compare("lp") == 0) ||
        (mdl.compare("hp") == 0) ||
        (mdl.compare("fp") == 0) ) {

      phiMin = 5.600; phiMax = 84.400;

      string Higgs(filename,3,1);

      if (Higgs.compare("d") == 0) {

         Cz1 = 11.95349795785275;
         Cz2 = 30.63269990028513;
         Cz3 = 42.58619785813789;
         Cw1 = 21.29309892906894;
         Cw2 = 9.339600971216193;
         Cw3 = 30.63269990028513;
         Cw4 = 42.58619785813789;

      }

      else if (Higgs.compare("t") == 0) {

         Cz1 = 5.976748978926375;
         Cz2 = 30.63269990028513;
         Cz3 = 85.17239571627579;
         Cw1 = 15.05649464522066;
         Cw2 = 3.302047590161717;
         Cw3 = 21.66058982554409;
         Cw4 = 60.22597858088265;

      }
   } 

   else if ( (mdl.compare("uu") == 0) ||
             (mdl.compare("nu") == 0) ) {

      phiMin = 10.179, phiMax = 79.821;

      C1 = 94.0397928463607;
      C2 = 77.1253849720165;

   } else {error(6);}

      cphmin = cos(TMath::Pi()*phiMin/180.0)*cos(TMath::Pi()*phiMin/180.0);
      cphmax = cos(TMath::Pi()*phiMax/180.0)*cos(TMath::Pi()*phiMax/180.0);
      sphmin = sin(TMath::Pi()*phiMin/180.0)*sin(TMath::Pi()*phiMin/180.0);
      sphmax = sin(TMath::Pi()*phiMax/180.0)*sin(TMath::Pi()*phiMax/180.0);

// LOOP OVER ROOT FILES  ////////////////////////////////////////////////
   
   for(file=0; file<=1; file++) {
   
      if(file==0) string epsfile  =  filename + "_" + strpltmd + ".eps";
      if(file==1) string filename =  filename + "_sm";
      string rootname = filename + ".root";
   
      TFile *rootfile = TFile::Open(rootname.c_str());      
      if(rootfile == NULL) error(1);
      
      TTree *tree = (TTree*)rootfile->Get(filename.c_str());
      if(tree == NULL) error(2);
   
      TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b");
      TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph");
      TBranch *fitxbranch   = (TBranch*)tree->GetBranch("fitx");

      if( (fits2bbranch == NULL) || 
          (fittphbranch == NULL) || 
          (fitxbranch   == NULL) ) error(3);

      tree->SetBranchAddress("fits2b",&fits2b);
      tree->SetBranchAddress("fittph",&fittph);
      tree->SetBranchAddress("fitx",  &fitx);
   
// GET ARRAYS ///////////////////////////////////////////////////////////

      Int_t Npoints = (Int_t)tree->GetEntries();

      Int_t tphStep = 0;

      Float_t tphMax = -1.0;

      for(point=0; point<Npoints; point++) {
      
         tree->GetEntry(point);
      
         if( fittph > tphMax ) {tphStep++; tphMax = fittph;}
      
      };

      const int tphSteps = tphStep;

      Float_t xArray[tphSteps], yArray[tphSteps], zArray[tphSteps];

      tphStep = -1, tphold = -1.0, fitxmin = 100000;

      for(point=0; point<Npoints; point++) {
      
         tree->GetEntry(point);

         if(fittph > tphold) {tphStep++; fitxmin = 100000;}

         fitsph = fittph / (1.0 + fittph);
         fitcph = 1.0 - fitsph; 
      
         if (strpltmd.compare("tan") == 0) {

            xVal = fitx;
            yVal = fittph;

         } else if (strpltmd.compare("cos") == 0) {

            xVal = fitx;
            yVal = sqrt(fitcph); 

         } else if (strpltmd.compare("sin") == 0) { 

            xVal = fitx; 
            yVal = sqrt(fitsph); 

         } else if (strpltmd.compare("mmp") == 0) { 

            if (fitsph != 0.0) {

               if ( (mdl.compare("lr") == 0) ||
                    (mdl.compare("lp") == 0) ||
                    (mdl.compare("hp") == 0) ||
                    (mdl.compare("fp") == 0) ) {

                  MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,xVal,yVal);

               } else if ( (mdl.compare("uu") == 0) ||
                           (mdl.compare("nu") == 0) ) {

                  MMII(C1,C2,fitx,fitsph,fitcph,xVal,yVal);

               }
            }   
         }

         if( (strpltmd.compare("mmp") == 0) && (tphStep==1) ) { 
          
            xArray[0] = xArray[1]; 
            yArray[0] = yArray[1];
            zArray[0] = zArray[1]; 
 
         }

         if(fitx>fitxmax) fitxmax = fitx;

         if(fitx<fitxmin) {
 
            xArray[tphStep] = xVal;
            yArray[tphStep] = yVal;
            zArray[tphStep] = fits2b;
            fitxmin = fitx;

         }
  
         tphold = fittph;
 
      }

      if(file==0) TGraph *NPplot = new TGraph(tphSteps,xArray,yArray);
      if(file==1) TGraph *SMplot = new TGraph(tphSteps,xArray,yArray);

      TMarker *NPmrk[tphSteps], *SMmrk[tphSteps];

      for(tphStep=0; tphStep<tphSteps; tphStep++){

         marker(zArray[tphStep],color,style);

         if(file==0) { NPmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style);
                       NPmrk[tphStep]->SetMarkerSize(0.8);    
                       NPmrk[tphStep]->SetMarkerColor(color);}
         if(file==1) { SMmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style);
                       SMmrk[tphStep]->SetMarkerSize(0.8);    
                       SMmrk[tphStep]->SetMarkerColor(color);}

         if( (strpltmd.compare("mmp") != 0) || (tphStep !=0 )) {

            if (xArray[tphStep] < xMin) xMin = xArray[tphStep]; 
            if (xArray[tphStep] > xMax) xMax = xArray[tphStep]; 
            if (yArray[tphStep] < yMin) yMin = yArray[tphStep]; 
            if (yArray[tphStep] > yMax) yMax = yArray[tphStep]; 

         }

         if( ((strfile.compare("uu-d") == 0) || (strfile.compare("nu-d") == 0)) && (strpltmd.compare("sin") == 0) ) {

            fitx = xArray[tphStep];
            fitsph = yArray[tphStep]*yArray[tphStep];
            fitcph = 1.0 - fitsph;

            if( (sphmin < fitsph) && (fitsph<sphmax) ) {

               MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW);

               if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;}
            }
         }
      }
   }
 
// CREATE PLOTS /////////////////////////////////////////////////////////

   NPplot->SetLineStyle(2);
   NPplot->SetMarkerStyle(20);
   NPplot->SetMarkerSize(0.4);
   SMplot->SetMarkerStyle(20);
   SMplot->SetMarkerSize(0.4);
   
   if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;}
   if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;}
   if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;}

   TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax);
   frame->SetTitle(plottitle.c_str());

   TAxis *xaxis = frame->GetXaxis();
   TAxis *yaxis = frame->GetYaxis();   
   xaxis->SetTitle(xtitle.c_str());
   xaxis->CenterTitle();
   xaxis->SetTitleOffset(1.);
   xaxis->SetDecimals();
   xaxis->SetLabelSize(0.03);
   xaxis->SetLabelOffset(0.01);
   yaxis->SetTitle(ytitle.c_str());
   yaxis->CenterTitle();
   yaxis->SetTitleOffset(1.2);
   yaxis->SetDecimals();
   yaxis->SetLabelSize(0.03);
   yaxis->SetLabelOffset(0.01);

   TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax);
   mmleg->AddEntry(NPplot,NPleg.c_str(),"l");
   mmleg->AddEntry(SMplot,SMleg.c_str(),"l"); 
   mmleg->SetTextSize(0.025);
   mmleg->SetFillStyle(0);

   if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) {

      for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();}

   }

   Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0};

   TGraph *circle = new TGraph(1,xdummy,ydummy);
   circle->SetMarkerStyle(24);
   circle->SetMarkerColor(kGreen+1);
   circle->SetMarkerSize(0.8); 
   
   TGraph *square = new TGraph(1,xdummy,ydummy);
   square->SetMarkerStyle(25);
   square->SetMarkerColor(kCyan+1);
   square->SetMarkerSize(0.8); 

   TGraph *triangle = new TGraph(1,xdummy,ydummy);
   triangle->SetMarkerStyle(26);
   triangle->SetMarkerColor(kBlue+1);
   triangle->SetMarkerSize(0.8); 

   TGraph *diamond = new TGraph(1,xdummy,ydummy);
   diamond->SetMarkerStyle(27);
   diamond->SetMarkerColor(kMagenta+1);
   diamond->SetMarkerSize(0.8); 

   TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax); 

   s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p");
   s2bleg->AddEntry(square,"#font[42]{0.25 < sin^{2}(2#tilde{#beta}) #leq 0.50}","p");
   s2bleg->AddEntry(triangle,"#font[42]{0.50 < sin^{2}(2#tilde{#beta}) #leq 0.75}","p");
   s2bleg->AddEntry(diamond,"#font[42]{0.75 < sin^{2}(2#tilde{#beta}) #leq 1.00}","p");
   s2bleg->SetTextSize(0.025);
   s2bleg->SetFillStyle(0); 

   NPplot->Draw(display.c_str());
   SMplot->Draw(display.c_str());
   mmleg->Draw();
   if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) s2bleg->Draw();

// BOUNDS ON PHI //////////////////////////////////////////////////////

   Int_t i;

   const int iSteps = 100;    

   fitxmin = 1.0, fitxmax *= 1.5;

   Float_t deltax = (fitxmax-fitxmin)/iSteps;

   Float_t phixmin0[iSteps], phixmax0[iSteps], phixmin1[iSteps], phixmax1[iSteps];

   Float_t phiymin0[iSteps], phiymax0[iSteps], phiymin1[iSteps], phiymax1[iSteps];

   if ( (strpltmd.compare("tan") == 0) || 
        (strpltmd.compare("cos") == 0) ||
        (strpltmd.compare("sin") == 0) ) {

      for(i=0; i<100; i++) {

         fitx = fitxmin + i*deltax;

         phixmin0[i] = fitx;
         if (strpltmd.compare("tan") == 0) { phiymin0[i] = sphmin / cphmin; phiymax0[i] = sphmax / cphmax; }
         if (strpltmd.compare("cos") == 0) { phiymin0[i] = sqrt(cphmin);    phiymax0[i] = sqrt(cphmax); }
         if (strpltmd.compare("sin") == 0) { phiymin0[i] = sqrt(sphmin);    phiymax0[i] = sqrt(sphmax); }

      }

      TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
      TGraph *phiMax0 = new TGraph(iSteps,phixmin0,phiymax0);

   } else if (strpltmd.compare("mmp") == 0) { 

      if ( (mdl.compare("lr") == 0) ||
           (mdl.compare("lp") == 0) ||
           (mdl.compare("hp") == 0) ||
           (mdl.compare("fp") == 0) ) {

         for(i=0; i<100; i++) {

            fitx = fitxmin + i*deltax;

            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,0.0,phixmin0[i],phiymin0[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,1.0,phixmin1[i],phiymin1[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,0.0,phixmax0[i],phiymax0[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,1.0,phixmax1[i],phiymax1[i]);

         }

         TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
         TGraph *phiMin1 = new TGraph(iSteps,phixmin1,phiymin1);
         TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0);
         TGraph *phiMax1 = new TGraph(iSteps,phixmax1,phiymax1);

         phiMin1->SetLineStyle(7);
         phiMin1->SetMarkerStyle(22);
         phiMin1->SetMarkerSize(1.0);
         phiMax1->SetLineStyle(7);
         phiMax1->SetMarkerStyle(22);
         phiMax1->SetMarkerSize(1.0);

         phiMin1->Draw("C");
         phiMax1->Draw("C");

      } else if ( (mdl.compare("uu") == 0) ||
                  (mdl.compare("nu") == 0) ) {

         for(i=0; i<100; i++) {

            fitx = fitxmin + i*deltax;

            MMII(C1,C2,fitx,sphmin,cphmin,phixmin0[i],phiymin0[i]);
            MMII(C1,C2,fitx,sphmax,cphmax,phixmax0[i],phiymax0[i]);

         }

         TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
         TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0);

      }
   } 
      
   phiMin0->SetLineStyle(3);
   phiMin0->SetMarkerStyle(20);
   phiMin0->SetMarkerSize(0.4);
   phiMax0->SetLineStyle(3);
   phiMax0->SetMarkerStyle(20);
   phiMax0->SetMarkerSize(0.4);

   phiMin0->Draw("C");
   phiMax0->Draw("C");

// LABEL ALLOWED REGION ///////////////////////////////////////////////

   TPaveText *allowed = new TPaveText(lblxmin,lblymin,lblxmax,lblymax,"NDC");
   TText *text = allowed->AddText("#font[42]{allowed (95% CL)}");
   allowed->SetTextSize(0.04);
   if (strpltmd.compare("tan") == 0) text->SetTextAngle(270);
   allowed->SetFillStyle(0);
   allowed->SetLineColor(0);
   allowed->SetBorderSize(1);
   allowed->Draw();

// SAVE GRAPHIC ///////////////////////////////////////////////////////

   MyC->Print(epsfile.c_str());
  
}
Exemplo n.º 18
0
void WorkingPanel::OnKeyDown(wxKeyEvent & e)
{
    int kc = e.GetKeyCode();
    switch (kc) {
    case WXK_LEFT :
        focusCell.col = (focusCell.col?focusCell.col:SudokuBase::Col)-1;
        break;
    case WXK_RIGHT :
        focusCell.col = (focusCell.col+1)%SudokuBase::Col;
        break;
    case WXK_UP :
        focusCell.row = (focusCell.row?focusCell.row:SudokuBase::Row)-1;
        break;
    case WXK_DOWN :
        focusCell.row = (focusCell.row+1)%SudokuBase::Row;
        break;
    default :
        if (fixed[focusCell.row][focusCell.col] == false) {
            if (WXK_NUMPAD0 <= kc && kc <= WXK_NUMPAD9) {
                focusCell.num = kc-WXK_NUMPAD0;
            } else if ('0' <= kc && kc <= '9') {
                focusCell.num = kc-'0';
            } else {
                break;
            }
            static_cast<SudokuFrame*>(myParent)->Record();
            sdk.Fill(focusCell);
            if (static_cast<SudokuFrame*>(myParent)->menuBar->IsChecked(wxID_PLAY)) {
                if (sdk.GetStatus() == Sudoku::Paradoxical) {
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Paradoxical"));
                } else {
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT(""));
                    if (sdk.GetStatus() == Sudoku::Full) {
                        sdks.Solve(sdk);
                        if (sdks.GetStatus() != Sudoku::Paradoxical) {
                            wxMessageDialog mdl(this, wxT("Congratulation! You win!"));
                            mdl.ShowModal();
                        }
                    }
                }
            } else {
                sdks.Solve(sdk);
                switch (sdks.GetStatus()) {
                case SudokuSolver::Paradoxical :
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Paradoxical"));
                    break;
                case SudokuSolver::NotEmpty :
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Not unique"));
                    break;
                case SudokuSolver::Full :
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Effictive"));
                    break;
                case SudokuSolver::Empty :
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Empty"));
                    break;
                default :
                    static_cast<SudokuFrame*>(myParent)->SetStatusText(wxT("Unknow"));
                    break;
                }
            }
        } 
        break;
    }
    Paint();
}