<commit_before>void AnalysisTrainFromStandardToMuonAODLocal(char* filein= "AliAODs.root", 
                                             char* fileout= "AliMuonAOD.root", 
				             char* dirChain= ".",
				             char* dirData= "."){
     
// Macro to produce a MUON-AOD, i.e. a replica of the standard AOD, containing only events
// where at least one muon is present
// 
// - The input files are the ESD (used only for tag creation) and the standard AOD.
//   Tags files are created from all the ESD/AOD files placed in the directory dirData 
//   and in its subdirectories.
// - The selection of the muon events is based on the AOD tags.
// - The content of the MUON-AOD can be defined by the user with some settings as
//   SetNeedsTracksBranchReplication(), SetNeedsVerticesBranchReplication() 
//   (defined in STEER/AliAODHandler.h)...


    gSystem->Load("libTree.so");
    gSystem->Load("libGeom.so");
    gSystem->Load("libVMC.so");
    gSystem->Load("libPhysics.so");

    // Load par files  
    SetupPar("STEERBase");
    SetupPar("ESD");
    SetupPar("AOD");
    SetupPar("ANALYSIS");
    SetupPar("ANALYSISalice");
    SetupPar("PWG3base");      
    SetupPar("PWG3muon");   
        
    // Create ESD tag files   
    printf("Creating ESD Tags\n");
    AliESDTagCreator *tesd = new AliESDTagCreator();
    tesd->SetStorage(0);     
    tesd->ReadLocalCollection(dirData);  
 
    // Create AOD tag files   
    printf("Creating AOD Tags\n");
    AliAODTagCreator *t = new AliAODTagCreator();
    t->SetStorage(0);
    t->ReadLocalCollection(dirData);    
    
    AliTagAnalysis *TagAna = new AliTagAnalysis("AOD"); 
    
    // Define tag cuts to select only events with muons
    printf("Defining Tags cuts to select events containing at least one muon\n");
    AliRunTagCuts *runCuts = new AliRunTagCuts();
    AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
    AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
    AliEventTagCuts *evCuts = new AliEventTagCuts();
    evCuts->SetNMuonRange(1,10);
    
    // Create the chain of interesting events
    TChain* chain = 0x0;
    TagAna->ChainLocalTags(dirChain);
    chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);

    // Define aod input handler
    AliAODInputHandler* aodInputHandler = new AliAODInputHandler();
    
    // Define aod output handler
    AliAODHandler* aodOutputHandler = new AliAODHandler();

    // Create non standard AOD
    aodOutputHandler->SetCreateNonStandardAOD(); 
    
    // Select the branches to be written in the MUON-AOD
    aodOutputHandler->SetNeedsHeaderReplication();
    aodOutputHandler->SetNeedsTracksBranchReplication();
    aodOutputHandler->SetNeedsVerticesBranchReplication();
    //aodOutputHandler->SetNeedsV0sBranchReplication();
    //aodOutputHandler->SetNeedsTrackletsBranchReplication(); 
    //aodOutputHandler->SetNeedsPMDClustersBranchReplication();
    //aodOutputHandler->SetNeedsJetsBranchReplication();
    //aodOutputHandler->SetNeedsFMDClustersBranchReplication();
    //aodOutputHandler->SetNeedsCaloClustersBranchReplication();
    
    aodOutputHandler->SetOutputFileName(fileout);

     // Define the analysis manager
    AliAnalysisManager *mgr  = new AliAnalysisManager("AOD Manager", "AOD Manager");
    mgr->SetInputEventHandler(aodInputHandler);
    mgr->SetOutputEventHandler(aodOutputHandler);
    //mgr->SetDebugLevel(10);
    
    AliAnalysisTaskFromStandardToMuonAOD *aodfilter = new AliAnalysisTaskFromStandardToMuonAOD("AOD Filter");
    mgr->AddTask(aodfilter);
  
    // Create containers for input/output
    AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
							     AliAnalysisManager::kInputContainer);
    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
							      AliAnalysisManager::kOutputContainer, "default");

    mgr->ConnectInput(aodfilter,0,cinput1);
    mgr->ConnectOutput(aodfilter,0,coutput1);
    
    // Run the analysis    
    printf("CHAIN HAS %d ENTRIES\n",(Int_t)chain->GetEntries());
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local",chain);
}


Int_t setupPar(const char* pararchivename) {
  ///////////////////
  // Setup PAR File//
  ///////////////////
  if (pararchivename) {
    char processline[1024];
    sprintf(processline,".! tar xvzf %s.par",pararchivename);
    gROOT->ProcessLine(processline);
    const char* ocwd = gSystem->WorkingDirectory();
    gSystem->ChangeDirectory(pararchivename);

    // check for BUILD.sh and execute
    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
      printf("*******************************\n");
      printf("*** Building PAR archive    ***\n");
      printf("*******************************\n");

      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
        Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
        return -1;
      }
    }
    // check for SETUP.C and execute
    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
      printf("*******************************\n");
      printf("*** Setup PAR archive       ***\n");
      printf("*******************************\n");
      gROOT->Macro("PROOF-INF/SETUP.C");
    }

    gSystem->ChangeDirectory("../");
  }

  return 1;
}

//______________________________________________________________________________
void SetupPar(char* pararchivename)
{
    if (pararchivename) {
	char processline[1024];
	sprintf(processline,".! tar xvzf %s.par",pararchivename);
	gROOT->ProcessLine(processline);
	TString ocwd = gSystem->WorkingDirectory();
	gSystem->ChangeDirectory(pararchivename);
	
	// check for BUILD.sh and execute
	if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
	    printf("*******************************\n");
	    printf("*** Building PAR archive    ***\n");
	    printf("*******************************\n");
	    
	    if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
		Error("runProcess","Cannot Build the PAR Archive! - Abort!");
		return -1;
	    }
	}
	// check for SETUP.C and execute
	if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
	    printf("*******************************\n");
	    printf("*** Setup PAR archive       ***\n");
	    printf("*******************************\n");
	    gROOT->Macro("PROOF-INF/SETUP.C");
	}
	
	gSystem->ChangeDirectory(ocwd.Data());
   printf("Current dir: %s\n", ocwd.Data());
    } 
}
<commit_msg>Removing dependence on ESD files and new possibility for selecting muon multiplicity in the forward region (Enrico, Roberta)<commit_after>void AnalysisTrainFromStandardToMuonAODLocal(char* filein= "AliAODs.root", 
                                             char* fileout= "AliMuonAOD.root", 
				             char* dirChain= ".",
				             char* dirData= ".",
					     Int_t nev=123456789){
     
// Macro to produce a MUON-AOD, i.e. a replica of the standard AOD, containing only events
// where at least one muon is present
// 
// - The input files are the standard AOD and the AOD.tag.root files 
// - The AOD.tag file can be:
//      1) the one previously created together with the AOD file (i.e. from
//         AnalysisTrainMuonLocal.C)
//      2) created on the fly with this macro
// - The selection of the muon events is based on the AOD tags
// - The content of the MUON-AOD can be defined by the user with some settings as
//   SetNeedsTracksBranchReplication(), SetNeedsVerticesBranchReplication() 
//   (defined in STEER/AliAODHandler.h)...


    gSystem->Load("libTree.so");
    gSystem->Load("libGeom.so");
    gSystem->Load("libVMC.so");
    gSystem->Load("libPhysics.so");
    gSystem->Load("libSTEER.so");              // for aliroot based analysis
    gSystem->Load("libPWG3muon.so");  // for aliroot based analysis

    // Load par files, if the analysis is par based
    // SetupPar("STEERBase");
    // SetupPar("ESD");
    // SetupPar("AOD");
    // SetupPar("ANALYSIS");
    // SetupPar("ANALYSISalice");
    // SetupPar("PWG3muon");   
     
    // Uncomment the following lines if the AOD tag file has to be created on the fly	 
    // printf("Creating AOD Tags on the fly\n");
    // AliAODTagCreator *t = new AliAODTagCreator();
    // t->SetStorage(0);
    // t->ReadLocalCollection(dirData); 
    
    AliTagAnalysis *TagAna = new AliTagAnalysis("AOD"); 
   
    // Define tag cuts to select events containing at least one muon in the dimuon spectrometer
    printf("Defining Tags cuts to select events containing at least one muon in the dimuon spectrometer\n");
    AliRunTagCuts *runCuts = new AliRunTagCuts();
    AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
    AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
    AliEventTagCuts *evCuts = new AliEventTagCuts();
    evCuts->SetNFWMuonRange(1,10);
   
    // Create the chain of interesting events
    TChain* chain = 0x0;
    TagAna->ChainLocalTags(dirChain);
    TagAna->SetType("AOD");
    chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
    Info("AnalysisTrainFromStandardToMuonAOD",Form("CHAIN HAS %d ENTRIES",(Int_t)chain->GetEntries()));

    // Define aod input handler
    AliAODInputHandler* aodInputHandler = new AliAODInputHandler();
    
    // Define aod output handler
    AliAODHandler* aodOutputHandler = new AliAODHandler();

    // Create non standard AOD
    aodOutputHandler->SetCreateNonStandardAOD(); 
    
    // Select the branches to be replicated in the MUON-AOD
    aodOutputHandler->SetNeedsHeaderReplication();
    aodOutputHandler->SetNeedsTracksBranchReplication();
    aodOutputHandler->SetNeedsVerticesBranchReplication();
    aodOutputHandler->SetNeedsV0sBranchReplication();
    aodOutputHandler->SetNeedsTrackletsBranchReplication(); 
    aodOutputHandler->SetNeedsPMDClustersBranchReplication();
    aodOutputHandler->SetNeedsJetsBranchReplication();
    aodOutputHandler->SetNeedsFMDClustersBranchReplication();
    aodOutputHandler->SetNeedsCaloClustersBranchReplication();
    
    aodOutputHandler->SetOutputFileName(fileout);

     // Define the analysis manager
    AliAnalysisManager *mgr  = new AliAnalysisManager("AOD Manager", "AOD Manager");
    mgr->SetInputEventHandler(aodInputHandler);
    mgr->SetOutputEventHandler(aodOutputHandler);
    //mgr->SetDebugLevel(10);
    
    AliAnalysisTaskFromStandardToMuonAOD *aodfilter = new AliAnalysisTaskFromStandardToMuonAOD("AOD Filter");
    mgr->AddTask(aodfilter);
  
    // Create containers for input/output
    AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
							     AliAnalysisManager::kInputContainer);
    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
							      AliAnalysisManager::kOutputContainer, "default");
							       
    mgr->ConnectInput(aodfilter,0,cinput1);
    mgr->ConnectOutput(aodfilter,0,coutput1);
 
    // Run the analysis    
    printf("CHAIN HAS %d ENTRIES\n",(Int_t)chain->GetEntries());
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local",chain,nev);
}


Int_t setupPar(const char* pararchivename) {
  ///////////////////
  // Setup PAR File//
  ///////////////////
  if (pararchivename) {
    char processline[1024];
    sprintf(processline,".! tar xvzf %s.par",pararchivename);
    gROOT->ProcessLine(processline);
    const char* ocwd = gSystem->WorkingDirectory();
    gSystem->ChangeDirectory(pararchivename);

    // check for BUILD.sh and execute
    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
      printf("*******************************\n");
      printf("*** Building PAR archive    ***\n");
      printf("*******************************\n");

      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
        Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
        return -1;
      }
    }
    // check for SETUP.C and execute
    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
      printf("*******************************\n");
      printf("*** Setup PAR archive       ***\n");
      printf("*******************************\n");
      gROOT->Macro("PROOF-INF/SETUP.C");
    }

    gSystem->ChangeDirectory("../");
  }

  return 1;
}

//______________________________________________________________________________
void SetupPar(char* pararchivename)
{
    if (pararchivename) {
	char processline[1024];
	sprintf(processline,".! tar xvzf %s.par",pararchivename);
	gROOT->ProcessLine(processline);
	TString ocwd = gSystem->WorkingDirectory();
	gSystem->ChangeDirectory(pararchivename);
	
	// check for BUILD.sh and execute
	if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
	    printf("*******************************\n");
	    printf("*** Building PAR archive    ***\n");
	    printf("*******************************\n");
	    
	    if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
		Error("runProcess","Cannot Build the PAR Archive! - Abort!");
		return -1;
	    }
	}
	// check for SETUP.C and execute
	if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
	    printf("*******************************\n");
	    printf("*** Setup PAR archive       ***\n");
	    printf("*******************************\n");
	    gROOT->Macro("PROOF-INF/SETUP.C");
	}
	
	gSystem->ChangeDirectory(ocwd.Data());
   printf("Current dir: %s\n", ocwd.Data());
    } 
}

{'fraction_non_alphanumeric': 0.1702835538752363, 'fraction_numerical': 0.005141776937618148, 'mean_word_length': 3.404262404262404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3949261', 'n_tokens_mistral': 4217, 'n_tokens_neox': 4060, 'n_words': 855}