<commit_before>#include <iostream>
#include <vector>

#include "THnSparse.h"
#include "THn.h"
#include "TList.h"
#include "TMath.h"
#include "TVectorF.h"
#include "TMatrix.h"
#include "TRandom3.h"

#include "AliAODEvent.h"
#include "AliAODMCParticle.h"
#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliLog.h"
#include "AliMCEvent.h"
#include "AliMultSelection.h"
#include "AliStack.h"
#include "AliVEvent.h"

#include "AliAnalysisTaskC2.h"
#include "AliAnalysisC2Utils.h"

using std::cout;
using std::endl;
  
//________________________________________________________________________
AliAnalysisTaskC2::AliAnalysisTaskC2()
  : AliAnalysisTaskC2Base(),
    fEventCounter(0),
    fSingles(0),
    fPairs(0),
    fcents(0),
    fRndmGenerator(0)
{
}

//________________________________________________________________________
AliAnalysisTaskC2::AliAnalysisTaskC2(const char *name, Int_t mode)
  : AliAnalysisTaskC2Base(name, mode),
    fEventCounter(0),
    fSingles(0),
    fPairs(0),
    fcents(0),
    fRndmGenerator(0)
{
  DefineOutput(1, TList::Class());
}

//________________________________________________________________________
void AliAnalysisTaskC2::UserCreateOutputObjects()
{
  // Call the base class to set up histograms there
  AliAnalysisTaskC2Base::UserCreateOutputObjects();
  // Setup output list if it was not done already
  if (!this->fOutputList){
    this->fOutputList = new TList();
    this->fOutputList->SetOwner();
  }
  
  // Setup up 2-particle density histogram
  // eta1, eta2, phi1, phi2, cent, zvtx
  const Int_t etaNbins = 15;
  // phiNbins must be divisable by 2, but not by 4; so that we can later shift it by pi/2 (2pi is total int.)
  // The idea is to have the deltaPhi histogram with a bin centered arround 0
  const Int_t phiNbins = 26;
  const Double_t pt_bin_edges[] = {3.0, 4.0, 6.0, 8.0, 15.0};
  const Int_t npTbins = sizeof(pt_bin_edges) / sizeof(pt_bin_edges[0]) - 1;
  const Int_t nptPairBins = AliAnalysisC2Utils::ComputePtPairBin(npTbins, npTbins) + 1;
  const Double_t cent_bin_edges[] = {0, 20, 40, 90};
  const Int_t nCent    = sizeof(cent_bin_edges)/sizeof(cent_bin_edges[0]) - 1;
  const Int_t nZvtx    = 20;
  const Int_t nbins[cPairsDims::kNdimensions] = {etaNbins, etaNbins,
						 phiNbins, phiNbins,
						 nptPairBins,
						 nCent, nZvtx};
  const Double_t xmin[cPairsDims::kNdimensions] = {-0.8, -0.8,
						   0, 0,
						   0,
						   0, -10};
  const Double_t xmax[cPairsDims::kNdimensions] = {0.8, 0.8,
						   2*TMath::Pi(), 2*TMath::Pi(),
						   Double_t(nptPairBins),
						   100, 10};
  this->fPairs = new THnC("pairs",
			  "<N_{1}N_{2}>;#eta_{1};#eta_{2};#phi_{1};#phi_{2};p_{pair};cent;z_{vtx};",
			  cPairsDims::kNdimensions, nbins, xmin, xmax);
  this->fPairs->GetAxis(cPairsDims::kCent)->Set(nCent, cent_bin_edges);
  // exclude_over_under_flow(this->fPairs);
  this->fOutputList->Add(fPairs);

  {
    // eta, phi, pt, cent, zvtx
    // Reuse values from pairs histogram where appropriate
    Int_t nbins_singles[cSinglesDims::kNdimensions] = {nbins[cPairsDims::kEta1],
						       nbins[cPairsDims::kPhi1],
						       npTbins,
						       nbins[cPairsDims::kCent],
						       nbins[cPairsDims::kZvtx]};
    Double_t xmin_singles[cSinglesDims::kNdimensions] = {xmin[cPairsDims::kEta1],
							 xmin[cPairsDims::kPhi1],
							 0,  // Dummy
							 xmin[cPairsDims::kCent],
							 xmin[cPairsDims::kZvtx]};
    Double_t xmax_singles[cSinglesDims::kNdimensions] = {xmax[cPairsDims::kEta1],
							 xmax[cPairsDims::kPhi1],
							 1,  // Dummy
							 xmax[cPairsDims::kCent],
							 xmax[cPairsDims::kZvtx]};
    this->fSingles = new THnS("singles", "<N_{1}>;#eta_{1};#phi_{1};p_{T};cent;z_{vtx};",
			      cSinglesDims::kNdimensions, nbins_singles, xmin_singles, xmax_singles);
    this->fSingles->GetAxis(cSinglesDims::kPt)->Set(npTbins, pt_bin_edges);
    this->fSingles->GetAxis(cSinglesDims::kCent)->Set(nCent, cent_bin_edges);
    this->fOutputList->Add(this->fSingles);
  }
  {
    // Event counter
    Int_t nbins_evt_counter[cEventCounterDims::kNdimensions] =
      {nbins[cEventCounterDims::kCent], nbins[cPairsDims::kZvtx]};
    Double_t xmin_evt_counter[cEventCounterDims::kNdimensions] =
      {xmin[cEventCounterDims::kCent], xmin[cPairsDims::kZvtx]};
    Double_t xmax_evt_counter[cEventCounterDims::kNdimensions] =
      {xmax[cEventCounterDims::kCent], xmax[cPairsDims::kZvtx]};
    this->fEventCounter = new THnF("eventCounter", "Event counter;cent;z_{vtx};",
				   cEventCounterDims::kNdimensions,
				   nbins_evt_counter, xmin_evt_counter, xmax_evt_counter);
    this->fEventCounter->GetAxis(cEventCounterDims::kCent)->Set(nCent, cent_bin_edges);
    this->fOutputList->Add(this->fEventCounter);
  }

  // Debug hists
  this->fcents = new TH1F("cents", "cents", 210, 0, 210);
  this->fOutputList->Add(this->fcents);

  // this->fRndmGenerator = new TRandom3();
  
  AliLog::SetGlobalLogLevel(AliLog::kError);
  PostData(1, fOutputList);
}

//________________________________________________________________________
void AliAnalysisTaskC2::UserExec(Option_t *)
{
  // AODEvent() returns a null pointer for whatever reason...
  AliMCEvent*   mcEvent = this->MCEvent();
  AliAODEvent* aodEvent = dynamic_cast< AliAODEvent* >(this->InputEvent());
  if (!this->IsValidEvent())
    return;
  AliMultSelection *multSelection =
    dynamic_cast< AliMultSelection* >(this->InputEvent()->FindListObject("MultSelection"));
  if( !multSelection){
    AliWarning("AliMultSelection object not found!");<commit_msg>Fixed bug in number of bins in event counter<commit_after>#include <iostream>
#include <vector>

#include "THnSparse.h"
#include "THn.h"
#include "TList.h"
#include "TMath.h"
#include "TVectorF.h"
#include "TMatrix.h"
#include "TRandom3.h"

#include "AliAODEvent.h"
#include "AliAODMCParticle.h"
#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliLog.h"
#include "AliMCEvent.h"
#include "AliMultSelection.h"
#include "AliStack.h"
#include "AliVEvent.h"

#include "AliAnalysisTaskC2.h"
#include "AliAnalysisC2Utils.h"

using std::cout;
using std::endl;
  
//________________________________________________________________________
AliAnalysisTaskC2::AliAnalysisTaskC2()
  : AliAnalysisTaskC2Base(),
    fEventCounter(0),
    fSingles(0),
    fPairs(0),
    fcents(0),
    fRndmGenerator(0)
{
}

//________________________________________________________________________
AliAnalysisTaskC2::AliAnalysisTaskC2(const char *name, Int_t mode)
  : AliAnalysisTaskC2Base(name, mode),
    fEventCounter(0),
    fSingles(0),
    fPairs(0),
    fcents(0),
    fRndmGenerator(0)
{
  DefineOutput(1, TList::Class());
}

//________________________________________________________________________
void AliAnalysisTaskC2::UserCreateOutputObjects()
{
  // Call the base class to set up histograms there
  AliAnalysisTaskC2Base::UserCreateOutputObjects();
  // Setup output list if it was not done already
  if (!this->fOutputList){
    this->fOutputList = new TList();
    this->fOutputList->SetOwner();
  }
  
  // Setup up 2-particle density histogram
  // eta1, eta2, phi1, phi2, cent, zvtx
  const Int_t etaNbins = 15;
  // phiNbins must be divisable by 2, but not by 4; so that we can later shift it by pi/2 (2pi is total int.)
  // The idea is to have the deltaPhi histogram with a bin centered arround 0
  const Int_t phiNbins = 26;
  const Double_t pt_bin_edges[] = {3.0, 4.0, 6.0, 8.0, 15.0};
  const Int_t npTbins = sizeof(pt_bin_edges) / sizeof(pt_bin_edges[0]) - 1;
  const Int_t nptPairBins = AliAnalysisC2Utils::ComputePtPairBin(npTbins, npTbins) + 1;
  const Double_t cent_bin_edges[] = {0, 20, 40, 90};
  const Int_t nCent    = sizeof(cent_bin_edges)/sizeof(cent_bin_edges[0]) - 1;
  const Int_t nZvtx    = 20;
  const Int_t nbins_pairs[cPairsDims::kNdimensions] = {
    etaNbins, etaNbins,
    phiNbins, phiNbins,
    nptPairBins,
    nCent, nZvtx};
  const Double_t xmin_pairs[cPairsDims::kNdimensions] = {
    -0.8, -0.8,
    0, 0,
    0,
    0, -10};
  const Double_t xmax_pairs[cPairsDims::kNdimensions] = {
    0.8, 0.8,
    2*TMath::Pi(), 2*TMath::Pi(),
    Double_t(nptPairBins),
    100, 10};
  this->fPairs = new THnC("pairs",
			  "<N_{1}N_{2}>;#eta_{1};#eta_{2};#phi_{1};#phi_{2};p_{pair};cent;z_{vtx};",
			  cPairsDims::kNdimensions, nbins_pairs, xmin_pairs, xmax_pairs);
  this->fPairs->GetAxis(cPairsDims::kCent)->Set(nCent, cent_bin_edges);
  // exclude_over_under_flow(this->fPairs);
  this->fOutputList->Add(fPairs);

  {
    // eta, phi, pt, cent, zvtx
    // Reuse values from pairs histogram where appropriate
    Int_t nbins_singles[cSinglesDims::kNdimensions] = {
      nbins_pairs[cPairsDims::kEta1],
      nbins_pairs[cPairsDims::kPhi1],
      npTbins,
      nbins_pairs[cPairsDims::kCent],
      nbins_pairs[cPairsDims::kZvtx]};
    Double_t xmin_singles[cSinglesDims::kNdimensions] = {
      xmin_pairs[cPairsDims::kEta1],
      xmin_pairs[cPairsDims::kPhi1],
      0,  // Dummy
      xmin_pairs[cPairsDims::kCent],
      xmin_pairs[cPairsDims::kZvtx]};
    Double_t xmax_singles[cSinglesDims::kNdimensions] = {
      xmax_pairs[cPairsDims::kEta1],
      xmax_pairs[cPairsDims::kPhi1],
      1,  // Dummy
      xmax_pairs[cPairsDims::kCent],
      xmax_pairs[cPairsDims::kZvtx]};
    this->fSingles = new THnS("singles", "<N_{1}>;#eta_{1};#phi_{1};p_{T};cent;z_{vtx};",
			      cSinglesDims::kNdimensions, nbins_singles, xmin_singles, xmax_singles);
    this->fSingles->GetAxis(cSinglesDims::kPt)->Set(npTbins, pt_bin_edges);
    this->fSingles->GetAxis(cSinglesDims::kCent)->Set(nCent, cent_bin_edges);
    this->fOutputList->Add(this->fSingles);
  }
  {
    // Event counter
    Int_t nbins_evt_counter[cEventCounterDims::kNdimensions] = {
      nbins_pairs[cPairsDims::kCent],
      nbins_pairs[cPairsDims::kZvtx]
    };
    Double_t xmin_evt_counter[cEventCounterDims::kNdimensions] = {
      xmin_pairs[cPairsDims::kCent],
      xmin_pairs[cPairsDims::kZvtx]
    };
    Double_t xmax_evt_counter[cEventCounterDims::kNdimensions] = {
      xmax_pairs[cPairsDims::kCent],
      xmax_pairs[cPairsDims::kZvtx]
    };
    this->fEventCounter = new THnF("eventCounter", "Event counter;cent;z_{vtx};",
				   cEventCounterDims::kNdimensions,
				   nbins_evt_counter, xmin_evt_counter, xmax_evt_counter);
    this->fEventCounter->GetAxis(cEventCounterDims::kCent)->Set(nCent, cent_bin_edges);
    this->fOutputList->Add(this->fEventCounter);
  }

  // Debug hists
  this->fcents = new TH1F("cents", "cents", 210, 0, 210);
  this->fOutputList->Add(this->fcents);

  // this->fRndmGenerator = new TRandom3();
  
  AliLog::SetGlobalLogLevel(AliLog::kError);
  PostData(1, fOutputList);
}

//________________________________________________________________________
void AliAnalysisTaskC2::UserExec(Option_t *)
{
  // AODEvent() returns a null pointer for whatever reason...
  AliMCEvent*   mcEvent = this->MCEvent();
  AliAODEvent* aodEvent = dynamic_cast< AliAODEvent* >(this->InputEvent());
  if (!this->IsValidEvent())
    return;
  AliMultSelection *multSelection =
    dynamic_cast< AliMultSelection* >(this->InputEvent()->FindListObject("MultSelection"));
  if( !multSelection){
    AliWarning("AliMultSelection object not found!");
{'fraction_non_alphanumeric': 0.14044793432676006, 'fraction_numerical': 0.01980904791648077, 'mean_word_length': 4.565044687189673, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 91, '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': '1203950', 'n_tokens_mistral': 4560, 'n_tokens_neox': 4241, 'n_words': 703}