Ejemplo n.º 1
0
void create_module_info(TString dir = "/castor/cern.ch/user/r/rougny/vcalH2L_7/GainRun_173484"){
  ofstream t;
  t.open("module_info.txt");
  if(! t.is_open()){
    cout << "[create_module_info] Could not open output txt file. Exiting ..." << endl;
    exit(1);
  }

  for(int i=0 ; i<40 ; ++i){
    ostringstream f_str("");
    f_str << "rfio://" << dir << "/" << i << ".root";
    cout << "Opening file : " << f_str.str() << endl;
    TFile* f = TFile::Open(f_str.str().c_str() , "READ");
    vector<TString> dir_list = makedirlist(f , "Module");
    
    for(int m = 0 ; m < dir_list.size() ; ++m){
      
      TDirectory* dir = f->GetDirectory(dir_list[m]);
      int detid = getDetId(((TH1*) dir->Get(((TKey*) dir->GetListOfKeys()->At(0))->GetName()))->GetName());
    
      t << detid << "  " << i << "  " << dir_list[m].Remove(0,dir_list[m].First('y')+2) << endl;
    
    }


    f->Close();
  
  }

  t.close();

}
Ejemplo n.º 2
0
/* up date the number of file or directory in the dialog box */
VOID
updatnum( int index, int num )
{
	if ( d_display )
	{
	  f_str( cpbox, index, num );
	  if ( wind_update( 0x0101 ) )
	  {
	    if ( w_draw_fld( whandle, cpbox, index ) == WM_CLOSE )
	      f_cancel = TRUE;

	    wind_update(0);
	  }
	}
}
Ejemplo n.º 3
0
void get_module_summary(int nRun , TString module = "0"){
  ostringstream f_str("");
  f_str << "Run_" << nRun << "/Summary_Run" << nRun << "/Comp_Run" << nRun << ".root" ;
  TFile* f = new TFile(f_str.str().c_str() , "READ");

  PIX_FINAL<TH1F*> h;
  h.gain   		= (TH1F*) f->Get("SUM_Gain_whole");
  h.pedestal   		= (TH1F*) f->Get("SUM_Pedestal_whole");
  h.err_gain   		= (TH1F*) f->Get("SUM_ErrorGain_whole");
  h.err_pedestal   	= (TH1F*) f->Get("SUM_ErrorPedestal_whole");
  h.plateau   		= (TH1F*) f->Get("SUM_GainSaturate_whole");
  h.dynamic_range   	= (TH1F*) f->Get("SUM_GainDynamicRange_whole");
  h.low_point   	= (TH1F*) f->Get("SUM_GainLowPoint_whole");
  h.high_point   	= (TH1F*) f->Get("SUM_GainHighPoint_whole");
  h.chi2NDF   		= (TH1F*) f->Get("SUM_GainChi2NDF_whole");
  h.chi2_prob   	= (TH1F*) f->Get("SUM_GainChi2Prob_whole");
  h.fit_result   	= (TH1F*) f->Get("SUM_GainFitResult_whole");
  h.n_points   		= (TH1F*) f->Get("SUM_GainNPoints_whole");
  h.frac_bad_fit   	= (TH1F*) f->Get("SUM_frac_bad_fit_whole");
  h.frac_gain_high   	= (TH1F*) f->Get("SUM_frac_gain_high_whole");
  
  h.gain->ResetBit(TH1::kCanRebin);
  int bin = h.gain->GetXaxis()->FindBin(module);
  if (bin==0){
    cout << "Module " << module << " is not present ..." << endl;
    return;
  }
  
  cout << "Module : " << module << endl;
  cout << "gain           : " << h.gain->GetBinContent(bin) << endl;	 
  cout << "pedestal       : " << h.pedestal->GetBinContent(bin) << endl;	 
  cout << "err_gain       : " << h.err_gain->GetBinContent(bin) << endl;	 
  cout << "err_pedestal   : " << h.err_pedestal  ->GetBinContent(bin) << endl; 
  cout << "plateau        : " << h.plateau->GetBinContent(bin) << endl;	 
  cout << "dynamic_range  : " << h.dynamic_range ->GetBinContent(bin) << endl; 
  cout << "low_point      : " << h.low_point->GetBinContent(bin) << endl;	 
  cout << "high_point     : " << h.high_point  ->GetBinContent(bin) << endl; 
  cout << "chi2NDF        : " << h.chi2NDF->GetBinContent(bin) << endl;	 
  cout << "chi2_prob      : " << h.chi2_prob->GetBinContent(bin) << endl;	 
  cout << "fit_result     : " << h.fit_result ->GetBinContent(bin) << endl;  
  cout << "n_points       : " << h.n_points->GetBinContent(bin) << endl;	 
  cout << "frac_bad_fit   : " << h.frac_bad_fit  ->GetBinContent(bin) << endl; 
  cout << "frac_gain_high : " << h.frac_gain_high ->GetBinContent(bin) << endl; 
  
  f->Close();
}
// When OnInit is called, a render context (in this case GLUT-Window) 
// is already available!
void  myWindow::OnInit()
{
    this->createSpiralSphere(1.0, 32, 32);
    this->createGrid(10);
    this->createCube();
    
	glClearColor(0.3f, 0.3f, 0.4f, 0.0f);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);

    

	// ********************************************
    // Compiling the shader programms
    //*********************************************

	// Do your GLEW experiments here:
    if (GLEW_ARB_shading_language_100) 
    { 
        std::cout << "GLEW_ARB_shading_language_100" << std::endl;
        int major, minor, revision;
        const GLubyte* sVersion = glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
        if (glGetError() == GL_INVALID_ENUM)
        {
            major = 1; minor = 0; revision=51;
        }
        else
        {
            std::string version((char*)sVersion);
            std::cout << version.c_str() << std::endl;
        }

        // Load vertex Shader
        this->vertShader = glCreateShader (GL_VERTEX_SHADER);
        if ( 0 == this->vertShader )
        {
            std::cout << "Error creating vertex shader" << std::endl;
        }

        std::ifstream v_shader_file("DiffuseShadingVShader.vert", std::ifstream::in);
        std::string v_str((std::istreambuf_iterator<char>(v_shader_file)), std::istreambuf_iterator<char>());
        const char* vs_code_array[] = {v_str.c_str()};
        
        glShaderSource( this->vertShader, 1, vs_code_array, NULL);

        // Compilar el shader
        glCompileShader( this->vertShader );

        // verificar resultado de la compilacion
        GLint vs_compilation_result;
        glGetShaderiv( this->vertShader, GL_COMPILE_STATUS, &vs_compilation_result );
        if( GL_FALSE == vs_compilation_result )
        {
            std::cout << "Vertex shader compilation failed!\n" << std::endl;
            GLint logLen;
            glGetShaderiv( this->vertShader, GL_INFO_LOG_LENGTH, &logLen );
            if( logLen > 0 )
            {
                char * log = (char *)malloc(logLen);
                GLsizei written;
                glGetShaderInfoLog(vertShader, logLen, &written, log);
                std::cout << "Shader log: " << log << std::endl;
                free(log);
            }
        }

         // Load fragment Shader
        this->fragShader = glCreateShader (GL_FRAGMENT_SHADER);
        if ( 0 == this->fragShader )
        {
            std::cout << "Error creating fragment shader" << std::endl;
        }

        std::ifstream f_shader_file("DiffuseShadingFShader.frag", std::ifstream::in);
        std::string f_str((std::istreambuf_iterator<char>(f_shader_file)), std::istreambuf_iterator<char>());
        const char* fs_code_array[] = {f_str.c_str()};
        
        glShaderSource( this->fragShader, 1, fs_code_array, NULL);

        // Compilar el shader
        glCompileShader( this->fragShader );

        // verificar resultado de la compilacion
        GLint fs_compilation_result;
        glGetShaderiv( this->fragShader, GL_COMPILE_STATUS, &fs_compilation_result );
        if( GL_FALSE == fs_compilation_result )
        {
            std::cout << "Fragment shader compilation failed!\n" << std::endl;
            GLint logLen;
            glGetShaderiv( this->fragShader, GL_INFO_LOG_LENGTH, &logLen );
            if( logLen > 0 )
            {
                char * log = (char *)malloc(logLen);
                GLsizei written;
                glGetShaderInfoLog( this->fragShader, logLen, &written, log);
                std::cout << "Shader log: " << log << std::endl;
                free(log);
            }
        }
	// *******************************************

    // *******************************************
    // Linking the shader programms
    // *******************************************
        this->programHandle = glCreateProgram();
        if ( 0 == this->programHandle )
        {
            std::cout << "Error creating program object" << std::endl;
        }
        else
        {
            glAttachShader( this->programHandle, this->vertShader );
            glAttachShader( this->programHandle, this->fragShader );

            glLinkProgram( this->programHandle );

            GLint status;
            glGetProgramiv( this->programHandle, GL_LINK_STATUS, &status );
            if( GL_FALSE == status )
            {
                std::cout << "Failed to link shader program!\n" << std::endl;
                GLint logLen;
                glGetProgramiv( this->programHandle, GL_INFO_LOG_LENGTH, &logLen);
                if( logLen > 0 )
                {
                    char * log = (char *)malloc(logLen);
                    GLsizei written;
                    glGetProgramInfoLog(programHandle, logLen, &written, log);
                    std::cout << "Program log: \n%s" << std::endl;
                    free(log);
                }
            }
            else
            {
                glUseProgram( this->programHandle );
            }
        }
    }
}
Ejemplo n.º 5
0
void EditFunction::accept()
{
  QString f_str( editfunctionpage->equation->text() );
        
        if ( m_id!=-1 )
                m_parser->fixFunctionName(f_str, XParser::Function, m_id);
        else
                m_parser->fixFunctionName(f_str, XParser::Function);
	if ( f_str.at(0)== 'x' || f_str.at(0)== 'y' || f_str.at(0)== 'r')
	{
		KMessageBox::error( this, i18n("You can only define plot functions in this dialog"));
		return;
	}
	
	Ufkt tmp_ufkt; //all settings are saved here until we know that no errors have appeared
	if( editfunctionpage->customMinRange->isChecked() )
	{
	  tmp_ufkt.usecustomxmin = true;
	  tmp_ufkt.str_dmin = editfunctionpage->min->text();
	  tmp_ufkt.dmin = m_parser->eval( editfunctionpage->min->text() );
	  if (m_parser->parserError() != 0)
	  {
	    showPage(0);
	    editfunctionpage->min->setFocus();
	    editfunctionpage->min->selectAll();
	    return;
	  }
	}
	else
	  tmp_ufkt.usecustomxmin = false;
	if( editfunctionpage->customMaxRange->isChecked() )
	{
	  tmp_ufkt.usecustomxmax = true;
	  tmp_ufkt.str_dmax= editfunctionpage->max->text();
	  tmp_ufkt.dmax = m_parser->eval( editfunctionpage->max->text() );
	  if (m_parser->parserError() != 0)
	  {
	    showPage(0);
	    editfunctionpage->max->setFocus();
	    editfunctionpage->max->selectAll();
	    return;
	  }
	}
	else
	  tmp_ufkt.usecustomxmax = false;
	
	if( tmp_ufkt.usecustomxmin && tmp_ufkt.usecustomxmax )
	{
		if ( tmp_ufkt.dmin >=  tmp_ufkt.dmax)
		{
			KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value"));
			showPage(0);
			editfunctionpage->min->setFocus();
			editfunctionpage->min->selectAll();
			return;
		}
		
		if (  tmp_ufkt.dmin<View::xmin || tmp_ufkt.dmax>View::xmax )
		{
			KMessageBox::error(this,i18n("Please insert a minimum and maximum range between %1 and %2").arg(View::xmin).arg(View::xmax) );
			showPage(0);
			editfunctionpage->min->setFocus();
			editfunctionpage->min->selectAll();
			return;
		}
	}

	tmp_ufkt.linewidth = editfunctionpage->lineWidth->value();
	tmp_ufkt.color = editfunctionpage->color->color().rgb();
	
	if (editintegralpage->showIntegral->isChecked() )
	{
		double initx = m_parser->eval(editintegralpage->txtInitX->text());
		tmp_ufkt.startx = initx;
		tmp_ufkt.str_startx = editintegralpage->txtInitX->text();
		if (m_parser->parserError(false) != 0)
		{
			KMessageBox::error(this,i18n("Please insert a valid x-value"));
			showPage(2);
			editintegralpage->txtInitX->setFocus();
                        editintegralpage->txtInitX->selectAll();
			return;
		}
		
		double inity = m_parser->eval(editintegralpage->txtInitY->text());
		tmp_ufkt.starty = inity;
		tmp_ufkt.str_starty = editintegralpage->txtInitY->text();
		if (m_parser->parserError(false) != 0)
		{
			KMessageBox::error(this,i18n("Please insert a valid y-value"));
			showPage(2);
			editintegralpage->txtInitY->setFocus();
			editintegralpage->txtInitY->selectAll();
			return;
		}
		tmp_ufkt.integral_mode = 1;
	}
	else
		tmp_ufkt.integral_mode = 0;

	tmp_ufkt.integral_color = editintegralpage->color->color().rgb();
	tmp_ufkt.integral_use_precision = editintegralpage->customPrecision->isChecked();
	tmp_ufkt.integral_precision = editintegralpage->precision->value();
	tmp_ufkt.integral_linewidth = editintegralpage->lineWidth->value();

        tmp_ufkt.f_mode = !editfunctionpage->hide->isChecked();
	
	if( editfunctionpage->useSlider->isChecked() )
		tmp_ufkt.use_slider = editfunctionpage->listOfSliders->currentItem(); //specify which slider that will be used
	else
	{
		tmp_ufkt.use_slider = -1;
		if ( editfunctionpage->useNoParameter->isChecked() || m_parameter.isEmpty() )
			m_parameter.clear();
		else
		{
			tmp_ufkt.parameters = m_parameter;
		}
			
	}

	tmp_ufkt.f1_mode =  editderivativespage->showDerivative1->isChecked();
	tmp_ufkt.f1_linewidth = editderivativespage->lineWidthDerivative1->value();
	tmp_ufkt.f1_color = editderivativespage->colorDerivative1->color().rgb();
	
	tmp_ufkt.f2_mode =  editderivativespage->showDerivative2->isChecked();
	tmp_ufkt.f2_linewidth = editderivativespage->lineWidthDerivative2->value();
	tmp_ufkt.f2_color = editderivativespage->colorDerivative2->color().rgb();
	
	if ( f_str.contains('y') != 0 && ( tmp_ufkt.f_mode || tmp_ufkt.f1_mode || tmp_ufkt.f2_mode) )
	{
		KMessageBox::error( this, i18n( "Recursive function is only allowed when drawing integral graphs") );
		return;
        }
        
        Ufkt *added_ufkt;
        if( m_id != -1 )  //when editing a function: 
        {
                int const ix = m_parser->ixValue(m_id);
                if ( ix == -1) //The function could have been deleted
                {
                        KMessageBox::error(this,i18n("Function could not be found"));
                        return;
                }
                added_ufkt =  &m_parser->ufkt[ix];
                QString const old_fstr = added_ufkt->fstr;
                if((  (!m_parameter.isEmpty() && editfunctionpage->useList->isChecked() ) || editfunctionpage->useSlider->isChecked() ) && !functionHas2Arguments() )
                        fixFunctionArguments(f_str); //adding an extra argument for the parameter value
                added_ufkt->fstr = f_str;
                m_parser->reparse(added_ufkt); //reparse the funcion
                if ( m_parser->parserError() != 0)
                {
                        added_ufkt->fstr = old_fstr;
                        m_parser->reparse(added_ufkt); 
                        raise();
                        showPage(0);
                        editfunctionpage->equation->setFocus();
                        editfunctionpage->equation->selectAll();
                        return;
                }
        }
        else //creating a new function
        {
                if((  (!m_parameter.isEmpty() && editfunctionpage->useList->isChecked() ) || editfunctionpage->useSlider->isChecked() ) && !functionHas2Arguments() )
                        fixFunctionArguments(f_str); //adding an extra argument for the parameter value
                int const id = m_parser->addfkt( f_str ); //create a new function otherwise
                if( id == -1)
                {
                        m_parser->parserError();
                        raise();
                        showPage(0);
                        editfunctionpage->equation->setFocus();
                        editfunctionpage->equation->selectAll();
                        return;
                }
                added_ufkt =  &m_parser->ufkt.last();
        }
        //save all settings in the function now when we know no errors have appeared
	added_ufkt->f_mode = tmp_ufkt.f_mode;
	added_ufkt->f1_mode = tmp_ufkt.f1_mode;
	added_ufkt->f2_mode = tmp_ufkt.f2_mode;
	added_ufkt->integral_mode = tmp_ufkt.integral_mode;
	added_ufkt->integral_use_precision = tmp_ufkt.integral_use_precision;
	added_ufkt->linewidth = tmp_ufkt.linewidth;
	added_ufkt->f1_linewidth = tmp_ufkt.f1_linewidth;
	added_ufkt->f2_linewidth = tmp_ufkt.f2_linewidth;
	added_ufkt->integral_linewidth = tmp_ufkt.integral_linewidth;
	added_ufkt->str_dmin = tmp_ufkt.str_dmin;
	added_ufkt->str_dmax = tmp_ufkt.str_dmax;
	added_ufkt->dmin = tmp_ufkt.dmin;
	added_ufkt->dmax = tmp_ufkt.dmax;
	added_ufkt->str_startx = tmp_ufkt.str_startx;
	added_ufkt->str_starty = tmp_ufkt.str_starty;
	added_ufkt->oldx = tmp_ufkt.oldx;
	added_ufkt->starty = tmp_ufkt.starty;
	added_ufkt->startx = tmp_ufkt.startx;
	added_ufkt->integral_precision = tmp_ufkt.integral_precision;
	added_ufkt->color = tmp_ufkt.color;
	added_ufkt->f1_color = tmp_ufkt.f1_color;
	added_ufkt->f2_color = tmp_ufkt.f2_color;
	added_ufkt->integral_color = tmp_ufkt.integral_color;
	added_ufkt->parameters = tmp_ufkt.parameters;
	added_ufkt->use_slider = tmp_ufkt.use_slider;
	added_ufkt->usecustomxmin = tmp_ufkt.usecustomxmin;
	added_ufkt->usecustomxmax = tmp_ufkt.usecustomxmax;
        
    m_updatedfunction = added_ufkt;
	
	// call inherited method
	KDialogBase::accept();
}