<commit_before>/// \file
/// \ingroup tutorial_multicore
/// \notebook -nodraw
/// Illustrate the usage of the multiproc TSelector interfaces with the h1 analysis
/// example.
///
/// \macro_code
///
/// \author <NAME>
/// \author <NAME>

#include "TString.h"
#include "TROOT.h"
#include "TTree.h"
#include "TH1F.h"
#include "TTreeReader.h"
#include "ROOT/TProcessExecutor.h"

const char *fh1[] = {"http://root.cern.ch/files/h1/dstarmb.root",
                     "http://root.cern.ch/files/h1/dstarp1a.root",
                     "http://root.cern.ch/files/h1/dstarp1b.root",
                     "http://root.cern.ch/files/h1/dstarp2.root"};

int mp103_processSelector(){

  // MacOSX may generate connection to WindowServer errors
  gROOT->SetBatch(kTRUE);

  TString selectorPath = gROOT->GetTutorialsDir();
  selectorPath += "/tree/h1analysis.C+";
  std::cout << "selector used is: "<< selectorPath<<"\n";
  TSelector *sel = TSelector::GetSelector(selectorPath);

// The following code generates a crash when Davix is used for HTTP
// Davix does not seem fork-safe; the problem has been reported to the
// Davix developers. For the time being we disable this part.
// To repoduce the problem, uncomment the next line.
//
// #define __reproduce_davix
#if defined(__reproduce_davix)
  TFile *fp = TFile::Open(fh1[0]);
  TTree *tree = (TTree *) fp->Get("h42");
#endif

  ROOT:TProcessExecutor pool(3);

  TList* out = 0;
#if defined(__reproduce_davix)
  //TProcessExecutor::Process with a single tree
  out = pool.ProcTree(*tree, *sel);;
  sel->GetOutputList()->Delete();
#endif

  //TProcessExecutor::Process with single file name and tree name
  //Note: we have less files than workers here
  out = pool.ProcTree(fh1[0], *sel, "h1");
  sel->GetOutputList()->Delete();

  // Prepare datasets: vector of files, TFileCollection
  TFileCollection fc;
  std::vector<std::string> files;
  for (int i = 0; i < 4; i++) {
     files.push_back(fh1[i]);
     fc.Add(new TFileInfo(fh1[i]));
  }<commit_msg>Renamed TProcPool to TProcessExecutor, TThreadPool to TTreadExecutor, TPool to TExecutor.<commit_after>/// \file
/// \ingroup tutorial_multicore
/// \notebook -nodraw
/// Illustrate the usage of the multiproc TSelector interfaces with the h1 analysis
/// example.
///
/// \macro_code
///
/// \author <NAME>
/// \author <NAME>

#include "TString.h"
#include "TROOT.h"
#include "TTree.h"
#include "TH1F.h"
#include "TTreeReader.h"
#include "ROOT/TProcessExecutor.hxx"

const char *fh1[] = {"http://root.cern.ch/files/h1/dstarmb.root",
                     "http://root.cern.ch/files/h1/dstarp1a.root",
                     "http://root.cern.ch/files/h1/dstarp1b.root",
                     "http://root.cern.ch/files/h1/dstarp2.root"};

int mp103_processSelector(){

  // MacOSX may generate connection to WindowServer errors
  gROOT->SetBatch(kTRUE);

  TString selectorPath = gROOT->GetTutorialsDir();
  selectorPath += "/tree/h1analysis.C+";
  std::cout << "selector used is: "<< selectorPath<<"\n";
  TSelector *sel = TSelector::GetSelector(selectorPath);

// The following code generates a crash when Davix is used for HTTP
// Davix does not seem fork-safe; the problem has been reported to the
// Davix developers. For the time being we disable this part.
// To repoduce the problem, uncomment the next line.
//
// #define __reproduce_davix
#if defined(__reproduce_davix)
  TFile *fp = TFile::Open(fh1[0]);
  TTree *tree = (TTree *) fp->Get("h42");
#endif

  ROOT::TProcessExecutor pool(3);

  TList* out = 0;
#if defined(__reproduce_davix)
  //TProcessExecutor::Process with a single tree
  out = pool.ProcTree(*tree, *sel);;
  sel->GetOutputList()->Delete();
#endif

  //TProcessExecutor::Process with single file name and tree name
  //Note: we have less files than workers here
  out = pool.ProcTree(fh1[0], *sel, "h1");
  sel->GetOutputList()->Delete();

  // Prepare datasets: vector of files, TFileCollection
  TFileCollection fc;
  std::vector<std::string> files;
  for (int i = 0; i < 4; i++) {
     files.push_back(fh1[i]);
     fc.Add(new TFileInfo(fh1[i]));
  }
{'fraction_non_alphanumeric': 0.15411042944785275, 'fraction_numerical': 0.013251533742331288, 'mean_word_length': 3.425624321389794, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1449518', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1366, 'n_words': 365}