<commit_before>AliAnalysisTaskSEDmesonsFilterCJ *AddTaskSEDmesonsFilterCJ(
  AliAnalysisTaskSEDmesonsFilterCJ::ECandidateType cand = AliAnalysisTaskSEDmesonsFilterCJ::kDstartoKpipi,
  TString filename = "DStartoKpipiCuts.root",
  Bool_t theMCon = kFALSE,
  Bool_t reco = kTRUE /*must be true if theMCon is false*/,
  TString suffix = "")
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskSEDmesonsFilterCJ", "No analysis manager to connect to.");
    return NULL;
  } 

  Bool_t useStdC = kFALSE;
  TFile* filecuts=TFile::Open(filename);
  if(!filecuts || (filecuts && !filecuts->IsOpen())) {
    cout<<"Input file not found: use std cuts"<<endl;
    useStdC = kTRUE;
  }

  AliRDHFCuts *analysiscuts=0x0;
  switch (cand) {
  case 0 :
    if(useStdC) {
      analysiscuts = new AliRDHFCutsD0toKpi();
      analysiscuts->SetStandardCutsPP2010();
    } else
      analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts");
    break;
  case 1 :
    if(useStdC) {
      analysiscuts = new AliRDHFCutsDStartoKpipi();
      analysiscuts->SetStandardCutsPP2010();
    } else
      analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts");
    analysiscuts->SetName("DStartoKpipiCuts");
    break;
  }
  
  if (!analysiscuts) { // mm let's see if everything is ok
    AliFatal("Specific AliRDHFCuts not found");
    return;
  } 

  printf("CREATE TASK\n"); //CREATE THE TASK

  // create the task
  AliAnalysisTaskSEDmesonsFilterCJ *task = new AliAnalysisTaskSEDmesonsFilterCJ("AnaTaskSEDmesonsFilterCJ",analysiscuts,cand);
  if(!theMCon) reco=kTRUE;
  task->SetMC(theMCon); //D meson settings
  task->SetUseReco(reco);
  mgr->AddTask(task);
  if(theMCon) {
     suffix+="MC";
     if(reco) suffix+="rec";  
  }
  
  TString candname="DStar"; 
  if(cand==0)  candname="D0";
  
  // Create and connect containers for input/output
  TString outputfile = AliAnalysisManager::GetCommonFileName();
  outputfile += ":PWG3_D2H_DmesonsForJetCorrelations";
  outputfile += suffix;

  TString nameContainer0="histograms";
  TString nameContainer1="cuts";
  //TString nameContainer2="DcandidatesSel";

  nameContainer0 += candname;
  nameContainer1 += candname;
  
  nameContainer0 += suffix;
  nameContainer1 += suffix;
//nameContainer2 += suffix;

  // ------ input data ------
  AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
  
  // ----- output data -----
  
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer0, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer1, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
//AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(nameContainer2, TList::Class(),AliAnalysisManager::kExchangeContainer, outputfile.Data());
  
  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
  mgr->ConnectOutput(task,1,coutput1);
  mgr->ConnectOutput(task,2,coutput2);
//mgr->ConnectOutput(task,3,coutput3);

  Printf("Input and Output connected to the manager");
  return task ;<commit_msg>Add exchange containers, only add the new filter if not found in the analysis manager<commit_after>// AddTaskSEDmesonsFilterCJ.C

AliAnalysisTaskSEDmesonsFilterCJ *AddTaskSEDmesonsFilterCJ(AliAnalysisTaskSEDmesonsFilterCJ::ECandidateType cand = AliAnalysisTaskSEDmesonsFilterCJ::kDstartoKpipi,
                                                           TString filename = "DStartoKpipiCuts.root",
                                                           Bool_t theMCon = kFALSE,
                                                           Bool_t reco = kTRUE, /*must be true if theMCon is false*/
                                                           TString suffix = "")
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskSEDmesonsFilterCJ", "No analysis manager to connect to.");
    return NULL;
  } 

  Bool_t useStdC = kFALSE;
  TFile* filecuts = TFile::Open(filename);
  if (!filecuts || (filecuts && !filecuts->IsOpen())) {
    ::Warning("AddTaskSEDmesonsFilterCJ", "Input file not found: use std cuts");
    useStdC = kTRUE;
  }

  if (!theMCon && !reco) {
    ::Warning("AddTaskSEDmesonsFilterCJ", "'reco' must be kTRUE if 'theMCon' is kFALSE!");
    reco = kTRUE;
  }

  if (theMCon) {
    suffix += "MC";
    if (reco) suffix += "rec";  
  }

  TString candname("DStar"); 
  if (cand==0) candname="D0";

  AliRDHFCuts *analysiscuts = 0x0;
  switch (cand) {
  case 0 :
    if(useStdC) {
      analysiscuts = new AliRDHFCutsD0toKpi();
      analysiscuts->SetStandardCutsPP2010();
    } else
      analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts");
    break;
  case 1 :
    if(useStdC) {
      analysiscuts = new AliRDHFCutsDStartoKpipi();
      analysiscuts->SetStandardCutsPP2010();
    } else
      analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts");
    analysiscuts->SetName("DStartoKpipiCuts");
    break;
  }
  
  if (!analysiscuts) {
    AliFatal("Specific AliRDHFCuts not found!");
    return;
  }

  TString taskFiltername("DmesonsFilterCJ");
  taskFiltername += candname;
  taskFiltername += suffix;
  if (theMCon) taskFiltername += "MC";
  if (!reco)   taskFiltername += "gen";
  
  AliAnalysisTaskSEDmesonsFilterCJ* task = mgr->GetTask(taskFiltername.Data());
  if (task) {
    ::Info("AddTaskSEDmesonsFilterCJ", Form("Task %s already exist, continue",taskFiltername.Data()));
    return task;
  }
  else {
    ::Info("AddTaskSEDmesonsFilterCJ", "Creating the task");

    // create the task
    task = new AliAnalysisTaskSEDmesonsFilterCJ(taskFiltername.Data(), analysiscuts, cand);
    task->SetMC(theMCon);
    task->SetUseReco(reco);
    mgr->AddTask(task);
  }
  
  // Create and connect containers for input/output
  TString outputfile = AliAnalysisManager::GetCommonFileName();
  outputfile += ":PWG3_D2H_DmesonsForJetCorrelations";
  outputfile += suffix;

  TString nameContainer0 = "histograms";
  TString nameContainer1 = "cuts";
  TString nameContainer2 = "Dcandidates";
  TString nameContainer3 = "DSBcandidates";

  nameContainer0 += candname;
  nameContainer1 += candname;
  nameContainer2 += candname;
  nameContainer3 += candname;
  
  nameContainer0 += suffix;
  nameContainer1 += suffix;
  nameContainer2 += suffix;
  nameContainer3 += suffix;

  // ------ input data ------
  AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
  
  // ----- output data -----
  
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(nameContainer0, TList::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(nameContainer1, AliRDHFCuts::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(nameContainer2, TClonesArray::Class(), AliAnalysisManager::kExchangeContainer, outputfile.Data()); // exchange
  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(nameContainer3, TClonesArray::Class(), AliAnalysisManager::kExchangeContainer, outputfile.Data()); // exchange
  
  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
  mgr->ConnectOutput(task,1,coutput1);
  mgr->ConnectOutput(task,2,coutput2);
  mgr->ConnectOutput(task,3,coutput3);
  mgr->ConnectOutput(task,4,coutput4);

  ::Info("AddTaskSEDmesonsFilterCJ", "Input and Output connected to the manager");
  return task;
{'fraction_non_alphanumeric': 0.1274990070170793, 'fraction_numerical': 0.011915795048325168, 'mean_word_length': 4.052842809364549, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6076145', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2442, 'n_words': 452}