<commit_before>/// \file runEMCALTimeCalibTask.C
/// \brief macro to run Time Calibration Task
///
/// Run in two steps. 
/// 1. First iteration over statistics gives calibration constants.
/// Remember to apply energy cuts. We want to take into account only GOOD cells.
/// 2. Run method ProduceCalibConsts(inputFile,outputFile) to obtain reference 
/// file with constants. 
/// 3. Second iteration with applied conatants give results.
///
/// \author <NAME> <<EMAIL>>, SUBATECH
/// \author <NAME> <<EMAIL>>, INP PAN Cracow
/// \date Jun 3, 2015

void runEMCALTimeCalibTask(Int_t type=0)
{
  //type = 0: local 
  //type = 1: grid

  Bool_t isPhysicsSelection=kFALSE;// <<-----FIXME <<-----uncomment it in real data
  Bool_t isCentralitySelection=kFALSE;

  TStopwatch timer;
  timer.Start();
  printf("*** the task is: AliAnalysisTaskEMCALTimeCalib ***\n");
  // Grid connection
  printf("*** Connect to AliEn ***\n");
  TGrid::Connect("alien://");
  //printf("*** Connected to AliEn? in  ***\n");
  cout<< "Connected to AliEn" <<endl;
  timer.Print();
  
  //libraries
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  //gSystem->Load("libVMC.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  //gSystem->Load("libAOD.so");
  
  // load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libANALYSISalice.so");

  gSystem->Load("libEMCALUtils.so");
  gSystem->Load("libPWGPPEMCAL.so");
  
  gSystem->AddIncludePath("-I$ALICE_ROOT");
  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
  gSystem->AddIncludePath("-I./");     

  // 	// test with lib from PWGGA train
  



  //ANALYSIS PART
  const char *collectionfile = "wn.xml";
  TChain* chain = NULL;
  if(type==0){//local files
    gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
    chain = CreateESDChain("files.txt", 1);
  }
  else if(type==1){//grid files
    chain = CreateChainFromCollection(collectionfile, "esdTree");
  }

  // for includes use either global setting in $HOME/.rootrc
  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
  // or in each macro
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
  gSystem->AddIncludePath("-I$ALICE_PHYSICS/include");



  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("MyEmcalAnalysis");
  AliESDInputHandler* esdH = new AliESDInputHandler();
  mgr->SetInputEventHandler(esdH);
  
  if(isPhysicsSelection){
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physselTask = AddTaskPhysicsSelection();
    // physselTask->AddCollisionTriggerClass("+CINT1WU-B-NOPF-ALL");
  }
  if(isCentralitySelection){
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask* centralityTask = AddTaskCentrality(); // Create task
  }

  //AliCalorimeterUtils *cu = new AliCalorimeterUtils();
  //   cu->SwitchOnBadChannelsRemoval(); 

  // Create task
  //UInt_t kTriggerInt = AliVEvent::kAnyINT;
  //UInt_t kTriggerEMC   = AliVEvent::kEMC8 || AliVEvent::kEMC7 || AliVEvent::kEMCEJE || AliVEvent::kEMCEGA;
  
  AliAnalysisTaskEMCALTimeCalib *taskmbemcal = new AliAnalysisTaskEMCALTimeCalib("TimeCalibTask");
  //  AliEMCALRecoUtils *reco = taskmbemcal->GetEMCALRecoUtils();
  //  taskmbemcal->PrintInfo();
  //  reco->SwitchOnRejectExoticCluster();

  taskmbemcal->SelectCollisionCandidates(AliVEvent::kEMC1|AliVEvent::kEMC7|AliVEvent::kEMC8|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA);
  taskmbemcal->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");

  //taskmbemcal->SelectCollisionCandidates(AliVEvent::kAnyINT);
  //taskmbemcal->SetDebugLevel(10);

  // Add task(s)
  // taskmbemcal->PrintInfo();
  if(isPhysicsSelection) mgr->AddTask(physselTask);
  mgr->AddTask(taskmbemcal);

  TString outputFileName;
  if(type==0)outputFileName="timeOutput.root";
  else if(type==1)outputFileName="timeResults.root";

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("chistolist", TList::Class(),
     AliAnalysisManager::kOutputContainer, outputFileName.Data());


  // Connect input/output
  mgr->ConnectInput(taskmbemcal, 0, cinput);

  // No need to connect to a common AOD output container if the task does not
  // fill AOD info.
  //  mgr->ConnectOutput(task, 0, coutput0);
  mgr->ConnectOutput(taskmbemcal, 1, coutputList);<commit_msg>update comments, adapt for e, <NAME><commit_after>/// \file runEMCALTimeCalibTask.C
/// \brief macro to run Time Calibration Task
///
/// Run in two steps. 
/// 1. First iteration over statistics gives calibration constants.
/// Remember to apply energy cuts. We want to take into account only GOOD cells.
/// 2. Run method ProduceCalibConsts(inputFile,outputFile) to obtain reference 
/// file with constants. 
/// 3. Second iteration with applied consatants plus extra timing cut gives corrected calibration constants.
///
/// \param type: Int_t, local or grid processing
/// \param isESD: Bool_t, flag to process ESD or AOD
/// \param isPhysicsSelection: Bool_t, flag to use Physics Selection
/// \param isCentralitySelection: Bool_t, flag to use Centrality Selection
/// \author <NAME> <<EMAIL>>, SUBATECH
/// \author <NAME> <<EMAIL>>, INP PAN Cracow
/// \date Jun 3, 2015

void runEMCALTimeCalibTask(Int_t type=0, Bool_t isESD=kTRUE, Bool_t isPhysicsSelection=kFALSE, Bool_t isCentralitySelection=kFALSE)
{
  //type = 0: local 
  //type = 1: grid

  TStopwatch timer;
  timer.Start();
  printf("*** the task is: AliAnalysisTaskEMCALTimeCalib ***\n");
  // Grid connection
  printf("*** Connect to AliEn ***\n");
  TGrid::Connect("alien://");
  //printf("*** Connected to AliEn? in  ***\n");
  cout<< "Connected to AliEn" <<endl;
  timer.Print();
  
  //libraries
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  //gSystem->Load("libVMC.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  
  // load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libANALYSISalice.so");

  gSystem->Load("libEMCALUtils.so");
  gSystem->Load("libPWGPPEMCAL.so");
  
  gSystem->AddIncludePath("-I$ALICE_ROOT");
  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
  gSystem->AddIncludePath("-I./");     

  // 	// test with lib from PWGGA train
  



  //ANALYSIS PART
  //  const char *collectionfile = "wn_1run.xml";
  //  const char *collectionfile = "wn.xml";
  const char *collectionfile;
  if(isESD==kTRUE) collectionfile = "esd_156889.xml";
  else collectionfile= "aod_156889.xml";
  //const char *collectionfile = "esd_156889.xml";
  TChain* chain = NULL;
  if(type==0){//local files
    if(isESD==kTRUE) {
      gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
      chain = CreateESDChain("files.txt", 1);
    } else {
      gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateAODChain.C");
      chain = CreateAODChain("filesAOD.txt", 1);
    }
  }
  else if(type==1){//grid files
    if(isESD==kTRUE) chain = CreateChainFromCollection(collectionfile, "esdTree");
    else chain = CreateChainFromCollection(collectionfile, "aodTree");
  }

  // for includes use either global setting in $HOME/.rootrc
  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
  // or in each macro
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
  gSystem->AddIncludePath("-I$ALICE_PHYSICS/include");



  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("MyEmcalAnalysis");
  AliInputEventHandler *inputHandler=NULL;

  //  AliESDInputHandler* esdH = new AliESDInputHandler();
  //  mgr->SetInputEventHandler(esdH);

  if(isESD==kTRUE) inputHandler = new AliESDInputHandler();
  else inputHandler = new AliAODInputHandler();

  mgr->SetInputEventHandler(inputHandler);

  AliPhysicsSelectionTask* physselTask=NULL;
  if(isPhysicsSelection){
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskPhysicsSelection.C");
    //    AliPhysicsSelectionTask* physselTask = AddTaskPhysicsSelection();
    physselTask = AddTaskPhysicsSelection();
    // physselTask->AddCollisionTriggerClass("+CINT1WU-B-NOPF-ALL");
  }
  AliCentralitySelectionTask* centralityTask=NULL;
  if(isCentralitySelection){
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
    //    AliCentralitySelectionTask* centralityTask = AddTaskCentrality(); // Create task
    centralityTask = AddTaskCentrality(); // Create task
  }

  //AliCalorimeterUtils *cu = new AliCalorimeterUtils();
  //   cu->SwitchOnBadChannelsRemoval(); 

  // Create task
  //UInt_t kTriggerInt = AliVEvent::kAnyINT;
  //UInt_t kTriggerEMC   = AliVEvent::kEMC8 || AliVEvent::kEMC7 || AliVEvent::kEMCEJE || AliVEvent::kEMCEGA;
  
  AliAnalysisTaskEMCALTimeCalib *taskmbemcal = new AliAnalysisTaskEMCALTimeCalib("TimeCalibTask");
  //  AliEMCALRecoUtils *reco = taskmbemcal->GetEMCALRecoUtils();
  //  taskmbemcal->PrintInfo();
  //  reco->SwitchOnRejectExoticCluster();

  taskmbemcal->SelectCollisionCandidates(AliVEvent::kEMC1|AliVEvent::kEMC7|AliVEvent::kEMC8|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA);
  taskmbemcal->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");

  //taskmbemcal->SelectCollisionCandidates(AliVEvent::kAnyINT);
  //taskmbemcal->SetDebugLevel(10);

  // Add task(s)
  // taskmbemcal->PrintInfo();
  if(isPhysicsSelection) mgr->AddTask(physselTask);
  if(isCentralitySelection) mgr->AddTask(centralityTask);
  mgr->AddTask(taskmbemcal);

  TString outputFileName;
  if(type==0)outputFileName="timeOutput.root";
  else if(type==1)outputFileName="timeResults.root";

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("chistolist", TList::Class(),
     AliAnalysisManager::kOutputContainer, outputFileName.Data());


  // Connect input/output
  mgr->ConnectInput(taskmbemcal, 0, cinput);

  // No need to connect to a common AOD output container if the task does not
  // fill AOD info.
  //  mgr->ConnectOutput(task, 0, coutput0);
  mgr->ConnectOutput(taskmbemcal, 1, coutputList);
{'fraction_non_alphanumeric': 0.14700136745458098, 'fraction_numerical': 0.008204727485837077, 'mean_word_length': 4.475401069518717, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2261147', 'n_tokens_mistral': 3674, 'n_tokens_neox': 3517, 'n_words': 659}