adding the option for hybrid tracks global+global constrained as well as global+TPC...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskFastEmbedding.C
1
2 AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(){
3
4     AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
5     if(!mgr){
6         ::Error("AddTaskCentralitySelection", "No analysis manager to connect ot.");
7         return NULL;
8     }
9     if(!mgr->GetInputEventHandler()){
10         ::Error("AddTaskCentralitySelection", "This task requires an input event handler.");
11         return NULL;
12     }
13
14
15     AliAnalysisTaskFastEmbedding *task = new AliAnalysisTaskFastEmbedding("FastEmbedding");
16     // ## set embedding mode ##
17     // kAODFull=0, kAODJetTracks, kAODJet4Mom, kToySingle4Mom
18     task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kToyTracks);
19
20     // ## set ranges for toy ##
21     //SetToyTrackRanges(
22     Double_t minPt = 20.;   Double_t maxPt = 200.;
23     Double_t minEta = -0.5; Double_t maxEta = 0.5;
24     //Double_t minEta = -0.4; Double_t maxEta = 0.4;  // for LHC10h pass1
25     Double_t minPhi = 0.;   Double_t maxPhi = 2*TMath::Pi();
26     //fToyDistributionTrackPt: 0 = uniform distribution
27     //                         else = exponential / power law (not implemented yet)
28     //task->SetToyNumberOfTrackRange(4,4);
29     //task->SetToyTrackRanges(0.15, 300., 5,-.9, .9, 0., 2*TMath::Pi());
30     task->SetToyTrackRanges(minPt,maxPt,0.,minEta,maxEta,minPhi,maxPhi);
31     task->SetToyFilterMap((1<<32)-1);
32
33     // ## set event selection for events of the addition AOD ##
34     // kEventsAll=0; kEventsJetPt
35     task->SetEvtSelecMode(AliAnalysisTaskFastEmbedding::kEventsJetPt);
36
37     // ## set jet pT range for event selection ##
38     // SetEvtSelJetPtRange(Float_t minPt, Float_t maxPt)
39     task->SetEvtSelJetPtRange(40.,-1.);
40     //task->SetEvtSelJetEtaRange(-0.4, 0.4); // smaller eta window for LHC10h pass1
41
42     mgr->AddTask(task);
43
44     // ## create the output containers ##
45     AliAnalysisDataContainer *coutputFastEmbedding = mgr->CreateContainer(
46          "fastembedding", TList::Class(), AliAnalysisManager::kOutputContainer,
47          Form("%s:PWG4_FastEmbedding", AliAnalysisManager::GetCommonFileName()));
48
49     mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
50     mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
51     mgr->ConnectOutput(task, 1, coutputFastEmbedding);
52
53
54     return task;
55
56 }
57
58 AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(TObjArray* aodarray){
59
60     AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding();
61     if(aodarray){
62       task->SetArrayOfAODPaths(aodarray);
63       task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kAODFull);
64     }
65
66     return task;
67 }
68
69
70 AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(const char* filepath, Int_t mode = 0){
71
72     AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding();
73     if(strlen(filepath)){
74
75        if(mode==0){ // path to single AOD
76           task->SetAODPath(filepath);
77        }
78        if(mode==1){ // path to text file with list of paths of multiple AODs
79            Printf("Read aod paths from file %s", filepath);
80            TObjArray* array = new TObjArray();
81            TObjString* ostr = 0;
82            TString line;
83            ifstream in;
84            in.open(filepath);
85            while(in.good()){
86               in >> line;
87               if(line.Length() == 0) continue;
88               Printf("found aod path %s", line.Data());
89               ostr = new TObjString(line.Data());
90               array->Add(ostr);
91            }
92            Printf("-> %d aod paths found", array->GetEntries());
93            
94            task->SetArrayOfAODPaths(array);
95        }
96
97        task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kAODFull);
98     }
99
100     return task;
101 }
102