void GameWinDialog::paintContent(QPainter &p)
{
  GamePanel::paintContent(p);

  p.setOpacity(1);
  p.setFont(gameStock->Font60);
  p.setPen(QPen(QColor(0x030055)));

  drawHCentered(p, 50, tr("You're the Winner!"));

  p.setFont(gameStock->Font40);

  drawHCentered(p, 200, tr("You finished all the levels!"));

  p.setFont(gameStock->Font20);

  const int y30 = DY(40);

  const int x1 = DX(300), x2 = DX(420), x3 = DX(600);
  const int /*y1 = DY(250), */y2 = DY(350)/*, y3 = DY(350)*/;

  p.drawPixmap(x1,y2, gameStock->Score);
  p.drawText(x3,y2+y30, QString::number(score));

  p.setPen(QPen(Qt::black));
  p.drawText(x2,y2+y30, tr("Score:"));
}
Exemple #2
0
void Scene::drawTextHint(QPainter& painter) {
	painter.setOpacity(1);
	painter.setPen(QPen(Qt::white));
	painter.setFont(gameStock->font12);
	QString hintText = "Hint";
	painter.drawText(0, DY(690), DX(860), DY(30), Qt::AlignRight, hintText);
}
void LevelWinDialog::paintContent(QPainter &p)
{
  GamePanel::paintContent(p);

  p.setOpacity(1);
  p.setFont(gameStock->Font40);
  p.setPen(QPen(QColor(0x030055)));

  drawHCentered(p, 50, tr("Level %1 completed!").arg(level));

  p.setFont(gameStock->Font20);

  const int y30 = DY(40);

  const int x1 = DX(300), x2 = DX(380), x3 = DX(600);
  const int y1 = DY(250), y2 = DY(350);

  p.drawPixmap(x1,y1, gameStock->Clock);
  p.drawText(x3,y1+y30, QString("%1:%2").arg(time/60, 2, 10, QChar('0')).arg(time%60, 2, 10, QChar('0')));

  p.drawPixmap(x1,y2, gameStock->Score);
  p.drawText(x3,y2+y30, QString::number(score));

  p.setPen(QPen(Qt::black));
  p.drawText(x2,y1+y30, tr("Time left:"));
  p.drawText(x2,y2+y30, tr("Score:"));
}
Exemple #4
0
void updatePMLEFieldUtilEy(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){
		
	int i, j, k; // These are the indexes
	int x,y,z;// There are indexes for the pmlConstStruct indexs
	long p;
	int m;
	double dyStore;
	double eps;
	for (i=xStart;i<xEnd+1;i++){
		x = abs(xBound - i)%PML_LAYERS;	
	for (j=yStart;j<yEnd+1;j++){
		y = abs(yBound - j)%PML_LAYERS;	
	for (k=zStart;k<zEnd+1;k++){
		z = abs(zBound - k)%PML_LAYERS;
			
		p = PMLINDEX(i,j,k);
		dyStore = DY(p);					
	
		m = MATERIALINDEX(i,j,k);
		eps = EPSR(m)*EPSNOT;
				
		DY(p)     = cz[z].c1*DY(p) + cz[z].c2*(HX(i,j,k) - HX(i,j,k-1) + HZ(i-1,j,k) - HZ(i,j,k) - JSY(m));
		EY(i,j,k) = cx[x].c3*EY(i,j,k) + cx[x].c4*(cy[y].c5*DY(p)-cy[y].c6*dyStore)/eps; 

	}}} // end for

}// end updatePMLEFieldUtilEy
void IScene::drawTextHint(QPainter &p)
{
  p.setOpacity(1);
  p.setPen(QPen(Qt::yellow));
  p.setFont(gameStock->Font12);
  //p.drawText(0,DY(690),DX(860),DY(30), Qt::AlignRight, hintText);
  p.drawText(0,DY(675),WIDTH,DY(30), Qt::AlignCenter, hintText);
}
Exemple #6
0
button *
add_button(Rectangle r, char *name, char *default_label, Pixel color,
    void *param) {
	button *b = (button *)malloc(sizeof(button));
	utf8 *label[bstates];

	assert(b);	// allocating button memory
	b->type = Button;
	b->r = r;
	b->name = name;
	b->state = default_button_state;
	b->next = 0;
	b->param = param;
	b->category = default_category;
	last_button = b;

	if ( !(ptinrect(r.min, screen_rect) &&
	    r.max.x <= screen_rect.max.x &&
	    r.max.y <= screen_rect.max.y)) {
		fprintf(stderr, "*** button %s is off screen, ignored:  %d,%d - %d,%d\n",
			name, r.min.x, r.min.y, r.max.x, r.max.y);
		return 0;
	}

	/* lookup configuration file alternates for our default label names. */

	label[Off] = lookup(name, ".off", default_label);
	label[On] = lookup(name, ".on", default_label);
	label[Unavailable] = lookup(name, ".unavail", default_label);

fprintf(stderr, "0 ");
	make_PixMap(&b->pm[Off],	(Rectangle){{0,0},{DX(r),DY(r)}}, color);
fprintf(stderr, "1 ");
	make_PixMap(&b->pm[On],		(Rectangle){{0,0},{DX(r),DY(r)}}, color);
fprintf(stderr, "1 ");
	make_PixMap(&b->pm[Unavailable],(Rectangle){{0,0},{DX(r),DY(r)}}, dim_color(color));
fprintf(stderr, "2\n");

	b_fill_rect(b->pm[Off], inset(b->pm[Off].r, BUTTON_RIM), dim_color(color));
	b_fill_rect(b->pm[On], inset(b->pm[On].r, BUTTON_RIM), Black);

	string_on_pixmap(&(b->pm[Off]), label[Off], White, 1, 1);
	string_on_pixmap(&(b->pm[On]), label[On], White, 1, 1);
	string_on_pixmap(&(b->pm[Unavailable]), label[Unavailable], dim_color(White), 1, 1);

	/* Add button to the end of the linked list */

fprintf(stderr, "2 ");
	if (buttons == 0)
		buttons = b;
	else {
		button *bp = buttons;
		while (bp->next)
			bp = bp->next;
		bp->next = b;
	}
	return b;
}
void IScene::addTime(int timeAdd)
{
  time += timeAdd;

  createStaticPopup(QRect(DX(975), DY(75), DX(100), DY(30)),
                  QString("+%1").arg(timeAdd),
                  Qt::AlignLeft | Qt::AlignTop,
                  gameStock->Font20,
                  Qt::yellow,
                  1,
                  0, 20,
                  0, -1
                  );
}
Exemple #8
0
void
show_hist(void) {
	int i, y;
	int font_height = FONTHEIGHT(text_font);
	Point p = (Point){hist_r.min.x, hist_r.max.y};
	struct button_info *bi = 0;

	clear_to_background(hist_r);

	for (i=0; i<nhist; i++) {
		button *bp = history[i];

		bi = (struct button_info *)bp->param;
		p.y -= 2;
		p.y -= DY(bi->name.r);
		write_pixmap(p, bi->name.r, bi->name);
	}

#ifdef explain
	clear_to_background(explain_r);
	if (nhist) {
		if (DX(bi->description.r))
			write_pixmap(explain_r.min, bi->description.r, bi->description);
		else
			write_pixmap(explain_r.min, bi->name.r, bi->name);
	}
#endif
}
Exemple #9
0
/*
 * Return a button's rectangle the same size and shape as the given rectangle,
 * just below it.
 */
Rectangle
above(Rectangle br) {
	Rectangle r;

	r.min.y = br.max.y + button_sep;
	r.max.y = r.min.y + DY(br);
	r.max.x = br.max.x;
	r.min.x = br.min.x;
	return r;
}
Exemple #10
0
static inline void calcE(void)
{
  for(int i=1; i<N_PX-1; i++)
    for(int j=1; j<N_PY-1; j++)
      Ex[ind(i,j)] = DX(i,j)/EPSEX(i,j);

  for(int i=1; i<N_PX-1; i++)
    for(int j=1; j<N_PY-1; j++)
      Ey[ind(i,j)] = DY(i,j)/EPSEY(i,j);
}
Exemple #11
0
/*
 * Return a button's rectangle the same size and shape as the given rectangle,
 * just below it.
 */
Rectangle
below(Rectangle br) {
	Rectangle r;

	r.max.y = br.min.y - button_sep;
	r.min.y = r.max.y - DY(br);
	r.max.x = br.max.x;
	r.min.x = br.min.x;
	return r;
}
Exemple #12
0
/*
 * Paint the button.  If it is hidden, blacken the area.  If they don't want us
 * to blacken the area, they shouldn't call us in the first place.
 */
void
paint_button(button *b) {
	assert(b->state >= 0 && b->state < bstates);
	if (b->state == Hidden) {
		fill_rect(b->r, Black);
		return;
	}
	write_pixmap(b->r.min,
	    (Rectangle){{0,0}, {DX(b->pm[b->state].r),DY(b->pm[b->state].r)}},
	    b->pm[b->state]);
}
Exemple #13
0
void updatePMLEFieldUtilAll(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){
		
	int i, j, k; // These are the indexes
	int x,y,z;// There are indexes for the pmlConstStruct indexs
	long p;
	int m;
	double dxStore, dyStore, dzStore;
	double eps;
// Either this, or make cOnes a bigger array with number of elements which are the max of xLen, yLen, zLen
	for (i=xStart;i<xEnd+1;i++){
		x = abs(xBound - i)%PML_LAYERS;	
	for (j=yStart;j<yEnd+1;j++){
		y = abs(yBound - j)%PML_LAYERS;		
	for (k=zStart;k<zEnd+1;k++){
		z = abs(zBound - k)%PML_LAYERS;
			
		//printf("(i,j,k) (%d, %d, %d), (x,y,z) (%d,%d,%d)\n", i,j,k,x,y,z);
		p = PMLINDEX(i,j,k);

		dxStore = DX(p);					
		dyStore = DY(p);					
		dzStore = DZ(p);			
	
		m = MATERIALINDEX(i,j,k);
		eps = EPSR(m)*EPSNOT;
				
		DX(p)     = cy[y].c1*DX(p) + cy[y].c2*(HZ(i,j,k) - HZ(i,j-1,k) - HY(i,j,k) + HY(i,j,k-1) - JSX(m));
		EX(i,j,k) = cz[z].c3*EX(i,j,k) + cz[z].c4*(cx[x].c5*DX(p)-cx[x].c6*dxStore)/eps; 
		 
		DY(p)     = cz[z].c1*DY(p) + cz[z].c2*(HX(i,j,k) - HX(i,j,k-1) + HZ(i-1,j,k) - HZ(i,j,k) - JSY(m));
		EY(i,j,k) = cx[x].c3*EY(i,j,k) + cx[x].c4*(cy[y].c5*DY(p)-cy[y].c6*dyStore)/eps; 
		
		DZ(p)     = cx[x].c1*DZ(p) + cx[x].c2*(HY(i,j,k) - HY(i-1,j,k) - HX(i,j,k) + HX(i,j-1,k) - JSZ(m));
		EZ(i,j,k) = cy[y].c3*EZ(i,j,k) + cy[y].c4*(cz[z].c5*DZ(p)-cz[z].c6*dzStore)/eps; 
	}}} // end for

}// end updatePMLEFieldUtilAll
Exemple #14
0
void Viewpoint::update(){
	//todo
	double dx = objToTrack->VX();
	double dy = objToTrack->VY();
	double dz = objToTrack->VZ();

	double x = objToTrack->X()-10*dx;
	double y = objToTrack->Y()-20*dy;
	double z = objToTrack->Z()-10*dz;
	X(x);
	Y(y);
	Z(z);

	DX(-dx);
	DY(dy);
	DZ(dz);
}
Exemple #15
0
static inline void calcJD(void)
{
  for(int i=1; i<N_PX-1; i++){
    for(int j=1; j<N_PY-1; j++){
      double complex nowJx = JX(i,j);
      Jx[ind(i,j)] = CJX(i,j)*JX(i,j) + CJXHZ(i,j)*(HZ(i,j) - HZ(i,j-1));
      Dx[ind(i,j)] = CDX(i,j)*DX(i,j) + CDXJX1(i,j)*JX(i,j) - CDXJX0(i,j)*nowJx;
    }
  }
  
  for(int i=1; i<N_PX-1; i++){
    for(int j=1; j<N_PY-1; j++){
      double complex nowJy = JY(i,j);
      Jy[ind(i,j)] = CJY(i,j)*JY(i,j) + CJYHZ(i,j)*(-HZ(i,j) + HZ(i-1,j));
      Dy[ind(i,j)] = CDY(i,j)*DY(i,j) + CDYJY1(i,j)*JY(i,j) - CDYJY0(i,j)*nowJy;
    }
  }
}
Exemple #16
0
void
add_slider(Rectangle r, char *name, char *default_label, Pixel color,
    b_func *func, int value) {
	button *b = (button *)malloc(sizeof(button));
	utf8 *label[bstates];
	assert(b);	// allocating button memory
	b->type = Slider;
	b->r = r;
	b->size = (Rectangle){{0,0}, {DX(r), DY(r)}};
	b->name = name;
	b->next = 0;
	b->func = func;
	b->init = (void *)0;
	b->value = value;
	last_button = b;

	if ( !(ptinrect(r.min, screen_rect) &&
		r.max.x <= screen_rect.max.x &&
		r.max.y <= screen_rect.max.y))
		return;

	/* lookup configuration file alternates for our default label names. */

	label[Off] = lookup(name, 0, default_label);

	b->pixels[Off] = make_PixMap(b->size.max);

	place_text(b->size.max, (void *)b->pixels[Off], label[Off], White);

	/* Add button to the end of the linked list */

	if (buttons == 0)
		buttons = b;
	else {
		button *bp = buttons;
		while (bp->next)
			bp = bp->next;
		bp->next = b;
	}
}
//------------------------------------------------------------------------------
//
// standAloneTop
//
//------------------------------------------------------------------------------
void standAloneTop(Int_t  njet          = 0,
		   Bool_t useDataDriven = true,
		   Int_t  printLevel    = 2)
{
  Double_t dyYield;
  Double_t dyStatError;
  Double_t dySystError;
  Double_t dyScaleFactor;

  DY(dyYield,
     dyStatError,
     dySystError,
     dyScaleFactor,
     njet,
     "SF",
     directory,
     useDataDriven,
     printLevel);

  Double_t topYield;
  Double_t topStatError;
  Double_t topSystError;
  Double_t topScaleFactor;

  std::cout<<"dyScaleFactor: "<<dyScaleFactor<<std::endl;
  Top(topYield,
      topStatError,
      topSystError,
      topScaleFactor,
      dyScaleFactor,
      njet,
      "All",
      directory,
      useDataDriven,
      printLevel);
}
Exemple #18
0
static inline int leapp(int i) {
	return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));
}
Exemple #19
0
 virtual void exec()
 {
   USE(READ, n, tsteps);
   T DX(static_cast<T>(1.0) / n);
   T DY(static_cast<T>(1.0) / n);
   T DT(static_cast<T>(1.0) / tsteps);
   T B1(static_cast<T>(2.0));
   T B2(static_cast<T>(1.0));
   T mul1(B1 * DT / (DX * DX));
   T mul2(B2 * DT / (DY * DY));
   T a(-mul1 / static_cast<T>(2.0));
   T b(static_cast<T>(1.0) + mul1);
   T c(a);
   T d(-mul2 / static_cast<T>(2.0));
   T e(static_cast<T>(1.0) + mul2);
   T f(d);
   USE(READWRITE, v, u, p, q);
   using exec_pol = NestedPolicy<ExecList<omp_parallel_for_exec, simd_exec>,
                                 Tile<TileList<tile_fixed<16>, tile_none>>>;
   for (int t = 0; t < tsteps; ++t) {
     forall<omp_parallel_for_exec>(1, n - 1, [=](int i) {
       v->at(0, i) = static_cast<T>(1.0);
       p->at(i, 0) = static_cast<T>(0.0);
       q->at(i, 0) = v->at(0, i);
       v->at(n - 1, i) = static_cast<T>(1.0);
     });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{1, n - 1},
       [=](int i, int j) {
         p->at(i, j) = -c / (a * p->at(i, j - 1) + b);
         q->at(i, j) = (-d * u->at(j, i - 1) + (1.0 + 2.0 * d) * u->at(j, i)
                        - f * u->at(j, i + 1)
                        - a * q->at(i, j - 1))
                       / (a * p->at(i, j - 1) + b);
       });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{2, n},
       [=](int i, int j_) {
         int j = n - j_;
         v->at(j, i) = p->at(i, j) * v->at(j + 1, i) + q->at(i, j);
       });
     forall<omp_parallel_for_exec>(1, n - 1, [=](int i) {
       u->at(i, 0) = static_cast<T>(1.0);
       p->at(i, 0) = static_cast<T>(0.0);
       q->at(i, 0) = u->at(i, 0);
       u->at(i, n - 1) = static_cast<T>(1.0);
     });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{1, n - 1},
       [=](int i, int j) {
         p->at(i, j) = -f / (d * p->at(i, j - 1) + e);
         q->at(i, j) =
           (-a * v->at(i - 1, j)
            + (static_cast<T>(1.0) + static_cast<T>(2.0) * a) * v->at(i, j)
            - c * v->at(i + 1, j)
            - d * q->at(i, j - 1))
           / (d * p->at(i, j - 1) + e);
       });
     forallN<exec_pol>(
       RangeSegment{1, n - 1},
       RangeSegment{2, n},
       [=](int i, int j_) {
         int j = n - j_;
         u->at(i, j) = p->at(i, j) * u->at(i, j + 1) + q->at(i, j);
       });
   }
 }
Exemple #20
0
/*
 * Adjust the top-level button layouts for a new category.
 */
static void
set_category(button *b) {
	button *bp;
	int cat;
	int pb, sb, rb;

	clear_to_background(button_field_r);
	current_primary_button = b;

	for (bp = buttons; bp; bp = bp->next) {
		if (bp->category == Cat_none)
			continue;
		if (bp->category == current_primary_button->category)
			bp->state = Off;
		else
			bp->state = Hidden;
	}

	/*
	 * set the primary button positions for this primary selection.
	 */
	for (cat=Cat_change_color; cat <= Cat_change_shape; cat++) {
		button *b = primary_buttons[cat].b;
		b->r.min.x = PRIMARY_X;
		b->r.max.x = b->r.min.x + DX(b->pm[On].r);
		b->r.min.y =
		    primary_buttons[cat].primary_bottom[current_primary_button->category];
		b->r.max.y = b->r.min.y + DY(b->pm[On].r);
		b->state = Off;
		paint_fancy_button(b);
		flush_screen();
	}
	current_primary_button->state = On;
	cat = current_primary_button->category;

	for (bp = buttons; bp; bp = bp->next) {
		if (bp->category != cat)
			continue;
		paint_fancy_button(bp);
		flush_screen();
	}

	/* draw lines */
#define LSC_RED	(SETRGB(252,62,50))

	pb = primary_buttons[cat].primary_bottom[cat];
	sb = primary_buttons[cat].secondary_bottom + BUTTON_SEP;
	rb = PRIMARY_X+DX(current_primary_button->pm[On].r) - 2;

	fill_rect((Rectangle){{PRIMARY_X, sb+10}, {PRIMARY_X+2, pb}}, LSC_RED);
	fill_rect((Rectangle){{rb, sb+10}, {rb+2, pb}}, LSC_RED);
	fill_rect((Rectangle){{PRIMARY_X+10, sb}, {rb-10, sb+2}}, LSC_RED);

	/*
	 * Add a rounded corner to the lower left of the secondary area.  We
	 * Simply steal the lower 10x10 pixels of a secondary button, a kludge.
	 */
	write_pixmap((Point){PRIMARY_X, sb}, (Rectangle){{0,0}, {10,10}},
		sample_secondary_button->pm[Off]);
	flush_screen();
}
Exemple #21
0
/*
 * Figure out where everything goes.  The major buttons vary depending on which
 * category is selected.  We place the minor buttons now which always appear
 * in a given place, though they are obscured when their type isn't selected.
 */
void
layout_screen(void) {
	utf8 *touch_screen;
	Pixel color;
	PixMap pm_up, pm_down;
	int i;

	Rectangle r;
	Rectangle left_col, right_col, subcat_right, subcat_left;
	button *last_top;
	Point top_secondary;
	int last_secondary_bottom;

	text_font = load_font(TEXT_FONT);
	button_font = load_font(BUTTON_FONT);
	big_button_font = load_font(BIG_BUTTON_FONT);

	touch_screen = lookup("touchscreen", 0, "no");
	set_font(button_font);

	if (!set_background(find_file("background.pnm", "lib/lsc"), SCREEN_WIDTH, SCREEN_HEIGHT)) {
		fprintf(stderr, "lsc: background file %s missing\n", "background.pnm");
//		exit(1);
	}

//set_background(find_file("lsc_background.pnm", "buttons"), SCREEN_WIDTH, SCREEN_HEIGHT);

	video_r.min.x = 81;
	video_r.max.x = video_r.min.x + VIDEO_WIDTH;
	video_r.min.y = 229;
	video_r.max.y = video_r.min.y + VIDEO_HEIGHT;

	fps_r.max.x = video_r.max.x;
	fps_r.min.x = fps_r.max.x - 130;
	fps_r.max.y = video_r.min.y - 3;
	fps_r.min.y = fps_r.max.y - (FONTHEIGHT(text_font) + 5);

	message_r.max.y = fps_r.max.y;
	message_r.min.y = fps_r.min.y;
	message_r.min.x = video_r.min.x;
	message_r.max.x = fps_r.min.x;

// "Changes made" @ 875,-877; -899; -920; -940
	timer_r = (Rectangle){{0, 1080-1070}, {SCREEN_WIDTH, 45}};
	bar_r = timer_r;
	bar_r.min.x += 40;

	hist_r = (Rectangle){{575, 0}, {800, 160}};
	explain_r = (Rectangle){{16, SCREEN_HEIGHT-62},
		{SCREEN_WIDTH-307, SCREEN_HEIGHT-39}};

	freeze_button    = lsc_button((Point){900+230,109}, "freeze", 0, 0);
	undo_button	 = lsc_button((Point){900+50,109}, "undo", 0, 0);
	startover_button = lsc_button((Point){900+50,29}, "startover", 0, 0);
	current_primary_button = (button *)0;

	default_button_state = Off;
	default_category = Cat_none;

#ifdef notdef
	default_category = Cat_none;

	top_secondary = (Point){SECONDARY_X,top_y};
#endif

#define PRIMARY_X	(SCREEN_WIDTH-244)
#define SECONDARY_X	(SCREEN_WIDTH-184)
#define BUTTON_TOP	(SCREEN_HEIGHT - 32)

#define	BELOW	((Point){SECONDARY_X, (last_button->r.min.y - 60)})

	button_field_r = (Rectangle){{PRIMARY_X, 0},
		{SCREEN_WIDTH, BUTTON_TOP}};
	default_button_state = Off;

	/*
	 * Define the primary buttons.  We fill in the positions of
	 * the buttons depending on the primary selected.  This is uglier
	 * than it should be.
	 */
	default_button_state = Off;
	default_category = Cat_change_color;
	primary_buttons[Cat_change_color].b = lsc_button((Point){0,0}, "color", 0, 0);

	default_category = Cat_change_look;
	primary_buttons[Cat_change_look].b = lsc_button((Point){0,0}, "look", 0, 0);

	default_category = Cat_change_shape;
	primary_buttons[Cat_change_shape].b = lsc_button((Point){0,0}, "shape", 0, 0);

	default_button_state = Hidden;

	/* color changers */

	primary_buttons[Cat_change_color].primary_bottom[Cat_change_color] =
	    primary_buttons[Cat_change_color].primary_bottom[Cat_change_look] =
	    primary_buttons[Cat_change_color].primary_bottom[Cat_change_shape] =
		BUTTON_TOP - DY(primary_buttons[Cat_change_color].b->pm[On].r);

	default_category = Cat_change_color;
	primary_buttons[default_category].b->r.min.y = 
	    primary_buttons[default_category].primary_bottom[default_category];
	last_button = primary_buttons[default_category].b;

	lsc_button(BELOW, "blkwht", do_point, init_lum);
	sample_secondary_button = last_button;
	lsc_button(BELOW, "brghtr", do_point, init_brighten);
	lsc_button(BELOW, "dimmer", do_point, init_truncatepix);
	lsc_button(BELOW, "contrast", do_point, init_high);
	lsc_button(BELOW, "negative", do_point, init_negative);
	lsc_button(BELOW, "solar", do_point, init_solarize);
	lsc_button(BELOW, "colorize", do_point, init_colorize);
	lsc_button(BELOW, "outline", do_sobel, 0);
	lsc_button(BELOW, "raisedgray", do_edge, 0);
	primary_buttons[Cat_change_color].secondary_bottom =
		last_button->r.min.y - BUTTON_SEP;
	primary_buttons[Cat_change_look].primary_bottom[Cat_change_color] = 
	    primary_buttons[Cat_change_color].secondary_bottom -
	    DY(primary_buttons[Cat_change_look].b->pm[On].r);
	primary_buttons[Cat_change_shape].primary_bottom[Cat_change_color] = 
	    primary_buttons[Cat_change_look].primary_bottom[Cat_change_color] -
	    DY(primary_buttons[Cat_change_shape].b->pm[On].r) - BUTTON_SEP;


	/* look changers */

	primary_buttons[Cat_change_look].primary_bottom[Cat_change_look] =
	    primary_buttons[Cat_change_look].primary_bottom[Cat_change_shape] = 
	    	primary_buttons[Cat_change_color].primary_bottom[Cat_change_color] -
	    	DY(primary_buttons[Cat_change_look].b->pm[On].r) - BUTTON_SEP;;

	default_category = Cat_change_look;
	primary_buttons[default_category].b->r.min.y = 
	    primary_buttons[default_category].primary_bottom[default_category];
	last_button = primary_buttons[default_category].b;

	lsc_button(BELOW, "bigpixels", do_remap, init_pixels4);
	lsc_button(BELOW, "blur", do_blur, 0);
	lsc_button(BELOW, "blurry", do_brownian, 0);
	lsc_button(BELOW, "focus", do_focus, 0);
	lsc_button(BELOW, "bleed", do_bleed, 0);
	lsc_button(BELOW, "oilpaint", do_new_oil, 0);
	lsc_button(BELOW, "crackle", do_shower, 0);
	lsc_button(BELOW, "zoom", do_remap, init_zoom);
	lsc_button(BELOW, "earthqke", do_shear, 0);
	lsc_button(BELOW, "speckle", do_cfs, 0);
	primary_buttons[Cat_change_look].secondary_bottom = last_button->r.min.y - BUTTON_SEP;
	primary_buttons[Cat_change_shape].primary_bottom[Cat_change_look] = 
	    primary_buttons[Cat_change_look].secondary_bottom - 
	    DY(primary_buttons[Cat_change_shape].b->pm[On].r);

	/* shape changers */

	primary_buttons[Cat_change_shape].primary_bottom[Cat_change_shape] =
	    	primary_buttons[Cat_change_look].primary_bottom[Cat_change_shape] -
	    	DY(primary_buttons[Cat_change_shape].b->pm[On].r) - BUTTON_SEP;;
	default_category = Cat_change_shape;
	primary_buttons[default_category].b->r.min.y = 
	    primary_buttons[default_category].primary_bottom[default_category];
	last_button = primary_buttons[default_category].b;

	lsc_button(BELOW, "fisheye", do_remap, init_fisheye);
	lsc_button(BELOW, "flip", do_remap, init_mirror);
	lsc_button(BELOW, "mirror", do_remap, init_copy_right);
	lsc_button(BELOW, "kite", do_remap, init_kite);
	lsc_button(BELOW, "pinch", do_remap, init_cone);
	lsc_button(BELOW, "cylinder", do_remap, init_cylinder);
	lsc_button(BELOW, "wave", do_smear, 0);
	lsc_button(BELOW, "twist", do_remap, init_twist);
	lsc_button(BELOW, "escher", do_remap, init_escher);
	lsc_button(BELOW, "shower", do_remap, init_shower2);
	primary_buttons[Cat_change_shape].secondary_bottom = last_button->r.min.y - BUTTON_SEP;
}
Exemple #22
0
//------------------------------------------------------------------------------
// XS
//------------------------------------------------------------------------------
void XS(Double_t &xsValue,
	Double_t &xsStat,
	Double_t &xsSyst,
	Double_t &xsLumi,
	Double_t  luminosity,
	Int_t     njet,
	TString   channel,
	TString   cutLevel,
	Bool_t    useNM1,
	TString   directory,
	Bool_t    useDataDriven,
	Int_t     printLevel)
{


  Int_t defineChannel = -1; 

  if ( njet == 0 && channel == "SF")  defineChannel  = jet0_SF;
  if ( njet == 0 && channel == "OF")  defineChannel  = jet0_OF;
  if ( njet == 1 && channel == "SF")  defineChannel  = jet1_SF;
  if ( njet == 1 && channel == "OF")  defineChannel  = jet1_OF;
  if ( njet == 0 && channel == "All")  defineChannel  = jet0;
  if ( njet == 1 && channel == "All")  defineChannel  = jet1;

  analysisLevel = cutLevel;

  if (useNM1) analysisLevel += "_NM1";

  TString dyChannel = "SF";

  if (channel.Contains("All") && printLevel > 0) {
    printf("\n");
    printf("   WWFull xs = %.2f pb;   WWto2L xs = %.2f pb\n", nlo8tev, nlo8tev*BR_WW_to_lnln);
    printf(" qqWWFull xs = %.2f pb; qqWWto2L xs = %.2f pb\n", nlo8tev*0.97, nlo8tev*0.97*BR_WW_to_lnln);
  }

  if (channel.Contains("EE"))   dyChannel = "EE";
  if (channel.Contains("MuMu")) dyChannel = "MuMu";

  Double_t dyScaleFactor       = -999;
  Double_t dyScaleFactorForTop = -999;
  Double_t topScaleFactor      = -999;

  Double_t NDY [3];
  Double_t NTop[3];


  // Needed to always have the SF DY scale factor in the top estimation
  //----------------------------------------------------------------------------
  DY(NDY[0],
     NDY[1],
     NDY[2],
     dyScaleFactorForTop,
     njet,
     "SF",  // "SF" --> dyChannel (individual topScaleFactor)
     directory,
     useDataDriven,
     0,
     false);

    Top(NTop[0],
      NTop[1],
      NTop[2],
      topScaleFactor,
      dyScaleFactorForTop, /// should be 1 in case of OF 0nly??? 
      njet,
      "All",  // "All" --> channel (individual topScaleFactor)
      directory,
      useDataDriven,
      printLevel);

  
    DY(NDY[0],
     NDY[1],
     NDY[2],
     dyScaleFactor,
     njet,
     dyChannel,
     directory,
     useDataDriven,
     printLevel,
     false);
  

  // Input files
  //----------------------------------------------------------------------------
  TString path = Form("%s/%djet/%s/", directory.Data(), njet, channel.Data());

  TFile* inputWW       = new TFile(path + "WW_pow_nnll.root");  
  TFile* inputggWW     = new TFile(path + "ggWWto2L.root");  
  TFile* inputqqWW     = new TFile(path + "WWTo2L2Nu_pow_nnll.root");  
  TFile* inputTT       = new TFile(path + "TTbar.root");  
  TFile* inputTW       = new TFile(path + "TW.root");  
  TFile* inputWj       = new TFile(path + "WJetsFakes_Total.root");
  TFile* inputWZ       = new TFile(path + "WZ.root");  
  TFile* inputZZ       = new TFile(path + "ZZ.root");  
  TFile* inputDY       = new TFile(path + "DY.root");  
  TFile* inputDYtautau = new TFile(path + "DYtautau.root");  
  TFile* inputWg       = new TFile(path + "Wgamma.root");  
  TFile* inputWgS      = new TFile(path + "WgammaStar.root"); 
  TFile* inputWgNoS    = new TFile(path + "WgammaNoStar.root");  
  TFile* inputH125     = new TFile(path + "HWW125.root"); 
  TFile* inputZgamma   = new TFile(path + "Zgamma.root");  
  TFile* inputVVV      = new TFile(path + "VVV.root");  

  TFile* inputData     = new TFile(path + "DataRun2012_Total.root");

  TFile* inputDYOF = new TFile(Form("%s/%djet/OF/DY.root", directory.Data(), njet));


  //----------------------------------------------------------------------------
  //
  // Estimate WW cross-section
  //
  //----------------------------------------------------------------------------
  TH1F* hNWW       = (TH1F*) inputWW      ->Get("hW" + analysisLevel);
  TH1F* hNggWW     = (TH1F*) inputggWW    ->Get("hW" + analysisLevel);
  TH1F* hNqqWW     = (TH1F*) inputqqWW    ->Get("hW" + analysisLevel);
  TH1F* hNTT       = (TH1F*) inputTT      ->Get("hW" + analysisLevel);
  TH1F* hNTW       = (TH1F*) inputTW      ->Get("hW" + analysisLevel);
  TH1F* hNWj       = (TH1F*) inputWj      ->Get("hW" + analysisLevel);
  TH1F* hNWZ       = (TH1F*) inputWZ      ->Get("hW" + analysisLevel);
  TH1F* hNZZ       = (TH1F*) inputZZ      ->Get("hW" + analysisLevel);
  TH1F* hNDY       = (TH1F*) inputDY      ->Get("hW" + analysisLevel);
  TH1F* hNDYtautau = (TH1F*) inputDYtautau->Get("hW" + analysisLevel);
  TH1F* hNWg       = (TH1F*) inputWg      ->Get("hW" + analysisLevel);
  TH1F* hNWgS      = (TH1F*) inputWgS     ->Get("hW" + analysisLevel);
  TH1F* hNWgNoS    = (TH1F*) inputWgNoS   ->Get("hW" + analysisLevel);
  TH1F* hNH125     = (TH1F*) inputH125    ->Get("hW" + analysisLevel);
  TH1F* hNZgamma   = (TH1F*) inputZgamma  ->Get("hW" + analysisLevel);
  TH1F* hNVVV      = (TH1F*) inputVVV     ->Get("hW" + analysisLevel);
  TH1F* hNData     = (TH1F*) inputData    ->Get("hW" + analysisLevel);
  TH1F* hNDYOF     = (TH1F*) inputDYOF    ->Get("hW" + analysisLevel);


  // Yields
  //----------------------------------------------------------------------------
  Double_t NggWW[]     = {hNggWW    ->GetBinContent(2), hNggWW    ->GetBinError(2), 0.00};
  Double_t NqqWW[]     = {hNqqWW    ->GetBinContent(2), hNqqWW    ->GetBinError(2), 0.00};
  Double_t NWW[]       = {hNWW      ->GetBinContent(2), hNWW      ->GetBinError(2), 0.00};
  Double_t NWj[]       = {hNWj      ->GetBinContent(2), hNWj      ->GetBinError(2), 0.36*hNWj->GetBinContent(2)};
  Double_t NWZ[]       = {hNWZ      ->GetBinContent(2), hNWZ      ->GetBinError(2), 0.00};
  Double_t NZZ[]       = {hNZZ      ->GetBinContent(2), hNZZ      ->GetBinError(2), 0.00};
  Double_t NDYtautau[] = {hNDYtautau->GetBinContent(2), hNDYtautau->GetBinError(2), 0.50*hNDYtautau->GetBinContent(2)}; // [*]
  Double_t NWg[]       = {hNWg      ->GetBinContent(2), hNWg      ->GetBinError(2), 0.00};
  Double_t NWgS[]      = {hNWgS     ->GetBinContent(2), hNWgS     ->GetBinError(2), 0.00};
  Double_t NWgNoS[]    = {hNWgNoS   ->GetBinContent(2), hNWgNoS   ->GetBinError(2), 0.00};
  Double_t NH125[]     = {hNH125    ->GetBinContent(2), hNH125    ->GetBinError(2), 0.00};
  Double_t NZgamma[]   = {hNZgamma  ->GetBinContent(2), hNZgamma  ->GetBinError(2), 0.00};
  Double_t NVVV[]      = {hNVVV     ->GetBinContent(2), hNVVV     ->GetBinError(2), 0.00};
  Double_t NData[]     = {hNData    ->GetBinContent(2), hNData    ->GetBinError(2)};


  // [*] Andrea: A normalization uncertainty of 50% has been added on final estimation of dytautau.
   

  // Top yields for the non-inclusive channels
  //----------------------------------------------------------------------------
  if (!channel.Contains("All")) {

    Double_t NTT[] = {hNTT->GetBinContent(2), hNTT->GetBinError(2), 0.0};
    Double_t NTW[] = {hNTW->GetBinContent(2), hNTW->GetBinError(2), 0.0};

    NTop[2] = NTop[2] * topScaleFactor * (NTT[0] + NTW[0]) / NTop[0];  // syst.
    NTop[0] = topScaleFactor * (NTT[0] + NTW[0]);                      // yield
    NTop[1] = topScaleFactor * sqrt(NTT[1]*NTT[1] + NTW[1]*NTW[1]);    // stat.
    }


  // DY yields for the {OF, EMu, MuE} channels
  //----------------------------------------------------------------------------
  if (channel.Contains("OF")  ||
      channel.Contains("EMu") ||
      channel.Contains("MuE")) {

    NDY[2] = NDY[2] * hNDY->GetBinContent(2) / NDY[0];  // syst.
    NDY[0] = hNDY->GetBinContent(2);                    // yield  // ---> use MC because is OF 
    NDY[1] = hNDY->GetBinError(2);                      // stat.
  }


  // DY yield for the All channel
  //----------------------------------------------------------------------------
  if (channel.Contains("All")) {

    NDY[2] = NDY[2] * (NDY[0] + hNDYOF->GetBinContent(2)) / NDY[0];                // syst.
    NDY[0] = NDY[0] + hNDYOF->GetBinContent(2);                                    // yield
    NDY[1] = sqrt(NDY[1]*NDY[1] + hNDYOF->GetBinError(2)*hNDYOF->GetBinError(2));  // stat.
  }


  // Add relative systematic uncertainties
  //----------------------------------------------------------------------------
  

  NggWW[2] = Systematics [ggWW+defineChannel]   ;  // Relative systematic uncertainty
  NqqWW[2] = Systematics [WW+defineChannel]   ;  // Relative systematic uncertainty

  cout << WW+defineChannel << endl;

  NWW[2]  = (NggWW[2]*NggWW[0] * NggWW[2]*NggWW[0]);
  NWW[2] += (NqqWW[2]*NqqWW[0] * NqqWW[2]*NqqWW[0]);
  NWW[2]  = sqrt(NWW[2]) / NWW[0];  // Relative systematic uncertainty

  NWZ    [2] =  Systematics [VV+defineChannel] * NWZ    [0] / 1e2;  // Absolute systematic uncertainty
  NZZ    [2] =  Systematics [VV+defineChannel] * NZZ    [0] / 1e2;  // Absolute systematic uncertainty

  NWgNoS [2] =  Systematics [Vg+defineChannel];  // Relative systematic uncertainty
  NWgS   [2] =  Systematics [VgS+defineChannel]; // Relative systematic uncertainty

  NWg    [2] = (NWgNoS [2]*NWgNoS [0] * NWgNoS [2]*NWgNoS [0]) / 1e4;  
  NWg    [2] += (NWgS [2]*NWgS [0] * NWgS [2]*NWgS [0]) / 1e4;
  NWg    [2] = sqrt(NWg [2]);// Absolute systematic uncertainty

  NH125  [2] =  Systematics [ggH+defineChannel]* NH125  [0] / 1e2;  // Absolute systematic uncertainty
  NZgamma[2] =  Systematics [Vg+defineChannel] * NZgamma[0] / 1e2;  // Absolute systematic uncertainty
  NVVV   [2] =  Systematics [VVV+defineChannel]* NVVV   [0] / 1e2;  // Absolute systematic uncertainty




  Double_t Background = NWj[0] + NWZ[0] + NZZ[0] + NWg[0] + NTop[0] + NDY[0] + NDYtautau[0] + NH125[0]  + NZgamma[0] + NVVV[0];
  
  Double_t statErrorB = sqrt(NWj      [1]*NWj      [1] +
			     NWZ      [1]*NWZ      [1] +
			     NZZ      [1]*NZZ      [1] +
			     NWg      [1]*NWg      [1] +
			     NTop     [1]*NTop     [1] +
			     NDY      [1]*NDY      [1] +
			     NDYtautau[1]*NDYtautau[1] +
			     NH125    [1]*NH125    [1] +
			     NZgamma  [1]*NZgamma  [1] +
			     NVVV     [1]*NVVV     [1]);

  Double_t systErrorB = sqrt(NWj      [2]*NWj      [2] +
			     NWZ      [2]*NWZ      [2] +
			     NZZ      [2]*NZZ      [2] +
			     NWg      [2]*NWg      [2] +
			     NTop     [2]*NTop     [2] +
			     NDY      [2]*NDY      [2] +
			     NDYtautau[2]*NDYtautau[2] +
			     NH125    [2]*NH125    [2] +
			     NZgamma  [2]*NZgamma  [2] +
			     NVVV     [2]*NVVV     [2]);

  Double_t totalErrorB = sqrt(statErrorB*statErrorB + systErrorB*systErrorB);


  //----------------------------------------------------------------------------
  //
  // Estimate WW efficiency
  //
  //----------------------------------------------------------------------------
  TH1F* hgg = (TH1F*) inputggWW->Get("hWeff" + analysisLevel);
  TH1F* hqq = (TH1F*) inputqqWW->Get("hWeff" + analysisLevel);

  Double_t NGenggWW = NTotalggWW;
  Double_t NGenqqWW = NTotalqqWW;

  Double_t f_gg = ggWW_xs / (ggWW_xs + qqWW_xs);
  Double_t f_qq = 1 - f_gg;


  Printf("%5.3f, %5.3f" ,hqq->GetBinContent(2),  NGenqqWW);

  Double_t ggWW_efficiency = ratioValue(hgg->GetBinContent(2), NGenggWW);
  Double_t qqWW_efficiency = ratioValue(hqq->GetBinContent(2), NGenqqWW);
  Double_t   WW_efficiency = f_gg*ggWW_efficiency + f_qq*qqWW_efficiency;

  Double_t ggWW_efficiencyErr = ratioError(hgg->GetBinContent(2), NGenggWW, hgg->GetBinError(2), sqrt(NGenggWW));
  Double_t qqWW_efficiencyErr = ratioError(hqq->GetBinContent(2), NGenqqWW, hqq->GetBinError(2), sqrt(NGenqqWW));

  // Systematic component
  Double_t WW_efficiencyErr = (f_gg*NggWW[2]*NggWW[0] + f_qq*NqqWW[2]*NqqWW[0]) / NWW[0];
  WW_efficiencyErr *= WW_efficiency / 1e2;
  WW_efficiencyErr *= WW_efficiencyErr;

  // Statistical component (negligible)
  WW_efficiencyErr += (f_gg*ggWW_efficiencyErr)*(f_gg*ggWW_efficiencyErr);
  WW_efficiencyErr += (f_qq*qqWW_efficiencyErr)*(f_qq*qqWW_efficiencyErr);

  // Absolute efficiency uncertainty
  WW_efficiencyErr = sqrt(WW_efficiencyErr);


  if (printLevel > 0) {
    printf("\n signal efficiencies\n");
    printf(" -------------------------------------------------\n");
    printf("       ggWW efficiency = (%6.3f +- %5.3f)%s (stat.)\n", 1e2*ggWW_efficiency, 1e2*ggWW_efficiencyErr, "%");
    printf("       qqWW efficiency = (%6.3f +- %5.3f)%s (stat.)\n", 1e2*qqWW_efficiency, 1e2*qqWW_efficiencyErr, "%");
    printf("         WW efficiency = (%6.3f +- %5.3f)%s (total)\n", 1e2*  WW_efficiency, 1e2*  WW_efficiencyErr, "%");
  }


  // Estimate WW cross-section
  //----------------------------------------------------------------------------
  Double_t xs = (NData[0] - Background) / (luminosity * WW_efficiency);

  xs /= BR_WW_to_lnln;

  //cout << "datos!! " << (NData[0] - Background) << endl;

  // Relative errors
  //----------------------------------------------------------------------------
  Double_t errxsStats = 1e2 * sqrt(NData[0]) / (NData[0] - Background);
  Double_t errxsBkg   = 1e2 * totalErrorB    / (NData[0] - Background);
  Double_t errxsEff   = 1e2 * WW_efficiencyErr / WW_efficiency;
  Double_t errxsSyst  = sqrt(errxsBkg*errxsBkg + errxsEff*errxsEff);
  Double_t errxsLumi  = 2.6;


  if (printLevel > 0) {
    printf("\n [PAS]");
    printf(" The total uncertainty on the background estimation is about %.0f%s,",
	   1e2 * totalErrorB / Background, "%");
    printf(" [PAS]\n");
  }


  // Save the result
  //----------------------------------------------------------------------------
  xsValue = xs;
  xsStat  = xs * errxsStats / 1e2;
  xsSyst  = xs * errxsSyst  / 1e2;
  xsLumi  = xs * errxsLumi  / 1e2;


  // Print
  //----------------------------------------------------------------------------
  Double_t statErrorVV = sqrt(NWZ[1]*NWZ[1] + NZZ[1]*NZZ[1]);
  Double_t systErrorVV = sqrt(NWZ[2]*NWZ[2] + NZZ[2]*NZZ[2]);

  Double_t statErrorDYAll = sqrt(NDY[1]*NDY[1] + NDYtautau[1]*NDYtautau[1]);
  Double_t systErrorDYAll = sqrt(NDY[2]*NDY[2] + NDYtautau[2]*NDYtautau[2]);

  Double_t statErrorSPlusB = sqrt(NWW[1]*NWW[1]                           + statErrorB*statErrorB);
  Double_t systErrorSPlusB = sqrt((NWW[2]*NWW[0]/1e2)*(NWW[2]*NWW[0]/1e2) + systErrorB*systErrorB);


  if (printLevel > 0) {
    printf("\n \\hline \n");
    printf("[%s] yields \\\\ \n", channel.Data());
    printf(" \\hline \n");
    printf("       sample              &  yield $\\pm$ stat. $\\pm$ syst.\\\\ \n ");
    printf(" \\hline \n");
    printf("       gg to WW            & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NggWW[0],            NggWW[1],        NggWW[2]*NggWW[0]/1e2);
    printf("       qq to WW            & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NqqWW[0],            NqqWW[1],        NqqWW[2]*NqqWW[0]/1e2);
    printf(" \\hline \n");
    printf("       tt+tW               & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NTop[0],             NTop[1],         NTop[2]);
    printf("       W+jets              & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NWj[0],              NWj[1],          NWj[2]);
    printf("       WZ+ZZ               & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NWZ[0]+NZZ[0],       statErrorVV,     systErrorVV);
    printf("       Z/g*                & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n",   NDY[0]+NDYtautau[0], statErrorDYAll,  systErrorDYAll);
    //printf(" (%.1f Z/g* + %.1f Z/g* -> tautau)\n",                           NDY[0],              NDYtautau[0]);
    printf("       Wg+Wg*              & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NWg[0],              NWg[1],          NWg[2]);
    printf("       Zgamma              & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NZgamma[0],          NZgamma[1],      NZgamma[2]);
    printf("       VVV              & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NVVV[0],          NVVV[1],      NVVV[2]);
    printf("       H125                & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NH125[0],            NH125[1],        NH125[2]);
    printf(" \\hline \n");
    printf("       total background    & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", Background,          statErrorB,      systErrorB);
    printf("       signal              & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NWW[0],              NWW[1],          NWW[2]*NWW[0]/1e2);
    printf(" \\hline \n");
    printf("       signal + background & %6.1f $\\pm$ %5.1f $\\pm$ %5.1f \\\\ \n", NWW[0]+Background,   statErrorSPlusB, systErrorSPlusB);
    printf(" \\hline \n");
    printf("       data                & %4.0f \\\\ \n",                           NData[0]);
    printf(" \\hline \n");
    printf("\n [%s] WW cross-section\n", channel.Data());
    printf(" -------------------------------------------------\n");
  }

  printf("       sigmaWW(%s,%s) = %5.2f +- %5.2f (stat.) +- %5.2f (syst.) +- %5.2f (lumi.) pb\n",
    	 channel.Data(), analysisLevel.Data(), xsValue, xsStat, xsSyst, xsLumi);


  // Difference wrt. the theoretical value
  //----------------------------------------------------------------------------
  if (channel.Contains("All") && printLevel > 0) {

    Double_t deltaXS    = xsValue - nlo8tev;
    Double_t deltaXSErr = xsStat*xsStat + xsSyst*xsSyst + xsLumi*xsLumi + nlo8tevPlus*nlo8tevPlus;

    deltaXSErr = sqrt(deltaXSErr);

    printf("\n       sigma(NLO) = %.2f + %.2f - %.2f pb\n", nlo8tev, nlo8tevPlus, nlo8tevMinus);
    printf("\n       sigmaWW(%s) - sigma(NLO) = %.2f +- %.2f pb", channel.Data(), deltaXS, deltaXSErr);
    printf(" = (%.0f +- %.0f)\%s of the theoretical value\n\n", 1e2*deltaXS/nlo8tev, 1e2*deltaXSErr/nlo8tev, "%");
  }
Exemple #23
0
bool GameScene::initLevel(int level)
{
  qsrand(QTime::currentTime().msec());

  // if level pack not found
  if (max_level == 0)
      return false;

  // init field
  const int max = MAX_COLS*MAX_ROWS;
  for (int i = 0; i < max; i++)
  {
    PlaceInfo &pi = field[i];
    if (pi.item)
      delete pi.item;
    field[i] = PlaceInfo();
  }

  qDeleteAll(tempItems);
  tempItems.clear();

  rows = cols = 0;

  currentItem = 0;
  currentCol = currentRow = -1;
  targetCol = targetRow = -1;
  lastClickPos = QPoint();
  moveState = MS_IDLE;

  availFrom = QPoint();
  availTo = QPoint();
  hintMove = false;
  hintText = "";

  inputDisabled = true;
  paintState = false;
  stat_active = false;

  // set level
  this->level = level;

  bonus = 1;
  bonus_time = 0;
  time = 10*60;

  targets = 0;

  frameCount = 1;

  // check if all levels were finished
  if (level > max_level)
  {
    showStatictics(STAT_GAME_WON);
    return true;
  }

  // load level from pack
  if (!loadLevel(level))
      return false;

  // set local info from profile
//  PlayerInfo *pl = gameProfile->currentPlayer();
  LevelPackInfo *lpi = gameProfile->currentPlayer()->currentLevelPackInfo();
  score = lpi->score;

  // more time for hard difficulty
  if (lpi->diff == DIFF_HARD)
    time = int(time*1.5);

  toolset->readProfile(lpi);
  gameBonus->readProfile(lpi, this);
  gameBackground->readProfile(gameProfile->currentPlayer());

  // add bonus to the timer
  time += toolset->bonusClock();

  stat->level_time = time;

  gameProfile->setGameStarted(true);
  gameProfile->setGamePaused(false);

  // set background
  loadRandomBackground();

  // pre-draw lower layer
  drawHUDonBackground();

  // set cursor
  setDefaultGameCursor();

  // start level
  createStaticPopup(QRect(0,0,DX(910),DY(700)),
                  tr("Level %1").arg(level),
                  Qt::AlignCenter,
                  gameStock->Font60,
                  Qt::white,
                  1,
                  0, 50,
                  0, -2);

  sndEngine->playSound(GameSound::sndLevelStart);

  advanceTimer->start();

  // init animation
  ls_x = ls_y = 0;
  level_start = true;

  return true;
}
Exemple #24
0
/* Subroutine */ int dswap_(int *n, double *dx, int *incx, 
	double *dy, int *incy)
{


    /* System generated locals */
    int i__1;

    /* Local variables */
    static int i, m;
    static double dtemp;
    static int ix, iy, mp1;


/*     interchanges two vectors.   
       uses unrolled loops for increments equal one.   
       jack dongarra, linpack, 3/11/78.   
       modified 12/3/93, array(1) declarations changed to array(*)   


    
   Parameter adjustments   
       Function Body */
#define DY(I) dy[(I)-1]
#define DX(I) dx[(I)-1]


    if (*n <= 0) {
	return 0;
    }
    if (*incx == 1 && *incy == 1) {
	goto L20;
    }

/*       code for unequal increments or equal increments not equal   
           to 1 */

    ix = 1;
    iy = 1;
    if (*incx < 0) {
	ix = (-(*n) + 1) * *incx + 1;
    }
    if (*incy < 0) {
	iy = (-(*n) + 1) * *incy + 1;
    }
    i__1 = *n;
    for (i = 1; i <= *n; ++i) {
	dtemp = DX(ix);
	DX(ix) = DY(iy);
	DY(iy) = dtemp;
	ix += *incx;
	iy += *incy;
/* L10: */
    }
    return 0;

/*       code for both increments equal to 1   


         clean-up loop */

L20:
    m = *n % 3;
    if (m == 0) {
	goto L40;
    }
    i__1 = m;
    for (i = 1; i <= m; ++i) {
	dtemp = DX(i);
	DX(i) = DY(i);
	DY(i) = dtemp;
/* L30: */
    }
    if (*n < 3) {
	return 0;
    }
L40:
    mp1 = m + 1;
    i__1 = *n;
    for (i = mp1; i <= *n; i += 3) {
	dtemp = DX(i);
	DX(i) = DY(i);
	DY(i) = dtemp;
	dtemp = DX(i + 1);
	DX(i + 1) = DY(i + 1);
	DY(i + 1) = dtemp;
	dtemp = DX(i + 2);
	DX(i + 2) = DY(i + 2);
	DY(i + 2) = dtemp;
/* L50: */
    }
    return 0;
} /* dswap_ */
Exemple #25
0
doublereal NL_FORTRAN_WRAP(ddot)(integer *n, doublereal *dx, integer *incx, doublereal *dy, 
	integer *incy)
{

    /* System generated locals */
    integer i__1;
    doublereal ret_val;

    /* Local variables */
    static integer i, m;
    static doublereal dtemp;
    static integer ix, iy, mp1;


/*     forms the dot product of two vectors.   
       uses unrolled loops for increments equal to one.   
       jack dongarra, linpack, 3/11/78.   
       modified 12/3/93, array(1) declarations changed to array(*)   


    
   Parameter adjustments   
       Function Body */
#define DY(I) dy[(I)-1]
#define DX(I) dx[(I)-1]

    ret_val = 0.;
    dtemp = 0.;
    if (*n <= 0) {
	return ret_val;
    }
    if (*incx == 1 && *incy == 1) {
	goto L20;
    }

/*        code for unequal increments or equal increments   
            not equal to 1 */

    ix = 1;
    iy = 1;
    if (*incx < 0) {
	ix = (-(*n) + 1) * *incx + 1;
    }
    if (*incy < 0) {
	iy = (-(*n) + 1) * *incy + 1;
    }
    i__1 = *n;
    for (i = 1; i <= *n; ++i) {
	dtemp += DX(ix) * DY(iy);
	ix += *incx;
	iy += *incy;
/* L10: */
    }
    ret_val = dtemp;
    return ret_val;

/*        code for both increments equal to 1   


          clean-up loop */

L20:
    m = *n % 5;
    if (m == 0) {
	goto L40;
    }
    i__1 = m;
    for (i = 1; i <= m; ++i) {
	dtemp += DX(i) * DY(i);
/* L30: */
    }
    if (*n < 5) {
	goto L60;
    }
L40:
    mp1 = m + 1;
    i__1 = *n;
    for (i = mp1; i <= *n; i += 5) {
	dtemp = dtemp + DX(i) * DY(i) + DX(i + 1) * DY(i + 1) + DX(i + 2) * 
		DY(i + 2) + DX(i + 3) * DY(i + 3) + DX(i + 4) * DY(i + 4);
/* L50: */
    }
L60:
    ret_val = dtemp;
    return ret_val;
} /* ddot_ */
Exemple #26
0
/* Subroutine */ int daxpy_(integer *n, doublereal *da, doublereal *dx, 
	integer *incx, doublereal *dy, integer *incy)
{


    /* System generated locals */
    integer i__1;

    /* Local variables */
    static integer i, m, ix, iy, mp1;


/*     constant times a vector plus a vector.   
       uses unrolled loops for increments equal to one.   
       jack dongarra, linpack, 3/11/78.   
       modified 12/3/93, array(1) declarations changed to array(*)   


    
   Parameter adjustments   
       Function Body */
#define DY(I) dy[(I)-1]
#define DX(I) dx[(I)-1]


    if (*n <= 0) {
	return 0;
    }
    if (*da == 0.) {
	return 0;
    }
    if (*incx == 1 && *incy == 1) {
	goto L20;
    }

/*        code for unequal increments or equal increments   
            not equal to 1 */

    ix = 1;
    iy = 1;
    if (*incx < 0) {
	ix = (-(*n) + 1) * *incx + 1;
    }
    if (*incy < 0) {
	iy = (-(*n) + 1) * *incy + 1;
    }
    i__1 = *n;
    for (i = 1; i <= *n; ++i) {
	DY(iy) += *da * DX(ix);
	ix += *incx;
	iy += *incy;
/* L10: */
    }
    return 0;

/*        code for both increments equal to 1   


          clean-up loop */

L20:
    m = *n % 4;
    if (m == 0) {
	goto L40;
    }
    i__1 = m;
    for (i = 1; i <= m; ++i) {
	DY(i) += *da * DX(i);
/* L30: */
    }
    if (*n < 4) {
	return 0;
    }
L40:
    mp1 = m + 1;
    i__1 = *n;
    for (i = mp1; i <= *n; i += 4) {
	DY(i) += *da * DX(i);
	DY(i + 1) += *da * DX(i + 1);
	DY(i + 2) += *da * DX(i + 2);
	DY(i + 3) += *da * DX(i + 3);
/* L50: */
    }
    return 0;
} /* daxpy_ */
Exemple #27
0
/* Subroutine */ int drot_(integer *n, doublereal *dx, integer *incx, 
	doublereal *dy, integer *incy, doublereal *c, doublereal *s)
{


    /* System generated locals */
    integer i__1;

    /* Local variables */
    static integer i;
    static doublereal dtemp;
    static integer ix, iy;


/*     applies a plane rotation.   
       jack dongarra, linpack, 3/11/78.   
       modified 12/3/93, array(1) declarations changed to array(*)   


    
   Parameter adjustments   
       Function Body */
#define DY(I) dy[(I)-1]
#define DX(I) dx[(I)-1]


    if (*n <= 0) {
	return 0;
    }
    if (*incx == 1 && *incy == 1) {
	goto L20;
    }

/*       code for unequal increments or equal increments not equal   
           to 1 */

    ix = 1;
    iy = 1;
    if (*incx < 0) {
	ix = (-(*n) + 1) * *incx + 1;
    }
    if (*incy < 0) {
	iy = (-(*n) + 1) * *incy + 1;
    }
    i__1 = *n;
    for (i = 1; i <= *n; ++i) {
	dtemp = *c * DX(ix) + *s * DY(iy);
	DY(iy) = *c * DY(iy) - *s * DX(ix);
	DX(ix) = dtemp;
	ix += *incx;
	iy += *incy;
/* L10: */
    }
    return 0;

/*       code for both increments equal to 1 */

L20:
    i__1 = *n;
    for (i = 1; i <= *n; ++i) {
	dtemp = *c * DX(i) + *s * DY(i);
	DY(i) = *c * DY(i) - *s * DX(i);
	DX(i) = dtemp;
/* L30: */
    }
    return 0;
} /* drot_ */