<commit_before>/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. */
/* See cxx source for full Copyright notice */
/* $Id$ */

#ifndef AliAnalysisTaskJetV2_H
#define AliAnalysisTaskJetV2_H

// uncomment to compile with debug information
//#define DEBUGTASK

#include <AliAnalysisTaskEmcalJet.h>
#include <AliEmcalJet.h>
#include <AliVEvent.h>
#include <AliVParticle.h>
#include <AliVCluster.h>
#include <TClonesArray.h>
#include <TMath.h>
#include <TArrayD.h>
#include <TRandom3.h>
#include <AliJetContainer.h>
#include <AliParticleContainer.h>

class TFile;
class TF1;
class TH1F;
class TH2F;
class TH3F;
class TProfile;
class AliLocalRhoParameter;
class AliClusterContainer;
class AliVTrack;

class AliAnalysisTaskJetV2 : public AliAnalysisTaskEmcalJet {
    public:
         // enumerators
        enum fitModulationType  { kNoFit, kV2, kV3, kCombined, kFourierSeries, kIntegratedFlow, kQC2, kQC4 }; // fit type
        enum fitGoodnessTest    { kChi2ROOT, kChi2Poisson, kKolmogorov, kKolmogorovTOY, kLinearFit };
        enum collisionType      { kPbPb, kPythia, kPbPb10h, kPbPb11h, kJetFlowMC }; // collision type, kPbPb = 11h, kept for backward compatibilitiy
        enum qcRecovery         { kFixedRho, kNegativeVn, kTryFit };    // how to deal with negative cn value for qcn value
        enum runModeType        { kLocal, kGrid };                      // run mode type
        enum dataType           { kESD, kAOD, kESDMC, kAODMC};          // data type
        enum detectorType       { kTPC, kVZEROA, kVZEROC, kVZEROComb, kFixedEP};  // detector that was used for event plane
        enum analysisType       { kCharged, kFull };                    // analysis type
        // constructors, destructor
                                AliAnalysisTaskJetV2();
                                AliAnalysisTaskJetV2(const char *name, runModeType type);
        virtual                 ~AliAnalysisTaskJetV2();
        // setting up the task and technical aspects
        void                    ExecOnce();
        virtual Bool_t          Notify();
        Bool_t                  InitializeAnalysis();
        virtual void            UserCreateOutputObjects();
        virtual void            Exec(Option_t *);
        virtual Bool_t          Run();
        TH1F*                   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c = -1, Bool_t append = kTRUE);
        TH2F*                   BookTH2F(const char* name, const char* x, const char* y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c = -1, Bool_t append = kTRUE);
        TH3F*                   BookTH3F(const char* name, const char* x, const char* y, const char* z, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t binsz, Double_t minz, Double_t maxz, Int_t c = -1, Bool_t append = kTRUE);
        /* inline */    static Double_t PhaseShift(Double_t x) {  
            while (x>=TMath::TwoPi())x-=TMath::TwoPi();
            while (x<0.)x+=TMath::TwoPi();
            return x; }
        /* inline */    static Double_t PhaseShift(Double_t x, Double_t n) {
            x = PhaseShift(x);
            if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
            if(TMath::Nint(n)==3) {
                if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
                if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
            }
            return x; }
        /* inline */    static Bool_t   IsInPlane(Double_t dPhi) {
            return (dPhi < -1.*TMath::Pi()/4. || dPhi > TMath::Pi()/4.); }
        /* inline */    static Double_t ChiSquarePDF(Int_t ndf, Double_t x) {
            Double_t n(ndf/2.), denom(TMath::Power(2, n)*TMath::Gamma(n));
            if (denom!=0)  return ((1./denom)*TMath::Power(x, n-1)*TMath::Exp(-x/2.)); 
            return -999; }
        // note that the cdf of the chisquare distribution is the normalized lower incomplete gamma function
        /* inline */    static Double_t ChiSquareCDF(Int_t ndf, Double_t x) { return TMath::Gamma(ndf/2., x/2.); }
        /* inline */    static Double_t ChiSquare(TH1& histo, TF1* func) {
            // evaluate the chi2 using a poissonian error estimate on bins
            Double_t chi2(0.);
            for(Int_t i(0); i < histo.GetXaxis()->GetNbins(); i++) {
                if(histo.GetBinContent(i+1) <= 0.) continue;
                chi2 += TMath::Power((histo.GetBinContent(i+1)-func->Eval(histo.GetXaxis()->GetBinCenter(1+i))), 2)/histo.GetBinContent(i+1);
            }
           return chi2;
        }
        /* inline */ Double_t KolmogorovTest(TH1F& histo, TF1* func) const {
            // return the probability from a Kolmogorov test
            return .5;
            TH1F test(histo);       // stack copy of test statistic
            for(Int_t i(0); i < test.GetXaxis()->GetNbins(); i++) test.SetBinContent(i+1, func->Eval(test.GetXaxis()->GetBinCenter(1+i)));
            if(fFitGoodnessTest == kKolmogorovTOY) return histo.TH1::KolmogorovTest((&test), "X");
            return histo.TH1::KolmogorovTest((&test));
        }

        // setters - analysis setup
        void                    SetRunToyMC(Bool_t t)                           {fRunToyMC = t; }
        void                    SetAttachToEvent(Bool_t b)                      {fAttachToEvent = b;}
        void                    SetFillHistograms(Bool_t b)                     {fFillHistograms = b;}
        void                    SetFillQAHistograms(Bool_t qa)                  {fFillQAHistograms = qa;}
        void                    SetReduceBinsXYByFactor(Float_t x, Float_t y)   {fReduceBinsXByFactor = x;
                                                                                 fReduceBinsYByFactor = y;}
        void                    SetNoEventWeightsForQC(Bool_t e)                {fNoEventWeightsForQC = e;}
        void                    SetCentralityClasses(TArrayD* c)                {fCentralityClasses = c;}
        void                    SetExpectedRuns(TArrayI* r)                     {fExpectedRuns = r;}
        void                    SetExpectedSemiGoodRuns(TArrayI* r)             {fExpectedSemiGoodRuns = r;}
        void                    SetIntegratedFlow(TH1F* i, TH1F* j)             {fUserSuppliedV2 = i;
                                                                                 fUserSuppliedV3 = j; }
        void                    SetOnTheFlyResCorrection(TH1F* r2, TH1F* r3)    {fUserSuppliedR2 = r2;
                                                                                 fUserSuppliedR3 = r3; }
        void                    SetEventPlaneWeights(TH1F* ep)                  {fEventPlaneWeights = ep; }
        void                    SetAcceptanceWeights(Bool_t w)                  {fAcceptanceWeights = w; }<commit_msg> fix for coverity issue 24413<commit_after>/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. */
/* See cxx source for full Copyright notice */
/* $Id$ */

#ifndef AliAnalysisTaskJetV2_H
#define AliAnalysisTaskJetV2_H

// uncomment to compile with debug information
//#define DEBUGTASK

#include <AliAnalysisTaskEmcalJet.h>
#include <AliEmcalJet.h>
#include <AliVEvent.h>
#include <AliVParticle.h>
#include <AliVCluster.h>
#include <TClonesArray.h>
#include <TMath.h>
#include <TArrayD.h>
#include <TRandom3.h>
#include <AliJetContainer.h>
#include <AliParticleContainer.h>

class TFile;
class TF1;
class TH1F;
class TH2F;
class TH3F;
class TProfile;
class AliLocalRhoParameter;
class AliClusterContainer;
class AliVTrack;

class AliAnalysisTaskJetV2 : public AliAnalysisTaskEmcalJet {
    public:
         // enumerators
        enum fitModulationType  { kNoFit, kV2, kV3, kCombined, kFourierSeries, kIntegratedFlow, kQC2, kQC4 }; // fit type
        enum fitGoodnessTest    { kChi2ROOT, kChi2Poisson, kKolmogorov, kKolmogorovTOY, kLinearFit };
        enum collisionType      { kPbPb, kPythia, kPbPb10h, kPbPb11h, kJetFlowMC }; // collision type, kPbPb = 11h, kept for backward compatibilitiy
        enum qcRecovery         { kFixedRho, kNegativeVn, kTryFit };    // how to deal with negative cn value for qcn value
        enum runModeType        { kLocal, kGrid };                      // run mode type
        enum dataType           { kESD, kAOD, kESDMC, kAODMC};          // data type
        enum detectorType       { kTPC, kVZEROA, kVZEROC, kVZEROComb, kFixedEP};  // detector that was used for event plane
        enum analysisType       { kCharged, kFull };                    // analysis type
        // constructors, destructor
                                AliAnalysisTaskJetV2();
                                AliAnalysisTaskJetV2(const char *name, runModeType type);
        virtual                 ~AliAnalysisTaskJetV2();
        // setting up the task and technical aspects
        void                    ExecOnce();
        virtual Bool_t          Notify();
        Bool_t                  InitializeAnalysis();
        virtual void            UserCreateOutputObjects();
        virtual void            Exec(Option_t *);
        virtual Bool_t          Run();
        TH1F*                   BookTH1F(const char* name, const char* x, Int_t bins, Double_t min, Double_t max, Int_t c = -1, Bool_t append = kTRUE);
        TH2F*                   BookTH2F(const char* name, const char* x, const char* y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t c = -1, Bool_t append = kTRUE);
        TH3F*                   BookTH3F(const char* name, const char* x, const char* y, const char* z, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t binsz, Double_t minz, Double_t maxz, Int_t c = -1, Bool_t append = kTRUE);
        /* inline */    static Double_t PhaseShift(Double_t x) {  
            while (x>=TMath::TwoPi())x-=TMath::TwoPi();
            while (x<0.)x+=TMath::TwoPi();
            return x; }
        /* inline */    static Double_t PhaseShift(Double_t x, Double_t n) {
            x = PhaseShift(x);
            if(TMath::Nint(n)==2) while (x>TMath::Pi()) x-=TMath::Pi();
            if(TMath::Nint(n)==3) {
                if(x>2.*TMath::TwoPi()/n) x = TMath::TwoPi() - x;
                if(x>TMath::TwoPi()/n) x = TMath::TwoPi()-(x+TMath::TwoPi()/n);
            }
            return x; }
        /* inline */    static Bool_t   IsInPlane(Double_t dPhi) {
            return (dPhi < -1.*TMath::Pi()/4. || dPhi > TMath::Pi()/4.); }
        /* inline */    static Double_t ChiSquarePDF(Int_t ndf, Double_t x) {
            Double_t n(ndf/2.), denom(TMath::Power(2, n)*TMath::Gamma(n));
            if (denom!=0)  return ((1./denom)*TMath::Power(x, n-1)*TMath::Exp(-x/2.)); 
            return -999; }
        // note that the cdf of the chisquare distribution is the normalized lower incomplete gamma function
        /* inline */    static Double_t ChiSquareCDF(Int_t ndf, Double_t x) { return TMath::Gamma(ndf/2., x/2.); }
        /* inline */    static Double_t ChiSquare(TH1& histo, TF1* func) {
            // evaluate the chi2 using a poissonian error estimate on bins
            Double_t chi2(0.);
            for(Int_t i(0); i < histo.GetXaxis()->GetNbins(); i++) {
                if(histo.GetBinContent(i+1) <= 0.) continue;
                chi2 += TMath::Power((histo.GetBinContent(i+1)-func->Eval(histo.GetXaxis()->GetBinCenter(1+i))), 2)/histo.GetBinContent(i+1);
            }
           return chi2;
        }
        /* inline */ Double_t KolmogorovTest(TH1F& histo, TF1* func) const {
            // return the probability from a Kolmogorov test
            return .5;
            /* this test is disabeled as it eats a lot of resources but kept as a dummty to 
             * ensure compatibility of the output with offline macros
            TH1F test(histo);       // stack copy of test statistic
            for(Int_t i(0); i < test.GetXaxis()->GetNbins(); i++) test.SetBinContent(i+1, func->Eval(test.GetXaxis()->GetBinCenter(1+i)));
            if(fFitGoodnessTest == kKolmogorovTOY) return histo.TH1::KolmogorovTest((&test), "X");
            return histo.TH1::KolmogorovTest((&test));
            */
        }

        // setters - analysis setup
        void                    SetRunToyMC(Bool_t t)                           {fRunToyMC = t; }
        void                    SetAttachToEvent(Bool_t b)                      {fAttachToEvent = b;}
        void                    SetFillHistograms(Bool_t b)                     {fFillHistograms = b;}
        void                    SetFillQAHistograms(Bool_t qa)                  {fFillQAHistograms = qa;}
        void                    SetReduceBinsXYByFactor(Float_t x, Float_t y)   {fReduceBinsXByFactor = x;
                                                                                 fReduceBinsYByFactor = y;}
        void                    SetNoEventWeightsForQC(Bool_t e)                {fNoEventWeightsForQC = e;}
        void                    SetCentralityClasses(TArrayD* c)                {fCentralityClasses = c;}
        void                    SetExpectedRuns(TArrayI* r)                     {fExpectedRuns = r;}
        void                    SetExpectedSemiGoodRuns(TArrayI* r)             {fExpectedSemiGoodRuns = r;}
        void                    SetIntegratedFlow(TH1F* i, TH1F* j)             {fUserSuppliedV2 = i;
                                                                                 fUserSuppliedV3 = j; }
        void                    SetOnTheFlyResCorrection(TH1F* r2, TH1F* r3)    {fUserSuppliedR2 = r2;
                                                                                 fUserSuppliedR3 = r3; }
        void                    SetEventPlaneWeights(TH1F* ep)                  {fEventPlaneWeights = ep; }
        void                    SetAcceptanceWeights(Bool_t w)                  {fAcceptanceWeights = w; }
{'fraction_non_alphanumeric': 0.10513150371640938, 'fraction_numerical': 0.013793596340766151, 'mean_word_length': 1.7808028616852147, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7386313', 'n_tokens_mistral': 4517, 'n_tokens_neox': 4258, 'n_words': 1056}