Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:22:07+00:00 2026-06-10T03:22:07+00:00

I have three .root files that I need to merge together. Normally I would

  • 0

I have three .root files that I need to merge together. Normally I would use hadd to merge the files, but the files contain duplicate entries which I need to remove. I can’t just delete the duplicated entries because TTrees are read-only. Is there a simple way to merge the files while ensuring that only unique entries are saved?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:22:09+00:00Added an answer on June 10, 2026 at 3:22 am

    I did manage to find a way to produce histograms that contain only unique entries using TEntryList. This allows you to specify which tree entries you wish to use. In my case, each entry has an event number which identifies it. So, I generated an entry list with the entry numbers corresponding to only unique event numbers.

    set<int> eventIds; // keep track of already seen event numbers
    int EVENT;
    int nEntries = tree->GetEntries();
    
    tree->SetBranchAddress("EVENT",&EVENT); // grab the event number from the tree
    
    TEntryList *tlist = new TEntryList(tree); // initialize entry list for 'TTree* tree'
    
    // loop over the entries in 'tree'
    for (int j = 0; j < nEntries; ++j)
    {
        tree->GetEvent(j);
    
        // if we have not seen this event yet, add it to the set
        // and to the entry list
        if (eventIds.count(EVENT) == 0)
        {
            eventIds.insert(EVENT);
            tlist->Enter(j,tree);
        }
    }
    
    // apply the entry list to the tree
    tree->SetEntryList(tlist);
    
    // histogram of the variable 'var' will be drawn only with the
    // entries specified by the entry list.
    tree->Draw("var");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some word templates(dot/dotx) files that contain xml tags along with plain text.
I have an array of folders/files that looks like this: Array ( [Root Folder
I need to transform large XML files that have a nested (hierarchical) structure of
I have a binary tree class that is created with a root node and
I have source XMLfiles that come in with multiple root elements and there is
Have three divs in a container that I want to float over a large
I have three files: lib.c lib.h => They should be built as a .so
I need to write a C program that will allow me to read/write files
I have all my rewrite rules setup and working in .htaccess but I need
I have some graphics files that exist within a directory that a web server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.