Exemplo n.º 1
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("sureste",ROOMS+"ciudad_71.c");
salida("suroeste",ROOMS+"ciudad_70.c");
}
Exemplo n.º 2
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("norte",ROOMS+"ciudad_239.c");
salida("este",ROOMS+"ciudad_249.c");
}
Exemplo n.º 3
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("oeste",ROOMS+"ciudad_138.c");
salida("este",ROOMS+"ciudad_140.c");
}
Exemplo n.º 4
0
void habitacion() {



nombre("$N$0Zorimeth:$R$4 Avenida de Lloth$R");
descripcion("LONG\n\n");
salida("norte",ROOMS+"ciudad_104.c");
salida("sur",ROOMS+"ciudad_129.c");
}
Exemplo n.º 5
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("noroeste",ROOMS+"ciudad_228.c");
salida("sur",ROOMS+"ciudad_248.c");
}
Exemplo n.º 6
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("oeste",ROOMS+"ciudad_192.c");
salida("noreste",ROOMS+"ciudad_177.c");
salida("este",ROOMS+"ciudad_194.c");
}
Exemplo n.º 7
0
void habitacion() {



    nombre("$N$0Zorimeth$R");
    descripcion("LONG\n\n");
    salida("norte",ROOMS+"ciudad_103.c");
    salida("este",ROOMS+"ciudad_114.c");
    salida("suroeste",ROOMS+"ciudad_126.c");
}
Exemplo n.º 8
0
void habitacion() {



nombre("$N$0Zorimeth$R");
descripcion("LONG\n\n");
salida("oeste",ROOMS+"ciudad_264.c");
salida("norte",ROOMS+"ciudad_251.c");
salida("sur",ROOMS+"ciudad_275.c");
}
Exemplo n.º 9
0
void habitacion() {



nombre("$N$0Zorimeth:$R$6 Avenida de la Antipoda Oscura$R");
descripcion("Junto con la avenida de Lloth, la avenida de la Antipoda Oscura es una de las principales "+
			"calles de Zorimeth. Por aqui se desarrollan las principales actividades de la ciudad. "+
			"No es muy dificil ver pasar a gente por este lugar. Tanto drows como orcos y goblins "+
			"esclavizados caminan a menudo por la avenida.\n\n");
salida("oeste",ROOMS+"ciudad_81.c");
salida("este",ROOMS+"ciudad_83.c");
}
Exemplo n.º 10
0
void WarningLog::loguear(const char* mensajeError, Log::LOG_TIPO tipo) throw(LogExcepcion) {
	const char * tipoDeLog;
	time_t t;
	struct tm * timestamp;

	time(&t);
	timestamp = localtime(&t);
	std::string fechaAux = asctime(timestamp);
	fechaAux.pop_back();
	fecha = fechaAux.c_str();

	switch (tipo) {
	case (LOG_ERR):
		tipoDeLog = "Error - ";
		break;
	case (LOG_WAR):
		tipoDeLog = "Warning - ";
		break;
	default:
		return;
	}
	std::ofstream salida(archivo, std::ios::out | std::ios::app);
	if (!salida.is_open())
		throw new LogExcepcion("No se puede abrir el archivo de Log para Warnings \n");
	salida << tipoDeLog << mensajeError << "\n";
	salida.close();
}
Exemplo n.º 11
0
void BPlusTree::exportToPlainText(string filePath, bool keytext, bool textContent){ // serveto's way

	ofstream salida(filePath.c_str(),ios::out | ios::trunc);

	salida << "--------- Arbol B+ ---------" << endl << endl;

	salida << "Tamanio Total Nodo:  " << TreeConstraits::getFullSizeNode() << endl;
	salida << "Tamanio Datos Control Nodo:  " << TreeConstraits::getControlSizeNode() << endl;
	salida << "Tamanio Efectivo Nodo:  " << TreeConstraits::getEfectiveSizeNode() << endl;
	salida << "Tamanio Datos Control Registro:  " << TreeConstraits::getControlSizeRecord() << endl << endl;
	salida << "Primera Hoja:  " << firstLeaf << endl;
	salida << "Nodos Libres:  ";

	vector<int>::iterator it = freeNodes.begin();
	while (it != freeNodes.end()) {
		int numeroDeNodo = *it;
		salida << numeroDeNodo << " | ";
		it++;
	}
	salida << endl;

	if (root)
		exportNode(salida, root, 1,keytext,textContent);

	salida.close();
}
Exemplo n.º 12
0
void FinalA::guardarArchivo(stDatos &datos){

	// Archivo de entrada. Abro el archivo de entrada en modo binario.
	ESArchivoCpp entrada("./archivos/FinalA_Entrada1.bmp",true,false);

	// Archivo de salida
	ESArchivoCpp salida("./archivos/FinalA_Salida.bmp",false,false);

	// Escribo todo el archivo original, para despues ir pisando los datos que necesito actualizar
	char* archivoCompleto = NULL;
	unsigned int tamanioArchivoCompleto = entrada.leerArchivo(&archivoCompleto);
	salida.escribirEnArchivo(archivoCompleto,datos.offsetDatos);
	if( archivoCompleto != NULL ) delete[] archivoCompleto;

	// Escribo el byte 2: Tamaño del archivo.
	unsigned int tamanioArrayDuplicado = (datos.cantidadFilas * 2) * ( datos.anchoFilaDoble );
	unsigned int tamanioArchivo = datos.offsetDatos + tamanioArrayDuplicado;
	salida.escribirEnArchivo((char*)&tamanioArchivo,2, sizeof(unsigned int));

	// Escribo el byte 18: Ancho en pixeles de la imagen.
	int anchoEnPixeles = datos.anchoPix * 2;
	salida.escribirEnArchivo( (char*)&anchoEnPixeles , 18 , sizeof(int) );					
	
	// Escribo el byte 22: Alto en pixeles de la imagen.
	int altoEnPixeles = datos.altoPix * 2;
	salida.escribirEnArchivo( (char*)&altoEnPixeles , 22 , sizeof(int) );

	// Escribo los nuevos valores del array duplicado
	salida.escribirEnArchivo((char*)datos.arrayPixelesDuplicados,datos.offsetDatos,tamanioArrayDuplicado);

	return void();
}
Exemplo n.º 13
0
int main(){
	grafo g = grafo();
	g.inicializar();
	//g.draw();

	/*vector<int> vec2(g.cantNodos);
	vector<int> vec;
	vector<int> solucion;
	for (int i = 0; i < vec2.size(); ++i){
		vec2[i] = i+1;
	}

	int fronteraMax = -1;*/

	iniciarTimer();
	//exacto(vec,0,g.cantNodos,vec2,g,0,solucion,fronteraMax);
	Solucion s = exacto(g);
	double t = finalizarTimer();

	#ifdef TEST
		//muestro runtime
		cout << "tiempo transcurrido: " << t << endl;
		return 0;
	#endif

	//g.draw(s);	
	salida(s);

	return 0;
}
Exemplo n.º 14
0
/*----------------------------------------------------------------------------*/
void XmlParser::agregarSalidaPacMan(Mapa* mapa,xmlpp::TextReader& reader)
{
	int idVertice = getAtributoInt(reader,ATRIB_ID_VERTICE);
	SalidaPacMan salida(idVertice);
	Modelo::getInstance()->SetSalidaPacMan(salida);
	elementosNoPastillas.push_back(idVertice);
}
Exemplo n.º 15
0
void habitacion() {


nombre("$N$0Zorimeth:$R$3 Narbondel$R");
descripcion("Ante ti se alza el imponente Narbondel, un inmenso pilar de piedra decorado con extraños símbolos "+
			"drow. Este es el punto central de la ciudad de Zorimeth, decenas de drows pasan por aqui diariamente."+
			"Cada día el maese de los hechizeros lanza un conjuro sobre el pilar que lo mantiene ligeramente "+
			"iluminado un día entero de la superficie.\n\n");
/*
add_item("narbondel","\nEste enorme pilar de piedra es el único modo que poseen los drows de tener constancia de paso "+
		"del tiempo. Gracias al hechizo que diariamente el maese de los hechizeros lanza sobre el pilar, ""una leve luminosidad recorre el pilar manteniendose durante un dia completo de la superficie. ""Gracias a esto, los drows son capaces de tener constancia del paso de los dias.\n\n");
*/
salida("oeste",ROOMS+"ciudad_84.c");
salida("norte",ROOMS+"ciudad_67.c");
salida("este",ROOMS+"ciudad_86.c");
salida("sur",ROOMS+"ciudad_104.c");
}
Exemplo n.º 16
0
int main()
{
        char divisaInicial, divisaFinal;
        double cantidad, cantidadConvertida;

        printf("Programa para de conversión de divisas.\n");
        entrada(&divisaInicial,&divisaFinal,&cantidad);
        cantidadConvertida=conversion(divisaInicial,divisaFinal,cantidad);
        salida(cantidadConvertida);

        system ("PAUSE");
        return 0;
}
Vector<double> SumaCuadrados::getGradient(Vector<double> argument) {
	//return 2*transpose(ModelMatrix)*(res);
	Vector<double> salida(argument.getSize());
	Vector<double> res = Residuals(argument);

	for(int icol = 0;icol<ModelMatrix.getNumberOfColumns();icol++){
    	salida[icol] = 0;
    	for(int jrow=0;jrow<ModelMatrix.getNumberOfRows();jrow++){
    		salida[icol]+=2*ModelMatrix[jrow][icol]*res[jrow];
    	}
    }
	return salida;
}
Exemplo n.º 18
0
void proba::on_abrir_clicked()
{
    QFileDialog *dialog=new QFileDialog(this,"Seleccione un fichero","");
    dialog->exec();
    QStringList fileNames = dialog->selectedFiles();
    QFile pfile(fileNames.first());
    if (pfile.open(QIODevice::ReadOnly))
      {
        QString salida(pfile.readAll());
        ui->plainTextEdit->setPlainText(salida);
        pfile.close();
      }
    delete dialog;
}
Exemplo n.º 19
0
Arquivo: 2.c Projeto: nee47/abb
// MODIFIQUE EL PRIMER CASO DE BORRAR (EL MAS DIFICIL)
// DENTRO DEL PRIMER CASO TAMBIEN HAY OTRO CASO PARTICULAR
// RESUELTO
void *abb_borrar(abb_t *abb, const char *clave){
  if(!abb->raiz) return NULL;
  abb_nodo_t** arbol = buscar_arbol(clave, &abb->raiz, abb->cmp);
  if (!(*arbol)) return NULL;
  void* dato_salida = NULL;
  /* primer caso */
  if((*arbol)->derecha && (*arbol)->izquierda){
    dato_salida = (*arbol)->dato;
    abb_nodo_t** padre_minimo = min(&(*arbol)->derecha, abb-> cmp);
    if(!(*padre_minimo)->izquierda) {
      abb_nodo_t* derecha_padre_minimo = (*padre_minimo)->derecha;
      printf("papa de MINIMON ES  %s \n", (*padre_minimo)->clave);
      (*arbol)->dato = (*padre_minimo)->dato; 
      free((*arbol)->clave);
      (*arbol)->clave = strdup((*padre_minimo)->clave);
      free((*padre_minimo)->clave);
      free(*padre_minimo);
      (*arbol)->derecha = derecha_padre_minimo;
      abb->cantidad_nodos--;
      return dato_salida;
    }
    printf("MINIMON ES  %s \n", (*padre_minimo)->izquierda->clave);
    (*arbol)->dato = (*padre_minimo)->izquierda->dato;
    free((*arbol)->clave);
    (*arbol)->clave = strdup((*padre_minimo)->izquierda->clave);
    //free((*padre_minimo)->izquierda->clave);
    abb_nodo_t* derecha_minimo = (*padre_minimo)->izquierda->derecha; 
    abb_nodo_t* nodo_a_borrar = (*padre_minimo)->izquierda;
    (*padre_minimo)->izquierda->derecha = (*arbol)->derecha;
    (*padre_minimo)->izquierda = derecha_minimo;
    free(nodo_a_borrar->clave);
    free(nodo_a_borrar);
    abb->cantidad_nodos--;
    return dato_salida;
  } 

  if(!(*arbol)->derecha && !(*arbol)->izquierda){  /* segundo caso  */
    dato_salida = (*arbol)->dato;
    free((*arbol)->clave);
    free(*arbol);
    *arbol = NULL;
    abb->cantidad_nodos-- ;
    return dato_salida;
  }
  /* tercer caso   */
  dato_salida = salida(arbol, abb);
  return dato_salida;
}
Exemplo n.º 20
0
void TableroVisual::prueba()
{
    QString pp = "exito";
    
    if(_cliente->estado() == "conectado")
    {
	QByteArray bloque;
        QDataStream salida(&bloque, QIODevice::WriteOnly);
        salida.setVersion(VERSION);
        salida << pp;
        salida.device()->seek(0);
        _cliente->cliente()->write(bloque);
        _cliente->cliente()->flush();
        connect(_cliente->cliente(), SIGNAL(readyRead()), this, SLOT(iniciarLectura()));
    }
}
Exemplo n.º 21
0
void ZGui::verEliminados()
{  
  QFile salida("/mmc/mmca1/zCleanerList.txt");
  QTextStream sal(&salida);
  salida.open(IO_WriteOnly | IO_Translate);
  QString aux="";
  for(int i=0;i<eliminados.count();i++)
  //      aux+=aux + eliminados[i] + '\n';     

  sal << eliminados[i] << endl;
  if(infos==NULL)
  {
  infos = new ZNoticeDlg(ZNoticeDlg::Information, 3000, QString("OK"), QString("List save in /mmc/mmca1"), this, "z", true, 0);
   infos->show();
 
  } infos=NULL;
salida.close();
Exemplo n.º 22
0
void automovil( void *id ){
	int ent,tie,sal,i;
//	for(i=0;i<NEJECUCIONES;i++)
	while(1)
	{
		ent = rand()%NENTRADAS;
		tie = rand()%5;
		sal = rand()%NSALIDAS;

		int id2 = (int) id;
		//printf("id2: %d",id2);

		int lug = entrada(id,ent);
		pthread_mutex_unlock(&C1);
		tiempo(tie);
		salida(id,sal,lug);
		pthread_mutex_unlock(&C1);
	}
	sleep(3);
}
Exemplo n.º 23
0
void Tarea1::on_Insertar_clicked()
{
    ofstream salida(ui->Direccion->text().toStdString().c_str(), ios::in | ios:: binary);
    salida.seekp(0,ios::end);
    int size = salida.tellp();
    //salida.seekp(0,ios::beg);
    cout<<size<<endl;

    srand(0);
    int aletoria;
    int *pos;
    int letras = ui->escritura->text().toStdString().size();
    string  letra = ui->escritura->text().toStdString();
    pos = new int[letras];

    for(int j=0; j<letras; j++){
        for(int i=0; i<10; i++){
            aletoria = 1+(rand()%(size/2));
        }
        if(aletoria>200){
        salida.seekp(aletoria,ios::beg);
        pos[j]= salida.tellp();
        salida.write(&letra[j],1);
        cout<<"Aletorio"<<aletoria<<endl;

        }
    }
    salida.seekp(100, ios::beg);
    for(int x=0; x<letras; x++){
        salida.write((char*)(&pos[x]),4);
        cout<<"Pos"<<pos[x]<<endl;
        cout<<"ubicacion"<<salida.tellp()<<endl;
    }
    salida.seekp(90, ios::beg);
    salida.write((char*)&letras, 4);
    salida.flush();
    salida.close();
}
Exemplo n.º 24
0
void BPlusTree::exportToPlainTextNoOrder(string filePath){

	ofstream salida(filePath.c_str(),ios::out | ios::trunc);
	int j = this->fileBlockManager->getBlockCount();
	for(int i = 0; i < j; i++){
		Node* n = NULL;
		n = this->hidratateNode(i);
		if(n->isLeaf()){
			salida << i << " LEAF ";
			for(int k = 0; k < n->keyMount; k++ )
				salida << " (" << n->keys[k].getKey() << ") ";
		}else{
			salida << i << " INNER ";
			for(int k = 0; k < n->keyMount; k++){
				InnerNode* inner = static_cast<InnerNode*> (n);
				salida << " (" << inner->keys[k].getKey() << ") " << inner->sons[k];

			}
		}
	salida << endl;
	}

}
Exemplo n.º 25
0
// Toma una imagen BMP 24-bit y le deja solo el componente verde de la misma
void FinalA::pruebaPintaVerde(void){
	ESArchivoCpp entrada("./archivos/FinalA_Entrada3.bmp",true,false);
	ESArchivoCpp salida("./archivos/FinalA_Salida.bmp",false,false);

	unsigned int tamanioArchivo = 0;
	entrada.leerArchivo( (char*)&tamanioArchivo , 2 , sizeof(unsigned int) );	// 2: Offset al tamanio de archivo, sacado del enunciado
	std::cout << "Tamanio del archivo (leido del BMP): " << tamanioArchivo << "\n";

	unsigned int offsetDatos = 0;
	entrada.leerArchivo( (char*)&offsetDatos , 10 , sizeof(unsigned int) );	// 10: Offset al offset de inicio de los datos, sacado del enunciado
	std::cout << "Offset a los datos del BMP: " << offsetDatos << "\n";

	int ancho = 0;
	entrada.leerArchivo( (char*)&ancho , 18 , sizeof(int) );		// 18: Offset al ancho en pixels de la imagen, sacado del enunciado
	std::cout << "Ancho de la imagen BMP: " << ancho << "\n";

	int alto = 0;
	entrada.leerArchivo( (char*)&alto , 22 , sizeof(int) );			// 22: Offset al alto en pixels de la imagen, sacado del enunciado
	std::cout << "Alto de la imagen BMP: " << alto << "\n";

	unsigned int anchoConPadding = (3 * ancho) + ( 4 - ((3 * ancho)%4) ) % 4;	// Ojo: Cada fila está alineada con bloques de 4 bytes, si es necesario tiene padding al final de la misma
	unsigned int tamanioDatos = (alto * anchoConPadding);
	std::cout << "El tamanio de la cabecera + los datos es: " << offsetDatos + tamanioDatos << "\n";

	unsigned char* datos = new unsigned char[tamanioDatos];
	entrada.leerArchivo( (char*)datos , offsetDatos , tamanioDatos );

	// Nota: El formato de los colores es >>> (B,G,R)
	for( unsigned long i = 0; i < alto; i++){		// Azul
		unsigned int filasAnt = i * anchoConPadding;
		for( unsigned long j = 0; j < (3 * ancho); j+=3){
			unsigned short numero = 0;
			datos[filasAnt + j] = (unsigned char)numero;	// Saco la componente azul
		}
	}

	for( unsigned long i = 0; i < alto; i++){		// Verde
		unsigned int filasAnt = i * anchoConPadding;
		for( unsigned long j = 1; j < (3 * ancho); j+=3){
			unsigned short numero = 255;
			//datos[filasAnt + j] = (unsigned char)numero;  // Al verde no le hago nada
		}
	}

	for( unsigned long i = 0; i < alto; i++){		// Rojo
		unsigned int filasAnt = i * anchoConPadding;
		for( unsigned long j = 2; j < (3 * ancho); j+=3){
			unsigned short numero = 0;
			datos[filasAnt + j] = (unsigned char)numero;	// Saco la componente roja
		}
	}

	char* archivoCompleto = NULL;
	unsigned int tamanioArchivoCompleto = entrada.leerArchivo(&archivoCompleto);

	salida.escribirEnArchivo(archivoCompleto,tamanioArchivoCompleto);
	salida.escribirEnArchivo((char*)datos,offsetDatos,tamanioDatos);

	delete[] datos;
	if( archivoCompleto != NULL ) delete[] archivoCompleto;

	return void();
}
Exemplo n.º 26
0
void pointsed(TString filename = "btagpatanalyzerpy.root", TString check="") {
	TString cmssw;
	// 167
	
	cmssw = "$3.1.0_pre9$";
	
	TFile *f = TFile::Open(filename);
/////////////////////////////////////////////////////////////////////////////////////////
	std::vector< TString > checks;
	checks.push_back("");
	checks.push_back("Corr30_");
	checks.push_back("Corr30t0_");
	checks.push_back("Corr30t1_");
	checks.push_back("Corr30t2_");
	checks.push_back("Corr30t0_nConstituent_");
	checks.push_back("Corr30t1_nConstituent_");
	checks.push_back("Corr30t2_nConstituent_");
	checks.push_back("Uncor10_");
	checks.push_back("Uncor10t0_");
	checks.push_back("Uncor10t1_");
	checks.push_back("Uncor10t2_");
	checks.push_back("Uncor10t0_nConstituent_");
	checks.push_back("Uncor10t1_nConstituent_");
	checks.push_back("Uncor10t2_nConstituent_");
/////////////////////////////////////////////////////////////////////////////////////////
	std::vector< TString > taggers;
	std::vector< TString > labeltag;
        std::vector< int> colorlines;
	taggers.push_back( "TC2" );colorlines.push_back( 1 );labeltag.push_back( "TCHE");
	taggers.push_back( "TC3" );colorlines.push_back( 2 );labeltag.push_back( "TCHP");
	taggers.push_back( "TP"  );colorlines.push_back( 3 );labeltag.push_back( "JP");
	taggers.push_back( "SSV" );colorlines.push_back( 4 );labeltag.push_back( "SSV");
	taggers.push_back( "CSV" );colorlines.push_back( 5 );labeltag.push_back( "CSV");
	taggers.push_back( "MSV" );colorlines.push_back( 6 );labeltag.push_back( "CSVMVAB");
	taggers.push_back( "SMT" );colorlines.push_back( 8 );labeltag.push_back( "SMT");
	taggers.push_back( "BTP" );colorlines.push_back( 9 );labeltag.push_back( "JBP");
	taggers.push_back( "SMTbyIP3d" );colorlines.push_back( 11 );labeltag.push_back( "SMTByIP3d");
	taggers.push_back( "SMTbyPt" );colorlines.push_back( 12 );labeltag.push_back( "SMTByPt");
	taggers.push_back( "SETbyIP3d" );colorlines.push_back( 13 );labeltag.push_back( "SETByIP3d");
	taggers.push_back( "SETbyPt" );colorlines.push_back( 14 );labeltag.push_back( "SETByPt");
//	taggers.push_back( "IPM" );colorlines.push_back( 11 );labeltag.push_back( "IPMVAB");
//	taggers.push_back( "SMNIPT" );colorlines.push_back( 12 );labeltag.push_back( "SMTNoIP");

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
//ed	for ( size_t ichks = 0; ichks < checks.size(); ++ichks ) {
//ed		TString check = checks[ichks];
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
        TString PerfTitle= check;
        if (check == "") PerfTitle="uncorr pt>30";
	if (check == "Corr30_") PerfTitle="pt>30";
	if (check == "Corr30t0_") PerfTitle="pt>30, #tracks > 0";
	if (check == "Corr30t1_") PerfTitle="pt>30, #tracks > 1";
	if (check == "Corr30t2_") PerfTitle="pt>30, #tracks > 2";
	if (check == "Corr30t0_nConstituent_") PerfTitle="pt>30, #tracks > 0 & nConstituents >1";
	if (check == "Corr30t1_nConstituent_") PerfTitle="pt>30, #tracks > 1 & nConstituents >1";
	if (check == "Corr30t2_nConstituent_") PerfTitle="pt>30, #tracks > 2 & nConstituents >1";
	if (check == "Uncor10_") PerfTitle="uncorr pt>10";
	if (check == "Uncor10t0_") PerfTitle="uncorr pt>10 #tracks > 0";
	if (check == "Uncor10t1_") PerfTitle="uncorr pt>10 #tracks > 1";
	if (check == "Uncor10t2_") PerfTitle="uncorr pt>10 #tracks > 2";
	if (check == "Uncor10t0_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 0 & nConstituents >1";
	if (check == "Uncor10t1_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 1 & nConstituents >1";
	if (check == "Uncor10t2_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 2 & nConstituents >1";

	std::vector< TString > discriminators;
        for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
  		discriminators.push_back( check+"disc"+taggers[itagger]+"_udsg" );
	}
//	discriminators.push_back( "discTC3_udsg" );
//	discriminators.push_back( "discTP_udsg" );

	TCanvas *cv = new TCanvas("cv","cv",900,900);
	TMultiGraph *mg =new TMultiGraph();
	TLegend *legend0 = new TLegend(0.68,0.12,0.88,0.32);
        // inverted axis
	TMultiGraph *mginv =new TMultiGraph();
	TLegend *legend1 = new TLegend(0.65,0.18,0.85,0.48);
	std::ofstream salida("BTagPATop3"+check+".txt");
	
	for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {

		TString tag    = check+"g"+taggers[itagger]+"_udsg";
		TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tag);

		
		TGraph *dgraph = (TGraph*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+discriminators[itagger]);
//		TGraph *udsgvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),dgraph->GetX());
		dgraph->Sort();
//		udsgvsdgraph->Sort();

		TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX());
		g->Sort();
		g->SetLineColor(itagger+1);
                legend0 -> AddEntry(g,taggers[itagger],"l");
		mg->Add(g);

                //inverted axis
		TGraphErrors *ginv = new TGraphErrors(agraph->GetN(),agraph->GetX(),agraph->GetY(),agraph->GetEX(),agraph->GetEY());
		ginv->Sort();
		ginv->SetLineColor(colorlines[itagger]);
		ginv->SetMarkerStyle(8);
		ginv->SetMarkerColor(colorlines[itagger]);
                legend1 -> AddEntry(ginv,labeltag[itagger],"l");
		mginv->Add(ginv);

		std::cout << " Tagger: " << tag << std::endl;
		std::cout << " Loose(10%): " << " cut > " << std::setprecision(4) << dgraph->Eval(0.1) << " b-eff = " << g->Eval(0.1) << std::endl;
		std::cout << " Medium(1%):  " << " cut > " << std::setprecision(4) << dgraph->Eval(0.01) << " b-eff = " << g->Eval(0.01) << std::endl;
		std::cout << " Tight(0.1%) = " << " cut > " << std::setprecision(4) << dgraph->Eval(0.001) << " b-eff = " << g->Eval(0.001) << std::endl;
                salida << " " << taggers[itagger] << endl;
	        salida << " #bin \t b-eff  \t err-beff \t  non-beff \t err-non-b"<< endl;
        	for ( size_t i=0;i< agraph->GetN();i++){ 
			salida	<< "  " << (i+1) << " \t "
				<< agraph->GetX()[i] <<" \t " 
				<< agraph->GetEX()[i]<<" \t "
				<< agraph->GetY()[i] <<" \t "
				<< agraph->GetEY()[i]
                       		<< " "<< endl;
		}

	}
//	cv->SetLogx();
	mg->Draw("ALP");
	mg->GetYaxis()->SetTitle("b-eff");
	mg->GetXaxis()->SetTitle("udsg-mistagging");
	legend0 -> Draw();
        cv-> SetGrid();
	cv-> Print ("BTagPATop"+check+".eps");
	cv-> Print ("BTagPATop"+check+".png");
	cv->cd(0);
	cv->SetLogx();
	mg->Draw("ALP");
	legend0 -> Draw();
	cv-> Print ("BTagPATop1"+check+".eps");
	cv-> Print ("BTagPATop1"+check+".png");
        //inverted axis
	TCanvas *cvinv = new TCanvas("cvinv","cvinv",700,700);
        cvinv->SetLogy(0);
	mginv->Draw("ALP");
	mginv->GetXaxis()->SetTitle("b-eff");
	mginv->GetYaxis()->SetTitle("udsg-mistagging");
	legend1 -> Draw();
        cvinv->SetGrid();
	cvinv-> Print ("BTagPATop2"+check+".eps");
	cvinv-> Print ("BTagPATop2"+check+".png");
	cvinv->cd(0);
//	cvinv->Update();
//	cvinv->SetLogx();
//	mginv->SetXmin(10^-4);
//      axis range using a histogram helper
    TH2D*hpx = new TH2D("hpx",PerfTitle,200,0.0,1.005,200,0.00002,1.05);
        hpx->SetStats(kFALSE);
		hpx->Draw();
	hpx->GetXaxis()->SetTitle("b-eff");
	hpx->GetYaxis()->SetTitle("udsg-mistagging");
	cvinv->SetLogy(1);
	mginv->Draw("AP");
	legend1 -> Draw();
	cvinv-> Print ("BTagPATop3"+check+".eps");
	cvinv-> Print ("BTagPATop3"+check+".png");
	//ed}
}
Exemplo n.º 27
0
void meoutput(int nsel = 1, int mode = 0, bool silent = false){
  
   
  
  // samples used
  double x_sec = 0.;
  char plotName[300];
  sprintf(plotName,"test");
  
  if (nsel == 0)                	{sprintf(plotName,"tt");}
  else if (nsel == 1)   		{sprintf(plotName,"tw");}
  
  
  if (mode != 0 &&  mode !=1 && mode !=2) mode = 0;
  if (!silent){
    if      (mode == 0) 	cout << " Electron-Muon Mixed channel " << endl;
    else if (mode == 1) 	cout << " Di-Muon channel " << endl;
    else if (mode == 2) 	cout << " Di-Electron channel " << endl;
  }
  
  char myRootFile[300];
  sprintf(myRootFile,"outputs/out_%d_%s.root", mode, plotName);
  TFile *input = TFile::Open(myRootFile);
  
  
  char myTexFile[300];
  sprintf(myTexFile,"out/%s_%d.lhco", plotName, mode);
  ofstream salida(myTexFile);
  
  // tree variables
  /////
  double xlWeight; 
  
  double metPt;
  double metPx;
  double metPy;
  
  std::vector<double> *ptLepton;
  std::vector<double> *pxLepton;
  std::vector<double> *pyLepton;
  std::vector<double> *pzLepton;
  std::vector<double> *eLepton;
  std::vector<double> *qLepton;
  
  std::vector<double> *ptJet;
  std::vector<double> *pxJet;
  std::vector<double> *pyJet;
  std::vector<double> *pzJet;
  std::vector<double> *eJet;
  std::vector<double> *qJet;
  std::vector<double> *btJet;
  
  TTree*Tree = (TTree*) gROOT->FindObject("myTree");
  
  Tree->SetBranchAddress("xlWeight", &xlWeight);
  
  Tree->SetBranchAddress("metPt", &metPt);
  Tree->SetBranchAddress("metPx", &metPx);
  Tree->SetBranchAddress("metPy", &metPy);
  
  Tree->SetBranchAddress("ptLepton",&ptLepton);
  Tree->SetBranchAddress("pxLepton",&pxLepton);
  Tree->SetBranchAddress("pyLepton",&pyLepton);
  Tree->SetBranchAddress("pzLepton",&pzLepton);
  Tree->SetBranchAddress("eLepton",&eLepton);
  Tree->SetBranchAddress("qLepton",&qLepton);
  
  Tree->SetBranchAddress("ptJet",&ptJet);
  Tree->SetBranchAddress("pxJet",&pxJet);
  Tree->SetBranchAddress("pyJet",&pyJet);
  Tree->SetBranchAddress("pzJet",&pzJet);
  Tree->SetBranchAddress("eJet",&eJet);
  Tree->SetBranchAddress("qJet",&qJet);
  Tree->SetBranchAddress("btJet",&btJet);
  
  int nEvents = Tree->GetEntries();
  if(!silent){
    cout << endl;
    cout << "------------------------------------------" << endl;
    cout << "Sample: " << plotName <<  endl;
    cout << "------------------------------------------" << endl;
    cout << "Number of Total events in the tuple: " <<  nEvents << endl;
    cout << "------------------------------------------" << endl;
  }
  
  
  //////////
  int n1Jet = 0;
  int nTotal = 0;
  int nUsed = 0;
  
  for(int event = 0; event<nEvents; event++){
    
    Tree->GetEntry(event);
    
    if (luminosity != 1000) xlWeight*=(luminosity/1000);
    
    if(ptLepton->size() != 2) cout << "Something is wrong, your Tree is not correctly filled" << endl;
    else {
      
      TLorentzVector lepton0(pxLepton->at(0),pyLepton->at(0), pzLepton->at(0), eLepton->at(0));
      TLorentzVector lepton1(pxLepton->at(1),pyLepton->at(1), pzLepton->at(1), eLepton->at(1)); 
      TLorentzVector pair = lepton0+lepton1;
      
      bool invMass = false;
      if      (mode == 0) invMass = true;
      else if (mode == 1 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
      else if (mode == 2 && (pair.M() > invMax || pair.M() < invMin)) invMass = true;
      
      if (invMass){
	if (metPt >= metCut || mode ==0){
	  
	  int nJets = 0;
	  int nSecondJets = 0;
	  int nJetsBt = 0;
	  bool bTagged = false;
	  int indexJet = -5;
	  for (int i=0; i < ptJet->size(); i++){
	    TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
	    if (tempJet.Pt()  >= jetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){
	      nJets++;
	      indexJet = i;
	      if(btJet->at(i) > 1.74) bTagged = true;
	    } else if (tempJet.Pt()  >= secondJetCut && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3) nSecondJets++;
	    if (btJet->at(i) > 1.74) nJetsBt++;
	    
	  }
	  
	  if (nJets == 1){
	    if (nJetsBt == 1 && bTagged){
	      // if (bTagged && nSecondJets == 0){
	      TLorentzVector jet(pxJet->at(indexJet),pyJet->at(indexJet), pzJet->at(indexJet), eJet->at(indexJet));
	      
	      double ptSysPx = lepton0.Px() + lepton1.Px() + jet.Px() + metPx;
	      double ptSysPy = lepton0.Py() + lepton1.Py() + jet.Py() + metPy;
	      double ptSystem = sqrt(ptSysPx*ptSysPx + ptSysPy*ptSysPy);
	      double ht = lepton0.Pt() + lepton1.Pt() + jet.Pt() + metPt; 
	      
	      if (ptSystem <= ptsysCut){
		if (ht > htMin || mode !=0){
		  nTotal++;
		  if (nSecondJets != 0){
		    nUsed++;
		    int indexSecondJet = -5;
		    for (int i=0; i < ptJet->size(); i++){
		      TLorentzVector tempJet(pxJet->at(i),pyJet->at(i), pzJet->at(i), eJet->at(i));
		      if (i != indexJet && TMath::Min(fabs(lepton0.DeltaR(tempJet)), fabs(lepton1.DeltaR(tempJet))) > 0.3){
			indexSecondJet = i;
			break;
		      } 
		    }
		    
		    TLorentzVector jet2(pxJet->at(indexSecondJet),pyJet->at(indexSecondJet), pzJet->at(indexSecondJet), eJet->at(indexSecondJet));
		    TVector3 missingEt(metPx, metPy, 0);
		    
		    salida << "0 1 1 " << endl;
		    salida << "1 2 " << lepton0.Eta() << " " << lepton0.Phi() << " " << lepton0.Pt() <<" " << lepton0.M() << " " << qLepton->at(0) << " 0 0 0 0 " <<  endl;
		    salida << "2 2 " << lepton1.Eta() << " " << lepton1.Phi() << " " << lepton1.Pt() <<" " << lepton1.M() << " " << qLepton->at(1) << " 0 0 0 0 " <<  endl;
		    salida << "3 4 " << jet.Eta() << " " << jet.Phi() << " " << jet.Pt() <<" " << jet.M() << " " << qJet->at(indexJet) << " 2 0 0 0 " <<  endl;
		    salida << "4 4 " << jet2.Eta() << " " << jet2.Phi() << " " << jet2.Pt() <<" " << jet2.M() << " " << qJet->at(indexSecondJet) << " 2 0 0 0 " <<  endl;
		    salida << "5 6 " << missingEt.Eta() << " " << missingEt.Phi() << " " << metPt <<" " << " 0 0 0 0 0 0 " <<  endl;
		    
		  } else n1Jet++;
		  
		  
		  
	       	}
	      }
	    }
	  }
	}
      }
      
    } // 2 leptons
  } // events
  
  
  if (!silent){ 
    cout << "Results: "  <<  endl;
    cout << nTotal << " events passed the selection" << endl;
    cout << nUsed << " events were used in the lhco file " << endl;
    cout << n1Jet << " events were not used (only 1 jet exactly) " << endl;
    cout << "------------------------------------------" << endl; 
  }

  
  
}
Exemplo n.º 28
0
void eewsProcess::start(QString argCommand, ProcessMode mode) {

	int pid = fork() ;

	if(!pid) {
		
		struct rusage execusage ;
		int timeUsed, memUsed ;
		timeUsed = memUsed = 0 ;

		QFlags<eewsProcess::ProcessMode> flags(mode) ;

		if(flags.testFlag(eewsProcess::Sandboxed)) {
			subProcess = new sandboxProcess(sandboxProcess::Sandboxed) ;
			subProcess->setTimeLimit((timeLimit/1000)+1) ;
		} else {
			subProcess = new sandboxProcess(sandboxProcess::NotSandboxed) ;
		}

		connect(subProcess,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(finishedSlot(int,QProcess::ExitStatus))) ;

		subProcess->setWorkingDirectory(directory) ;
		subProcess->start(argCommand) ;

		subProcess->waitForStarted() ;

		if(QFile::exists(directory + "/stdin")) {
			QFile file(this) ;
			file.setFileName(directory + "/stdin") ;
			file.open(QIODevice::ReadOnly) ;
			subProcess->write(file.readAll()) ;
			file.close() ;
			subProcess->closeWriteChannel() ;
		}

		while(!subProcess->waitForFinished(100)) {

			QFile file(this) ;
			file.setFileName(QString("/proc/%1/statm").arg(subProcess->pid())) ;
			file.open(QIODevice::ReadOnly | QIODevice::Text) ;
			QTextStream salida(&file) ;

			int shit ;
			int tmpMemUsed ;

			salida >> shit >> shit >> shit >> shit >> shit >> tmpMemUsed ;

			file.close() ;

			tmpMemUsed = (tmpMemUsed * PAGESIZE) - memOffset ;

			if(tmpMemUsed > memUsed) memUsed = tmpMemUsed ;

			if(memLimit && memLimit < memUsed) subProcess->kill() ;

		}

		getrusage(RUSAGE_CHILDREN,&execusage) ;

		QFile file(this) ;

		file.setFileName(directory + "/cpuUsage") ;
		file.open(QIODevice::WriteOnly | QIODevice::Text) ;
		file.write(QString::number((execusage.ru_utime.tv_usec / 1000) + (execusage.ru_utime.tv_sec * 1000)).toAscii()) ;
		file.close() ;

		file.setFileName(directory + "/memUsage") ;
		file.open(QIODevice::WriteOnly | QIODevice::Text) ;
		file.write(QString::number(memUsed).toAscii()) ;
		file.close() ;

		file.setFileName(directory + "/stdout") ;
		file.open(QIODevice::WriteOnly) ;
		file.write(subProcess->readAllStandardOutput()) ;
		file.close() ;

		file.setFileName(directory + "/stderr") ;
		file.open(QIODevice::WriteOnly) ;
		file.write(subProcess->readAllStandardError()) ;
		file.close() ;

		_exit(0) ;
	}

	int pid_status ;

	waitpid(pid,&pid_status,0) ;

	int exitCode, exitStatus ;

	QFile file(this) ;
	file.setFileName(directory + "/exitCode") ;
	file.open(QIODevice::ReadOnly | QIODevice::Text) ;
	QTextStream exitCodeData(&file) ;
	exitCodeData >> exitCode ;
	file.close() ;

	file.setFileName(directory + "/exitStatus") ;
	file.open(QIODevice::ReadOnly | QIODevice::Text) ;
	QTextStream exitStatusData(&file) ;
	exitStatusData >> exitStatus ;
	file.close() ;

	emit finished(exitCode,(QProcess::ExitStatus)exitStatus,this) ;

}
Exemplo n.º 29
0
Arquivo: entrada.c Projeto: gllort/mud
void habitacion() {
    nombre("$N$2Entrada a los Reinos");

    salida("comun", "/dominios/cielo/comun.c");
}