Exemple #1
0
	/*
	 *inputColumn
	 *Description: takes input for column and validates the input. Returns the  column number
	 */
	int inputColumn()
	{
		//variable declaration
        char input;
        int check, test;
        char inputerror[25] = "Please Enter a Number: ";  //sets error msg

        do
        {
            test = 1;  //intialised here for repeating loop
            scanf("%c",&input);
            if(input == '\n')
            {
                spacer();
                printf("%s", inputerror); //error mesg
                test = 0;
            }
            else
            {
                flush();
                check = (int)input; // casts char input into and integer
			    //input validation to check input is a number.
                if(check < 48 || check > 57) //asci values for numbers
                {
                    test = 0; //flags loop to repeat
                    spacer();
                    printf("%s", inputerror); //error message
                }
            }
        }while(test == 0);
		
        return(check - 48); //returns number by removing 48 from the ascii value of int
    }
Exemple #2
0
int mainScreen(int pamt){
    int x, dummy;
    spacer();
    for(x = 0; x < 2; x++){
          tabSpacer();
    }
    printf("     Welcome to the game CLUE!");
    spacer();
    for(x = 0; x < 2; x++){
          tabSpacer();
    }
    printf("Please enter the amount of players: ");
    scanf("%d", &pamt);
    if(pamt > 6){
       for(x = 0; x < 2; x++){
          tabSpacer();
       }
       printf("    Error! Max player amount is 6");
       sleep(5000);
       return 0;
    }
    if(pamt < 2){
        for(x = 0; x < 2; x++){
          tabSpacer();
        }
        printf(" Error! Game needs 2 players to play!");
        sleep(5000);
       return 0;    
    }
    system("cls");
    return pamt;
}
Exemple #3
0
void HexView::paintOffsets(QPainter *painter, int &left,int first, int last)
{
    QPen pen;

    for (int i=first; i<=last ; ++i) {
        QRect offsets(left,rowHeight() * i,offsetsWidth(),rowHeight());

        if (showGuidelines_) {
            pen.setColor(Qt::green);
            painter->setPen(pen);
            painter->drawRect(offsets);
        }

        pen.setColor(Qt::black);
        painter->setPen(pen);
        QString offset = getHexNumber(i * bytesPerRow(),offsetLen(),true);
        painter->drawText( offsets ,Qt::AlignCenter ,offset  );
    }

    left += offsetsWidth();

    if (showGuidelines_) {
        QRect space(left,0,spacer() ,contentHeight());
        pen.setColor(Qt::blue);
        painter->setPen(pen);
        painter->drawRect(space);
    }

    left += spacer();
}
int
main ()
{
  spacer ();

  breakpt ();

  spacer ();

  return 0;
}
Exemple #5
0
void HexView::recalcWidth()
{
    int sizeOfOffsets = (2 + offsetLen()) * asciiSpacer();
    int spacers = 0;
    if (showOffsets()) {
        spacers += spacer() + sizeOfOffsets;
    }
    if (showHex()) {
        spacers += spacer() + (bytesPerRow() * hexSpacer());
    }
    if (showAscii()) {
        spacers += bytesPerRow() * asciiSpacer();
    }
    setContentWidth( spacers );

}
Exemple #6
0
void GPlotWindow::gridLines(int maxHorizAxisLabels, int maxVertAxisLabels, unsigned int col)
{
	if(maxHorizAxisLabels > 0)
	{
		GPlotLabelSpacer spacer(m_window.x, m_window.x + m_window.w, maxHorizAxisLabels);
		for(int i = 0; i < spacer.count(); i++)
		{
			double pos = spacer.label(i);
			line(pos, m_window.y, pos, m_window.y + m_window.h, col);
		}
	}
	else if(maxHorizAxisLabels == -1)
	{
		GPlotLabelSpacerLogarithmic spacer(m_window.x, m_window.x + m_window.w);
		while(true)
		{
			double pos;
			bool primary;
			if(!spacer.next(&pos, &primary))
				break;
			double x = log(pos);
			line(x, m_window.y, x, m_window.y + m_window.h, col);
		}
	}
	if(maxVertAxisLabels > 0)
	{
		GPlotLabelSpacer spacer(m_window.y, m_window.y + m_window.h, maxVertAxisLabels);
		for(int i = 0; i < spacer.count(); i++)
		{
			double pos = spacer.label(i);
			line(m_window.x, pos, m_window.x + m_window.w, pos, col);
		}
	}
	else if(maxVertAxisLabels == -1)
	{
		GPlotLabelSpacerLogarithmic spacer(m_window.y, m_window.y + m_window.h);
		while(true)
		{
			double pos;
			bool primary;
			if(!spacer.next(&pos, &primary))
				break;
			double y = log(pos);
			line(m_window.x, y, m_window.x + m_window.w, y, col);
		}
	}
}
Exemple #7
0
	/*
	 *printTitle
	 *Description: Prints out the game title and my information. Waits for enter key before exiting
	 */
   void printTitle()
   {
       char temp;
       clearScreen();
       printf("\n\n\n\n");
       spacer();
       printf(" Welcome to Connect four!\n");
       spacer();
       printf("Created by Philip Kealley\n");
       spacer();
       printf("   ICT106 Assignment 1\n");
       printf("\n\n");
       spacer();
       printf("  Press Enter to play\n");
       spacer();
       getchar(); //waits for enter key
	}
Exemple #8
0
	/*
	 *continueGame
	 *Description: Asks if the user wishes to play again, validates the input and returns boolean yes or no  depending upon the answer.
	 */
	int continueGame()
	{
		//variable declaration
    	int test;
	    char input;
	    char inputerror[25] = "Please Enter a Y or N: ";

        printf("\n");
		spacer();
        printf("Play again? Y/N : ");
		
		do
		{
            test = 1; // intitalised here for repeated loops
		
			scanf("%c", &input);
			if(input == '\n')
			{
                spacer();
				printf("%s", inputerror); //error msg
				test = 0;
            }
			else
			{
				flush(); // clear input buffer
				input = tolower(input); // convert uppercase into lowercase
				
				if(input != 'n' && input != 'y') //checks that input was valid
				{
					spacer();
					printf("%s", inputerror); //error msg
					test = 0; // flag loop repeat
				}
			}

		}while(test == 0);
		
		if(input == 'y')
		{
			return(1); // returns true 
		}
		else
		{
			return(0); // returns false
		}
	}
Exemple #9
0
String MIValue::Dump(int level) const
{
	String spacer(' ', level);
	switch(type)
	{
		case MIString:
			return spacer + MARK_STRING + Dump(string);

		case MITuple:
		{
			String s = spacer + MARK_TUPLE + "{\n";
			level += 4;
			spacer = String(' ', level);
			for(int i = 0; i < tuple.GetCount(); i++)
			{
				String s1 = spacer + tuple.GetKey(i) + "=";
				s += s1;
				MIValue const &val = tuple[i];
				if(val.type == MIString)
					s += val.Dump();
				else
				{
					s += '\n' + val.Dump(level + 4);
					s = s.Left(s.GetCount()-1);
				}
				if(i < tuple.GetCount() - 1)
					s += ',';
				s += '\n';
			}
			level -= 4;
			spacer = String(' ', level);
			s += spacer + "}\n";
			return s;
		}

		case MIArray:
		{
			String s = spacer + MARK_ARRAY + "[ \n";
			level += 4;
			for(int i = 0; i < array.GetCount(); i++)
			{
				MIValue const &val = array[i];
				s += val.Dump(level);
				if(val.type != MIString)
					s = s.Left(s.GetCount()-1);
				if(i < array.GetCount() - 1)
					s += ',';
				s += '\n';
			}
			s += spacer + "]\n";
			return s;
		}
		
		default:
			return spacer + "*UNKNOWN MIVALUE TYPE*";
	}
}
Exemple #10
0
	/*
	 *printGrid
	 *Description: Prints out the game grid on the screen
	 */
	void printGrid(int grid[column_size][row_size])
	{
		//variable declaration
		//intialised as top row
		int r, c, i;
	
		printf("\n");
		
		for(r = (row_size - 1); r >= 0; r--)
		//outer loop works through each row from the top down
		{
			spacer();
			for(c = 0; c < column_size; c++)
			//inner loop works through each column from left to right
			{
				if(grid[c][r] == 1)
					printf("|O");
				else
					if(grid[c][r] == 2)
						printf("|X"); 
					else
						printf("| ");
			}
			printf("|\n"); //needed to tidy the grid output
		 }
		 spacer();
		 
		for(i = 0; i < column_size; i++)
		 //prints a ---- line depending on grid size
		{
			printf("--");
		}
			printf("-\n"); //needed to tidy the grid output
			spacer();
			   
		for(i = 0; i < column_size; i++)
		//prints the column references depending on grid size
		{
			printf("|%d", i);
		}
		
		printf("|"); //tidying of grid output
	}
Exemple #11
0
void HexView::paintHex(QPainter *painter, int &left,int first, int last)
{
    QPen pen;

    for (int i=first ;i<=last;++i) {
        for (int j=0;j<bytesPerRow_;++j) {

            int validx = (i * bytesPerRow()) + j;


            if (validx < contentLength_)    {
                int valueint = value(validx);
                QRectF hex(left + (j * hexSpacer()),i * rowHeight() , hexSpacer(),rowHeight());

                if (showGuidelines_) {
                    pen.setColor(Qt::green);
                    painter->setPen(pen);
                    painter->drawRect(hex);
                }


                QString valuestr = getHexNumber(valueint,2);

                pen.setColor(Qt::black);
                painter->setPen(pen);
                painter->drawText( hex ,Qt::AlignCenter,valuestr  );
            }
        }

    }


    left += (bytesPerRow() * hexSpacer());

    if (showGuidelines_) {
        QRect space(left,0,spacer() ,contentHeight());
        pen.setColor(Qt::blue);
        painter->setPen(pen);
        painter->drawRect(space);
    }

   left += spacer();
}
Exemple #12
0
	ticpp::Element* ImportFromXrc( ticpp::Element* xrcObj )
	{
		XrcToXfbFilter filter(xrcObj, _("sizeritem"));
		filter.AddProperty(_("option"), _("proportion"), XRC_TYPE_INTEGER);
		filter.AddProperty(_("flag"),   _("flag"),   XRC_TYPE_BITLIST);
		filter.AddProperty(_("border"), _("border"), XRC_TYPE_INTEGER);
		ticpp::Element* sizeritem = filter.GetXfbObject();

		// XrcLoader::GetObject imports spacers as sizeritems, so check for a spacer
		if ( xrcObj->FirstChildElement("size", false ) && !xrcObj->FirstChildElement("object", false ) )
		{
			// it is a spacer
			XrcToXfbFilter spacer( xrcObj, _("spacer") );
			spacer.AddPropertyPair( "size", _("width"), _("height") );
			sizeritem->LinkEndChild( spacer.GetXfbObject() );
		}
		return sizeritem;
	}
bool progThread::PrepareIntelLine(QByteArray* x,int address,int length)
{
	unsigned char chksum;
	bool retval=false;
	QString Buff;
	unsigned char c;	
	QChar spacer('0');
	Buff = QString(":%1%2").arg(length,2,16,spacer).arg(address,4,16,spacer);
	Buff += "00";
	chksum = (unsigned char)(length + (address%0x100) + (address/0x100));
	for(int j=0;j<length;j++)
	{
		c = FlashBuff[address+j];
		Buff+=QString("%1").arg( c,2,16,spacer);
		chksum += c;
		if(c!=0xff) retval=true;
	}
	Buff+=QString("%1\r\n").arg((unsigned char)(0x100-chksum),2,16,spacer);
	*x = Buff.toAscii();
	return retval;
}
int main()
{
    list_char* stack = stack_char_create();

    stack_char_print( stack );
    printf( "\n" );
    printf( "The amount of items on this stack is %d.\n\n", stack_char_len( stack ) );

    stack_char_push( stack, 'A' );
    stack_char_push( stack, 'B' );
    stack_char_print( stack );
    printf( "\n" );
    printf( "The amount of items on this stack is %d.\n\n", stack_char_len( stack ) );

    printf( "The top element on the stack " );
    stack_char_print( stack );
    printf( " is %c.\n\n", stack_char_peek( stack ) );

    stack_char_pop( stack );
    printf( "After removing the top element, the stack is " );
    stack_char_print( stack );
    printf( "\n" );
    printf( "The amount of items on this stack is %d.\n\n", stack_char_len( stack ) );

    stack_char_initialize( stack );
    printf( "After initializing, the stack is " );
    stack_char_print( stack );
    printf( "\n" );
    printf( "The amount of items on this stack is %d.\n\n", stack_char_len( stack ) );

    stack_char_destroy( stack );



    spacer();

    list_char* queue = queue_char_create();

    queue_char_print( queue );
    printf( "\n" );
    printf( "The amount of items in this queue is %d.\n\n", queue_char_len( queue ) );

    queue_char_enqueue( queue, 'A' );
    queue_char_enqueue( queue, 'B' );
    queue_char_print( queue );
    printf( "\n" );
    printf( "The amount of items in this queue is %d.\n\n", queue_char_len( queue ) );

    printf( "The front element in the queue " );
    queue_char_print( queue );
    printf( " is %c.\n\n", queue_char_peek( queue ) );

    queue_char_dequeue( queue );
    printf( "After removing the front element, the queue is " );
    queue_char_print( queue );
    printf( "\n" );
    printf( "The amount of items in this queue is %d.\n\n", queue_char_len( queue ) );

    queue_char_initialize( queue );
    printf( "After initializing, the queue is " );
    queue_char_print( queue );
    printf( "\n" );
    printf( "The amount of items in this queue is %d.\n\n", queue_char_len( queue ) );

    queue_char_destroy( queue );

    return 0;
}
Exemple #15
0
  bool show() {
    label(Far::get_msg(MSG_SFX_OPTIONS_DLG_PROFILE));
    vector<wstring> profile_names;
    profile_names.reserve(profiles.size());
    for (unsigned i = 0; i < profiles.size(); i++) {
      profile_names.push_back(profiles[i].name);
    }
    profile_names.push_back(wstring());
    profile_ctrl_id = combo_box(profile_names, profiles.size(), 30, DIF_DROPDOWNLIST);
    new_line();
    separator();
    new_line();

    label(Far::get_msg(MSG_SFX_OPTIONS_DLG_MODULE));
    vector<wstring> module_names;
    const SfxModules& sfx_modules = ArcAPI::sfx();
    module_names.reserve(sfx_modules.size() + 1);
    unsigned name_width = 0;
    for_each(sfx_modules.begin(), sfx_modules.end(), [&] (const SfxModule& sfx_module) {
      wstring name = sfx_module.description();
      module_names.push_back(name);
      if (name_width < name.size())
        name_width = name.size();
    });
    module_names.push_back(wstring());
    module_ctrl_id = combo_box(module_names, sfx_modules.find_by_name(options.name), name_width + 6, DIF_DROPDOWNLIST);
    new_line();

    replace_icon_ctrl_id = check_box(Far::get_msg(MSG_SFX_OPTIONS_DLG_REPLACE_ICON), options.replace_icon);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_SFX_OPTIONS_DLG_ICON_PATH));
    icon_path_ctrl_id = history_edit_box(options.icon_path, L"arclite.icon_path", AUTO_SIZE, DIF_EDITPATH | DIF_SELECTONENTRY);
    new_line();

    unsigned label_len = 0;
    vector<wstring> labels;
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_PRODUCT_NAME));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_VERSION));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_COMPANY_NAME));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_FILE_DESCRIPTION));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_COMMENTS));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_VER_INFO_LEGAL_COPYRIGHT));
    for (unsigned i = 0; i < labels.size(); i++)
      if (label_len < labels[i].size())
        label_len = labels[i].size();
    label_len += 2;
    vector<wstring>::const_iterator label_text = labels.cbegin();
    replace_version_ctrl_id = check_box(Far::get_msg(MSG_SFX_OPTIONS_DLG_REPLACE_VERSION), options.replace_version);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_product_name_ctrl_id = edit_box(options.ver_info.product_name, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_version_ctrl_id = edit_box(options.ver_info.version, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_company_name_ctrl_id = edit_box(options.ver_info.company_name, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_file_description_ctrl_id = edit_box(options.ver_info.file_description, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_comments_ctrl_id = edit_box(options.ver_info.comments, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    ver_info_legal_copyright_ctrl_id = edit_box(options.ver_info.legal_copyright, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();

    label_len = 0;
    labels.clear();
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_TITLE));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_BEGIN_PROMPT));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_PROGRESS));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_RUN_PROGRAM));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_DIRECTORY));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_EXECUTE_FILE));
    labels.push_back(Far::get_msg(MSG_SFX_OPTIONS_DLG_INSTALL_CONFIG_EXECUTE_PARAMETERS));
    for (unsigned i = 0; i < labels.size(); i++)
      if (label_len < labels[i].size())
        label_len = labels[i].size();
    label_len += 2;
    label_text = labels.cbegin();
    append_install_config_ctrl_id = check_box(Far::get_msg(MSG_SFX_OPTIONS_DLG_APPEND_INSTALL_CONFIG), options.append_install_config);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_title_ctrl_id = edit_box(options.install_config.title, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_begin_prompt_ctrl_id = edit_box(options.install_config.begin_prompt, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    TriState value;
    if (options.install_config.progress == L"yes")
      value = triTrue;
    else if (options.install_config.progress == L"no")
      value = triFalse;
    else
      value = triUndef;
    install_config_progress_ctrl_id = check_box3(wstring(), value);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_run_program_ctrl_id = edit_box(options.install_config.run_program, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_directory_ctrl_id = edit_box(options.install_config.directory, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_execute_file_ctrl_id = edit_box(options.install_config.execute_file, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();
    spacer(2);
    label(*label_text++);
    pad(label_len);
    install_config_execute_parameters_ctrl_id = edit_box(options.install_config.execute_parameters, AUTO_SIZE, DIF_SELECTONENTRY);
    new_line();

    separator();
    new_line();
    ok_ctrl_id = def_button(Far::get_msg(MSG_BUTTON_OK), DIF_CENTERGROUP);
    cancel_ctrl_id = button(Far::get_msg(MSG_BUTTON_CANCEL), DIF_CENTERGROUP);
    new_line();

    int item = Far::Dialog::show();

    return (item != -1) && (item != cancel_ctrl_id);
  }
Exemple #16
0
QWidget* createToolBarItem(const ToolBarsManager::ToolBarDefinition::Entry &definition, QWidget *parent, Window *window)
{
	if (definition.action == QLatin1String("spacer"))
	{
		QWidget *spacer(new QWidget(parent));
		spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

		return spacer;
	}

	if (!definition.entries.isEmpty())
	{
		return new ToolButtonWidget(definition, parent);
	}

	if (definition.action == QLatin1String("AddressWidget"))
	{
		return new AddressWidget(window, parent);
	}

	if (definition.action == QLatin1String("ConfigurationOptionWidget"))
	{
		return new ConfigurationOptionWidget(window, definition, parent);
	}

	if (definition.action == QLatin1String("ErrorConsoleWidget"))
	{
		return new ErrorConsoleWidget(parent);
	}

	if (definition.action == QLatin1String("ContentBlockingInformationWidget"))
	{
		return new ContentBlockingInformationWidget(window, definition, parent);
	}

	if (definition.action == QLatin1String("MenuButtonWidget"))
	{
		return new MenuButtonWidget(definition, parent);
	}

	if (definition.action == QLatin1String("PanelChooserWidget"))
	{
		return new PanelChooserWidget(definition, parent);
	}

	if (definition.action == QLatin1String("PrivateWindowIndicatorWidget"))
	{
		return new PrivateWindowIndicatorWidget(definition, parent);
	}

	if (definition.action == QLatin1String("ProgressInformationDocumentProgressWidget") || definition.action == QLatin1String("ProgressInformationTotalProgressWidget") || definition.action == QLatin1String("ProgressInformationTotalSizeWidget") || definition.action == QLatin1String("ProgressInformationElementsWidget") || definition.action == QLatin1String("ProgressInformationSpeedWidget") || definition.action == QLatin1String("ProgressInformationElapsedTimeWidget") || definition.action == QLatin1String("ProgressInformationMessageWidget"))
	{
		return new ProgressInformationWidget(window, definition, parent);
	}

	if (definition.action == QLatin1String("SearchWidget"))
	{
		SearchWidget *searchWidget(new SearchWidget(window, parent));
		searchWidget->setOptions(definition.options);

		return searchWidget;
	}

	if (definition.action == QLatin1String("SizeGripWidget"))
	{
		return new QSizeGrip(parent);
	}

	if (definition.action == QLatin1String("StatusMessageWidget"))
	{
		return new StatusMessageWidget(parent);
	}

	if (definition.action == QLatin1String("TabBarWidget"))
	{
		return new TabBarWidget(parent);
	}

	if (definition.action == QLatin1String("ZoomWidget"))
	{
		return new ZoomWidget(window, parent);
	}

	if (definition.action.startsWith(QLatin1String("bookmarks:")))
	{
		BookmarksItem *bookmark(definition.action.startsWith(QLatin1String("bookmarks:/")) ? BookmarksManager::getModel()->getItem(definition.action.mid(11)) : BookmarksManager::getBookmark(definition.action.mid(10).toULongLong()));

		if (bookmark)
		{
			return new BookmarkWidget(bookmark, definition, parent);
		}
	}

	if (definition.action.endsWith(QLatin1String("Action")))
	{
		const int identifier(ActionsManager::getActionIdentifier(definition.action.left(definition.action.length() - 6)));

		if (identifier >= 0)
		{
			ActionWidget *actionWidget(nullptr);

			if (identifier == ActionsManager::GoBackAction || identifier == ActionsManager::GoForwardAction)
			{
				actionWidget = new NavigationActionWidget(window, definition, parent);
			}
			else
			{
				actionWidget = new ActionWidget(identifier, window, definition, parent);;
			}

			actionWidget->setOptions(definition.options);

			return actionWidget;
		}
	}

	if (definition.action.endsWith(QLatin1String("Menu")))
	{
		return new ToolButtonWidget(definition, parent);
	}

	return nullptr;

}
Exemple #17
0
	/* 
	 *setGridSize
	 *Desctiption: Displays current grid size, asks if they want to change. Gives options for changing the grid and takes user input on which option. Changes the global variables for column_size and row_size.
	 */
	void setGridSize()
	{
		//variable declaration
		char input, selection;
		int test;
		char inputerror[25] = "Please Enter a Y or N: "; //initialize of errors
		char selectionerror[35] = "Please Enter a Valid Selection!";
		
		clearScreen();
		printf("\n");
		spacer();
		printf("Grid size is currently %d x %d\n", column_size, row_size); //prints the current values for grid size.
		spacer();
		printf("Change Grid Size? y/n  ");
		
		do
		{
			test = 1; //test is initialised here for the loop. 0 is true and 1 is false
			scanf("%c", &input);
			if(input == '\n') //checks if user just hit enter with no input
            {
                printf("\n");
                spacer();
                printf("%s", inputerror); //print error
                test = 0; //set to false
            }
            else
            {
                flush(); //clear input buffer
                input = tolower(input); // change uppercase input to lowercase
				if(input != 'n' && input != 'y') 
				{
					test = 0; //set to false
					printf("\n");
					spacer();
					printf("%s", inputerror); //print error
				}
            }

		}while(test == 0); //repeats while true  (test == 0)
			
           if(input == 'y') //checks input
           {
				//prints grid size menu.
    			printf("\n");
    			spacer();
                printf("a) 7 x 6\n");
                spacer();
    			printf("b) 8 x 7\n");
    			spacer();
    			printf("c) 9 x 7\n");
    			spacer();
    			printf("d) 10 x 7\n");
				
				do
				{
				 
					test = 1; //set to false
					spacer();
					scanf("%c", &selection);
					if(selection == '\n') //checks if user just hit enter with no input
					{
						 
						spacer();
						printf("%s\n", selectionerror); //print error
						test = 0;
					}
					else
					{
						flush();
						selection = tolower(selection); //change uppercase to lower 
						if(selection != 'a' && selection != 'b' && selection != 'c' && selection != 'd') //check input is valid
						{
								 
							spacer();
							printf("%s\n", selectionerror); //print error
							test = 0;
						}
					}
				}while(test == 0);
				//changes the grid size based on menu selection.
				switch(selection)
				{
					case 'a':
						column_size = 7;
						row_size = 6;
						break;
					case 'b':
						column_size = 8;
						row_size = 7;
						break;
					case 'c':
						column_size = 9;
						row_size = 7;
						break;
					case 'd':
						column_size = 10;
						row_size = 7;
						break;
						//no need for default because input is validated to only correct entry. 
				}
          }

	}
Exemple #18
0
int main()
{
	//prototypes for main
    void printTitle(), setGridSize(), clearGrid(int grid[column_size][row_size]), playerTurn(int player, int grid[column_size][row_size]);
    int checkWinner(int grid[column_size][row_size]), continueGame();
	
	//variable initilisation.
	int player, winner;

    printTitle();
		
		do
    	{
			//construction of new game
            player = 1; //resets player
			winner = 0; // resets winner
    		setGridSize();
    		int grid[column_size][row_size]; // constructs grid
            clearGrid(grid); // sets all grid values to 0
    		clearScreen();

			//game plays out inside until winner or draw.
    		while(winner == 0)
    		{

    			playerTurn(player, grid);
    			winner = checkWinner(grid);
    			if(winner == 0) 
				{
					//switches player
    				if(player == 1)
					{
    					player = 2;
					}
    				else
					{
    					player = 1;
					}
				}
    			else
    			{
						//clears screen and prints grid between turns.
    		        	clearScreen();
                        printGrid(grid);
                        spacer(); //spacer called repeatedly to move print to center of console
    					printf("\n\n");
    					spacer();
						
    				if(winner != 3) //checks if winner was a player or a draw. A winner of '3' is a draw
					{
                        printf("Winner is Player %d!!!", winner);
					}
                    else
					{
                        printf("Draw!!!");
					}
                }
    		}
		//starts a new game if true
    	}while(continueGame());

		return(0);
}
void packExpectedJuneMass(const int iMass) {
  // This Root macro is for the purpose of providing input for expected limit computation
  // It packs predicted background and a set of signal samples into a root file per Higgs mass
  // 
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  canvas = new TCanvas ("cg1","PadX",10,10,800,600);
  gStyle->SetPadColor(0);
  canvas->SetFillColor(0);
  
  //   const int nbtag = 4;
  const int nbtag = 1;
  //const std::string sbtag[nbtag] = { "TCHPT", "TCHP6", "CSVT", "SSVHPT" };
  const std::string sbtag[nbtag] = { "CSVT" };

  std::string L1L2Mode("Weight");
  std::string signalMode("PU_WEIGHTED-NEW");
  //   std::string L1L2Mode("Cut");
  //   std::string signalMode("CUT_BASED");
  std::string scenario("LowMass2011");
  
  string IgorVersion("V6");
#include "Analysis/Utilities/interface/HbbMass.h"

  if (iMass >= nSignal) {
    std::cout << "Bad iMass=" << iMass << std::endl;
    return;
  }

  //   const int nSignal=7;
  //   int signalMass[nSignal] = { 90, 100, 120, 140, 180, 250, 350 };
  //   double efficiency[nSignal] = { 0.0022081, 0.00324694, 0.00600146, 0.00918135,
  // 				0.0138382, 0.0189684, 0.0206572 };
  double efficiency[nSignal][nbtag];
  double intLumi = 0;
  string IgorScen("");
  string spacer("");
  string SashaPath("");
  string IgorPath("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production");

  if (IgorVersion == "V4") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-4");
  } else if (IgorVersion == "V6") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production2");
  }


  if (scenario == "LowMass2011") {
    //intLumi = 2.66794; // in fb-1
    intLumi = 2.692643;  // with new method
    IgorScen.assign("low");
    spacer.assign("");
    SashaPath.assign("Data-Run2011AB");
  } else if (scenario == "MediumMass2011") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 4.040802;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    SashaPath.assign("Data-Run2011AB-Medium");
  } else {
    std::cout << "Bad scenario" << std::endl;
    return;
  }
  string signalHistPattern("massEvBtag/mjjEvBTag_%s");
  if (L1L2Mode == "Weight") {
    signalHistPattern.assign("massEvBtagTW/mjjEvBTagTW_%s");
  }
  
  double fScal[nSignal][nbtag];
  
  // signal templates
  const int nSyst = 4;
  const int nUpDown = 2;
  std::string signalFile( "" );
  std::string signalSystFiles[nSyst][nUpDown];
  std::string systName[nSyst] = { "JES", "SFbc", "SFudsg", "JER" };
  bool realDataNuisance[nSyst] = { false, true, true, false }; // indicate if relevant for real data

  std::string upDownName[nUpDown] = { "Up", "Down" };
  TH2F* hSignalSyst[nSyst][nUpDown][nbtag];

    // signal templates
  if (IgorVersion != "V3") {
    std::cout << "Using signal files " << IgorVersion << std::endl;
    signalFile.assign( Form("%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",IgorPath.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  } else {
    std::cout << "Using V3 signal files" << std::endl;
    signalFile.assign( Form("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",signalMode.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  }

  // output file
  TFile* hout = new TFile(Form("ExpectedLimitJune-M-%d.root",signalMass[iMass]),"recreate");
  hout->cd();
  TH2::AddDirectory(true);

  TFile* fSig = new TFile( signalFile.c_str() );
  if ( fSig == NULL ) {
    std::cout << "Could not open signal central file " << signalFile.c_str() << std::endl;
    return;
  } else {
    std::cout << "Open signal file " << signalFile.c_str() << std::endl;
  }

  TH2F* hSignalCentral[nbtag];

  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hSignalCentral[ibtag] = mergeSignal(fSig,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
					"bbH");
    // read the efficiency
    TH1F* histEffMerged = (TH1F*) fSig->Get(Form("TrigEff/EffMerged%s",sbtag[ibtag].c_str()));
    if ( histEffMerged == NULL) {
      std::cout << "Efficiency histo not found" << std::endl;
      return;
    }
    double newEff = histEffMerged->GetBinContent(1);
    std::cout << "Mass= " << signalMass[iMass] 
	      << " btag= " << sbtag[ibtag]
	      << " Efficiency = " << newEff << std::endl;
    efficiency[iMass][ibtag] = newEff;
    
    double normShould = 1000 * intLumi * efficiency[iMass][ibtag];
    double normIs = hSignalCentral[ibtag]->GetSum();
    std::cout << hSignalCentral[ibtag]->GetName() << " TotalContents=" << hSignalCentral[ibtag]->GetSum()
	      << std::endl;
    fScal[iMass][ibtag] = normShould / normIs;
    std::cout << "normShould = " << normShould << " normIs " << normIs
	      << " rescale by " << fScal[iMass][ibtag] << std::endl;
    hSignalCentral[ibtag]->Scale( fScal[iMass][ibtag] );
    hout->cd();
    hSignalCentral[ibtag]->Write();

    // create empty file just as marker
    ofstream markerFile;
    markerFile.open(Form("pack-%s-%s.txt",sbtag[ibtag].c_str(),scenario.c_str()),ios::app);
    markerFile << "Template for mass " << signalMass[iMass] << std::endl;
    markerFile.close();
  }


  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      if (IgorVersion != "V3") {
	signalSystFiles[iSyst][iUpDown] = Form( "%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						IgorPath.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      } else {	
	signalSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						signalMode.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      }
      std::cout << "Signal systematics file " << signalSystFiles[iSyst][iUpDown] << std::endl;
      TFile* fSigSys = new TFile( signalSystFiles[iSyst][iUpDown].c_str() );
      if ( fSigSys == NULL ) {
	std::cout << "Could not open signal syst file " << signalSystFiles[iSyst][iUpDown].c_str() << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	hSignalSyst[iSyst][iUpDown][ibtag] = mergeSignal(fSigSys,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
							 Form("bbH_%s_%s",systName[iSyst].c_str(),upDownName[iUpDown].c_str()));
	std::cout << "The merged hist has name " << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << std::endl;
	std::cout << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << " TotalContents=" << hSignalSyst[iSyst][iUpDown][ibtag]->GetSum()
		  << std::endl;

	hSignalSyst[iSyst][iUpDown][ibtag]->Scale( fScal[iMass][ibtag] );
	hout->cd();
	hSignalSyst[iSyst][iUpDown][ibtag]->Write();
      }
      fSigSys->Close();
    }
  }

  // backgrounds
  std::string backgroundFile( Form("/afs/naf.desy.de/user/s/spiridon/scratch/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_SFzero/TripleBtagAnalysis.root",SashaPath.c_str()) );
  std::cout << "Background central file : " << backgroundFile << std::endl;
  TFile* fBac = new TFile( backgroundFile.c_str() );
  if ( fBac == NULL ) {
    std::cout << "Could not open background central file " << signalFile.c_str() << std::endl;
    return;
  }
  TH2F* hBackgroundCentral[nbtag];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hBackgroundCentral[ibtag] = mergeBackground(fBac,"bgPredict/MassBTagPred_%s_%s_Cat%dTpat%d",sbtag[ibtag].c_str(),"BBB",scenario);
    hout->cd();
    hBackgroundCentral[ibtag]->Write();
  }

  std::string backgroundSystFiles[nSyst][nUpDown];
  std::string systNameSasha[nSyst] = { "JES", "SFbc", "SFq" };
  std::string upDownNameSasha[nUpDown] = { "plus2", "minus2" };
  TH2F* hBackgroundSyst[nSyst][nUpDown][nbtag];

  // for nuisances like JEC, the up/down templates are just copies of the central templates
  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    
    if (realDataNuisance[iSyst]) {
      std::cout << "Real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	backgroundSystFiles[iSyst][iUpDown] = Form( "/afs/naf.desy.de/user/s/spiridon/scratch/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",SashaPath.c_str(),systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	TFile* fBacSys = new TFile( backgroundSystFiles[iSyst][iUpDown].c_str() );
	std::cout << "Background systematics file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	if ( fBacSys == NULL ) {
	  std::cout << "Could not open background syst file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	  return;
	}
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  hBackgroundSyst[iSyst][iUpDown][ibtag] = mergeBackground(fBacSys,
								   "bgPredict/MassBTagPred_%s_%s_Cat%dTpat%d",
								   sbtag[ibtag].c_str(),Form("BBB_%s_%s",systName[iSyst].c_str(),
											     upDownName[iUpDown].c_str()),scenario);
	  hout->cd();
	  hBackgroundSyst[iSyst][iUpDown][ibtag]->Write();
	}
	fBacSys->Close();
      }
    }
  }
 
  hout->Write();
  hout->Close();
  fSig->Close();
  
  return;
}
Exemple #20
0
	/*
	 *playerTurn
	 *Description: Takes in user inputs for column and changes the resulting empty place in that column to the player number
	 */
	void playerTurn(int player, int grid[column_size][row_size])
	{
		//varaible initialisation
        int inputColumn();
		int col,test, row, placement;
		char placementerror[45] = "Can not place in that column! Try Again"; //error msg
        
	    //print out the grid and ask for input
        clearScreen();
        printGrid(grid);
        printf("\n\n");
        spacer();
        printf("Player %d ", player);
			if(player == 1)
			{
				printf("'O'\n");
			}
			else
			{
				printf("'X'\n");
			}
        spacer();
    	printf("Enter column: ");
		 
		do
		{
			placement = 0;
		   //will repeat until player makes a successful move (checks if column selected is full)
            do
			//will repeat until player selects a valid input (checks if column is inside grid)
            {
				test = 1;  //initialised here for repeating loop
				col = inputColumn();
				//validates input is within grid.
				if(col < 0 || col > (column_size - 1))
				{
			        test = 0;
			        
			        spacer();
			        printf("%s\n", placementerror );
			        spacer();
				}
            }while(test == 0);
			
			row = 0; //row is intialised here for repeating loops.
			 
			while(placement == 0 && row < row_size)
			//checks column selected from the bottom row and working upwards until it finds an empty position '0' and changes the value to the player.
			{
				if(grid[col][row] == 0)
				{
					grid[col][row] = player;
					placement = 1; //sets to 0 when a successfull move is made
                }
				else
					row++;
			}
			if(placement == 0) //if the above loop does not make a successful move within the column selected then placement will be 0 here.
			{
                spacer();
				printf("%s\n", placementerror); //print error 
				spacer();
			}
		}while(placement == 0);
	}
Exemple #21
0
void Dialog::pad(unsigned pos) {
  if (pos > x - c_x_frame) spacer(pos - (x - c_x_frame));
}
Exemple #22
0
GImage* GPlotWindow::labelAxes(int maxHorizAxisLabels, int maxVertAxisLabels, int precision, float size, unsigned int color, double angle)
{
	int spacing = 10;
	int horizMargin = 200;
	int vertMargin = 200;
	GImage* pOutImage = new GImage();
	pOutImage->setSize(m_pImage->width() + horizMargin, m_pImage->height() + vertMargin);
	pOutImage->clear(0xffffffff);
	GRect r(0, 0, m_pImage->width(), m_pImage->height());
	pOutImage->blit(horizMargin, 0, m_pImage, &r);
	if(maxHorizAxisLabels > 0)
	{
		GPlotLabelSpacer spacer(m_window.x, m_window.x + m_window.w, maxHorizAxisLabels);
		for(int i = 0; i < spacer.count(); i++)
		{
			double pos = spacer.label(i);
			int x1, y1;
			windowToView(pos, 0, &x1, &y1);
			numericLabel(pOutImage, pos, horizMargin + x1, m_pImage->height() + spacing, precision, size, color, angle);
		}
	}
	else if(maxHorizAxisLabels == -1)
	{
		GPlotLabelSpacerLogarithmic spacer(m_window.x, m_window.x + m_window.w);
		while(true)
		{
			double pos;
			bool primary;
			if(!spacer.next(&pos, &primary))
				break;
			if(primary)
			{
				double x = log(pos);
				int x1, y1;
				windowToView(x, 0, &x1, &y1);
				numericLabel(pOutImage, pos, horizMargin + x1, m_pImage->height() + spacing, precision, size, color, angle);
			}
		}
	}
	if(maxVertAxisLabels > 0)
	{
		GPlotLabelSpacer spacer(m_window.y, m_window.y + m_window.h, maxVertAxisLabels);
		for(int i = 0; i < spacer.count(); i++)
		{
			double pos = spacer.label(i);
			int x1, y1;
			windowToView(0, pos, &x1, &y1);
			numericLabel(pOutImage, pos, horizMargin - spacing, y1, precision, size, color, 0.0);
		}
	}
	else if(maxVertAxisLabels == -1)
	{
		GPlotLabelSpacerLogarithmic spacer(m_window.y, m_window.y + m_window.h);
		while(true)
		{
			double pos;
			bool primary;
			if(!spacer.next(&pos, &primary))
				break;
			if(primary)
			{
				double y = log(pos);
				int x1, y1;
				windowToView(0, y, &x1, &y1);
				numericLabel(pOutImage, pos, horizMargin - spacing, y1, precision, size, color, 0.0);
			}
		}
	}
	return pOutImage;
}
Exemple #23
0
    /**
        @brief Adds a formatter. Also, the second argument is the @ref
        hpx::util::logging::formatter::spacer_t "spacer" string

        @param fmt The formatter
        @param format_str The @ref hpx::util::logging::formatter::spacer_t
        "spacer" string
    */
    template<class formatter> void add_formatter(formatter fmt,
        const char_type * format_str) {
        add_formatter( spacer(fmt, format_str) );
    }
void CHostageImprov::UpdatePosition(float deltaT)
{
	CNavArea *area = TheNavAreaGrid.GetNavArea(&m_hostage->pev->origin);

	if (area != NULL)
	{
		m_lastKnownArea = area;
	}

	DrawAxes(m_moveGoal, 255, 255, 0);

	if (IsJumping())
	{
		Vector dir;
		const float pushSpeed = 100.0f;

		if (!m_hasJumped)
		{
			m_hasJumped = true;
			m_hasJumpedIntoAir = false;
			m_hostage->pev->velocity.z += 300.0f;
		}
		else
			ResetJump();

		dir = m_jumpTarget - GetFeet();
		dir.z = 0;

#ifndef PLAY_GAMEDLL
		// TODO: fix test demo
		dir.NormalizeInPlace();

		m_hostage->pev->velocity.x = dir.x * pushSpeed;
		m_hostage->pev->velocity.y = dir.y * pushSpeed;
#else
		Vector vecRet = NormalizeMulScalar<float_precision, float_precision, float_precision, float>(dir, pushSpeed);
		m_hostage->pev->velocity.x = vecRet.x;
		m_hostage->pev->velocity.y = vecRet.y;
#endif

		m_hostage->SetBoneController(0);
		m_hostage->SetBoneController(1);

		FaceTowards(m_jumpTarget, deltaT);
		return;
	}

	if (m_isLookingAt)
	{
		Vector angles = UTIL_VecToAngles(m_viewGoal - GetEyes());
		float_precision pitch = angles.x - m_hostage->pev->angles.x;
		float_precision yaw = angles.y - m_hostage->pev->angles.y;

		while (yaw > 180.0f)
			yaw -= 360.0f;

		while (yaw < -180.0f)
			yaw += 360.0f;

		while (pitch > 180.0f)
			pitch -= 360.0f;

		while (pitch < -180.0f)
			pitch += 360.0f;

		m_hostage->SetBoneController(0, yaw);
		m_hostage->SetBoneController(1, -pitch);

		if (IsAtMoveGoal() && !HasFaceTo())
		{
			if (yaw < -45.0f || yaw > 45.0f)
			{
				FaceTowards(m_viewGoal, deltaT);
			}
		}
	}
	else
	{
		m_hostage->SetBoneController(0);
		m_hostage->SetBoneController(1);
	}

	if (HasFaceTo() && FaceTowards(m_faceGoal, deltaT))
		ClearFaceTo();

	if (!IsAtMoveGoal() || m_path.GetSegmentCount() > 0)
	{
		if (m_path.GetSegmentCount() <= 0)
		{
			HostagePathCost pathCost;
			if (m_path.Compute(&GetFeet(), &m_moveGoal, pathCost))
			{
				m_follower.SetPath(&m_path);
				m_follower.SetImprov(this);

				m_follower.Reset();
				m_follower.Debug(cv_hostage_debug.value > 0.0);
			}
		}

		m_follower.Update(deltaT, m_inhibitObstacleAvoidance.IsElapsed());

		if (m_moveType == Stopped)
		{
			m_follower.ResetStuck();
		}

		if (m_follower.IsStuck())
		{
			Wiggle();
		}
	}

	const float friction = 3.0f;

	m_vel.x += m_vel.x * -friction * deltaT;
	m_vel.y += m_vel.y * -friction * deltaT;

	float_precision speed = m_vel.NormalizeInPlace();

	const float maxSpeed = 285.0f;
	if (speed > maxSpeed)
	{
		speed = maxSpeed;
	}

	m_vel.x = m_vel.x * speed;
	m_vel.y = m_vel.y * speed;

	KeepPersonalSpace spacer(this);
	ForEachPlayer(spacer);

	if (g_pHostages != NULL)
	{
		g_pHostages->ForEachHostage(spacer);
	}

	m_hostage->pev->velocity.x = m_vel.x;
	m_hostage->pev->velocity.y = m_vel.y;

	m_moveFlags = 0;
}
void packTemplatesMass(const int iMass) {
  // This Root macro is for the purpose of providing input for expected limit computation
  // It packs predicted background and a set of signal samples into a root file per Higgs mass
  // 
  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  canvas = new TCanvas ("cg1","PadX",10,10,800,600);
  gStyle->SetPadColor(0);
  canvas->SetFillColor(0);

//   const int nbtag = 4;
  const int nbtag = 1;
  //const std::string sbtag[nbtag] = { "TCHPT", "TCHP6", "CSVT", "SSVHPT" };
  const std::string sbtag[nbtag] = { "CSVT" };

  const int nfc=3;
  const int ncateg=3;
  string sfc[nfc] = { "q", "c", "b" };

  // this is for the combination of triggers in real data
  int nTCombData = 4;
  std::string tCombData[] = {"Trig0", "Trig1", "Trig2", "Trig3"};

  std::string L1L2Mode("Weight");
  std::string signalMode("PU_WEIGHTED-NEW");
//   std::string L1L2Mode("Cut");
//   std::string signalMode("CUT_BASED");

  //std::string scenario("LowMass2011");
  //std::string scenario("MediumMass2011");

  std::string scenario;
  bool useTemplateError;
  bool useNP;
  if (  getHbbCfg(scenario,useTemplateError,useNP) != 0 ) return;

  string IgorVersion("V6");

#include "Analysis/Utilities/interface/HbbMass.h"

  if (iMass >= nSignal) {
    std::cout << "Bad iMass=" << iMass << std::endl;
    return;
  }
//   const int nSignal=7;
//   int signalMass[nSignal] = { 90, 100, 120, 140, 180, 250, 350 };
  // int signalMass[nSignal] = { 90, 100, 120, 130, 140, 160, 180, 200, 250, 350 }
  //  there are also : 450, 500, 600, 700, 800, 900, 1000
//   double efficiency[nSignal] = { 0.0022081, 0.00324694, 0.00600146, 0.00918135,
// 				0.0138382, 0.0189684, 0.0206572 };
  double efficiency[nSignal][nbtag];
  double intLumi = 0;
  string IgorScen("");
  string spacer("");
  string SashaPath("");
  string IgorPath("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production");

  if (IgorVersion == "V4") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-4");
  } else if (IgorVersion == "V6") {
    IgorPath.assign("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/SignalTemplates-Production2");
  }

  if (scenario == "LowMass2011") {
    //intLumi = 2.66794; // in fb-1
    intLumi = 2.692643;  // with new method
    IgorScen.assign("low");
    spacer.assign("");
    //SashaPath.assign("Data-Run2011AB");
    SashaPath.assign("Data-Run2011AB/TripleBtagAnalysis_CR3_SF7");
  } else if (scenario == "MediumMass2011") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 4.040802;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    //SashaPath.assign("Data-Run2011AB-Medium");
    SashaPath.assign("Data-Run2011AB/TripleBtagAnalysis_CR3_SF7_med");
  

  } else if (scenario == "MediumMass2012") {
    //intLumi = 3.99983; // in fb-1
    intLumi = 2.663;
    IgorScen.assign("medium");
    spacer.assign("/MEDIUM");
    //SashaPath.assign("Data-Run2011AB-Medium");
    SashaPath.assign("");
}
else {
    std::cout << "Bad scenario in packing" << std::endl;
    return;
  }
  string signalHistPattern("massEvBtag/mjjEvBTag_%s");
  if (L1L2Mode == "Weight") {
    signalHistPattern.assign("massEvBtagTW/mjjEvBTagTW_%s");
  }

  double fScal[nSignal][nbtag];
  
  // systematics
//   const int nSyst = 3;
//   std::string systName[nSyst] = { "JES", "SFbc", "SFudsg" };
//   bool realDataNuisance[nSyst] = { false, true, true }; // indicate if relevant for real data

  string bbPurity("DataDriven"); //  "MC", "DataDrivenR", "None"
  //string bbPurity("None"); //  "MC", "DataDrivenR", "None"

  bool onlineBtagCorr = true;

  int nSyst = 4;
  std::string systName[] = { "JES", "SFbc", "SFudsg", "JER" };
  bool realDataNuisance[] = { false, true, true, false }; // indicate if relevant for real data

  const int nUpDown = 2;
  std::string signalFile = "";

bool dosignal=true;


#if defined(MEDIUM2012)
dosignal=false;
nTCombData=1; ///only one trigger
//nSyst=0; /// no syst templates

#endif


  // signal templates
  if (IgorVersion != "V3") {
    std::cout << "Using signal files " << IgorVersion << std::endl;
    signalFile.assign( Form("%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",IgorPath.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  } else {
    std::cout << "Using V3 signal files" << std::endl;
    signalFile.assign( Form("/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/SF/job_1/TripleBtagAnalysisM-%d_%s.root",signalMode.c_str(),signalMass[iMass],spacer.c_str(),signalMass[iMass],IgorScen.c_str() ) );
  }
  std::string signalSystFiles[nSyst][nUpDown];
  //bool activeNuisance[nSyst] = { true, true, true };
  std::string upDownName[nUpDown] = { "Up", "Down" };
  TH2F* hSignalSyst[nSyst][nUpDown][nbtag];

  // output file
  TFile* hout = new TFile(Form("packedTemplates-M-%d.root",signalMass[iMass]),"recreate");
  hout->cd();
  TH2::AddDirectory(true);

  TFile* fSig = new TFile( signalFile.c_str() );
  if ( fSig == NULL ) {
    std::cout << "Could not open signal central file " << signalFile.c_str() << std::endl;
    return;
  } else {
    std::cout << "Open signal file " << signalFile.c_str() << std::endl;
  }

  TH2F* hSignalCentral[nbtag];

  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    hSignalCentral[ibtag] = mergeSignal(fSig,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
					Form("bbH_%s",sbtag[ibtag].c_str()));
    // read the efficiency
    TH1F* histEffMerged = (TH1F*) fSig->Get(Form("TrigEff/EffMerged%s",sbtag[ibtag].c_str()));
    if ( histEffMerged == NULL) {
      std::cout << "Efficiency histo not found" << std::endl;
      return;
    }
    double newEff = histEffMerged->GetBinContent(1);
    std::cout << "Mass= " << signalMass[iMass] 
	      << " btag= " << sbtag[ibtag]
	      << " Efficiency = " << newEff << std::endl;
    efficiency[iMass][ibtag] = newEff;

    double normShould = 1000 * intLumi * efficiency[iMass][ibtag];
    double normIs = hSignalCentral[ibtag]->GetSumOfWeights();
    std::cout << hSignalCentral[ibtag]->GetName() << " TotalContents=" << hSignalCentral[ibtag]->GetSumOfWeights()
	      << std::endl;
    fScal[iMass][ibtag] = normShould / normIs;
    std::cout << "normShould = " << normShould << " normIs " << normIs
	      << " rescale by " << fScal[iMass][ibtag] << std::endl;
    hSignalCentral[ibtag]->Scale( fScal[iMass][ibtag] );
    hout->cd();
    hSignalCentral[ibtag]->Write();
    histEffMerged->Write();

    // create empty file just as marker
    ofstream markerFile;
    markerFile.open(Form("pack-%s-%s.txt",sbtag[ibtag].c_str(),scenario.c_str()),ios::app);
    markerFile << "Template for mass " << signalMass[iMass] << std::endl;
    markerFile.close();
  }

  // read the nominal cross section
  TH1F* histXSect = (TH1F*) fSig->Get("xsection/xsect");
  if ( histXSect == NULL) {
    std::cout << "xsection/xsect" << " not found" << std::endl;
    return;
  }
  histXSect->Write();

  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
      if (IgorVersion != "V3") {
	signalSystFiles[iSyst][iUpDown] = Form( "%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						IgorPath.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      } else {	
	signalSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_0_1/src/Analysis/HbbMSSMAnalysis/test/Systematics-test-3/%s/theMergeList-SUSYBBHToBB_M-%d_7TeV-pythia6-tauola%s/%s_Sys%s/job_1/TripleBtagAnalysisM-%d_%s.root",
						signalMode.c_str(),signalMass[iMass],spacer.c_str(),systName[iSyst].c_str(),
						upDownName[iUpDown].c_str(),signalMass[iMass],IgorScen.c_str());
      }
      std::cout << "Signal systematics file " << signalSystFiles[iSyst][iUpDown] << std::endl;
      TFile* fSigSys = new TFile( signalSystFiles[iSyst][iUpDown].c_str() );
      if ( fSigSys == NULL ) {
	std::cout << "Could not open signal syst file " << signalSystFiles[iSyst][iUpDown].c_str() << std::endl;
	return;
      }
      for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	hSignalSyst[iSyst][iUpDown][ibtag] 
	  = mergeSignal(fSigSys,Form(signalHistPattern.c_str(),sbtag[ibtag].c_str()),
			Form("bbH_%s_%s_%s",systName[iSyst].c_str(),
			     upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()));
	std::cout << "The merged hist has name " << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << std::endl;
	std::cout << hSignalSyst[iSyst][iUpDown][ibtag]->GetName() << " TotalContents=" << hSignalSyst[iSyst][iUpDown][ibtag]->GetSumOfWeights()
		  << std::endl;
	
	hSignalSyst[iSyst][iUpDown][ibtag]->Scale( fScal[iMass][ibtag] );
	hout->cd();
	hSignalSyst[iSyst][iUpDown][ibtag]->Write();
      }
      fSigSys->Close();
    }
  }

  // real data
  std::string backgroundFile( Form("/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_SF/TripleBtagAnalysis.root",SashaPath.c_str()) );

#if defined(MEDIUM2012)
//bool dosignal=true;
//backgroundFile = std::string("/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/MVA-production-selection-trees/TripleBtagAnalysis.root");
backgroundFile = std::string("/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/Blind-test-BG-only-Fit/MEDIUM/TripleBtagAnalysis_SF/TripleBtagAnalysis.root");
#endif


  std::cout << "Background central file : " << backgroundFile << std::endl;
  TFile* fBac = new TFile( backgroundFile.c_str() );
  if ( fBac == NULL ) {
    std::cout << "Could not open background central file " << signalFile.c_str() << std::endl;
    return;
  }

  // hist-to-be-fitted
  TH2F* mjjEbtdata[nbtag];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    mjjEbtdata[ibtag] = getTrigsAndMerge(fBac,Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()),nTCombData,tCombData);

    if (mjjEbtdata[ibtag] == NULL) {
      std::cout << "Histogram not found: " << Form("massEvBtag/mjjEvBTag_%s",sbtag[ibtag].c_str()) << std::endl;
      return;
    }
    // rename
    mjjEbtdata[ibtag]->SetName( Form("Data_%s",sbtag[ibtag].c_str() ) );
    hout->cd();
    mjjEbtdata[ibtag]->Write();
  }

  TH2F* hBackgroundCentral[nbtag][ncateg][nfc];
  TH2F* hBackgroundCentralError[nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      int theTpat;
      if (onlineBtagCorr) {
	theTpat = 3;
      } else {
	theTpat = icateg;
      }

      for (int ifc=0; ifc<nfc; ++ifc) {
	string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	if (bbPurity == "None") {
	   templateCore.assign("massBTagTemplatesCld/MassBTagTemplateUncld");
	}
	string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	hBackgroundCentral[ibtag][icateg][ifc] = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
									   templateCore.c_str(),
									   sfc[ifc].c_str(),
									   sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);

	if ( hBackgroundCentral[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystName << std::endl;
	  return;
	}
	// rename
	templateId tName(ifc,icateg);
	hBackgroundCentral[ibtag][icateg][ifc]->SetName( Form("%s_%s",tName.name().c_str(),sbtag[ibtag].c_str()) );
	// read the template errors
	templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	hBackgroundCentralError[ibtag][icateg][ifc] 
	  = getTrigsAndMerge(fBac,Form("%s_%s_%s_Cat%dTpat%d",
				       templateCore.c_str(),
				       sfc[ifc].c_str(),
				       sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	if ( hBackgroundCentralError[ibtag][icateg][ifc] == NULL ) {
	  std::cout << "Hist not found: " << hbSystNameError << std::endl;
	  return;
	}
	if (useTemplateError) {
	  // add the template error
	  std::cout << " ==== Adding Btag Errors ==== " << hBackgroundCentral[ibtag][icateg][ifc]->GetName() << std::endl;
	  for (int ibinx=1; ibinx<= (hBackgroundCentral[ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
	    for (int ibiny=1; ibiny<= (hBackgroundCentral[ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
	      float oldError = hBackgroundCentral[ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
	      float addError = hBackgroundCentralError[ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
	      float newError = sqrt( oldError * oldError + addError * addError );
	      hBackgroundCentral[ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
	    }
	  }
	}
	hout->cd();
	hBackgroundCentral[ibtag][icateg][ifc]->Write();
      }
    }
  }



  std::string backgroundSystFiles[nSyst][nUpDown];
  std::string systNameSasha[] = { "JES", "SFbc", "SFq" };
  std::string upDownNameSasha[nUpDown] = { "plus2", "minus2" };
  TH2F* hBackgroundSyst[nSyst][nUpDown][nbtag][ncateg][nfc];
  TH2F* hBackgroundSystError[nSyst][nUpDown][nbtag][ncateg][nfc];

//#if !defined(MEDIUM2012)

  // for nuisances like JEC, the up/down templates are just copies of the central templates
  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    if (! realDataNuisance[iSyst]) {
      std::cout << "Non-real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  for (int icateg=0; icateg<ncateg; ++icateg) {
	    for (int ifc=0; ifc<nfc; ++ifc) {
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		= new TH2F( *hBackgroundCentral[ibtag][icateg][ifc] );
	      // rename
	      templateId tName(ifc,icateg);
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		->SetName( Form("%s_%s_%s_%s",
				tName.name().c_str(),systName[iSyst].c_str(),
				upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	    }
	  }
	}
      }
    }
  }
//#endif

  fBac->Close();


  for (int iSyst=0; iSyst<nSyst; ++iSyst) {
    if (realDataNuisance[iSyst]) {
      std::cout << "Real data relevant nuisance: " << systName[iSyst].c_str() << std::endl;
      for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
//	backgroundSystFiles[iSyst][iUpDown] = Form( "/afs/naf.desy.de/user/r/rmankel/scratch/HbbPat/CMSSW_4_2_4_patch1/src/Analysis/HbbMSSMAnalysis/test/results/v1/%s/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",SashaPath.c_str(),systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	backgroundSystFiles[iSyst][iUpDown] = Form( "/data/user/marfin/CMSSW_5_3_3/src/Analysis/HbbMSSMAnalysis/test/Analysis2012/Blind-test-BG-only-Fit/MEDIUM/TripleBtagAnalysis_%s%s/TripleBtagAnalysis.root",systNameSasha[iSyst].c_str(),upDownNameSasha[iUpDown].c_str() );
	TFile* fBacSys = new TFile( backgroundSystFiles[iSyst][iUpDown].c_str() );
	std::cout << "Background systematics file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	if ( fBacSys == NULL ) {
	  std::cout << "Could not open background syst file " << backgroundSystFiles[iSyst][iUpDown] << std::endl;
	  return;
	}
	for (int ibtag=0; ibtag<nbtag; ++ibtag) {
	  for (int icateg=0; icateg<ncateg; ++icateg) {
	    int theTpat;
	    if (onlineBtagCorr) {
	      theTpat = 3;
	    } else {
	      theTpat = icateg;
	    }

	    for (int ifc=0; ifc<nfc; ++ifc) {
	      string templateCore("massBTagTemplatesCld/MassBTagTemplateCld");
	      if (bbPurity == "None") {
		templateCore.assign("massBTagTemplatesCld/MassBTagTemplateUncld");
	      }
	      string hbSystName( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
				      sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] 
		= getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
						templateCore.c_str(),
						sfc[ifc].c_str(),
						sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	      if ( hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
		std::cout << "Hist not found: " << hbSystName << std::endl;
		return;
	      }
	      // rename
	      templateId tName(ifc,icateg);
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]
		->SetName( Form("%s_%s_%s_%s",
				tName.name().c_str(),systName[iSyst].c_str(),
				upDownName[iUpDown].c_str(),sbtag[ibtag].c_str()) );
	      
	      // read template errors
	      templateCore.assign("errorMassBTagTemplates/ErrorMassBTagTemplate");
	      string hbSystNameError( Form("%s_%s_%s_Cat%dTpat%d",templateCore.c_str(),
					   sfc[ifc].c_str(),sbtag[ibtag].c_str(),icateg,theTpat) );
	      hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] 
		= getTrigsAndMerge(fBacSys,Form("%s_%s_%s_Cat%dTpat%d",
						templateCore.c_str(),
						sfc[ifc].c_str(),
						sbtag[ibtag].c_str(),icateg,theTpat),nTCombData,tCombData);
	      if ( hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc] == NULL ) {
		std::cout << "Hist not found: " << hbSystNameError << std::endl;
		return;
	      }
	      if (useTemplateError) {
		// add the template error
		std::cout << " ==== ErrorAdd ==== " << hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
		for (int ibinx=1; ibinx<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetXaxis()->GetNbins()); ++ibinx) {
		  for (int ibiny=1; ibiny<= (hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetYaxis()->GetNbins()); ++ibiny) {
		    float oldError = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinError(ibinx,ibiny);
		    float addError = hBackgroundSystError[iSyst][iUpDown][ibtag][icateg][ifc]->GetBinContent(ibinx,ibiny);
		    float newError = sqrt( oldError * oldError + addError * addError );
		    hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->SetBinError(ibinx,ibiny,newError);
		  }
		}
	      }
	      hout->cd();
	      hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->Write();
	    }
	  }
	}
	fBacSys->Close();
      }
    }
  }

  std::cout << "Everything done " << std::endl;

#ifdef PROJECTIONS

TFile * projections_out=TFile::Open("projections.root","RECREATE");

  // loop over background templates
  //TH1D* bgProX[nbtag][ncateg][nfc];
  TH1D* bgSystProX[nSyst][nUpDown][nbtag][ncateg][nfc];
  for (int ibtag=0; ibtag<nbtag; ++ibtag) {
    for (int icateg=0; icateg<ncateg; ++icateg) {
      for (int ifc=0; ifc<nfc; ++ifc) {
	TH2F* theTemp = hBackgroundCentral[ibtag][icateg][ifc];
	TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
	theTempProX->SetName( Form("%sProX",theTemp->GetName()) );
	TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
	std::cout << "Made projection " << theTempProX->GetName() << std::endl;

	if ( (icateg == 0) && (ifc == 0) ) {
	  for (int ibinx=1; ibinx<= theTempProX->GetXaxis()->GetNbins(); ++ibinx) {
	    std::cout << ibinx << " content " << theTempProX->GetBinContent(ibinx)
		      << " error " << theTempProX->GetBinError(ibinx) << std::endl;
	  }
	}
	theTempProX->SetMarkerStyle(20);
	theTempProX->SetMarkerColor(1);
	theTempProX->SetLineColor(1);
	theTempProX->SetMarkerSize(1);
	std::cout << "Draw" << std::endl;
	theTempProX->Draw("EP");
	theTempProX->Write();






	//theTempProX->Draw("LP,SAME");
	// draw the SFbc systematics
	int colSyst[3] = {1, 2, 4};
	int lstyleUpDown[2] = {1, 1};
	for (int iSyst=1; iSyst<nSyst; ++iSyst) {
	  for (int iUpDown=0; iUpDown<nUpDown; ++iUpDown) {
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc] =  hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->ProjectionX(Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()),0,-1,"e");
	    bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetName( Form("%sProXX",hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc]->GetName()) );
	    std::cout << "Made projection " << bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->GetName() << std::endl;
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->SetLineColor( colSyst[iSyst] );
	     bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->Draw("HIST,SAME");
		 bgSystProX[iSyst][iUpDown][ibtag][icateg][ifc]->Write();


// 	    TH2F* theTemp = hBackgroundSyst[iSyst][iUpDown][ibtag][icateg][ifc];
// 	    TH1D* theTempProX = theTemp->ProjectionX(Form("%sProX",theTemp->GetName()),0,-1,"e");
// 	    theTempProX->SetLineColor( colSyst[iSyst] );
// 	    TH1D* theTempProY = theTemp->ProjectionY(Form("%sProY",theTemp->GetName()),0,-1,"e");
// 	    theTempProY->SetLineColor( colSyst[iSyst] );
// 	    //theTempProX->Draw("HIST");
	  }
	}

	canvas->Print(Form("Template_%s_%s_Cat%d_ProX.png",sbtag[ibtag].c_str(),sfc[ifc].c_str(),icateg));


	theTempProY->SetMarkerStyle(20);
	theTempProY->SetMarkerColor(1);
	theTempProY->SetLineColor(1);
	theTempProY->SetMarkerSize(1);
	std::cout << "Draw" << std::endl;
	theTempProY->Draw("EP");
	theTempProY->Write();


      }
    }
  }

projections_out->Write();
projections_out->Close();



#endif

  hout->Write();
  hout->Close();

  // close the signal central file
  fSig->Close();

  return;
}
Exemple #26
0
	/*! Parses a Position Weight Matrices string
	 Parses string containing position weight matrix definitions
	 \param[in] std::string file
	 */
	bool PWM::parse(const std::string& matrix){
		size_t thresh = matrix.find("THRESHOLD DEFINITION");
        size_t track  = matrix.find("TRACK SYMBOL DEFINITIONS");
        size_t ambig  = matrix.find("AMBIGUOUS SYMBOL DEFINITIONS");
        size_t pwm = matrix.find("POSITION WEIGHT DEFINITIONS");
		size_t back = matrix.find("BACKGROUND DEFINITION");
		size_t space = matrix.find("SPACER DEFINITIONS");
		size_t blank;
        size_t nlChar;
		
		if (thresh != std::string::npos){
			blank=matrix.find("\n\n",thresh);
			
			size_t nlCharEq = matrix.rfind("####\n",blank);
			size_t nlCharNum= matrix.rfind("====\n",blank);
			//Check for optional dividing line
			if (nlCharEq!=std::string::npos){
				nlChar=nlCharEq+5;
			}
			else if (nlCharNum!=std::string::npos){
				nlChar=nlCharNum+5;
			}
			else{  //No divider line
				nlChar=matrix.find("\n",thresh);
				nlChar++;
			}
			
			
			std::string thr (matrix.substr(nlChar,blank-nlChar));
			
			if (!_parseThreshold(thr)){
				return false;
			}
			
		}
		
		if (track != std::string::npos){
			blank=matrix.find("\n\n",track);

            size_t nlCharEq = matrix.rfind("####\n",blank);
            size_t nlCharNum= matrix.rfind("====\n",blank);
            //Check for optional dividing line
            if (nlCharEq!=std::string::npos){
                nlChar=nlCharEq+5;
            }
            else if (nlCharNum!=std::string::npos){
                nlChar=nlCharNum+5;
            }
            else{  //No divider line
                nlChar=matrix.find("\n",track);
                nlChar++;
            }


            std::string trck (matrix.substr(nlChar,blank-nlChar));

            if (!_parseTrack(trck)){
                return false;
            }
			
        }
        else{
            std::cerr << "Required section: TRACK SYMBOL DEFINITIONS missing from the model" << std::endl;
            return false;
        }
		
		if (ambig != std::string::npos){
			blank=matrix.find("\n\n",ambig);

            size_t nlCharEq = matrix.rfind("####\n",blank);
            size_t nlCharNum= matrix.rfind("====\n",blank);
            //Check for optional dividing line
            if (nlCharEq!=std::string::npos){
                nlChar=nlCharEq+5;
            }
            else if (nlCharNum!=std::string::npos){
                nlChar=nlCharNum+5;
            }
            else{  //No divider line
                nlChar=matrix.find("\n",ambig);
                nlChar++;
            }

            std::string amb(matrix.substr(nlChar,blank-nlChar));

            if (!_parseAmbiguous(amb)){
                return false;
            }

		}
		
		if (back!= std::string::npos){
			blank=matrix.find("\n\n",back);
			
            size_t nlCharEq = matrix.rfind("####\n",blank);
            size_t nlCharNum= matrix.rfind("====\n",blank);
            //Check for optional dividing line
            if (nlCharEq!=std::string::npos){
                nlChar=nlCharEq+5;
            }
            else if (nlCharNum!=std::string::npos){
                nlChar=nlCharNum+5;
            }
            else{  //No divider line
                nlChar=matrix.find("\n",back);
                nlChar++;
            }
			
            std::string background(matrix.substr(nlChar,blank-nlChar));
			
            if (!_parseBackground(background)){
                return false;
            }
		}
		
		//Parse the positions
		if (pwm != std::string::npos){
			std::string positions = matrix.substr(pwm);
			_parsePositions(positions);
		}
		
		
		//Parse the Spacer Information
		if (space != std::string::npos){
			blank=matrix.find("\n\n",space);
			
            size_t nlCharEq = matrix.rfind("####\n",blank);
            size_t nlCharNum= matrix.rfind("====\n",blank);
            //Check for optional dividing line
            if (nlCharEq!=std::string::npos){
                nlChar=nlCharEq+5;
            }
            else if (nlCharNum!=std::string::npos){
                nlChar=nlCharNum+5;
            }
            else{  //No divider line
                nlChar=matrix.find("\n",space);
                nlChar++;
            }
			
            std::string spacer(matrix.substr(nlChar,blank-nlChar));
			
            if (!_parseSpacer(spacer)){
                return false;
            }
		}
		
		_finalizeTransitions();
		
		return true;
	}
Exemple #27
0
  bool show() {
    use_full_install_ui_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_USE_FULL_INSTALL_UI), options.use_full_install_ui);
    new_line();
    update_stable_builds_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_UPDATE_STABLE_BUILDS), options.update_stable_builds);
    new_line();
    logged_install_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_LOGGED_INSTALL), options.logged_install);
    new_line();
    open_changelog_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_OPEN_CHANGELOG), options.open_changelog);
    new_line();
    label(Far::get_msg(MSG_CONFIG_INSTALL_PROPERTIES));
    install_properties_ctrl_id = edit_box(options.install_properties, 30);
    new_line();
    separator();
    new_line();

    use_proxy_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_USE_PROXY), options.http.use_proxy);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_PROXY_SERVER));
    proxy_server_ctrl_id = edit_box(options.http.proxy_server, 20);
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_PROXY_PORT));
    proxy_port_ctrl_id = edit_box(options.http.proxy_port ? int_to_str(options.http.proxy_port) : wstring(), 6);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_PROXY_AUTH_SCHEME));
    vector<wstring> auth_scheme_list;
    auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_BASIC));
    auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_NTLM));
    auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_PASSPORT));
    auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_DIGEST));
    auth_scheme_list.push_back(Far::get_msg(MSG_CONFIG_PROXY_AUTH_NEGOTIATE));
    proxy_auth_scheme_ctrl_id = combo_box(auth_scheme_list, options.http.proxy_auth_scheme, AUTO_SIZE, DIF_DROPDOWNLIST);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_PROXY_USER_NAME));
    proxy_user_name_ctrl_id = edit_box(options.http.proxy_user_name, 15);
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_PROXY_PASSWORD));
    proxy_password_ctrl_id = edit_box(options.http.proxy_password, 15);
    new_line();
    separator();
    new_line();

    cache_enabled_ctrl_id = check_box(Far::get_msg(MSG_CONFIG_CACHE_ENABLED), options.cache_enabled);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_CACHE_MAX_SIZE));
    cache_max_size_ctrl_id = edit_box(int_to_str(options.cache_max_size), 2);
    new_line();
    spacer(2);
    label(Far::get_msg(MSG_CONFIG_CACHE_DIR));
    cache_dir_ctrl_id = edit_box(options.cache_dir, 30);
    new_line();
    separator();
    new_line();

    ok_ctrl_id = def_button(Far::get_msg(MSG_BUTTON_OK), DIF_CENTERGROUP);
    cancel_ctrl_id = button(Far::get_msg(MSG_BUTTON_CANCEL), DIF_CENTERGROUP);
    new_line();

    int item = Far::Dialog::show();

    return (item != -1) && (item != cancel_ctrl_id);
  }