<commit_before>// $Header$

#include "EventAlieve.h"
#include <Reve/Reve.h>

#include <AliRunLoader.h>
#include <AliESD.h>
#include <AliESDfriend.h>

#include <TFile.h>
#include <TTree.h>

#include <TROOT.h>
#include <TSystem.h>

using namespace Reve;
using namespace Alieve;

//______________________________________________________________________
// Event
//

ClassImp(Event)

Event* Alieve::gEvent = 0;

Bool_t Alieve::Event::fgUseRunLoader = true;
Bool_t Alieve::Event::fgUseESDTree   = true;

void Event::Initialize(Bool_t use_runloader, Bool_t use_esd)
{
  static const Exc_t eH("Event::Initialize ");

  fgUseRunLoader = use_runloader;
  fgUseESDTree   = use_esd;

  /*
  if(fgUseRunLoader == false && fgUseESDTree == false)
    throw(eH + "should use at least one data source.");

  if(fgUseRunLoader) {
    AssertMacro("loadlibs.C");
  }
  else if(fgUseESDTree) {
    gSystem->Load("libESD.so");
  }
  */
}

/**************************************************************************/

Event::Event() :
  EventBase(),

  fPath (), fEventId   (0),
  fRunLoader (0),
  fESDFile       (0), fESDTree       (0), fESD       (0),
  fESDfriendFile (0), fESDfriendTree (0), fESDfriend (0)
{}

Event::Event(TString path, Int_t ev) :
  EventBase("AliEVE Event"),

  fPath (path), fEventId(ev),
  fRunLoader (0),
  fESDFile       (0), fESDTree       (0), fESD       (0),
  fESDfriendFile (0), fESDfriendTree (0), fESDfriend (0)
{
  Open();
}

/**************************************************************************/

void Event::Open()
{
  static const Exc_t eH("Event::Open ");

  gSystem->ExpandPathName(fPath);
  if(fPath[0] != '/')
    fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data());

  if(fgUseRunLoader) {
    TString ga_path(Form("%s/galice.root", fPath.Data()));
    if(gSystem->AccessPathName(ga_path, kReadPermission))
      throw(eH + "can not read '" + ga_path + "'.");
    fRunLoader = AliRunLoader::Open(ga_path);
    if(!fRunLoader)
      throw(eH + "failed opening ALICE run loader from '" + ga_path + "'.");
    {
      TString alice_path = fPath + "/";
      fRunLoader->SetDirName(alice_path);
    }
    if(fRunLoader->LoadgAlice() != 0)
      throw(eH + "failed loading gAlice.");

    if(fRunLoader->GetEvent(fEventId) != 0)
      throw(eH + "failed getting required event.");
  }

  if(fgUseESDTree) {
    TString p(Form("%s/AliESDs.root", fPath.Data()));
    if(gSystem->AccessPathName(p, kReadPermission))
      throw(eH + "can not read '" + p + "'.");
    fESDFile = new TFile(p);
    if(fESDFile->IsZombie()) {
      delete fESDFile; fESDFile = 0;
      throw(eH + "failed opening ALICE ESD from '" + p + "'.");
    }
<commit_msg>During opening of a run via run-loader also load run-header.<commit_after>// $Header$

#include "EventAlieve.h"
#include <Reve/Reve.h>

#include <AliRunLoader.h>
#include <AliESD.h>
#include <AliESDfriend.h>

#include <TFile.h>
#include <TTree.h>

#include <TROOT.h>
#include <TSystem.h>

using namespace Reve;
using namespace Alieve;

//______________________________________________________________________
// Event
//

ClassImp(Event)

Event* Alieve::gEvent = 0;

Bool_t Alieve::Event::fgUseRunLoader = true;
Bool_t Alieve::Event::fgUseESDTree   = true;

void Event::Initialize(Bool_t use_runloader, Bool_t use_esd)
{
  static const Exc_t eH("Event::Initialize ");

  fgUseRunLoader = use_runloader;
  fgUseESDTree   = use_esd;

  /*
  if(fgUseRunLoader == false && fgUseESDTree == false)
    throw(eH + "should use at least one data source.");

  if(fgUseRunLoader) {
    AssertMacro("loadlibs.C");
  }
  else if(fgUseESDTree) {
    gSystem->Load("libESD.so");
  }
  */
}

/**************************************************************************/

Event::Event() :
  EventBase(),

  fPath (), fEventId   (0),
  fRunLoader (0),
  fESDFile       (0), fESDTree       (0), fESD       (0),
  fESDfriendFile (0), fESDfriendTree (0), fESDfriend (0)
{}

Event::Event(TString path, Int_t ev) :
  EventBase("AliEVE Event"),

  fPath (path), fEventId(ev),
  fRunLoader (0),
  fESDFile       (0), fESDTree       (0), fESD       (0),
  fESDfriendFile (0), fESDfriendTree (0), fESDfriend (0)
{
  Open();
}

/**************************************************************************/

void Event::Open()
{
  static const Exc_t eH("Event::Open ");

  gSystem->ExpandPathName(fPath);
  if(fPath[0] != '/')
    fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data());

  if(fgUseRunLoader) {
    TString ga_path(Form("%s/galice.root", fPath.Data()));
    if(gSystem->AccessPathName(ga_path, kReadPermission))
      throw(eH + "can not read '" + ga_path + "'.");
    fRunLoader = AliRunLoader::Open(ga_path);
    if(!fRunLoader)
      throw(eH + "failed opening ALICE run loader from '" + ga_path + "'.");
    {
      TString alice_path = fPath + "/";
      fRunLoader->SetDirName(alice_path);
    }
    if(fRunLoader->LoadgAlice() != 0)
      throw(eH + "failed loading gAlice.");
    if(fRunLoader->LoadHeader() != 0)
      throw(eH + "failed loading header.");

    if(fRunLoader->GetEvent(fEventId) != 0)
      throw(eH + "failed getting required event.");
  }

  if(fgUseESDTree) {
    TString p(Form("%s/AliESDs.root", fPath.Data()));
    if(gSystem->AccessPathName(p, kReadPermission))
      throw(eH + "can not read '" + p + "'.");
    fESDFile = new TFile(p);
    if(fESDFile->IsZombie()) {
      delete fESDFile; fESDFile = 0;
      throw(eH + "failed opening ALICE ESD from '" + p + "'.");
    }

{'fraction_non_alphanumeric': 0.2120051085568327, 'fraction_numerical': 0.0074803867907316185, 'mean_word_length': 3.8214599824098503, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 38, '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': '892309', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1971, 'n_words': 389}