]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/EMCAL/macros/AddTaskEmcalClusterMaker.C
add exotic cluster remove switch to cluster maker
[u/mrichter/AliRoot.git] / PWG / EMCAL / macros / AddTaskEmcalClusterMaker.C
1 // $Id$
2
3 AliEmcalClusterMaker* AddTaskEmcalClusterMaker(
4   const UInt_t nonLinFunct   = AliEMCALRecoUtils::kBeamTestCorrected,
5   const Bool_t remExClus     = kTRUE,
6   const char *nClusters      = 0,
7   const char *outClusName    = "EmcCaloClusters",
8   const Double_t emin        = 0.3,
9   const Bool_t   histo       = kFALSE,
10   const char *outputname     = "AnalysisResults.root"
11 )
12 {  
13   // Get the pointer to the existing analysis manager via the static access method.
14   //==============================================================================
15   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
16   if (!mgr)
17   {
18     ::Error("AddTaskHadCorr", "No analysis manager to connect to.");
19     return NULL;
20   }  
21   
22   // Check the analysis type using the event handlers connected to the analysis manager.
23   //==============================================================================
24   if (!mgr->GetInputEventHandler())
25   {
26     ::Error("AddTaskHadCorr", "This task requires an input event handler");
27     return NULL;
28   }
29
30   TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
31   if (nClusters==0) {
32     if (inputDataType != "ESD")
33       nClusters = "caloClusters";
34     else 
35       nClusters = "CaloClusters";
36   }
37   
38   //-------------------------------------------------------
39   // Init the task and do settings
40   //-------------------------------------------------------
41
42   TString name(Form("EmcalClusterMaker_%s_%s", nClusters, outClusName));
43   AliEmcalClusterMaker *ecm = new AliEmcalClusterMaker(name, histo);
44   ecm->SetOutClusName(outClusName);
45   AliEMCALRecoUtils *ru = new AliEMCALRecoUtils;
46   ru->SetNonLinearityFunction(nonLinFunct);
47   if(remExClus) ru->SwitchOnRejectExoticCluster();
48   ecm->SetRecoUtils(ru);
49   AliClusterContainer *clusCont = ecm->AddClusterContainer(nClusters);
50   clusCont->SetClusECut(emin);
51
52   //-------------------------------------------------------
53   // Final settings, pass to manager and set the containers
54   //-------------------------------------------------------
55
56   mgr->AddTask(ecm);
57     
58   // Create containers for input/output
59   mgr->ConnectInput (ecm, 0, mgr->GetCommonInputContainer());
60
61   if (histo) {
62     AliAnalysisDataContainer *coecm = mgr->CreateContainer(name,
63                                                            TList::Class(),
64                                                            AliAnalysisManager::kOutputContainer,
65                                                            outputname);
66     mgr->ConnectOutput(ecm,1,coecm);
67   }
68     
69   return ecm;
70 }