<commit_before>#include "Riostream.h"
void LoadLibraries();
void AddAnalysisTasks(); 
class AliAnalysisAlien;                                                                                                                    
AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode);

Int_t runNumbers[5] = {137844};

Bool_t doCDBconnect   = 1;
Bool_t doEventStat    = 1;
Bool_t doCentrality   = 1;
Bool_t doQAsym        = 1;
Bool_t doVZERO        = 1;   // there is a 2nd file
Bool_t doVertex       = 1;
Bool_t doSPD          = 1;   // needs RP   
Bool_t doTPC          = 1;
Bool_t doSDD          = 1;   // needs RP
Bool_t doSSDdEdx      = 1;
// new 
Bool_t doTRD          = 1;
Bool_t doITS          = 1;
Bool_t doCALO         = 1;
Bool_t doMUONTrig     = 1;
Bool_t doImpParRes    = 1;
Bool_t doMUON         = 1;
Bool_t doTOF          = 1;
Bool_t doHMPID        = 1;

Bool_t doMUONEff      = 0;   // NEEDS geometry
Bool_t doV0           = 0;   // NEEDS MCtruth 

TString     train_name         = "QA";      // QA local folder name
TString     train_tag          = "";        // Train special tag appended to 
                                            // visible name. ("sim", "pp", ...)
               // Name in train page (DON'T CHANGE)
TString     visible_name       = Form("QA$2_$3%s", train_tag.Data()); //# FIXED #
TString     job_comment        = "PWG1 QA train"; // Can add observations here
               // Job tag (DON'T CHANGE)
TString     job_tag            = Form("%s: %s", visible_name.Data(), job_comment.Data());
               // Package versions - Modify as needed
TString     root_version       = "v5-27-06b";
TString     aliroot_version    = "v4-21-10-AN";
               // Production directory - change as needed for test mode
TString     grid_datadir       = "/alice/data/2010/LHC10h";
               // Work directory in GRID (DON'T CHANGE)
TString     grid_workdir       = "/alice/cern.ch/user/a/alidaq/QA/QA$2";
               // Job splitting
Int_t       grid_split         = 10;       // Splitting
               // Debug level
Int_t       debug_level        = 1;        // Debugging
               // File merging
Int_t       maxMergeFiles      = 10;       // Max files to merge in a chunk
               // Data pattern - change as needed for test mode
TString     data_pattern       = "*ESDs/pass1/*ESDs.root";
               // Output directory (DON'T CHANGE)
TString     alien_outdir       = "$1/QA$2";
               // Input collection (production mode)
TString     data_collection    = "$1/qa1.xml";
TString     mergeExcludes      = ""; // Files to be excluded for merging
TString     mergeDirName       = "QA$2";
TString     terminateFiles     = "trending.root"; // Files produced during Terminate

Bool_t useProductionMode       = kTRUE;
Bool_t useMergeViaJDL          = kTRUE;
Bool_t useFastReadOption       = kTRUE;
Bool_t useOverwriteMode        = kTRUE;
Bool_t useDevelopmentVersion   = kFALSE;

void PilotAnalysis(const char *plugin_mode = "full")
{
  TString smode(plugin_mode);
  smode.ToLower();
  if (smode == "test") useProductionMode = kFALSE;
  if (!useProductionMode) {
     TGrid::Connect("alien://");
     if (!gGrid || !gGrid->IsConnected()) {
       ::Error("PilotAnalysis", "No grid connection");
       return;
     }
  }   
  // Write configuration
  TString cdir = gSystem->WorkingDirectory();
  gSystem->MakeDirectory(train_name);
  gSystem->ChangeDirectory(train_name);
  ofstream out;
  out.open(Form("%sConfig.C",train_name.Data()), ios::out);
  out << "{" << endl;
  out << "   train_name      = " << "\"" << train_name.Data() << "\";" << endl;
  out << "   root_version    = " << "\"" << root_version.Data() << "\";" << endl;
  out << "   aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
  out << "   grid_datadir   = " << "\"" << grid_datadir.Data() << "\";" << endl;
  if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
  out << "   alien_outdir    = " << "\"" << alien_outdir.Data() << "\";" << endl;
  out << "   doQAsim         = " << doQAsym << ";" << endl;
  out << "   doVZERO         = " << doVZERO << ";" << endl;
  out << "   doVertex        = " << doVertex << ";" << endl;
  out << "   doSPD           = " << doSPD << ";" << endl;
  out << "   doSDD           = " << doSDD << ";" << endl;
  out << "   doSSDdEdx       = " << doSSDdEdx << ";" << endl;
  out << "   doTPC           = " << doTPC << ";" << endl;
  out << "   doTRD           = " << doTRD << ";" << endl;
  out << "   doImpParRes     = " << doImpParRes << ";" << endl;
  out << "   doMUON          = " << doMUON << ";" << endl;
  out << "   doTOF           = " << doTOF << ";" << endl;
  out << "   doHMPID         = " << doHMPID << ";" << endl;
  out << "   doEventStat     = " << doEventStat << ";" << endl;
  out << "   doCentrality    = " << doCentrality << ";" << endl;
  out << "}" << endl;
  out.close();
  
  // Load libraries
  gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWG1");
  LoadLibraries();
  // Create manager
  AliAnalysisManager *mgr  = new AliAnalysisManager("PilotAnalysis", "Production train");
  mgr->SetNSysInfo(100);
  mgr->SetDebugLevel(1);
  // Input handler
  AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
  esdHandler->SetReadFriends(kTRUE);
  esdHandler->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdHandler);
  mgr->SetDebugLevel(debug_level);
  
  // AnalysisTasks
  AddAnalysisTasks();
  // Grid handler
  AliAnalysisAlien *alienHandler = CreateAlienHandler(plugin_mode);
  mgr->SetGridHandler(alienHandler);
  if (mgr->InitAnalysis()) {                                                                                                              
    mgr->PrintStatus(); 
    if (!strcmp(plugin_mode, "local")) mgr->StartAnalysis("local");
    else mgr->StartAnalysis("grid");
  }
}

void LoadLibraries()
{
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libCORRFW");
  gSystem->Load("libTENDER");
  gSystem->Load("libPWG0base.so");
  gSystem->Load("libPWG0dep.so");
  gSystem->Load("libPWG0selectors.so");
  gSystem->Load("libPWG1.so");
  gSystem->Load("libPWG2.so");
  gSystem->Load("libPWG2forward.so");

  if (doCALO) {
     gSystem->Load("libEMCALUtils");
     gSystem->Load("libPWG4PartCorrBase");
     gSystem->Load("libPWG4PartCorrDep");
  }  
  if(doMUONTrig) {
     gSystem->Load("libPWG3base");
     gSystem->Load("libPWG3muon");
     gSystem->Load("libPWG3muondep");
  }   
}

void AddAnalysisTasks()
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  mgr->SetCommonFileName("QAresults.root");
  //
  // CDB connection
  //
  if (doCDBconnect) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskCDBconnect.C");
    AliTaskCDBconnect *taskCDB = AddTaskCDBconnect();
    if (!taskCDB) return;
    taskCDB->SetRunNumber(runNumbers[0]);
  }    
  
  //
  // Event Statistics (<NAME>)
  //
  if (doEventStat) {
      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
      AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
//      mgr->RegisterExtraFile("event_stat.root");
      if (!terminateFiles.IsNull()) terminateFiles += ",";
      terminateFiles += "event_stat.root";
  }
  
  //
  // Centrality (<NAME>)
  //
  if (doCentrality) {
     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
     AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
     gROOT->LoadMacro("$ALICE_ROOT/PWG1/Centrality/AddTaskHIMultCorr.C");
     AliAnalysisTaskHIMultCorr *taskHIcentrality = AddTaskHIMultCorr();
  }   
  
  // Vertexing (<NAME>)
  // 
  if (doVertex) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskVertexESD.C");
    AliAnalysisTaskVertexESD* taskvertexesd =  AddTaskVertexESD();
    taskvertexesd->SelectCollisionCandidates();
  }  

  // TPC QA (<NAME>)
  //
  if (doQAsym) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskQAsym.C");
    AliAnalysisTaskSE * taskqasim = AddTaskQAsym(0);
    taskqasim->SelectCollisionCandidates();
  }  
  //
  // VZERO QA  (C. Cheshkov)
  //
  if (doVZERO) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskVZEROQA.C");<commit_msg>new version of the QA<commit_after>#include "Riostream.h"
void LoadLibraries();
void AddAnalysisTasks(); 
class AliAnalysisAlien;                                                                                                                    
AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode);

Int_t runNumbers[5] = {137844};

Bool_t doCDBconnect   = 1;
Bool_t doEventStat    = 1;
Bool_t doCentrality   = 0;
Bool_t doQAsym        = 1;
Bool_t doVZERO        = 1;   // there is a 2nd file
Bool_t doVertex       = 1;
Bool_t doSPD          = 1;   // needs RP   
Bool_t doTPC          = 0;
Bool_t doSDD          = 1;   // needs RP
Bool_t doSSDdEdx      = 1;
// new 
Bool_t doTRD          = 1;
Bool_t doITS          = 1;
Bool_t doCALO         = 1;
Bool_t doMUONTrig     = 1;
Bool_t doImpParRes    = 1;
Bool_t doMUON         = 1;
Bool_t doTOF          = 1;
Bool_t doHMPID        = 1;

Bool_t doMUONEff      = 0;   // NEEDS geometry
Bool_t doV0           = 0;   // NEEDS MCtruth 

TString     train_name         = "QA";      // QA local folder name
TString     train_tag          = "pp";        // Train special tag appended to 
                                            // visible name. ("sim", "pp", ...)
               // Name in train page (DON'T CHANGE)
TString     visible_name       = Form("QA$2_$3%s", train_tag.Data()); //# FIXED #
TString     job_comment        = "PWG1 QA train (no TPC)"; // Can add observations here
               // Job tag (DON'T CHANGE)
TString     job_tag            = Form("%s: %s", visible_name.Data(), job_comment.Data());
               // Package versions - Modify as needed
TString     root_version       = "v5-27-06b";
TString     aliroot_version    = "v4-21-12-AN";
               // Production directory - change as needed for test mode
TString     grid_datadir       = "/alice/data/2010/LHC10e";
               // Work directory in GRID (DON'T CHANGE)
TString     grid_workdir       = "/alice/cern.ch/user/a/alidaq/QA/QA$2";
               // Job splitting
Int_t       grid_split         = 20;       // Splitting
               // Debug level
Int_t       debug_level        = 1;        // Debugging
               // File merging
Int_t       maxMergeFiles      = 10;       // Max files to merge in a chunk
               // Data pattern - change as needed for test mode
TString     data_pattern       = "*ESDs/pass2/*ESDs.root";
               // Output directory (DON'T CHANGE)
TString     alien_outdir       = "$1/QA$2";
               // Input collection (production mode)
TString     data_collection    = "$1/qa1.xml";
TString     mergeExcludes      = ""; // Files to be excluded for merging
TString     mergeDirName       = "QA$2";
TString     terminateFiles     = "trending.root"; // Files produced during Terminate

Bool_t useProductionMode       = kTRUE;
Bool_t useMergeViaJDL          = kTRUE;
Bool_t useFastReadOption       = kFALSE;
Bool_t useOverwriteMode        = kTRUE;
Bool_t useDevelopmentVersion   = kFALSE;

void PilotAnalysis(const char *plugin_mode = "full")
{
  TString smode(plugin_mode);
  smode.ToLower();
  if (smode == "test") useProductionMode = kFALSE;
  if (!useProductionMode) {
     TGrid::Connect("alien://");
     if (!gGrid || !gGrid->IsConnected()) {
       ::Error("PilotAnalysis", "No grid connection");
       return;
     }
  }   
  // Write configuration
  TString cdir = gSystem->WorkingDirectory();
  gSystem->MakeDirectory(train_name);
  gSystem->ChangeDirectory(train_name);
  ofstream out;
  out.open(Form("%sConfig.C",train_name.Data()), ios::out);
  out << "{" << endl;
  out << "   train_name      = " << "\"" << train_name.Data() << "\";" << endl;
  out << "   root_version    = " << "\"" << root_version.Data() << "\";" << endl;
  out << "   aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
  out << "   grid_datadir   = " << "\"" << grid_datadir.Data() << "\";" << endl;
  if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
  out << "   alien_outdir    = " << "\"" << alien_outdir.Data() << "\";" << endl;
  out << "   doQAsim         = " << doQAsym << ";" << endl;
  out << "   doVZERO         = " << doVZERO << ";" << endl;
  out << "   doVertex        = " << doVertex << ";" << endl;
  out << "   doSPD           = " << doSPD << ";" << endl;
  out << "   doSDD           = " << doSDD << ";" << endl;
  out << "   doSSDdEdx       = " << doSSDdEdx << ";" << endl;
  out << "   doTPC           = " << doTPC << ";" << endl;
  out << "   doTRD           = " << doTRD << ";" << endl;
  out << "   doImpParRes     = " << doImpParRes << ";" << endl;
  out << "   doMUON          = " << doMUON << ";" << endl;
  out << "   doTOF           = " << doTOF << ";" << endl;
  out << "   doHMPID         = " << doHMPID << ";" << endl;
  out << "   doEventStat     = " << doEventStat << ";" << endl;
  out << "   doCentrality    = " << doCentrality << ";" << endl;
  out << "}" << endl;
  out.close();
  
  // Load libraries
  gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWG1");
  LoadLibraries();
  // Create manager
  AliAnalysisManager *mgr  = new AliAnalysisManager("PilotAnalysis", "Production train");
  mgr->SetNSysInfo(100);
  mgr->SetDebugLevel(1);
  // Input handler
  AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
  esdHandler->SetReadFriends(kTRUE);
  esdHandler->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdHandler);
  mgr->SetDebugLevel(debug_level);
  
  // AnalysisTasks
  AddAnalysisTasks();
  // Grid handler
  AliAnalysisAlien *alienHandler = CreateAlienHandler(plugin_mode);
  mgr->SetGridHandler(alienHandler);
  if (mgr->InitAnalysis()) {                                                                                                              
    mgr->PrintStatus(); 
    if (!strcmp(plugin_mode, "local")) mgr->StartAnalysis("local");
    else mgr->StartAnalysis("grid");
  }
}

void LoadLibraries()
{
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libCORRFW");
  gSystem->Load("libTENDER");
  gSystem->Load("libPWG0base.so");
  gSystem->Load("libPWG0dep.so");
  gSystem->Load("libPWG0selectors.so");
  gSystem->Load("libPWG1.so");
  gSystem->Load("libPWG2.so");
  gSystem->Load("libPWG2forward.so");

  if (doCALO) {
     gSystem->Load("libEMCALUtils");
     gSystem->Load("libPWG4PartCorrBase");
     gSystem->Load("libPWG4PartCorrDep");
  }  
  if(doMUONTrig) {
     gSystem->Load("libPWG3base");
     gSystem->Load("libPWG3muon");
     gSystem->Load("libPWG3muondep");
  }   
}

void AddAnalysisTasks()
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  mgr->SetCommonFileName("QAresults.root");
  // Statistics task
  mgr->AddStatisticsTask(AliVEvent::kMB);
  //
  // CDB connection
  //
  if (doCDBconnect) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskCDBconnect.C");
    AliTaskCDBconnect *taskCDB = AddTaskCDBconnect();
    if (!taskCDB) return;
    taskCDB->SetRunNumber(runNumbers[0]);
  }    
  
  //
  // Event Statistics (<NAME>)
  //
  if (doEventStat) {
      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
      AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
//      mgr->RegisterExtraFile("event_stat.root");
      if (!terminateFiles.IsNull()) terminateFiles += ",";
      terminateFiles += "event_stat.root";
  }
  
  //
  // Centrality (<NAME>)
  //
  if (doCentrality) {
     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
     AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
// J.Thaeder
//     gROOT->LoadMacro("$ALICE_ROOT/PWG1/Centrality/AddTaskHIMultCorr.C");
//     AliAnalysisTaskHIMultCorr *taskHIcentrality = AddTaskHIMultCorr();
  }   
  
  // Vertexing (<NAME>)
  // 
  if (doVertex) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddTaskVertexESD.C");
    AliAnalysisTaskVertexESD* taskvertexesd =  AddTaskVertexESD();
    taskvertexesd->SelectCollisionCandidates();
  }  

  // TPC QA (<NAME>)
  //
  if (doQAsym) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskQAsym.C");
    AliAnalysisTaskSE * taskqasim = AddTaskQAsym(0);
    taskqasim->SelectCollisionCandidates();
  }  
  //
  // VZERO QA  (<NAME>)
  //
  if (doVZERO) {
    gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskVZEROQA.C");
{'fraction_non_alphanumeric': 0.15361175837963792, 'fraction_numerical': 0.00991814542630101, 'mean_word_length': 2.3576730190571715, 'pattern_counts': {'":': 0, '<': 352, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3373463', 'n_tokens_mistral': 5982, 'n_tokens_neox': 5742, 'n_words': 1029}