<commit_before>/*
 * AliFemtoDreamCorrHists.cxx
 *
 *  Created on: Sep 12, 2017
 *      Author: gu74req
 */
#include <iostream>
#include <vector>
#include "AliFemtoDreamCorrHists.h"
#include "TMath.h"
ClassImp(AliFemtoDreamCorrHists)
AliFemtoDreamCorrHists::AliFemtoDreamCorrHists()
:fQA(0)
,fResults(0)
,fPairs(0)
,fPairQA(0)
,fMinimalBooking(false)
,fMomentumResolution(false)
,fSameEventDist(0)
,fSameEventMultDist(0)
,fPairCounterSE(0)
,fMixedEventDist(0)
,fMixedEventMultDist(0)
,fPairCounterME(0)
,fMomResolution(0)
,fDoMultBinning(false)
{
}

AliFemtoDreamCorrHists::AliFemtoDreamCorrHists(
    AliFemtoDreamCollConfig *conf,bool MinimalBooking) {
  fResults=new TList();
  fResults->SetName("Results");
  fResults->SetOwner();
  if (!fMinimalBooking) {
    fQA=new TList();
    fQA->SetName("PairQA");
    fQA->SetOwner();
  }
  fMinimalBooking=MinimalBooking;
  fMomentumResolution=conf->GetDoMomResolution();
  fDoMultBinning=conf->GetDoMultBinning();
  int multbins=conf->GetNMultBins();
  int nParticles=conf->GetNParticles();
  const int nHists=conf->GetNParticleCombinations();
  std::vector<int> NBinsHist=conf->GetNBinsHist();
  std::vector<int>::iterator itNBins=NBinsHist.begin();
  std::vector<float> kRelMin=conf->GetMinKRel();
  std::vector<float>::iterator itKMin=kRelMin.begin();
  std::vector<float> kRelMax=conf->GetMaxKRel();
  std::vector<float>::iterator itKMax=kRelMax.begin();

  if (nHists!=(int)NBinsHist.size() || nHists!=(int)kRelMin.size() ||
      nHists!=(int)kRelMax.size()) {
    //Todo: Replace by AliFatal!
    std::cout<<"something went horribly wrong!"<<std::endl;
  }
  //The way the histograms are assigned later is going to be for example for
  //4 different particle species X1,X2,X3,X4:
  //    X1  X2  X3  X4
  //X1  1   2   3   4
  //X2      5   6   7
  //X3          8   9
  //X4              10<-----Number of the Histogram=Position in input vector
  //X1 corresponds the first particle array in your vector that you hand over
  //in the AliFemtoDreamPartCollection::SetEvent Method, X2 to the second and
  //so on.
  //in case we only book the most basic things we don't need this
  if (!fMinimalBooking) {
    fPairQA=new TList*[nHists];
    fPairCounterSE=new TH2F*[nHists];
    fPairCounterME=new TH2F*[nHists];
    if (fMomentumResolution) {
      fMomResolution=new TH2F*[nHists];
    }
  }
  //we always want to do this, regardless of the booking type!
  fPairs=new TList*[nHists];
  fSameEventDist=new TH1F*[nHists];
  fMixedEventDist=new TH1F*[nHists];
  if (fDoMultBinning) {
    fSameEventMultDist=new TH2F*[nHists];
    fMixedEventMultDist=new TH2F*[nHists];
  } else {
    fSameEventMultDist=0;
    fMixedEventMultDist=0;
  }
  int Counter=0;
  for (int iPar1 = 0; iPar1 < nParticles; ++iPar1) {
    for (int iPar2 = iPar1; iPar2 < nParticles; ++iPar2) {
      fPairs[Counter]=new TList();
      TString PairFolderName=Form("Particle%d_Particle%d",iPar1,iPar2);
      fPairs[Counter]->SetName(PairFolderName.Data());
      fPairs[Counter]->SetOwner();
      fResults->Add(fPairs[Counter]);

      TString SameEventName=Form("SEDist_Particle%d_Particle%d",iPar1,iPar2);
      fSameEventDist[Counter]=new TH1F(SameEventName.Data(),
                                       SameEventName.Data(),
                                       *itNBins,*itKMin,*itKMax);
      fSameEventDist[Counter]->Sumw2();
      fPairs[Counter]->Add(fSameEventDist[Counter]);<commit_msg>Wrong order of initialization of fMinimalBooking and the fQA TList led to a Segmentation Violation. Nobody wants that.<commit_after>/*
 * AliFemtoDreamCorrHists.cxx
 *
 *  Created on: Sep 12, 2017
 *      Author: gu74req
 */
#include <iostream>
#include <vector>
#include "AliFemtoDreamCorrHists.h"
#include "TMath.h"
ClassImp(AliFemtoDreamCorrHists)
AliFemtoDreamCorrHists::AliFemtoDreamCorrHists()
:fQA(0)
,fResults(0)
,fPairs(0)
,fPairQA(0)
,fMinimalBooking(false)
,fMomentumResolution(false)
,fSameEventDist(0)
,fSameEventMultDist(0)
,fPairCounterSE(0)
,fMixedEventDist(0)
,fMixedEventMultDist(0)
,fPairCounterME(0)
,fMomResolution(0)
,fDoMultBinning(false)
{
}

AliFemtoDreamCorrHists::AliFemtoDreamCorrHists(
    AliFemtoDreamCollConfig *conf,bool MinimalBooking) {
  fMinimalBooking=MinimalBooking;
  fMomentumResolution=conf->GetDoMomResolution();
  fDoMultBinning=conf->GetDoMultBinning();
  int multbins=conf->GetNMultBins();
  int nParticles=conf->GetNParticles();
  const int nHists=conf->GetNParticleCombinations();
  std::vector<int> NBinsHist=conf->GetNBinsHist();
  std::vector<int>::iterator itNBins=NBinsHist.begin();
  std::vector<float> kRelMin=conf->GetMinKRel();
  std::vector<float>::iterator itKMin=kRelMin.begin();
  std::vector<float> kRelMax=conf->GetMaxKRel();
  std::vector<float>::iterator itKMax=kRelMax.begin();

  if (nHists!=(int)NBinsHist.size() || nHists!=(int)kRelMin.size() ||
      nHists!=(int)kRelMax.size()) {
    //Todo: Replace by AliFatal!
    std::cout<<"Initialzing the bin sizes, something went horribly wrong!"<<std::endl;
  }
  //The way the histograms are assigned later is going to be for example for
  //4 different particle species X1,X2,X3,X4:
  //    X1  X2  X3  X4
  //X1  1   2   3   4
  //X2      5   6   7
  //X3          8   9
  //X4              10<-----Number of the Histogram=Position in input vector
  //X1 corresponds the first particle array in your vector that you hand over
  //in the AliFemtoDreamPartCollection::SetEvent Method, X2 to the second and
  //so on.
  //in case we only book the most basic things we don't need this
  fResults=new TList();
  fResults->SetName("Results");
  fResults->SetOwner();

  if (!fMinimalBooking) {
    fQA=new TList();
    fQA->SetName("PairQA");
    fQA->SetOwner();

    fPairQA=new TList*[nHists];
    fPairCounterSE=new TH2F*[nHists];
    fPairCounterME=new TH2F*[nHists];
    if (fMomentumResolution) {
      fMomResolution=new TH2F*[nHists];
    }
  } else {
    fQA=0;
    fPairQA=0;
    fPairCounterSE=0;
    fPairCounterME=0;
    fMomResolution=0;
  }
  //we always want to do this, regardless of the booking type!
  fPairs=new TList*[nHists];
  fSameEventDist=new TH1F*[nHists];
  fMixedEventDist=new TH1F*[nHists];
  if (fDoMultBinning) {
    fSameEventMultDist=new TH2F*[nHists];
    fMixedEventMultDist=new TH2F*[nHists];
  } else {
    fSameEventMultDist=0;
    fMixedEventMultDist=0;
  }
  int Counter=0;
  for (int iPar1 = 0; iPar1 < nParticles; ++iPar1) {
    for (int iPar2 = iPar1; iPar2 < nParticles; ++iPar2) {
      fPairs[Counter]=new TList();
      TString PairFolderName=Form("Particle%d_Particle%d",iPar1,iPar2);
      fPairs[Counter]->SetName(PairFolderName.Data());
      fPairs[Counter]->SetOwner();
      fResults->Add(fPairs[Counter]);

      TString SameEventName=Form("SEDist_Particle%d_Particle%d",iPar1,iPar2);
      fSameEventDist[Counter]=new TH1F(SameEventName.Data(),
                                       SameEventName.Data(),
                                       *itNBins,*itKMin,*itKMax);
      fSameEventDist[Counter]->Sumw2();
      fPairs[Counter]->Add(fSameEventDist[Counter]);
{'fraction_non_alphanumeric': 0.1357132738348208, 'fraction_numerical': 0.020257826887661142, 'mean_word_length': 4.079136690647482, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3951080', 'n_tokens_mistral': 2758, 'n_tokens_neox': 2678, 'n_words': 484}