]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/macros/AddTaskHadCorr.C
Protection against re-initialization of histograms if not already
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskHadCorr.C
CommitLineData
804ae415 1// $Id$
b2de6a89 2
25283b37 3AliHadCorrTask* AddTaskHadCorr(
9b9955ea 4 const char *nTracks = "EmcalTracks",
5 const char *nClusters = "EmcalClusters",
e61400a6 6 const char *outClusName = "CaloClustersCorr",
b2de6a89 7 const Double_t hadcorr = 1,
8 const Double_t minPt = 0.15,
ab601ed1 9 const Double_t phiMatch = 0.050,
10 const Double_t etaMatch = 0.025,
b72edd5f 11 const Double_t Eexcl = 0,
12 const Bool_t trackClus = kTRUE,
13 const Bool_t histo = kFALSE,
14 const char *outputname = "AnalysisResults.root"
b2de6a89 15)
25283b37 16{
17 // Get the pointer to the existing analysis manager via the static access method.
18 //==============================================================================
19 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
20 if (!mgr)
21 {
22 ::Error("AddTaskHadCorr", "No analysis manager to connect to.");
23 return NULL;
24 }
25
26 // Check the analysis type using the event handlers connected to the analysis manager.
27 //==============================================================================
28 if (!mgr->GetInputEventHandler())
29 {
30 ::Error("AddTaskHadCorr", "This task requires an input event handler");
31 return NULL;
32 }
33
34 //-------------------------------------------------------
35 // Init the task and do settings
36 //-------------------------------------------------------
37
e61400a6 38 TString name(Form("HadCorr_%s", outClusName));
5d845887 39 AliHadCorrTask *hcor = new AliHadCorrTask(name, histo);
ab601ed1 40 hcor->SetOutClusName(outClusName);
41 hcor->SetPhiMatch(phiMatch);
42 hcor->SetEtaMatch(etaMatch);
b2de6a89 43 hcor->SetHadCorr(hadcorr);
b72edd5f 44 hcor->SetEexcl(Eexcl);
45 hcor->SetTrackClus(trackClus);
7cd832c7 46
47 AliParticleContainer *trackCont = hcor->AddParticleContainer(nTracks);
48 if (trackCont) trackCont->SetParticlePtCut(minPt);
49 AliParticleContainer *clusCont = hcor->AddParticleContainer(nClusters);
50 if (clusCont) clusCont->SetParticlePtCut(minPt);
25283b37 51
52 //-------------------------------------------------------
53 // Final settings, pass to manager and set the containers
54 //-------------------------------------------------------
55
56 mgr->AddTask(hcor);
57
58 // Create containers for input/output
59 mgr->ConnectInput (hcor, 0, mgr->GetCommonInputContainer() );
d41a0b1c 60
61 if (histo) {
62 AliAnalysisDataContainer *cohcor = mgr->CreateContainer(name,
63 TList::Class(),
64 AliAnalysisManager::kOutputContainer,
65 outputname);
66 mgr->ConnectOutput(hcor,1,cohcor);
67 }
25283b37 68
69 return hcor;
25283b37 70}