Undoing some unwanted method renames
[u/mrichter/AliRoot.git] / PWGJE / macros / AddTaskFastEmbedding.C
CommitLineData
2cc9dfde 1
2AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(){
3
31b9d515 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 = 50.; Double_t maxPt = 100.;
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(50.,110.);
40 //task->SetEvtSelJetEtaRange(-0.4, 0.4); // smaller eta window for LHC10h pass1
41 task->SetEvtSelJetEtaRange(-0.5, 0.5);
42
43 task->SetTrackFilterMap(272);
44
45 // event selection
46 task->SetOfflineTrgMask(AliVEvent::kMB);
47 task->SetCentMin(0.);
48 task->SetCentMax(80.);
49
50 //task->SetVtxMin(-10.);
51 //task->SetVtxMax(10.);
52
53 mgr->AddTask(task);
54
55 // ## create the output containers ##
56 AliAnalysisDataContainer *coutputFastEmbedding = mgr->CreateContainer(
57 "fastembedding", TList::Class(), AliAnalysisManager::kOutputContainer,
5c4489e2 58 Form("%s:PWGJE_FastEmbedding", AliAnalysisManager::GetCommonFileName()));
31b9d515 59
60 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
61 mgr->ConnectOutput(task, 0, mgr->GetCommonOutputContainer());
62 mgr->ConnectOutput(task, 1, coutputFastEmbedding);
63
64
65 return task;
2cc9dfde 66
67}
68
69AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(TObjArray* aodarray){
70
31b9d515 71 AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding();
72 if(aodarray){
2cc9dfde 73 task->SetArrayOfAODPaths(aodarray);
74 task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kAODFull);
31b9d515 75 }
2cc9dfde 76
31b9d515 77 return task;
2cc9dfde 78}
79
80
1a2bb6d5 81AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(const char* filepath, Int_t mode = 0){
2cc9dfde 82
31b9d515 83 AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding();
84 if(strlen(filepath)){
85
86 if(mode==0){ // path to single AOD
87 task->SetAODPath(filepath);
88 }
89 if(mode==1){ // path to text file with list of paths of multiple AODs
90 Printf("Read aod paths from file %s", filepath);
91 TObjArray* array = new TObjArray();
92 TObjString* ostr = 0;
93 TString line;
94 ifstream in;
95 in.open(filepath);
96 while(in.good()){
97 in >> line;
e39a4f22 98 if(line.Length() == 0) continue;
99
31b9d515 100 Printf("found aod path %s", line.Data());
101 ostr = new TObjString(line.Data());
102 array->Add(ostr);
103 }
104 Printf("-> %d aod paths found", array->GetEntries());
105
106 task->SetArrayOfAODPaths(array);
107 }
e39a4f22 108 if(mode==2) { //read root file which contains object array
109 TFile *f = TFile::Open(filepath);
110 TObjArray *objarray;
111 f->GetObject("array",objarray);
112
113 Printf("-> %d aod paths found", objarray->GetEntries());
114
115 task->SetArrayOfAODPaths(objarray);
116
8ad1ea82 117
118 Int_t count = 0;
119 Int_t iEntry = -1;
120 Int_t iEntrySum = 0;
121 Int_t iEntryMax = 0;
122
123 TArrayI* array = new TArrayI();
124
125 for(int i=0; i<objarray->GetEntriesFast(); i++) {
67590be4 126 TObjString *objStr = (TObjString*) objarray->At(i);
8ad1ea82 127 TString str = objStr->GetString();
128 iEntry = str.Atoi();
129 array->Set(count+1);
130 array->AddAt(iEntry,count);
131 count++;
132 iEntrySum += iEntry;
133 if(iEntry>iEntryMax) iEntryMax = iEntry;
134 }
135
136 task->SetArrayOfAODEntries(array);
137 task->SetAODEntriesSum(iEntrySum);
138 task->SetAODEntriesMax(iEntryMax);
139
e39a4f22 140 }
31b9d515 141
142 task->SetEmbedMode(AliAnalysisTaskFastEmbedding::kAODFull);
143 }
144
145 return task;
146}
147
148AliAnalysisTaskFastEmbedding* AddTaskFastEmbedding(const char* aodpath, const char* entriespath){
149
150 AliAnalysisTaskFastEmbedding *task = AddTaskFastEmbedding(aodpath, 1);
151
152 Printf("Read entries of aod files from %s", entriespath);
153 TArrayI* array = new TArrayI();
154 Int_t count = 0;
155 Int_t iEntry = -1;
156 Int_t iEntrySum = 0;
157 Int_t iEntryMax = 0;
158 TString line;
159 ifstream in;
160 in.open(entriespath);
161 while(in.good()){
162 in >> line;
163 iEntry = line.Atoi();
164
165 array->Set(count+1);
166 array->AddAt(iEntry,count);
167 count++;
168 iEntrySum += iEntry;
169 if(iEntry>iEntryMax) iEntryMax = iEntry;
170 }
171
172 task->SetArrayOfAODEntries(array);
173 task->SetAODEntriesSum(iEntrySum);
174 task->SetAODEntriesMax(iEntryMax);
175
176 return task;
2cc9dfde 177}
178