New structure with AddTaskJets (D. Perrino)
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 15 Mar 2009 15:55:26 +0000 (15:55 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 15 Mar 2009 15:55:26 +0000 (15:55 +0000)
PWG4/macros/AddTaskJets.C [new file with mode: 0644]
PWG4/macros/AnalysisTrainCAF.C

diff --git a/PWG4/macros/AddTaskJets.C b/PWG4/macros/AddTaskJets.C
new file mode 100644 (file)
index 0000000..8751b9c
--- /dev/null
@@ -0,0 +1,137 @@
+AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf)\r
+{\r
+// Creates a jet fider task, configures it and adds it to the analysis manager.\r
+\r
+   // Get the pointer to the existing analysis manager via the static access method.\r
+   //==============================================================================\r
+   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
+   if (!mgr) {\r
+      ::Error("AddTaskJets", "No analysis manager to connect to.");\r
+      return NULL;\r
+   }  \r
+   \r
+   // Check the analysis type using the event handlers connected to the analysis manager.\r
+   //==============================================================================\r
+   if (!mgr->GetInputEventHandler()) {\r
+      ::Error("AddTaskJets", "This task requires an input event handler");\r
+      return NULL;\r
+   }\r
+\r
+   // Create the task and configure it.\r
+   //===========================================================================\r
+   AliAnalysisTaskJets *jetana;\r
+   AliJetReader *er = 0;\r
+\r
+   switch (jr) {\r
+     case "MC":\r
+       AliJetKineReaderHeader *jrh = new AliJetKineReaderHeader();\r
+       jrh->SetComment("MC full Kinematics");\r
+       jrh->SetFastSimTPC(kFALSE);\r
+       jrh->SetFastSimEMCAL(kFALSE);\r
+       jrh->SetPtCut(0.);\r
+       jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0.9\r
+       // Define reader and set its header\r
+       er = new AliJetKineReader();\r
+       er->SetReaderHeader(jrh);\r
+       break;\r
+\r
+     case "ESD":\r
+       AliJetESDReaderHeader *jrh = new AliJetESDReaderHeader();\r
+       jrh->SetComment("Testing");\r
+       jrh->SetFirstEvent(0);\r
+       jrh->SetLastEvent(1000);\r
+       jrh->SetPtCut(0.);\r
+       jrh->SetReadSignalOnly(kFALSE);\r
+       // Define reader and set its header\r
+       er = new AliJetESDReader();\r
+       er->SetReaderHeader(jrh);\r
+       break;\r
+\r
+     case "AOD":\r
+       AliJetAODReaderHeader *jrh = new AliJetAODReaderHeader();\r
+       jrh->SetComment("AOD Reader");\r
+       jrh->SetPtCut(0.);\r
+       jrh->SetTestFilterMask(1<<0);\r
+       // Define reader and set its header\r
+       er = new AliJetAODReader();\r
+       er->SetReaderHeader(jrh);\r
+       break;\r
+\r
+        default:\r
+       ::Error("AddTaskJets", "Wrong jet reader selected\n");\r
+       return 0;\r
+   }\r
+\r
+    // Define jet header and jet finder\r
+   AliJetFinder *jetFinder = 0;\r
+   switch (jf) {\r
+     case "CDF":\r
+       AliCdfJetHeader *jh = new AliCdfJetHeader();\r
+       jh->SetRadius(0.7);\r
\r
+       jetFinder = new AliCdfJetFinder();\r
+       jetFinder->SetOutputFile("jets.root");\r
+      break;\r
+\r
+     case "DA":\r
+       AliDAJetHeader *jh=new AliDAJetHeader();\r
+       jh->SetComment("DA jet code with default parameters");\r
+       jh->SelectJets(kTRUE);\r
+       jh->SetNclust(10);\r
+\r
+       jetFinder = new AliDAJetFinder();\r
+       break;\r
+\r
+     case "Fastjet":\r
+       AliFastJetHeader *jh = new AliFastJetHeader();\r
+       jh->SetRparam(0.7); // setup parameters\r
+\r
+       jetFinder = new AliFastJetFinder();\r
+       jetFinder->SetOutputFile("jets.root");\r
+       break;\r
+\r
+     case "UA1":\r
+       AliUA1JetHeaderV1 *jh=new AliUA1JetHeaderV1();\r
+       jh->SetComment("UA1 jet code with default parameters");\r
+       jh->BackgMode(2);\r
+       jh->SetRadius(1.0);\r
+       jh->SetEtSeed(4.);\r
+       jh->SetLegoNbinPhi(432);\r
+       jh->SetLegoNbinEta(274);\r
+       jh->SetLegoEtaMin(-2);\r
+       jh->SetLegoEtaMax(+2);\r
+       jh->SetJetEtaMax(0.5);\r
+       jh->SetJetEtaMin(-0.5);\r
+       jh->SetMinJetEt(10.);\r
+\r
+       jetFinder = new AliUA1JetFinderV1();\r
+       break;\r
+\r
+     case default:\r
+       ::Error("AddTaskJets", "Wrong jet finder selected\n");\r
+       return 0;\r
+   }\r
+   if (jetFinder){\r
+       if (jh) jetFinder->SetJetHeader(jh);\r
+       if (er) jetFinder->SetJetReader(er);\r
+   }\r
+\r
+   jetana = new AliAnalysisTaskJets(Form("JetAnalysis%s%s",jr,jf));\r
+   AliAnalysisDataContainer *cout_jet = mgr->CreateContainer(Form("jethist%s%s",jr,jf), TList::Class(),\r
+                                                             AliAnalysisManager::kOutputContainer, Form("jethist%s_%s.root",jr,jf));\r
+   // Connect jet finder to task.\r
+   jetana->SetJetFinder(jetFinder);\r
+   jetana->SetConfigFile("");\r
+   jetana->SetDebugLevel(10);\r
+   mgr->AddTask(jetana);\r
+\r
+   // Create ONLY the output containers for the data produced by the task.\r
+   // Get and connect other common input/output containers via the manager as below\r
+   //==============================================================================\r
+   mgr->ConnectInput  (jetana, 0, mgr->GetCommonInputContainer());\r
+// AOD output slot will be used in a different way in future\r
+   mgr->ConnectOutput (jetana, 0, mgr->GetCommonOutputContainer());\r
+   mgr->ConnectOutput (jetana, 1, cout_jet);\r
+   \r
+   return jetana;\r
+}\r
index 772e082763f228e5190177069515ae4cb92827ab..89e2cb5c1eef1dc0a6b0d2d1746ebb2c662d2255 100644 (file)
-//______________________________________________________________________________
-void AnalysisTrainCAF(Int_t nEvents = 10000, Int_t nOffset = 0, char *ds = "/PWG4/kleinb/LHC08v_jetjet15-50")
-{
-// Example of running analysis train in CAF. To run in debug mode:
-//  - export ROOTSYS=debug  on your local client
-//  - un-comment gProof->ClearPackages()
-//  - un-comment lines with debugging info
-
-// WHY AOD is not a exchange container when running from ESD->AOD
-
-    Bool_t debug         = kTRUE;
-    Bool_t useMC         = kTRUE;
-    Bool_t readTR        = kFALSE;
-    Bool_t bPROOF        = kTRUE;
-
-
-    
-    Int_t iAODanalysis   = 0;
-    Int_t iAODhandler    = 1;
-    Int_t iESDfilter     = 1;  // Only active if iAODanalysis=0
-    Int_t iJETAN         = 1;
-    Int_t iJETANAOD      = 0;
-    Int_t iJETANMC       = 1;
-    Int_t iDIJETAN       = 0;
-    Int_t iPWG4SPECTRUM  = 1;
-    Int_t iPWG4UE        = 0;
-
-    if (iAODanalysis) {
-       useMC = kFALSE;
-       readTR = kFALSE;
-       iESDfilter = 0;
-       iMUONfilter = 0;
-    }    
-    if (iJETANAOD) iESDfilter=1;
-    if (iESDfilter) iAODhandler=1;
-
-    // Dataset from CAF
-    TString dataset(ds);
-    // CKB quick hack for local analysis
-    //    gROOT->LoadMacro("CreateESDChain.C");
-    // TChain *chain = CreateESDChain("jetjet15-50.txt",1000);
-    TChain *chain = 0;
-
-    printf("==================================================================\n");
-    printf("===========    RUNNING ANALYSIS TRAIN IN CAF MODE    =============\n");
-    printf("==================================================================\n");
-    if (iAODanalysis) printf("=  AOD analysis on dataset: %s\n", dataset.Data());
-    else              printf("=  ESD analysis on dataset: %s\n", dataset.Data());
-    if (iESDfilter)   printf("=  ESD filter                                                    =\n");
-    if (iJETAN)       printf("=  Jet analysis                                                  =\n");
-    if (iJETANAOD)    printf("=  Jet analysis from AOD                                        =\n");
-    if (iJETANMC)     printf("=  Jet analysis from Kinematics                                  =\n");
-    if (iDIJETAN)     printf("=  DiJet analysis                                                =\n");
-    if (iPWG4SPECTRUM)printf("=  PWG4 Jet spectrum analysis                                    =\n");
-    if (iPWG4UE)      printf("=  PWG4 UE                                                       =\n");
-    printf("==================================================================\n");
-    if (useMC) 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");
-    
-    // Load common libraries
-    gSystem->Load("libTree.so");
-    gSystem->Load("libGeom.so");
-    gSystem->Load("libVMC.so");
-    gSystem->Load("libPhysics.so");
-
-
-    // Reset user processes if CAF if not responding anymore
-    // TProof::Reset("alicecaf"); 
-    // One may enable a different ROOT version on CAF
-
-    //    const char* proofNode = "alicecaf";
-    const char* proofNode = "localhost";
-
-
-
-
-    // Connect to proof
-    if(bPROOF){
-      TProof::Mgr(proofNode)->ShowROOTVersions();
-      //      TProof::Mgr(proofNode)->SetROOTVersion("v5-21-01-alice_dbg");
-      TProof::Open(proofNode); 
-
-      // Clear packages if changing ROOT version on CAF or local
-      //      gProof->ClearPackages();
-      // Enable proof debugging if needed
-      //    gProof->SetLogLevel(5);
-      // To debug the train in PROOF mode, type in a root session:
-      // root[0] TProof::Mgr("lxb6064")->GetSessionLogs()->Display("*",0,10000);
-      // Common packages
-      // --- Enable the STEERBase Package
-      gProof->UploadPackage("${ALICE_ROOT}/STEERBase.par");
-      gProof->EnablePackage("STEERBase");
-      // --- Enable the ESD Package
-      gProof->UploadPackage("${ALICE_ROOT}/ESD.par");
-      gProof->EnablePackage("ESD");
-      // --- Enable the AOD Package
-      gProof->UploadPackage("${ALICE_ROOT}/AOD.par");
-      gProof->EnablePackage("AOD");
-      // --- Enable the ANALYSIS Package
-      gProof->UploadPackage("${ALICE_ROOT}/ANALYSIS.par");
-      gProof->EnablePackage("ANALYSIS");
-      // --- Enable the ANALYSISalice Package
-      gProof->UploadPackage("${ALICE_ROOT}/ANALYSISalice.par");
-      gProof->EnablePackage("ANALYSISalice");
-
-
-      // --- Enable the JETAN Package
-      if (iJETAN||iJETANMC) {
-       gProof->UploadPackage("${ALICE_ROOT}/JETAN.par");
-       gProof->EnablePackage("JETAN");
-      }   
-      // --- Enable particle correlation analysis
-      if (iPWG4UE||iPWG4SPECTRUM) {
-       gProof->UploadPackage("${ALICE_ROOT}/PWG4JetTasks.par");
-       gProof->EnablePackage("PWG4JetTasks");
-      }   
-
-    }
-    else{
-      gSystem->Load("libSTEERBase");
-      gSystem->Load("libESD");
-      gSystem->Load("libAOD");
-      gSystem->Load("libANALYSIS");
-      gSystem->Load("libANALYSISalice");
-
-
-      // --- Enable the JETAN Package
-      if (iJETAN||iJETANMC||iJETANAOD) gSystem->Load("libJETAN");
-      // --- Enable particle correlation analysis
-      if (iPWG4UE||iPWG4SPECTRUM)gSystem->Load("libPWG4JetTasks");  
-    }
-
-
-    // Make the analysis manager
-    AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "A test setup for the analysis train");
-    if (iAODanalysis) {
-    // AOD input handler
-       AliAODInputHandler *aodH = new AliAODInputHandler();
-       mgr->SetInputEventHandler(aodH);
-    } else {   
-    // ESD input handler
-       AliESDInputHandler *esdHandler = new AliESDInputHandler();
-       mgr->SetInputEventHandler(esdHandler);
-//       esdHandler->SetInactiveBranches("FMD CaloCluster");
-    }
-    // Monte Carlo handler
-    if (useMC && !iAODanalysis) {
-       AliMCEventHandler* mcHandler = new AliMCEventHandler();
-       mgr->SetMCtruthEventHandler(mcHandler);
-       mcHandler->SetReadTR(readTR); 
-    }   
-    // Top container for input 
-    AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
-    
-    // This container is managed by the AOD handler
-    AliAnalysisDataContainer *cout_aod = 0;
-    if (iAODhandler) {
-       // AOD output handler
-       AliAODHandler* aodHandler   = new AliAODHandler();
-       aodHandler->SetFillAOD(kFALSE);
-       mgr->SetOutputEventHandler(aodHandler);       
-       aodHandler->SetOutputFileName(Form("AliAODs_pwg4_%07d-%07d.root",nOffset,nOffset+nEvents));
-       cout_aod = mgr->GetCommonOutputContainer();
-       cout_aod->SetSpecialOutput();
-    }   
-
-    // Debugging if needed
-    if (debug) mgr->SetDebugLevel(0);
-//    AliLog::EnableDebug(kTRUE);
-    AliLog::SetGlobalLogLevel(0);
-
-
-    if (iESDfilter && !iAODanalysis) {
-       // Set of cuts plugged into the ESD filter
-       // 
-       // standard
-       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->SetMinNsigmaToVertex(3);
-       esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);
-       esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
-       //
-       AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
-       trackFilter->AddCuts(esdTrackCutsL);
-       //
-       // ESD filter task putting standard info to output AOD (with cuts)
-       AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
-       esdfilter->SetTrackFilter(trackFilter);
-       esdfilter->SetDebugLevel(10);
-       mgr->AddTask(esdfilter);
-       // Connect to data containers
-       mgr->ConnectInput  (esdfilter,  0, cinput  );
-       mgr->ConnectOutput (esdfilter,  0, cout_aod );
-    }   
-    // Jet analysis
-    AliAnalysisDataContainer *c_aodjet = 0;
-    if (iJETAN && !iAODanalysis) {
-       AliAnalysisTaskJets *jetana = new AliAnalysisTaskJets("JetAnalysis");
-       jetana->SetDebugLevel(10);
-       jetana->SetConfigFile("${ALICE_ROOT}/JETAN/ConfigJetAnalysis.C");
-       mgr->AddTask(jetana);
-       // Output histograms list for jet analysis                       
-       AliAnalysisDataContainer *cout_jet = mgr->CreateContainer("jethist", TList::Class(),
-                                                                AliAnalysisManager::kOutputContainer,Form("jethist_%07d-%07d.root",nOffset,nOffset+nEvents));
-       // Dummy AOD output container for jet analysis (no client yet)
-       c_aodjet = mgr->CreateContainer("cAODjet", TTree::Class(),
-                           AliAnalysisManager::kExchangeContainer);
-       // Connect to data containers
-       mgr->ConnectInput  (jetana,     0, cinput  );
-       mgr->ConnectOutput (jetana,     0, c_aodjet );
-       // mgr->ConnectOutput (jetana,     0, cout_aod );
-       mgr->ConnectOutput (jetana,     1, cout_jet );
-    }   
-    // JETANALYSIS from the AOD
-    if (iJETANAOD) {
-       AliAnalysisTaskJets *jetanaAOD = new AliAnalysisTaskJets("AODJetAnalysis");
-       jetanaAOD->SetDebugLevel(10);
-       jetanaAOD->SetNonStdBranch("jetsAOD");    
-       jetanaAOD->SetConfigFile("${ALICE_ROOT}/JETAN/ConfigJetAnalysisAOD.C");
-       mgr->AddTask(jetanaAOD);
-       // Output histograms list for jet analysis                       
-       AliAnalysisDataContainer *cout_jetAOD = mgr->CreateContainer("jethistAOD", TList::Class(),
-                                                                   AliAnalysisManager::kOutputContainer, Form("jethistAOD_%07d-%07d.root",nOffset,nOffset+nEvents));
-       // Dummy AOD output container for jet analysis (no client yet)
-       c_aodjet0 = mgr->CreateContainer("cAODjet0", TTree::Class(),
-                           AliAnalysisManager::kExchangeContainer);
-       // Connect to data containers
-       mgr->ConnectInput  (jetanaAOD,     0, cout_aod  );
-       mgr->ConnectOutput (jetanaAOD,     0, c_aodjet0 );
-       // mgr->ConnectOutput (jetana,     0, cout_aod );
-       mgr->ConnectOutput (jetanaAOD,     1, cout_jetAOD );
-    }   
-    // Jet analysisMC
-    AliAnalysisDataContainer *c_aodjetMC = 0;
-    if (iJETANMC && useMC) {
-       AliAnalysisTaskJets *jetanaMC = new AliAnalysisTaskJets("JetAnalysisMC");
-       jetanaMC->SetDebugLevel(10);
-       jetanaMC->SetConfigFile("${ALICE_ROOT}/JETAN/ConfigJetAnalysisMC.C");
-       jetanaMC->SetNonStdBranch("jetsMC");
-       mgr->AddTask(jetanaMC);
-       // Output histograms list for jet analysis                       
-       AliAnalysisDataContainer *cout_jetMC = mgr->CreateContainer("jethistMC", TList::Class(),
-                                                                  AliAnalysisManager::kOutputContainer,Form("jethistMC_%07d-%07d.root",nOffset,nOffset+nEvents));
-       // Dummy AOD output container for jet analysis (no client yet)
-       c_aodjetMC = mgr->CreateContainer("cAODjetMC", TTree::Class(),
-                           AliAnalysisManager::kExchangeContainer);
-       // Connect to data containers
-       mgr->ConnectInput  (jetanaMC,     0, cinput  );
-       mgr->ConnectOutput (jetanaMC,     0, c_aodjetMC );
-       // mgr->ConnectOutput (jetanaMC,     0, cout_aod );
-       mgr->ConnectOutput (jetanaMC,     1, cout_jetMC );
-    }   
-    // Dijet analysis
-    if(iDIJETAN){
-      AliAnalysisTaskDiJets *dijetana = new AliAnalysisTaskDiJets("DiJetAnalysis");
-      dijetana->SetDebugLevel(2);
-      
-      mgr->AddTask(dijetana);
-
-      //
-      // Create containers for input/output
-      AliAnalysisDataContainer *c_aod_dijet = mgr->CreateContainer("cAODdijet", TTree::Class(),
-                                                                  AliAnalysisManager::kExchangeContainer);
-      mgr->ConnectInput  (dijetana,  0, cinput  );
-      mgr->ConnectOutput (dijetana,  0, c_aod_dijet);
-    }
-
-
-    if (iPWG4SPECTRUM) {
-      AliAnalysisTaskJetSpectrum* pwg4spec = new  AliAnalysisTaskJetSpectrum("Jet Spectrum");
-      
-      // default parameters use a switch via iPWGSPECTRUM
-      // or a config file
-      pwg4spec->SetAnalysisType(AliAnalysisTaskJetSpectrum::kAnaMC);
-      //      if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);
-      pwg4spec->SetDebugLevel(11); 
-      //      pwg4spec->SetBranchRec("jetsMC"); 
-      //      pwg4spec->SetBranchGen("jetsMC"); 
-      mgr->AddTask(pwg4spec);
-
-      AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer("pwg4spec", TList::Class(),AliAnalysisManager::kOutputContainer,Form( "pwg4spec_%07d-%07d.root",nOffset,nOffset+nEvents));
-      // coutput1_Spec->SetSpecialOutput();
-      // Dummy AOD output container for jet analysis (no client yet)
-      c_aodSpec = mgr->CreateContainer("cAODjetSpec", TTree::Class(),
-                                       AliAnalysisManager::kExchangeContainer);
-      mgr->ConnectInput  (pwg4spec,  0, cinput);    
-      // mgr->ConnectInput  (pwg4spec,  0, c_aodjet);    
-      mgr->ConnectOutput (pwg4spec,  0, c_aodSpec );
-      mgr->ConnectOutput (pwg4spec,  1, coutput1_Spec );
-    }   
-
-    
-    // Particle correlation analysis
-    if (iPWG4UE) {
-      AliAnalysisTaskUE* ueana = new  AliAnalysisTaskUE("Underlying Event");
-      
-
-      // default parameters use a switch via iPWGUE
-      // or a config file
-      Int_t anaType =1; 
-      Int_t regType =1;
-      Double_t jetEtaCut=0.2;
-      Double_t trackPtCut=0.5; 
-      Double_t trackEtaCut= 0.9; 
-      Double_t rad=0.7; 
-      Double_t deltaPhiCut = 2.616;
-
-      ueana->SetDebugLevel(10); 
-      ueana->SetPtRangeInHist(25, 0., 250.);
-      ueana->SetAnaTopology(anaType);      
-      ueana->SetRegionType(regType);        
-      ueana->SetJet1EtaCut(jetEtaCut);     
-      ueana->SetTrackPtCut(trackPtCut); 
-      ueana->SetPtSumOrdering(2);
-      ueana->SetConeRadius(rad);   
-      ueana->SetTrackEtaCut(trackEtaCut);
-      ueana->SetJet2DeltaPhiCut(deltaPhiCut);
-      mgr->AddTask(ueana);
-
-
-      AliAnalysisDataContainer *coutput1_UE = mgr->CreateContainer("histosUE", TList::Class(),AliAnalysisManager::kOutputContainer, Form("pwg4UE_%07d-%07d.root",nOffset,nOffset+nEvents));
-
-      mgr->ConnectInput  (ueana,  0, cinput);    
-      //      mgr->ConnectInput  (ueana,  0, c_aodjet);    
-      mgr->ConnectOutput (ueana,     0, coutput1_UE );
-    }   
-
-    // Run the analysis
-    //    
-    if (mgr->InitAnalysis()) {
-       mgr->PrintStatus();
-       if(bPROOF)mgr->StartAnalysis("proof",dataset.Data(), nEvents,nOffset);
-       else mgr->StartAnalysis("local",chain);
-    }   
-}
+//______________________________________________________________________________\r
+void AnalysisTrainCAF(Int_t nEvents = 10000, Int_t nOffset = 0, char *ds = "/PWG4/kleinb/LHC08r_jetjet50")\r
+{\r
+// Example of running analysis train in CAF. To run in debug mode:\r
+//  - export ROOTSYS=debug  on your local client\r
+//  - un-comment gProof->ClearPackages()\r
+//  - un-comment lines with debugging info\r
+\r
+// WHY AOD is not a exchange container when running from ESD->AOD\r
+\r
+    Bool_t debug         = kTRUE;\r
+    Bool_t useMC         = kTRUE;\r
+    Bool_t readTR        = kFALSE;\r
+    Bool_t bPROOF        = kTRUE;\r
+\r
+\r
+    \r
+    Int_t iAODanalysis   = 0;\r
+    Int_t iAODhandler    = 1;\r
+    Int_t iESDfilter     = 1;  // Only active if iAODanalysis=0\r
+    Int_t iJETAN         = 1;\r
+    Int_t iJETANESD      = 0;\r
+    Int_t iJETANMC       = 0;\r
+    Int_t iDIJETAN       = 0;\r
+    Int_t iPWG4SPECTRUM  = 1;\r
+    Int_t iPWG4UE        = 0;\r
+\r
+    if (iAODanalysis) {\r
+       useMC = kFALSE;\r
+       readTR = kFALSE;\r
+       iESDfilter = 0;\r
+       iMUONfilter = 0;\r
+    }    \r
+    if (iJETAN) iESDfilter=1;\r
+    if (iESDfilter) iAODhandler=1;\r
+\r
+    // Dataset from CAF\r
+    TString dataset(ds);\r
+    // CKB quick hack for local analysis\r
+    //    gROOT->LoadMacro("CreateESDChain.C");\r
+    // TChain *chain = CreateESDChain("jetjet15-50.txt",1000);\r
+    TChain *chain = 0;\r
+\r
+    printf("==================================================================\n");\r
+    printf("===========    RUNNING ANALYSIS TRAIN IN CAF MODE    =============\n");\r
+    printf("==================================================================\n");\r
+    if (iAODanalysis) printf("=  AOD analysis on dataset: %s\n", dataset.Data());\r
+    else              printf("=  ESD analysis on dataset: %s\n", dataset.Data());\r
+    if (iESDfilter)   printf("=  ESD filter                                                    =\n");\r
+    if (iJETAN)       printf("=  Jet analysis from AOD                                         =\n");\r
+    if (iJETANESD)    printf("=  Jet analysis from ESD                                         =\n");\r
+    if (iJETANMC)     printf("=  Jet analysis from Kinematics                                  =\n");\r
+    if (iDIJETAN)     printf("=  DiJet analysis                                                =\n");\r
+    if (iPWG4SPECTRUM)printf("=  PWG4 Jet spectrum analysis                                    =\n");\r
+    if (iPWG4UE)      printf("=  PWG4 UE                                                       =\n");\r
+    printf("==================================================================\n");\r
+    if (useMC) printf(":: use MC    TRUE\n");\r
+    else       printf(":: use MC    FALSE\n");\r
+    if (readTR) printf(":: read TR   TRUE\n");\r
+    else        printf(":: read TR   FALSE\n");\r
+    if (debug) printf(":: debugging TRUE\n");\r
+    else       printf(":: debugging FALSE\n");\r
+    \r
+    // Load common libraries\r
+    gSystem->Load("libTree.so");\r
+    gSystem->Load("libGeom.so");\r
+    gSystem->Load("libVMC.so");\r
+    gSystem->Load("libPhysics.so");\r
+\r
+\r
+    // Reset user processes if CAF if not responding anymore\r
+    // TProof::Reset("alicecaf"); \r
+    // One may enable a different ROOT version on CAF\r
+\r
+    const char* proofNode = "alicecaf";\r
+\r
+\r
+\r
+\r
+    // Connect to proof\r
+    if(bPROOF){\r
+      TProof::Mgr(proofNode)->ShowROOTVersions();\r
+      //      TProof::Mgr(proofNode)->SetROOTVersion("v5-21-01-alice_dbg");\r
+      TProof::Open(proofNode); \r
+\r
+      // Clear packages if changing ROOT version on CAF or local\r
+      //      gProof->ClearPackages();\r
+      // Enable proof debugging if needed\r
+      //    gProof->SetLogLevel(5);\r
+      // To debug the train in PROOF mode, type in a root session:\r
+      // root[0] TProof::Mgr("lxb6064")->GetSessionLogs()->Display("*",0,10000);\r
+      // Common packages\r
+      // --- Enable the STEERBase Package\r
+      gProof->UploadPackage("${ALICE_ROOT}/STEERBase.par");\r
+      gProof->EnablePackage("STEERBase");\r
+      // --- Enable the ESD Package\r
+      gProof->UploadPackage("${ALICE_ROOT}/ESD.par");\r
+      gProof->EnablePackage("ESD");\r
+      // --- Enable the AOD Package\r
+      gProof->UploadPackage("${ALICE_ROOT}/AOD.par");\r
+      gProof->EnablePackage("AOD");\r
+      // --- Enable the ANALYSIS Package\r
+      gProof->UploadPackage("${ALICE_ROOT}/ANALYSIS.par");\r
+      gProof->EnablePackage("ANALYSIS");\r
+      // --- Enable the ANALYSISalice Package\r
+      gProof->UploadPackage("${ALICE_ROOT}/ANALYSISalice.par");\r
+      gProof->EnablePackage("ANALYSISalice");\r
+\r
+\r
+      // --- Enable the JETAN Package\r
+      if (iJETAN||iJETANESD||iJETANMC) {\r
+       gProof->UploadPackage("${ALICE_ROOT}/JETAN.par");\r
+       gProof->EnablePackage("JETAN");\r
+      }   \r
+      // --- Enable particle correlation analysis\r
+      if (iPWG4UE||iPWG4SPECTRUM) {\r
+       gProof->UploadPackage("${ALICE_ROOT}/PWG4JetTasks.par");\r
+       gProof->EnablePackage("PWG4JetTasks");\r
+      }   \r
+\r
+    }\r
+    else{\r
+      gSystem->Load("libSTEERBase");\r
+      gSystem->Load("libESD");\r
+      gSystem->Load("libAOD");\r
+      gSystem->Load("libANALYSIS");\r
+      gSystem->Load("libANALYSISalice");\r
+\r
+\r
+      // --- Enable the JETAN Package\r
+      if (iJETAN||iJETANESD||iJETANMC) gSystem->Load("libJETAN");\r
+      // --- Enable particle correlation analysis\r
+      if (iPWG4UE||iPWG4SPECTRUM)gSystem->Load("libPWG4JetTasks");  \r
+    }\r
+\r
+\r
+    // Make the analysis manager\r
+    AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "A test setup for the analysis train");\r
+    if (iAODanalysis) {\r
+    // AOD input handler\r
+       AliAODInputHandler *aodH = new AliAODInputHandler();\r
+       mgr->SetInputEventHandler(aodH);\r
+    } else {   \r
+    // ESD input handler\r
+       AliESDInputHandler *esdHandler = new AliESDInputHandler();\r
+       mgr->SetInputEventHandler(esdHandler);\r
+//       esdHandler->SetInactiveBranches("FMD CaloCluster");\r
+    }\r
+    // Monte Carlo handler\r
+    if (useMC && !iAODanalysis) {\r
+       AliMCEventHandler* mcHandler = new AliMCEventHandler();\r
+       mgr->SetMCtruthEventHandler(mcHandler);\r
+       mcHandler->SetReadTR(readTR); \r
+    }   \r
+    // Top container for input \r
+    AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();\r
+    \r
+    // This container is managed by the AOD handler\r
+    AliAnalysisDataContainer *cout_aod = 0;\r
+    if (iAODhandler) {\r
+       // AOD output handler\r
+       AliAODHandler* aodHandler   = new AliAODHandler();\r
+       aodHandler->SetFillAOD(kFALSE);\r
+       mgr->SetOutputEventHandler(aodHandler);       \r
+       aodHandler->SetOutputFileName(Form("AliAODs_pwg4_%07d-%07d.root",nOffset,nOffset+nEvents));\r
+       cout_aod = mgr->GetCommonOutputContainer();\r
+       cout_aod->SetSpecialOutput();\r
+    }   \r
+\r
+    // Debugging if needed\r
+    if (debug) mgr->SetDebugLevel(0);\r
+//    AliLog::EnableDebug(kTRUE);\r
+    AliLog::SetGlobalLogLevel(0);\r
+\r
+\r
+    if (iESDfilter && !iAODanalysis) {\r
+       // Set of cuts plugged into the ESD filter\r
+       // \r
+       // standard\r
+       AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");\r
+       esdTrackCutsL->SetMinNClustersTPC(50);   \r
+       esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);\r
+       esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
+       esdTrackCutsL->SetRequireTPCRefit(kTRUE);\r
+       esdTrackCutsL->SetMinNsigmaToVertex(3);\r
+       esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);\r
+       esdTrackCutsL->SetAcceptKingDaughters(kFALSE);\r
+       //\r
+       AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");\r
+       trackFilter->AddCuts(esdTrackCutsL);\r
+       //\r
+       // ESD filter task putting standard info to output AOD (with cuts)\r
+       AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");\r
+       esdfilter->SetTrackFilter(trackFilter);\r
+       esdfilter->SetDebugLevel(10);\r
+       mgr->AddTask(esdfilter);\r
+       // Connect to data containers\r
+       mgr->ConnectInput  (esdfilter,  0, cinput  );\r
+       mgr->ConnectOutput (esdfilter,  0, cout_aod );\r
+    }   \r
+    // Jet analysis from the AOD\r
+    AliAnalysisDataContainer *c_aodjet = 0;\r
+    if (iJETAN) {\r
+       gROOT->LoadMacro("AddTaskJets.C");\r
+       AliAnalysisTaskJets *jetanaAOD = AddTaskJets("AOD","UA1");\r
+    }   \r
+    // JETANALYSIS from the ESD\r
+    if (iJETANESD && !iAODanalysis) {\r
+       gROOT->LoadMacro("AddTaskJets.C");\r
+       AliAnalysisTaskJets *jetanaESD = AddTaskJets("ESD","UA1");\r
+       jetanaESD->SetDebugLevel(10);\r
+       jetanaESD->SetNonStdBranch("jetsESD");    \r
+    }   \r
+    // Jet analysisMC\r
+    AliAnalysisDataContainer *c_aodjetMC = 0;\r
+    if (iJETANMC && useMC) {\r
+       gROOT->LoadMacro("AddTaskJets.C");\r
+       AliAnalysisTaskJets *jetanaMC = AddTaskJets("MC","UA1");\r
+       jetanaMC->SetDebugLevel(10);\r
+       jetanaMC->SetNonStdBranch("jetsMC");\r
+    }   \r
+    // Dijet analysis\r
+    if(iDIJETAN){\r
+      AliAnalysisTaskDiJets *dijetana = new AliAnalysisTaskDiJets("DiJetAnalysis");\r
+      dijetana->SetDebugLevel(2);\r
+      \r
+      mgr->AddTask(dijetana);\r
+\r
+      //\r
+      // Create containers for input/output\r
+      AliAnalysisDataContainer *c_aod_dijet = mgr->CreateContainer("cAODdijet", TTree::Class(),\r
+                                                                  AliAnalysisManager::kExchangeContainer);\r
+      mgr->ConnectInput  (dijetana,  0, cinput  );\r
+      mgr->ConnectOutput (dijetana,  0, c_aod_dijet);\r
+    }\r
+\r
+\r
+    if (iPWG4SPECTRUM) {\r
+      AliAnalysisTaskJetSpectrum* pwg4spec = new  AliAnalysisTaskJetSpectrum("Jet Spectrum");\r
+      \r
+      // default parameters use a switch via iPWGSPECTRUM\r
+      // or a config file\r
+      pwg4spec->SetAnalysisType(AliAnalysisTaskJetSpectrum::kAnaMC);\r
+      //      if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);\r
+      pwg4spec->SetDebugLevel(11); \r
+      //      pwg4spec->SetBranchRec("jetsMC"); \r
+      //      pwg4spec->SetBranchGen("jetsMC"); \r
+      mgr->AddTask(pwg4spec);\r
+\r
+      AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer("pwg4spec", TList::Class(),AliAnalysisManager::kOutputContainer,Form( "pwg4spec_%07d-%07d.root",nOffset,nOffset+nEvents));\r
+      // coutput1_Spec->SetSpecialOutput();\r
+      // Dummy AOD output container for jet analysis (no client yet)\r
+      c_aodSpec = mgr->CreateContainer("cAODjetSpec", TTree::Class(),\r
+                                       AliAnalysisManager::kExchangeContainer);\r
+      mgr->ConnectInput  (pwg4spec,  0, cinput);    \r
+      // mgr->ConnectInput  (pwg4spec,  0, c_aodjet);    \r
+      mgr->ConnectOutput (pwg4spec,  0, c_aodSpec );\r
+      mgr->ConnectOutput (pwg4spec,  1, coutput1_Spec );\r
+    }   \r
+\r
+    \r
+    // Particle correlation analysis\r
+    if (iPWG4UE) {\r
+      AliAnalysisTaskUE* ueana = new  AliAnalysisTaskUE("Underlying Event");\r
+      \r
+\r
+      // default parameters use a switch via iPWGUE\r
+      // or a config file\r
+      Int_t anaType =1; \r
+      Int_t regType =1;\r
+      Double_t jetEtaCut=0.2;\r
+      Double_t trackPtCut=0.5; \r
+      Double_t trackEtaCut= 0.9; \r
+      Double_t rad=0.7; \r
+      Double_t deltaPhiCut = 2.616;\r
+\r
+      ueana->SetDebugLevel(10); \r
+      ueana->SetPtRangeInHist(25, 0., 250.);\r
+      ueana->SetAnaTopology(anaType);      \r
+      ueana->SetRegionType(regType);        \r
+      ueana->SetJet1EtaCut(jetEtaCut);     \r
+      ueana->SetTrackPtCut(trackPtCut); \r
+      ueana->SetPtSumOrdering(2);\r
+      ueana->SetConeRadius(rad);   \r
+      ueana->SetTrackEtaCut(trackEtaCut);\r
+      ueana->SetJet2DeltaPhiCut(deltaPhiCut);\r
+      mgr->AddTask(ueana);\r
+\r
+\r
+      AliAnalysisDataContainer *coutput1_UE = mgr->CreateContainer("histosUE", TList::Class(),AliAnalysisManager::kOutputContainer, Form("pwg4UE_%07d-%07d.root",nOffset,nOffset+nEvents));\r
+\r
+      mgr->ConnectInput  (ueana,  0, cinput);    \r
+      //      mgr->ConnectInput  (ueana,  0, c_aodjet);    \r
+      mgr->ConnectOutput (ueana,     0, coutput1_UE );\r
+    }   \r
+\r
+    // Run the analysis\r
+    //    \r
+    if (mgr->InitAnalysis()) {\r
+       mgr->PrintStatus();\r
+       if(bPROOF)mgr->StartAnalysis("proof",dataset.Data(), nEvents,nOffset);\r
+       else mgr->StartAnalysis("local",chain);\r
+    }   \r
+}\r