<commit_before>/////////////////////////////////////////////////////////////////////////////////////////////
//
// AddTaskGammaConvFlow_PbPb2 macro
// Author: <NAME>, <NAME>, <NAME>
//         Commented where necessary
/////////////////////////////////////////////////////////////////////////////////////////////

class AliAnalysisDataContainer;
class AliFlowTrackCuts;
class AliFlowTrackSimpleCuts;
class AliFlowEventCuts;
class AliFlowEventSimpleCuts;

class CutHandlerConvFlow{
  public:
    CutHandlerConvFlow(Int_t nMax=10){
      nCuts=0; nMaxCuts=nMax; validCuts = true;
      eventCutArray = new TString[nMaxCuts]; photonCutArray = new TString[nMaxCuts];
      for(Int_t i=0; i<nMaxCuts; i++) {eventCutArray[i] = ""; photonCutArray[i] = "";}
    }

    void AddCut(TString eventCut, TString photonCut){
      if(nCuts>=nMaxCuts) {cout << "ERROR in CutHandlerConvFlow: Exceeded maximum number of cuts!" << endl; validCuts = false; return;}
      if( eventCut.Length()!=8 || photonCut.Length()!=26) {cout << "ERROR in CutHandlerConvFlow: Incorrect length of cut string!" << endl; validCuts = false; return;}
      eventCutArray[nCuts]=eventCut; photonCutArray[nCuts]=photonCut;
      nCuts++;
      return;
    }
    Bool_t AreValid(){return validCuts;}
    Int_t GetNCuts(){if(validCuts) return nCuts; else return 0;}
    TString GetEventCut(Int_t i){if(validCuts&&i<nMaxCuts&&i>=0) return eventCutArray[i]; else{cout << "ERROR in CutHandlerConvFlow: GetEventCut wrong index i" << endl;return "";}}
    TString GetPhotonCut(Int_t i){if(validCuts&&i<nMaxCuts&&i>=0) return photonCutArray[i]; else {cout << "ERROR in CutHandlerConvFlow: GetPhotonCut wrong index i" << endl;return "";}}
  private:
    Bool_t validCuts;
    Int_t nCuts; Int_t nMaxCuts;
    TString* eventCutArray;
    TString* photonCutArray;
};

void AddTask_GammaConvFlow_PbPb2(
                                  TString uniqueID              = "",
                                  Int_t harmonic                = 2,
                                  Int_t trainConfig             = 1,                            //change different set of cuts
                                  Int_t enableQAMesonTask       = 0,                            //enable QA in AddTask_GammaConvFlow_PbPb2
                                  Int_t enableQAPhotonTask      = 0,                            // enable additional QA task
                                  //TString fileNameInputForWeighting = "MCSpectraInput.root",  // path to file for weigting input
                                  Bool_t doWeighting            = kFALSE,                       //enable Weighting
                                  TString cutnumberAODBranch    = "100000006008400000001500000",
                                  Bool_t BasicHistoSP           = kFALSE,
                                  Bool_t debug                  = kFALSE,
                                  Bool_t UseMassSel             = kFALSE,
                                  Float_t MinMass               = 0,
                                  Float_t MaxMass               = 0.2,
                                  Bool_t UseKappaSel            = kFALSE,
                                  Float_t MinKappa              = 0,
                                  Float_t MaxKappa              = 10,
                                  Int_t FilterVariable          = 1,                              // 1 = Mass, 2 = Kappa, 3 = MCee mass, 4 = MCee kappa, 5 = !MCee mass, 6 = !MCee kappa
                                  const Int_t NFilterBins       = 1,
                                  Double_t MinFilter            = 0.0,
                                  Double_t MaxFilter            = 0.2,
                                  Bool_t isMC                   = kFALSE,
                                  Int_t ApplydPhidRCut         = 0,
                                  Bool_t PerformExtraStudies    = kFALSE,                         // with kTRUE it performs the LTM study and dRdPhi study
                                  TString additionalTrainConfig = "0"                             // additional counter for trainconfig, always has to be last parameter
                               ) {

  Int_t isHeavyIon = 1;

  // make use of train subwagon feature
  if (additionalTrainConfig.Atoi() > 0){
    trainConfig = trainConfig + additionalTrainConfig.Atoi();
  }



  // ================== GetAnalysisManager ===============================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
      Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
      return ;
  }

  // ================== GetInputEventHandler =============================
  AliVEventHandler *inputHandler=mgr->GetInputEventHandler();

  //=========  Set Cutnumber for V0Reader ================================
  TString cutnumberPhoton = "30000008400100001500000000";
  TString cutnumberEvent = "10000003";
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
  TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
      AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data());

      fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
      fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
      fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
      fV0ReaderV1->SetUseMassToZero(kFALSE);
      if (!mgr) {
          Error("AddTask_V0ReaderV1", "No analysis manager found.");
          return;
      }

      AliConvEventCuts *fEventCuts=NULL;
      if(cutnumberEvent!=""){
          fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
          fEventCuts->SetPreSelectionCutFlag(kTRUE);
          fEventCuts->SetV0ReaderName(V0ReaderName);
          if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
              fV0ReaderV1->SetEventCuts(fEventCuts);
              fEventCuts->SetFillCutHistograms("",kTRUE);
          }
      }

      // Set AnalysisCut Number
      AliConversionPhotonCuts *fCuts=NULL;
      if(cutnumberPhoton!=""){
          fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
          fCuts->SetPreSelectionCutFlag(kTRUE);
          fCuts->SetIsHeavyIon(isHeavyIon);
          fCuts->SetV0ReaderName(V0ReaderName);
          if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
              fV0ReaderV1->SetConversionCuts(fCuts);
              fCuts->SetFillCutHistograms("",kTRUE);
          }
      }

      if(inputHandler->IsA()==AliAODInputHandler::Class()){
          // AOD mode
        fV0ReaderV1->AliV0ReaderV1::SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
      }
      fV0ReaderV1->Init();

      AliLog::SetGlobalLogLevel(AliLog::kInfo);

      //connect input V0Reader
      mgr->AddTask(fV0ReaderV1);
      mgr->ConnectInput(fV0ReaderV1,0,cinput);
  }


  CutHandlerConvFlow cuts;

  if (trainConfig == 1){
    cuts.AddCut("60100013", "04200009297002003220000000");
  } else if (trainConfig == 2) {
    cuts.AddCut("61200013", "04200009297002003220000000");
  } else if (trainConfig == 3) {
    cuts.AddCut("50100013", "04200009297002003220000000");
  } else if (trainConfig == 4) {
    cuts.AddCut("50200013", "04200009297002003220000000");
  } else if (trainConfig == 5) {
    cuts.AddCut("51200013", "04200009297002003220000000");
  } else if (trainConfig == 6) {
    cuts.AddCut("52400013", "04200009297002003220000000");
  } else if (trainConfig == 7) {
    cuts.AddCut("54600013", "04200009297002003220000000");
  } else if (trainConfig == 8) {
    cuts.AddCut("54800013", "04200009297002003220000000");
  } else if (trainConfig == 9) {
    cuts.AddCut("54500013", "04200009297002003220000000");
  } else if (trainConfig == 10) {
    cuts.AddCut("55600013", "04200009297002003220000000");
  } else if (trainConfig == 11) {
    cuts.AddCut("56800013", "04200009297002003220000000");
  } else if (trainConfig == 12) {
    cuts.AddCut("56700013", "04200009297002003220000000");
  } else if (trainConfig == 13) {
    cuts.AddCut("57800013", "04200009297002003220000000");
  } else if (trainConfig == 14) {
    cuts.AddCut("46900013", "04200009297002003220000000");
  } else if (trainConfig == 15) {
    cuts.AddCut("58900013", "04200009297002003220000000");
  } else  if (trainConfig == 16){
    cuts.AddCut("60100013", "00200009297002008250400000");
  } else if (trainConfig == 17) {
    cuts.AddCut("61200013", "00200009297002008250400000");
  } else if (trainConfig == 18) {
    cuts.AddCut("50100013", "00200009297002008250400000");
  } else if (trainConfig == 19) {
    cuts.AddCut("50200013", "00200009297002008250400000");
  } else if (trainConfig == 20) {
    cuts.AddCut("53500013", "00200009297002008250400000");
    cuts.AddCut("53585013", "00200009297002008250400000");
    cuts.AddCut("53583013", "00200009297002008250400000");
  } else if (trainConfig == 21) {
    cuts.AddCut("52400013", "00200009297002008250400000");
  } else if (trainConfig == 22) {
    cuts.AddCut("54600013", "00200009297002008250400000");
  } else if (trainConfig == 23) {
    cuts.AddCut("54800013", "00200009297002008250400000");
  } else if (trainConfig == 24) {
    cuts.AddCut("54500013", "00200009297002008250400000");
  } else if (trainConfig == 25) {
    cuts.AddCut("55600013", "00200009297002008250400000");
  } else if (trainConfig == 26) {<commit_msg>PWGGA/GammaConv adding flow test for Michael<commit_after>/////////////////////////////////////////////////////////////////////////////////////////////
//
// AddTaskGammaConvFlow_PbPb2 macro
// Author: <NAME>, <NAME>, <NAME>
//         Commented where necessary
/////////////////////////////////////////////////////////////////////////////////////////////

class AliAnalysisDataContainer;
class AliFlowTrackCuts;
class AliFlowTrackSimpleCuts;
class AliFlowEventCuts;
class AliFlowEventSimpleCuts;

class CutHandlerConvFlow{
  public:
    CutHandlerConvFlow(Int_t nMax=10){
      nCuts=0; nMaxCuts=nMax; validCuts = true;
      eventCutArray = new TString[nMaxCuts]; photonCutArray = new TString[nMaxCuts];
      for(Int_t i=0; i<nMaxCuts; i++) {eventCutArray[i] = ""; photonCutArray[i] = "";}
    }

    void AddCut(TString eventCut, TString photonCut){
      if(nCuts>=nMaxCuts) {cout << "ERROR in CutHandlerConvFlow: Exceeded maximum number of cuts!" << endl; validCuts = false; return;}
      if( eventCut.Length()!=8 || photonCut.Length()!=26) {cout << "ERROR in CutHandlerConvFlow: Incorrect length of cut string!" << endl; validCuts = false; return;}
      eventCutArray[nCuts]=eventCut; photonCutArray[nCuts]=photonCut;
      nCuts++;
      return;
    }
    Bool_t AreValid(){return validCuts;}
    Int_t GetNCuts(){if(validCuts) return nCuts; else return 0;}
    TString GetEventCut(Int_t i){if(validCuts&&i<nMaxCuts&&i>=0) return eventCutArray[i]; else{cout << "ERROR in CutHandlerConvFlow: GetEventCut wrong index i" << endl;return "";}}
    TString GetPhotonCut(Int_t i){if(validCuts&&i<nMaxCuts&&i>=0) return photonCutArray[i]; else {cout << "ERROR in CutHandlerConvFlow: GetPhotonCut wrong index i" << endl;return "";}}
  private:
    Bool_t validCuts;
    Int_t nCuts; Int_t nMaxCuts;
    TString* eventCutArray;
    TString* photonCutArray;
};

void AddTask_GammaConvFlow_PbPb2(
                                  TString uniqueID              = "",
                                  Int_t harmonic                = 2,
                                  Int_t trainConfig             = 1,                            //change different set of cuts
                                  Int_t enableQAMesonTask       = 0,                            //enable QA in AddTask_GammaConvFlow_PbPb2
                                  Int_t enableQAPhotonTask      = 0,                            // enable additional QA task
                                  //TString fileNameInputForWeighting = "MCSpectraInput.root",  // path to file for weigting input
                                  Bool_t doWeighting            = kFALSE,                       //enable Weighting
                                  TString cutnumberAODBranch    = "100000006008400000001500000",
                                  Bool_t BasicHistoSP           = kFALSE,
                                  Bool_t debug                  = kFALSE,
                                  Bool_t UseMassSel             = kFALSE,
                                  Float_t MinMass               = 0,
                                  Float_t MaxMass               = 0.2,
                                  Bool_t UseKappaSel            = kFALSE,
                                  Float_t MinKappa              = 0,
                                  Float_t MaxKappa              = 10,
                                  Int_t FilterVariable          = 1,                              // 1 = Mass, 2 = Kappa, 3 = MCee mass, 4 = MCee kappa, 5 = !MCee mass, 6 = !MCee kappa
                                  const Int_t NFilterBins       = 1,
                                  Double_t MinFilter            = 0.0,
                                  Double_t MaxFilter            = 0.2,
                                  Bool_t isMC                   = kFALSE,
                                  Int_t ApplydPhidRCut         = 0,
                                  Bool_t PerformExtraStudies    = kFALSE,                         // with kTRUE it performs the LTM study and dRdPhi study
                                  TString additionalTrainConfig = "0"                             // additional counter for trainconfig, always has to be last parameter
                               ) {

  Int_t isHeavyIon = 1;

  // make use of train subwagon feature
  if (additionalTrainConfig.Atoi() > 0){
    trainConfig = trainConfig + additionalTrainConfig.Atoi();
  }



  // ================== GetAnalysisManager ===============================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
      Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
      return ;
  }

  // ================== GetInputEventHandler =============================
  AliVEventHandler *inputHandler=mgr->GetInputEventHandler();

  //=========  Set Cutnumber for V0Reader ================================
  TString cutnumberPhoton = "30000008400100001500000000";
  TString cutnumberEvent = "10000003";
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
  TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
      AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data());

      fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
      fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
      fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
      fV0ReaderV1->SetUseMassToZero(kFALSE);
      if (!mgr) {
          Error("AddTask_V0ReaderV1", "No analysis manager found.");
          return;
      }

      AliConvEventCuts *fEventCuts=NULL;
      if(cutnumberEvent!=""){
          fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
          fEventCuts->SetPreSelectionCutFlag(kTRUE);
          fEventCuts->SetV0ReaderName(V0ReaderName);
          if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
              fV0ReaderV1->SetEventCuts(fEventCuts);
              fEventCuts->SetFillCutHistograms("",kTRUE);
          }
      }

      // Set AnalysisCut Number
      AliConversionPhotonCuts *fCuts=NULL;
      if(cutnumberPhoton!=""){
          fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
          fCuts->SetPreSelectionCutFlag(kTRUE);
          fCuts->SetIsHeavyIon(isHeavyIon);
          fCuts->SetV0ReaderName(V0ReaderName);
          if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
              fV0ReaderV1->SetConversionCuts(fCuts);
              fCuts->SetFillCutHistograms("",kTRUE);
          }
      }

      if(inputHandler->IsA()==AliAODInputHandler::Class()){
          // AOD mode
        fV0ReaderV1->AliV0ReaderV1::SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
      }
      fV0ReaderV1->Init();

      AliLog::SetGlobalLogLevel(AliLog::kInfo);

      //connect input V0Reader
      mgr->AddTask(fV0ReaderV1);
      mgr->ConnectInput(fV0ReaderV1,0,cinput);
  }


  CutHandlerConvFlow cuts;

  if (trainConfig == 1){
    cuts.AddCut("60100013", "04200009297002003220000000");
  } else if (trainConfig == 2) {
    cuts.AddCut("61200013", "04200009297002003220000000");
  } else if (trainConfig == 3) {
    cuts.AddCut("50100013", "04200009297002003220000000");
  } else if (trainConfig == 4) {
    cuts.AddCut("50200013", "04200009297002003220000000");
  } else if (trainConfig == 5) {
    cuts.AddCut("51200013", "04200009297002003220000000");
  } else if (trainConfig == 6) {
    cuts.AddCut("52400013", "04200009297002003220000000");
  } else if (trainConfig == 7) {
    cuts.AddCut("54600013", "04200009297002003220000000");
  } else if (trainConfig == 8) {
    cuts.AddCut("54800013", "04200009297002003220000000");
  } else if (trainConfig == 9) {
    cuts.AddCut("54500013", "04200009297002003220000000");
  } else if (trainConfig == 10) {
    cuts.AddCut("55600013", "04200009297002003220000000");
  } else if (trainConfig == 11) {
    cuts.AddCut("56800013", "04200009297002003220000000");
  } else if (trainConfig == 12) {
    cuts.AddCut("56700013", "04200009297002003220000000");
  } else if (trainConfig == 13) {
    cuts.AddCut("57800013", "04200009297002003220000000");
  } else if (trainConfig == 14) {
    cuts.AddCut("46900013", "04200009297002003220000000");
  } else if (trainConfig == 15) {
    cuts.AddCut("58900013", "04200009297002003220000000");
  } else  if (trainConfig == 16){
    cuts.AddCut("60100013", "00200009297002008250400000");
  } else if (trainConfig == 17) {
    cuts.AddCut("61200013", "00200009297002008250400000");
  } else if (trainConfig == 18) {
    cuts.AddCut("50100013", "00200009297002008250400000");
  } else if (trainConfig == 19) {
    cuts.AddCut("50200013", "00200009297002008250400000");
  } else if (trainConfig == 20) {
    cuts.AddCut("53500013", "00200009297002008250400000");
    cuts.AddCut("53585013", "00200009297002008250400000");
    cuts.AddCut("53583013", "00200009297002008250400000");
  } else if (trainConfig == 21) { //15o
    cuts.AddCut("13500013", "00200009297002008250400000");
    cuts.AddCut("13585013", "00200009297002008250400000");
    cuts.AddCut("13583013", "00200009297002008250400000");
  } else if (trainConfig == 22) {
    cuts.AddCut("54600013", "00200009297002008250400000");
  } else if (trainConfig == 23) {
    cuts.AddCut("54800013", "00200009297002008250400000");
  } else if (trainConfig == 24) {
    cuts.AddCut("54500013", "00200009297002008250400000");
  } else if (trainConfig == 25) {
    cuts.AddCut("55600013", "00200009297002008250400000");
  } else if (trainConfig == 26) {
{'fraction_non_alphanumeric': 0.14321308071632494, 'fraction_numerical': 0.1185569685958993, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 36, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6883576', 'n_tokens_mistral': 7426, 'n_tokens_neox': 5781, 'n_words': 1076}