Esempio n. 1
0
/* Be careful about trying to compile over running programs (parallel make).
 * temp_file helps here. */
char *compile_info(const void *ctx, const char *dir)
{
	char *info_c_file, *info, *compiled, *output;
	int fd;

	/* Copy it to a file with proper .c suffix. */
	info = grab_file(ctx, tal_fmt(ctx, "%s/_info", dir));
	if (!info)
		return NULL;

	info_c_file = temp_file(ctx, ".c", "_info");
	fd = open(info_c_file, O_WRONLY|O_CREAT|O_EXCL, 0600);
	if (fd < 0)
		return NULL;
	if (!write_all(fd, info, tal_count(info)-1))
		return NULL;

	if (close(fd) != 0)
		return NULL;

	compiled = temp_file(ctx, "", "info");
	if (compile_and_link(ctx, info_c_file, find_ccan_dir(dir), "",
			     compiler, cflags, "", compiled, &output))
		return compiled;
	return NULL;
}
Esempio n. 2
0
void TripPrep::Trip_Processing::Write_Temp (void)
{
	Trip_Data *trip_ptr;
	Trip_Map_Itr trip_itr;
	Time_Map_Itr time_itr;

	//---- open the next temp file ----

	Trip_File temp_file (CREATE, BINARY);

	temp_file.Part_Flag (true);
	temp_file.Pathname (trip_file.Filename () + ".temp");
	temp_file.First_Open (false);
	temp_file.Open (num_temp++);

	//---- read records in sorted order ----

	if (exe->Trip_Sort () == TRAVELER_SORT) {
		for (trip_itr = traveler_sort.begin (); trip_itr != traveler_sort.end (); trip_itr++) {
			trip_ptr = trip_ptr_array [trip_itr->second];
			temp_file.Write_Trip (*trip_ptr);
			delete trip_ptr;
		}
		traveler_sort.clear ();
	} else {
		for (time_itr = time_sort.begin (); time_itr != time_sort.end (); time_itr++) {
			trip_ptr = trip_ptr_array [time_itr->second];
			temp_file.Write_Trip (*trip_ptr);
			delete trip_ptr;
		}
		time_sort.clear ();
	}
	temp_file.Close ();
	trip_ptr_array.clear ();
}
Esempio n. 3
0
/* Creates and adds an example file. */
static char *add_example(struct manifest *m, struct ccan_file *source,
			 struct doc_section *example)
{
	char *name, *linemarker;
	unsigned int i;
	int fd;
	struct ccan_file *f;

	name = tal_fmt(m, "example-%s-%s",
		       source->name, example->function);
	/* example->function == 'struct foo' */
	while (strchr(name, ' '))
		*strchr(name, ' ') = '_';

	name = temp_file(m, ".c", take(name));
	f = new_ccan_file(m, take(path_dirname(m, name)),
			  take(path_basename(m, name)));
	tal_steal(f, name);
	list_add_tail(&m->examples, &f->list);

	fd = open(f->fullname, O_WRONLY | O_CREAT | O_EXCL, 0600);
	if (fd < 0)
		return tal_fmt(m, "Creating temporary file %s: %s",
			       f->fullname, strerror(errno));

	/* Add #line to demark where we are from, so errors are correct! */
	linemarker = tal_fmt(f, "#line %i \"%s\"\n",
			     example->srcline+2, source->fullname);
	if (write(fd, linemarker, strlen(linemarker)) != (int)strlen(linemarker)) {
		close(fd);
		return cast_const(char *, "Failure writing to temporary file");
	}
Esempio n. 4
0
int
install_stdin(void)
    /* install what we get through stdin */
{
    int tmp_fd = 0;
    FILE *tmp_file = NULL;
    char *tmp_str = NULL;
    int c;
    short return_val = EXIT_OK;
	    	    
    tmp_fd = temp_file(&tmp_str);
    
    if( (tmp_file = fdopen(tmp_fd, "w")) == NULL )
	die_e("Could not fdopen file %s", tmp_str);

    while ( (c = getc(stdin)) != EOF )
	putc(c, tmp_file);

    fclose(tmp_file);
    close(tmp_fd);

    if ( make_file(tmp_str) == ERR )
	goto exiterr;
    else
	goto exit;

  exiterr:
	return_val = EXIT_ERR;    
  exit:
    if ( remove(tmp_str) != 0 )
	error_e("Could not remove %s", tmp_str);
    free(tmp_str);
    return return_val;

}
Esempio n. 5
0
/* Return a FILE pointer for a temporary file to fill with input for
   the pipeline.  */
FILE *
pex_input_file (struct pex_obj *obj, int flags, const char *in_name)
{
  char *name = (char *) in_name;
  FILE *f;

  /* This must be called before the first pipeline stage is run, and
     there must not have been any other input selected.  */
  if (obj->count != 0
      || (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO)
      || obj->next_input_name)
    {
      errno = EINVAL;
      return NULL;
    }

  name = temp_file (obj, flags, name);
  if (! name)
    return NULL;

  f = fopen (name, (flags & PEX_BINARY_OUTPUT) ? "wb" : "w");
  if (! f)
    {
      free (name);
      return NULL;
    }

  obj->input_file = f;
  obj->next_input_name = name;
  obj->next_input_name_allocated = (name != in_name);

  return f;
}
Esempio n. 6
0
/**
 * Read and return the current CPU temperature.
 */
int Throttle::readTemp() const
{
	int temp;
	std::ifstream temp_file(temp_fn);
	temp_file >> temp;
	return temp;
}
Esempio n. 7
0
File: unix.c Progetto: rennis250/sam
int
tempdisk(void)
{
        char buf[4096];
        int fd = temp_file(buf, sizeof buf);
        //if (fd >= 0)
                //remove(buf);
        return fd; 
}
QHash<QString, QString> RcsInterfaceTarDiff::getComment()
{
	QString file=temp_file();
	
	extract(file, "Properties.txt");
	
	QHash<QString, QString> list=readCommentsFromPropertiesFile(file);
	
	QFile::remove(file);
	
	return list;
}
Esempio n. 9
0
/* Compile multiple object files into a single.  Returns NULL if fails. */
char *link_objects(const void *ctx, const char *basename,
		   const char *objs, char **errmsg)
{
	char *file = temp_file(ctx, ".o", basename);

	if (compile_verbose)
		printf("Linking objects into %s\n", file);

	if (run_command(ctx, NULL, errmsg, "ld -r -o %s %s", file, objs))
		return file;

	talloc_free(file);
	return NULL;
}
Esempio n. 10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("Userfields Interface");
    init_flag=0;
    //ui->tableWidget->hideColumn(0);
    QFile config_file(".\\config.ini");

    QSettings setting(".\\config.ini",QSettings::IniFormat);

    if (!config_file.exists() || setting.status() != QSettings::NoError)
    {
        setting.setValue("filename","C:/program Files (x86)/Zeiss/CALYPSO 5.4/opt/om/protform/userfields.ini");
    }
    fileName = setting.value("filename").toString();

    QFile origin_name(fileName);
    if (!origin_name.exists())
    {
        if (origin_name.copy(":/userfields.ini",fileName))
        {
            QMessageBox msgbox(QMessageBox::Warning, tr("Warning"),
                               tr("as your file didn't exist.\nI use a default one to instead."),0,this);
            msgbox.addButton(tr("Continue"), QMessageBox::AcceptRole);
            msgbox.exec();
        }

    }
    origin_name.setPermissions(QFile::Permission(0x7777));
    origin_name.remove("./qt_settings_format.ini");
    origin_name.copy("./qt_settings_format.ini");

    QFile temp_file("./qt_settings_format.ini");
    temp_file.setPermissions(QFile::Permission(0x7777));
    calypso = new QSettings("./qt_settings_format.ini",QSettings::IniFormat);

    all_list = calypso->childGroups();
    QString str;
    foreach(str,all_list)
    {
        calypso->beginGroup(str);
        QStringList sub_list = calypso->childKeys();
        calypso->endGroup();
        if (sub_list.contains("name"))
            u_field_list.push_back(str);
        else
            u_value_list.push_back(str);
    }
static void Iterate_all_files(benchmark::State& state) {
  std::unique_ptr<TemporaryFile> temp_file(CreateZip());
  ZipArchiveHandle handle;
  void* iteration_cookie;
  ZipEntry data;
  ZipString name;

  while (state.KeepRunning()) {
    OpenArchive(temp_file->path, &handle);
    StartIteration(handle, &iteration_cookie);
    while (Next(iteration_cookie, &data, &name) == 0) {
    }
    EndIteration(iteration_cookie);
    CloseArchive(handle);
  }
}
static void FindEntry_no_match(benchmark::State& state) {
  // Create a temporary zip archive.
  std::unique_ptr<TemporaryFile> temp_file(CreateZip());
  ZipArchiveHandle handle;
  ZipEntry data;

  // In order to walk through all file names in the archive, look for a name
  // that does not exist in the archive.
  std::string_view name("thisFileNameDoesNotExist");

  // Start the benchmark.
  while (state.KeepRunning()) {
    OpenArchive(temp_file->path, &handle);
    FindEntry(handle, name, &data);
    CloseArchive(handle);
  }
}
Esempio n. 13
0
static bool compile(const void *ctx,
		    struct manifest *m,
		    struct ccan_file *file,
		    char **output)
{
	file->compiled[COMPILE_NORMAL] = temp_file(ctx, "", file->fullname);
	if (!compile_and_link(ctx, file->fullname, ccan_dir,
			      example_obj_list(m, file),
			      compiler, cflags,
			      lib_list(m), file->compiled[COMPILE_NORMAL],
			      output)) {
		/* Don't keep failures, even with --keep */
		unlink(file->compiled[COMPILE_NORMAL]);
		file->compiled[COMPILE_NORMAL] = NULL;
		return false;
	}
	return true;
}
static QString make_temp_dir()
{
	QString dir=temp_file();
	
	dir=QFileInfo(dir).fileName();
	
	QDir temp=QDir::temp();
	
	//printf("Temp dir %s\n", temp.path().toLocal8Bit().data() );
	
	if(!temp.mkdir(dir))
	{
		printf("[%s:make_temp_dir] Error: Dir %s can not be make.\n", __FILE__, dir.toLocal8Bit().data() );
		exit(0);
	}
	
	temp.cd(dir);
	
	return temp.path();
}
Esempio n. 15
0
static BOOL extract(LPVOID cdata, DWORD csz) {
    HANDLE h;
    WCHAR tempnam[MAX_PATH+1] = {0};
    BOOL ret = true;
    HZIP zipf;
    ZIPENTRYW ze;
    ZRESULT res;
    int nitems;
    HRESULT hr;
    IProgressDialog *pd = NULL;

    hr = CoCreateInstance(CLSID_ProgressDialog, NULL,
            CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pd));

    if (FAILED(hr)) { show_error(L"Failed to create progress dialog"); return false; }
    pd->SetTitle(L"Extracting Calibre Portable");
    pd->SetLine(1, L"Decompressing data...", true, NULL);

    h = temp_file(tempnam);
    if (h == INVALID_HANDLE_VALUE) return false;

    pd->StartProgressDialog(NULL, NULL, PROGDLG_NORMAL | PROGDLG_AUTOTIME | PROGDLG_NOCANCEL, NULL);
    if (!decompress(cdata, csz, h, pd)) { ret = false; goto end; }
    SetFilePointer(h, 0, NULL, FILE_BEGIN);
    zipf = OpenZip(h, 0, ZIP_HANDLE);
    if (zipf == 0) { show_last_error(L"Failed to open zipped portable data"); ret = false; goto end; }

    res = GetZipItem(zipf, -1, &ze);
    if (res != ZR_OK) { show_zip_error(L"Failed to get count of items in portable data", L"", res); ret = false; goto end;}
    nitems = ze.index;

    pd->SetLine(1, L"Copying files...", true, NULL);
    if (!unzip(zipf, nitems, pd)) { ret = false; goto end; }
end:
    pd->StopProgressDialog();
    pd->Release();
    CloseHandle(h);
    DeleteFile(tempnam);
    return ret;
}
Esempio n. 16
0
const char *
pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable,
       	                char * const * argv, char * const * env,
                        const char *orig_outname, const char *errname,
                  	int *err)
{
  const char *errmsg;
  int in, out, errdes;
  char *outname;
  int outname_allocated;
  int p[2];
  int toclose;
  pid_t pid;

  in = -1;
  out = -1;
  errdes = -1;
  outname = (char *) orig_outname;
  outname_allocated = 0;

  /* If the user called pex_input_file, close the file now.  */
  if (obj->input_file)
    {
      if (fclose (obj->input_file) == EOF)
        {
          errmsg = "closing pipeline input file";
          goto error_exit;
        }
      obj->input_file = NULL;
    }

  /* Set IN.  */

  if (obj->next_input_name != NULL)
    {
      /* We have to make sure that the previous process has completed
	 before we try to read the file.  */
      if (!pex_get_status_and_time (obj, 0, &errmsg, err))
	goto error_exit;

      in = obj->funcs->open_read (obj, obj->next_input_name,
				  (flags & PEX_BINARY_INPUT) != 0);
      if (in < 0)
	{
	  *err = errno;
	  errmsg = "open temporary file";
	  goto error_exit;
	}
      if (obj->next_input_name_allocated)
	{
	  free (obj->next_input_name);
	  obj->next_input_name_allocated = 0;
	}
      obj->next_input_name = NULL;
    }
  else
    {
      in = obj->next_input;
      if (in < 0)
	{
	  *err = 0;
	  errmsg = "pipeline already complete";
	  goto error_exit;
	}
    }

  /* Set OUT and OBJ->NEXT_INPUT/OBJ->NEXT_INPUT_NAME.  */

  if ((flags & PEX_LAST) != 0)
    {
      if (outname == NULL)
	out = STDOUT_FILE_NO;
      else if ((flags & PEX_SUFFIX) != 0)
	{
	  outname = concat (obj->tempbase, outname, NULL);
	  outname_allocated = 1;
	}
      obj->next_input = -1;
    }
  else if ((obj->flags & PEX_USE_PIPES) == 0)
    {
      outname = temp_file (obj, flags, outname);
      if (! outname)
        {
          *err = 0;
          errmsg = "could not create temporary file";
          goto error_exit;
        }

      if (outname != orig_outname)
        outname_allocated = 1;

      if ((obj->flags & PEX_SAVE_TEMPS) == 0)
	{
	  pex_add_remove (obj, outname, outname_allocated);
	  outname_allocated = 0;
	}

      /* Hand off ownership of outname to the next stage.  */
      obj->next_input_name = outname;
      obj->next_input_name_allocated = outname_allocated;
      outname_allocated = 0;
    }
  else
    {
      if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_OUTPUT) != 0) < 0)
	{
	  *err = errno;
	  errmsg = "pipe";
	  goto error_exit;
	}

      out = p[WRITE_PORT];
      obj->next_input = p[READ_PORT];
    }

  if (out < 0)
    {
      out = obj->funcs->open_write (obj, outname,
				    (flags & PEX_BINARY_OUTPUT) != 0);
      if (out < 0)
	{
	  *err = errno;
	  errmsg = "open temporary output file";
	  goto error_exit;
	}
    }

  if (outname_allocated)
    {
      free (outname);
      outname_allocated = 0;
    }

  /* Set ERRDES.  */

  if (errname != NULL && (flags & PEX_STDERR_TO_PIPE) != 0)
    {
      *err = 0;
      errmsg = "both ERRNAME and PEX_STDERR_TO_PIPE specified.";
      goto error_exit;
    }

  if (obj->stderr_pipe != -1)
    {
      *err = 0;
      errmsg = "PEX_STDERR_TO_PIPE used in the middle of pipeline";
      goto error_exit;
    }

  if (errname == NULL)
    {
      if (flags & PEX_STDERR_TO_PIPE)
	{
	  if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_ERROR) != 0) < 0)
	    {
	      *err = errno;
	      errmsg = "pipe";
	      goto error_exit;
	    }
	  
	  errdes = p[WRITE_PORT];
	  obj->stderr_pipe = p[READ_PORT];	  
	}
      else
	{
	  errdes = STDERR_FILE_NO;
	}
    }
  else
    {
      errdes = obj->funcs->open_write (obj, errname, 
				       (flags & PEX_BINARY_ERROR) != 0);
      if (errdes < 0)
	{
	  *err = errno;
	  errmsg = "open error file";
	  goto error_exit;
	}
    }

  /* If we are using pipes, the child process has to close the next
     input pipe.  */

  if ((obj->flags & PEX_USE_PIPES) == 0)
    toclose = -1;
  else
    toclose = obj->next_input;

  /* Run the program.  */

  pid = obj->funcs->exec_child (obj, flags, executable, argv, env,
				in, out, errdes, toclose, &errmsg, err);
  if (pid < 0)
    goto error_exit;

  ++obj->count;
  obj->children = XRESIZEVEC (pid_t, obj->children, obj->count);
  obj->children[obj->count - 1] = pid;

  return NULL;

 error_exit:
  if (in >= 0 && in != STDIN_FILE_NO)
    obj->funcs->close (obj, in);
  if (out >= 0 && out != STDOUT_FILE_NO)
    obj->funcs->close (obj, out);
  if (errdes >= 0 && errdes != STDERR_FILE_NO)
    obj->funcs->close (obj, errdes);
  if (outname_allocated)
    free (outname);
  return errmsg;
}
Esempio n. 17
0
void TripPrep::Trip_Processing::Temp_Time_Write (int part)
{
	int num, first_num, partition;
	bool stat;
	string process_type;

	Trip_Data *trip_ptr, *merge_ptr;

	Time_Index time_index, last_time, first_time, *time_ptr;
	Time_Map_Itr time_itr;
	Select_Map_Itr sel_itr;

	//---- open the temp files ----

	Partition_Files <Trip_File> temp_file_set;
	Partition_Data <Trip_Data> temp_trip_set;
	Partition_Data <Time_Index> time_rec_set;

	Trip_File temp_file (READ, BINARY);

	temp_file.Part_Flag (true);
	temp_file.Pathname (trip_file.Filename () + ".temp");

	temp_file_set.Initialize (&temp_file, num_temp);

	trip_ptr = 0;
	temp_trip_set.Initialize (num_temp);
	temp_trip_set.push_back (trip_ptr);

	time_rec_set.Initialize (num_temp + 1);

	//---- initialize the first index for each partition -----

	for (num = 0; num <= num_temp; num++) {
		if (num == num_temp) {
			time_itr = time_sort.begin ();
			stat = (time_itr != time_sort.end ());

			if (stat) {
				trip_ptr = trip_ptr_array [time_itr->second];
			} else {
				trip_ptr = 0;
			}
			temp_trip_set [num] = trip_ptr;
		} else {
			trip_ptr = temp_trip_set [num];
			stat = temp_file_set [num]->Read_Trip (*trip_ptr);
		}
		time_ptr = time_rec_set [num];

		if (stat) {
			trip_ptr->Get_Time_Index (*time_ptr);
		} else {
			time_ptr->Set (MAX_INTEGER, 0, 0);
		}
	}

	//---- write the process message ----

	if (exe->merge_flag) {
		process_type = "Merging";
		if (!merge_file.Open (part)) {
			MAIN_LOCK 
			exe->Error (String ("Opening %s") % merge_file.Filename ()); 
			END_LOCK
		}
int main( int argc,char * argv[] )
{
	QApplication a( argc,argv ) ;

	MainWindow w( []( const QVector<QString>& exe,const QString& keyFile,const QString& password ){

		/*
		 * TODO: look into passing the passphrase more securely
		 */

		QString arg = QString( "%1 --extract -sf %2 -xf - -p %3" ).arg( exe.first(),keyFile,password ) ;

		QProcess p ;

		p.start( arg ) ;

		p.waitForFinished( -1 ) ;

		QByteArray key = p.readAllStandardOutput() ;

		p.close() ;

		if( key.isEmpty() ){

			return key ;
		}else{

			key = "\n-----BEGIN PGP MESSAGE-----\n\n" + key + "-----END PGP MESSAGE-----\n" ;

			QString temp_path = QString( "%1/%2/" ).arg( QDir::homePath(),"/.zuluCrypt/" ) ;

			QDir d ;
			d.mkpath( temp_path ) ;

			temp_path += QString( ".tomb-%1" ).arg( QString::number( getpid() ) ) ;
			/*
			 * temp_path will have something like "/home/ink/.zuluCrypt/.tomb-3452"
			 * this will be a path to a temporary file we will pass to gpg since gpg expects a keyfile path
			 * TODO: look into skipping creating a temporary file and do everything in memory
			 */
			QFile temp_file( temp_path ) ;

			temp_file.open( QIODevice::WriteOnly ) ;
			temp_file.write( key ) ;
			temp_file.close() ;

			key = plugins::gpg( QVector<QString>{ exe.at( 1 ) },temp_path,password ) ;

			temp_file.setFileName( temp_path ) ;
			temp_file.open( QIODevice::WriteOnly ) ;

			uchar * m = temp_file.map( 0,temp_file.size() ) ;

			if( m ){
				memset( m,'\0',temp_file.size() ) ;
				temp_file.unmap( m ) ;
			}
			temp_file.close() ;
			temp_file.remove() ;
			return key ;
		}
	} ) ;

	w.setToken( argv ) ;
	w.setApplicationName( "tomb" ) ;
	w.setkeyLabel( QObject::tr( "Enter tomb/steghide Key Below" ) ) ;
	w.setkeyFileLabel( QObject::tr( "Enter A Path To A tomb/steghide Keyfile Below" ) ) ;

	w.setExe( { "steghide","gpg" } ) ;

	w.Show() ;

	return a.exec() ;
}
Esempio n. 19
0
FILE *
create_mail(cl_t * line, char *subject, char *content_type, char *encoding,
            char **env)
    /* create a temp file and write in it a mail header */
{
    /* create temporary file for stdout and stderr of the job */
    int mailfd = temp_file(NULL);
    FILE *mailf = fdopen(mailfd, "r+");
    char hostname[USER_NAME_LEN];
    /* is this a complete mail address ? (ie. with a "@", not only a username) */
    char add_hostname = 0;
    int i = 0;

    if (mailf == NULL)
        die_e("Could not fdopen() mailfd");

#ifdef HAVE_GETHOSTNAME
    if (gethostname(hostname, sizeof(hostname)) != 0) {
        error_e("Could not get hostname");
        hostname[0] = '\0';
    }
    else {
        /* it is unspecified whether a truncated hostname is NUL-terminated */
        hostname[USER_NAME_LEN - 1] = '\0';

        /* check if mailto is a complete mail address */
        add_hostname = (strchr(line->cl_mailto, '@') == NULL) ? 1 : 0;
    }
#else                           /* HAVE_GETHOSTNAME */
    hostname[0] = '\0';
#endif                          /* HAVE_GETHOSTNAME */

    /* write mail header */
    if (add_hostname)
        fprintf(mailf, "To: %s@%s\n", line->cl_mailto, hostname);
    else
        fprintf(mailf, "To: %s\n", line->cl_mailto);

    if (subject)
        fprintf(mailf, "Subject: fcron <%s@%s> %s: %s\n",
                line->cl_file->cf_user, (hostname[0] != '\0') ? hostname : "?",
                subject, line->cl_shell);
    else
        fprintf(mailf, "Subject: fcron <%s@%s> %s\n", line->cl_file->cf_user,
                (hostname[0] != '\0') ? hostname : "?", line->cl_shell);

    if (content_type == NULL) {
        fprintf(mailf, "Content-Type: text/plain; charset=%s\n",
                default_mail_charset);
    }
    else {
        /* user specified Content-Type header. */
        char *c = NULL;

        /* Remove new-lines or users could specify arbitrary mail headers!
         * (fcrontab should already prevent that, but better safe than sorry) */
        for (c = content_type; *c != '\0'; c++) {
            if (*c == '\n')
                *c = ' ';
        }
        fprintf(mailf, "Content-Type: %s\n", content_type);
    }

    if (encoding != NULL) {
        char *c = NULL;

        /* Remove new-lines or users could specify arbitrary mail headers!
         * (fcrontab should already prevent that, but better safe than sorry) */
        for (c = encoding; *c != '\0'; c++) {
            if (*c == '\n')
                *c = ' ';
        }
        fprintf(mailf, "Content-Transfer-Encoding: %s\n", encoding);
    }

    /* Add headers so as automated systems can identify that this message
     * is an automated one sent by fcron.
     * That's useful for example for vacation auto-reply systems: no need
     * to send such an automated response to fcron! */

    /* The Auto-Submitted header is
     * defined (and suggested by) RFC3834. */
    fprintf(mailf, "Auto-Submitted: auto-generated\n");

    /* See environ(7) and execle(3) to get documentation on environ:
     * it is an array of NULL-terminated strings, whose last entry is NULL */
    if (env != NULL) {
        for (i = 0; env[i] != NULL; i++) {
            fprintf(mailf, "X-Cron-Env: <%s>\n", env[i]);
        }
    }

    /* Final line return to end the header section: */
    fprintf(mailf, "\n");

    return mailf;
}
Esempio n. 20
0
void PlanPrep::Plan_Processing::Temp_Trip_Write (int part)
{
	int num, first_num;
	bool stat;
	string process_type;

	Plan_Data *plan_ptr, *merge_ptr;

	Trip_Index trip_index, last_trip, first_trip, *trip_ptr;
	Trip_Map_Itr trip_itr;

	//---- open the temp files ----

	Partition_Files <Plan_File> temp_file_set;
	Partition_Data <Plan_Data> temp_plan_set;
	Partition_Data <Trip_Index> trip_rec_set;

	Plan_File temp_file (READ, BINARY);

	temp_file.Part_Flag (true);
	temp_file.Pathname (plan_file->Filename () + ".temp");

	temp_file_set.Initialize (&temp_file, num_temp);

	plan_ptr = 0;
	temp_plan_set.Initialize (num_temp);
	temp_plan_set.push_back (plan_ptr);

	trip_rec_set.Initialize (num_temp + 1);

	//---- initialize the first index for each partition -----

	for (num = 0; num <= num_temp; num++) {
		if (num == num_temp) {
			trip_itr = traveler_sort.begin ();
			stat = (trip_itr != traveler_sort.end ());
			if (stat) {
				plan_ptr = plan_ptr_array [trip_itr->second];
			} else {
				plan_ptr = 0;
			}
			temp_plan_set [num] = plan_ptr;
		} else {
			plan_ptr = temp_plan_set [num];
			stat = temp_file_set [num]->Read_Plan (*plan_ptr);
		}
		trip_ptr = trip_rec_set [num];

		if (stat) {
			plan_ptr->Get_Index (*trip_ptr);
		} else {
			trip_ptr->Set (MAX_INTEGER);
		}
	}

	//---- write the process message ----

	if (exe->merge_flag) {
		process_type = "Merging";
		if (!merge_file->Open (part)) {
			MAIN_LOCK 
			exe->Error (String ("Opening %s") % merge_file->Filename ()); 
			END_LOCK
		}
Esempio n. 21
0
const char *
pex_run (struct pex_obj *obj, int flags, const char *executable,
         char * const * argv, const char *orig_outname, const char *errname,
         int *err)
{
    const char *errmsg;
    int in, out, errdes;
    char *outname;
    int outname_allocated;
    int p[2];
    long pid;

    in = -1;
    out = -1;
    errdes = -1;
    outname = (char *) orig_outname;
    outname_allocated = 0;

    /* If the user called pex_input_file, close the file now.  */
    if (obj->input_file)
    {
        if (fclose (obj->input_file) == EOF)
        {
            errmsg = "closing pipeline input file";
            goto error_exit;
        }
        obj->input_file = NULL;
    }

    /* Set IN.  */

    if (obj->next_input_name != NULL)
    {
        /* We have to make sure that the previous process has completed
        before we try to read the file.  */
        if (!pex_get_status_and_time (obj, 0, &errmsg, err))
            goto error_exit;

        in = obj->funcs->open_read (obj, obj->next_input_name,
                                    (flags & PEX_BINARY_INPUT) != 0);
        if (in < 0)
        {
            *err = errno;
            errmsg = "open temporary file";
            goto error_exit;
        }
        if (obj->next_input_name_allocated)
        {
            free (obj->next_input_name);
            obj->next_input_name_allocated = 0;
        }
        obj->next_input_name = NULL;
    }
    else
    {
        in = obj->next_input;
        if (in < 0)
        {
            *err = 0;
            errmsg = "pipeline already complete";
            goto error_exit;
        }
    }

    /* Set OUT and OBJ->NEXT_INPUT/OBJ->NEXT_INPUT_NAME.  */

    if ((flags & PEX_LAST) != 0)
    {
        if (outname == NULL)
            out = STDOUT_FILE_NO;
        else if ((flags & PEX_SUFFIX) != 0)
        {
            outname = concat (obj->tempbase, outname, NULL);
            outname_allocated = 1;
        }
        obj->next_input = -1;
    }
    else if ((obj->flags & PEX_USE_PIPES) == 0)
    {
        outname = temp_file (obj, flags, outname);
        if (! outname)
        {
            *err = 0;
            errmsg = "could not create temporary file";
            goto error_exit;
        }

        if (outname != orig_outname)
            outname_allocated = 1;

        if ((obj->flags & PEX_SAVE_TEMPS) == 0)
        {
            pex_add_remove (obj, outname, outname_allocated);
            outname_allocated = 0;
        }

        /* Hand off ownership of outname to the next stage.  */
        obj->next_input_name = outname;
        obj->next_input_name_allocated = outname_allocated;
        outname_allocated = 0;
    }
    else
    {
        if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_OUTPUT) != 0) < 0)
        {
            *err = errno;
            errmsg = "pipe";
            goto error_exit;
        }

        out = p[WRITE_PORT];
        obj->next_input = p[READ_PORT];
    }

    if (out < 0)
    {
        out = obj->funcs->open_write (obj, outname,
                                      (flags & PEX_BINARY_OUTPUT) != 0);
        if (out < 0)
        {
            *err = errno;
            errmsg = "open temporary output file";
            goto error_exit;
        }
    }

    if (outname_allocated)
    {
        free (outname);
        outname_allocated = 0;
    }

    /* Set ERRDES.  */

    if (errname == NULL)
        errdes = STDERR_FILE_NO;
    else
    {
        /* We assume that stderr is in text mode--it certainly shouldn't
        be controlled by PEX_BINARY_OUTPUT.  If necessary, we can add
         a PEX_BINARY_STDERR flag.  */
        errdes = obj->funcs->open_write (obj, errname, 0);
        if (errdes < 0)
        {
            *err = errno;
            errmsg = "open error file";
            goto error_exit;
        }
    }

    /* Run the program.  */

    pid = obj->funcs->exec_child (obj, flags, executable, argv, in, out, errdes,
                                  &errmsg, err);
    if (pid < 0)
        goto error_exit;

    ++obj->count;
    obj->children = XRESIZEVEC (long, obj->children, obj->count);
    obj->children[obj->count - 1] = pid;

    return NULL;

error_exit:
    if (in >= 0 && in != STDIN_FILE_NO)
        obj->funcs->close (obj, in);
    if (out >= 0 && out != STDOUT_FILE_NO)
        obj->funcs->close (obj, out);
    if (errdes >= 0 && errdes != STDERR_FILE_NO)
        obj->funcs->close (obj, errdes);
    if (outname_allocated)
        free (outname);
    return errmsg;
}
//-----------------------------------------------------------------
void MP3Worker::run_implementation()
{
  auto file_name = m_source_info.absoluteFilePath().replace('/', QDir::separator());

  // QTemporaryFile and QThreads are not playing fine together, the temp names are being reused
  // and taglib fails upon reading the file. This approach seems to work.
  auto id = QUuid::createUuid();
  QTemporaryFile temp_file(id.toString());
  if(!temp_file.open())
  {
    emit error_message(QString("Couldn't open temporary file for file '%1'.").arg(file_name));
    return;
  }

  QFile original_file(file_name);
  if(!original_file.open(QFile::ReadOnly))
  {
    emit error_message(QString("Couldn't open file '%1'.").arg(file_name));
    return;
  }

  // taglib wouldn't open files with unicode names.
  temp_file.write(original_file.readAll());
  temp_file.waitForBytesWritten(-1);
  temp_file.flush();
  temp_file.close();

  auto temp_name = temp_file.fileName() + MP3_EXTENSION;
  temp_file.rename(temp_name); // taglib won't open a file if it doesn't have the correct extension. ¿¿??
  original_file.close();

  QString track_title;

  { // ensure TagLib File object is destroyed at the end of scope.
    TagLib::MPEG::File file_metadata(temp_name.toStdString().c_str());

    if(file_metadata.hasID3v1Tag() || file_metadata.hasID3v2Tag())
    {
      if(m_configuration.useMetadataToRenameOutput())
      {
        if(!file_metadata.hasID3v2Tag())
        {
          track_title = parse_metadata(file_metadata.tag());
        }
        else
        {
          track_title = parse_metadata_id3v2(file_metadata.ID3v2Tag());
        }
      }

      emit progress(25);

      if(m_configuration.extractMetadataCoverPicture() && file_metadata.hasID3v2Tag())
      {
        extract_cover(file_metadata.ID3v2Tag());
      }

      emit progress(50);

      if(m_configuration.stripTagsFromMp3())
      {
        file_metadata.strip();
        file_metadata.save();
      }
    }
  }

  emit progress(75);

  if(track_title.isEmpty())
  {
    track_title = m_source_info.absoluteFilePath().split('/').last().remove(MP3_EXTENSION);
  }
  track_title = Utils::formatString(track_title, m_configuration.formatConfiguration());

  auto source_name = m_source_info.absoluteFilePath().split('/').last();
  emit information_message(QString("Renaming '%1' from '%2'.").arg(track_title).arg(source_name));

  auto final_name = m_source_path + track_title;

  original_file.rename(original_file.fileName() + TEMP_EXTENSION);

  if(!QFile::copy(temp_file.fileName(), final_name))
  {
    emit error_message(QString("Couldn't copy file '%1' to '%2'.").arg(m_source_info.absoluteFilePath()).arg(final_name));
    original_file.rename(original_file.fileName().remove(TEMP_EXTENSION));
  }
  else
  {
    original_file.remove();
  }
}
QString RcsInterfaceTarDiff::diff(QString version1, QString version2)
{
	QString file1=temp_file();
	QString file2=temp_file();
	
	extract(file1, version1);
	extract(file2, version2);
	
	QStringList s1=read_file(file1);
	QStringList s2=read_file(file1);
	
	int len1=0, len2=0, len;
	
	for(int i=0;i<s1.size();i++)
	{
		if(len1<s1[i].size()) len1=s1[i].size();
	}
	
	for(int i=0;i<s2.size();i++)
	{
		if(len2<s2[i].size()) len2=s2[i].size();
	}
	
	len=len1+len2+10;
	
	QString command="diff -y -t -W "+QString::number(len)+" '"+file1+"' '"+file2+"'";
	
	QStringList result=system_string(command);
	
	
	
	//printf("Ejecutado diff\n");
	
	QFile::remove(file1);
	QFile::remove(file2);
	
	//Se construye la salida según los resultados de diff
	QString html;
	len2=len/2;
	
	html+="<html>"
	"<HEAD>"
		"<META HTTP-EQUIV='CONTENT-TYPE' CONTENT='text/html; charset=utf-8'>"
		"<TITLE>SimpleRcs</TITLE>"
	"</HEAD>"
	"<body>";
	
	html+="<b>Showing differences between:</b><br>";
		
	
	html+="<TABLE BORDER=1 BORDERCOLOR='#000000' CELLPADDING=3 CELLSPACING=0>"
		"<tr>"
			"<td></td>"
			"<td><b>"+version1+"</b></td>"
			"<td></td>"
			"<td></td>"
			"<td><b>"+version2+"</b></td>"
		"</tr>\n";
	
	int size=result.size();
	int line1_num=0;
	int line2_num=0;
	for(int i=0;i<size;i++)
	{
		QString line=result[i];
		len=line.size();
		QString ch;
		if(len2<len)
		{
			ch=line.mid(len1+2,5).trimmed();
		}
		else
		{
			ch=line.right(2).trimmed();
		}
		//printf("ch=%s\n", ch.toLocal8Bit().data());
		
		QString line1=line.left(len2-1).trimmed();
		QString line2=line.mid(len2+1).trimmed();
		QString color;
		
		line1=line1.replace("&", "&amp;");
		line1=line1.replace("<", "&lt;");
		line1=line1.replace(">", "&gt;");
		line1=line1.replace(" ", "&nbsp;");
		line1=line1.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
		
		line2=line2.replace("&", "&amp;");
		line2=line2.replace("<", "&lt;");
		line2=line2.replace(">", "&gt;");
		line2=line2.replace(" ", "&nbsp;");
		line2=line2.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
		
		line="";
		
		if( ch=="|" )
		{
			color="#23ff23";
			line1_num++;
			line2_num++;
		}
		else if(ch=="(" || ch==")" || ch=="/")
		{
			color="#ff0000";
			line1_num++;
			line2_num++;
		}
		else if( ch=="<" )
		{
			color="#ff0000";
			line1_num++;
			ch="&lt;";
		}
		else if( ch==">" )
		{
			color="#ffa000";
			line2_num++;
			ch="&gt;";
		}
		else
		{
			color="#ffffff";
			line1_num++;
			line2_num++;
		}
		
		line="<tr>"
			"<td BGCOLOR='"+color+"'>"+QString::number(line1_num)+"</td>"
			"<td BGCOLOR='"+color+"'>"+line1+"</td>"
			"<td BGCOLOR='"+color+"'>"+ch+"</td>"
			"<td BGCOLOR='"+color+"'>"+QString::number(line2_num)+"</td>"
			"<td BGCOLOR='"+color+"'>"+line2+"</td>"
		"</tr>";
		
		
		html+=line+"\n";
	}
	
	html+="</table></body></html>";
	
	//printf("%s", html.toLocal8Bit().data());
	
	return html;
}
Esempio n. 24
0
int multiple_detector_fit()
{

  std::cout << "Beginning : ... " << std::endl;

  Int_t npoints = 1000;
  Double_t emin = 0.2; 
  Double_t emax = 3.0;

  bool use100m = false;
  bool use470m = true;
  bool use600m = false;


  std::vector<int> baselines;
  std::vector<double> scales;
  std::vector<std::string> names;
  std::vector<double> volume;

  if (use100m) baselines.push_back(100);
  if (use470m) baselines.push_back(470);
  if (use600m) baselines.push_back(600);
  int nL = baselines.size();

  double NULLVec[3][20];
  double OscVec[3][1001][7][20];

  for(int i = 0; i < 20; i++){
    NULLVec[0][i] = 0;
    NULLVec[1][i] = 0;
    NULLVec[2][i] = 0;

  }

  for(int u = 0; u < 1000; u++){
    for(int s = 0; s < 7; s++){
      for(int i = 0; i < 20; i++){

	OscVec[0][u][s][i] = 0;
        OscVec[1][u][s][i] = 0;
        OscVec[2][u][s][i] = 0;

      }
    }
  }


  int nbinsE = 0;

  int counter = 0;
  if (use100m){

    std::string temp_name = "../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root";

    TFile temp_file(temp_name.c_str());
    TH1D *NULL_100;
    NULL_100 = (TH1D*)(temp_file.Get("NumuCC"));
    nbinsE = NULL_100->GetNbinsX();
    std::cout << nbinsE << std::endl;
      for(int i = 1; i <= nbinsE; i++){
	  NULLVec[counter][i-1] = (NULL_100->GetBinContent(i));
      }

    for(int u = 0; u < npoints; u++){
      for(int s = 0; s < 7; s++){
	TH1D *OSC_100;
	TString upoint = Form("%d",u);
	TString name = "Universe_";
	TString name2 = "_MultiSim_";
	TString mul = Form("%d",s);
	
	name += upoint;
	name += name2;
	name += mul;	
       
	OSC_100 = (TH1D*)(temp_file.Get(name));
          for(int i = 1; i <= nbinsE; i++){
              OscVec[counter][u][s][i-1] = (OSC_100->GetBinContent(i));
	      //	      if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl;

	  }

	delete OSC_100;
      }
    }
    counter++;
    delete NULL_100;
    temp_file.Close();
  }

  if (use470m){
    std::string temp_name = "../MatrixFiles/combined_ntuple_470m_nu_processed_numu.root";

    TFile temp_file(temp_name.c_str());
    TH1D *NULL_470;
    NULL_470 = (TH1D*)(temp_file.Get("NumuCC"));
    nbinsE = NULL_470->GetNbinsX();
    std::cout << nbinsE<< std::endl;
      for(int i = 1; i <= nbinsE; i++){
	  NULLVec[counter][i-1] = (NULL_470->GetBinContent(i));
      }

    for(int u = 0; u < npoints; u++){
      for(int s = 0; s < 7; s++){
	TH1D *OSC_470;
	TString upoint = Form("%d",u);//std::to_string(u);
	TString name = "Universe_";
	TString name2 = "_MultiSim_";
	TString mul = Form("%d",s);// = std::to_string(s);
	
	name += upoint;
	name += name2;
	name += mul;	
       
	OSC_470 = (TH1D*)(temp_file.Get(name));
          for(int i = 1; i <= nbinsE; i++){
	    OscVec[counter][u][s][i-1] = (OSC_470->GetBinContent(i));
	  }

	delete OSC_470;
      }
    }
    counter++;
    delete NULL_470;
    temp_file.Close();
  }

  if (use600m){
    std::string temp_name = "../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root";

    TFile temp_file(temp_name.c_str());
    TH1D *NULL_600;
    NULL_600 = (TH1D*)(temp_file.Get("NumuCC"));
    nbinsE = NULL_600->GetNbinsX();
    std::cout << nbinsE<< std::endl;
      for(int i = 1; i <= nbinsE; i++){
	  NULLVec[counter][i-1] = (NULL_600->GetBinContent(i));
      }

    for(int u = 0; u < npoints; u++){
      for(int s = 0; s < 7; s++){
	TH1D *OSC_600;
	TString upoint = Form("%d",u);//std::to_string(u);
	TString name = "Universe_";
	TString name2 = "_MultiSim_";
	TString mul = Form("%d",s);// = std::to_string(s);
	
	name += upoint;
	name += name2;
	name += mul;	
       
	OSC_600 = (TH1D*)(temp_file.Get(name));
          for(int i = 1; i <= nbinsE; i++){
	    OscVec[counter][u][s][i-1] = (OSC_600->GetBinContent(i));

	  }

	delete OSC_600;
      }
    }
    counter++;    
    delete NULL_600;
    temp_file.Close();
  }


  //  int nL = 3;
  int mbins = (nbinsE*nL);
 
  TMatrix M6 (mbins,mbins);
  TMatrix M5 (mbins,mbins);
  TMatrix M4 (mbins,mbins);
  TMatrix M3 (mbins,mbins);
  TMatrix M2 (mbins,mbins);
  TMatrix M1 (mbins,mbins);
  TMatrix M0 (mbins,mbins);
  
  TMatrix C6 (mbins,mbins);
  TMatrix C5 (mbins,mbins);
  TMatrix C4 (mbins,mbins);
  TMatrix C3 (mbins,mbins);
  TMatrix C2 (mbins,mbins);
  TMatrix C1 (mbins,mbins);
  TMatrix C0 (mbins,mbins);

  int N = 0;

  TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins);
  TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins);
  TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins);
  TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins);
  TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins);
  TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins);
  TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins);

  int Erri = 0, Errj = 0;

  std::cout << "Filling Error Matrix..." << std::endl;

  for(int Lrow = 0; Lrow < nL; Lrow++){
    for(int Erow = 0; Erow < nbinsE; Erow++){

      Errj = 0;

      for(int Lcol = 0; Lcol < nL; Lcol++){
        for(int Ecol = 0; Ecol < nbinsE; Ecol++){

          M6 (Erri,Errj) = 0;
          M5 (Erri,Errj) = 0;
          M4 (Erri,Errj) = 0;
          M3 (Erri,Errj) = 0;
          M2 (Erri,Errj) = 0;
          M1 (Erri,Errj) = 0;
          M0 (Erri,Errj) = 0;

	  N = 0;

	  for(int u = 0; u < npoints; u++){

	    M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]);
            M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]);
            M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]);
            M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]);
            M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]);
            M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]);
            M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]);

	    N++;
	    
	  }

	  M6 (Erri,Errj) /= N;
          M5 (Erri,Errj) /= N;
          M4 (Erri,Errj) /= N;
          M3 (Erri,Errj) /= N;
          M2 (Erri,Errj) /= N;
          M1 (Erri,Errj) /= N;
	  M0 (Erri,Errj) /= N;


	  
	  M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
	  
	  if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj)));
      if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj)));
      if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj)));
      if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj)));
      if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj)));
      if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj)));
      if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj)));


          Errj++;

	}}

      Erri++;

    }}

  for(int i = 0; i < Erri; i++){
    for(int j = 0; j < Errj; j++){

      C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j));
      C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j));
      C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j));
      C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j));
      C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j));
      C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j));
      C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j));

    }
  }
  
  std::cout << "...Error Matrix Filled" << std::endl;


  TCanvas* c6 = new TCanvas("c6","",700,700);
  c6->SetLeftMargin(.1);
  c6->SetBottomMargin(.1);
  c6->SetTopMargin(.075);
  c6->SetRightMargin(.15);
  c6->cd();

  M6.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //  TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  add_plot_label("  0.2 GeV               #minus             3.0 GeV ", 0.48,0.07,0.04);



  TLatex *MD = new TLatex(.3,.01,"MicroBooNE (470m)");
  MD->SetNDC();
  MD->SetTextFont(62);
  MD->SetTextSize(0.04);
  MD->Draw();

  TLatex *MD45 = new TLatex(.05,.3,"MicroBooNE (470m)");
  MD45->SetNDC();
  MD45->SetTextAngle(90);
  MD45->SetTextFont(62);
  MD45->SetTextSize(0.04);
  MD45->Draw();


  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  c6->Print("total_1Det_matrix.pdf");



  TCanvas* c61 = new TCanvas("c61","",700,700);
  c61->SetLeftMargin(.1);
  c61->SetBottomMargin(.1);
  c61->SetTopMargin(.075);
  c61->SetRightMargin(.15);
  c61->cd();

  C6.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);
  add_plot_label("  0.2 GeV               #minus             3.0 GeV ", 0.48,0.07,0.04);

 
  MD->Draw();

  MD45->Draw();


  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  c61->Print("total_1Det_correlation_matrix.pdf");

 
  cout<<"\nEnd of routine.\n";

  return 0;

}
Esempio n. 25
0
void
edit_file(char *buf)
    /* copy file to a temp file, edit that file, and install it
       if necessary */
{
    char *cureditor = NULL;
    char editorcmd[PATH_LEN];
    pid_t pid;
    int status;
    struct stat st;
    time_t mtime = 0;
    char *tmp_str;
    FILE *f, *fi;
    int file = 0;
    int c;
    char correction = 0;
    short return_val = EXIT_OK;

    explain("fcrontab : editing %s's fcrontab", user);	

    if ((cureditor=getenv("VISUAL")) == NULL || strcmp(cureditor, "\0") == 0 )
	if((cureditor=getenv("EDITOR"))==NULL || strcmp(cureditor, "\0") == 0 )
	    cureditor = editor;
	
    file = temp_file(&tmp_str);
    if ( (fi = fdopen(file, "w")) == NULL ) {
	error_e("could not fdopen");
	goto exiterr;
    }
#ifndef USE_SETE_ID
    if (fchown(file, asuid, asgid) != 0) {
	error_e("Could not fchown %s to asuid and asgid", tmp_str);
	goto exiterr;
    }
#endif
    /* copy user's fcrontab (if any) to a temp file */
    if ( (f = fopen(buf, "r")) == NULL ) {
	if ( errno != ENOENT ) {
	    error_e("could not open file %s", buf);
	    goto exiterr;
	}
	else
	    fprintf(stderr, "no fcrontab for %s - using an empty one\n",
		    user);
    }
    else { 
	/* copy original file to temp file */
	while ( (c=getc(f)) != EOF )
	    putc(c, fi);
	fclose(f);
    }

    fclose(fi);
    close(file);

    do {

	if ( stat(tmp_str, &st) == 0 )
	    mtime = st.st_mtime;
	else {
	    error_e("could not stat \"%s\"", buf);
	    goto exiterr;
	}

	switch ( pid = fork() ) {
	case 0:
	    /* child */
	    if ( uid != ROOTUID ) {
		if (setgid(asgid) < 0) {
		    error_e("setgid(asgid)");
		    goto exiterr;
		}
		if (setuid(asuid) < 0) {
		    error_e("setuid(asuid)");
		    goto exiterr;
		}
	    }
	    else {
		/* Some programs, like perl, require gid=egid : */
		if ( setgid(getgid()) < 0 ) {
		    error_e("setgid(getgid())");
		    goto exiterr;
		}
	    }
	    snprintf(editorcmd, sizeof(editorcmd), "%s %s", cureditor, tmp_str);
	    execlp(shell, shell, "-c", editorcmd, tmp_str, NULL);
	    error_e("Error while running \"%s\"", cureditor);
	    goto exiterr;

	case -1:
	    error_e("fork");
	    goto exiterr;

	default:
	    /* parent */
	    break ;
	}
	    
	/* only reached by parent */
	waitpid(pid, &status, 0);
	if ( ! WIFEXITED(status) ) {
	    fprintf(stderr, "Editor exited abnormally:"
		    " fcrontab is unchanged.\n");
	    goto exiterr;
	}

#ifndef USE_SETE_ID
	/* we have chown the tmp file to user's name : user may have
	 * linked the tmp file to a file owned by root. In that case, as
	 * fcrontab is setuid root, user may read some informations he is not
	 * allowed to read :
	 * we *must* check that the tmp file is not a link. */

	/* open the tmp file, chown it to root and chmod it to avoid race
	 * conditions */
	/* make sure that the tmp file is not a link */
	{
	    int fd = 0;
	    if ( (fd = open(tmp_str, O_RDONLY)) <= 0 ||
		 fstat(fd, &st) != 0 || ! S_ISREG(st.st_mode) ||
		 S_ISLNK(st.st_mode) || st.st_uid != asuid || st.st_nlink > 1){
		fprintf(stderr, "%s is not a valid regular file.\n", tmp_str);
		close(fd);
		goto exiterr;
	    }
	    if ( fchown(fd, ROOTUID, ROOTGID) != 0 || fchmod(fd, S_IRUSR|S_IWUSR) != 0 ){
		fprintf(stderr, "Can't chown or chmod %s.\n", tmp_str);
		close(fd);
		goto exiterr;
	    }
	    close(fd);
	}
#endif
	
	/* check if file has been modified */
	if ( stat(tmp_str, &st) != 0 ) {
	    error_e("could not stat %s", tmp_str);
	    goto exiterr;
	}    

	else if ( st.st_mtime > mtime || correction == 1) {

	    correction = 0;

	    switch ( read_file(tmp_str) ) {
	    case ERR:
		goto exiterr;
	    case 2:
		fprintf(stderr, "\nFile contains some errors. "
			"Ignore [i] or Correct [c] ? ");
		/* the 2nd getchar() is for the newline char (\n) */
		while ( (c = getchar())	&& c != 'i' && c != 'c' ) {
		    fprintf(stderr, "Please press c to correct, "
			    "or i to ignore: ");
		    while (c != '\n')
			c = getchar();
		}
		if ( c == 'c' ) {
		    /* free memory used to store the list */
		    delete_file(user);
		    correction = 1;
		}
		break;
	    default:
		break;
	    }

	}
	else {
	    fprintf(stderr, "Fcrontab is unchanged :"
		    " no need to install it.\n"); 
	    goto end;
	}

    } while ( correction == 1);

    if ( write_file(tmp_str) != OK )
	return_val = EXIT_ERR;
    
    /* free memory used to store the list */
    delete_file(user);
    
    /* tell daemon to update the conf */
    need_sig = 1;
    
  end:
    if ( remove(tmp_str) != 0 )
	error_e("could not remove %s", tmp_str);
    free(tmp_str);
    xexit (return_val);

  exiterr:
    if ( remove(tmp_str) != 0 )
	error_e("could not remove %s", tmp_str);
    free(tmp_str);
    xexit (EXIT_ERR);

}
Esempio n. 26
0
int multiple_detector_fit()
{

  std::cout << "Beginning : ... " << std::endl;

  Int_t npoints = 1000;
  Double_t emin = 0.2; 
  Double_t emax = 3.0;

  bool use100m = true;
  bool use470m = true;
  bool use600m = true;


  std::vector<int> baselines;
  std::vector<double> scales;
  std::vector<std::string> names;
  std::vector<double> volume;

  if (use100m) baselines.push_back(100);
  if (use470m) baselines.push_back(470);
  if (use600m) baselines.push_back(600);


  double NULLVec[2][20];
  double OscVec[2][1001][7][20];

  for(int i = 0; i < 20; i++){
    NULLVec[0][i] = 0;
    NULLVec[1][i] = 0;

  }

  for(int u = 0; u < 1000; u++){
    for(int s = 0; s < 7; s++){
      for(int i = 0; i < 20; i++){

	OscVec[0][u][s][i] = 0;
        OscVec[1][u][s][i] = 0;

      }
    }
  }


  int nbinsE = 0;


  if (use100m){

    std::string temp_name = /*"../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_100m_nu_processed_CoreyBins_numu.root";

    TFile temp_file(temp_name.c_str());
    TH1D *NULL_100;
    NULL_100 = (TH1D*)(temp_file.Get("NumuCC"));
    nbinsE = NULL_100->GetNbinsX();
    std::cout << nbinsE << std::endl;
      for(int i = 1; i <= nbinsE; i++){
	  NULLVec[0][i-1] = (NULL_100->GetBinContent(i));
      }

    for(int u = 0; u < npoints; u++){
      for(int s = 0; s < 7; s++){
	TH1D *OSC_100;
	TString upoint = Form("%d",u);
	TString name = "Universe_";
	TString name2 = "_MultiSim_";
	TString mul = Form("%d",s);
	
	name += upoint;
	name += name2;
	name += mul;	
       
	OSC_100 = (TH1D*)(temp_file.Get(name));
          for(int i = 1; i <= nbinsE; i++){
              OscVec[0][u][s][i-1] = (OSC_100->GetBinContent(i));
	      //	      if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl;

	  }

	delete OSC_100;
      }
    }
    
    delete NULL_100;
    temp_file.Close();
  }

  if (use470m){
    std::string temp_name = /*"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_CoreyBins_numu.root";

    TFile temp_file(temp_name.c_str());
    TH1D *NULL_470;
    NULL_470 = (TH1D*)(temp_file.Get("NumuCC"));
    nbinsE = NULL_470->GetNbinsX();
    std::cout << nbinsE<< std::endl;
      for(int i = 1; i <= nbinsE; i++){
	  NULLVec[1][i-1] = (NULL_470->GetBinContent(i));
      }

    for(int u = 0; u < npoints; u++){
      for(int s = 0; s < 7; s++){
	TH1D *OSC_470;
	TString upoint = Form("%d",u);//std::to_string(u);
	TString name = "Universe_";
	TString name2 = "_MultiSim_";
	TString mul = Form("%d",s);// = std::to_string(s);
	
	name += upoint;
	name += name2;
	name += mul;	
       
	OSC_470 = (TH1D*)(temp_file.Get(name));
          for(int i = 1; i <= nbinsE; i++){
	    OscVec[1][u][s][i-1] = (OSC_470->GetBinContent(i));
	    if(OscVec[1][u][s][i-1] != OscVec[1][u][s][i-1])  OscVec[1][u][s][i-1] = NULLVec[1][i-1];//std::cout << "erm, u :" << u << " s : " << s << " E : " << i  <<std::endl;

	  }

	delete OSC_470;
      }
    }
    
    delete NULL_470;
    temp_file.Close();
  }

  int nL = 2;
  int mbins = (nbinsE*nL);
 
  TMatrix M6 (mbins,mbins);
  TMatrix M5 (mbins,mbins);
  TMatrix M4 (mbins,mbins);
  TMatrix M3 (mbins,mbins);
  TMatrix M2 (mbins,mbins);
  TMatrix M1 (mbins,mbins);
  TMatrix M0 (mbins,mbins);
  
  TMatrix C6 (mbins,mbins);
  TMatrix C5 (mbins,mbins);
  TMatrix C4 (mbins,mbins);
  TMatrix C3 (mbins,mbins);
  TMatrix C2 (mbins,mbins);
  TMatrix C1 (mbins,mbins);
  TMatrix C0 (mbins,mbins);

  int N = 0;

  TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins);
  TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins);
  TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins);
  TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins);
  TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins);
  TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins);
  TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins);

  int Erri = 0, Errj = 0;

  std::cout << "Filling Error Matrix..." << std::endl;

  for(int Lrow = 0; Lrow < 2; Lrow++){
    for(int Erow = 0; Erow < nbinsE; Erow++){

      Errj = 0;

      for(int Lcol = 0; Lcol < 2; Lcol++){
        for(int Ecol = 0; Ecol < nbinsE; Ecol++){

          M6 (Erri,Errj) = 0;
          M5 (Erri,Errj) = 0;
          M4 (Erri,Errj) = 0;
          M3 (Erri,Errj) = 0;
          M2 (Erri,Errj) = 0;
          M1 (Erri,Errj) = 0;
          M0 (Erri,Errj) = 0;

	  N = 0;

	  for(int u = 0; u < npoints; u++){

	    M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]);
            M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]);
            M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]);
            M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]);
            M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]);
            M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]);
            M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]);

	    N++;
	    
	  }

	  M6 (Erri,Errj) /= N;
          M5 (Erri,Errj) /= N;
          M4 (Erri,Errj) /= N;
          M3 (Erri,Errj) /= N;
          M2 (Erri,Errj) /= N;
          M1 (Erri,Errj) /= N;
	  M0 (Erri,Errj) /= N;


	  
	  M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
          M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol];
	  
	  if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj)));
      if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj)));
      if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj)));
      if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj)));
      if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj)));
      if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj)));
      if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj)));

      std::cout << M6 (Erri,Errj) << "\t";

          Errj++;

	}}

      Erri++;

    }}

  for(int i = 0; i < Erri; i++){
    for(int j = 0; j < Errj; j++){

      C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j));
      C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j));
      C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j));
      C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j));
      C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j));
      C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j));
      C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j));

    }
  }
  
  std::cout << "...Error Matrix Filled" << std::endl;


  TCanvas* c6 = new TCanvas("c6","",700,700);
  c6->SetLeftMargin(.1);
  c6->SetBottomMargin(.1);
  c6->SetTopMargin(.075);
  c6->SetRightMargin(.15);
  c6->cd();

  M6.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //  TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);



  TLatex *ND = new TLatex(.15,.01,"LAr1-ND (100m) ");
  ND->SetNDC();
  ND->SetTextFont(62);
  ND->SetTextSize(0.04);
  ND->Draw();

  TLatex *MD = new TLatex(.5,.01,"T600 (600m, on axis)");
  MD->SetNDC();
  MD->SetTextFont(62);
  MD->SetTextSize(0.04);
  MD->Draw();

  TLatex *ND45 = new TLatex(.05,.15,"LAr1-ND (100m) ");
  ND45->SetNDC();
  ND45->SetTextAngle(90);
  ND45->SetTextFont(62);
  ND45->SetTextSize(0.04);
  ND45->Draw();

  TLatex *MD45 = new TLatex(.05,.54,"T600 (600m, on axis)");
  MD45->SetNDC();
  MD45->SetTextAngle(90);
  MD45->SetTextFont(62);
  MD45->SetTextSize(0.04);
  MD45->Draw();

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  //  c6->Print("total_matrix.pdf");



  TCanvas* c61 = new TCanvas("c61","",700,700);
  c61->SetLeftMargin(.1);
  c61->SetBottomMargin(.1);
  c61->SetTopMargin(.075);
  c61->SetRightMargin(.15);
  c61->cd();

  C6.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);
  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);


  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  //  c61->Print("total_correlation_matrix.pdf");

 

  TCanvas* c5 = new TCanvas("c5","",700,700);
  c5->SetLeftMargin(.1);
  c5->SetBottomMargin(.1);
  c5->SetTopMargin(.075);
  c5->SetRightMargin(.15);
  c5->cd();

  M5.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);
  
TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("K^{+} Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();




  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();

  //  c5->Print("mult5_matrix.pdf");

  TCanvas* c51 = new TCanvas("c51","",700,700);
  c51->SetLeftMargin(.1);
  c51->SetBottomMargin(.1);
  c51->SetTopMargin(.075);
  c51->SetRightMargin(.15);
  c51->cd();

  C5.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{+} Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();



  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();

  //  c51->Print("mult5_correlation_matrix.pdf");

  TCanvas* c4 = new TCanvas("c4","",700,700);
  c4->SetLeftMargin(.1);
  c4->SetBottomMargin(.1);
  c4->SetTopMargin(.075);
  c4->SetRightMargin(.15);
  c4->cd();

  M4.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();



  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c4->Print("mult4_matrix.pdf");

  TCanvas* c41 = new TCanvas("c41","",700,700);
  c41->SetLeftMargin(.1);
  c41->SetBottomMargin(.1);
  c41->SetTopMargin(.075);
  c41->SetRightMargin(.15);
  c41->cd();

  C4.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c41->Print("mult4_correlation_matrix.pdf");



  TCanvas* c3 = new TCanvas("c3","",700,700);
  c3->SetLeftMargin(.1);
  c3->SetBottomMargin(.1);
  c3->SetTopMargin(.075);
  c3->SetRightMargin(.15);
  c3->cd();

  M3.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();


  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c3->Print("mult3_matrix.pdf");

  TCanvas* c31 = new TCanvas("c31","",700,700);
  c31->SetLeftMargin(.1);
  c31->SetBottomMargin(.1);
  c31->SetTopMargin(.075);
  c31->SetRightMargin(.15);
  c31->cd();

  C3.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();



  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c31->Print("mult3_correlation_matrix.pdf");


  TCanvas* c2 = new TCanvas("c2","",700,700);
  c2->SetLeftMargin(.1);
  c2->SetBottomMargin(.1);
  c2->SetTopMargin(.075);
  c2->SetRightMargin(.15);
  c2->cd();

  M2.Draw("COLZ");
  gStyle->SetPalette(56,0);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);
  TMatrixFBase->SetContour(999);
  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();



  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c2->Print("mult2_matrix.pdf");

  TCanvas* c21 = new TCanvas("c21","",700,700);
  c21->SetLeftMargin(.1);
  c21->SetBottomMargin(.1);
  c21->SetTopMargin(.075);
  c21->SetRightMargin(.15);
  c21->cd();

  C2.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c21->Print("mult2_correlation_matrix.pdf");


  TCanvas* c1 = new TCanvas("c1","",700,700);
  c1->SetLeftMargin(.1);
  c1->SetBottomMargin(.1);
  c1->SetTopMargin(.075);
  c1->SetRightMargin(.15);
  c1->cd();

  M1.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c1->Print("mult1_matrix.pdf");

  TCanvas* c11 = new TCanvas("c11","",700,700);
  c11->SetLeftMargin(.1);
  c11->SetBottomMargin(.1);
  c11->SetTopMargin(.075);
  c11->SetRightMargin(.15);
  c11->cd();

  C1.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c11->Print("mult1_correlation_matrix.pdf");


  TCanvas* c0 = new TCanvas("c0","",700,700);
  c0->SetLeftMargin(.1);
  c0->SetBottomMargin(.1);
  c0->SetTopMargin(.075);
  c0->SetRightMargin(.15);
  c0->cd();

  M0.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Covariance Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kBlue);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Fractional Error Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();


  //  c0->Print("mult0_matrix.pdf");

  TCanvas* c01 = new TCanvas("c01","",700,700);
  c01->SetLeftMargin(.1);
  c01->SetBottomMargin(.1);
  c01->SetTopMargin(.075);
  c01->SetRightMargin(.15);
  c01->cd();

  C0.Draw("COLZ");
  gStyle->SetPalette(56,0);
  TMatrixFBase->SetContour(999);
  //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1);

  TMatrixFBase->GetZaxis()->SetTitleFont(62);
  TMatrixFBase->GetZaxis()->SetLabelFont(62);
  TMatrixFBase->GetZaxis()->SetTitleSize(0.045);
  //  TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Correlation Matrix");
  TMatrixFBase->GetZaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetXaxis()->SetTitle("");
  TMatrixFBase->GetXaxis()->SetLabelSize(0);
  TMatrixFBase->GetXaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetTitle("");
  TMatrixFBase->GetYaxis()->SetTitleOffset(1.5);
  TMatrixFBase->GetYaxis()->SetLabelSize(0);
  TMatrixFBase->SetStats(0);

  TLine *split = new TLine();
  split->SetLineStyle(2);
  split->SetLineWidth(5);
  split->SetLineColor(kYellow);
  split->DrawLineNDC(.1,.51,.849,.51);
  split->DrawLineNDC(.475,.101,.475,.930);
  add_plot_label("|            0.2 #minus 3.0 GeV            |            0.2 #minus 3.0 GeV            | ", 0.48,0.08,0.03);

  TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Correlation Matrix");
  Total->SetNDC();
  Total->SetTextFont(62);
  Total->SetTextSize(0.045);
  Total->Draw();

  ND->Draw();
  MD->Draw();
  ND45->Draw();
  MD45->Draw();

  //  c01->Print("mult0_correlation_matrix.pdf");
 
  TCanvas* c86 = new TCanvas("c86","",800,400);
  c86->SetLeftMargin(.1);
  c86->SetBottomMargin(.1);
  c86->SetTopMargin(.05);
  c86->SetRightMargin(.05);
  c86->cd();

  Fig6->GetYaxis()->SetTitle("Fractional Error");
  Fig6->GetYaxis()->SetTitleFont(62);
  Fig6->GetXaxis()->SetTitleFont(62);
  Fig6->GetYaxis()->SetLabelFont(62);
  Fig6->GetXaxis()->SetLabelFont(62);
  Fig6->GetYaxis()->CenterTitle();
  Fig6->GetYaxis()->SetTitleSize(0.06);
  Fig6->GetYaxis()->SetTitleOffset(0.8);
  Fig6->GetXaxis()->SetLabelSize(0.06);
  Fig6->GetYaxis()->SetLabelSize(0.06);
  Fig6->GetXaxis()->SetTitleOffset(1.5);
  Fig6->SetStats(0);
  Fig6->SetMinimum(-0.01);
  Fig6->SetMaximum(0.21);
  Fig6->SetMarkerStyle(8);
  Fig6->GetYaxis()->SetNdivisions(509);
  Fig6->GetXaxis()->SetNdivisions(509);
  Fig6->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);

  TLatex *ND = new TLatex(.23,.85,"LAr1-ND (100m) ");
  ND->SetNDC();
  ND->SetTextFont(62);
  ND->SetTextSize(0.05);
  ND->Draw();

  TLatex *MD = new TLatex(.65,.85,"T600 (600m, on axis)");
  MD->SetNDC();
  MD->SetTextFont(62);
  MD->SetTextSize(0.05);
  MD->Draw();

  //  c86->Print("FractionalErrors_Total.pdf");

  TCanvas* c85 = new TCanvas("c85","",800,400);
  c85->SetLeftMargin(.1);
  c85->SetBottomMargin(.1);
  c85->SetTopMargin(.05);
  c85->SetRightMargin(.05);
  c85->cd();

  Fig5->GetYaxis()->SetTitle("K#lower[-0.2]{+} Fractional Error");
  Fig5->GetYaxis()->SetTitleFont(62);
  Fig5->GetXaxis()->SetTitleFont(62);
  Fig5->GetYaxis()->SetLabelFont(62);
  Fig5->GetXaxis()->SetLabelFont(62);
  Fig5->GetYaxis()->CenterTitle();
  Fig5->GetYaxis()->SetTitleSize(0.06);
  Fig5->GetYaxis()->SetTitleOffset(0.8);
  Fig5->GetXaxis()->SetLabelSize(0.06);
  Fig5->GetYaxis()->SetLabelSize(0.06);
  Fig5->GetXaxis()->SetTitleOffset(1.5);
  Fig5->SetStats(0);
  Fig5->SetMinimum(-0.01);
  Fig5->SetMaximum(0.21);
  Fig5->SetMarkerStyle(8);
  Fig5->GetYaxis()->SetNdivisions(509);
  Fig5->GetXaxis()->SetNdivisions(509);
  Fig5->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c85->Print("FractionalErrors_Kplus.pdf");

  
  TCanvas* c84 = new TCanvas("c84","",800,400);
  c84->SetLeftMargin(.1);
  c84->SetBottomMargin(.1);
  c84->SetTopMargin(.05);
  c84->SetRightMargin(.05);
  c84->cd();

  Fig4->GetYaxis()->SetTitle("K#lower[-0.2]{-} Fractional Error");
  Fig4->GetYaxis()->SetTitleFont(62);
  Fig4->GetXaxis()->SetTitleFont(62);
  Fig4->GetYaxis()->SetLabelFont(62);
  Fig4->GetXaxis()->SetLabelFont(62);
  Fig4->GetYaxis()->CenterTitle();
  Fig4->GetYaxis()->SetTitleSize(0.06);
  Fig4->GetYaxis()->SetTitleOffset(0.8);
  Fig4->GetXaxis()->SetLabelSize(0.06);
  Fig4->GetYaxis()->SetLabelSize(0.06);
  Fig4->GetXaxis()->SetTitleOffset(1.5);
  Fig4->SetStats(0);
  Fig4->SetMinimum(-0.01);
  Fig4->SetMaximum(0.21);
  Fig4->SetMarkerStyle(8);
  Fig4->GetYaxis()->SetNdivisions(509);
  Fig4->GetXaxis()->SetNdivisions(509);
  Fig4->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c84->Print("FractionalErrors_Kmin.pdf");


  TCanvas* c83 = new TCanvas("c83","",800,400);
  c83->SetLeftMargin(.1);
  c83->SetBottomMargin(.1);
  c83->SetTopMargin(.05);
  c83->SetRightMargin(.05);
  c83->cd();

  Fig3->GetYaxis()->SetTitle("K#lower[-0.2]{0} Fractional Error");
  Fig3->GetYaxis()->SetTitleFont(62);
  Fig3->GetXaxis()->SetTitleFont(62);
  Fig3->GetYaxis()->SetLabelFont(62);
  Fig3->GetXaxis()->SetLabelFont(62);
  Fig3->GetYaxis()->CenterTitle();
  Fig3->GetYaxis()->SetTitleSize(0.06);
  Fig3->GetYaxis()->SetTitleOffset(0.8);
  Fig3->GetXaxis()->SetLabelSize(0.06);
  Fig3->GetYaxis()->SetLabelSize(0.06);
  Fig3->GetXaxis()->SetTitleOffset(1.5);
  Fig3->SetStats(0);
  Fig3->SetMinimum(-0.01);
  Fig3->SetMaximum(0.21);
  Fig3->SetMarkerStyle(8);
  Fig3->GetYaxis()->SetNdivisions(509);
  Fig3->GetXaxis()->SetNdivisions(509);
  Fig3->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c83->Print("FractionalErrors_K0.pdf");


  TCanvas* c82 = new TCanvas("c82","",800,400);
  c82->SetLeftMargin(.1);
  c82->SetBottomMargin(.1);
  c82->SetTopMargin(.05);
  c82->SetRightMargin(.05);
  c82->cd();

  Fig2->GetYaxis()->SetTitle("#pi#lower[-0.2]{+} Fractional Error");
  Fig2->GetYaxis()->SetTitleFont(62);
  Fig2->GetXaxis()->SetTitleFont(62);
  Fig2->GetYaxis()->SetLabelFont(62);
  Fig2->GetXaxis()->SetLabelFont(62);
  Fig2->GetYaxis()->CenterTitle();
  Fig2->GetYaxis()->SetTitleSize(0.06);
  Fig2->GetYaxis()->SetTitleOffset(0.8);
  Fig2->GetXaxis()->SetLabelSize(0.06);
  Fig2->GetYaxis()->SetLabelSize(0.06);
  Fig2->GetXaxis()->SetTitleOffset(1.5);
  Fig2->SetStats(0);
  Fig2->SetMinimum(-0.01);
  Fig2->SetMaximum(0.21);
  Fig2->SetMarkerStyle(8);
  Fig2->GetYaxis()->SetNdivisions(509);
  Fig2->GetXaxis()->SetNdivisions(509);
  Fig2->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c82->Print("FractionalErrors_piplus.pdf");


  TCanvas* c81 = new TCanvas("c81","",800,400);
  c81->SetLeftMargin(.1);
  c81->SetBottomMargin(.1);
  c81->SetTopMargin(.05);
  c81->SetRightMargin(.05);
  c81->cd();

  Fig1->GetYaxis()->SetTitle("#pi#lower[-0.2]{-} Fractional Error");
  Fig1->GetYaxis()->SetTitleFont(62);
  Fig1->GetXaxis()->SetTitleFont(62);
  Fig1->GetYaxis()->SetLabelFont(62);
  Fig1->GetXaxis()->SetLabelFont(62);
  Fig1->GetYaxis()->CenterTitle();
  Fig1->GetYaxis()->SetTitleSize(0.06);
  Fig1->GetYaxis()->SetTitleOffset(0.8);
  Fig1->GetXaxis()->SetLabelSize(0.06);
  Fig1->GetYaxis()->SetLabelSize(0.06);
  Fig1->GetXaxis()->SetTitleOffset(1.5);
  Fig1->SetStats(0);
  Fig1->SetMinimum(-0.01);
  Fig1->SetMaximum(0.21);
  Fig1->SetMarkerStyle(8);
  Fig1->GetYaxis()->SetNdivisions(509);
  Fig1->GetXaxis()->SetNdivisions(509);
  Fig1->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c81->Print("FractionalErrors_pimin.pdf");


  TCanvas* c80 = new TCanvas("c80","",800,400);
  c80->SetLeftMargin(.1);
  c80->SetBottomMargin(.1);
  c80->SetTopMargin(.05);
  c80->SetRightMargin(.05);
  c80->cd();

  Fig0->GetYaxis()->SetTitle("Beam Fractional Error");
  Fig0->GetYaxis()->SetTitleFont(62);
  Fig0->GetXaxis()->SetTitleFont(62);
  Fig0->GetYaxis()->SetLabelFont(62);
  Fig0->GetXaxis()->SetLabelFont(62);
  Fig0->GetYaxis()->CenterTitle();
  Fig0->GetYaxis()->SetTitleSize(0.06);
  Fig0->GetYaxis()->SetTitleOffset(0.8);
  Fig0->GetXaxis()->SetLabelSize(0.06);
  Fig0->GetYaxis()->SetLabelSize(0.06);
  Fig0->GetXaxis()->SetTitleOffset(1.5);
  Fig0->SetStats(0);
  Fig0->SetMinimum(-0.01);
  Fig0->SetMaximum(0.21);
  Fig0->SetMarkerStyle(8);
  Fig0->GetYaxis()->SetNdivisions(509);
  Fig0->GetXaxis()->SetNdivisions(509);
  Fig0->Draw("P");
  split->SetLineColor(1);
  split->SetLineWidth(2);
  split->DrawLine(19,-0.01,19,0.21);
  ND->Draw();
  MD->Draw();

  //  c80->Print("FractionalErrors_beam.pdf");

 
  cout<<"\nEnd of routine.\n";

  return 0;

}