<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                       *
 * Author: <NAME>, <NAME>                     *
 * Version 1.0                                 *
 *                                       *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its    *
 * documentation strictly for non-commercial purposes is hereby granted    *
 * without fee, provided that the above copyright notice appears in all    *
 * copies and that both the copyright notice and this permission notice    *
 * appear in the supporting documentation. The authors make no claims    *
 * about the suitability of this software for any purpose. It is      *
 * provided "as is" without express or implied warranty.               *
 **************************************************************************/
void AddTask_SigmaPlToProtonPiZeroAOD(
  Int_t     trainConfig                   = 1,        // change different set of cuts
  Int_t     isMC                          = 0,        // run MC
  TString   photonCutNumberV0Reader       = "00000008400100001500000000",       // 00000008400000000100000000 nom. B, 00000088400000000100000000 low B
  TString   periodNameV0Reader            = "LHC18b",
  // general setting for task
  Int_t     enableExtMatchAndQA           = 0,        // disabled (0), extMatch (1), extQA_noCellQA (2), extMatch+extQA_noCellQA (3), extQA+cellQA (4), extMatch+extQA+cellQA (5)
  Int_t     enableLightOutput             = kTRUE,   // switch to run light output (only essential histograms for afterburner)
  Int_t     enableTriggerMimicking        = 0,        // enable trigger mimicking
  Bool_t    enableTriggerOverlapRej       = kFALSE,   // enable trigger overlap rejection
  // settings for weights
  // FPTW:fileNamePtWeights, FMUW:fileNameMultWeights, separate with ;
  TString   fileNameExternalInputs        = "FMUW:fileNameMultWeights;FEPC:fileNamedEdxPostCalib",
  Int_t     doWeightingPart               = 0,        // enable Weighting
  TString   generatorName                 = "LHC18b", //"DPMJET", // generator Name
  Bool_t    enableMultiplicityWeighting   = kFALSE,   //
  TString   periodNameAnchor              = "LHC18b",       //
  // subwagon config
  TString   additionalTrainConfig         = "0"       // additional counter for trainconfig)
  )
{
   AliCutHandlerPCM cuts(13);


  TString addTaskName                 = "AddTask_SigmaPlToProtonPiZeroAOD";
    TString sAdditionalTrainConfig      = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "", "", addTaskName);
  if (sAdditionalTrainConfig.Atoi() > 0){
    trainConfig = trainConfig + sAdditionalTrainConfig.Atoi();
    cout << "INFO: " << addTaskName.Data() << " running additionalTrainConfig '" << sAdditionalTrainConfig.Atoi() << "', train config: '" << trainConfig << "'" << endl;
  }

  TString fileNamePtWeights           = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FPTW:");
  TString fileNameMultWeights         = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FMUW:");
  TString fileNameCustomTriggerMimicOADB   = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FTRM:");

  TString corrTaskSetting             = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "CF", "", addTaskName);
  if(corrTaskSetting.CompareTo(""))
    cout << "corrTaskSetting: " << corrTaskSetting.Data() << endl;

  Int_t trackMatcherRunningMode = 0; // CaloTrackMatcher running mode
  TString strTrackMatcherRunningMode  = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "TM", "", addTaskName);
  if(additionalTrainConfig.Contains("TM"))
    trackMatcherRunningMode = strTrackMatcherRunningMode.Atoi();

  Bool_t doTreeEOverP = kFALSE; // switch to produce EOverP tree
  TString strdoTreeEOverP             = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "EPCLUSTree", "", addTaskName);
  if(strdoTreeEOverP.Atoi()==1)
    doTreeEOverP = kTRUE;

  TH1S* histoAcc = 0x0;         // histo for modified acceptance
  TString strModifiedAcc              = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "MODIFYACC", "", addTaskName);
  if(strModifiedAcc.Contains("MODIFYACC")){
    TString tempType = strModifiedAcc;
    tempType.Replace(0,9,"");
    cout << "INFO: connecting to alien..." << endl;
    TGrid::Connect("alien://");
    cout << "done!" << endl;
    TFile *w = TFile::Open(fileNamePtWeights.Data());
    if(!w){cout << "ERROR: Could not open file: " << fileNamePtWeights.Data() << endl;return;}
    histoAcc = (TH1S*) w->Get(tempType.Data());
    if(!histoAcc) {cout << "ERROR: Could not find histo: " << tempType.Data() << endl;return;}
    cout << "found: " << histoAcc << endl;
  }

  Int_t isHeavyIon = 0;

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

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

  // //=========  Set Cutnumber for V0Reader ================================
  TString cutnumberPhoton = photonCutNumberV0Reader.Data();
  TString cutnumberEvent = "00000003";
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();

  //   //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
  TString V0ReaderName        = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
  AliV0ReaderV1 *fV0ReaderV1  =  NULL;
  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
    cout << "V0Reader: " << V0ReaderName.Data() << " not found!!"<< endl;
    return;
  } else {
    cout << "V0Reader: " << V0ReaderName.Data() << " found!!"<< endl;
  }

  //================================================
  //========= Add task to the ANALYSIS manager =====
  //================================================
  AliAnalysisTaskSigmaPlToProtonPiZeroAOD* task = NULL;
  task = new AliAnalysisTaskSigmaPlToProtonPiZeroAOD(addTaskName.Data());
  task->SelectCollisionCandidates(AliVEvent::kAnyINT);
  task->SetIsHeavyIon(isHeavyIon);
  task->SetIsMC(isMC);
  task->SetV0ReaderName(V0ReaderName);
  task->SetCorrectionTaskSetting(corrTaskSetting);
  task->SetTrackMatcherRunningMode(trackMatcherRunningMode);

  // here is the order of the cluster cut string
  // usually for EMCal we start with 11111: default values for            "ClusterType", "EtaMin", "EtaMax", "PhiMin", "PhiMax"
  // then two numbers for nonlinearity, e.g. 21: this is                  "NonLinearity1", "NonLinearity2"
  // Then some cuts on the clusters, e.g. 06003222: this is               "DistanceToBadChannel", "Timing", "TrackMatching", "ExoticCell", "MinEnergy", "MinNCells", "MinM02", "MaxM02"
  // finally some for now unused cuts, usually 0000: this is              "MinMaxM20", "RecConv", "MaximumDispersion", "NLM"


  // *****************************************************************************************************
  // ******************** pp 13 TeV cuts             *****************************************************
  // *****************************************************************************************************
  if (trainConfig == 1){   // PHOS Standard
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311021"); 
  } else if (trainConfig == 2){   // PHOS PID
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20220003211311011"); // NCluster TPC 50
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20320003211311011"); // NCluster TPC 65
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20110003211311011"); // Nchi2 TPC 4
  } else if (trainConfig == 3){   // PHOS
    cuts.AddCutHeavyMesonSigma("00010113","24466190sa09cc00000","0163103100000010","20120003211311011");
    cuts.AddCutHeavyMesonSigma("00010113","244661904a09cc00000","0163103100000010","20120003211311011");
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra01cc00000","0163103100000010","20120003211311011");
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra07cc00000","0163103100000010","20120003211311011");
  } else if (trainConfig == 4){   // PHOS DCA-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120002211311011"); // DCAXY 0.02
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120004211311011"); // DCAXY 0.015
  } else if (trainConfig == 5){   // PHOS Pion mass-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211322011"); // tighter mass cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211342011"); // on left side tighter
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211333011"); // looser mass cut
  } else if (trainConfig == 6){   // PHOS Opening angle-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311011"); // tight cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311031"); // tighter cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311041"); // tightest cut
  } else if (trainConfig == 7){   // Background describtion
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311010"); // changed to pion rotation  
  } else if (trainConfig == 10){    // PHI 7
    cuts.AddCutHeavyMesonSigma("00062113","24466190sa09cc00000","0163103100000010","20120003211311011");



  } else if (trainConfig == 100){    // EDC
    cuts.AddCutHeavyMesonSigma("00010113","4117912067032230000","0163103100000050","20120003211311011");
  } else if (trainConfig == 101){    // PHI7
    cuts.AddCutHeavyMesonSigma("0008e113","4117912067032230000","0163103100000010","20120003211311011");
    cuts.AddCutHeavyMesonSigma("0008d113","4117912067032230000","0163103100000010","20120003211311011");
  }

  if(!cuts.AreValid()){
    cout << "\n\n****************************************************" << endl;
    cout << "ERROR: No valid cuts stored in CutHandlerCalo! Returning..." << endl;
    cout << "****************************************************\n\n" << endl;
    return;
  }

  Int_t numberOfCuts = cuts.GetNCuts();

  TList *EventCutList = new TList();
  TList *ClusterCutList = new TList();
  TList *MesonCutList = new TList();
  TList *SigmaCutList = new TList();<commit_msg>PWGGA/GammaConv: Changed the train configs<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                       *
 * Author: <NAME>, <NAME>                     *
 * Version 1.0                                 *
 *                                       *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its    *
 * documentation strictly for non-commercial purposes is hereby granted    *
 * without fee, provided that the above copyright notice appears in all    *
 * copies and that both the copyright notice and this permission notice    *
 * appear in the supporting documentation. The authors make no claims    *
 * about the suitability of this software for any purpose. It is      *
 * provided "as is" without express or implied warranty.               *
 **************************************************************************/
void AddTask_SigmaPlToProtonPiZeroAOD(
  Int_t     trainConfig                   = 1,        // change different set of cuts
  Int_t     isMC                          = 0,        // run MC
  TString   photonCutNumberV0Reader       = "00000008400100001500000000",       // 00000008400000000100000000 nom. B, 00000088400000000100000000 low B
  TString   periodNameV0Reader            = "LHC18b",
  // general setting for task
  Int_t     enableExtMatchAndQA           = 0,        // disabled (0), extMatch (1), extQA_noCellQA (2), extMatch+extQA_noCellQA (3), extQA+cellQA (4), extMatch+extQA+cellQA (5)
  Int_t     enableLightOutput             = kTRUE,   // switch to run light output (only essential histograms for afterburner)
  Int_t     enableTriggerMimicking        = 0,        // enable trigger mimicking
  Bool_t    enableTriggerOverlapRej       = kFALSE,   // enable trigger overlap rejection
  // settings for weights
  // FPTW:fileNamePtWeights, FMUW:fileNameMultWeights, separate with ;
  TString   fileNameExternalInputs        = "FMUW:fileNameMultWeights;FEPC:fileNamedEdxPostCalib",
  Int_t     doWeightingPart               = 0,        // enable Weighting
  TString   generatorName                 = "LHC18b", //"DPMJET", // generator Name
  Bool_t    enableMultiplicityWeighting   = kFALSE,   //
  TString   periodNameAnchor              = "LHC18b",       //
  // subwagon config
  TString   additionalTrainConfig         = "0"       // additional counter for trainconfig)
  )
{
   AliCutHandlerPCM cuts(13);


  TString addTaskName                 = "AddTask_SigmaPlToProtonPiZeroAOD";
    TString sAdditionalTrainConfig      = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "", "", addTaskName);
  if (sAdditionalTrainConfig.Atoi() > 0){
    trainConfig = trainConfig + sAdditionalTrainConfig.Atoi();
    cout << "INFO: " << addTaskName.Data() << " running additionalTrainConfig '" << sAdditionalTrainConfig.Atoi() << "', train config: '" << trainConfig << "'" << endl;
  }

  TString fileNamePtWeights           = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FPTW:");
  TString fileNameMultWeights         = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FMUW:");
  TString fileNameCustomTriggerMimicOADB   = cuts.GetSpecialFileNameFromString (fileNameExternalInputs, "FTRM:");

  TString corrTaskSetting             = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "CF", "", addTaskName);
  if(corrTaskSetting.CompareTo(""))
    cout << "corrTaskSetting: " << corrTaskSetting.Data() << endl;

  Int_t trackMatcherRunningMode = 0; // CaloTrackMatcher running mode
  TString strTrackMatcherRunningMode  = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "TM", "", addTaskName);
  if(additionalTrainConfig.Contains("TM"))
    trackMatcherRunningMode = strTrackMatcherRunningMode.Atoi();

  Bool_t doTreeEOverP = kFALSE; // switch to produce EOverP tree
  TString strdoTreeEOverP             = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "EPCLUSTree", "", addTaskName);
  if(strdoTreeEOverP.Atoi()==1)
    doTreeEOverP = kTRUE;

  TH1S* histoAcc = 0x0;         // histo for modified acceptance
  TString strModifiedAcc              = cuts.GetSpecialSettingFromAddConfig(additionalTrainConfig, "MODIFYACC", "", addTaskName);
  if(strModifiedAcc.Contains("MODIFYACC")){
    TString tempType = strModifiedAcc;
    tempType.Replace(0,9,"");
    cout << "INFO: connecting to alien..." << endl;
    TGrid::Connect("alien://");
    cout << "done!" << endl;
    TFile *w = TFile::Open(fileNamePtWeights.Data());
    if(!w){cout << "ERROR: Could not open file: " << fileNamePtWeights.Data() << endl;return;}
    histoAcc = (TH1S*) w->Get(tempType.Data());
    if(!histoAcc) {cout << "ERROR: Could not find histo: " << tempType.Data() << endl;return;}
    cout << "found: " << histoAcc << endl;
  }

  Int_t isHeavyIon = 0;

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

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

  // //=========  Set Cutnumber for V0Reader ================================
  TString cutnumberPhoton = photonCutNumberV0Reader.Data();
  TString cutnumberEvent = "00000003";
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();

  //   //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
  TString V0ReaderName        = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
  AliV0ReaderV1 *fV0ReaderV1  =  NULL;
  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
    cout << "V0Reader: " << V0ReaderName.Data() << " not found!!"<< endl;
    return;
  } else {
    cout << "V0Reader: " << V0ReaderName.Data() << " found!!"<< endl;
  }

  //================================================
  //========= Add task to the ANALYSIS manager =====
  //================================================
  AliAnalysisTaskSigmaPlToProtonPiZeroAOD* task = NULL;
  task = new AliAnalysisTaskSigmaPlToProtonPiZeroAOD(addTaskName.Data());
  task->SelectCollisionCandidates(AliVEvent::kAnyINT);
  task->SetIsHeavyIon(isHeavyIon);
  task->SetIsMC(isMC);
  task->SetV0ReaderName(V0ReaderName);
  task->SetCorrectionTaskSetting(corrTaskSetting);
  task->SetTrackMatcherRunningMode(trackMatcherRunningMode);

  // here is the order of the cluster cut string
  // usually for EMCal we start with 11111: default values for            "ClusterType", "EtaMin", "EtaMax", "PhiMin", "PhiMax"
  // then two numbers for nonlinearity, e.g. 21: this is                  "NonLinearity1", "NonLinearity2"
  // Then some cuts on the clusters, e.g. 06003222: this is               "DistanceToBadChannel", "Timing", "TrackMatching", "ExoticCell", "MinEnergy", "MinNCells", "MinM02", "MaxM02"
  // finally some for now unused cuts, usually 0000: this is              "MinMaxM20", "RecConv", "MaximumDispersion", "NLM"


  // *****************************************************************************************************
  // ******************** pp 13 TeV cuts             *****************************************************
  // *****************************************************************************************************
  if (trainConfig == 1){   // PHOS Standard
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311021"); 
  } else if (trainConfig == 2){   // PHOS PID
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20220003211311021"); // NCluster TPC 50
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20320003211311021"); // NCluster TPC 65
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20110003211311021"); // Nchi2 TPC 4
  } else if (trainConfig == 3){   // PHOS
    cuts.AddCutHeavyMesonSigma("00010113","24466190sa09cc00000","0163103100000010","20120003211311021");
    cuts.AddCutHeavyMesonSigma("00010113","244661904a09cc00000","0163103100000010","20120003211311021");
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra01cc00000","0163103100000010","20120003211311021");
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra07cc00000","0163103100000010","20120003211311021");
  } else if (trainConfig == 4){   // PHOS DCA-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120002211311021"); // DCAXY 0.02
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120004211311021"); // DCAXY 0.015
  } else if (trainConfig == 5){   // PHOS Pion mass-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211322021"); // tighter mass cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211342021"); // on left side tighter
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211333021"); // looser mass cut
  } else if (trainConfig == 6){   // PHOS Opening angle-Variation
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311011"); // tight cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311031"); // tighter cut
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311041"); // tightest cut
  } else if (trainConfig == 7){   // Background describtion
    cuts.AddCutHeavyMesonSigma("00010113","24466190ra09cc00000","0163103100000010","20120003211311020"); // changed to pion rotation  
  } else if (trainConfig == 10){    // PHI 7
    cuts.AddCutHeavyMesonSigma("00062113","24466190sa09cc00000","0163103100000010","20120003211311021");



  } else if (trainConfig == 100){    // EDC
    cuts.AddCutHeavyMesonSigma("00010113","4117912067032230000","0163103100000050","20120003211311021");
  } else if (trainConfig == 101){    // PHI7
    cuts.AddCutHeavyMesonSigma("0008e113","4117912067032230000","0163103100000010","20120003211311021");
    cuts.AddCutHeavyMesonSigma("0008d113","4117912067032230000","0163103100000010","20120003211311021");
  }

  if(!cuts.AreValid()){
    cout << "\n\n****************************************************" << endl;
    cout << "ERROR: No valid cuts stored in CutHandlerCalo! Returning..." << endl;
    cout << "****************************************************\n\n" << endl;
    return;
  }

  Int_t numberOfCuts = cuts.GetNCuts();

  TList *EventCutList = new TList();
  TList *ClusterCutList = new TList();
  TList *MesonCutList = new TList();
  TList *SigmaCutList = new TList();
{'fraction_non_alphanumeric': 0.186152513788231, 'fraction_numerical': 0.12698846802497835, 'mean_word_length': 4.039044556729444, 'pattern_counts': {'":': 0, '<': 159, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 16, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438356', 'n_tokens_mistral': 8508, 'n_tokens_neox': 6468, 'n_words': 1261}