<commit_before>//
// *** Class AliRsnPairFunctions ***
//
// "Core" method for defining the work on a pari of particles.
// For one analysis, one must setup one of this for each pair he wants to analyze,
// adding to it all analysis which he desires to do.
// Here he defines the cuts, and the particle types and charges, and can add
// functions which do different operations on the same pair, and some binning
// with respect to some kinematic variables (eta, momentum)
//
// authors: <NAME> (email: <EMAIL>)
//          <NAME> (email: <EMAIL>)
//

#include <TList.h>

#include "AliLog.h"

#include "AliRsnMother.h"
#include "AliRsnEvent.h"
#include "AliRsnFunction.h"
#include "AliRsnCutSet.h"
#include "AliRsnValue.h"

#include "AliRsnPairFunctions.h"

ClassImp(AliRsnPairFunctions)

//_____________________________________________________________________________
AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) :
   AliRsnPair(name, def),
   fFunctions("AliRsnFunction", 0)
{
//
// Default constructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) :
   AliRsnPair(copy),
   fFunctions(copy.fFunctions)
{
//
// Default constructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy)
{
   AliRsnPair::operator=(copy);

   Int_t i, n = copy.fFunctions.GetEntries();
   for (i = 0; i < n; i++) {
      AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i];
      if (fcn) AddFunction(fcn);
   }

   return (*this);
}

//_____________________________________________________________________________
AliRsnPairFunctions::~AliRsnPairFunctions()
{
//
// Destructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::Compute()
{
//
// Makes computations using the two passed daughter objects.
// Checks all cuts and then computes the corresponding pair object
// and then fill the list of required values using it.
//

   AliDebug(AliLog::kDebug + 2, "<-");

   TObjArrayIter   nextFcn(&fFunctions);
   AliRsnFunction *fcn = 0x0;

   while ((fcn = (AliRsnFunction*)nextFcn())) {
      fcn->SetPairDef(fPairDef);
      fcn->SetPair(&fMother);
      fcn->Fill();
   }

   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::Init(const char *prefix, TList *list)
{
//
// Generates needed histograms, giving them a name based on
// the flags defined here, on the pair definition, and attaches
// a prefix to it, according to the argument.
//
// All generated histograms are stored into the output TList.
//

   AliDebug(AliLog::kDebug + 2, "<-");

   Int_t  i;
   TString hName("");
   AliRsnFunction *fcn = 0;
   for (i = 0; i < fFunctions.GetEntries(); i++) {
      fcn = (AliRsnFunction*)fFunctions.At(i);
      hName += prefix;
      hName += '_';
      hName += GetName();
      hName += '_';
      hName += fcn->GetName();
      if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
      else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
   }

   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn)
{
//
// Adds a new computing function
//

   AliDebug(AliLog::kDebug + 2, "<-");

   fFunctions.Print();
   Int_t size = fFunctions.GetEntries();
   new(fFunctions[size]) AliRsnFunction(*fcn);

   AliDebug(AliLog::kDebug + 2, "->");
}<commit_msg>Fix of a bug that arises when adding more than 1 function to AliRsnPairFunctions<commit_after>//
// *** Class AliRsnPairFunctions ***
//
// "Core" method for defining the work on a pari of particles.
// For one analysis, one must setup one of this for each pair he wants to analyze,
// adding to it all analysis which he desires to do.
// Here he defines the cuts, and the particle types and charges, and can add
// functions which do different operations on the same pair, and some binning
// with respect to some kinematic variables (eta, momentum)
//
// authors: <NAME> (email: <EMAIL>)
//          <NAME> (email: <EMAIL>)
//

#include <TList.h>

#include "AliLog.h"

#include "AliRsnMother.h"
#include "AliRsnEvent.h"
#include "AliRsnFunction.h"
#include "AliRsnCutSet.h"
#include "AliRsnValue.h"

#include "AliRsnPairFunctions.h"

ClassImp(AliRsnPairFunctions)

//_____________________________________________________________________________
AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) :
   AliRsnPair(name, def),
   fFunctions("AliRsnFunction", 0)
{
//
// Default constructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) :
   AliRsnPair(copy),
   fFunctions(copy.fFunctions)
{
//
// Default constructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy)
{
   AliRsnPair::operator=(copy);

   Int_t i, n = copy.fFunctions.GetEntries();
   for (i = 0; i < n; i++) {
      AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i];
      if (fcn) AddFunction(fcn);
   }

   return (*this);
}

//_____________________________________________________________________________
AliRsnPairFunctions::~AliRsnPairFunctions()
{
//
// Destructor
//

   AliDebug(AliLog::kDebug + 2, "<-");
   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::Compute()
{
//
// Makes computations using the two passed daughter objects.
// Checks all cuts and then computes the corresponding pair object
// and then fill the list of required values using it.
//

   AliDebug(AliLog::kDebug + 2, "<-");

   TObjArrayIter   nextFcn(&fFunctions);
   AliRsnFunction *fcn = 0x0;

   while ((fcn = (AliRsnFunction*)nextFcn())) {
      fcn->SetPairDef(fPairDef);
      fcn->SetPair(&fMother);
      fcn->Fill();
   }

   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::Init(const char *prefix, TList *list)
{
//
// Generates needed histograms, giving them a name based on
// the flags defined here, on the pair definition, and attaches
// a prefix to it, according to the argument.
//
// All generated histograms are stored into the output TList.
//

   AliDebug(AliLog::kDebug + 2, "<-");

   Int_t  i;
   TString hName("");
   AliRsnFunction *fcn = 0;
   for (i = 0; i < fFunctions.GetEntries(); i++) {
      fcn = (AliRsnFunction*)fFunctions.At(i);
      hName  = prefix;
      hName += '_';
      hName += GetName();
      hName += '_';
      hName += fcn->GetName();
      if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
      else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
   }

   AliDebug(AliLog::kDebug + 2, "->");
}

//_____________________________________________________________________________
void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn)
{
//
// Adds a new computing function
//

   AliDebug(AliLog::kDebug + 2, "<-");

   fFunctions.Print();
   Int_t size = fFunctions.GetEntries();
   new(fFunctions[size]) AliRsnFunction(*fcn);

   AliDebug(AliLog::kDebug + 2, "->");
}
{'fraction_non_alphanumeric': 0.13810773653293337, 'fraction_numerical': 0.004874390701162355, 'mean_word_length': 4.2818481848184815, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 43, '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': '7472515', 'n_tokens_mistral': 2465, 'n_tokens_neox': 2381, 'n_words': 595}