示例#1
0
QString formatCM_UppercaseCoinNameURI(const SendCoinsRecipient &info)
{
    QString ret = QString("CM_LowercaseCoinName:%1").arg(info.address);
    int paramCount = 0;

    if (info.amount)
    {
        ret += QString("?amount=%1").arg(CM_UppercaseCoinNameUnits::format(CM_UppercaseCoinNameUnits::CM_AllCapsCoinCode, info.amount));
        paramCount++;
    }

    if (!info.label.isEmpty())
    {
        QString lbl(QUrl::toPercentEncoding(info.label));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if (!info.message.isEmpty())
    {
        QString msg(QUrl::toPercentEncoding(info.message));;
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    return ret;
}
示例#2
0
void writecode_vtables(){
	PCLASSE lc = definedClasses;
	while(lc){
		
		int n = count_methods(lc->name);
		writecode("ALLOC ");
		writecodeiln(n);
		
		int written[n];
		int i;
		for(i=0;i<n;i++) written[i]=0;
		
		PCLASSE lc2 = lc;
		while(lc2){
			PMETH lm = lc2->lmethodes;
			while(lm){
				int index = get_meth_index(lc->name,lm->name);
				if(!written[index]){
					writecodeln("DUPN 1");
					writecode("PUSHA ");
					writecodeln(lbl(lm->label));
					writecode("STORE ");
					writecodeiln(index);
					written[index] = 1;
				}
				lm = lm->suiv;
			}
			lc2 = get_class(lc2->name_parent);
		}
		lc = lc->suiv;
	}	
}
示例#3
0
QString formatPatacoinURI(const SendCoinsRecipient &info)
{
    QString ret = QString("patacoin:%1").arg(info.address);
    int paramCount = 0;

    if (info.amount)
    {
        ret += QString("?amount=%1").arg(PatacoinUnits::format(PatacoinUnits::PTC, info.amount));
        paramCount++;
    }

    if (!info.label.isEmpty())
    {
        QString lbl(QUrl::toPercentEncoding(info.label));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if (!info.message.isEmpty())
    {
        QString msg(QUrl::toPercentEncoding(info.message));;
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    return ret;
}
示例#4
0
QString formatBitcoinURI(const SendCoinsRecipient &info)
{
    QString ret = QString("envycoin:%1").arg(info.address);
    int paramCount = 0;

    if (info.amount)
    {
        QLocale localeC(QLocale::c());
        localeC.setNumberOptions(QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator);
        ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::ENVY, info.amount, false, true, localeC));
        paramCount++;
    }

    if (!info.label.isEmpty())
    {
        QString lbl(QUrl::toPercentEncoding(info.label));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if (!info.message.isEmpty())
    {
        QString msg(QUrl::toPercentEncoding(info.message));;
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    return ret;
}
示例#5
0
QString QRCodeDialog::getURI()
{
    QString ret = QString("BitShekel:%1").arg(address);

    int paramCount = 0;
    if(ui->chkReq->isChecked() && ui->lnReqAmount->text().isEmpty() == false) {
        bool ok= false;
        double amount = ui->lnReqAmount->text().toDouble(&ok);
        if(ok) {
            ret += QString("?amount=%1X8").arg(ui->lnReqAmount->text());
            paramCount++;
        }
    }

    if(ui->lnLabel->text().isEmpty() == false) {
        QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text()));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if(ui->lnMessage->text().isEmpty() == false) {
        QString msg(QUrl::toPercentEncoding(ui->lnMessage->text()));
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    return ret;
}
示例#6
0
QString QRCodeDialog::getURI()
{
    QString ret = QString(BRAND_lower ":%1").arg(address);
    int paramCount = 0;
    if (ui->chkReqPayment->isChecked() && !ui->lnReqAmount->text().isEmpty())
    {
        bool ok = false;
        ui->lnReqAmount->text().toDouble(&ok);
        if (ok)
        {
            ret += QString("?amount=%1").arg(ui->lnReqAmount->text());
            paramCount++;
        }
    }

    if (!ui->lnLabel->text().isEmpty())
    {
        QString lbl(QUrl::toPercentEncoding(ui->lnLabel->text()));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if (!ui->lnMessage->text().isEmpty())
    {
        QString msg(QUrl::toPercentEncoding(ui->lnMessage->text()));
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    // limit URI length to 255 chars, to prevent a DoS against the QR-Code dialog
    if (ret.length() < 256)
        return ret;
    else
        return QString("");
    }
示例#7
0
QString formatBitcoinURI(const SendCoinsRecipient &info)
{
    QString ret = QString(URI_SCHEME ":%1").arg(info.address);
    int paramCount = 0;

    if (info.amount)
    {
        ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, info.amount, false, BitcoinUnits::separatorNever));
        paramCount++;
    }

    if (!info.label.isEmpty())
    {
        QString lbl(QUrl::toPercentEncoding(info.label));
        ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
        paramCount++;
    }

    if (!info.message.isEmpty())
    {
        QString msg(QUrl::toPercentEncoding(info.message));
        ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
        paramCount++;
    }

    return ret;
}
示例#8
0
int main(int argc, char **argv)
{
  Iup::Open(argc, argv);

  Iup::Frame frame(Iup::List().SetAttributes("DROPDOWN=YES, 1=Test, 2=XXX, VALUE=1"));
  frame.SetAttribute("TITLE", "List");

  Iup::Text text;

  text.SetAttributes("EXPAND = YES, VALUE = \"Enter your text here\"");
  
  /* Creates a label */
  Iup::Label lbl("This element is a label");

  /* Creatas a button */
  Iup::Button btn("This button does nothing");

  /* Creates handles for manipulating the zbox VALUE */
  Iup::SetHandle("frame", frame);
  Iup::SetHandle("text", text);
  Iup::SetHandle("lbl", lbl);
  Iup::SetHandle("btn", btn);
	
  /* Creates zbox with four elements */
  Iup::Zbox zbox(frame, text, lbl, btn);

  /* Sets zbox alignment */
  zbox.SetAttribute("ALIGNMENT", "ACENTER");
  zbox.SetAttribute("VALUE", "text");
  zbox.SetAttribute("NAME", "ZBOX");

  Iup::List list;
  Iup::Hbox hbox(list);

    /* Creates frame */
  Iup::Frame frm(hbox);

  /* Creates dialog */
  Iup::Dialog dlg
  (
    Iup::Vbox
    (
      frm,
      zbox
    )
  );

  list.SetAttributes("1 = frame, 2 = text, 3 = lbl, 4 = btn, VALUE=2");
  frm.SetAttribute("TITLE", "Select an element");
  dlg.SetAttributes("MARGIN=10x10, GAP=10, TITLE = \"IupZbox Example\"");
  list.SetCallback("ACTION", (Icallback)list_cb);

  dlg.ShowXY(IUP_CENTER, IUP_CENTER);

  Iup::MainLoop();

  Iup::Close();

  return 0;
}
示例#9
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QLabel lbl("Hello Pasha!");

    QLabel.show();
}
示例#10
0
void asm_prgm(void)
{
	mov_literal(GP0, 0x1234);
	call_literal_labeled("times_two_plus_one");
	call_literal_labeled("times_two_plus_one");
	halt();
		
	lbl("times_two_plus_one");
	add(GP0, GP0, GP0);
	mov(GP1, LR);
	call_literal_labeled("plus_one");
	pop(PC);
	
	lbl("plus_one");
	inc(GP0, GP0);
	pop(PC);
}
示例#11
0
void writecode_class( PCLASSE cl ){

	PMETH lm = cl->lmethodes;
	current_class_name = cl->name;
	parent_current_class_name = cl->name_parent;
	

	while(lm){
		PATT m = lm->lparams;
		lm->lparams2 = NULL;
		PATT m2 = lm->lparams2;
		PATT prec = NULL;
		while(m){
			m2 = NEW(1,ATTRIBUT);
			if( prec == NULL ) lm->lparams2 = m2;
			if( prec != NULL ) prec->suiv = m2;
  			memcpy(m2,m,sizeof(ATTRIBUT));
			m2->suiv = NULL;
			prec = m2;
			m2 = m2->suiv;
			m = m->suiv;
		}
		
		 m = lm->lparams2;
		while(m){
			m = m->suiv;
		}

		 int label = newlbl();
		 writecode(lbl(label));
		 writecodeln(":NOP");
		 current_method = lm;

		  if(cl->lattributs){
		  			AttributsEnvironnement = NEW(1,ATTRIBUT);
		  			memcpy(AttributsEnvironnement,cl->lattributs,sizeof(ATTRIBUT));
		  	}else AttributsEnvironnement = NULL;		
		
		PATT local_fin_env = enrichissement_att_environnement(cl->name_parent,lm->lparams);
	    writecode_exp(lm->expression, local_fin_env );
		desenrichissement_att_environnement(local_fin_env);

		
	    lm->label = label;
	    writecode("STOREL -");
	    int c = count_params(lm);	
	    writecodeiln(2+c);	
	    writecodeln("RETURN");
	    lm = lm->suiv;	
	}
	
	current_class_name = NULL;
	parent_current_class_name = NULL;
}
示例#12
0
void VolumeSlider::showEvent(QShowEvent *ev)
{
    if (!shown) {
        shown=true;
        QLabel lbl(parentWidget());
        lbl.ensurePolished();
        QColor col=clampColor(lbl.palette().text().color());

        if (col!=textCol) {
            textCol=col;
            generatePixmaps();
        }
    }
    QSlider::showEvent(ev);
}
示例#13
0
//---------------------------------------------------------------------------------------------------------------------------------------------------
void TerminalTWT::CreateUI()
{
    XMLFile *uiStyle = gCache->GetResource<XMLFile>("UI/DefaultStyle.xml");
    gUIRoot->SetDefaultStyle(uiStyle);

    SharedPtr<Cursor> cursor(new Cursor(context_));
    cursor->SetStyleAuto(uiStyle);
    gUI->SetCursor(cursor);
    cursor->SetPosition(gGraphics->GetWidth() / 2, gGraphics->GetHeight() / 2);

    gInput->SetMouseVisible(true);

    ///
    int width = engineParameters_["WindowWidth"].GetInt();
    int height = engineParameters_["WindowHeight"].GetInt();

    ///
    label = new Text(context_);
    label->SetFont(gCache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 50);
    label->SetColor(Color::YELLOW);
    label->SetText(L"Танкист МК");
    label->SetPosition((width - label->GetWidth()) / 2, 10);
    gUIRoot->AddChild(label);

    ///
    progressBar = new ProgressBar(context_);
    progressBar->SetPosition((width - progressBar->GetWidth()) / 2, height - 50);

    ///
    textVerifyUpdate = new Text(context_);
    textVerifyUpdate->SetFont(gCache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 13);
    textVerifyUpdate->SetColor(Color::GREEN);
    textVerifyUpdate->SetText(L"Проверяю наличие обновлений...");
    textVerifyUpdate->SetPosition((width - textVerifyUpdate->GetWidth()) / 2, height - 100);

    ///
    buttonPlay = new Button(context_);
    buttonPlay->SetStyleAuto();
    SharedPtr<Text> lbl(new Text(context_));
    lbl->SetFont(gCache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
    lbl->SetAlignment(Urho3D::HA_CENTER, Urho3D::VA_CENTER);
    lbl->SetText(L"ИГРАТЬ");
    buttonPlay->AddChild(lbl);
    buttonPlay->SetFixedSize(100, 30);
    buttonPlay->SetPosition((width - buttonPlay->GetWidth()) / 2, height - 100);
}
示例#14
0
int main(int argc, char** argv) {
	QApplication app(argc, argv);
	
	QLineEdit txt("QLineEdit");
	txt.installEventFilter(new MouseFilter(&txt));
	txt.show();

	QLabel lbl("QLabel");
	lbl.installEventFilter(new MouseFilter(&lbl));
	lbl.show();

	QPushButton pcmd("QPushButton");
	pcmd.installEventFilter(new MouseFilter(&pcmd));
	pcmd.show();

	app.exec();
}
示例#15
0
void MakeSpinPlots::PlotSignalFits(TString tag, TString mcName,TString cosThetaBin){
  TCanvas cv;
  TString cat=tag;
  if(cosThetaBin!="") tag = tag+"_"+cosThetaBin;

  float mean = ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getVal();
  RooPlot *frame = ws->var("mass")->frame(105,140,70);//mean-10,mean+10,40);
  RooAbsData *d = ws->data(mcName+"_Combined")->reduce(TString("evtcat==evtcat::")+cat);
  if(cosThetaBin!=""){
    TObjArray *arr = cosThetaBin.Tokenize("_");
    float low  = atof(arr->At(1)->GetName());
    float high = atof(arr->At(2)->GetName());
    d = d->reduce( Form("cosT < %0.2f && cosT >= %0.2f",high,low) );
    delete arr;
  }

  d->plotOn(frame);
  RooFitResult *res = (RooFitResult*)ws->obj(Form("%s_FIT_%s_fitResult",mcName.Data(),tag.Data()));
  RooAbsPdf * pdf = ws->pdf(Form("%s_FIT_%s",mcName.Data(),tag.Data())); //signal model
  std::cout << pdf << "\t" << res << std::endl;
  pdf->plotOn(frame,RooFit::FillColor(kGreen),RooFit::VisualizeError(*res,2.0));
  pdf->plotOn(frame,RooFit::FillColor(kYellow),RooFit::VisualizeError(*res,1.0));
  pdf->plotOn(frame,RooFit::LineColor(kRed));
  d->plotOn(frame); //data
  
  tPair lbl(mcName,tag);

  TLatex *prelim = new TLatex(0.18,0.9,"CMS Preliminary Simulation");
  TLatex *sigL  = new TLatex(0.18,0.6,Form("#sigma_{eff} = %0.2f GeV",fitSigEff[lbl].first,fitSigEff[lbl].second));
  prelim->SetNDC();
  sigL->SetNDC();
  prelim->SetTextSize(0.05);
  sigL->SetTextSize(0.05);
  
  frame->addObject(prelim);
  frame->addObject(sigL);
  frame->Draw();
  cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.png",mcName.Data(),outputTag.Data(),tag.Data()));
  cv.SaveAs(basePath+Form("/signalModels/C/sig_%s_%s_%s.C",mcName.Data(),outputTag.Data(),tag.Data()));
  cv.SaveAs(basePath+Form("/signalModels/sig_%s_%s_%s.pdf",mcName.Data(),outputTag.Data(),tag.Data()));

}
void GL_APIENTRY ObjectPtrLabelKHR(const void *ptr, GLsizei length, const GLchar *label)
{
    EVENT("(const void *ptr = 0x%0.8p, GLsizei length = %d, const GLchar *label = 0x%0.8p)", ptr,
          length, label);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        if (!ValidateObjectPtrLabelKHR(context, ptr, length, label))
        {
            return;
        }

        LabeledObject *object = context->getLabeledObjectFromPtr(ptr);
        ASSERT(object != nullptr);

        std::string lbl(label, (length > 0) ? static_cast<size_t>(length) : strlen(label));
        object->setLabel(lbl);
    }
}
示例#17
0
int Program::FindLabelOffset(const char* label)
{
    std::string lbl(label);

    if (m_LabelMap.count(lbl))
    {
        return m_LabelMap.at(lbl) - (m_InstructionList.size());
    }

    // Label not added yet. Check if it's in the unknown label map.
    if (m_UnknownLabels.count(lbl))
    {
        return m_UnknownLabels.at(lbl);
    }

    // Completely new label. Add it to the unknown map.
    m_UnknownLabels.insert(_LabelMap::value_type(lbl, m_NextUnknownLabelID++));

    return m_NextUnknownLabelID - 1;
}
示例#18
0
文件: plot.hpp 项目: dblalock/dig
static void plot_array(data_t* data, length_t length, int nlevels=8,
                       double yBin=0, string title=string(), char marker='x') {
    // compute vertical bin size and number of bins
    auto minVal = min(data, length);
    auto maxVal = max(data, length);
    auto range = maxVal - minVal;

    if (yBin <= 0) {
        yBin = (maxVal - minVal) / nlevels;
    }
    nlevels = static_cast<int>(range / yBin) + 2;

    // create string in which to write plot
    int nrows = nlevels;
    int ncols = static_cast<int>(length);
    int stringLen = nrows * ncols;
    string s(stringLen, ' '); // whitespace

    // compute offset so that y axis labels are multiples of yBin
    double offset = yBin * static_cast<int>(floor(minVal / yBin));

    // populate plot body
    for (int i = 0; i < length; i++) {
        int level = static_cast<int>(floor((data[i] - offset) / yBin));
        level = max(level, 0);
        int idx = level * ncols + i;
        s[idx] = marker;
    }

    _print_title(title, ncols);

    // print the plot and y axis labels
    char axLabel[32];
    // iterate thru rows of mat, from high to low values
    for (int i = nlevels - 1; i >= 0; i--) {
        double lb = i * yBin + offset;
        snprintf(axLabel, 31, "%6.2f", lb);
        string lbl(axLabel);
        std::cout << lbl << " " << s.substr(i * ncols, ncols) << "\n";
    }
}
示例#19
0
void Ui::ToolBar::init() {
    GtkStyle::applyTheme(this);
    ensurePolished();
    QLabel lbl(this);
    lbl.ensurePolished();
    QColor col=Utils::clampColor(lbl.palette().windowText().color());

    playIcon=Core::MonoIcon::icon(Core::MonoIcon::ex_mediaplay, col);
    pauseIcon=Core::MonoIcon::icon(Core::MonoIcon::ex_mediapause, col);
    prevAction=ActionCollection::get()->createAction("previous", tr("Previous Track"), Core::MonoIcon::icon(Core::MonoIcon::ex_mediaprevious, col));
    playPauseAction=ActionCollection::get()->createAction("play", tr("Play/Pause"), playIcon);
    nextAction=ActionCollection::get()->createAction("next", tr("Next Track"), Core::MonoIcon::icon(Core::MonoIcon::ex_medianext, col));
    showLyricsAction=ActionCollection::get()->createAction("lyrics", tr("Show Lyrics"), Core::MonoIcon::icon(Core::MonoIcon::commento, col));
    showLyricsAction->setCheckable(true);

    playPauseAction->setShortcut(Qt::ControlModifier+Qt::Key_P);
    prevAction->setShortcut(Qt::ControlModifier+Qt::Key_Left);
    nextAction->setShortcut(Qt::ControlModifier+Qt::Key_Right);

    nowPlaying=new NowPlayingWidget(this);
    volumeSlider=new VolumeSlider(this);
    volumeSlider->setColor(col);

    addSpacer();
    QWidget *controls=new QWidget(this);
    QHBoxLayout *controlsLayout=new QHBoxLayout(controls);
    QList<Action *> controlActs=QList<Action *>() << prevAction << playPauseAction << nextAction;
    int otherIconSize=Utils::scaleForDpi(28);
    int playPauseIconSize=Utils::scaleForDpi(32);
    int pad=Utils::scaleForDpi(8);
    foreach (Action *act, controlActs) {
        int iconSize=act==playPauseAction ? playPauseIconSize : otherIconSize;
        ToolButton *btn=new ToolButton(controls);
        btn->setDefaultAction(act);
        btn->setFixedSize(QSize(iconSize+pad, iconSize+pad));
        btn->setIconSize(QSize(iconSize, iconSize));
        btn->setAutoRaise(true);
        btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
        controlsLayout->addWidget(btn);
    }
示例#20
0
void MakeSpinPlots::DrawSpinSubBackground(TString tag, TString mcName,bool signal){
  bool drawSM = (smName!="" && smName!=mcName);

  TCanvas cv;
  double thisN  = ws->data(mcName+"_Combined")->reduce(TString("evtcat==evtcat::")+tag)->sumEntries();
  float norm = thisN; //607*lumi/12.*thisN/(totEB+totEE);
  tPair lbl(mcName,tag);


  if(signal) norm = nSignal[lbl].first;   //((RooFormulaVar*)ws->obj(Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data())) )->getVal();
  RooPlot *frame = ws->var("cosT")->frame(0,1,10);

  RooDataSet* tmp = (RooDataSet*)ws->data("Data_Combined")->reduce(TString("((mass>115 && mass<120) || (mass>130 && mass<135)) && evtcat==evtcat::")+tag);
  tmp->plotOn(frame,RooFit::Rescale(norm/tmp->sumEntries()));

  ws->pdf(Form("%s_FIT_%s_cosTpdf",mcName.Data(),tag.Data()))->plotOn(frame,RooFit::LineColor(kGreen),RooFit::Normalization(norm/tmp->sumEntries()));
  if(drawSM) ws->pdf(Form("%s_FIT_%s_cosTpdf",smName.Data(),tag.Data()))->plotOn(frame,RooFit::LineColor(kRed),RooFit::Normalization(norm/tmp->sumEntries()));
  if(signal){
    RooDataHist *h = (RooDataHist*)ws->data( Form("Data_%s_%s_bkgSub_cosT",mcName.Data(),tag.Data()) );
    h->plotOn(frame,RooFit::MarkerStyle(4));
    std::cout << "Nsig: " << h->sumEntries() << std::endl;
  }
  
  frame->SetMaximum(frame->GetMaximum()*(signal?3.:1.2)*norm/tmp->sumEntries());
  frame->SetMinimum(-1*frame->GetMaximum());
  TLegend l(0.6,0.2,0.95,0.45);
  l.SetFillColor(0);
  l.SetBorderSize(0);
  l.SetHeader(tag);
  l.AddEntry(frame->getObject(0),"Data m#in [115,120]#cup[130,135]","p");
  l.AddEntry(frame->getObject(1),mcName,"l");
  if(drawSM) l.AddEntry(frame->getObject(2),"SM Higgs","l");
  if(signal) l.AddEntry(frame->getObject(2+drawSM),"bkg-subtracted Data","p");
  
  frame->Draw();
  l.Draw("SAME");
  cv.SaveAs( basePath+Form("/cosThetaPlots/CosThetaDist_SimpleSub_%s%s_%s_%s.png",outputTag.Data(),(signal ? "":"_BLIND"),mcName.Data(),tag.Data()) );
  cv.SaveAs( basePath+Form("/cosThetaPlots/C/CosThetaDist_SimpleSub_%s%s_%s_%s.C",outputTag.Data(),(signal ? "":"_BLIND"),mcName.Data(),tag.Data()) );
  cv.SaveAs( basePath+Form("/cosThetaPlots/CosThetaDist_SimpleSub_%s%s_%s_%s.pdf",outputTag.Data(),(signal ? "":"_BLIND"),mcName.Data(),tag.Data()) );
}
void GL_APIENTRY ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
{
    EVENT(
        "(GLenum identifier = 0x%X, GLuint name = %u, GLsizei length = %d, const GLchar *label = "
        "0x%0.8p)",
        identifier, name, length, label);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        if (!ValidateObjectLabelKHR(context, identifier, name, length, label))
        {
            return;
        }

        LabeledObject *object = context->getLabeledObject(identifier, name);
        ASSERT(object != nullptr);

        std::string lbl(label, (length > 0) ? static_cast<size_t>(length) : strlen(label));
        object->setLabel(lbl);
    }
}
示例#22
0
void MakeSpinPlots::getFitValues(TString tag,TString mcName){
  std::cout << tag << std::endl;
  //Data_RSG125_FULLFIT_Nsig
  double sig  = ws->var(Form("Data_%s_FULLFIT_Nsig",mcName.Data()))->getVal();
  double sige = ws->var(Form("Data_%s_FULLFIT_Nsig",mcName.Data()))->getError();
  double fsig = ws->var(Form("Data_%s_FULLFIT_%s_fsig",mcName.Data(),tag.Data()))->getVal();
  std::cout << sig*fsig << " +- " << sige*fsig <<std::endl;
  //double bkg  = ws->var(Form("Data_%s_FULLFIT_Nbkg",mcName.Data()))->getVal();
  //double bkge = ws->var(Form("Data_%s_FULLFIT_Nbkg",mcName.Data()))->getError();
  double bkg = ws->var(Form("Data_%s_FULLFIT_%s_Nbkg",mcName.Data(),tag.Data()))->getVal();
  double bkge = ws->var(Form("Data_%s_FULLFIT_%s_Nbkg",mcName.Data(),tag.Data()))->getError();
  //std::cout << bkg*fbkg << " +- " << bkge*fbkg <<std::endl;
  double mean = ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getVal();
  double meane= ws->var(Form("%s_FIT_%s_mean",mcName.Data(),tag.Data()))->getError();

  std::cout << mean << " +- " << meane <<std::endl;  

  double sigEff = ws->var(Form("%s_FIT_%s_sigmaEff",mcName.Data(),tag.Data()))->getVal();
  double sigEffE = 0;
  std::cout << sigEff << " +- " << sigEffE <<std::endl;  
  //Data_BKGFIT_EB_0_bkgModel
  RooAbsPdf * bkgPdf = ws->pdf(Form("Data_BKGFIT_%s_bkgModel",tag.Data()));
  std::cout << bkgPdf <<std::endl;
  RooRealVar range("range","",mean-sigEff,mean+sigEff);
  RooRealVar all("all","",ws->var("mass")->getMin(),ws->var("mass")->getMax());
  double BkgInRange  = bkgPdf->createIntegral(range)->getVal()/bkgPdf->createIntegral(all)->getVal()*bkg;
  double BkgInRangeE = bkgPdf->createIntegral(range)->getVal()/bkgPdf->createIntegral(all)->getVal()*bkge;
  

  tPair lbl(mcName,tag);

  nSignal[lbl]      = dPair(sig*fsig,sige*fsig);
  nBackground[lbl]  = dPair(bkg,bkge);
  fitMean[lbl]      = dPair(mean,meane);
  fitSigEff[lbl]    = dPair(sigEff,sigEffE);
  fitBkg1Sigma[lbl] = dPair(BkgInRange,BkgInRangeE);

}
示例#23
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QLabel lbl("0");

    Counter counter;

    QSignalMapper* mapper = new QSignalMapper();
    QObject::connect(mapper, SIGNAL(mapped(const QString&)), &counter, SLOT(slotInc(const QString&)));

    QPushButton* but1 = new QPushButton("Button1");
    QObject::connect(but1, SIGNAL(clicked()), mapper, SLOT(map()));
    mapper->setMapping(but1, "Button1 Action");

    QPushButton* but2 = new QPushButton("Button2");
    QObject::connect(but2, SIGNAL(clicked()), mapper, SLOT(map()));
    mapper->setMapping(but2, "Button2 Action");

    QPushButton quitButton("Quit");

    QVBoxLayout layout;
    layout.addWidget(&lbl);
    layout.addWidget(but1);
    layout.addWidget(but2);
    layout.addWidget(&quitButton);

    QWidget window;
    window.setLayout(&layout);
    window.show();

    QObject::connect(&counter, SIGNAL(counterChanged(int)), &lbl, SLOT(setNum(int)));
    QObject::connect(&counter, SIGNAL(goodbye()), &app, SLOT(quit()));
    QObject::connect(&quitButton, SIGNAL(clicked(bool)), &app, SLOT(quit()));

    return app.exec();
}
示例#24
0
void writecode_exp(PARBRE arbre, PATT super_fin_env) {
	char * typeg = NULL;
	char * typed = NULL;
	PATT local_fin_env = NULL;
	char * id = arbre->gauche.S;

	if(arbre)
	switch (arbre->op)
	{

		case New : {
				writecodeln("--NEW");
				
				int c=0;
				writecode("ALLOC ");
				PCLASSE lc = get_class(arbre->gauche.A->gauche.S);
				while(lc){
					PATT att = lc->lattributs;
					while(att){
						c++;
						att = att->suiv;
					}
					lc = get_class(lc->name_parent);
				}
				writecodeiln(1+c);
				writecodeln("DUPN 1"); 
				writecode("PUSHG ");
				writecodeiln( (get_class(arbre->gauche.A->gauche.S))->index );
				writecodeln("STORE 0"); writecodeln("--NEWEND");
				}
				break;
				
		case Bloc : { writecodeln("--BLOC");
				local_fin_env = enrichissement_att_environnement(NULL,arbre->droit.lattributs);

				//Allouer les variables
				PATT att = arbre->droit.lattributs;
				int c = 0;
				while(att){
					c++;
					att = att->suiv;
				}
				writecode("PUSHN ");
				writecodeiln(c);
				writecode_exp( arbre->gauche.A, local_fin_env );
				int i;
				for(i=0;i<c;i++){
					writecodeln("SWAP");
					writecodeln("POPN 1");
				}
				desenrichissement_att_environnement(local_fin_env);
				writecodeln("--BLOCEND");
				} 
				break;

		case Self :
			writecodeln("PUSHL -1");
			//return current_class_name;
			break;
				
		case Id : {
			int index = get_var_index( super_fin_env, id );
			if( current_method == NULL ){ //Main
				writecode("PUSHL ");
				writecodeiln(index + count_classes(definedClasses));
			}else{ 
				if( index > -1 ){
					writecode("PUSHL ");
					writecodeiln(index);				
				}else{
					int indexparam = index_param( current_method , id );
					int n = count_params( current_method );
					if( indexparam ){
						writecode("PUSHL -");
						writecodeiln( n + 2 - indexparam );
					}else{
						int indexatt = index_att( current_class_name , id );
						if( indexatt >=0 ){
							writecodeln("PUSHL -1");
							writecode("LOAD ");
							writecodeiln(indexatt + 1);
						}
					}
				
				}
				
			}
			
			}
			break;
        
		case Fct :{ writecodeln("--APPEL");
			writecodeln("PUSHN 1"); //Pour le retour de la fonction
			
			//Met self au dessus de la pile
			writecodeln("PUSHL -1");
			
			PFONC f = arbre->gauche.F;
			PARG arg = f->largs;
			int c = 0;
			while(arg){
				writecode_exp( arg->expression, super_fin_env );
				writecodeln("SWAP");
				c++;
				arg = arg->suiv;
			}

			writecodeln("DUPN 1");
			writecodeln("LOAD 0");	
			writecode("LOAD ");
			writecodeiln( (get_meth_index( check_type(arbre->gauche.A , NULL, super_fin_env), f->name) ) );
			writecodeln("CALL");
			writecode("POPN ");
			writecodeiln( c + 1 ); //Dépile le destinataire et les paramètres
			writecodeln("--APPELEND");	
		} break;
		
		case Aff: { writecodeln("--AFF");
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("DUPN 1");
			if( arbre->gauche.A->op == '.' ){ //C'est le champ d'un objet
				writecode_exp(arbre->gauche.A->gauche.A, super_fin_env);
				int indexatt = index_att( check_type( arbre->gauche.A->gauche.A, NULL, super_fin_env ) ,
								arbre->gauche.A->droit.S );
				writecodeln("SWAP");
				writecode("STORE ");	
				writecodeiln(indexatt + 2);
			}else { //C'est un id
				
				int index = get_var_index( super_fin_env, arbre->gauche.A->gauche.S );
				if( current_method == NULL ){ //Main
					writecode("STOREL ");
					writecodeiln(index + count_classes(definedClasses));
				}else{
					if( index > -1 ){
						writecode("STOREL ");
						writecodeiln(index);				
					}else{
						int indexparam = index_param( current_method , arbre->gauche.A->gauche.S );
						if( indexparam ){
							int n = count_params( current_method );
							writecode("STOREL -");
							writecodeiln( n + 2 - indexparam );					
						}else{ 
							int indexatt = index_att( current_class_name , arbre->gauche.A->gauche.S );
							if( indexatt >= 0 ){
								writecodeln("PUSHL -1");
								writecodeln("SWAP");
								writecode("STORE ");
								writecodeiln(indexatt + 1);
							}
						}

					}

				}				
			}writecodeln("--AFFEND");
		}

		break;
			
		case ';':
		
			if( arbre->droit.A != NULL ){
				writecode_exp( arbre->gauche.A, super_fin_env );
				writecodeln("POPN 1");
				writecode_exp( arbre->droit.A, super_fin_env );
			}
			break;
			
		case '.' : {
			
			if( arbre->droit.A->op == Id ){	
				writecode_exp( arbre->gauche.A, super_fin_env );
				int index = index_att( check_type( arbre->gauche.A, NULL, super_fin_env ) , arbre->droit.A->gauche.S );
				writecode("LOAD ");
				writecodeiln(index + 2);
				
			}else if( arbre->droit.A->op == Fct ){
				int imprimer = 0;
				PFONC f = arbre->droit.A->gauche.F;
				if( strcmp(f->name,"imprimer")==0 ){
					if( strcmp(check_type( arbre->gauche.A, NULL, super_fin_env ),"Entier")==0 ){
						writecode_exp( arbre->gauche.A, super_fin_env );
						writecodeln("DUPN 1");
						writecodeln("WRITEI");
						imprimer=1;
					}
					if( strcmp(check_type( arbre->gauche.A, NULL, super_fin_env ),"Chaine")==0  ){
						writecode_exp( arbre->gauche.A, super_fin_env );
						writecodeln("DUPN 1");
						writecodeln("WRITES");
						imprimer=1;
					}
				}

				if( !imprimer && arbre->gauche.A->op == Super ){ writecodeln("--APPEL");
						writecodeln("PUSHN 1"); //Pour le retour de la fonction

						PARG arg = f->largs;
						int c = 0;
						while(arg){
							writecode_exp( arg->expression, super_fin_env );
							c++;
							arg = arg->suiv;
						}

						writecodeln("PUSHL -1");
						
						int index = get_class(parent_current_class_name)->index;
						writecode("PUSHG ");
						writecodeiln(index);	
						writecode("LOAD ");
						writecodeiln( (get_meth_index( check_type(arbre->gauche.A, NULL ,super_fin_env), f->name) ) );
						writecodeln("CALL");
						writecode("POPN ");
						writecodeiln( c + 1 ); //Dépile le destinataire et les paramètres
						writecodeln("--APPELEND");
				}else if(!imprimer){		
					writecodeln("--APPEL");	
					writecodeln("PUSHN 1"); //Pour le retour de la fonction
					writecode_exp( arbre->gauche.A, super_fin_env );
				
					PFONC f = arbre->droit.A->gauche.F;
					PARG arg = f->largs;
					int c = 0;
					while(arg){
						writecode_exp( arg->expression, super_fin_env );
						writecodeln("SWAP");
						c++;
						arg = arg->suiv;
					}

					writecodeln("DUPN 1");
					writecodeln("LOAD 0");	
					writecode("LOAD ");
					writecodeiln( (get_meth_index( check_type(arbre->gauche.A, NULL, super_fin_env), f->name) ) );
					writecodeln("CALL");
					writecode("POPN ");
					writecodeiln( c + 1 ); //Dépile le destinataire et les paramètres
					writecodeln("--APPELEND");
				}
			}
			}
			break;
			
		case Cste:	
			writecode("PUSHI ");
			writecodeiln(arbre->gauche.E);
			break;
			
		case String:
			writecode("PUSHS ");
			writecodeln(arbre->gauche.S);
			break;
		
 		case '+':
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("ADD");
			break;
		    
		 case '-': 			
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("SUB");
			break;
			
		 case '*':
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("MUL");
			break;
		
		 case '/':					
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("DIV");
			break;

		case ITE :	
			writecode_exp(arbre->gauche.A, super_fin_env);
			int lblelse = newlbl();
			int lblend = newlbl();
			writecode("JZ ");
			writecodeln(lbl(lblelse));
			writecode_exp( arbre->droit.A->gauche.A, super_fin_env );
			writecode("JUMP ");
			writecodeln(lbl(lblend));
			writecode(lbl(lblelse));
			writecodeln(": NOP");
			writecode_exp( arbre->droit.A->droit.A, super_fin_env );
			writecode(lbl(lblend));
			writecodeln(": NOP");
			break;
			
		case LT :	
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("INF");
			break;

		case LE :
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("INFEQ");
			break;

		case GT :
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("SUP");
			break;

		case GE :
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("SUPEQ");
			break;

		case EQ :
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("EQUAL");
			break;

		case NEQ :
			writecode_exp(arbre->gauche.A, super_fin_env);
			writecode_exp(arbre->droit.A, super_fin_env);
			writecodeln("EQUAL");
			writecodeln("NOT");
			break;
	}
}
示例#25
0
QList<photo*>* db::getUnlabeledPhotos(){

	bool a=false;
	QSqlQuery query(database);
	query.prepare("SELECT DISTINCT Iid FROM HasFaces WHERE Pid = 1 ");
	a=query.exec();
	//	QList<int> photoId;
	QList<photo*>* pl = new QList<photo*>();
	while(query.next()){
		int imageId=query.value(0).toInt();
		//		photoId.append(imageId);
		QList<face*>* fl = new QList<face*>();

		QSqlQuery query4(database);
		query4.prepare("SELECT DISTINCT path FROM Images WHERE Iid = :imageId ");
		query4.bindValue(":imageId", imageId);
		bool k4 = query4.exec();
		query4.next();
		QString imagePath(query4.value(0).toString()); 


		QSqlQuery query2(database);
		query2.prepare("SELECT DISTINCT Fid,Pid FROM HasFaces WHERE Iid = :imageId ");
		query2.bindValue(":imageId", imageId);
		bool k=query2.exec();
		while(query2.next()){
			int faceId = query2.value(0).toInt(); 
			int personId = query2.value(1).toInt(); 
			QSqlQuery query3(database);
			query3.prepare("SELECT * FROM Faces WHERE Fid = :FId ");
			query3.bindValue(":FId", faceId);
			bool k3=query3.exec();
			//facelist olcak
			while(query3.next()){
				double x=query3.value(1).toDouble();
				double y=query3.value(2).toDouble();
				double width=query3.value(3).toDouble();
				double height=query3.value(4).toDouble();
				double tw=query3.value(5).toDouble(); 
				double th=query3.value(6).toDouble();
				QString featureListStr = query3.value(7).toString();

				QSqlQuery query5(database);
				query5.prepare("SELECT name FROM Person WHERE Pid = :PId ");
				query5.bindValue(":PId", personId);
				bool k5=query5.exec();
				query5.next();
				QString lbl(query5.value(0).toString());

				double* featureList = returnFacialFeatures(featureListStr);

				face* f = new face(faceId,QStringToString(imagePath),x,y,width,height,tw,th,featureList,QStringToString(lbl));
				f->setPhotoID(imageId);
				fl->append(f);
			}
		}
		photo* p = new photo(imagePath,fl);
		p->setID(imageId);
		pl->append(p);
	}


	return pl;
}
示例#26
0
void draw_data_mgg(TString folderName,bool blind=true,float min=103,float max=160)
{
  TFile inputFile(folderName+"/data.root");
  
  const int nCat = 5;
  TString cats[5] = {"HighPt","Hbb","Zbb","HighRes","LowRes"};

  TCanvas cv;

  for(int iCat=0; iCat < nCat; iCat++) {

    RooWorkspace *ws  = (RooWorkspace*)inputFile.Get(cats[iCat]+"_mgg_workspace");
    RooFitResult* res = (RooFitResult*)ws->obj("fitresult_pdf_data");

    RooRealVar * mass = ws->var("mgg");
    mass->setRange("all",min,max);
    mass->setRange("blind",121,130);
    mass->setRange("low",106,121);
    mass->setRange("high",130,160);

    mass->setUnit("GeV");
    mass->SetTitle("m_{#gamma#gamma}");
    
    RooAbsPdf * pdf = ws->pdf("pdf");
    RooPlot *plot = mass->frame(min,max,max-min);
    plot->SetTitle("");
    
    RooAbsData* data = ws->data("data")->reduce(Form("mgg > %f && mgg < %f",min,max));
    double nTot = data->sumEntries();
    if(blind) data = data->reduce("mgg < 121 || mgg>130");
    double nBlind = data->sumEntries();
    double norm = nTot/nBlind; //normalization for the plot
    
    data->plotOn(plot);
    pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::Range("Full"),RooFit::LineWidth(0.1) );
    plot->Print();

    //add the fix error band
    RooCurve* c = plot->getCurve("pdf_Norm[mgg]_Range[Full]_NormRange[Full]");
    const int Nc = c->GetN();
    //TGraphErrors errfix(Nc);
    //TGraphErrors errfix2(Nc);
    TGraphAsymmErrors errfix(Nc);
    TGraphAsymmErrors errfix2(Nc);
    Double_t *x = c->GetX();
    Double_t *y = c->GetY();
    double NtotalFit = ws->var("Nbkg1")->getVal()*ws->var("Nbkg1")->getVal() + ws->var("Nbkg2")->getVal()*ws->var("Nbkg2")->getVal();
    for( int i = 0; i < Nc; i++ )
      {
	errfix.SetPoint(i,x[i],y[i]);
	errfix2.SetPoint(i,x[i],y[i]);
	mass->setVal(x[i]);      
	double shapeErr = pdf->getPropagatedError(*res)*NtotalFit;
	//double totalErr = TMath::Sqrt( shapeErr*shapeErr + y[i] );
	//total normalization error
	double totalErr = TMath::Sqrt( shapeErr*shapeErr + y[i]*y[i]/NtotalFit ); 
	if ( y[i] - totalErr > .0 )
	  {
	    errfix.SetPointError(i, 0, 0, totalErr, totalErr );
	  }
	else
	  {
	    errfix.SetPointError(i, 0, 0, y[i] - 0.01, totalErr );
	  }
	//2sigma
	if ( y[i] -  2.*totalErr > .0 )
	  {
	    errfix2.SetPointError(i, 0, 0, 2.*totalErr,  2.*totalErr );
	  }
	else
	  {
	    errfix2.SetPointError(i, 0, 0, y[i] - 0.01,  2.*totalErr );
	  }
	/*
	std::cout << x[i] << " " << y[i] << " "
		  << " ,pdf get Val: " << pdf->getVal()
		  << " ,pdf get Prop Err: " << pdf->getPropagatedError(*res)*NtotalFit
		  << " stat uncertainty: " << TMath::Sqrt(y[i]) << " Ntot: " << NtotalFit <<  std::endl;
	*/
      }
    errfix.SetFillColor(kYellow);
    errfix2.SetFillColor(kGreen);


    //pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kFALSE));
    //pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kFALSE));
    //pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kTRUE));
    //pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kTRUE));
    plot->addObject(&errfix,"4");
    plot->addObject(&errfix2,"4");
    plot->addObject(&errfix,"4");
    data->plotOn(plot);
    TBox blindBox(121,plot->GetMinimum()-(plot->GetMaximum()-plot->GetMinimum())*0.015,130,plot->GetMaximum());
    blindBox.SetFillColor(kGray);
    if(blind) {
      plot->addObject(&blindBox);
      pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kTRUE));
      pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kTRUE));
    }
    //plot->addObject(&errfix,"4");
    //data->plotOn(plot);

    //pdf->plotOn(plot,RooFit::Normalization( norm ) );
    //pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::Range("Full"),RooFit::LineWidth(1.5) );
    pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::Range("Full"), RooFit::LineWidth(1));
    data->plotOn(plot);
    /*
    pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::Range("all"),RooFit::LineWidth(0.8) );
    //pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kGreen),RooFit::Range("all"), RooFit::VisualizeError(*res,2.0,kFALSE));
    //pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kYellow),RooFit::Range("all"), RooFit::VisualizeError(*res,1.0,kFALSE));
    pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kGreen),RooFit::Range("all"), RooFit::VisualizeError(*res,2.0,kTRUE));
    pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kYellow),RooFit::Range("all"), RooFit::VisualizeError(*res,1.0,kTRUE));
    data->plotOn(plot);
    pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::Range("all"),RooFit::LineWidth(0.8) );
    */
    TLatex lbl0(0.1,0.96,"CMS Preliminary");
    lbl0.SetNDC();
    lbl0.SetTextSize(0.042);
    plot->addObject(&lbl0);
    
    TLatex lbl(0.4,0.96,Form("%s Box",cats[iCat].Data()));
    lbl.SetNDC();
    lbl.SetTextSize(0.042);
    plot->addObject(&lbl);

    TLatex lbl2(0.6,0.96,"#sqrt{s}=8 TeV  L = 19.78 fb^{-1}");
    lbl2.SetNDC();
    lbl2.SetTextSize(0.042);
    plot->addObject(&lbl2);


    int iObj=-1;
    TNamed *obj;
    while( (obj = (TNamed*)plot->getObject(++iObj)) ) {
      obj->SetName(Form("Object_%d",iObj));
    }

    plot->Draw();
    TString tag = (blind ? "_BLIND" : "");
    cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".png");
    cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".pdf");
    cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".C");
      
  }
  
}
示例#27
0
void MakeSpinPlots::DrawIndFit(TString tag, TString mcName){
  TCanvas *cv = new TCanvas(Form("%s_%s",mcName.Data(),tag.Data()));
  
  if(ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) ) == 0) return;

  RooRealVar* mass = ws->var("mass");
  mass->setBins( (mass->getMax() - mass->getMin())/1.5 ); //enfore 1.5GeV bin width
  RooPlot* frame  = mass->frame();

  tPair lbl(mcName,tag);

  double Ns = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
  double Nb = ws->var( Form("Data_%s_INDFIT_%s_Nbkg",mcName.Data(),tag.Data()) )->getVal();

  double Nblind = ws->data("Data_Combined")->reduce("(mass>100 && mass<119) || (mass>135.5 && mass<170)")->sumEntries(TString("evtcat==evtcat::")+tag);
  double Ntot   = ws->data("Data_Combined")->sumEntries(TString("evtcat==evtcat::")+tag);

  RooFitResult* fitres = (RooFitResult*)ws->obj(Form("Data_%s_INDFIT_fitResult",mcName.Data())); 
  std::cout << fitres << std::endl;
    ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame,RooFit::LineColor(kWhite),RooFit::MarkerColor(kWhite));
  //Data_Hgg125_INDFIT_EB_0
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kGreen),RooFit::VisualizeError(*fitres,2.0));
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kYellow),RooFit::VisualizeError(*fitres,1.0));
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::LineColor(kRed));
  std::cout << "1" << std::endl;
  ws->pdf(Form("Data_BKGFIT_%s_bkgModel",tag.Data()))->plotOn(frame, RooFit::Normalization(Nb/(Nb+Ns)),RooFit::LineColor(kRed),RooFit::LineStyle(kDashed));
  std::cout << "2" << std::endl;

  ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame);
  frame->Draw();

  //TLatex *prelim = new TLatex(250,x->GetXmax()-40.,"CMS Preliminary");
  TLatex *prelim = new TLatex(0.12,0.96,"CMS Preliminary");
  TLatex *lum = new TLatex(0.7,0.96,Form("#sqrt{s}=8 TeV  L = %0.1f fb^{-1}",lumi));
  prelim->SetNDC();
  lum->SetNDC();
  prelim->SetTextSize(0.045);
  prelim->SetTextColor(kBlack);
  lum->SetTextSize(0.045);
  lum->SetTextColor(kBlack);

  TLatex *owner = new TLatex(0.6,0.88,"Alex Mott (Nov. 13, 2012)");
  owner->SetNDC();
  owner->SetTextSize(0.045);
  owner->SetTextColor(kBlack);

  TLatex *mu = new TLatex(0.7,0.8,Form("#mu = %0.1f #pm %0.2f", fitMean[lbl].first,fitMean[lbl].second));
  mu->SetNDC();
  mu->SetTextSize(0.045);

  TLatex *sig = new TLatex(0.7,0.72,Form("#sigma_{eff} = %0.1f #pm %0.2f", fitSigEff[lbl].first,fitSigEff[lbl].second));
  sig->SetNDC();
  sig->SetTextSize(0.045);

  float nSig = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
  float nSigErr = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getError();

  TLatex *Nsig = new TLatex(0.7,0.64,Form("N_{sig}= %0.1f #pm %0.1f",nSig,nSigErr));
  Nsig->SetNDC();
  Nsig->SetTextSize(0.045);


  frame->addObject(prelim);
  frame->addObject(lum);
  //frame->addObject(owner);
  frame->addObject(mu);
  frame->addObject(sig);
  frame->addObject(Nsig);
  frame->Draw();
  cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.png",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/C/mgg-FloatedFraction-%s-%s-%s.C",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.pdf",outputTag.Data(),mcName.Data(),tag.Data()) );
  delete cv;
}
示例#28
0
void drawContext::drawScale()
{
  glPushMatrix();
  glLoadIdentity();

  double size = std::max(_right -_left, _top - _bottom);
  double width = size / 3.5;
  double height = size / 10.;
  double dh = height / 5;

	// Draw the scale bar
  int nPview = 0;
  for(int i=0; i<PView::list.size();i++){
    PView *p = PView::list[i];
    PViewOptions *opt = p->getOptions();
    if(!opt->visible) continue;
    PViewData *data = p->getData();

    double box = width / (opt->nbIso ? opt->nbIso : 1);
    double xmin = _left + (_right - _left - width)/2.;
    double ymin = _bottom + 0.7 * height + height * nPview;

    std::vector<GLfloat> vertex(opt->nbIso*3*4);
    std::vector<GLubyte> color(opt->nbIso*4*4);
    for(int i = 0; i < opt->nbIso; i++){
      if(opt->intervalsType == PViewOptions::Discrete ||
         opt->intervalsType == PViewOptions::Numeric){
        unsigned int col = opt->getColor(i, opt->nbIso);
        color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
          (GLubyte)CTX::instance()->unpackRed(col);
        color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
          (GLubyte)CTX::instance()->unpackGreen(col);
        color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
          (GLubyte)CTX::instance()->unpackBlue(col);
        color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
          (GLubyte)CTX::instance()->unpackAlpha(col);
        vertex[i*3*4+0] = xmin + i * box;
        vertex[i*3*4+1] = ymin;
        vertex[i*3*4+2] = 0.;
        vertex[i*3*4+3] = xmin + i * box;
        vertex[i*3*4+4] = ymin + dh;
        vertex[i*3*4+5] = 0.;
        vertex[i*3*4+6] = xmin + (i + 1) * box;
        vertex[i*3*4+7] = ymin;
        vertex[i*3*4+8] = 0.;
        vertex[i*3*4+9] = xmin + (i + 1) * box;
        vertex[i*3*4+10] = ymin + dh;
        vertex[i*3*4+11] = 0.;
      }
      else if(opt->intervalsType == PViewOptions::Continuous){
        double dv = (opt->tmpMax - opt->tmpMin) / (opt->nbIso ? opt->nbIso : 1);
        double v1 = opt->tmpMin + i * dv;
        unsigned int col1 = opt->getColor(v1, opt->tmpMin, opt->tmpMax, true);
        color[i*4*4+0] = color[i*4*4+4] = (GLubyte)CTX::instance()->unpackRed(col1);
        color[i*4*4+1] = color[i*4*4+5] = (GLubyte)CTX::instance()->unpackGreen(col1);
        color[i*4*4+2] = color[i*4*4+6] = (GLubyte)CTX::instance()->unpackBlue(col1);
        color[i*4*4+3] = color[i*4*4+7] = (GLubyte)CTX::instance()->unpackAlpha(col1);
        vertex[i*3*4+0] = xmin + i * box;
        vertex[i*3*4+1] = ymin;
        vertex[i*3*4+2] = 0.;
        vertex[i*3*4+3] = xmin + i * box;
        vertex[i*3*4+4] = ymin + dh;
        vertex[i*3*4+5] = 0.;
        double v2 = opt->tmpMin + (i + 1) * dv;
        unsigned int col2 = opt->getColor(v2, opt->tmpMin, opt->tmpMax, true);
        color[i*4*4+8] = color[i*4*4+12] = (GLubyte)CTX::instance()->unpackRed(col2);
        color[i*4*4+9] = color[i*4*4+13] = (GLubyte)CTX::instance()->unpackGreen(col2);
        color[i*4*4+10] = color[i*4*4+14] = (GLubyte)CTX::instance()->unpackBlue(col2);
        color[i*4*4+11] = color[i*4*4+15] = (GLubyte)CTX::instance()->unpackAlpha(col2);
        vertex[i*3*4+6] = xmin + (i + 1) * box;
        vertex[i*3*4+7] = ymin;
        vertex[i*3*4+8] = 0.;
        vertex[i*3*4+9] = xmin + (i + 1) * box;
        vertex[i*3*4+10] = ymin + dh;
        vertex[i*3*4+11] = 0.;
      }
      else{
        unsigned int col = opt->getColor(i, opt->nbIso);
        color[i*4*4+0] = color[i*4*4+4] = color[i*4*4+8] = color[i*4*4+12] =
          (GLubyte)CTX::instance()->unpackRed(col);
        color[i*4*4+1] = color[i*4*4+5] = color[i*4*4+9] = color[i*4*4+13] =
          (GLubyte)CTX::instance()->unpackGreen(col);
        color[i*4*4+2] = color[i*4*4+6] = color[i*4*4+10] = color[i*4*4+14] =
          (GLubyte)CTX::instance()->unpackBlue(col);
        color[i*4*4+3] = color[i*4*4+7] = color[i*4*4+11] = color[i*4*4+15] =
          (GLubyte)CTX::instance()->unpackAlpha(col);
        vertex[i*3*4+0] = xmin + i * box;
        vertex[i*3*4+1] = ymin;
        vertex[i*3*4+2] = 0.;
        vertex[i*3*4+3] = xmin + i * box;
        vertex[i*3*4+4] = ymin + dh;
        vertex[i*3*4+5] = 0.;
        vertex[i*3*4+6] = xmin + (i + 1) * box;
        vertex[i*3*4+7] = ymin;
        vertex[i*3*4+8] = 0.;
        vertex[i*3*4+9] = xmin + (i + 1) * box;
        vertex[i*3*4+10] = ymin + dh;
        vertex[i*3*4+11] = 0.;
      }
    }

    glVertexPointer(3, GL_FLOAT, 0, &vertex[0]);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, &color[0]);
    glEnableClientState(GL_COLOR_ARRAY);
    if(opt->intervalsType == PViewOptions::Discrete ||
       opt->intervalsType == PViewOptions::Numeric ||
       opt->intervalsType == PViewOptions::Continuous)
      glDrawArrays(GL_TRIANGLE_STRIP, 0, opt->nbIso*4);
    else
      glDrawArrays(GL_LINES, 0, opt->nbIso*4);
    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);

    char label[1024];
    int nt = data->getNumTimeSteps();
    if((opt->showTime == 1 && nt > 1) || opt->showTime == 2){
      char tmp[256];
      sprintf(tmp, opt->format.c_str(), data->getTime(opt->timeStep));
      sprintf(label, "%s (%s)", data->getName().c_str(), tmp);
    }
    else if((opt->showTime == 3 && nt > 1) || opt->showTime == 4){
      sprintf(label, "%s (%d/%d)", data->getName().c_str(), opt->timeStep,
              data->getNumTimeSteps() - 1);
    }
    else{
      sprintf(label, "%s", data->getName().c_str());
    }
    drawString lbl(label, 20 * _fontFactor);
    lbl.draw(xmin + width / 2, ymin + 2.8 * dh, 0.,
             _width/(_right-_left), _height/(_top-_bottom));

    drawString val(data->getName().c_str(), 15 * _fontFactor);
    for(int i = 0; i < 3; i++) {
      double v = opt->getScaleValue(i, 3, opt->tmpMin, opt->tmpMax);
      sprintf(label, opt->format.c_str(), v);
      val.setText(label);
      val.draw(xmin + i * width/ 2, ymin + 1.5 * dh, 0.,
               _width/(_right-_left), _height/(_top-_bottom));
    }
    nPview++;
  }
  glPopMatrix();
}
示例#29
0
unsigned short Assembler::start()
{
    unsigned short start = 0;
    Parser::LinePtr curLine;
    std::map<std::string, unsigned short> labelAddr;
    std::deque<Parser::LinePtr> lines;
    unsigned short curAddr(0);
#ifdef DEBUG
    std::cout << "Analyzing code..." << std::endl;
#endif
    while (curLine = m_parser.getNextLine()) {
        std::string lbl(curLine->label);
        if (!curLine->label.empty()) {
            if (labelAddr.find(curLine->label) != labelAddr.end()) {
                std::string msg("Duplicate label: ");
                msg += curLine->label;
                msg += " on line ";
                msg += (int)m_parser.getLineNumber();
                throw AssemblerException(msg);
            }
            labelAddr[curLine->label] = curAddr;
            this->labelReverse[curAddr] = curLine->label;
        }
        lines.push_back(curLine);
        byteToLineMap[curAddr] = (int)m_parser.getLineNumber();
        if (boost::dynamic_pointer_cast<Parser::Byte>(curLine)) {
            curAddr++;
        } else {
            curAddr+=4;
        }
    }
#ifdef DEBUG
    std::cout << "Processed: " << m_parser.getLineNumber() << " lines. " << labelAddr.size() << " labels, "
        << lines.size() * 4 << " bytes used." << std::endl;
    std::cout << "Building binary block..." << std::endl;
#endif

    curAddr = 0;
    while (lines.size()) {
        Parser::LinePtr line(lines.front());
        lines.pop_front();
        Parser::IntPtr intData(boost::dynamic_pointer_cast<Parser::Int>(line));
        Parser::BytePtr byteData(boost::dynamic_pointer_cast<Parser::Byte>(line));
        Parser::InstructionPtr instruction(boost::dynamic_pointer_cast<Parser::Instruction>(line));

        if (byteData) {
            // This is byte data
            m_block[curAddr] = byteData->value;
            curAddr++;
        } else if (intData) {
            *((int*)&m_block[curAddr]) = intData->value;
            curAddr += sizeof(intData->value);
        } else if (instruction) {
            // This is an actual "machine" instruction
            // First, let's record the address of the first instruction (relative to the "machine")
            if (!start)
                start = curAddr;
            ParamType type = PT_DEFAULT;
            instructionBlock block;
            block.value = 0;
            if (instruction->args.size() >= 1) {
                char reg(getRegister(instruction->args[0]));
                if (reg >= 0) {
                    block.uint8_param = (unsigned char)reg;
                    type = PT_REG;
                } else if (labelAddr.find(instruction->args[0]) != labelAddr.end()) {
                    block.uint16_param2 = labelAddr[instruction->args[0]];
                    type = PT_ADDR;
                } else {
                    try {
                        block.uint16_param2 = boost::lexical_cast<unsigned short>(instruction->args[0]);
                        type = PT_IMMEDIATE;
                    } catch (...) { // boost::bad_lexical_cast
                        std::string msg = "Invalid command; unrecognized argument 1 on command " + instruction->name;
                        msg += " on line " + boost::lexical_cast<std::string>(byteToLineMap[curAddr]);
                        throw AssemblerException(msg);
                    }
                }
            }
            if (instruction->args.size() >= 2 && !block.uint16_param2) {
                char reg(getRegister(instruction->args[1]));
                if (reg >= 0) {
                    block.uint8_param2 = (unsigned char)reg;
                    type = PT_REGREG;
                } else if (labelAddr.find(instruction->args[1]) != labelAddr.end()) {
                    block.uint16_param2 = labelAddr[instruction->args[1]];
                    type = PT_REGADDR;
                } else {
                    try {
                        block.uint16_param2 = boost::lexical_cast<unsigned short>(instruction->args[1]);
                        type = PT_REGIMMEDIATE;
                    } catch (...) { // boost::bad_lexical_cast
                        std::string msg = "Invalid command; unrecognized argument 2 on command " + instruction->name;
                        msg += " on line " + boost::lexical_cast<std::string>(byteToLineMap[curAddr]);
                        throw AssemblerException(msg);
                    }
                }
            }
            if (instruction->args.size() > 2) {
                throw AssemblerException("Too many arguments on command " + instruction->name + " on line " + boost::lexical_cast<std::string>(byteToLineMap[curAddr]));
            }
            block.instruction = m_config->strToBinary(instruction->name, type);
            *((int*)&m_block[curAddr]) = block.value;
            curAddr += sizeof(block.value);
        } else {
            throw AssemblerException("Invalid LinePtr found at " + curAddr);
        }
    }

    return start;
}
void make1DLimitHH(TString combine_dir,bool blind=true){
  //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiHH_0_175/";

  TGraph obser( (275-125)/25 );
  TGraph graph( (275-125)/25 );
  TGraphAsymmErrors error( (275-125)/25 );

    for(int m=125;m<501;m+=25) {
      int i=(m-125)/25;
      TFile limit_file(Form("%s/higgsCombineChiHH_0_%d.Asymptotic.mH120.root",combine_dir.Data(),m) );
      TTree *limit_tree = (TTree*)limit_file.Get("limit");
      TTreeFormula limit_form("get_limit","limit",limit_tree);

      limit_tree->GetEntry(1);
      float down = limit_form.EvalInstance();
      limit_tree->GetEntry(2);
      float exp = limit_form.EvalInstance();
      limit_tree->GetEntry(3);
      float up = limit_form.EvalInstance();
      limit_tree->GetEntry(5);
      float obs = limit_form.EvalInstance();

      graph.SetPoint(i,float(m),exp);
      error.SetPoint(i,float(m),exp);
      error.SetPointError(i,0,0,exp-down,up-exp);

      obser.SetPoint(i,float(m),obs);
    }

    TGraphErrors* theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt");

    TCanvas cv;
    cv.SetLogy();

    theo->SetMaximum(1e2);
    theo->SetMinimum(1e-2);
    theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    theo->GetXaxis()->SetTitle("m_{chargino}");
    theo->SetFillColor(kBlue);
    theo->SetLineStyle(kDotted);
    theo->SetLineWidth(2.0);
    
    error.SetMaximum(1e2);
    error.SetMinimum(1e-2);
    error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    error.GetXaxis()->SetTitle("m_{chargino}");
    error.SetFillColor(kGreen);
    error.Draw("A3");

    theo->Draw("3C");

    graph.SetLineStyle(kDashed);
    graph.SetLineWidth(2);
    graph.Draw("C");

    obser.SetLineStyle(1);
    obser.SetLineWidth(2);
    if(!blind) obser.Draw("C");

    TLegend leg(0.7,0.7,0.85,0.85);
    leg.SetFillColor(0);
    leg.SetBorderSize(0);
    leg.AddEntry(&graph,"expected","l");
    leg.AddEntry(&error,"expected #pm1#sigma","F");
    leg.AddEntry(theo,"theoretical","f");
    if(!blind)     leg.AddEntry(&obser,"observed","l");

    leg.Draw("SAME");

    TLatex prelim(0.65,0.96,"CMS Preliminary");
    prelim.SetNDC();
    prelim.SetTextSize(0.045);
    prelim.Draw();

    TLatex lbl(0.5,0.86,"#sqrt{s} = 8 TeV  #int L dt = 19.78 fb^{-1}");
    lbl.SetNDC();
    lbl.SetTextSize(0.045);
    lbl.Draw();

    cv.SaveAs(combine_dir+"expected_exclusion_HH_1D.png");


}