Example #1
0
void runProofFwdDetsQA(const char * dataset = "/COMMON/COMMON/LHC09a4_run8101X",Long64_t nentries=100000, Long64_t firstentry=0)
{
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");

  // Connect to Proof
  gEnv->SetValue("XSec.GSI.DelegProxy","2");
  TProof::Open("cheshkov:[email protected]");

  // Upload and enable packages: please use the correct version!
  gProof->UploadPackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16");
  gProof->EnablePackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16");

  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("AliAnaFwdDetsQA");

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

  // Enable MC event handler
  AliVEventHandler* handler = new AliMCEventHandler;
  mgr->SetMCtruthEventHandler(handler);

  // Create task

  gProof->Load(Form("%s/PWGPP/AliAnaFwdDetsQA.cxx++g",
		    gSystem->Getenv("ALICE_ROOT")));
  AliAnalysisTask *task = new AliAnaFwdDetsQA("AliAnaFwdDetsQA");

  // Add task
  mgr->AddTask(task);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput = 
    mgr->CreateContainer("coutput", TList::Class(), 
    AliAnalysisManager::kOutputContainer, "FwdDetsQA.root");

  // Connect input/output
  mgr->ConnectInput(task, 0, cinput);
  mgr->ConnectOutput(task, 1, coutput);


  // Enable debug printouts
  mgr->SetDebugLevel(3);

  if (!mgr->InitAnalysis())
    return;

  mgr->PrintStatus();

  TFileCollection *proofColl = gProof->GetDataSet(dataset);
  TChain *chain = new TChain("esdTree");
  chain->AddFileInfoList((TCollection*)(proofColl->GetList()));
  mgr->StartAnalysis("proof", chain, nentries, firstentry);

    //  mgr->StartAnalysis("proof",dataset,nentries,firstentry);
}
Example #2
0
void runProofT0analysis(const char * dataset = "/COMMON/COMMON/LHC09a4_10TeV_200k#esdTree",Long64_t nentries=20000, Long64_t firstentry=0)
{
// Connect to Proof
  TProof::Open("proof://[email protected]"); 
  //TProof::Open("lxb6046");

  // Upload and enable packages: please use the correct version!
  gProof->UploadPackage("AF-v4-16");
  gProof->EnablePackage("AF-v4-16");
  gProof->ShowDataSets();      
 
  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("AliT0MultiplicityTask");

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

  // Enable MC event handler
  AliVEventHandler* handler = new AliMCEventHandler;
  mgr->SetMCtruthEventHandler(handler);

  // Create task
  //  gProof->Load("AliMCComparisonTrack.cxx++g");
  gProof->Load("AliT0MultiplicityTask.cxx++g");
  AliAnalysisTask *task = new AliT0MultiplicityTask("AliT0MultiplicityTask");

  // Add task
  mgr->AddTask(task);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = 
    mgr->CreateContainer("cchain", TChain::Class(), AliAnalysisManager::kInputContainer);
  AliAnalysisDataContainer *coutput = 
    mgr->CreateContainer("coutput", TList::Class(), 
    AliAnalysisManager::kOutputContainer, "MultHist.root");

  // Connect input/output
  mgr->ConnectInput(task, 0, cinput);
  mgr->ConnectOutput(task, 1, coutput);


  // Enable debug printouts
  mgr->SetDebugLevel(3);

  if (!mgr->InitAnalysis())
    return;

  mgr->PrintStatus();

   mgr->StartAnalysis("proof",dataset,nentries,firstentry);
}
Example #3
0
void rundStarTask(const char* mode = "test", bool isMC=true){
  // Include AliPhysics and AliRoot libraries
  gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");
  //Check the run mode
  if(std::strcmp(mode,"local")!=0 && std::strcmp(mode,"grid")!=0 && std::strcmp(mode,"test")!=0){
    Printf("\n\tIncorrect run option, check first argument of run macro");
    Printf("\tmode = local, test or grid\n");
    return;
  }
  Printf("%s analysis chosen",mode);
  //Define the plugin
  AliAnalysisGrid *plugin = 0x0;
  TChain *chain = 0x0;
  if(std::strcmp(mode,"local")!=0) {
    plugin = CreateAlienHandler(mode,isMC);
    if(!plugin) return;
  }
  else {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateAODChain.C");
    chain = CreateAODChain("localdata.txt");
  }
  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager(kTaskName);
  if(plugin) mgr->SetGridHandler(plugin);
  // Define input handlers
  if(isMC){
    AliMCEventHandler*  mcHandler = new AliMCEventHandler();
    if (plugin) mgr->SetMCtruthEventHandler(mcHandler);
  }
  AliAODInputHandler *aodH = new AliAODInputHandler();
  mgr->SetInputEventHandler(aodH);
  // Compile the class
  gROOT->LoadMacro("AliAnalysisTaskdStar.cxx++g");
  // PID response
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
  AliAnalysisTaskPIDResponse *pidTask = AddTaskPIDResponse(isMC); // useMC
  // dStar task
  gROOT->LoadMacro("AddTaskdStar.C");
  AliAnalysisTaskdStar *task = AddTaskdStar(isMC);
  // Disbale debug printouts
  mgr->SetDebugLevel(3);
  AliLog::SetGlobalLogLevel(AliLog::kFatal);
  AliLog::SetGlobalDebugLevel(0);
  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  // Start analysis in grid.
  if (std::strcmp(mode,"local")==0)
    mgr->StartAnalysis(mode,chain);
  else
    mgr->StartAnalysis("grid");
}
Example #4
0
void runProofTRDComparison(const char *dataset="/PWG0/COMMON/run30000X_10TeV_0.5T",Long64_t nentries=1000, Long64_t firstentry=0)
{
  // Connect to Proof
  TProof::Open("lxb6046");

  // Upload and enable packages: please use the correct version!
  gProof->UploadPackage("AF-v4-14");
  gProof->EnablePackage("AF-v4-14");

  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("AliTRDComparison");

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

  // Enable MC event handler
  AliVEventHandler* handler = new AliMCEventHandler;
  mgr->SetMCtruthEventHandler(handler);

  // Create task
  gProof->Load("AliMCComparisonTrack.cxx++g");
  gProof->Load("AliTRDComparisonTask.cxx++g");
  AliAnalysisTask *task = new AliTRDComparisonTask("AliTRDComparisonTask");

  // Add task
  mgr->AddTask(task);

  // Create containers for input/output
  AliAnalysisDataContainer* cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer* coutput = 
    mgr->CreateContainer("coutput", TList::Class(), 
    AliAnalysisManager::kOutputContainer, "AliTRDComparisonHist.root");

  // Connect input/output
  mgr->ConnectInput(task, 0, cinput);
  mgr->ConnectOutput(task, 1, coutput);


  // Enable debug printouts
  mgr->SetDebugLevel(3);

  if (!mgr->InitAnalysis())
    return;

  mgr->PrintStatus();

  mgr->StartAnalysis("proof",dataset,nentries,firstentry);
}
Example #5
0
void TaskBuzzer(UInt_t config, const char *collection="wn.xml") 
{
  printf("Running buzzer with: %s\n", ConfigName(config));
  TGrid::Connect("alien://");
  if (!gGrid || !gGrid->IsConnected()) {
    ::Error("PilotAnalysis", "No grid connection");
    return;
  }
  TChain *chain = CreateChain(collection, "ESD");
  // Load libraries
  gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD");
  LoadLibraries();
  // Create manager
  AliAnalysisManager *mgr  = new AliAnalysisManager("ESDfiltering", "Production train");
  mgr->SetNSysInfo(100);
  // Input handler
  AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
//  AliESDInputHandler *esdHandler = new AliESDInputHandler();
  esdHandler->SetReadFriends(kTRUE);
  esdHandler->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdHandler);
  if (config & kAOD) {
     // AOD output handler
     AliAODHandler* aodHandler   = new AliAODHandler();
     aodHandler->SetOutputFileName("AliAOD.root");
     if (!mergeExcludes.IsNull()) mergeExcludes += " ";
     mergeExcludes += "AliAOD.root";
     mgr->SetOutputEventHandler(aodHandler);
  }   
  // AnalysisTasks
  AddAnalysisTasks(config);

  mgr->SetDebugLevel(1);
  if (mgr->InitAnalysis()) {                                                                                                              
    mgr->PrintStatus(); 
    mgr->StartAnalysis("local", chain);
  }  
} 
Example #6
0
void runCPVAnalysis(const char *runmode = "full")
{
    // set if you want to run the analysis locally (kTRUE), or on grid (kFALSE)
    // Bool_t local = kFALSE;
     Bool_t local = kTRUE;
    // if you run on grid, specify test mode (kTRUE) or full grid model (kFALSE)
    // Bool_t gridTest = kTRUE;
    Bool_t gridTest = kFALSE;
    
    // since we will compile a class, tell root where to look for headers  
    gROOT->ProcessLine(".include $ROOTSYS/include");
    gROOT->ProcessLine(".include $ALICE_ROOT/include");

    // create the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("AnalysisTaskCPV");
    AliESDInputHandler *esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);


    //PID task
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AliAnalysisTask *taskPID =  AddTaskPIDResponse(/*Bool_t isMC=*/ kFALSE, /*Bool_t autoMCesd=*/kTRUE,
						   /*Bool_t tuneOnData=*/kTRUE);
    
    // // Add physics selection
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
    physSelTask->GetPhysicsSelection()->SetUseBXNumbers(kFALSE);// ---> ???
    
    // load the addtask macro
    gROOT->LoadMacro("AddTaskCPV.C");
    // create an instance of your analysis task
    AliAnalysisTaskCPV *task = AddTaskCPV();
    task->SetRCPV(428.3);
    task->SelectCollisionCandidates(AliVEvent::kINT7);

    if(!mgr->InitAnalysis()) return;
    mgr->SetDebugLevel(2);
    mgr->PrintStatus();
    mgr->SetUseProgressBar(1, 25);

    if(local) {
        // if you want to run locally, we need to define some input
        TChain* chain = new TChain("esdTree");
        // add a few files to the chain (change this so that your local files are added)
        TGrid::Connect("alien://");
        chain->Add("alien:///alice/data/2015/LHC15n/000244340/pass2/15000244340020.100/AliESDs.root");
        // start the analysis locally, reading the events from the tchain
        mgr->StartAnalysis("local", chain);
    } else {
        // if we want to run on grid, we create and configure the plugin
        AliAnalysisAlien *alienHandler = new AliAnalysisAlien();
	alienHandler->SetCheckCopy(kFALSE);
        // also specify the include (header) paths on grid
        alienHandler->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");
        // select the aliphysics version. all other packages
        // are LOADED AUTOMATICALLY!
        alienHandler->SetAliPhysicsVersion("vAN-20170215-1");
        // set the Alien API version
        alienHandler->SetAPIVersion("V1.1x");
        // select the input data
        alienHandler->SetGridDataDir("/alice/data/2015/LHC15n");
        alienHandler->SetDataPattern("/pass2/*/AliESDs.root");

	const Int_t runList[] = {244340, 244343};
	const Int_t nRuns = 2;
	// const Int_t runList[] = {244340, 244343, 244351, 244355, 244359, 
	// 			 244364, 244377, 244411, 244416, 244418, 
	// 			 244421, 244453, 244480, 244481, 244482, 
	// 			 244483, 244484, 244531, 244540, 244542, 
	// 			 244617, 244618, 244627, 244628};
	// const Int_t nRuns = 24;
        // MC has no prefix, data has prefix 000
        alienHandler->SetRunPrefix("000");
        // runnumber
	for (Int_t iRun=0; iRun<nRuns; iRun++) {
	  alienHandler->AddRunNumber(runList[iRun]);
	}
        // number of files per subjob
        alienHandler->SetSplitMaxInputFileNumber(50);
        alienHandler->SetExecutable("CPVTask.sh");
        // specify how many seconds your job may take
        alienHandler->SetTTL(36000);
        alienHandler->SetJDLName("CPVTask.jdl");

        alienHandler->SetOutputToRunNo(kTRUE);
        alienHandler->SetKeepLogs(kTRUE);
        // merging: run with kTRUE to merge on grid
        // after re-running the jobs in SetRunMode("terminate") 
        // (see below) mode, set SetMergeViaJDL(kFALSE) 
        // to collect final results
        alienHandler->SetMaxMergeStages(2);
        alienHandler->SetMergeViaJDL(kTRUE);

        // define the output folders
        alienHandler->SetGridWorkingDir("CPVWorkingDir");
        alienHandler->SetGridOutputDir("CPVOutputDir_R428");

        // connect the alien plugin to the manager
        mgr->SetGridHandler(alienHandler);
        if(gridTest) {
            // speficy on how many files you want to run
            alienHandler->SetNtestFiles(1);
            // and launch the analysis
            alienHandler->SetRunMode("test");
            mgr->StartAnalysis("grid");
        } else {
            // else launch the full grid analysis
            alienHandler->SetRunMode(runmode);
            mgr->StartAnalysis("grid");
        }
    }
}
Example #7
0
void runLocalSim() {
    TStopwatch timer;
    timer.Start();

    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice");

    gROOT->LoadMacro("AliAnalysisEt.cxx+g");
    gROOT->LoadMacro("AliAnalysisEtReconstructed.cxx+g");
    gROOT->LoadMacro("AliAnalysisEtMonteCarlo.cxx+g");
    gROOT->LoadMacro("AliAnalysisEtReconstructedPhos.cxx+g");
    gROOT->LoadMacro("AliAnalysisEtMonteCarloPhos.cxx+g");

    gROOT->LoadMacro("AliAnalysisTaskTotEt.cxx+g");
    //____________________________________________//
    /*AliTagAnalysis *TagAna = new AliTagAnalysis("ESD");
    TagAna->ChainLocalTags("../Tags");

    AliRunTagCuts *runCuts = new AliRunTagCuts();
    AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
    AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
    AliEventTagCuts *evCuts = new AliEventTagCuts();
    //   evCuts->SetMultiplicityRange(11,12);
    evCuts->SetNPHOSClustersRange(0,10000);

    TChain* chain = 0x0;
    chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
    *///  chain->SetBranchStatus("*Calo*",0);

    TChain *chain = new TChain("esdTree");
    //chain->Add("/media/wd/data/LHC10b/10000116134019.10/AliESDs.root");
//   chain->Add("../ESDs/140012/001/AliESDs.root");
//   chain->Add("../ESDs/140012/002/AliESDs.root");
//   chain->Add("../ESDs/140012/003/AliESDs.root");
//   chain->Add("../ESDs/140012/004/AliESDs.root");
//   chain->Add("../ESDs/140012/005/AliESDs.root");
//   chain->Add("../ESDs/140012/006/AliESDs.root");
//   chain->Add("../ESDs/140012/007/AliESDs.root");
//   chain->Add("../ESDs/140012/008/AliESDs.root");
//   chain->Add("../ESDs/140012/009/AliESDs.root");
//   chain->Add("../ESDs/140012/010/AliESDs.root");
//   chain->Add("../ESDs/140012/011/AliESDs.root");

    chain->Add("/media/wd/data/LHC10a/140009/088/AliESDs.root");
   chain->Add("/media/wd/data/LHC10a/140009/081/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/065/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/050/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/010/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/013/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/025/AliESDs.root");
chain->Add("/media/wd/data/LHC10a/140009/021/AliESDs.root");
   chain->Add("/media/wd/data/LHC10a/140009/072/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/011/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/092/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/043/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/002/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/008/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/059/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/107/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/017/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/085/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/103/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/091/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/034/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/084/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/071/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/079/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/087/AliESDs.root");
    chain->Add("/media/wd/data/LHC10a/140009/067/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/028/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/068/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/051/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/020/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/102/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/066/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/063/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/047/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/105/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/040/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/053/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/083/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/069/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/016/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/006/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/039/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/077/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/100/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/003/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/052/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/009/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/026/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/062/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/095/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/070/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/106/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/027/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/054/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/073/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/022/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/044/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/012/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/056/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/031/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/086/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/023/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/075/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/093/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/005/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/035/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/057/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/019/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/042/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/046/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/048/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/024/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/018/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/014/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/064/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/032/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/104/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/029/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/082/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/108/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/074/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/041/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/058/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/089/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/080/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/101/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/055/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/098/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/096/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/038/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/1000/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/033/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/094/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/004/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/060/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/076/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/078/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/061/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/090/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/097/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140009/099/AliESDs.root");
//
//   chain->Add("/media/wd/data/LHC10a/140010/081/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/065/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/050/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/010/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/013/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/025/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/021/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/072/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/011/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/092/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/043/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/002/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/001/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/015/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/008/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/059/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/017/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/045/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/103/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/091/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/034/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/084/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/071/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/079/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/087/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/067/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/028/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/068/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/051/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/020/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/102/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/066/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/063/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/047/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/105/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/040/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/053/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/083/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/069/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/016/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/006/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/039/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/077/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/100/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/036/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/003/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/052/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/007/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/009/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/026/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/062/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/030/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/095/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/070/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/027/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/054/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/073/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/022/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/044/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/012/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/056/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/031/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/086/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/023/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/075/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/093/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/005/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/035/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/057/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/019/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/042/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/046/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/048/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/024/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/018/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/014/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/064/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/032/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/104/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/029/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/082/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/058/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/089/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/080/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/101/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/055/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/098/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/096/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/038/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/1000/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/033/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/094/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/004/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/060/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/076/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/078/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/061/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/090/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/037/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/097/AliESDs.root");
// chain->Add("/media/wd/data/LHC10a/140010/099/AliESDs.root");




    // Make the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
    AliVEventHandler* esdH = new AliESDInputHandler;
    mgr->SetInputEventHandler(esdH);
    AliMCEventHandler* handler = new AliMCEventHandler;
    handler->SetReadTR(kFALSE);
    mgr->SetMCtruthEventHandler(handler);

    AliAnalysisTaskTotEt *task1 = new AliAnalysisTaskTotEt("TaskTotEt");
    mgr->AddTask(task1);

    // Create containers for input/output
    //AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1", TChain::Class(),AliAnalysisManager::kInputContainer);
    AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();

    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("out1", TList::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.sim.root");

    //____________________________________________//
    mgr->ConnectInput(task1,0,cinput1);
    mgr->ConnectOutput(task1,1,coutput1);

    mgr->SetDebugLevel(1);

    if (!mgr->InitAnalysis()) return;
    mgr->PrintStatus();
    mgr->StartAnalysis("local",chain);

    timer.Stop();
    timer.Print();
}
Example #8
0
void runGrid() {

  gSystem->Load("libCore.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libSTEERBase");
  //  gSystem->Load("libESD");
  gSystem->Load("libAOD");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libTENDER");
  //  gSystem->Load("libPWGPP");

  gROOT->ProcessLine(".include $ALICE_ROOT/include");
  
  gROOT->LoadMacro("CreateAlienHandler.C");
  AliAnalysisGrid *alienHandler = CreateAlienHandler();  
  if (!alienHandler) return;

  cout<<" Got alien handler"<<endl;
  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");

  mgr->SetGridHandler(alienHandler);

  /*
  // For centrality Selection: Requires input event handler.
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
  AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
  taskCentrality->SetPass(2); // remember to set the pass you are processing!!! 
  */
  // My Task
  gROOT->LoadMacro("AliAnalysisFBMultFluct.cxx++g");
  AliAnalysisTask *task = new AliAnalysisFBMultFluct("TaskFBGrid");

  //  task->SelectCollisionCandidates(AliVEvent::kMB) // Added for minbias trigger on 3Jun14
  //  task->SelectCollisionCandidates(AliVEvent::kCentral) // Added for minbias trigger on 3Jun14

  mgr->AddTask(task);

  /*
  AliESDInputHandler* esdH = new AliESDInputHandler;
  mgr->SetInputEventHandler(esdH);
  AliMCEventHandler *mc = new AliMCEventHandler();
  mgr->SetMCtruthEventHandler(mc);
  TChain *chain = new TChain("aodTree");
  //  chain->Add("/Users/sadhanadash/QA/AliESDs.root");
  chain->Add("/Users/rashmi/ALICE/InitFluct/alice/data/2010/LHC11h/000170388/ESDs/pass2_muon/AOD/132/AliAOD.root");
  //  chain->Add("/Users/rashmi/ALICE/InitFluct/alice/data/2011/LHC11h/000170388/ESDs/pass2_muon/AOD/132/AliESDs.root");
  chain->Add("AliESDs.root");
  */

  
  //  AliAODInputHandler* aodH = new AliAODInputHandler;
    AliVEventHandler* aodH = new AliAODInputHandler;
  mgr->SetInputEventHandler(aodH);
  cout<<" SetInputEventHandler"<<endl;
  
  //   TChain *chain = new TChain("aodTree");
   //alice/data/2010/LHC10h/000139510/ESDs/pass2/AOD160/0001
  //chain->Add("AODfile/139510/AliAOD.root");
  //  chain->Add("pass2/137161/1/AliAOD.root");
  //  chain->Add("pass2/137161/2/AliAOD.root");
  // chain->GetListOfFiles()->Print();

  // Create containers for input/output

  AliAnalysisDataContainer *coutput = 
    //     mgr->CreateContainer("coutput", TObjArray::Class(),
    //     mgr->CreateContainer("coutput", TList::Class(),
    //     AliAnalysisManager::kOutputContainer, "MC.AOD.root" );
    mgr->CreateContainer("coutput", TList::Class(),
			 AliAnalysisManager::kOutputContainer, "AOD.DATA.root" );

  AliAnalysisDataContainer *cTree = 
    mgr->CreateContainer("cTree",TTree::Class(),AliAnalysisManager::kOutputContainer,"AOD.DATA.root");
  
  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput(task,1,coutput);
  mgr->ConnectOutput(task,2,cTree);
  /*
  mgr->CreateContainer("cinput",TFile::Class(),1,"AOD.137161.input.root");
  mgr->ConnectInput(task,2,cinput); 
  */
  mgr->SetDebugLevel(1);
  
  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();

  cout<<" Starting Analysis now"<<endl;
  //  mgr->StartAnalysis("local",chain);
  mgr->StartAnalysis("grid");
}
Example #9
0
//______________________________________________________________________________
void RunGrid(
         const char* runtype = "grid", // local, proof or grid
         const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
         const Long64_t nentries = 400, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
         const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
         const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
         const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode
         const char *taskname = "Deuterons2011ESD"
         )
{
  // check run type
  if(runtype != "local" && runtype != "proof" && runtype != "grid"){
    Printf("\n\tIncorrect run option, check first argument of run macro");
    Printf("\tint runtype = local, proof or grid\n");
    return;
  }
  Printf("%s analysis chosen",runtype);
  
  gROOT->ProcessLine(".include $ALICE_ROOT/include");
  
  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
  gSystem->AddIncludePath("-I$ALICE_ROOT/PWGHF/vertexingHF");
  // Load analysis specific libraries
  //=====================================================================
  
  gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS  -I$ALICE_ROOT/OADB -I$ALICE_ROOT/PWGHF -I$ALICE_ROOT/PWGHF/base -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWG/FLOW/Base -I$ALICE_ROOT/PWG/FLOW/Tasks -g");
  
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libMinuit.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  gSystem->Load("libANALYSIS.so");
  gSystem->Load("libOADB.so");
  gSystem->Load("libANALYSISalice.so");
  gSystem->Load("libCORRFW.so");
  gSystem->Load("libPWGHFbase.so");
  gSystem->Load("libPWGflowBase.so");
  gSystem->Load("libPWGflowTasks.so");
  gSystem->Load("libPWGHFvertexingHF.so");
  
  // Load analysis specific libraries
  //=====================================================================
  //------ Create AlienPlugin ---------------------
  AliAnalysisGrid *plugin = 0x0;
  TChain *chain = 0x0;
  if (runtype != "local") {
    plugin = CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
    if(!plugin) return;
  } else {
    gROOT->LoadMacro("$ALICE_ROOT/PWGCF/Correlations/macros/dphicorrelations/CreateESDChain.C");
    chain = CreateESDChain("ESDs.txt");
  }
  
  //---- Create the analysis manager
  AliAnalysisManager* mgr = new AliAnalysisManager(taskname);
  if(plugin) mgr->SetGridHandler(plugin);
  
  //  Input
  
  AliESDInputHandler* iH = new AliESDInputHandler("handler","handler for my analisys");
  mgr->SetInputEventHandler(iH);
  
  //--------------------------------------------------------------
  // Other tasks

  // Physics selection
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
  AliPhysicsSelectionTask *physSel = AddTaskPhysicsSelection(kFALSE); // useMC
  // Centrality selection
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
  AliCentralitySelectionTask *taskCentr = AddTaskCentrality();
  // PID response
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
  AliAnalysisTaskPIDResponse *pidTask = AddTaskPIDResponse(kFALSE); // useMC
  // PID QA
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
  AliAnalysisTaskPIDqa *pidQATask = AddTaskPIDqa();
  
  gROOT->LoadMacro("./AliAnalysisTaskFlowd.cxx+g");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/AliAnalysisTaskCheckCascadePbPb.cxx++g");
  gROOT->LoadMacro("./AddTaskFlowd.C");//$ALICE_ROOT/PWGLF/STRANGENESS/Cascades/macros/AddTaskCheckCascadePbPb.C");
  AliAnalysisTaskFlowd *task = AddTaskFlowd(kTRUE);
  

  
  //__________________________________________________________________________
  // Disable debug printouts
  mgr->SetDebugLevel(3);
  AliLog::SetGlobalLogLevel(AliLog::kFatal);
  AliLog::SetGlobalDebugLevel(0);
  
  //__________________________________________________________________________
  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  // Start analysis in grid.
  if (runtype == "local")
    mgr->StartAnalysis(runtype,chain,nentries,firstentry);
  else
    mgr->StartAnalysis(runtype,nentries,firstentry);
}
Example #10
0
//______________________________________________________________________________
void AODtrainsim(Int_t merge=0)
{
  // Main analysis train macro.
  // merge = 0: production
  // merge = 1: intermediate merging
  // merge = 2: final merging + terminate
  // merge = 3: terminate only

  if (merge) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("AODtrainsim.C", "No grid connection");
      return;
    }
  }
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
  printf("==================================================================\n");
  printf("===========    RUNNING FILTERING TRAIN   ==========\n");
  printf("==================================================================\n");
  printf("=  Configuring analysis train for:                               =\n");
  if (usePhysicsSelection)   printf("=  Physics selection                                                =\n");
  if (iESDfilter)   printf("=  ESD filter                                                    =\n");
  if (iMUONcopyAOD) printf("=  MUON copy AOD                                                 =\n");

  // Load common libraries and set include path
  gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_PHYSICS/include");

  // Make the analysis manager and connect event handlers
  AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Production train");
  if (useSysInfo) mgr->SetNSysInfo(100);

  // Load ParFiles
  if (!LoadAnalysisLibraries()) {
    ::Error("AODtrainsim.C", "Could not load analysis libraries");
    return;
  }
  
  // Create input handler (input container created automatically)
  // ESD input handler
  AliESDInputHandler *esdHandler = new AliESDInputHandler();
  mgr->SetInputEventHandler(esdHandler);
  // Monte Carlo handler
  if (useMC) {
    AliMCEventHandler* mcHandler = new AliMCEventHandler();
    mgr->SetMCtruthEventHandler(mcHandler);
    mcHandler->SetReadTR(useTR);
  }
  // AOD output container, created automatically when setting an AOD handler
  if (iAODhandler) {
    // AOD output handler
    AliAODHandler* aodHandler   = new AliAODHandler();
    aodHandler->SetOutputFileName("AliAOD.root");
    mgr->SetOutputEventHandler(aodHandler);
  }
  // Debugging if needed
  if (useDBG) mgr->SetDebugLevel(3);

  AddAnalysisTasks(merge);
  if (merge) {
    if (merge < 3) AODmerge();
    if (merge > 1) {
      mgr->InitAnalysis();
      mgr->SetGridHandler(new AliAnalysisAlien());
      mgr->StartAnalysis("grid terminate",0);
    }
    return;
  }
  // Run the analysis
  //
  TChain *chain = CreateChain();
  if (!chain) return;

  TStopwatch timer;
  timer.Start();
  mgr->SetSkipTerminate(kTRUE);
  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
  }
  timer.Print();
}
Example #11
0
//________________________________________________________________
void runAAF(Int_t nFilesMax, char* type, char* textFileName, Int_t task)
{
  Int_t analysisMC  = 0;
  Bool_t debug      = kTRUE;
  Bool_t readTR     = kFALSE;
  Bool_t esdAna     = kTRUE;  // run ESD analysis (kTRUE) or AOD analysis (kFALSE)
  Int_t runtype = -1;
  
  if(strstr(type,"aod") != NULL) {
    esdAna = kFALSE;; // AOD analysis
    cout << "Performing AOD analysis" << endl;
  } else 
    cout << "Performing ESD analysis" << endl;
  
  const Char_t* treeName = GetTreeName(esdAna);
  
  if(strstr(type,"PbPb") != NULL) runtype = 2; // PbPb
  if(strstr(type,"pp") != NULL) runtype = 3; // pp
  if(strstr(type,"900") != NULL){ // 900GeV pp
    if(runtype != -1){
      printf("conflicting run types\n");
      return;
    }
    runtype = 1;
  }
  if(runtype == -1) runtype = 0; // 7TeV pp
  
  char *test;
  test = strstr(type,"MC");
  if(test != NULL){
    analysisMC = kTRUE;
    cout << "Test: " << test << endl;
    if(sscanf(test,"MC%d",&analysisMC)){
      //  cout << "**************" << analysisMC << endl;
      if(!analysisMC) analysisMC = 1;
    }
  }
  cout << "MonteCarlo " << analysisMC << endl;
  
  const char* alirootver = "v5-02-17-AN";
  Int_t mode = -1; // mode 1: PROOF, 2: GRID, 0: LOCAL
  printf("===================================================================\n");
  if(strstr(type,"proof") != NULL){ 
    if(mode != -1){
      printf("===== CONFLICTING TYPES =====\n");
      return;
    }
    mode = 1; 
    printf("===============   RUNNING ANALYSIS IN CAF MODE   ================\n");
  }
  if(strstr(type,"grid") != NULL){
    if(mode != -1){
      printf("===== CONFLICTING TYPES =====\n");
      return;
    }
    printf("===============  RUNNING ANALYSIS IN GRID MODE   ================\n");
    mode = 2; 
  }
  if(strstr(type,"local") != NULL || mode<0){ 
    if(mode != -1){
      printf("===== CONFLICTING TYPES =====\n");
      return;
    }
    printf("===============  RUNNING ANALYSIS IN LOCAL MODE  ================\n");
    mode = 0;
  }
  
  printf("===================================================================\n");
  printf("===================================================================\n");
  if (analysisMC) printf(":: use MC    TRUE\n");
  else            printf(":: use MC    FALSE\n");
  if (readTR)     printf(":: read TR   TRUE\n");
  else            printf(":: read TR   FALSE\n");
  if (debug)      printf(":: debugging TRUE\n");
  else            printf(":: debugging FALSE\n");
  
  Char_t taskname[128];
  
  switch(task){
  case 1:
    sprintf(taskname,"HighPtDeDxCosmic");
    break;
  case 2:
    sprintf(taskname,"HighPtDeDx");
    break;
  case 3:
    sprintf(taskname,"HighPtDeDxV0");
    break;
  case 4:{
    sprintf(taskname,"EffDecomposition");
  }
    break;
  default:
    printf("Unknown task\n");
    return;
  }
  
  Char_t nameouputfiles[1280]={0};
  if(runtype ==2){
    for(Int_t i=0;i<6;++i){
      //Char_t tmpname[128]={0};
      sprintf(nameouputfiles,"%s %s_Tree_%1.0f_%1.0f.root",nameouputfiles,taskname,minCent[i],maxCent[i]);
      
    }
  }
  if(runtype ==3){
    sprintf(nameouputfiles,"%s %s_Tree.root",taskname);
  }
  


  cout<<"Files to be stored:"<<nameouputfiles<<endl;


  // Load common libraries   
  gSystem->Load("libTree.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  gSystem->Load("libCDB.so");
  gSystem->Load("libANALYSIS.so");
  gSystem->Load("libANALYSISalice.so");
  // tender

  gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));


  cout << "mode " << mode << ", type " << type << endl;

  if (mode == 1){
    cout << "Connecting to CAF..." << endl;
    gEnv->SetValue("XSec.GSI.DelegProxy","2");

    //const char* AAF = "[email protected]";    
    const char* AAF = "[email protected]";    

    if(strstr(type,"reset") != NULL)
       TProof::Reset(AAF,kFALSE);
    //       TProof::Reset("[email protected]",kTRUE);
    //    TProof::Open(AAF);
    TProof::Open(AAF, "workers=10");

    TList *list = new TList();
    list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "CDB"));

    gProof->EnablePackage(Form("[email protected]::%s",alirootver), list);

    cout << "Connected to " << AAF << endl;
  }

 
  // Load the analysis macro (old version); should be removed when the library will be decided
  Char_t loadtask[128];

  if(task==4) {
    sprintf(loadtask,"AliAnaTaskV0%s.cxx++", taskname);
  }else{
    sprintf(loadtask,"AliAnalysisTask%s.cxx++", taskname);
  }
  
  if(mode == 1){ // PROOF
    
    // switch(task){
    // case 1: // ch fluct
    //   break;
    // case 2: // high pt dedx
    //gProof->Load("DebugClasses.C++g");
    //   break;
    // case 3: // high pt v0s
    //   gProof->Load("DebugClasses.C++g");
    //   break;
    // default:
    //   printf("Unknown task\n");
    //   return;
    // }

    gProof->Load(loadtask);
  }else{

    if(task==2) {
      
      cout << "Analysis task is loaded with AliRoot" << endl;
    } else {

      gROOT->LoadMacro(loadtask);
    }
  }

  // Make the analysis manager
  AliAnalysisManager* mgr = new AliAnalysisManager("PID histos", "testing analysis");


  // Dataset 
  switch(mode){
  case 1: // PROOF
    TFileCollection* proofColl = gProof->GetDataSet(textFileName);
    TFileCollection* stagedColl = proofColl->GetStagedSubset();
    TChain* chain = CreateChainCAF(nFilesMax, stagedColl, treeName);
//    TChain* chain = CreateChainCAF(nFilesMax, textFileName, treeName, analysisMC);
    break;
  case 2: // GRID
    //gSystem->Setenv("alien_CLOSE_SE", "ALICE::GSI::SE2");
    //    gSystem->Setenv("alien_CLOSE_SE", "ALICE::NIHAM::FILE");
    TGrid::Connect("alien://");
    //gSystem->Setenv("alien_CLOSE_SE", "ALICE::GSI::SE2");
    //    gSystem->Setenv("alien_CLOSE_SE", "ALICE::NIHAM::FILE");
    
    Char_t gridmode[64];
    sprintf(gridmode, "full");
    if(strstr(type,"term") != NULL) 
      sprintf(gridmode, "terminate");
    if(strstr(type,"off") != NULL) 
      sprintf(gridmode, "offline");
    if(strstr(type,"sub") != NULL) 
      sprintf(gridmode, "submit");
    if(strstr(type,"test") != NULL) 
      sprintf(gridmode, "test");


    gROOT->LoadMacro("CreateAlienHandler.C");
    //    AliAnalysisGrid *alienHandler = CreateAlienHandler(nFilesMax, analysisMC, runtype, taskname, gridmode);  
    AliAnalysisGrid *alienHandler = CreateAlienHandler(nFilesMax, analysisMC, esdAna, taskname, nameouputfiles, gridmode, textFileName, alirootver, task);  
    if (!alienHandler) return; 

    // DOES NOT WORK BECAUSE THERE ARE NO GETTERS?
    // // Here we can add extra files to the plugin
    // switch(task){
    // case 1: // ch fluct
    //   break;
    // case 2: // high pt dedx
    //   alienHandler->SetAnalysisSource(Form("DebugClasses.C %s", alienHandler->GetAnalysisSource()));
    //   alienHandler->SetAdditionalLibs(Form("DebugClasses.C %s", alienHandler->GetAdditionalLibs()));
    //   break;
    // case 3: // high pt v0s
    //   alienHandler->SetAnalysisSource(Form("DebugClasses.C %s", alienHandler->GetAnalysisSource()));
    //   alienHandler->SetAdditionalLibs(Form("DebugClasses.C %s", alienHandler->GetAdditionalLibs()));
    //   break;
    // default:
    //   printf("Unknown task\n");
    //   return;
    // }

    // Connect plugin to the analysis manager
    mgr->SetGridHandler(alienHandler); 
    break;
  case 0: // LOCAL
    // Process data - chain
    AliXRDPROOFtoolkit tool;
    TChain* chain = tool.MakeChain(textFileName,treeName, 0, 100);
    chain->Lookup();
    break;
  default:
    printf("Unknown mode");
    return;
  }
  
  // ESD input handler
  if(esdAna) {

    AliESDInputHandler *esdHandler = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdHandler);
  } else {

    AliAODInputHandler* aodHandler = new AliAODInputHandler();
    mgr->SetInputEventHandler(aodHandler);
  }

  // Monte Carlo handler
  if (analysisMC) {
    AliMCEventHandler* mcHandler = new AliMCEventHandler();
    if(esdAna)
      mgr->SetMCtruthEventHandler(mcHandler);
    mcHandler->SetReadTR(readTR); 
  }

  // Debug if needed
  if (debug) 
    mgr->SetDebugLevel(3);


  // ######### Centrality task ###############  

  cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
  cout<<"esdAna="<<esdAna<<"  runtype="<<runtype<<endl;
    
  // ######### PHYSICS SELECTION ###############
  if (esdAna) { // PC: 17/8-15: this does not work for AODs..... 

    cout << "Adding task physics selection" << endl;
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
    if (analysisMC) {
      AliPhysicsSelection* physSel = physSelTask->GetPhysicsSelection();
      physSel->SetAnalyzeMC();
    }
  }

  if(esdAna && runtype==2) { // only for ESD and PbPb

    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); 
    //taskCentrality->SetPass(2);
    if (analysisMC)
      taskCentrality->SetMCInput(); 
  }

  // ######### PID task ###############

  if(task == 2) {
    cout << "Loading macro in AliRoot!" << endl;
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/SPECTRA/IdentifiedHighPt/train/macros/AddTask.C");      
    cout << "Adding task!" << endl;
    AliAnalysisTask* taskPid = AddTask(analysisMC, taskname, runtype, kTriggerInt, minCent, maxCent);
  } else {
    cout << "Adding AliAnaTaskV0EffDecomposition" << endl;
    gROOT->LoadMacro("AddTask.C");  
    AliAnalysisTask* taskPid = AddTask(taskname);
  }
  
  // Run the analysis  
  if (mgr->InitAnalysis()){
    mgr->PrintStatus();
    switch(mode){
    case 1: // PROOF
      mgr->StartAnalysis("proof",chain);
      break;
    case 2: // GRID
      mgr->StartAnalysis("grid");
      break;
    case 0:
      mgr->StartAnalysis("local",chain);
      break;
    default:
      printf("Unknown mode\n");
      return;
    }
  } 
}  
Example #12
0
void Embedding(const char* dataset="collection.xml")
{
    
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libPhysics");
  
  //load analysis framework
  gSystem->Load("libSTEERBase");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE
  
  gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_ROOT/PHOS");

  // A task can be compiled dynamically with AClic
  gROOT->LoadMacro("AliPHOSEmbedding.cxx+g");
  
  // Connect to alien
  TString token = gSystem->Getenv("GRID_TOKEN") ;
  if (1) // token == "OK" ) 
    TGrid::Connect("alien://");
  else 
    AliInfo("You are not connected to the GRID") ; 
  cout << "Pi0Analysis: processing collection " << dataset << endl;
  
  // Create the chain
  TChain* chain = new TChain("esdTree");

  TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
  
  TAlienResult* result = collection->GetGridResult("",0 ,0);
  TList* rawFileList = result->GetFileInfoList();
  for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
    TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
    const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
    printf("Processing %s\n", rawFile) ;
    chain->Add(rawFile);
    printf("Chain: %d entries.\n",chain->GetEntries()); 
  }
  TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(0));
  const char * fn = fi->GetCurrentUrl()->GetUrl() ;

  char runNum[7]; 
  for(Int_t i=0;i<6;i++)runNum[i]=fn[35+i] ;

  runNum[6]=0 ;
  Int_t iRunNum=atoi(runNum) ;
  printf("Run number=%d \n",iRunNum) ;

  //Run AOD simulation
  int nrun = atoi(runNum);
  int nevent = 0;
  int seed = 0;

  char sseed[1024];
  char sevent[1024];
  char sprocess[1024];
  char sfield[1024];
  char senergy[1024];

  sprintf(sevent,"");
  sprintf(sprocess,"");
  sprintf(sfield,"");
  sprintf(senergy,"");

  seed = 0;
  sprintf(sseed,"%d",seed);

  if (seed==0) {
    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
    fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  } else {
    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
    fprintf(stdout,"!!!  MC Seed is %d \n",seed);
    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  }
  
// set the seed environment variable
  gSystem->Setenv("CONFIG_SEED",sseed);
  gSystem->Setenv("CONFIG_RUN_TYPE","kPythia6"); // kPythia6 or kPhojet^M
  gSystem->Setenv("CONFIG_FIELD","k5kG");      // kNoField or k5kG^M
  gSystem->Setenv("CONFIG_ENERGY","2760");    // 900 or 10000 (GeV)
  gSystem->Setenv("DC_RUN",runNum);    //run number 
  

  char nSimEvents[55] ;
  sprintf(nSimEvents,"%d",chain->GetEntries());
  gSystem->Setenv("SIM_EVENTS",nSimEvents); 
  gSystem->Exec("mv geometry.root geometry_PHOS.root") ;
  gSystem->Exec("aliroot -b -q simrun.C > simrun.log 2>&1");
  gSystem->Exec("mv geometry_PHOS.root geometry.root") ;

  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("Pi0EmbeddingManager");
  
  // ESD input handler
  AliESDInputHandler* esdH = new AliESDInputHandler();
  esdH->SetReadFriends(kFALSE);
  mgr->SetInputEventHandler(esdH);

  // Output
  AliAODHandler* aodHandler   = new AliAODHandler();
  aodHandler->SetOutputFileName("AliAODout.root");
  mgr->SetOutputEventHandler(aodHandler);

  
  // Debug level
  mgr->SetDebugLevel(0);


  // Add physics selection
  gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE);

  gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
  AliCentralitySelectionTask *taskCentrality = AddTaskCentrality() ;

  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
  AliEPSelectionTask *taskEP = AddTaskEventplane() ;

  // Add my task
  AliPHOSEmbedding *task1 = new AliPHOSEmbedding("Embedding");

  TChain* chainAOD = new TChain("aodTree");
  chainAOD->AddFile("AliAOD.root") ;
  task1->SetSignalChain(chainAOD) ;
  task1->SelectCollisionCandidates();


  TFile *fOldCalib = TFile::Open("OldCalibration.root");
  if(fOldCalib->IsOpen()){
    printf("\n\n...Adding PHOS calibration used in ESD production \n") ;
    char key[55] ;
    TH2F * hCalib[5] ;
    for(Int_t mod=0;mod<5; mod++){
      sprintf(key,"calibrationMod%d",mod) ;
      hCalib[mod] = (TH2F*)fOldCalib->Get(key) ;
    }
    task1->SetOldCalibration(hCalib) ;
    fOldCalib->Close() ;
  }

  mgr->AddTask(task1);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput   = mgr->GetCommonInputContainer(); 
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("output0",
                      TTree::Class(), AliAnalysisManager::kOutputContainer);


  // Connect input/output
  mgr->ConnectInput(task1 , 0, cinput);
  mgr->ConnectOutput(task1, 0,coutput1);

  AliLog::SetClassDebugLevel("AliGeomManager", 10) ;

  AliCDBManager::Instance()->SetRun(iRunNum) ;
//  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB") ;
//  AliCDBManager::Instance()->SetDefaultStorage("raw://") ;
  AliCDBManager::Instance()->SetDefaultStorage("alien://folder=/alice/data/2010/OCDB") ;
  AliCDBManager::Instance()->SetSpecificStorage("PHOS/*/*",
                                                "local://OCDB");
printf("RunNunm===%d \n",iRunNum) ;
  

  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
  }
  
  if(iRunNum<=137848){ //period 1
    gSystem->Exec("mv BadMap_LHC10h_period1.root BadMap_LHC10h.root") ;
  }
  else{
    gSystem->Exec("mv BadMap_LHC10h_period234.root BadMap_LHC10h.root") ;
  }
  gSystem->Exec("aliroot -b -q AnalyzeDiff.C> analyze3.log 2>&1");

}
Example #13
0
void runTask(Float_t etamax=0.5,const char * incollection = 0, const char * outfile = "dndeta.root", Bool_t skipNorm = kFALSE)
{
  // for running with root only
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libSTEERBase");
  gSystem->Load("libESD");
  gSystem->Load("libAOD");

  // load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");


  TChain * chain = new TChain ("TE");
  if (incollection == 0) {
    chain->Add("galice.root");
  }
  else if (TString(incollection).Contains("xml")){
    TGrid::Connect("alien://");
    TAlienCollection * coll = TAlienCollection::Open (incollection);
    while(coll->Next()){
      chain->Add(TString("alien://")+coll->GetLFN());
    }
  } else {
    ifstream file_collect(incollection);
    TString line;
    while (line.ReadLine(file_collect) ) {
      chain->Add(line.Data());
    }
  }
  chain->GetListOfFiles()->Print();

  // 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");

  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("dNdeta");

  AliVEventHandler* esdH = new AliESDInputHandler;
  ((AliESDInputHandler*)esdH)->SetReadFriends(kFALSE);
  mgr->SetInputEventHandler(esdH);

  // Create tasks
  gROOT->LoadMacro("AliAnalysisTaskdNdetaMC.cxx++g");

  AliAnalysisTask *task1 = new AliAnalysisTaskdNdetaMC("TaskdNdeta");
  ((AliAnalysisTaskdNdetaMC*)task1)->SetEtaMax(etamax);
  if (skipNorm) ((AliAnalysisTaskdNdetaMC*)task1)->SkipNormalization();
  // Enable MC event handler

  AliMCEventHandler* handler = new AliMCEventHandler;
  handler->SetReadTR(kFALSE);
  mgr->SetMCtruthEventHandler(handler);

  // Add tasks
  mgr->AddTask(task1);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("coutput", TList::Class(),    AliAnalysisManager::kOutputContainer, outfile);

  // Connect input/output
  mgr->ConnectInput(task1, 0, cinput);
  mgr->ConnectOutput(task1, 1, coutput1);

  // Enable debug printouts
  mgr->SetDebugLevel(0);

  if (!mgr->InitAnalysis()) return;

  mgr->PrintStatus();

  mgr->StartAnalysis("local", chain);
}
Example #14
0
//     const char*   cDataType      = "AOD",       // set the analysis type, AOD or ESD
//##################################################
AliAnalysisManager* EmcalJetCDF (
    const char*   cRunPeriod     = "LHC11d",    // set the run period
    const char*   cLocalFiles    = "data.txt",  // set the local list file
    const Int_t   arg_sel_chg    = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   arg_sel_full   = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   mgr_mode       = 0,         // local = 0, proof = 1, grid = 2, mixing = 3
    const Int_t   alien_mode     = 0,         // test = 0, offline = 1, submit = 2, merge = 3, full = 4
    const char*   cTaskName      = "CDFJets",   // sets name of task manager
    unsigned int  iNumFiles      = 100,         // numger of files to process from list file
    unsigned int  iNumEvents     = 999999999,   // number of events to be analyzed
    bool          bDoChargedJets = true,        // enable charge jets
    bool          bDoFullJets    = false        // enable full jets
) {
//Load needed libs
TString     ListLibs      = ""; // string list of loaded libs
TString     ListLibsExtra = ""; // string list of loaded extra libs
LoadLibs( ListLibs, ListLibsExtra );

AnalysisType  ManagerMode = static_cast<AnalysisType>(mgr_mode);
PluginType    PluginMode  = static_cast<PluginType>(alien_mode);

namespace CDF = PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetCDF_NS; // shortcut to task namespace
unsigned int       kGridFilesPerJob         = iNumFiles;      // Maximum number of files per job (gives size of AOD)
unsigned int       kTTL                     = 64800 ;         // Time To Live; 18h = 64800; 12h = 43200

bool bDoBackgroundSubtraction = true;
bool bDoEmbedding = false;

// Embeded Configuration options
// Embedding files list
const TString embeddedFilesList = "aodFilesEmbed.txt";
// If true, events that are not selected in the PbPb will not be used for embedding.
// This ensures that good embedded events are not wasted on bad PbPb events.
const bool internalEventSelection = true;
// Do jet matching
const bool useJetTagger = true;


TString sGridMode ("test");
if ( PluginMode == PluginType::offline ) { sGridMode = "offline"; }
if ( PluginMode == PluginType::submit )  { sGridMode = "submit"; }
if ( PluginMode == PluginType::merge )   { sGridMode = "merge"; }
if ( PluginMode == PluginType::full )    { sGridMode = "full"; }
const char* cGridMode = sGridMode.Data();

TString sAnalysisType ("local");
if ( ManagerMode == AnalysisType::proof )  { sAnalysisType = "proof"; }
if ( ManagerMode == AnalysisType::grid )   { sAnalysisType = "grid"; }
if ( ManagerMode == AnalysisType::mixing ) { sAnalysisType = "mix"; }
const char* cAnalysisType = sAnalysisType.Data();

cout << std::endl << ">>>>>>>> ManagerMode : " << ManagerMode << " ; String value : " << cAnalysisType << std::endl << ">>>>>>>> PluginMode : " << PluginMode << " ; String value : " << cGridMode << std::endl << std::endl;

//---------------------------------------------------------------------------------------------
TRegexp false_regex ("[f,F][a,A][l,L][s,S][e,E]");
TRegexp true_regex ("[t,T][r,R][u,U][e,E]");
TRegexp enable_regex ("[e,E][n,N][a,A][b,B][l,L][e,E]");
TRegexp disable_regex ("[d,D][i,I][s,S][a,A][b,B][l,L][e,E]");

bool  bDoSample = false;
TString ENV_doSAMPLE = gSystem->Getenv("CDF_doSAMPLE");
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("0") || ENV_doSAMPLE.Contains(false_regex) ) ) { bDoSample = kFALSE; }
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("1") || ENV_doSAMPLE.Contains(true_regex)  ) ) { bDoSample = kTRUE; }

bool  bDoCDF    = true;
TString ENV_doCDF = gSystem->Getenv("CDF_doCDF");
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("0") || ENV_doCDF.Contains(false_regex) ) ) { bDoCDF = kFALSE; }
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("1") || ENV_doCDF.Contains(true_regex)  ) ) { bDoCDF = kTRUE; }

// ######   DEBUG    ######
Int_t           debug              =  0 ; // kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType
UInt_t          mgr_debug          =  0 ; // AliAnalysisManager debug level
UInt_t          kUseSysInfo        =  0 ; // activate debugging

TString ENV_DEBUG = gSystem->Getenv("CDF_DEBUG");
if (!ENV_DEBUG.IsNull() && ENV_DEBUG.IsDigit() ) { debug = ENV_DEBUG.Atoi(); }

TString ENV_DEBUG_MGR = gSystem->Getenv("CDF_DEBUG_MGR");
if (!ENV_DEBUG_MGR.IsNull() && ENV_DEBUG_MGR.IsDigit() ) { mgr_debug = ENV_DEBUG_MGR.Atoi(); }

TString ENV_NSYSINFO = gSystem->Getenv("CDF_NSYSINFO");
if (!ENV_NSYSINFO.IsNull() && ENV_NSYSINFO.IsDigit() ) { kUseSysInfo = ENV_NSYSINFO.Atoi(); }

if ( debug == 0 ) { AliLog::SetGlobalLogLevel ( AliLog::kFatal   ); }
if ( debug == 1 ) { AliLog::SetGlobalLogLevel ( AliLog::kError   ); }
if ( debug == 2 ) { AliLog::SetGlobalLogLevel ( AliLog::kWarning ); }
if ( debug == 3 ) { AliLog::SetGlobalLogLevel ( AliLog::kInfo    ); }
if ( debug >= 4 ) { AliLog::SetGlobalLogLevel ( AliLog::kDebug   ); }

// Progress bar
Bool_t bUseProgBar = kFALSE; // N.B. !! if true will set fDebug to 0
TString ENV_USEPROGBAR = gSystem->Getenv("PROGRESSBAR");
if (!ENV_USEPROGBAR.IsNull() && ( ENV_USEPROGBAR.EqualTo("1") || ENV_USEPROGBAR.Contains(true_regex) ) )  { bUseProgBar = kTRUE; }

//##################################################
//        AliEN plugin variables
//##################################################
const char* curdir = gSystem->BaseName(gSystem->pwd());
TString     kJobTag (curdir);

TString execArgs (" -l -b -q -x");
TString exec =
//               "aliroot";
              "root.exe";

TString     kPluginExecutableCommand = exec + execArgs;

TString     kAliPhysicsVersion       = "vAN-20190304-1";

// == grid plugin files rules
TString     kGridExtraFiles          = ""; // extra files that will be added to the input list in the JDL
TString     kGridMergeExclude        = "AliAOD.root AliAOD.Jets.root"; // Files that should not be merged
TString     kGridOutputStorages      = "disk=2"; // Make replicas on the storages

// FILES USED IN MACRO
TString     kCommonOutputFileName    = "AnalysisResults.root";

//--------------------
//   PROOF SETTINGS
//--------------------
TString kAAF        = "";
Int_t   kProofReset = 0; (void)kProofReset;
Int_t   kWorkers    = 20; (void)kWorkers;
Int_t   kCores      = 8  ; (void)kCores;
// AliRoot mode among the list supported by the proof cluster.
// TString     kAlirootMode             = "ALIROOT";     // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode)

//############################################################
// const AliAnalysisTaskEmcal::EDataType_t kAod = AliAnalysisTaskEmcal::kAOD;
// const AliAnalysisTaskEmcal::EDataType_t kEsd = AliAnalysisTaskEmcal::kESD;

const AliJetContainer::EJetType_t    fulljet = AliJetContainer::kFullJet;
const AliJetContainer::EJetType_t     chgjet = AliJetContainer::kChargedJet;
const AliJetContainer::EJetAlgo_t     antikt = AliJetContainer::antikt_algorithm;
const AliJetContainer::EJetAlgo_t         kt = AliJetContainer::kt_algorithm;
const AliJetContainer::ERecoScheme_t  recomb = AliJetContainer::pt_scheme;

// kTPC, kTPCfid, kEMCAL, kEMCALfid, kDCAL, kDCALfid, kDCALonly, kDCALonlyfid, kPHOS, kPHOSfid, kUser
const AliEmcalJet::JetAcceptanceType acc_chgjets  = AliEmcalJet::kTPCfid;
const AliEmcalJet::JetAcceptanceType acc_fulljets = AliEmcalJet::kEMCALfid;
//############################################################

// data source name
TString kDataSource (cLocalFiles);

// label of dataset from InputData.C
TString kGridDataSet ("");
if ( ManagerMode == AnalysisType::grid ) { kGridDataSet = kDataSource;}

//############################################################
// SETUP OF TRIGGERS
const AliEmcalPhysicsSelection::EOfflineEmcalTypes mykEMCAL  = AliEmcalPhysicsSelection::kEmcalOk;
const AliVEvent::EOfflineTriggerTypes  mykEMC             = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA);
const AliVEvent::EOfflineTriggerTypes  mykEMC_noGA        = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE);

const AliVEvent::EOfflineTriggerTypes  mykMB              = AliVEvent::kAnyINT;
const AliVEvent::EOfflineTriggerTypes  mykMB_central      = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_semicentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kSemiCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_mostcentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral | AliVEvent::kSemiCentral);

AliVEvent::EOfflineTriggerTypes kPhysSel   = mykMB; //AliVEvent::kAnyINT; // physics selection
// AliVEvent::EOfflineTriggerTypes kSel_tasks = mykMB;

AliVEvent::EOfflineTriggerTypes kSel_chg   = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_chg);
AliVEvent::EOfflineTriggerTypes kSel_full  = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_full);

//############################################################
// Analysis manager
  AliAnalysisManager* pMgr = new AliAnalysisManager(cTaskName);
  pMgr->SetDebugLevel(mgr_debug);
  if ( kUseSysInfo > 0 ) { pMgr->SetNSysInfo ( kUseSysInfo ); }

  // actual runName in the form of LHCXXX....
  TString sRunName;
  Bool_t kIsAOD = kTRUE;
  AliAnalysisTaskEmcal::EDataType_t iDataType = AliAnalysisTaskEmcal::kAOD; // assuming default is to process AOD
  TString file;
  AliAnalysisAlien* plugin = NULL;
  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL, const char* outdir, const char subworkdir, const char* extradirlvl);
    plugin = CreateAlienHandler(cGridMode, kJobTag.Data(), kGridFilesPerJob, kTTL);
    if ( !plugin ) { ::Error ( "runEMCalJetSampleTask.C - StartGridAnalysis", "plugin invalid" ); return NULL; }
    pMgr->SetGridHandler(plugin);

    // use this command to run the macro
    plugin->SetExecutableCommand(kPluginExecutableCommand.Data());

    // AliPhysics version.
    plugin->SetAliPhysicsVersion ( kAliPhysicsVersion.Data() ); // Here you can set the (Ali)PHYSICS version you want to use

    gROOT->LoadMacro("InputData.C");
    InputData(kGridDataSet);
    sRunName = CDF::GetPeriod( plugin->GetGridDataDir() );

    file = CDF::GetFileFromPath(plugin->GetDataPattern());
    if (file.Contains("AliESD")) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }

    plugin->SetMergeExcludes(kGridMergeExclude.Data());
    }

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    if ( kDataSource.IsNull() ) { Printf("You need to provide the list of local files!"); return NULL; }
    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }
    Printf("Setting local analysis for %d files from list %s, max events = %d", iNumFiles, kDataSource.Data(), iNumEvents);

    // get the path of first file
    file = pChain->GetFile()->GetEndpointUrl()->GetUrl();
    sRunName = CDF::GetPeriod(file.Data()); // get the run name : first token beggining with lhc
    if ( CDF::GetFileFromPath(file).Contains("AliESD") ) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }
    }

  TString sDataType ("AOD");
  if (!kIsAOD) { sDataType = "ESD"; }
  std::cout << ">>> Analysis data type : " << sDataType.Data() << std::endl;

  // name of de period (for MC is the name of "achored to" production)
  TString sRunPeriod (cRunPeriod);
  sRunPeriod.ToLower();

  bool isMC = false;
  isMC = CDF::PeriodIsMC(sRunName.Data());

  // EMCAL corrections task configuration file
  TString EMCALcfg ("CDF_CorrectionsConf.yaml");
  if (isMC) {EMCALcfg = "CDF_MC_CorrectionsConf.yaml";}

  if ( !kGridExtraFiles.IsNull() ) {kGridExtraFiles += " ";}
  kGridExtraFiles += EMCALcfg;

  AliAnalysisTaskEmcal::BeamType iBeamType = AliAnalysisTaskEmcal::kpp;
  Bool_t bIsRun2 = kFALSE;

  if (sRunPeriod.Length() == 6 && (sRunPeriod.BeginsWith("lhc15") || sRunPeriod.BeginsWith("lhc16") || sRunPeriod.BeginsWith("lhc17") || sRunPeriod.BeginsWith("lhc18") ) ) { bIsRun2 = kTRUE; }

  if (sRunPeriod == "lhc10h" || sRunPeriod == "lhc11h" || sRunPeriod == "lhc15o" || sRunPeriod == "lhc17n" )                            { iBeamType = AliAnalysisTaskEmcal::kAA; }
  if (sRunPeriod == "lhc12g" || sRunPeriod == "lhc13b" || sRunPeriod == "lhc13c" || sRunPeriod == "lhc13d" || sRunPeriod == "lhc13e" ||
      sRunPeriod == "lhc13f" || sRunPeriod == "lhc16q" || sRunPeriod == "lhc16r" || sRunPeriod == "lhc16s" || sRunPeriod == "lhc16t" )  { iBeamType = AliAnalysisTaskEmcal::kpA; }

  Double_t kGhostArea = 0.01;
  if (iBeamType != AliAnalysisTaskEmcal::kpp) { kGhostArea = 0.005; }

  AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod);
  Printf("Default track cut period set to: %s", AliTrackContainer::GetDefTrackCutsPeriod().Data());

  Bool_t bDoEmcalCorrections  = kFALSE;
  if (bDoFullJets) { bDoEmcalCorrections  = kTRUE; }

// ###   Containers and string definitions
  TString name_tracks   = "usedefault";
  TString name_clusters = "usedefault";
  TString name_cells    = "usedefault";
  // Set centrality estimator for centrality task
  TString cent_est_chg  = "V0M" ;
  TString cent_est_full = "V0M" ;

  TString mc_container ("");
  if (isMC) { mc_container = "mcparticles"; }

/*
  // General input object names
  TString tracksName             = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kTrack);
  TString clustersName           = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCluster);
  TString emcalCellsName         = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCaloCells);
  // Combined (PbPb + embedded det level)
  TString emcalCellsCombined = emcalCellsName + "Combined";
  TString clustersCombined = clustersName + "Combined";
*/

//##########################
//   TASKS DEFINITIONS   ###
//##########################
  AliAODInputHandler* pAODHandler = NULL;
  AliESDInputHandler* pESDHandler = NULL;
  if (kIsAOD)
    { pAODHandler = AliAnalysisTaskEmcal::AddAODHandler(); }
  else
    { pESDHandler = AliAnalysisTaskEmcal::AddESDHandler(); }

  // CDBconnect task
  AliTaskCDBconnect* taskCDB = AliTaskCDBconnect::AddTaskCDBconnect();
  taskCDB->SetFallBackToRaw(kTRUE); // Needed for the moment as not all grid sites do support cvmfs OCDB for the moment
  if (!taskCDB) { std::cout << "--------->>>>  taskCDB :: could not connect!!!! CHECK CVMFS" << std::endl; return NULL;}

  // Physics selection task
  AliPhysicsSelectionTask* pPhysSelTask = NULL;
  if (!kIsAOD) {
    // signature : (Bool_t mCAnalysisFlag = kFALSE, Bool_t applyPileupCuts = kFALSE, UInt_t deprecatedFlag2 = 0, Bool_t useSpecialOutput=kFALSE)
    pPhysSelTask = AliPhysicsSelectionTask::AddTaskPhysicsSelection();
    }

  // Centrality task
  // The Run 2 condition is too restrictive, but until the switch to MultSelection is complete, it is the best we can do
  AliCentralitySelectionTask* pCentralityTask = NULL;
  if ( !kIsAOD && (iBeamType != AliAnalysisTaskEmcal::kpp && bIsRun2) ) {
    //signature : (Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE)
    pCentralityTask = AliCentralitySelectionTask::AddTaskCentrality(kFALSE, kIsAOD);
    pCentralityTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // AliMultSelection
  AliMultSelectionTask* pMultSelTask = NULL;
  if (bIsRun2) {
    // signature : ( Bool_t lCalibration = kFALSE, TString lExtraOptions = "", Int_t lNDebugEstimators = 1, const TString lMasterJobSessionFlag = "")
    pMultSelTask = AliMultSelectionTask::AddTaskMultSelection();
    pMultSelTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // Embedding task
  if (bDoEmbedding) {
    // Debug options
    //AliLog::SetClassDebugLevel("AliAnalysisTaskEmcalEmbeddingHelper", AliLog::kDebug+0);

    // Setup embedding task
    AliAnalysisTaskEmcalEmbeddingHelper * embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::AddTaskEmcalEmbeddingHelper();
    embeddingHelper->SelectCollisionCandidates(kPhysSel);
    // The pt hard bin should be set via the filenames in this file
    // If using a file pattern, it could be configured via embeddingHelper->SetPtHardBin(ptHardBin);
    embeddingHelper->SetFileListFilename(embeddedFilesList.Data());

    // Some example settings for LHC12a15e_fix (anchored to LHC11h)
    embeddingHelper->SetNPtHardBins(11);
    embeddingHelper->SetMCRejectOutliers();

    // Setup internal event selection and additional configuration options
    embeddingHelper->SetConfigurationPath("EmbeddingConfigurationExample.yaml");

    // Initialize the task to complete the setup.
    embeddingHelper->Initialize();
    }

  // EMCal corrections
  AliEmcalCorrectionTask* correctionTask = NULL;
  if (bDoEmcalCorrections) {
    // Configuration of the Correction Task is handled via a YAML file, which is setup below
    // signature : (TString suffix)
    correctionTask = AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask();
//  correctionTask = AliEmcalCorrectionTask::ConfigureEmcalCorrectionTaskOnLEGOTrain(suffix);
    correctionTask->SelectCollisionCandidates(kPhysSel);
    correctionTask->SetUseNewCentralityEstimation(bIsRun2);
    correctionTask->SetForceBeamType(static_cast<AliEmcalCorrectionTask::BeamType>(iBeamType));

    // Configure and initialize
    correctionTask->SetUserConfigurationFilename( EMCALcfg.Data() );
    //correctionTask->SetUserConfigurationFilename("alien:///alice/cern.ch/user/m/mfasel/EMCALCorrectionConfig/ConfigDataPWGJEhighClusterThresholds.yaml");
    correctionTask->Initialize(true);

    }

//     TObjArray correctionTasks;
//
//     // Create the Correction Tasks
//     // "data" corresponds to the PbPb level
//     // "embed" corresponds to the embedded detector level
//     // "combined" corresponds to the hybrid (PbPb + embedded detector) level
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("data"));
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("embed"));
//     // It is important that combined is last!
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("combined"));
//
//     // Loop over all of the correction tasks to configure them
//     AliEmcalCorrectionTask * tempCorrectionTask = 0;
//     TIter next(&correctionTasks);
//     while (( tempCorrectionTask = static_cast<AliEmcalCorrectionTask *>(next()))) {
//       tempCorrectionTask->SelectCollisionCandidates(kPhysSel);
//       // Configure centrality
//       tempCorrectionTask->SetNCentBins(5);
//       tempCorrectionTask->SetUseNewCentralityEstimation(bIsRun2);
//       tempCorrectionTask->SetUserConfigurationFilename("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/EMCalCorrectionTaskEmbeddingExample.yaml");
//
//       tempCorrectionTask->Initialize(true);
//       }

  // Background
  TString sRhoChName;
  TString sRhoFuName;
  AliAnalysisTaskRho* pRhoTask = NULL;
  if ( bDoBackgroundSubtraction && iBeamType != AliAnalysisTaskEmcal::kpp ) {
    sRhoChName = "Rho";
    sRhoFuName = "Rho_Scaled";

    AliEmcalJetTask* pKtChJetTask = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", kt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 0., kFALSE, kFALSE);
    pKtChJetTask->SelectCollisionCandidates(kPhysSel);

    //signature :
    // const char* nTracks = "usedefault", const char* nClusters = "usedefault", const char* nRho = "Rho", Double_t jetradius = 0.2, UInt_t acceptance = AliEmcalJet::kTPCfid,
    // AliJetContainer::EJetType_t jetType = AliJetContainer::kChargedJet, const Bool_t histo = kFALSE, AliJetContainer::ERecoScheme_t rscheme = AliJetContainer::pt_scheme, const char* suffix = ""
    pRhoTask = AliAnalysisTaskRho::AddTaskRhoNew(name_tracks.Data(), name_clusters.Data(), sRhoChName, 0.4);
    pRhoTask->SetExcludeLeadJets(2);
    pRhoTask->SelectCollisionCandidates(kPhysSel);
    pRhoTask->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);

    if (bDoFullJets) {
      TString sFuncPath = "alien:///alice/cern.ch/user/s/saiola/LHC11h_ScaleFactorFunctions.root";
      TString sFuncName = "LHC11h_HadCorr20_ClustersV2";
      pRhoTask->LoadRhoFunction(sFuncPath, sFuncName);
      }
    }

  // Find Charged jets
  AliEmcalJetTask* pChJet02Task = NULL;
  AliEmcalJetTask* pChJet04Task = NULL;
  AliEmcalJetTask* pChJet02Task_MC = NULL;
  AliEmcalJetTask* pChJet04Task_MC = NULL;
  if (bDoChargedJets) {
    pChJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet02Task->SelectCollisionCandidates(kSel_chg);

    pChJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet04Task->SelectCollisionCandidates(kSel_chg);

    if (isMC) {
      pChJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pChJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pChJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pChJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoChargedJets

  // Find Full jets
  AliEmcalJetTask* pFuJet02Task = NULL;
  AliEmcalJetTask* pFuJet04Task = NULL;
  AliEmcalJetTask* pFuJet02Task_MC = NULL;
  AliEmcalJetTask* pFuJet04Task_MC = NULL;
  if (bDoFullJets) {
    pFuJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet02Task->SelectCollisionCandidates(kSel_full);
    pFuJet02Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    pFuJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet04Task->SelectCollisionCandidates(kSel_full);
    pFuJet04Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (isMC) {
      pFuJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pFuJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pFuJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pFuJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
      if (bDoEmbedding) {
        pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pFuJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoFullJets

////////////////////////
//   ANALYSIS TASKS   //
////////////////////////

  // Sample task - charge jets
  AliAnalysisTaskEmcalJetSample* sampleTaskchg = NULL;
  if (bDoSample && bDoChargedJets) {
    sampleTaskchg = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), "", "", "SMPCHG");
    sampleTaskchg->SetHistoBins(600, 0, 300);
    sampleTaskchg->SelectCollisionCandidates(kSel_chg);
    sampleTaskchg->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskchg_partCont = sampleTaskchg->GetParticleContainer(0);
    sampleTaskchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { sampleTaskchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      sampleTaskchg->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskchg->SetNCentBins(5);
      }
    }

  // Sample task - full jets
  AliAnalysisTaskEmcalJetSample* sampleTaskfull = NULL;
  if (bDoSample && bDoFullJets) {
    sampleTaskfull = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), name_clusters.Data(), name_cells.Data(), "SMPFULL");
    sampleTaskfull->SetHistoBins(600, 0, 300);
    sampleTaskfull->SelectCollisionCandidates(kSel_full);
    sampleTaskfull->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskfull_partCont = sampleTaskfull->GetParticleContainer(0);
    sampleTaskfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* sampleTaskfull_clusCont = sampleTaskfull->GetClusterContainer(0);
    sampleTaskfull_clusCont->SetClusECut(0.);
    sampleTaskfull_clusCont->SetClusPtCut(0.);
    sampleTaskfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    sampleTaskfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    sampleTaskfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      sampleTaskfull_partCont->SetIsEmbedding(kTRUE);
      sampleTaskfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      sampleTaskfull->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskfull->SetNCentBins(5);
      }
    }


  //###   CDF task - charged jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg = NULL;
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg_MC = NULL;
  if (bDoCDF && bDoChargedJets) {
    anaTaskCDFchg = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), "", "", "", "CDFchg" );
    anaTaskCDFchg->SetHistoBins(600, 0, 300);
    anaTaskCDFchg->SelectCollisionCandidates(kSel_chg);
    anaTaskCDFchg->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFchg_partCont = anaTaskCDFchg->GetParticleContainer(0);
    anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { anaTaskCDFchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      anaTaskCDFchg->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFchg->SetNCentBins(5);
      anaTaskCDFchg->SetCentralityEstimator(cent_est_chg.Data());
      }

    //#################################################
    if (isMC){
      anaTaskCDFchg_MC = CDF::AddTaskEmcalJetCDF ( mc_container.Data(), "", "", "", "CDFchgMC" );
      anaTaskCDFchg_MC->SetHistoBins(600, 0, 300);
      anaTaskCDFchg_MC->SelectCollisionCandidates(kSel_chg);
      anaTaskCDFchg_MC->SetDebugLevel(debug);

      AliParticleContainer* anaTaskCDFchg_partCont_MC = anaTaskCDFchg_MC->GetMCParticleContainer(0);
      anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

      if (bDoEmbedding) { anaTaskCDFchg_partCont_MC->SetIsEmbedding(kTRUE); }

      if ( pMultSelTask ) {
        anaTaskCDFchg_MC->SetUseNewCentralityEstimation(bIsRun2);
        anaTaskCDFchg_MC->SetNCentBins(5);
        anaTaskCDFchg_MC->SetCentralityEstimator(cent_est_chg.Data());
        }
      }
    }

  //###   CDF task - full jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFfull = NULL;
  if (bDoCDF && bDoFullJets) {
    anaTaskCDFfull = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), name_clusters.Data(), name_cells.Data(), mc_container.Data(), "CDFfull" );
    anaTaskCDFfull->SetHistoBins(600, 0, 300);
    anaTaskCDFfull->SelectCollisionCandidates(kSel_full);
    anaTaskCDFfull->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFfull_partCont = anaTaskCDFfull->GetParticleContainer(0);
    anaTaskCDFfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* anaTaskCDFfull_clusCont = anaTaskCDFfull->GetClusterContainer(0);
    anaTaskCDFfull_clusCont->SetClusECut(0.);
    anaTaskCDFfull_clusCont->SetClusPtCut(0.);
    anaTaskCDFfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    anaTaskCDFfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    anaTaskCDFfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      anaTaskCDFfull_partCont->SetIsEmbedding(kTRUE);
      anaTaskCDFfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      anaTaskCDFfull->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFfull->SetNCentBins(5);
      anaTaskCDFfull->SetCentralityEstimator(cent_est_full.Data());
      }
    }

//########################
//   ANALYSIS TASKS - CONTAINERS SETUP
//########################

//   AliEmcalJetTask* pChJet02Task_MC = NULL;
//   AliEmcalJetTask* pChJet04Task_MC = NULL;

// add jet containers to CDF task for charged jets
  if (bDoChargedJets && bDoCDF) {
    AliJetContainer* jetcont_chg = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // CHG JETS 0.2
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      // CHG JETS 0.4
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

    if (isMC) {
      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
      }

    jetcont_chg = NULL;
    }

  // add jet containers to CDF task for full jets
  if (bDoFullJets && bDoCDF) {
    AliJetContainer* jetcont_full = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // FULL JETS 0.2
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      // FULL JETS 0.4
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    if (isMC) {
      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);

      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);
      }
    jetcont_full = NULL;
    }

  // add jet containers to sample task for charged jets
  if (bDoChargedJets && bDoSample) {
    AliJetContainer* jetCont02chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    AliJetContainer* jetCont04chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02chg_sample->SetRhoName(sRhoChName);
      jetCont02chg_sample->SetPercAreaCut(0.6);

      jetCont04chg_sample->SetRhoName(sRhoChName);
      jetCont04chg_sample->SetPercAreaCut(0.6);
      }
    }

  // add jet containers to sample task for full jets
  if (bDoFullJets && bDoSample) {
    AliJetContainer* jetCont02full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    AliJetContainer* jetCont04full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02full_sample->SetRhoName(sRhoFuName);
      jetCont02full_sample->SetPercAreaCut(0.6);

      jetCont04full_sample->SetRhoName(sRhoFuName);
      jetCont04full_sample->SetPercAreaCut(0.6);
      }
    }


  TObjArray* tasks_list = pMgr->GetTasks(); TIter task_iter (tasks_list); AliAnalysisTaskSE* task = NULL;
  while (( task = dynamic_cast<AliAnalysisTaskSE*>(task_iter.Next()) )) {
    if (task->InheritsFrom("AliAnalysisTaskEmcal")) {
      Printf("Setting beam type %d for task %s", iBeamType, static_cast<AliAnalysisTaskEmcal*>(task)->GetName());
      static_cast<AliAnalysisTaskEmcal*>(task)->SetForceBeamType(iBeamType);
      }
    }

  //   Let's start #########################################################################################################
  if ( !pMgr->InitAnalysis() ) { std::cout << ">>>>>>>>>>>>>> AliAnalysisManager Initialising FAILED!!! " << std::endl; return NULL; }
  std::cout << "##-->> Initialising Analysis :: Status :" << std::endl;
  pMgr->PrintStatus();
  pMgr->SetUseProgressBar(bUseProgBar, 100);

  // task profiling
  if ( kUseSysInfo > 0 ) {
    for ( int i = 0; i < pMgr->GetTopTasks()->GetEntries(); i++ ) { pMgr->ProfileTask (i); }
    }

  CDF::SaveManager("train.root");

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    // enable class level debugging for these classes
    if ( debug > 2 ) {
    //   pMgr->AddClassDebug("AliJetContainer", 100);
    //   pMgr->AddClassDebug("AliEmcalJetTask", 100);
      if (bDoCDF)    { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetCDF", 100); }
      if (bDoSample) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetSample", 100); }
      }

    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }

    // start analysis
    Printf("Starting LOCAL Analysis...");
    pMgr->StartAnalysis( cAnalysisType, pChain, iNumEvents );
    }

  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // start analysis
    Printf("Starting GRID Analysis...");

    ListLibs += kGridExtraFiles;
    if ( ListLibs.Length() )       { plugin->SetAdditionalLibs     ( ListLibs.Data() ); }
    if ( ListLibsExtra.Length() )  { plugin->SetAdditionalRootLibs ( ListLibsExtra.Data() ); }

    if ( PluginMode == PluginType::test )
      { plugin->StartAnalysis(iNumEvents); }
    else {
      pMgr->SetDebugLevel(0);
      plugin->StartAnalysis();
      }
    }

cout << "END of EmcalJetCDF.C" << std::endl;
return pMgr;
}
Example #15
0
//______________________________________________________________________________
void AODtrain(Int_t merge=0)
{
  // Main analysis train macro.
  ProcessEnvironment();

  UpdateFlags();

  PrintSettings();

  if (merge || doCDBconnect) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("AODtrain", "No grid connection");
      return;
    }
  }
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
   printf("==================================================================\n");
   printf("===========    RUNNING FILTERING TRAIN   ==========\n");
   printf("===========    Collision System is %s    ==========\n",CollisionSystem[iCollision]);
   printf("==================================================================\n");
   printf("=  Configuring analysis train for:                               =\n");
   if (usePhysicsSelection)   printf("=  Physics selection                                                =\n");
   if (useTender)    printf("=  TENDER                                                        =\n");
   if (iESDfilter)   printf("=  ESD filter                                                    =\n");
   if (iMUONcopyAOD) printf("=  MUON copy AOD                                                 =\n");
   if (iJETAN)       printf("=  Jet analysis                                                  =\n");
   if (iJETANdelta)  printf("=     Jet delta AODs                                             =\n");
   if (iPWGHFvertexing) printf("=  PWGHF vertexing                                                =\n");
   if (iPWGDQJPSIfilter) printf("=  PWGDQ j/psi filter                                             =\n");
   if (iPWGHFd2h) printf("=  PWGHF D0->2 hadrons QA                                     =\n");

   // Make the analysis manager and connect event handlers
   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Production train");
    mgr->SetCacheSize(0);
   if (useSysInfo) {
      //mgr->SetNSysInfo(100);
      AliSysInfo::SetVerbose(kTRUE);
   }   
   // Create input handler (input container created automatically)
   // ESD input handler
   AliESDInputHandler *esdHandler = new AliESDInputHandler();
   mgr->SetInputEventHandler(esdHandler);       
   // Monte Carlo handler
   if (useMC) {
      AliMCEventHandler* mcHandler = new AliMCEventHandler();
      mgr->SetMCtruthEventHandler(mcHandler);
      mcHandler->SetReadTR(useTR); 
   }   
   // AOD output container, created automatically when setting an AOD handler
   if (iAODhandler) {
      // AOD output handler
      AliAODHandler* aodHandler   = new AliAODHandler();
      aodHandler->SetOutputFileName("AliAOD.root");
      mgr->SetOutputEventHandler(aodHandler);
   }
   // Debugging if needed
   if (useDBG) mgr->SetDebugLevel(3);

   AddAnalysisTasks(cdbPath);
   if (merge) {
      AODmerge();
      mgr->InitAnalysis();
      mgr->SetGridHandler(new AliAnalysisAlien);
      mgr->StartAnalysis("gridterminate",0);
      return;
   }   
   // Run the analysis                                                                                                                     
   //
   TChain *chain = CreateChain();
   if (!chain) return;
                                                                                                                                                   
   TStopwatch timer;
   timer.Start();
   mgr->SetSkipTerminate(kTRUE);
   if (mgr->InitAnalysis()) {
      mgr->PrintStatus();
      mgr->StartAnalysis("local", chain);
   }
   timer.Print();
}                                                                                                                                          
Example #16
0
//______________________________________________________________________________
void QAtrainsim(Int_t run = 0,
             const char *xmlfile   = "wn.xml",
             Int_t  stage          = 0, /*0 = QA train, 1...n - merging stage*/
             const char *cdb     = "raw://")
{
  run_number = run;

  ProcessEnvironment();

  //
  // set OCDB source
  TString ocdbConfig = "default,snapshot";
  if (gSystem->Getenv("CONFIG_OCDB"))
    ocdbConfig = gSystem->Getenv("CONFIG_OCDB");
  if (stage != 0) {
    //
    gSystem->Setenv("CONFIG_RUN", gSystem->Getenv("ALIEN_JDL_LPMRUNNUMBER"));
    // set OCDB 
    gROOT->LoadMacro("$ALIDPG_ROOT/MC/OCDBConfig.C");
    OCDBDefault(1);
  }
  else if (ocdbConfig.Contains("alien") || ocdbConfig.Contains("cvmfs")) {
    // set OCDB 
    gROOT->LoadMacro("$ALIDPG_ROOT/MC/OCDBConfig.C");
    OCDBDefault(1);
  }
  else {
    // set OCDB snapshot mode
    AliCDBManager *cdbm = AliCDBManager::Instance();
    cdbm->SetSnapshotMode("OCDBrec.root");
  }
  printf("------ Run QAtrainsim.C for collision type %s ------\n",CollisionSystem[iCollisionType]);


  UpdateFlags();
  
  TString cdbString(cdb);
  if (cdbString.Contains("raw://") && !ocdbConfig.Contains("cvmfs")) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("QAtrain", "No grid connection");
      return;
    }
  }
  // gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_PHYSICS -I$ALICE_PHYSICS/include -I$ALICE_PHYSICS/PWGPP/TRD/macros");
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
  // Load libraries
  // LoadLibraries();
  printf("Include path: %s\n", gSystem->GetIncludePath());
  // Create manager
  AliAnalysisManager *mgr  = new AliAnalysisManager("PilotAnalysis_sim", "Production train");
  mgr->SetRunFromPath(run_number);
  // Input handler
  AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
  esdHandler->SetReadFriends(kTRUE);
  esdHandler->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdHandler);
  mgr->SetDebugLevel(debug_level);
  
  // Monte Carlo handler
  AliMCEventHandler* mcHandler = new AliMCEventHandler();
  mgr->SetMCtruthEventHandler(mcHandler);
  mcHandler->SetPreReadMode(1);
  mcHandler->SetReadTR(kTRUE);

  // subsidiary handler for mc-to-mc embedding
  TString bgDir = gSystem->Getenv("CONFIG_BGEVDIR");
  if (!bgDir.IsNull()) { // add extra handler for underlaying event
    if (bgDir.BeginsWith("alien://") && !gGrid && !TGrid::Connect("alien://")) {
      printf("Failed to create a grid connection\n");
      abort();
    }
    if (!bgDir.EndsWith("/")) bgDir += "/";
    AliMCEventHandler* mcHandlerBg = new AliMCEventHandler();
    mcHandlerBg->SetInputPath(bgDir.Data());
    mcHandlerBg->SetPreReadMode(1);
    mcHandlerBg->SetReadTR(kTRUE);
    mcHandler->AddSubsidiaryHandler(mcHandlerBg);
  }
  
  // AnalysisTasks
  //  mgr->Lock();
  mgr->SetFileInfoLog("fileinfo.log"); 
  AddAnalysisTasks(cdb);
  //  mgr->UnLock();
  //  mcHandler = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
  //  mcHandler->SetReadTR(kTRUE);
  //  mcHandler->SetPreReadMode(1);
  if (stage>0) {
    QAmerge(xmlfile, stage);
    return;
  }   
  // Input chain
  TChain *chain = new TChain("esdTree");
  chain->Add("AliESDs.root");
  TStopwatch timer;
  timer.Start();
  if (mgr->InitAnalysis()) {                                                                                                              
    mgr->PrintStatus(); 
    mgr->SetSkipTerminate(kTRUE);
  //   mgr->SetNSysInfo(1);
    mgr->StartAnalysis("local", chain);
  }
  timer.Print();
}
Example #17
0
void Hyperon(const char* dataset="collection.xml")
{
  /* $Id$ */
  TStopwatch timer;
  timer.Start();


    TStringToken libs("Core,Tree,Geom,VMC,Physics,Minuit,Gui,XMLParser,Minuit2,Proof,STEERBase,ESD,AOD,OADB,ANALYSIS,ANALYSISalice,CDB,RAWDatabase,STEER,CORRFW,PHOSUtils,PHOSbase,PHOSpi0Calib,PHOSrec,PHOSshuttle,PHOSsim", ",");
  while( libs.NextToken() )
    gSystem->Load( Form("lib%s", libs.Data()) );

  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libPhysics");
  gSystem->Load("libPWGGAGammaConv");
  gSystem->Load("libPWGGAHyperon");
  
  //load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE
  
  // Connect to alien
  TString token = gSystem->Getenv("GRID_TOKEN") ;
  if (1) // token == "OK" ) 
    TGrid::Connect("alien://");
  else 
    AliInfo("You are not connected to the GRID") ; 

  cout << "Pi0Analysis: processing collection " << dataset << endl;

  // Create the chain
  TChain* chain = new TChain("aodTree");

  TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
  
  TAlienResult* result = collection->GetGridResult("",0 ,0);
  TList* rawFileList = result->GetFileInfoList();
  
  for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
    TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
    const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
    printf("Processing %s\n", rawFile) ;
    chain->Add(rawFile);
    printf("Chain: %d entries.\n",chain->GetEntriesFast()); 
  }

  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("Hyperon");
  mgr->SetCommonFileName("histos.root");
  
  // AOD input handler
  AliAODInputHandler* aodH = new AliAODInputHandler();
  mgr->SetInputEventHandler(aodH);

  
  // Debug level
  mgr->SetDebugLevel(2);

   gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C"); 
   AliCentralitySelectionTask* taskCentrality = AddTaskCentrality(); 
   if (analysisMC) 
    taskCentrality->SetMCInput(); 

  // // Update it for Hyperon (YK 22.01.2015)
  // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
  // AliEPSelectionTask *taskEP = AddTaskEventplane() ; 

  // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
  // AliVZEROEPSelectionTask *selTask = AddTaskVZEROEPSelection();  

  // Add my task
  AliAnalysisHyperon* task = new AliAnalysisHyperon();
  // gROOT->LoadMacro("$ALICE_ROOT/PWGGA/PHOSTasks/PHOS_PbPb/AddTaskPHOSPi0Flow.C"); // Update it for Hyperon (YK 22.01.2015)
  // task = AddTaskPHOSPi0Flow();

  
  // // Create containers for input/output
  AliAnalysisDataContainer *cinput   = mgr->GetCommonInputContainer(); 
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("Hyperon",TList::Class(),AliAnalysisManager::kOutputContainer,"HyperonHist.root");
  
  // // Connect input/output
  mgr->ConnectInput(task , 0, cinput);
  mgr->ConnectOutput(task, 1, coutput1);
 
  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
  }

  timer.Stop();
  timer.Print();
}
void runFlowTaskCentralityKinkTrain( Int_t mode = mLocal,
                                     Bool_t useFlowParFiles = kFALSE,
                                     Bool_t DATA = kTRUE,
                                     const Char_t* dataDir="fileList",
                                     Int_t nEvents = 1e4,
                                     Int_t offset=0 )
{
  // Time:
  TStopwatch timer;
  timer.Start();

  // Load needed libraries:
  LoadLibraries(mode,useFlowParFiles);

  // Create analysis manager:
  AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");

  // Chains:
  if(mode == mLocal)
  {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGUD/macros/CreateESDChain.C");
    TChain* chain = CreateESDChain(dataDir, nEvents, offset);
    //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
  }

  // Connect plug-in to the analysis manager:
  if(mode == mGrid)
  {
    gROOT->LoadMacro("CreateAlienHandler.C");
    AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
    if(!alienHandler) return;
    mgr->SetGridHandler(alienHandler);
  }

  // Event handlers:
  AliVEventHandler* esdH = new AliESDInputHandler;
  mgr->SetInputEventHandler(esdH);
  if (!DATA)
  {
    AliMCEventHandler *mc = new AliMCEventHandler();
    mgr->SetMCtruthEventHandler(mc);
  }

  // Task to check the offline trigger:
  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
  AddTaskPhysicsSelection(!DATA);

  //Add the centrality determination task
  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
  AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
  if (!DATA) centSelTask->SetMCInput();

  //add the PID response task
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
  AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(!DATA);

  //Add the TOF tender
  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGCF/FLOW/macros/AddTaskTenderTOF.C");
  //AddTaskTenderTOF();

  // Setup kink analysis per centrality bin:
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKink.C");
  for (Int_t i=binfirst; i<binlast+1; i++)
  {
    Float_t lowCentralityBinEdge = centralityArray[i];
    Float_t highCentralityBinEdge = centralityArray[i+1];
    AddTaskFlowCentralityKink( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kUnknown,
                              AliFlowTrackCuts::kTOFbeta,
                              -1,2,kTRUE );
    AddTaskFlowCentralityKink( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kUnknown,
                              AliFlowTrackCuts::kTOFbeta,
                              1,2,kTRUE );
    AddTaskFlowCentralityKink( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kUnknown,
                              AliFlowTrackCuts::kTOFbeta,
                              -1,3 );
    AddTaskFlowCentralityKink( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kUnknown,
                              AliFlowTrackCuts::kTOFbeta,
                              1,3 );
  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)

  // Setup kaon analysis per centrality bin:
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
  for (Int_t i=binfirst; i<binlast+1; i++)
  {
    Float_t lowCentralityBinEdge = centralityArray[i];
    Float_t highCentralityBinEdge = centralityArray[i+1];
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kKaon,
                              AliFlowTrackCuts::kTOFbeta,
                              -1,2,kTRUE );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kKaon,
                              AliFlowTrackCuts::kTOFbeta,
                              1,2,kTRUE );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kKaon,
                              AliFlowTrackCuts::kTOFbeta,
                              -1,3 );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kKaon,
                              AliFlowTrackCuts::kTOFbeta,
                              1,3 );
  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)

  // Setup He3 analysis per centrality bin:
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
  for (Int_t i=binfirst; i<binlast+1; i++)
  {
    Float_t lowCentralityBinEdge = centralityArray[i];
    Float_t highCentralityBinEdge = centralityArray[i+1];
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kHe3,
                              AliFlowTrackCuts::kTPCNuclei,
                              -1,2,kTRUE );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kHe3,
                              AliFlowTrackCuts::kTPCNuclei,
                              1,2,kTRUE );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kHe3,
                              AliFlowTrackCuts::kTPCNuclei,
                              -1,3 );
    AddTaskFlowCentralityPID( lowCentralityBinEdge,
                              highCentralityBinEdge,
                              commonOutputFileName,
                              AliPID::kHe3,
                              AliFlowTrackCuts::kTPCNuclei,
                              1,3 );
  } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)

  // Enable debug printouts:
  mgr->SetDebugLevel(2);
  // Run the analysis:
  if(!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  if(mode == mLocal)
  {
    mgr->StartAnalysis("local",chain);
  }
  else if(mode == mPROOF)
  {
    mgr->StartAnalysis("proof",dataDir,nEvents,offset);
  }
  else if(mode == mGrid)
  {
    mgr->StartAnalysis("grid");
  }

  // Print real and CPU time used for analysis:
  timer.Stop();
  timer.Print();

} // end of void runFlowTaskCentralityPIDTrain(...)
Example #19
0
void runLocal() {
  TStopwatch timer;
  timer.Start();
  gSystem->Load("libCore.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libPhysics.so");
  //____________________________________________________//
  //_____________Setting up required packages___________//
  //____________________________________________________//
  gSystem->Load("libSTEERBase.so");
  gSystem->Load("libSTEER.so");
  gSystem->Load("libESD.so");
  gSystem->Load("libAOD.so");
  gSystem->Load("libANALYSIS.so");
  gSystem->Load("libANALYSISalice.so");
  gROOT->ProcessLine(".include $ALICE_ROOT/include");
  gROOT->ProcessLine(".include $ALICE_ROOT/PHOS");

  //___________Compile analysis task using AClic____________//
  gROOT->LoadMacro("EqEnCalibTask.cxx+g");

  // chain using tags
//   AliTagAnalysis *tagAna = new AliTagAnalysis("ESD");
//   tagAna->ChainLocalTags("tags");
// 
//   AliRunTagCuts *runCuts = new AliRunTagCuts();
//   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
//   AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
//   AliEventTagCuts *evCuts = new AliEventTagCuts();
//   // evCuts->SetMultiplicityRange(11,12);
//   TChain* chain = 0x0;
//   chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts);

  // chain using list of files.
  gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
  TChain* chain = CreateESDChain("files.txt", 10);

  
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
  AliESDInputHandler* esdH = new AliESDInputHandler();
  mgr->SetInputEventHandler(esdH);
  AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
  
  // Create the task
  EqEnCalibTask *task = new EqEnCalibTask("EqEnCalibTask");
  //task.SetDebugLevel(4);
  mgr->AddTask(task);
  mgr->ConnectInput(task, 0, cinput0);
  AliAnalysisDataContainer *outContainer = mgr->CreateContainer("outContainer", TList::Class(),AliAnalysisManager::kOutputContainer, "ee-calib.output.root");
  mgr->ConnectOutput(task, 1, outContainer);
  
  // Start the task
  mgr->SetDebugLevel(1);
  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  mgr->StartAnalysis("local",chain);

  timer.Stop();
  timer.Print();
}
Example #20
0
AliMeanPtAnalysisTask* AddTask_mkrueger_MeanPt(TString controlstring, Int_t cutModeLow = 100, Int_t cutModeHigh = 101)
{
  // INFO: for MC use 4 different trains (cutModeLow, cutModeHigh) = (100,105), (105,109), (109,113), (113,116), (116,120)

  // settings:
  Bool_t includeCrosscheckHistos = kFALSE;
  Bool_t is2013pA = kFALSE;
  UInt_t offlineTriggerMask = AliVEvent::kINT7;
  Bool_t is2015Data = kFALSE;
  Bool_t isPbPbAnalysis = kFALSE;

  Int_t maxMultiplicity = 100;
  Float_t etaCut = 0.8;
  if(controlstring.Contains("eta03")) etaCut = 0.3;

  Float_t upperPtCut = 10.;
  Bool_t includeSigmas = kTRUE;
  string colsys = "pp";

  const Int_t nMultSteps = 3;
  Int_t multSteps[] = {100, 0, 0};
  Int_t multBinWidth[] = {1,1,1};

  Int_t nBinsCent = 1;
  Double_t centBinEdgesDummy[2] = {0., 100.};
  Double_t centBinEdgesUsed[9] = {0., 5., 10., 20., 40., 60., 80., 90., 100.};
  Double_t* centBinEdges = centBinEdgesDummy;


  if(controlstring.Contains("pp")){
    if(controlstring.Contains("performanceHistos")) includeCrosscheckHistos = kTRUE;
    if(controlstring.Contains("5TeV")) is2015Data = kTRUE;
    if(controlstring.Contains("7TeV")) offlineTriggerMask = AliVEvent::kMB;
  }
  if(controlstring.Contains("XeXe"))  {
    colsys = "XeXe";
    multSteps[0] = 3500;  multBinWidth[0] = 1;
    multSteps[1] = 0;    multBinWidth[1] = 1;
    multSteps[2] = 0;    multBinWidth[2] = 1;
    nBinsCent = 8;
    centBinEdges = centBinEdgesUsed;
  }
  if(controlstring.Contains("pPb"))  {
    colsys = "pPb";
    multSteps[0] = 300;   multBinWidth[0] = 1;
    multSteps[1] = 0;     multBinWidth[1] = 1;
    multSteps[2] = 0;     multBinWidth[2] = 1;
    is2013pA = kTRUE;
  }
  if(controlstring.Contains("PbPb")) {
    isPbPbAnalysis = kTRUE;
    is2015Data = kTRUE;
    colsys = "PbPb";
    multSteps[0] = 4500;   multBinWidth[0] = 1;
    multSteps[1] = 0;    multBinWidth[1] = 1;
    multSteps[2] = 0;    multBinWidth[2] = 1;
    nBinsCent = 8;
    centBinEdges = centBinEdgesUsed;
  }
  if(controlstring.Contains("excludeSigmas")) includeSigmas = kFALSE;

  // Binning in Multiplicity
  const Int_t nBinsMult = multSteps[0]+ multSteps[1] + multSteps[2] + 1;
  Double_t multBinEdges[nBinsMult+1];
  multBinEdges[0] = -0.5;
  multBinEdges[1] = 0.5;
  Int_t startBin = 1;
  Int_t endBin = 1;
  for(Int_t multStep = 0; multStep < nMultSteps; multStep++){
    endBin += multSteps[multStep];
    for(Int_t multBin = startBin; multBin < endBin; multBin++)  {
      multBinEdges[multBin+1] = multBinEdges[multBin] + multBinWidth[multStep];
    }
    startBin = endBin;
  }


  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();

  if (!mgr) {
    Error("AddTask_mkrueger_MeanPt", "No analysis manager found.");
    return 0;
  }

  // Switch off all AliInfo (too much output!!!)
  AliLog::SetGlobalLogLevel(AliLog::kError);
  mgr->SetDebugLevel(0);

  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  Bool_t hasMC = (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler() != 0x0);

  if(controlstring.Contains("PbPb") && hasMC) offlineTriggerMask = AliVEvent::kMB;

  AliMeanPtAnalysisTask* mainTask = NULL;

  char taskName[100] = "";


  for(Int_t cutMode = cutModeLow; cutMode < cutModeHigh; cutMode++){
    sprintf(taskName, "mkrueger_%s_eta_%.2f_cutMode_%d", colsys.c_str(), etaCut, cutMode);

    AliMeanPtAnalysisTask* task = new AliMeanPtAnalysisTask(taskName);

    task->SetIncludeCrosscheckHistos(includeCrosscheckHistos);
    task->Set2013pA(is2013pA);

    // general cuts
    task->SelectCollisionCandidates(offlineTriggerMask);
    task->SetTriggerMask(offlineTriggerMask);

    task->SetUseMC(hasMC);
    if(type.Contains("ESD")) task->SetUseESD();
    else task->SetUseAOD();
    task->SetBinsMult(nBinsMult, multBinEdges);
    task->SetBinsCent(nBinsCent, centBinEdges);

    // nominal cut-setting:
    task->SetMinEta(-etaCut);
    task->SetMaxEta(etaCut);
    task->SetMinPt(0.15);
    task->SetMaxPt(upperPtCut);

    task->Set2013pA(kFALSE);
    task->Set2015data(is2015Data);

    task->SetMeanXYZv(0.0,0.0,0.0);
    task->SetSigmaMeanXYZv(1.0,1.0,10.0);
    task->SetZvtx(10.);

    // Quality cuts for tracks
    task->SetTPCRefit(kTRUE);
    task->SetITSRefit(kTRUE);
    task->SetKinkDaughters(kFALSE);
    task->SetRatioCrossedRowsOverFindableClustersTPC(0.8);
    task->SetFractionSharedClustersTPC(0.4);
    task->SetMaxchi2perTPCclu(4.);
    task->SetClusterReqITS(kTRUE);
    task->SetMaxchi2perITSclu(36.);
    task->SetDCAtoVertex2D(kFALSE);
    task->SetSigmaToVertex(kFALSE);
    task->SetDCAtoVertexZ(2.0);
    task->SetDCAtoVertexXYPtDep("0.0182+0.0350/pt^1.01");
    task->SetMaxChi2TPCConstrained(36.); // was excluded for some reason?
    task->SetMinLenghtInActiveZoneTPC(0);
    task->SetGeometricalCut(kTRUE,3,130,1.5,0.85,0.7); ///if kTRUE comment CrossedRowsTPC cut
    // task->SetMinCrossedRowsTPC(120);

//MC1--
      if(cutMode == 100) mainTask = task; // has no particular use... just to return task with nominal cut setting in macro

    // cut-variation:
      if(cutMode == 101) {task->SetMaxchi2perITSclu(25.);}
      if(cutMode == 102) {task->SetMaxchi2perITSclu(49.);}

      if(cutMode == 103) {task->SetMaxchi2perTPCclu(3); }
      if(cutMode == 104) {task->SetMaxchi2perTPCclu(5); }
//MC2--
      if(cutMode == 105) {task->SetRatioCrossedRowsOverFindableClustersTPC(0.7);}
      if(cutMode == 106) {task->SetRatioCrossedRowsOverFindableClustersTPC(0.9);}

      if(cutMode == 107) {task->SetFractionSharedClustersTPC(0.2);}
      if(cutMode == 108) {task->SetFractionSharedClustersTPC(1.0);}
//MC3--
      if(cutMode == 109) {task->SetMaxChi2TPCConstrained(25.);}
      if(cutMode == 110) {task->SetMaxChi2TPCConstrained(49.);}

      if(cutMode == 111) {task->SetDCAtoVertexXYPtDep("0.0104+0.0200/pt^1.01");}
      if(cutMode == 112) {task->SetDCAtoVertexXYPtDep("0.0260+0.0500/pt^1.01");}
//MC4--
      if(cutMode == 113) {task->SetDCAtoVertexZ(1.0);}
      if(cutMode == 114) {task->SetDCAtoVertexZ(5.0);}

      if(cutMode == 115) {task->SetClusterReqITS(kFALSE);}
//MC5--
      if(cutMode == 116) {task->SetGeometricalCut(kTRUE,3,120,1.5,0.85,0.7);}
      if(cutMode == 117) {task->SetGeometricalCut(kTRUE,3,140,1.5,0.85,0.7);}

      if(cutMode == 118) {task->SetGeometricalCut(kTRUE,4,130,1.5,0.85,0.7);}
      if(cutMode == 119) {task->SetGeometricalCut(kTRUE,2,130,1.5,0.85,0.7);}



  // hang task in train

    mgr->AddTask(task);

    AliAnalysisDataContainer* cinput = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer* coutput = mgr->CreateContainer(taskName,
							    TList::Class(),
							    AliAnalysisManager::kOutputContainer,
							    "AnalysisResults.root");



    mgr->ConnectInput(task, 0, cinput);
    mgr->ConnectOutput(task, 1, coutput);


  }


  return mainTask;

}
Example #21
0
void runNorm(TString inputFileName = "AliAOD.root", Int_t nEvents = 1e6, TString beamConf = "p-Pb", Bool_t isESD = kFALSE, Bool_t isMC = kFALSE, Int_t debugLevel = 0)
{

  TStopwatch timer;
  timer.Start();
  
  // Check runing mode
  Int_t mode = GetMode(inputFileName);
  if(mode < 0){
    Error("runAnalysis","Please provide either an ESD/AOD root file or a collection of ESDs/AODs.");
    return;
  }
  
  // Load common libraries
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libPhysics");
  gSystem->Load("libSTEERBase");
  //  gSystem->Load("libSTEER");
  gSystem->Load("libESD");
  gSystem->Load("libAOD");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libEventMixing");
  gSystem->Load("libCORRFW");
  gSystem->Load("libPWGmuon"); 
  gSystem->Load("libPWGmuondep"); 
  
  gSystem->AddIncludePath(Form("-I\"%s/include\" -I\"%s/include\"", gSystem->ExpandPathName("$ALICE_ROOT"),gSystem->ExpandPathName("$ALICE_PHYSICS")));
  gROOT->ProcessLine(Form(".include %s/include %s/include", gSystem->ExpandPathName("$ALICE_ROOT"), gSystem->ExpandPathName("$ALICE_PHYSICS")));

  // Create input chain
  TChain* chain = CreateChain(inputFileName,isESD);
  if (!chain) return;
  
  // Create the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("MuonTask");
  
  if ( isESD) {
    // ESD input handler
    AliESDInputHandler* esdH = new AliESDInputHandler();
    esdH->SetReadFriends(kFALSE);
    mgr->SetInputEventHandler(esdH);
  }
  else {
    // AOD input handler
    AliAODInputHandler* aodH = new AliAODInputHandler();
    mgr->SetInputEventHandler(aodH);
  }

  TString dataType = mgr->GetInputEventHandler()->GetDataType();
  Info("runLocal",Form("Manager with %s",dataType.Data()));

 // Enable MC event handler for ESDs
  if ( isMC && isESD ){
    AliVEventHandler* handler = new AliMCEventHandler;
    mgr->SetMCtruthEventHandler(handler);
  }
  
  // event selection and centrality framework
  if ( isESD ){
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physicsSelection = AddTaskPhysicsSelection(isMC);
    if ( !physicsSelection ) {
      Error("runLocal","AliPhysicsSelectionTask not created!");
      return;
    }
  }
  if ( isESD ){
    // event centrality
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
    if ( !taskCentrality ) {
      Error("runLocal on ESD","AliCentralitySelectionTask not created!");
      return;
    }
    if ( isMC ) taskCentrality->SetMCInput();     
    //taskCentrality->SetPass(1); // remember to set the pass you are processing!!!
  }
  /*else {
    //Only on full AOD, it is possible to reprocess the centrality framework
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(kTRUE,kTRUE);
    if ( !taskCentrality ) {
      Error("runLocal on AOD","AliCentralitySelectionTask not created!");
      return;
    }
    if ( isMC ) taskCentrality->SetMCInput();    
    }*/
  
  // Example analysis
  // Create task
  //Analysis task is on working directory
  //  gROOT->LoadMacro("AliAnalysisTaskNorm.cxx+g");
  //  gROOT->LoadMacro("AddTaskNorm.C");
  gROOT->LoadMacro("$ALICE_PHYSICS/../src/PWG/muon/AliAnalysisTaskNorm.cxx+g");
  gROOT->LoadMacro("$ALICE_PHYSICS/../src/PWG/muon/AddTaskNorm.C");
  AliAnalysisTaskNorm* task = AddTaskNorm(isESD,isMC,beamConf);
  if (!task) {
    Error("runAnalysis","AliAnalysisTaskNorm not created!");
    return;
  }
  task->SetDebugLevel(debugLevel);
  
  // Enable debug printouts
  mgr->SetDebugLevel(debugLevel);

  // start local analysis
  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    if(debugLevel>=2) mgr->SetNSysInfo(100);
    mgr->StartAnalysis("local", chain, nEvents);
  }

  if(debugLevel>=2){
    mgr->ProfileTask("Task");
  }

  timer.Stop();
  timer.Print();
}
Example #22
0
void CPVanalysis(const TString dataset="")
{
    
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libPhysics");
  
  //load analysis framework
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE
  
  gSystem->AddIncludePath("-I$ALICE_ROOT/include -I$ALICE_ROOT/PHOS");

  // A task can be compiled dynamically with AClic
  gROOT->LoadMacro("AliAnalysisTaskCPV.cxx+g");
  
  // Connect to alien
  TString token = gSystem->Getenv("GRID_TOKEN") ;
  token="OK";
  if ( token == "OK" ) 
    TGrid::Connect("alien://");
  else 
    Printf("You are not connected to the GRID") ; 
    // AliInfo("You are not connected to the GRID") ; 

  cout << "CPVanalysis: processing collection " << dataset << endl;
  
  // Create the chain
    TChain* chain;

  if (dataset.Contains(".txt")) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
    chain = CreateESDChain(dataset.Data(), 1000);
  }
  else if (dataset.Contains(".xml")) {
    chain = new TChain("esdTree");
    TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
  
    TAlienResult* result = collection->GetGridResult("",0 ,0);
    TList* rawFileList = result->GetFileInfoList();
    
    for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
      TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
      const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
      printf("Processing %s\n", rawFile) ;
      chain->Add(rawFile);
      printf("Chain: %d entries.\n",chain->GetEntries()); 
    }
  }
  
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("CPVanalysis");
  
  // ESD input handler
  AliESDInputHandler* esdH = new AliESDInputHandler();
  esdH->SetReadFriends(kFALSE);
  mgr->SetInputEventHandler(esdH);
  
  // Debug level
  mgr->SetDebugLevel(0);
  
  //PID task
  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
  AliAnalysisTask *taskPID =  AddTaskPIDResponse(/*Bool_t isMC=*/ kFALSE, /*Bool_t autoMCesd=*/kTRUE,
						 /*Bool_t tuneOnData=*/kTRUE);

  // // Add physics selection
  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
  physSelTask->GetPhysicsSelection()->SetUseBXNumbers(kFALSE);// ---> ???

  // Add my task
  AliAnalysisTaskCPV *task1 = new AliAnalysisTaskCPV("CPVanalysis");

  // task1->SelectCollisionCandidates(AliVEvent::kMB);
  mgr->AddTask(task1);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput   = mgr->GetCommonInputContainer(); 
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("histCPV1",TList::Class(),AliAnalysisManager::kOutputContainer,"CPVanalysis.root");
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histCPV2",TList::Class(),AliAnalysisManager::kOutputContainer,"CPVanalysis.root");

  ((AliInputEventHandler*)mgr->GetInputEventHandler())->SetNeedField(1);


  // Connect input/output
  mgr->ConnectInput(task1 , 0, cinput);
  mgr->ConnectOutput(task1, 1, coutput1);
  mgr->ConnectOutput(task1, 2, coutput2);
  
  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
  }
  
}
Example #23
0
//______________________________________________________________________________
void runPmdTask(Bool_t         isGrid = 0,
		Bool_t           isMC = 0,
		const char *gridmode  = "test") {

 
  if (isGrid) {
    Printf("Strating the Grid Job ");
    Printf("Grid Mode %s",gridmode);
    if (isMC)  Printf("It is Data Type Run");
    if (!isMC) Printf("It is MC Type Run");
  }
    
  // Load the needed libraries most of 
  // them already loaded by aliroot
  //--------------------------------------
  gSystem->Load("libTree");
  gSystem->Load("libGeom");
  gSystem->Load("libVMC");
  gSystem->Load("libXMLIO");
  gSystem->Load("libPhysics");

  gSystem->Load("libSTEERBase");
  gSystem->Load("libESD");
  gSystem->Load("libAOD");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");

  // Use AliRoot includes to compile our task                                   
  gROOT->ProcessLine(".include $ALICE_INSTALL/include");
  
  AliAnalysisManager *mgr = new AliAnalysisManager("PMDAnalysis");
  
  if(isGrid) {
    gROOT->LoadMacro("CreateAlienHandler.C");
    AliAnalysisGrid *alienHandler = CreateAlienHandler(gridmode);  
    if (!alienHandler) return;
    mgr->SetGridHandler(alienHandler);
  }
    
  
 
  //  TChain *  chain;
  //  if(!isGrid) {
  //  gROOT->LoadMacro("CreateESDChain.C"); // use it if you know it
  //  chain = CreateESDChain("file.txt", 10);
  //  }
 
  TChain *  chain = new TChain("esdTree"); 
  if(!isGrid) {
    ifstream file_collect(incollection);
    TString line;
    while (line.ReadLine(file_collect) ) {
      chain->Add(line.Data());
    }
  }
    
  if(isMC) {
    AliVEventHandler* esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);
    AliMCEventHandler *mc = new AliMCEventHandler();
    //mc->SetReadTR(kTRUE);
    mgr->SetMCtruthEventHandler(mc);
    gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(isMC);
    physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();

    gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *centralityTask = AddTaskCentrality();
  } else {
    AliVEventHandler* esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);
    gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
    AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(isMC);
    
    gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *centralityTask = AddTaskCentrality();
  }

  gROOT->LoadMacro("AliPMDAnalysisTaskPbPb.cxx++g");   
  gROOT->LoadMacro("AddAliPMDAnalysisTaskPbPb.C");
  AddAliPMDAnalysisTaskPbPb("MyTask",isMC);
  
  // Enable debug printouts
  mgr->SetDebugLevel(0);
  if (!mgr->InitAnalysis())
    return;
  
 mgr->PrintStatus();
 
 if(isGrid)
   mgr->StartAnalysis("grid");
 else  
   mgr->StartAnalysis("local",chain);
 
};
Example #24
0
void AnaPi0Select(const char* dataset="minbias_LHC09a4_81040_81050.xml")
{
    
    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libVMC");
    gSystem->Load("libPhysics");

    //load analysis framework
    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE

    //Set local DB for PHOS
    gROOT->ProcessLine(".! tar xzvf PHOS.tgz") ;
    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
    AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local://./");

    // A task can be compiled dynamically with AClic
    gROOT->LoadMacro("AliAnalysisTaskPi0CalibSelection.cxx+g");

    // Connect to alien
    TString token = gSystem->Getenv("GRID_TOKEN") ;
    if ( token == "OK" ) 
     TGrid::Connect("alien://");
    else 
     AliInfo("You are not connected to the GRID") ; 

    // Create the chain
    TChain* chain = new TChain("esdTree");
    TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
   
    TAlienResult* result = collection->GetGridResult("",0 ,0);
    TList* rawFileList = result->GetFileInfoList();

    for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
     TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
     const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
     printf("Processing %s\n", rawFile) ;
     chain->Add(rawFile);
     printf("Chain: %d entries.\n",chain->GetEntries()); 
    }

    // Make the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("Pi0CalibSelect","Pi0CalibSelection");

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

    // Debug level
    mgr->SetDebugLevel(10);

    // Add task
    AliAnalysisTaskPi0CalibSelection *task = new AliAnalysisTaskPi0CalibSelection("Pi0CalibSelection");
    task->SetClusterMinEnergy(0.4);
    mgr->AddTask(task);

    // Create containers for input/output
    AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput = mgr->CreateContainer("histos",TList::Class(),AliAnalysisManager::kOutputContainer,"histos.root");

    // Connect input/output
    mgr->ConnectInput(task, 0, cinput);
    mgr->ConnectOutput(task, 1, coutput);

    if (mgr->InitAnalysis()) {
	     mgr->PrintStatus();
	     mgr->StartAnalysis("local", chain);
    }

}
//_____________________________________________________________________________
void RunPerformanceTaskResEffMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseESDfriend=kTRUE,  Bool_t bProof=kTRUE)
{
  if(!chain) 
  {
    AliDebug(AliLog::kError, "ERROR: No input chain available");
    return;
  }
  //
  // Swtich off all AliInfo (too much output!)
  //
  AliLog::SetGlobalLogLevel(AliLog::kError);

  //
  // Create analysis manager
  //
  AliAnalysisManager *mgr = new AliAnalysisManager;
  if(!mgr) { 
    Error("runTPCQA","AliAnalysisManager not set!");
    return;
  }

  //
  // Set ESD input handler
  //
  AliESDInputHandler* esdH = new AliESDInputHandler;
  if(!esdH) { 
    Error("runTPCQA","AliESDInputHandler not created!");
    return;
  }
  if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdH);

  //
  // Set MC input handler
  //
  if(bUseMCInfo) {
    AliMCEventHandler* mcH = new AliMCEventHandler;
    if(!esdH) { 
      Error("runTPCQA","AliMCEventHandler not created!");
      return;
    }
    mcH->SetReadTR(kTRUE);
    mgr->SetMCtruthEventHandler(mcH);
  }

  //
  // Create task
  //
  AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance");
  if (!task) {
    Error("AddTaskPerformanceTPC", "TPC performance task cannot be created!");
    return NULL;
  }
  task->SetUseMCInfo(bUseMCInfo);
  task->SetUseESDfriend(bUseESDfriend);

  //
  // Add task to analysis manager
  //
  mgr->AddTask(task);

  //
  // Create TPC-ESD track reconstruction cuts
  // MB tracks
  //
  AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts("pRecInfoCutsTPC"); 
  if(pRecInfoCutsTPC) {
    pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
    pRecInfoCutsTPC->SetMaxDCAToVertexZ(30.0);
    //pRecInfoCutsTPC->SetMaxDCAToVertexZ(3.0);
    pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
    pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
    pRecInfoCutsTPC->SetAcceptKinkDaughters(kTRUE);
    pRecInfoCutsTPC->SetMinNClustersTPC(50);
    pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(1000000.);
    pRecInfoCutsTPC->SetDCAToVertex2D(kFALSE);

    pRecInfoCutsTPC->SetHistogramsOn(kFALSE); 
  } 
  else {
    Error("AddTaskPerformanceTPC", "AliRecInfoCutsTPC cannot be created!");
    return NULL;
  }

  //
  // Create TPC-ESD track reconstruction cuts
  // MATCH tracks
  //
  AliRecInfoCuts *pRecInfoCutsMATCH = new AliRecInfoCuts("pRecInfoCutsMATCH"); 
  if(pRecInfoCutsMATCH) {
    pRecInfoCutsMATCH->SetMaxDCAToVertexXY(3.0);
    pRecInfoCutsMATCH->SetMaxDCAToVertexZ(3.0);
    pRecInfoCutsMATCH->SetRequireSigmaToVertex(kFALSE);
    pRecInfoCutsMATCH->SetRequireTPCRefit(kFALSE);
    pRecInfoCutsMATCH->SetAcceptKinkDaughters(kTRUE);
    pRecInfoCutsMATCH->SetMinNClustersTPC(50);
    pRecInfoCutsMATCH->SetMaxChi2PerClusterTPC(1000000.);
    pRecInfoCutsMATCH->SetDCAToVertex2D(kFALSE);
    pRecInfoCutsMATCH->SetTPCITSMatchingRadius(70); 
    pRecInfoCutsMATCH->SetTPCTRDMatchingRadius(260); 
    pRecInfoCutsMATCH->SetMinNClustersITS(3);

    pRecInfoCutsMATCH->SetHistogramsOn(kFALSE); 
  } 
  else {
    Error("AddTaskPerformanceTPC", "AliRecInfoCutsTPC cannot be created!");
    return NULL;
  }

  //
  // Create TPC-ESD track reconstruction cuts
  // standard cuts
  AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts("pRecInfoCuts"); 
  if(pRecInfoCuts) {
    pRecInfoCuts->SetMaxDCAToVertexXY(3.0);
    pRecInfoCuts->SetMaxDCAToVertexZ(3.0);
    pRecInfoCuts->SetMinNClustersTPC(50);
    pRecInfoCuts->SetMinNClustersITS(2);
    pRecInfoCuts->SetHistogramsOn(kFALSE); 
    pRecInfoCuts->SetTPCITSMatchingRadius(70); 
    pRecInfoCuts->SetTPCTRDMatchingRadius(260); 
  } 
  else {
    Error("AddTaskPerformanceTPC", "AliRecInfoCuts cannot be created!");
    return NULL;
  }
  //
  // Create TPC-MC track reconstruction cuts
  //
  AliMCInfoCuts  *pMCInfoCuts = new AliMCInfoCuts("pMCInfoCuts");
  if(pMCInfoCuts) {
    pMCInfoCuts->SetMinTrackLength(70);
  } 
  else {
    Error("AddTaskPerformanceTPC", "AliMCInfoCuts cannot be created!");
    return NULL;
  }

  //
  // Create performance objects for TPC and set cuts 
  //
  enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };

  //
  // Resolution
  //
  AliPerformanceRes *pCompRes0 = new AliPerformanceRes("AliPerformanceRes","AliPerformanceRes",kTPC,kFALSE); 
  if(!pCompRes0) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes");
  }
  pCompRes0->SetAliRecInfoCuts(pRecInfoCuts);
  pCompRes0->SetAliMCInfoCuts(pMCInfoCuts);

  AliPerformanceRes *pCompRes3 = new AliPerformanceRes("AliPerformanceResTPCInner","AliPerformanceResTPCInner",kTPCInner,kFALSE); 
  if(!pCompRes3) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCInner");
  }
  pCompRes3->SetAliRecInfoCuts(pRecInfoCuts);
  pCompRes3->SetAliMCInfoCuts(pMCInfoCuts);

  AliPerformanceRes *pCompRes4 = new AliPerformanceRes("AliPerformanceResTPCOuter","AliPerformanceResTPCOuter",kTPCOuter,kFALSE); 
  if(!pCompRes4) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCOuter");
  }
  pCompRes4->SetAliRecInfoCuts(pRecInfoCuts);
  pCompRes4->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // Efficiency
  //
  AliPerformanceEff *pCompEff0 = new AliPerformanceEff("AliPerformanceEff","AliPerformanceEff",kTPC,kFALSE); 
  if(!pCompEff0) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
  }
  pCompEff0->SetAliRecInfoCuts(pRecInfoCuts);
  pCompEff0->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // dEdx
  //
  AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); 
  if(!pCompDEdx3) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDEdxTPCInner");
  }
  pCompDEdx3->SetAliRecInfoCuts(pRecInfoCuts);
  pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // DCA
  //
  AliPerformanceDCA *pCompDCA0 = new AliPerformanceDCA("AliPerformanceDCA","AliPerformanceDCA",kTPC,kFALSE); 
  if(!pCompDCA0) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDCA");
  }
  pCompDCA0->SetAliRecInfoCuts(pRecInfoCuts);
  pCompDCA0->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // TPC performance
  //
  AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE); 
  if(!pCompTPC0) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceTPC");
  }
  pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
  pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // TPC+ITS matching performance
  //
  AliPerformanceMatch *pCompMatch0 = new AliPerformanceMatch("AliPerformanceMatchTPCITS","AliPerformanceMatchTPCITS",0,kFALSE); 
  if(!pCompMatch0) {
    Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCITS");
  }
  pCompMatch0->SetAliRecInfoCuts(pRecInfoCutsMATCH);
  pCompMatch0->SetAliMCInfoCuts(pMCInfoCuts);
  //
  // TPC+TRD matching performance
  //
  AliPerformanceMatch *pCompMatch1 = new AliPerformanceMatch("AliPerformanceMatchTPCTRD","AliPerformanceMatchTPCTRD",1,kFALSE); 
  if(!pCompMatch1) {
    Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCTRD");
  }
  pCompMatch1->SetAliRecInfoCuts(pRecInfoCutsMATCH);
  pCompMatch1->SetAliMCInfoCuts(pMCInfoCuts);
 
  AliPerformanceMatch *pCompMatch2 = new AliPerformanceMatch("AliPerformanceMatchTPCEFF","AliPerformanceMatchTPCEFF",2,kFALSE); 
  if(!pCompMatch2) {
    Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCEFF");
  }
  pCompMatch2->SetAliRecInfoCuts(pRecInfoCutsMATCH);
  pCompMatch2->SetAliMCInfoCuts(pMCInfoCuts);

  //
  // Add components to the performance task
  //
  //task->AddPerformanceObject( pCompDEdx3 );
  //task->AddPerformanceObject( pCompDCA0 );
  //task->AddPerformanceObject( pCompTPC0 );
  //task->AddPerformanceObject( pCompMatch0 );
  //task->AddPerformanceObject( pCompMatch1 );
  //task->AddPerformanceObject( pCompMatch2 );

  //
  if(bUseMCInfo) { 
     task->AddPerformanceObject( pCompRes0 );
     //task->AddPerformanceObject( pCompRes3 );
     //task->AddPerformanceObject( pCompRes4 );
     task->AddPerformanceObject( pCompEff0 );
  }

  //
  if(!bUseMCInfo) {
    pCompDEdx3->SetTriggerClass(triggerClass);
    pCompDCA0->SetTriggerClass(triggerClass);
    pCompTPC0->SetTriggerClass(triggerClass);
    pCompMatch0->SetTriggerClass(triggerClass);
    pCompMatch1->SetTriggerClass(triggerClass);
    pCompMatch2->SetTriggerClass(triggerClass);
  }

  //
  // Create containers for input
  //
  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());

  //
  // Create containers for output
  //
  AliAnalysisDataContainer *coutput_tpc = mgr->CreateContainer("TPCMC", TList::Class(), AliAnalysisManager::kOutputContainer, Form("TPC.MC.%s.root", task->GetName()));
  mgr->ConnectOutput(task, 1, coutput_tpc);

  // Enable debug printouts
  mgr->SetDebugLevel(0);

  if (!mgr->InitAnalysis())
    return;

  mgr->PrintStatus();

  if(bProof) mgr->StartAnalysis("proof",chain);
  else mgr->StartAnalysis("local",chain);
}
void AliAnalysisTaskFilteredTest(const char *esdList,
                                 Int_t run = 0,
                                 Float_t scalingTracks = 1,
                                 Float_t scalingV0 = 1,
                                 Float_t scalingFriend = 1,
                                 const char *ocdb = "cvmfs://",
                                 Int_t nFiles = 100000,
                                 Int_t firstFile = 0,
                                 Int_t nEvents = 1000000000,
                                 Int_t firstEvent = 0,
                                 Bool_t mc = kFALSE)
{
    TStopwatch timer;
    timer.Start();
 
    printf("\n\n\n");
    printf("scalingTracks=%d\n",scalingTracks);
    printf("scalingV0=%d\n",scalingV0);
    printf("nFiles=%d\n",nFiles);

    gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_ROOT/TRD");

    //____________________________________________//
    // Make the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
    mgr->SetDebugLevel(0);

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

    // Enable MC event handler
    AliMCEventHandler* handlerMC = new AliMCEventHandler;
    //handler->SetReadTR(kFALSE);
    if (mc) mgr->SetMCtruthEventHandler(handlerMC);

    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskCDBconnect.C");
    AddTaskCDBconnect(ocdb,run);

    if (gSystem->AccessPathName("localOCDBaccessConfig.C", kFileExists)==0) {
      gROOT->LoadMacro("localOCDBaccessConfig.C");
      localOCDBaccessConfig();
    }
    // Create input chain
    TChain* chain = AliXRDPROOFtoolkit::MakeChain(esdList, "esdTree",0,nFiles,firstFile);

    if(!chain) {
        printf("ERROR: chain cannot be created\n");
        return;
    }
    chain->Lookup();
  

    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    Bool_t isMC=kFALSE; // kTRUE in case of MC
    AddTaskPIDResponse(isMC); 

    //
    // Wagons to run 
    //
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskFilteredTree.C");
    AliAnalysisTaskFilteredTree* task = (AliAnalysisTaskFilteredTree*)AddTaskFilteredTree("Filtered.root");
    task->SetLowPtTrackDownscaligF(scalingTracks);
    task->SetLowPtV0DownscaligF(scalingV0);
    task->SetFriendDownscaling(scalingFriend);
    task->SetUseESDfriends(kTRUE);
    task->Dump();
    // Init
    if (!mgr->InitAnalysis()) 
        mgr->PrintStatus();
    //
    // Run on dataset
    mgr->StartAnalysis("local",chain,nEvents, firstEvent);
    timer.Stop();
    timer.Print();
    delete mgr;
    CheckOutput();
}
Example #27
0
//_____________________________________________________________________________
void RunPerformanceTrain(Char_t *file="esd.root", Int_t runNumber = 2, const char* triggerClass ="CINT1B-ABCE-NOPF-ALL", Bool_t bUseMCInfo=kFALSE, Bool_t bUseESDfriend=kTRUE, Bool_t bGrid=kFALSE)
{
  //
  // Grid settings
  // use GSI::SE
  if(bGrid) {
    gSystem->Setenv("alien_CLOSE_SE","ALICE::GSI::SE");
    TGrid * alien = TGrid::Connect("alien://",0,0,"t");
    gSystem->Setenv("alien_CLOSE_SE","ALICE::GSI::SE");
  }

  //
  // Train Configuration
  //
  Int_t       iPWGPPperfTPC       = 1;      // Test TPC performance
  Int_t       iPWGPPperfTRD       = 0;      // Test TRD performance
  Int_t       iPWGPPperfITS       = 0;      // Test ITS performance
  Int_t       iPWGPPperfCalo      = 0;      // Test Calo performance
  Int_t       iPWGPPperfMuonTrig  = 0;      // Test Muon Trigger performance
  Int_t       iPWGPPperfMuonEff   = 0;      // Test Muon Efficiency performance
  Int_t       iPWGPPperfTOF       = 0;      // Test TOF-TPC matching performance
  Int_t       iPWGPPperfPrimVertex = 0;     // Test Primary Vertex performance
  Int_t       iPWGPPv0QA          = 0;      // V0 algorithm QA task

  //
  // Load Libraries
  //
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libTender");
  gSystem->Load("libCORRFW");

  gSystem->Load("libTPCcalib");
  gSystem->Load("libPWGPP");

  gSystem->Load("libPHOSUtils");
  gSystem->Load("libEMCALUtils");
  gSystem->Load("libPWG4PartCorrBase");
  gSystem->Load("libPWG4PartCorrDep");

  gSystem->Load("libPWGmuon"); // The class is here

  //
  // OCDB Configuration 
  //
  AliCDBManager *cdbManager = AliCDBManager::Instance();
  cdbManager->SetDefaultStorage("local:///lustre/alice/alien/alice/data/2009/OCDB");
  //cdbManager->SetDefaultStorage("local://$ALICE_PHYSICS/OCDB");
  //cdbManager->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd()));
  cdbManager->SetRun(runNumber);
  //cdbManager->SetCacheFlag(kFALSE);
  // initialize magnetic field from the GRP manager.
  //if(magField==0) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 0., 0., AliMagF::k2kG));
  //if(magField==1) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k2kG));
  //if(magField==2) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG));

  /*
  AliGRPManager grpMan;
  grpMan.ReadGRPEntry();
  grpMan.SetMagField();
  AliRunInfo *runInfo = grpMan.GetRunInfo();
 
  //
  // Load geometry
  //
  */
  AliGeomManager::LoadGeometry();

  //
  // Swtich off all AliInfo (too much output!)
  //
  AliLog::SetGlobalLogLevel(AliLog::kError);

  //
  // Create input ESD chain
  //
  /*
  gROOT->LoadMacro("$ALICE_PHYSICS/PWG0/CreateESDChain.C");
  TChain* chain = CreateESDChain(list,nFiles,fistFile);
  if(!chain) { 
    Error("RunPerformanceTrain","ESD chain not created!");
    return;
  }
  */
  TChain  *chain = new TChain("esdTree");
  if(!chain) { 
    Error("RunPerformanceTrain","ESD chain not created!");
    return;
  }
  chain->Add(file);
  chain->Lookup();

  //
  // Create analysis manager
  //
  AliAnalysisManager *mgr = new AliAnalysisManager;
  if(!mgr) { 
    Error("RunPerformanceTrain","AliAnalysisManager not set!");
    return;
  }

  //
  // Set ESD input handler
  //
  AliESDInputHandler* esdH = new AliESDInputHandler;
  if(!esdH) { 
    Error("RunPerformanceTrain","AliESDInputHandler not created!");
    return;
  }
  if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdH);

  /*
  //
  // Set RecPoints and ESD input handler
  //
  AliESDInputHandlerRP* rpH = new AliESDInputHandlerRP;
  if(!rpH) { 
    Error("RunPerformanceTrain","AliESDInputHandlerRP not created!");
    return;
  }
  if(bUseESDfriend) rpH->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(rpH);
  */

  //
  // Set MC input handler
  //
  if(bUseMCInfo) {
    AliMCEventHandler* mcH = new AliMCEventHandler;
    if(!mcH) { 
      Error("RunPerformanceTrain","AliMCEventHandler not created!");
      return;
    }
    mcH->SetReadTR(kTRUE);
    mgr->SetMCtruthEventHandler(mcH);
  }


  //
  // Add task to AliAnalysisManager
  //

  //
  // TPC performance
  //
  if(iPWGPPperfTPC) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskPerformanceTPC.C");
    AliPerformanceTask *tpcQA = AddTaskPerformanceTPC(bUseMCInfo,bUseESDfriend,triggerClass);
    if(!tpcQA) { 
      Error("RunPerformanceTrain","AliPerformanceTask not created!");
      return;
    }
  } 
  else {
    Printf("RunPerformanceTrain: TPC Performance - EXCLUDED!");
  }
  //
  // TRD perormance
  //
  if(iPWGPPperfTRD) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTrainPerformanceTRD.C");
    if(!AddTrainPerformanceTRD(bUseMCInfo,bUseESDfriend)) { 
      Error("RunPerformanceTrain","TrainPerformanceTRD not created!");
      return;
    }
  } else {
    Printf("RunPerformanceTrain: TRD TrainPerformanceTRD - EXCLUDED!");
  }
  //
  // ITS performance
  //
  if(iPWGPPperfITS) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskPerformanceITS.C");
    AliAnalysisTaskITSTrackingCheck *itsQA = AddTaskPerformanceITS(bUseMCInfo);
    if(!itsQA) { 
      Error("RunPerformanceTrain","AliAnalysisTaskITSTrackingCheck not created!");
      return;
    }
  } 
  else {
    Printf("RunPerformanceTrain: AliAnalysisTaskITSTrackingCheck - EXCLUDED!");
  }
  //
  // Calorimeter Performance
  //
  if(iPWGPPperfCalo) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWG4/macros/AddTaskCalorimeterQA.C");
    AliAnalysisTaskParticleCorrelation *taskCaloQA = AddTaskCalorimeterQA("ESD",bUseMCInfo,kFALSE);
    if(!taskCaloQA) { 
      Error("RunPerformanceTrain","AliAnalysisTaskParticleCorrelation not created!");
      return;
    }
    mgr->AddTask(taskCaloQA);
  } 
  else {
    Printf("RunPerformanceTrain: AliAnalysisTaskParticleCorrelation - EXCLUDED!");
  }
  //
  // Muon Trigger
  //
  if(iPWGPPperfMuonTrig) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskMTRchamberEfficiency.C");
    AliAnalysisTaskTrigChEff *taskMuonTrig = AddTaskMTRchamberEfficiency();
    if(!taskMuonTrig) { 
      Error("RunPerformanceTrain","AliAnalysisTaskTrigChEff not created!");
      return;
    }
    mgr->AddTask(taskMuonTrig);
  } 
  else {
    Printf("RunPerformanceTrain: AliAnalysisTaskTrigChEff - EXCLUDED!");
  }
  //
  // Muon Efficiency
  //
  if(iPWGPPperfMuonEff) {
  gROOT->LoadMacro("$ALICE_PHYSICS/PWG3/muondep/AddTaskMUONTrackingEfficiency.C");
  AliAnalysisTaskMuonTrackingEff *taskMuonTrackEff = AliAnalysisTaskMuonTrackingEff();
  if(!taskMuonTrackEff) { 
     Error("RunPerformanceTrain","AliAnalysisTaskMuonTrackingEff not created!");
     return;
  }
  mgr->AddTask(taskMuonTrackEff);
  } 
  else {
    Printf("RunPerformanceTrain: Muon Efficiency - EXCLUDED!");
  }
  //
  // TOF performance
  //
  if(iPWGPPperfTOF) {
  //
  } 
  else {
    Printf("RunPerformanceTrain: TOF - EXCLUDED!");
  }
  //
  // PWGPP Primary Vertex
  //
  if(iPWGPPperfPrimVertex) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskVertexESD.C");
    AliAnalysisTaskVertexESD *taskPrimVertex = AddTaskVertexESD();
    if(!taskPrimVertex) { 
      Error("RunPerformanceTrain","AliAnalysisTaskVertexESD not created!");
      return;
    }
  } 
  else {
    Printf("RunPerformanceTrain: AliAnalysisTaskVertexESD - EXCLUDED!");
  }
  //
  // PWGPP V0 QA
  //
  if (iPWGPPv0QA) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/macros/AddTaskV0QA.C");
    AliAnalysisTaskV0QA *taskv0QA = AddTaskV0QA(bUseMCInfo);
    if(!taskv0QA) {
      Error("RunPerformanceTrain","AliAnalysisTaskV0QA not created!");
      return;
    }    
  }
  else {
    Printf("RunPerformanceTrain: AliAnalysisTaskV0QA - EXCLUDED!");
  }

  //
  // Disable debug printouts
  //
  mgr->SetDebugLevel(0);

  if (!mgr->InitAnalysis())
    return;

  mgr->PrintStatus();
  //mgr->StartAnalysis("local",chain, nEvents, firstEvent);
  mgr->StartAnalysis("local",chain);
}
Example #28
0
void runAODFilterMC()
{
  // PROOF example

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

      bool bKineFilter = true;
      //      TProof::Mgr("alicecaf")->SetROOTVersion("v5-21-01-alice_dbg");
      TProof::Open("alicecaf");
      //      gProof->SetParallel(1);

      char *dataset = "/COMMON/COMMON/LHC08c11_10TeV_0.5T";
      //      char *dataset = "/PWG4/kleinb/LHC08q_jetjet100";
      // gProof->ClearPackages();
      gProof->UploadPackage("${ALICE_ROOT}/STEERBase.par");
      gProof->EnablePackage("STEERBase");
      gProof->UploadPackage("${ALICE_ROOT}/ESD.par");
      gProof->EnablePackage("ESD");
      gProof->UploadPackage("${ALICE_ROOT}/AOD.par");
      gProof->EnablePackage("AOD");
      gProof->UploadPackage("${ALICE_ROOT}/ANALYSIS.par");
      gProof->EnablePackage("ANALYSIS");
      gProof->UploadPackage("${ALICE_ROOT}/ANALYSISalice.par");
      gProof->EnablePackage("ANALYSISalice");
      
      //
      if (gApplication) gApplication->InitializeGraphics();
      // Create the chain
      //


	/////////////////////////////////////////////////////////////////////////////////// 
	// Create the analysis manager
	//
	// Input 
      AliESDInputHandler* inpHandler = new AliESDInputHandler();
      // Output
      AliAODHandler* aodHandler = new AliAODHandler();
      aodHandler->SetOutputFileName("aod_ckb2.root");
      // MC Truth
      AliMCEventHandler* mcHandler = new AliMCEventHandler();
      AliAnalysisManager *mgr  = new AliAnalysisManager("Filter Manager", "Filter Manager");
     if(bKineFilter){
       mgr->SetMCtruthEventHandler(mcHandler);
     }

      mgr->SetInputEventHandler  (inpHandler);
      mgr->SetOutputEventHandler (aodHandler);
      aodHandler->Dump();

      mgr->SetDebugLevel(10);

      // Filtering of MC particles (decays conversions etc)
      // this task is also needed to set the MCEventHandler
      // to the AODHandler, this will not be needed when
      // AODHandler goes to ANALYSISalice
      AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
      if(bKineFilter)mgr->AddTask(kinefilter);
      
      
      // 
      AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
      esdTrackCutsL->SetMinNClustersTPC(50);
      esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
      esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
      esdTrackCutsL->SetRequireTPCRefit(kTRUE);
      esdTrackCutsL->SetDCAToVertexZ(3.0);
      esdTrackCutsL->SetDCAToVertexXY(3.0);
      esdTrackCutsL->SetDCAToVertex2D(kTRUE);
      esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
      esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);

      AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
      esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
      
      AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
      trackFilter->AddCuts(esdTrackCutsL);
      trackFilter->AddCuts(esdTrackCutsITSsa);
      
      AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
      esdfilter->SetTrackFilter(trackFilter);
      
      mgr->AddTask(esdfilter);
    
    
      //
      // Create containers for input/output
      AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
      AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
      
      coutput1->SetSpecialOutput();

      if(bKineFilter){
	mgr->ConnectInput  (kinefilter,     0, cinput1  );
	mgr->ConnectOutput (kinefilter,     0, coutput1 );
	AliAnalysisDataContainer *coutputEx = mgr->CreateContainer("cFilterList", TList::Class(),
								   AliAnalysisManager::kOutputContainer,"pyxsec_hists.root");
	mgr->ConnectOutput (kinefilter,     1, coutputEx );
      }

	mgr->ConnectInput  (esdfilter,     0, cinput1  );
	mgr->ConnectOutput (esdfilter,     0, coutput1 );
      
      //
      // Run the analysis
      //    
      mgr->InitAnalysis();
      mgr->PrintStatus();
      mgr->StartAnalysis("proof",dataset,10000);

}
void RunSingleTrackEfficiencyTaskHFCJ()
{
    
    TBenchmark fBenchMark;
    fBenchMark.Start("AliCFSingleTrackEfficiencyTask");
    
    Load();
    
    if(fAnalysisMode=="grid"){
        //gSystem->Exec(Form("alien-token-init %s",fUsername.Data()));
        TGrid::Connect("alien://") ;
    }
    
    if(IsPlugin) {
        AliAnalysisGrid *alienHandler = CreateAlienHandler();
        if(!alienHandler) return;
    }
    
    printf("CREATE ANALYSIS MANAGER\n");
    AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");
    mgr->SetDebugLevel(10);
    if(IsPlugin) mgr->SetGridHandler(alienHandler);
    
    AliMCEventHandler*  mcHandler = new AliMCEventHandler();
    if (!readAOD) mgr->SetMCtruthEventHandler(mcHandler);
    
    AliInputEventHandler* dataHandler;
    if   (readAOD) dataHandler = new AliAODInputHandler();
    else           dataHandler = new AliESDInputHandler();
    mgr->SetInputEventHandler(dataHandler);
    
    if (!readAOD) {
        gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
        AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kTRUE);
    }
    
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AliAnalysisTaskSE *setupTask = AddTaskPIDResponse(kTRUE, kTRUE, kTRUE, 2, kFALSE, "", kTRUE, kFALSE, -1);
    
    if(ifTaskPIDQA){
        gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa.C");
        AliAnalysisTaskPIDqa *pidQA = AddTaskPIDqa();
    }
    
    printf("Prepare to create the task\n");
    gROOT->LoadMacro("./AddSingleTrackEfficiencyTaskDhCorrelations.C");
    
    //NCharge Filterbin0 + kFAST configuration + w/o external cut file
    AliCFSingleTrackEfficiencyTask *taskNchF0wFile  = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "NchFbit0woFile", AliPID::kPion, 0, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID, "", "");
    
    //NCharge Filterbin0 + kFAST configuration + w external cut file
    AliCFSingleTrackEfficiencyTask *taskNchF0  = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "NchFbit0", AliPID::kPion, 0, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID, "AssocPartCuts_Std_NewPoolsAndCode_10000Tr.root", "AssociatedTrkCuts");
    
    //Pion Filterbin0+ kFAST configuration + w external cut file
    AliCFSingleTrackEfficiencyTask *taskPionF0 = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "PionFbit0", AliPID::kPion, 211, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID,"AssocPartCuts_Std_NewPoolsAndCode_10000Tr.root", "AssociatedTrkCuts");
    
    //Kaons Filterbin0+ kFAST configuration + w external cut file
    AliCFSingleTrackEfficiencyTask *taskKaonF0 = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "KaonFbit0", AliPID::kKaon, 321, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID,"AssocPartCuts_Std_NewPoolsAndCode_10000Tr.root", "AssociatedTrkCuts");
    
    //Protons Filterbin0+ kFAST configuration + w external cut file
    AliCFSingleTrackEfficiencyTask *taskProtF0 = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "ProtonFbit0", AliPID::kProton, 2212, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID,"AssocPartCuts_Std_NewPoolsAndCode_10000Tr.root", "AssociatedTrkCuts");
    
    //Electron Filterbin0+ kFAST configuration + w external cut file
    AliCFSingleTrackEfficiencyTask *taskElecF0 = AddSingleTrackEfficiencyTaskDhCorrelations(kTRUE, "ElectronFbit0", AliPID::kElectron,11, AliVEvent::kAnyINT, kFALSE, AliCFSingleTrackEfficiencyTask::kFast, AliSingleTrackEffCuts::kNoBayesianPID, "AssocPartCuts_Std_NewPoolsAndCode_10000Tr.root", "AssociatedTrkCuts");
    
    
    
    // Run the analysis
    TChain * analysisChain=0;
    if(analysisChain) printf("CHAIN HAS %d ENTRIES\n",(Int_t)analysisChain->GetEntries());
    if(!mgr->InitAnalysis()) return;
    mgr->PrintStatus();
    if(fAnalysisMode=="grid" && !IsPlugin) fAnalysisMode="local";
    if(fAnalysisMode!="proof") {
        mgr->StartAnalysis(fAnalysisMode.Data(),analysisChain,nEntries,firstentry);
    }
    
    fBenchMark.Stop("AliCFSingleTrackEfficiencyTask");
    fBenchMark.Show("AliCFSingleTrackEfficiencyTask");
    
    return;
    
}
Example #30
0
void runLocal() {
  TStopwatch timer;
  timer.Start();
  
  gSystem->Load("libTree.so");
  //____________________________________________________//
  //_____________Setting up STEERBase.par_______________//
  //____________________________________________________//
  setupPar("STEERBase");
  gSystem->Load("libSTEERBase.so");

  //____________________________________________________//
  //_____________Setting up ESD.par_____________________//
  //____________________________________________________//
  setupPar("ESD");
  gSystem->Load("libVMC.so");
  gSystem->Load("libESD.so");
  //____________________________________________________//
  //_____________Setting up AOD.par_____________________//
  //____________________________________________________//
  setupPar("AOD");
  gSystem->Load("libAOD.so");
                                                                
  //_____________________________________________________________//
  //_____________Setting up ANALYSIS_NEW.par_____________________//
  //_____________________________________________________________//
  setupPar("ANALYSIS");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  
  //  gROOT->LoadMacro("../tasks/AliAnalysisTaskTotEt.cxx+");

  gSystem->AddIncludePath("-I$ALICE_ROOT/include");

  gROOT->LoadMacro("AliAnalysisTaskTotEt.cxx+g");

  //____________________________________________//
  AliTagAnalysis *TagAna = new AliTagAnalysis("ESD"); 
  TagAna->ChainLocalTags("../Tags");

  AliRunTagCuts *runCuts = new AliRunTagCuts();
  AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
  AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
  AliEventTagCuts *evCuts = new AliEventTagCuts();
  //   evCuts->SetMultiplicityRange(11,12);  
  evCuts->SetNPHOSClustersRange(0,100);  
  
  TChain* chain = 0x0;
  chain = TagAna->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
  //  chain->SetBranchStatus("*Calo*",0);
  
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TotEtManager");
  AliVEventHandler* esdH = new AliESDInputHandler;
  mgr->SetInputEventHandler(esdH);  
  
  AliAnalysisTaskTotEt *task1 = new AliAnalysisTaskTotEt("TaskTotEt");
  mgr->AddTask(task1);
  // Create containers for input/output
  AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain1", TChain::Class(),AliAnalysisManager::kInputContainer);
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist1", TH1::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.root");
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("chist2", TH1::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.root");
  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("chist3", TH1::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.root");
  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("chist4", TH1::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.root");
  AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("cnt", TNtuple::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.root");
  //  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("carray1", TClonesArray::Class(), AliAnalysisManager::kOutputContainer,"Pt.ESD.root");
    //____________________________________________//
  mgr->ConnectInput(task1,0,cinput1);
  mgr->ConnectOutput(task1,1,coutput1);
  mgr->ConnectOutput(task1,2,coutput2);
  mgr->ConnectOutput(task1,3,coutput3);
  mgr->ConnectOutput(task1,4,coutput4);
  mgr->ConnectOutput(task1,5,coutput5);
  //  mgr->ConnectOutput(task1,3,coutput4);

  mgr->SetDebugLevel(2);

  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  mgr->StartAnalysis("local",chain);

  timer.Stop();
  timer.Print();
}