<commit_before>#include "TChain.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "TParticle.h"
#include "TObjArray.h"

#include "AliAnalysisTask.h"
#include "AliAnalysisManager.h"

#include "AliStack.h"
#include "AliMCEvent.h"
#include "AliESDEvent.h"
#include "AliESDInputHandler.h"
#include "AliESDtrackCuts.h"
#include "AliCentrality.h"

#include "AliEbyEFluctuationAnalysisTask.h"

// Event by event charge fluctuation analysis
// Authors: <NAME> and <NAME>
// 

ClassImp(AliEbyEFluctuationAnalysisTask)

//________________________________________________________________________
AliEbyEFluctuationAnalysisTask::AliEbyEFluctuationAnalysisTask(const char *name) 
  : AliAnalysisTaskSE(name), fESD(0), fOutputList(0), 
    fHistEventStats(0), fHistCentrality(0),
    fHistNMultMC(0), fHistNPlusNMinusMC(0), 
    fESDtrackCuts(0),
    fAnalysisType("ESD"), fAnalysisMode("TPC"),
    fCentralityEstimator("V0M"), fCentralityBins20(kFALSE),
    fVxMax(3.), fVyMax(3.), fVzMax(10.) {
  // Constructor
  
  for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
    fHistNMult[iBin-1] = NULL;
    fHistNPlusNMinus[iBin-1] = NULL;
  }

  // Define input and output slots here
  // Input slot #0 works with a TChain
  DefineInput(0, TChain::Class());
  // Output slot #0 id reserved by the base class for AOD
  // Output slot #1 writes into a TH1 container
  DefineOutput(1, TList::Class());
}

//________________________________________________________________________
void AliEbyEFluctuationAnalysisTask::UserCreateOutputObjects() {
  // Create histograms
  // Called once

  fOutputList = new TList();
  fOutputList->SetOwner();

  //Event stats.
  TString gCutName[4] = {"Total","Offline trigger",
                         "Vertex","Analyzed"};
  fHistEventStats = new TH1F("fHistEventStats",
                             "Event statistics;;N_{events}",
                             4,0.5,4.5);
  for(Int_t i = 1; i <= 4; i++)
    fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data());
  fOutputList->Add(fHistEventStats);

  //ESD analysis
  if(fAnalysisType == "ESD") {
    fHistCentrality = new TH1F("fHistCentrality",";Centrality bin;Events",
			       nCentralityBins,0.5,nCentralityBins+0.5);
    fOutputList->Add(fHistCentrality);
    
    TString histName;
    for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
      histName = "fHistNMult"; histName += "Centrality"; histName += iBin; 
      fHistNMult[iBin-1] = new TH1F(histName.Data(), 
				    ";N_{mult.}",
				    500,0,3000);
      fOutputList->Add(fHistNMult[iBin-1]);
    }
    for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
      histName = "fHistNPlusNMinus"; histName += "Centrality"; histName += iBin; 
      fHistNPlusNMinus[iBin-1] = new TH2F(histName.Data(), 
					  ";N_{+};N_{-}",
					  2000,0.5,2000.5,2000,0.5,2000.5);  
      fOutputList->Add(fHistNPlusNMinus[iBin-1]);
    }
  }//ESD analysis
  else if(fAnalysisType == "MC") {
    TString histName = "fHistNMultMC";
    fHistNMultMC = new TH1F(histName.Data(), 
			    ";N_{mult.}",
			    600,0,6000);
    fOutputList->Add(fHistNMultMC);
    
    histName = "fHistNPlusNMinusMC";
    fHistNPlusNMinusMC = new TH2F(histName.Data(), 
				  ";N_{+};N_{-}",
				  3000,0.5,3000.5,3000,0.5,3000.5);  
    fOutputList->Add(fHistNPlusNMinusMC);
  }//MC analysis
}

//________________________________________________________________________
void AliEbyEFluctuationAnalysisTask::UserExec(Option_t *) {
  // Main loop
  // Called for each event
  
  Int_t nPlus = 0, nMinus = 0;

  // Post output data.
  //ESD analysis
  if(fAnalysisType == "ESD") {
    fESD = dynamic_cast<AliESDEvent*>(InputEvent());
    if (!fESD) {
      printf("ERROR: fESD not available\n");
      return;
    }
  
    fHistEventStats->Fill(1); //all events
    
    //Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
    //if(isSelected) {
      fHistEventStats->Fill(2); //triggered + centrality
      Printf("Event accepted");

      //Centrality stuff
      AliCentrality *centrality = fESD->GetCentrality();
      Int_t nCentrality = 0;
      if(fCentralityBins20) 
	nCentrality = centrality->GetCentralityClass5(fCentralityEstimator.Data());
      else
	nCentrality = centrality->GetCentralityClass10(fCentralityEstimator.Data());

      if((nCentrality < 0)||(nCentrality > 19)) return;
      
      if(fAnalysisMode = "TPC") {
	const AliESDVertex *vertex = fESD->GetPrimaryVertexTPC();<commit_msg>Bug fix (Satya)<commit_after>#include "TChain.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TCanvas.h"
#include "TParticle.h"
#include "TObjArray.h"

#include "AliAnalysisTask.h"
#include "AliAnalysisManager.h"

#include "AliStack.h"
#include "AliMCEvent.h"
#include "AliESDEvent.h"
#include "AliESDInputHandler.h"
#include "AliESDtrackCuts.h"
#include "AliCentrality.h"

#include "AliEbyEFluctuationAnalysisTask.h"

// Event by event charge fluctuation analysis
// Authors: <NAME> and <NAME>
// 

ClassImp(AliEbyEFluctuationAnalysisTask)

//________________________________________________________________________
AliEbyEFluctuationAnalysisTask::AliEbyEFluctuationAnalysisTask(const char *name) 
  : AliAnalysisTaskSE(name), fESD(0), fOutputList(0), 
    fHistEventStats(0), fHistCentrality(0),
    fHistNMultMC(0), fHistNPlusNMinusMC(0), 
    fESDtrackCuts(0),
    fAnalysisType("ESD"), fAnalysisMode("TPC"),
    fCentralityEstimator("V0M"), fCentralityBins20(kFALSE),
    fVxMax(3.), fVyMax(3.), fVzMax(10.) {
  // Constructor
  
  for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
    fHistNMult[iBin-1] = NULL;
    fHistNPlusNMinus[iBin-1] = NULL;
  }

  // Define input and output slots here
  // Input slot #0 works with a TChain
  DefineInput(0, TChain::Class());
  // Output slot #0 id reserved by the base class for AOD
  // Output slot #1 writes into a TH1 container
  DefineOutput(1, TList::Class());
}

//________________________________________________________________________
void AliEbyEFluctuationAnalysisTask::UserCreateOutputObjects() {
  // Create histograms
  // Called once

  fOutputList = new TList();
  fOutputList->SetOwner();

  //Event stats.
  TString gCutName[4] = {"Total","Offline trigger",
                         "Vertex","Analyzed"};
  fHistEventStats = new TH1F("fHistEventStats",
                             "Event statistics;;N_{events}",
                             4,0.5,4.5);
  for(Int_t i = 1; i <= 4; i++)
    fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data());
  fOutputList->Add(fHistEventStats);

  //ESD analysis
  if(fAnalysisType == "ESD") {
    fHistCentrality = new TH1F("fHistCentrality",";Centrality bin;Events",
			       nCentralityBins,0.5,nCentralityBins+0.5);
    fOutputList->Add(fHistCentrality);
    
    TString histName;
    for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
      histName = "fHistNMult"; histName += "Centrality"; histName += iBin; 
      fHistNMult[iBin-1] = new TH1F(histName.Data(), 
				    ";N_{mult.}",
				    500,0,3000);
      fOutputList->Add(fHistNMult[iBin-1]);
    }
    for(Int_t iBin = 1; iBin <= nCentralityBins; iBin++) {
      histName = "fHistNPlusNMinus"; histName += "Centrality"; histName += iBin; 
      fHistNPlusNMinus[iBin-1] = new TH2F(histName.Data(), 
					  ";N_{+};N_{-}",
					  2000,0.5,2000.5,2000,0.5,2000.5);  
      fOutputList->Add(fHistNPlusNMinus[iBin-1]);
    }
  }//ESD analysis
  else if(fAnalysisType == "MC") {
    TString histName = "fHistNMultMC";
    fHistNMultMC = new TH1F(histName.Data(), 
			    ";N_{mult.}",
			    600,0,6000);
    fOutputList->Add(fHistNMultMC);
    
    histName = "fHistNPlusNMinusMC";
    fHistNPlusNMinusMC = new TH2F(histName.Data(), 
				  ";N_{+};N_{-}",
				  3000,0.5,3000.5,3000,0.5,3000.5);  
    fOutputList->Add(fHistNPlusNMinusMC);
  }//MC analysis
}

//________________________________________________________________________
void AliEbyEFluctuationAnalysisTask::UserExec(Option_t *) {
  // Main loop
  // Called for each event
  
  Int_t nPlus = 0, nMinus = 0;

  // Post output data.
  //ESD analysis
  if(fAnalysisType == "ESD") {
    fESD = dynamic_cast<AliESDEvent*>(InputEvent());
    if (!fESD) {
      printf("ERROR: fESD not available\n");
      return;
    }
  
    fHistEventStats->Fill(1); //all events
    
    //Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
    //if(isSelected) {
      fHistEventStats->Fill(2); //triggered + centrality
      Printf("Event accepted");

      //Centrality stuff
      AliCentrality *centrality = fESD->GetCentrality();
      Int_t nCentrality = 0;
      if(fCentralityBins20) 
	nCentrality = centrality->GetCentralityClass5(fCentralityEstimator.Data());
      else
	nCentrality = centrality->GetCentralityClass10(fCentralityEstimator.Data());

      if((nCentrality < 0)||(nCentrality > 19)) return;
      
      if(fAnalysisMode == "TPC") {
	const AliESDVertex *vertex = fESD->GetPrimaryVertexTPC();
{'fraction_non_alphanumeric': 0.14501477509029223, 'fraction_numerical': 0.02692349786582029, 'mean_word_length': 3.7371695178849142, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 45, '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': '4438354', 'n_tokens_mistral': 3448, 'n_tokens_neox': 3232, 'n_words': 555}