//------------------------------------------------------------------------------
void PlotAlignmentValidation::plotChi2(const char *inputFile)
{
  // Opens the file (it should be OfflineValidation(Parallel)_result.root)
  // and reads and plots the norm_chi^2 and h_chi2Prob -distributions.

  // First set default style: plots are already formatted
  TStyle defStyle("Default","Default Style");
  defStyle.cd();
  gStyle->SetOptStat(1);
  TGaxis::SetMaxDigits(3);

  Bool_t errorflag = kTRUE;
  TFile* fi1 = new TFile(inputFile,"read");
  TDirectoryFile* mta1 = NULL;
  TDirectoryFile* mtb1 = NULL;
  TCanvas* normchi = NULL;
  TCanvas* chiprob = NULL;
  if (fi1 != NULL) {
    mta1 = (TDirectoryFile*) fi1->Get("TrackerOfflineValidationStandalone");
    if(mta1 != NULL) {
      mtb1 = (TDirectoryFile*) mta1->Get("GlobalTrackVariables");
      if(mtb1 != NULL) {
        normchi = (TCanvas*) mtb1->Get("h_normchi2");
	chiprob = (TCanvas*) mtb1->Get("h_chi2Prob");
        if (normchi != NULL && chiprob != NULL) {
          errorflag = kFALSE;
        }
      }
    }
  }
  if(errorflag)
  {
    std::cout << "PlotAlignmentValidation::plotChi2: Can't find data from given file,"
              << " no chi^2-plots produced" << std::endl;
    return;
  }

  // Small adjustments: move the legend right so that it doesn't block
  // the exponent of the y-axis scale
  TLegend* l = (TLegend*)findObjectFromCanvas(normchi, "TLegend");
  if (l != 0) {
    l->SetX1NDC(0.25);
  }
  l = (TLegend*)findObjectFromCanvas(chiprob, "TLegend");
  if (l != 0) {
    l->SetX1NDC(0.25);
  }

  chiprob->Draw();
  normchi->Draw();

  // EPS-files
  normchi->Print((outputDir + "/h_normchi2.eps").c_str());
  chiprob->Print((outputDir + "/h_chi2Prob.eps").c_str());

  // ROOT-files
  TFile fi2((outputDir + "/h_normchi2.root").c_str(), "recreate");
  normchi->Write();
  fi2.Close();

  TFile fi3((outputDir + "/h_chi2Prob.root").c_str(), "recreate");
  chiprob->Write();
  fi3.Close();

  fi1->Close();
  TGaxis::SetMaxDigits(4);

}
Exemple #2
0
void SCFonts::AddScalableFonts(const QString &path, QString DocName)
{
	//Make sure this is not empty or we will scan the whole drive on *nix
	//QString::null+/ is / of course.
	if (path.isEmpty())
		return;
	FT_Library library = NULL;
	QString pathfile, fullpath;
//	bool error;
//	error =
	FT_Init_FreeType( &library );
	QString pathname(path);
	if ( !pathname.endsWith("/") )
		pathname += "/";
	pathname=QDir::toNativeSeparators(pathname);
	QDir d(pathname, "*", QDir::Name, QDir::Dirs | QDir::Files | QDir::Readable);
	if ((d.exists()) && (d.count() != 0))
	{
		for (uint dc = 0; dc < d.count(); ++dc)
		{
			// readdir may return . or .., which we don't want to recurse
			// over. Skip 'em.
			if (d[dc] == "." || d[dc] == "..")
				continue;
			fullpath = pathname+d[dc];
			QFileInfo fi(fullpath);
			if (!fi.exists())      // Sanity check for broken Symlinks
				continue;
			
			qApp->processEvents();
			
			bool symlink = fi.isSymLink();
			if (symlink)
			{
				QFileInfo fi3(fi.readLink());
				if (fi3.isRelative())
					pathfile = pathname+fi.readLink();
				else
					pathfile = fi3.absoluteFilePath();
			}
			else
				pathfile = fullpath;
			QFileInfo fi2(pathfile);
			if (fi2.isDir()) 
			{
				if (symlink)
				{
					// Check if symlink points to a parent directory
					// in order to avoid infinite recursion
					QString fullpath2 = fullpath, pathfile2 = pathfile;
					if (ScCore->isWinGUI())
					{
						// Ensure both path use same separators on Windows
						fullpath2 = QDir::toNativeSeparators(fullpath2.toLower());
						pathfile2 = QDir::toNativeSeparators(pathfile2.toLower());
					}
					if (fullpath2.startsWith(pathfile2))
						continue;
				}
				if (DocName.isEmpty())
					AddScalableFonts(pathfile);
				continue;
			}
			QString ext = fi.suffix().toLower();
			QString ext2 = fi2.suffix().toLower();
			if ((ext != ext2) && (ext.isEmpty())) 
				ext = ext2;
			if ((ext == "ttc") || (ext == "dfont") || (ext == "pfa") || (ext == "pfb") || (ext == "ttf") || (ext == "otf"))
			{
				AddScalableFont(pathfile, library, DocName);
			}
#ifdef Q_OS_MAC
			else if (ext.isEmpty() && DocName.isEmpty())
			{
				bool error = AddScalableFont(pathfile, library, DocName);
				if (error)
					error = AddScalableFont(pathfile + "/..namedfork/rsrc",library, DocName);
			}
#endif				
		}
	}
	FT_Done_FreeType(library);
}