]>
Commit | Line | Data |
---|---|---|
6eebc585 | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | /* $Id$ */ | |
17 | ||
18 | // | |
19 | //----------------------------------------------------------------------------- | |
20 | /// \class AliAnalysisTaskNorm | |
21 | /// Analysis task for muon trigger normalization | |
22 | /// The output is a list of histograms and collections of counters. | |
23 | /// The macro class can run on AODs or ESDs. | |
24 | /// | |
25 | /// \author Cynthia Hadjidakis | |
26 | //----------------------------------------------------------------------------- | |
27 | ||
28 | #include "Riostream.h" | |
29 | ||
30 | //ROOT includes | |
31 | #include "TChain.h" | |
32 | #include "TGraph.h" | |
33 | ||
34 | //STEERBase includes | |
35 | #include "AliVEvent.h" | |
36 | ||
37 | //STEER includes | |
38 | #include "AliAODEvent.h" | |
39 | #include "AliESDEvent.h" | |
40 | #include "AliInputEventHandler.h" | |
41 | #include "AliCentrality.h" | |
42 | #include "AliAODTracklets.h" | |
43 | #include "AliCounterCollection.h" | |
44 | #include "AliTriggerConfiguration.h" | |
45 | ||
46 | //ANALYSIS includes | |
47 | #include "AliAnalysisManager.h" | |
48 | #include "AliAnalysisUtils.h" | |
49 | ||
50 | //PWGmuon include | |
51 | #include "AliMuonEventCuts.h" | |
52 | ||
53 | //PWGmuondep include | |
24690c33 | 54 | // #include "AliAnalysisTriggerScalers.h" |
6eebc585 | 55 | |
56 | #include "AliAnalysisTaskNorm.h" | |
57 | ||
58 | using std::cout; | |
59 | using std::endl; | |
60 | ||
61 | ClassImp(AliAnalysisTaskNorm) | |
62 | ||
63 | //________________________________________________________________________ | |
64 | AliAnalysisTaskNorm::AliAnalysisTaskNorm(const char *name) // All data members should be initialised here | |
65 | : AliAnalysisTaskSE(name), | |
66 | fRunCounters(0x0), | |
67 | fEventCounters(0x0), | |
68 | fListVertex(0x0), | |
69 | fListV0A(0x0), | |
70 | fListZN(0x0), | |
71 | fIsESD(kFALSE), | |
72 | fIsMC(kFALSE), | |
73 | fBeamConf(0), | |
74 | fMuonEventCuts(new AliMuonEventCuts("stdEventCuts","stdEventCuts")), | |
75 | fSCentEst(0x0), | |
76 | fCentBin(0), | |
77 | fSCentBin(0x0), | |
78 | fTrackletsBin(0), | |
79 | fSTrackletsBin(0x0), | |
80 | fV0AMultBin(0), | |
81 | fSV0AMultBin(0x0) | |
82 | { | |
83 | // Constructor | |
84 | // Define input and output slots here (never in the dummy constructor) | |
85 | // Input slot #0 works with a TChain - it is connected to the default input container | |
86 | DefineInput(0, TChain::Class()); | |
87 | // Output slot #1 writes into a AliCounterCollection | |
88 | DefineOutput(1, AliCounterCollection::Class()); | |
89 | // Output slot #2 writes into a AliCounterCollection | |
90 | DefineOutput(2, AliCounterCollection::Class()); | |
91 | // Output slot #3 writes into a TObjArray | |
92 | DefineOutput(3, TObjArray::Class()); | |
93 | // Output slot #4 writes into a TObjArray | |
94 | DefineOutput(4, TObjArray::Class()); | |
95 | // Output slot #5 writes into a TObjArray | |
96 | DefineOutput(5, TObjArray::Class()); | |
97 | ||
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | AliAnalysisTaskNorm::~AliAnalysisTaskNorm() | |
102 | { | |
103 | // Destructor. Clean-up the output list, but not the histograms that are put inside | |
104 | // (the list is owner and will clean-up these histograms). Protect in PROOF case. | |
105 | if ( !AliAnalysisManager::GetAnalysisManager()->IsProofMode() ) { | |
106 | if (fEventCounters) delete fEventCounters; | |
107 | if (fRunCounters) delete fRunCounters; | |
108 | if (fListVertex) delete fListVertex; | |
109 | if (fListV0A) delete fListV0A; | |
110 | if (fListZN) delete fListZN; | |
111 | } | |
112 | ||
113 | if (fSCentEst) delete fSCentEst; | |
114 | if (fSCentBin) delete fSCentBin; | |
115 | if (fSTrackletsBin) delete fSTrackletsBin; | |
116 | if (fSV0AMultBin) delete fSV0AMultBin; | |
117 | ||
118 | delete fMuonEventCuts; | |
119 | } | |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | void AliAnalysisTaskNorm::UserCreateOutputObjects() | |
123 | { | |
124 | ||
125 | //initialize centrality bins and estimators | |
126 | TString centEst[] = {"CL1","V0A","ZN","any"};//,"V0C","ZNA","ZNC"};//,"ZNA","ZNC","ZPA","ZPC"}; | |
127 | Int_t nCentEst = sizeof(centEst)/sizeof(centEst[0]); | |
128 | TString listOfCentEst = ""; | |
129 | ||
130 | fSCentEst = new TObjArray(nCentEst); | |
131 | fSCentEst->SetOwner(kTRUE); | |
132 | for (Int_t iCentEst = 0; iCentEst < nCentEst; iCentEst++) { | |
133 | TObjString *obj = new TObjString(centEst[iCentEst].Data()); | |
134 | fSCentEst->AddAt(obj,iCentEst); | |
135 | listOfCentEst += Form("%s",centEst[iCentEst].Data()); | |
136 | if ( iCentEst < nCentEst - 1 ) listOfCentEst += Form("/"); | |
137 | } | |
138 | ||
139 | Int_t centTabBin[] = {0,1,5,10,20,40,60,80,100}; | |
140 | Int_t nCentBin = sizeof(centTabBin)/sizeof(centTabBin[0]); | |
141 | nCentBin -= 1; | |
142 | fCentBin.Set(nCentBin+1, centTabBin); | |
143 | ||
144 | fSCentBin = new TObjArray(nCentBin); | |
145 | fSCentBin->SetOwner(kTRUE); | |
146 | ||
147 | Int_t min = 0 , max = 0; | |
148 | for ( Int_t iBin = 0; iBin < nCentBin+1; iBin++ ) { | |
149 | max = (Int_t)centTabBin[iBin]; | |
150 | if ( iBin >= 1 ) { | |
151 | TObjString *sobj = new TObjString(Form("%d-%d",min,max)); | |
152 | fSCentBin->AddAt(sobj,iBin-1); | |
153 | } | |
154 | min = (Int_t) centTabBin[iBin]; | |
155 | } | |
156 | ||
157 | TString listOfCentBin = ""; | |
158 | for (Int_t iBin = 0; iBin < nCentBin; iBin++) { | |
159 | TObjString *obj = (TObjString*) fSCentBin->At(iBin); | |
160 | if(obj) { | |
161 | listOfCentBin += Form("%s/",(obj->GetString()).Data()); | |
162 | } | |
163 | } | |
164 | listOfCentBin += "other/"; | |
165 | listOfCentBin += "any"; | |
166 | ||
167 | ||
168 | // Int_t trTabBin[] = {0,1,30,42,56,72,300}; | |
169 | Int_t trTabBin[] = {0,1,15,30,35,40,45,50,60,70,100,300}; | |
170 | Int_t nTrBin = sizeof(trTabBin)/sizeof(trTabBin[0]); | |
171 | nTrBin -= 1; | |
172 | fTrackletsBin.Set(nTrBin+1,trTabBin); | |
173 | ||
174 | fSTrackletsBin = new TObjArray(nTrBin); | |
175 | fSTrackletsBin->SetOwner(kTRUE); | |
176 | ||
177 | min = max = 0; | |
178 | for ( Int_t iBin = 0; iBin < nTrBin+1; iBin++ ) { | |
179 | max = trTabBin[iBin]; | |
180 | if ( iBin >= 1 ) { | |
181 | TObjString *sobj = new TObjString(Form("%d-%d",min,max)); | |
182 | fSTrackletsBin->AddAt(sobj,iBin-1); | |
183 | } | |
184 | min = trTabBin[iBin]; | |
185 | } | |
186 | TString listOfTrackletsBin = ""; | |
187 | for (Int_t iBin = 0; iBin < nTrBin; iBin++) { | |
188 | TObjString *obj = (TObjString*) fSTrackletsBin->At(iBin); | |
189 | if(obj) { | |
190 | listOfTrackletsBin += Form("%s/",(obj->GetString()).Data()); | |
191 | } | |
192 | } | |
193 | listOfTrackletsBin += "other"; | |
194 | ||
195 | // printf("%s\n",listOfTrackletsBin.Data()); | |
196 | Int_t v0AMultTabBin[] = {0,15,40,80,140,200,280,400,500,700}; | |
197 | Int_t nV0AMultBin = sizeof(v0AMultTabBin)/sizeof(v0AMultTabBin[0]); | |
198 | nV0AMultBin -= 1; | |
199 | fV0AMultBin.Set(nV0AMultBin+1,v0AMultTabBin); | |
200 | ||
201 | fSV0AMultBin = new TObjArray(nV0AMultBin); | |
202 | fSV0AMultBin->SetOwner(kTRUE); | |
203 | ||
204 | min = max = 0; | |
205 | for ( Int_t iBin = 0; iBin < nV0AMultBin+1; iBin++ ) { | |
206 | max = v0AMultTabBin[iBin]; | |
207 | if ( iBin >= 1 ) { | |
208 | TObjString *sobj = new TObjString(Form("%d-%d",min,max)); | |
209 | fSV0AMultBin->AddAt(sobj,iBin-1); | |
210 | } | |
211 | min = v0AMultTabBin[iBin]; | |
212 | } | |
213 | TString listOfV0AMultBin = ""; | |
214 | for (Int_t iBin = 0; iBin < nV0AMultBin; iBin++) { | |
215 | TObjString *obj = (TObjString*) fSV0AMultBin->At(iBin); | |
216 | if(obj) { | |
217 | listOfV0AMultBin += Form("%s/",(obj->GetString()).Data()); | |
218 | } | |
219 | } | |
220 | listOfV0AMultBin += "other"; | |
221 | ||
222 | // printf("%s\n",listOfV0AMultBin.Data()); | |
223 | ||
224 | //create event counters | |
225 | fEventCounters = new AliCounterCollection("eventCounters"); | |
226 | fEventCounters->AddRubric("run",1000000); | |
227 | fEventCounters->AddRubric("trigger",1000000); | |
228 | fEventCounters->AddRubric("norm", "MBinMB/MSLinMSL/MULinMUL/MSLinMB/MULinMSL/MULinMB/other/any"); | |
229 | fEventCounters->AddRubric("physsel", "yes/no"); | |
230 | fEventCounters->AddRubric("isspdpu", "n3d6/n3d8/n4d6/n4d8/n5d6/n5d8/n6d6/n6d8/multbinstd/mv/any"); | |
231 | // fEventCounters->AddRubric("ntracklets",listOfTrackletsBin.Data()); | |
232 | //fEventCounters->AddRubric("v0amult",listOfV0AMultBin.Data()); | |
233 | // fEventCounters->AddRubric("outofbunchpileup", "yes/no"); | |
234 | // fEventCounters->AddRubric("spdpu", "yes/no"); | |
235 | fEventCounters->AddRubric("centest",listOfCentEst.Data()); | |
236 | fEventCounters->AddRubric("centbin", listOfCentBin.Data()); | |
237 | fEventCounters->AddRubric("vertex", "yes/no"); | |
238 | fEventCounters->AddRubric("vertexcut", "abszb10/zbm10/zap10"); | |
239 | ||
240 | fEventCounters->Init(); | |
241 | ||
242 | //create run counters | |
243 | fRunCounters = new AliCounterCollection("runCounters"); | |
244 | fRunCounters->AddRubric("run",1000000); | |
245 | // fRunCounters->AddRubric("L0b",1000000); | |
246 | fRunCounters->AddRubric("l0brate",1000000); | |
247 | fRunCounters->AddRubric("l2a",1000000); | |
248 | fRunCounters->AddRubric("ncoll",1000000); | |
249 | fRunCounters->AddRubric("trigger",1000000); | |
250 | ||
251 | fRunCounters->Init(); | |
252 | ||
253 | //histograms for vertex | |
254 | fListVertex = new TObjArray(2000); | |
255 | fListVertex->SetOwner(); | |
256 | ||
257 | Float_t zrange = 50; | |
258 | Int_t nzbin = 1000, ncbin=150; | |
259 | Int_t npileup=20; | |
260 | ||
261 | TH1F* hVZMB = new TH1F("hVZMB"," primary vertex z (cm) for MB trigger",nzbin,-zrange,zrange); | |
262 | fListVertex->AddAtAndExpand(hVZMB, kVZMB); | |
263 | TH1F* hPileupVZMB = new TH1F("hPileupVZMB"," pile-up vertices z (cm) for MB trigger",nzbin,-zrange,zrange); | |
264 | fListVertex->AddAtAndExpand(hPileupVZMB, kPileupVZMB); | |
265 | TH1F* hVnMB = new TH1F("hVnMB"," number of vertex contributors for MB trigger",ncbin,0,ncbin); | |
266 | fListVertex->AddAtAndExpand(hVnMB, kVnCMB); | |
267 | TH1F* hNPileupMB = new TH1F("hNPileupMB"," number of pileup vertices for MB trigger",npileup,0,npileup); | |
268 | fListVertex->AddAtAndExpand(hNPileupMB, kNPileupMB); | |
269 | TH1F* hPileupVnMB = new TH1F("hPileupVnMB"," number of pileup vertices contributors for MB trigger",ncbin,0,ncbin); | |
270 | fListVertex->AddAtAndExpand(hPileupVnMB, kPileupnCMB); | |
271 | TH1F* hDeltaZMB = new TH1F("hDeltaZMB"," distance between primary vertex z and secondary vertices (cm) for MB trigger",nzbin,-zrange,zrange); | |
272 | fListVertex->AddAtAndExpand(hDeltaZMB, kDeltaZMB); | |
273 | ||
274 | TH1F* hVZMUL = new TH1F("hVZMUL"," primary vertex z (cm) for MUL trigger",nzbin,-zrange,zrange); | |
275 | fListVertex->AddAtAndExpand(hVZMUL, kVZMUL); | |
276 | TH1F* hPileupVZMUL = new TH1F("hPileupVZMUL"," pile-up vertices z (cm) for MUL trigger",nzbin,-zrange,zrange); | |
277 | fListVertex->AddAtAndExpand(hPileupVZMUL, kPileupVZMUL); | |
278 | TH1F* hVnMUL = new TH1F("hVnMUL"," number of contributors for MUL trigger",ncbin,0,ncbin); | |
279 | fListVertex->AddAtAndExpand(hVnMUL, kVnCMUL); | |
280 | TH1F* hNPileupMUL = new TH1F("hNPileupMUL"," number of pileup vertices for MUL trigger",npileup,0,npileup); | |
281 | fListVertex->AddAtAndExpand(hNPileupMUL, kNPileupMUL); | |
282 | TH1F* hPileupVnMUL = new TH1F("hPileupVnMUL"," number of pileup vertices contributors for MUL trigger",ncbin,0,ncbin); | |
283 | fListVertex->AddAtAndExpand(hPileupVnMUL, kPileupnCMUL); | |
284 | TH1F* hDeltaZMUL = new TH1F("hDeltaZMUL"," distance between primary vertex z and secondary vertices (cm) for MUL trigger",nzbin,-zrange,zrange); | |
285 | fListVertex->AddAtAndExpand(hDeltaZMUL, kDeltaZMUL); | |
286 | ||
287 | // histograms for V0A multiplicty | |
288 | fListV0A = new TObjArray(2000); | |
289 | fListV0A->SetOwner(); | |
290 | ||
291 | Int_t nV0Abin = 350; | |
292 | Float_t v0AMin = 0 , v0AMax = 700; | |
293 | Float_t centTabBin2[] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105}; | |
294 | Int_t nCentBin2 = sizeof(centTabBin2)/sizeof(centTabBin2[0]); | |
295 | nCentBin2--; | |
296 | Int_t nV0ACentBin = 105; | |
297 | Float_t v0ACentMin = 0, v0ACentMax = 105; | |
298 | ||
299 | TH1F* hV0AMultMB = new TH1F("hV0AMultMB"," V0A mutliplicity for CINT7 trigger",nV0Abin,v0AMin,v0AMax); | |
300 | fListV0A->AddAtAndExpand(hV0AMultMB, kV0AMB); | |
301 | TH1F* hV0AMultMUL = new TH1F("hV0AMultMUL"," V0A mutliplicity for CMUL7 trigger",nV0Abin,v0AMin,v0AMax); | |
302 | fListV0A->AddAtAndExpand(hV0AMultMUL, kV0AMUL); | |
303 | TH1F* hV0ACentMB = new TH1F("hV0ACentMB"," V0A centrality for CINT7 trigger",nV0ACentBin,v0ACentMin,v0ACentMax); | |
304 | fListV0A->AddAtAndExpand(hV0ACentMB, kV0ACentMB); | |
305 | TH1F* hV0ACentMUL = new TH1F("hV0ACentMUL"," V0A centrality for CMUL7 trigger",nV0ACentBin,v0ACentMin,v0ACentMax); | |
306 | fListV0A->AddAtAndExpand(hV0ACentMUL, kV0ACentMUL); | |
307 | TH2F* hV0AMultvsCentMB = new TH2F("hV0AMultvsCentMB"," V0A centrality vs multiplicity for CINT7 trigger",nV0Abin,v0AMin,v0AMax,200,0,200); | |
308 | fListV0A->AddAtAndExpand(hV0AMultvsCentMB, kV0AMultvsCentMB); | |
309 | TH2F* hV0ACentvsV0CCentMUL = new TH2F("hV0ACentvsV0CCentMUL"," V0A vs V0C centrality for CMUL7 trigger",nCentBin2,centTabBin2,nCentBin2,centTabBin2);//,centMin,centMax,nCent,centMin,centMax); | |
310 | hV0ACentvsV0CCentMUL->SetXTitle("V0A Event Multiplicity"); | |
311 | hV0ACentvsV0CCentMUL->SetYTitle("V0C Event Multiplicity"); | |
312 | fListV0A->AddAtAndExpand(hV0ACentvsV0CCentMUL, kV0ACentvsV0CCentMUL); | |
313 | TH2F* hV0ACentvsV0CCentMB = new TH2F("hV0ACentvsV0CCentMB"," V0A vs V0C centrality for CINT7 trigger",nCentBin2,centTabBin2,nCentBin2,centTabBin2);//,centMin,centMax,nCent,centMin,centMax); | |
314 | hV0ACentvsV0CCentMB->SetXTitle("V0A Event Multiplicity"); | |
315 | hV0ACentvsV0CCentMB->SetYTitle("V0C Event Multiplicity"); | |
316 | fListV0A->AddAtAndExpand(hV0ACentvsV0CCentMB, kV0ACentvsV0CCentMB); | |
317 | TH2F* hV0ACentvsCL1CentMUL = new TH2F("hV0ACentvsCL1CentMUL"," V0A vs CL1 centrality for CMUL7 trigger",nCentBin2,centTabBin2,nCentBin2,centTabBin2);//nCent,centMin,centMax,nCent,centMin,centMax); | |
318 | hV0ACentvsCL1CentMUL->SetXTitle("V0A Event Multiplicity"); | |
319 | hV0ACentvsCL1CentMUL->SetYTitle("CL1 Event Multiplicity"); | |
320 | fListV0A->AddAtAndExpand(hV0ACentvsCL1CentMUL, kV0ACentvsCL1CentMUL); | |
321 | TH2F* hV0ACentvsCL1CentMB = new TH2F("hV0ACentvsCL1CentMB"," V0A vs CL1 centrality for CINT7 trigger",nCentBin2,centTabBin2,nCentBin2,centTabBin2);//nCent,centMin,centMax,nCent,centMin,centMax); | |
322 | hV0ACentvsCL1CentMB->SetXTitle("V0A Event Multiplicity"); | |
323 | hV0ACentvsCL1CentMB->SetYTitle("CL1 Event Multiplicity"); | |
324 | fListV0A->AddAtAndExpand(hV0ACentvsCL1CentMB, kV0ACentvsCL1CentMB); | |
325 | TH2F* hV0CCentvsCL1CentMB = new TH2F("hV0CCentvsCL1CentMB"," V0C vs CL1 centrality for CINT7 trigger",nCentBin2,centTabBin2,nCentBin2,centTabBin2);//nCent,centMin,centMax,nCent,centMin,centMax); | |
326 | hV0CCentvsCL1CentMB->SetXTitle("V0C Event Multiplicity"); | |
327 | hV0CCentvsCL1CentMB->SetYTitle("CL1 Event Multiplicity"); | |
328 | fListV0A->AddAtAndExpand(hV0CCentvsCL1CentMB, kV0CCentvsCL1CentMB); | |
329 | ||
330 | ||
331 | // histograms for ZN multiplicity | |
332 | fListZN = new TObjArray(2000); | |
333 | fListZN->SetOwner(); | |
334 | ||
335 | Int_t nZNbin = 2100; | |
336 | Float_t zNMin = -100 , zNMax = 2000; | |
337 | Int_t nZNCentBin = 105; | |
338 | Float_t zNCentMin = 0, zNCentMax = 105; | |
339 | ||
340 | TH1F* hZNMultMB = new TH1F("hZNMultMB"," ZN mutliplicity for CINT7 trigger",nZNbin,zNMin,zNMax); | |
341 | fListZN->AddAtAndExpand(hZNMultMB, kZNMB); | |
342 | TH1F* hZNMultMUL = new TH1F("hZNMultMUL"," ZN mutliplicity for CMUL7 trigger",nZNbin,zNMin,zNMax); | |
343 | fListZN->AddAtAndExpand(hZNMultMUL, kZNMUL); | |
344 | TH1F* hZNCentMB = new TH1F("hZNCentMB"," ZN centrality distribution for CINT7 trigger",nZNCentBin,zNCentMin,zNCentMax); | |
345 | fListZN->AddAtAndExpand(hZNCentMB, kZNCentMB); | |
346 | TH1F* hZNCentMUL = new TH1F("hZNCentMUL"," ZN centrality distribution for CMUL7 trigger",nZNCentBin,zNCentMin,zNCentMax); | |
347 | fListZN->AddAtAndExpand(hZNCentMUL, kZNCentMUL); | |
348 | TH2F* hZNMultvsCentMB = new TH2F("hZNMultvsCentMB"," ZN centrality vs multiplicity for CINT7 trigger",nZNbin,zNMin,zNMax,250,-50,200); | |
349 | fListZN->AddAtAndExpand(hZNMultvsCentMB, kZNMultvsCentMB); | |
350 | ||
351 | ||
352 | PostData(1,fEventCounters); | |
353 | PostData(2,fRunCounters); | |
354 | PostData(3,fListVertex); | |
355 | PostData(4,fListV0A); | |
356 | PostData(5,fListZN); | |
357 | ||
358 | } | |
359 | ||
360 | //________________________________________________________________________ | |
361 | Bool_t AliAnalysisTaskNorm::IsAODEvent ( const AliVEvent* event ) | |
362 | { | |
363 | /// Check if event is from ESD or AOD | |
364 | return ( event->IsA() == AliAODEvent::Class() ); | |
365 | } | |
366 | ||
367 | //________________________________________________________________________ | |
368 | TString AliAnalysisTaskNorm::GetFiredTriggerClasses ( const AliVEvent* event ) | |
369 | { | |
370 | /// Check if track is from ESD or AOD | |
371 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetFiredTriggerClasses() : static_cast<const AliESDEvent*>(event)->GetFiredTriggerClasses(); | |
372 | } | |
373 | ||
374 | //_____________________________________________________________________________ | |
375 | void AliAnalysisTaskNorm::UserExec(Option_t *) | |
376 | { | |
377 | ||
378 | Bool_t keepEvent = fMuonEventCuts->IsSelected(fInputHandler); | |
379 | TString sListOfTrig = GetFiredTriggerClasses(InputEvent()); | |
380 | ||
381 | if ( DebugLevel() > 0 ) { | |
382 | AliInfo(Form("keepEvent %d - isEsd=%d - isMC=%d - beam conf = %s List of trigger=%s",keepEvent,fIsESD,fIsMC,fBeamConf.Data(),sListOfTrig.Data())); | |
383 | fMuonEventCuts->Print(); | |
384 | } | |
385 | ||
386 | if(!keepEvent) return; | |
387 | ||
388 | const TObjArray* selectedTrigClasses = fMuonEventCuts->GetSelectedTrigClassesInEvent(InputEvent()); | |
389 | ||
390 | AliAODEvent *aod = 0; | |
391 | AliESDEvent *esd = 0; | |
392 | if ( !fIsESD ){ | |
393 | aod = static_cast<AliAODEvent *>(InputEvent()); | |
394 | } | |
395 | else { | |
396 | esd = dynamic_cast<AliESDEvent *>(InputEvent()); | |
397 | } | |
398 | if ( !esd && !aod ){ | |
399 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
400 | return; | |
401 | } | |
402 | ||
403 | AliCentrality *centrality = ( fIsESD ) ? esd->GetCentrality() : aod->GetCentrality(); | |
404 | ||
405 | //Get list of normalization factor | |
406 | TList* normFactorList = BuildListOfNormFactor(selectedTrigClasses); | |
407 | //Get list of all triggers | |
408 | TList* triggerList = BuildListOfTrigger(selectedTrigClasses); | |
409 | //Get list of all centrality estimators + bins | |
410 | TList* centralityList = BuildListOfCentrality(centrality); | |
411 | //Get list of spd pile-up cases | |
412 | TList* spdPileUpList = BuildListOfPileUp((AliVEvent*)InputEvent()); | |
413 | //Get list of ntracklets | |
414 | TList* trackletsList = BuildListOfTracklets((AliVEvent*)InputEvent()); | |
415 | //Get list of V0A multiplicity bin | |
416 | TList* v0AMultList = BuildListOfV0AMult((AliVEvent*)InputEvent()); | |
417 | ||
418 | if ( DebugLevel() > 0 ){ | |
419 | Print(); | |
420 | cout<<"Trigger List"<<endl; | |
421 | triggerList->Print(); | |
422 | cout<<"Norm factor List"<<endl; | |
423 | normFactorList->Print(); | |
424 | cout<<"Centrality List"<<endl; | |
425 | centralityList->Print(); | |
426 | cout<<"Spd Pile-Up List"<<endl; | |
427 | spdPileUpList->Print(); | |
428 | cout<<"Tracklet List"<<endl; | |
429 | trackletsList->Print(); | |
430 | cout<<"V0AMult List"<<endl; | |
431 | v0AMultList->Print(); | |
432 | cout<<"Trigger Mask "<<(InputEvent())->GetTriggerMask()<<endl; | |
433 | } | |
434 | ||
435 | //Get run number | |
436 | Int_t runNr = ( (AliVEvent*) InputEvent() )->GetRunNumber(); | |
437 | ||
438 | //Get Phys Sel. | |
439 | Bool_t physSel = kFALSE; | |
440 | UInt_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()); | |
441 | if (isSelected) physSel = kTRUE; | |
442 | ||
443 | //Get out-of-bunch pile-up | |
444 | Bool_t outofbcpileup = kFALSE; | |
445 | AliAnalysisUtils analysisUtils; | |
446 | outofbcpileup = analysisUtils.IsOutOfBunchPileUp((AliVEvent*)InputEvent()); | |
447 | ||
448 | //vertex | |
449 | Bool_t isVertex = kFALSE; | |
450 | TString sVertexCut = ""; | |
451 | Int_t nVertexContributors = (((AliVEvent*) InputEvent() )->GetPrimaryVertex())->GetNContributors(); | |
452 | if (nVertexContributors > 0) isVertex = kTRUE; | |
453 | Double_t zVertex = (((AliVEvent*) InputEvent() )->GetPrimaryVertex())->GetZ(); | |
454 | if (TMath::Abs(zVertex) <= 10) sVertexCut = "vertexcut:abszb10"; | |
455 | else if (zVertex < -10) sVertexCut = "vertexcut:zbm10"; | |
456 | else if (zVertex > +10) sVertexCut = "vertexcut:zap10"; | |
457 | ||
458 | ||
459 | //Fill some histograms for the vertex (primary and secondary) | |
460 | if (physSel && isVertex && sVertexCut.Contains("abszb10") ) FillHistoPileUpVertices((AliVEvent*)InputEvent(),selectedTrigClasses); | |
461 | ||
462 | //Fill some control histograms for the multiplicity | |
463 | if (physSel) FillHistoMult((AliVEvent*)InputEvent(),selectedTrigClasses); | |
464 | ||
465 | //Fill event counters | |
466 | // FillEventCounters(runNr,triggerList,normFactorList,physSel,t0pileup,bgID); | |
467 | FillEventCounters(runNr,triggerList,normFactorList,centralityList,spdPileUpList,trackletsList,v0AMultList,physSel,isVertex,sVertexCut,outofbcpileup); | |
468 | ||
469 | //clean memory | |
470 | //DO NOT clean selectedTrigClasses, it is a constant | |
471 | delete normFactorList; | |
472 | delete triggerList; | |
473 | delete centralityList; | |
474 | delete spdPileUpList; | |
475 | delete trackletsList; | |
476 | delete v0AMultList; | |
477 | ||
478 | PostData(1, fEventCounters); | |
479 | PostData(2, fRunCounters); | |
480 | PostData(3, fListVertex); | |
481 | PostData(4, fListV0A); | |
482 | PostData(5, fListZN); | |
483 | ||
484 | return; | |
485 | ||
486 | } | |
487 | ||
488 | ||
489 | //_____________________________________________________________________________ | |
490 | void AliAnalysisTaskNorm::Terminate(Option_t *) | |
491 | { | |
492 | ||
493 | fEventCounters = dynamic_cast<AliCounterCollection *>(GetOutputData(1)); | |
494 | if (!fEventCounters) { AliError("Could not retrieve AliCounterCollection* fEventCounters"); return; } | |
495 | ||
496 | fRunCounters = dynamic_cast<AliCounterCollection *>(GetOutputData(2)); | |
497 | if (!fRunCounters) { AliError("Could not retrieve AliCounterCollection* fRunCounters"); return; } | |
498 | ||
499 | fListVertex = dynamic_cast<TObjArray *>(GetOutputData(3)); | |
500 | if (!fListVertex) { AliError("Could not retrieve TObjArray* fListVertex"); return; } | |
501 | ||
502 | fListV0A = dynamic_cast<TObjArray *>(GetOutputData(4)); | |
503 | if (!fListV0A) { AliError("Could not retrieve TObjArray* fListV0A"); return; } | |
504 | ||
505 | fListZN = dynamic_cast<TObjArray *>(GetOutputData(5)); | |
506 | if (!fListZN) { AliError("Could not retrieve TObjArray* fListZN"); return; } | |
507 | ||
508 | ||
509 | } | |
510 | ||
511 | ||
512 | //_____________________________________________________________________________ | |
513 | void AliAnalysisTaskNorm::Print(Option_t *) const | |
514 | { | |
515 | ||
516 | cout << ClassName() << " - " << GetName() << " - " << fIsESD <<" - "<< fIsMC << endl; | |
517 | ||
518 | } | |
519 | ||
520 | ||
521 | //_____________________________________________________________________________ | |
522 | void AliAnalysisTaskNorm::Print(TObjArray *obj) const | |
523 | { | |
524 | ||
525 | if (!obj) return; | |
526 | ||
527 | for ( Int_t itrig=0; itrig<obj->GetEntries(); ++itrig ) { | |
528 | TString sName = ((TObjString*)obj->At(itrig))->GetString(); | |
529 | cout<<sName<<" - "; | |
530 | } | |
531 | cout<<endl; | |
532 | ||
533 | } | |
534 | ||
535 | //________________________________________________________________________ | |
536 | void AliAnalysisTaskNorm::FillHistoPileUpVertices(const AliVEvent *event, const TObjArray *trigClass) | |
537 | { | |
538 | ||
539 | Bool_t isMB = kFALSE; | |
540 | Bool_t isMUL = kFALSE; | |
541 | ||
542 | for ( Int_t itrig = 0; itrig < trigClass->GetEntries(); itrig++ ) { | |
543 | TString sTrigClassName = ((TObjString*)trigClass->At(itrig))->GetString(); | |
544 | if ( sTrigClassName.Contains("CINT7-B-NOPF-ALLNOTRD") ) isMB = kTRUE; | |
545 | if ( sTrigClassName.Contains("CMUL7-B-NOPF-MUON") || sTrigClassName.Contains("CMUL7-B-NOPF-ALLNOTRD") ) isMUL = kTRUE; | |
546 | } | |
547 | ||
548 | // fill histo related to pileup vertices | |
549 | const AliAODEvent *aod = 0; | |
550 | const AliESDEvent *esd = 0; | |
551 | ||
552 | if ( !fIsESD ){ | |
553 | aod = static_cast<const AliAODEvent *>(event); | |
554 | } | |
555 | else { | |
556 | esd = dynamic_cast<const AliESDEvent *>(event); | |
557 | } | |
558 | if ( !esd && !aod ){ | |
559 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
560 | return; | |
561 | } | |
562 | ||
563 | Double_t zPV = 0; | |
564 | Int_t nContrPV = -1; | |
565 | ||
566 | //primary vertex | |
567 | AliVVertex *primaryVertex = (fIsESD) ? (AliVVertex*) esd->GetPrimaryVertexSPD() : (AliVVertex*) aod->GetPrimaryVertexSPD(); | |
568 | ||
569 | if (primaryVertex) { | |
570 | zPV = primaryVertex->GetZ(); | |
571 | nContrPV = primaryVertex->GetNContributors(); | |
572 | //printf("primary vertex: z= %.2f ncontr = %d\n",zPV,nContrPV); | |
573 | } | |
574 | if(isMB) { | |
575 | ((TH1F*)fListVertex->UncheckedAt(kVZMB))->Fill(zPV); | |
576 | ((TH1F*)fListVertex->UncheckedAt(kVnCMB))->Fill(nContrPV); | |
577 | } | |
578 | if (isMUL){ | |
579 | ((TH1F*)fListVertex->UncheckedAt(kVZMUL))->Fill(zPV); | |
580 | ((TH1F*)fListVertex->UncheckedAt(kVnCMUL))->Fill(nContrPV); | |
581 | } | |
582 | ||
583 | //pile-up vertices | |
584 | Int_t nPileUpVertices = (fIsESD) ? esd->GetNumberOfPileupVerticesSPD() : aod->GetNumberOfPileupVerticesSPD(); | |
585 | AliVVertex *pileupVertex = 0; | |
586 | ||
587 | if(isMB) ((TH1F*)fListVertex->UncheckedAt(kNPileupMB))->Fill(nPileUpVertices); | |
588 | if(isMUL) ((TH1F*)fListVertex->UncheckedAt(kNPileupMUL))->Fill(nPileUpVertices); | |
589 | ||
590 | Double_t zV = 0; | |
591 | Int_t nContr = -1; | |
592 | ||
593 | for (Int_t iV = 0; iV < nPileUpVertices; iV++) { | |
594 | zV = 0; | |
595 | nContr = -1; | |
596 | pileupVertex = (fIsESD) ? (AliVVertex*) esd->GetPileupVertexSPD(iV) : (AliVVertex*) aod->GetPileupVertexSPD(iV); | |
597 | if (!pileupVertex) continue; | |
598 | zV = pileupVertex->GetZ(); | |
599 | nContr = pileupVertex->GetNContributors(); | |
600 | //printf("pile-up vertex nr %d/%d: z= %.2f ncontr = %d\n",iV,nPileUpVertices,zV,nContr); | |
601 | if(isMB){ | |
602 | ((TH1F*)fListVertex->UncheckedAt(kPileupVZMB))->Fill(zV); | |
603 | ((TH1F*)fListVertex->UncheckedAt(kPileupnCMB))->Fill(nContr); | |
604 | ((TH1F*)fListVertex->UncheckedAt(kDeltaZMB))->Fill(zPV-zV); | |
605 | } | |
606 | if(isMUL){ | |
607 | ((TH1F*)fListVertex->UncheckedAt(kPileupVZMUL))->Fill(zV); | |
608 | ((TH1F*)fListVertex->UncheckedAt(kPileupnCMUL))->Fill(nContr); | |
609 | ((TH1F*)fListVertex->UncheckedAt(kDeltaZMUL))->Fill(zPV-zV); | |
610 | } | |
611 | } | |
612 | ||
613 | return; | |
614 | } | |
615 | ||
616 | //________________________________________________________________________ | |
617 | void AliAnalysisTaskNorm::FillHistoMult(const AliVEvent *event, const TObjArray *trigClass) | |
618 | { | |
619 | ||
620 | Bool_t isMB = kFALSE; | |
621 | Bool_t isMUL = kFALSE; | |
622 | ||
623 | for ( Int_t itrig = 0; itrig < trigClass->GetEntries(); itrig++ ) { | |
624 | TString sTrigClassName = ((TObjString*)trigClass->At(itrig))->GetString(); | |
625 | if ( sTrigClassName.Contains("CINT7-B-NOPF-ALLNOTRD") ) isMB = kTRUE; | |
626 | if ( sTrigClassName.Contains("CMUL7-B-NOPF-MUON") ) isMUL = kTRUE; | |
627 | } | |
628 | ||
629 | // fill histo related to V0A multiplicity | |
630 | AliAODEvent *aod = 0; | |
631 | AliESDEvent *esd = 0; | |
632 | ||
633 | if ( !fIsESD ){ | |
634 | aod = static_cast<AliAODEvent *> (const_cast<AliVEvent*> (event) ); | |
635 | } | |
636 | else { | |
637 | esd = dynamic_cast<AliESDEvent *> (const_cast<AliVEvent*> (event) ); | |
638 | } | |
639 | if ( !esd && !aod ){ | |
640 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
641 | return; | |
642 | } | |
643 | ||
644 | AliVVZERO *v0Data = (fIsESD) ? (AliVVZERO*) esd->GetVZEROData() : (AliVVZERO*) aod->GetVZEROData(); | |
645 | if ( !v0Data ) return; | |
646 | ||
647 | Float_t v0AMult = 0; | |
648 | for (Int_t i = 0 ; i < 32 ; i++) v0AMult += v0Data->GetMultiplicityV0A(i); | |
649 | ||
650 | AliCentrality *centrality = dynamic_cast<AliCentrality*> ( ( fIsESD ) ? esd->GetCentrality() : aod->GetCentrality() ); | |
651 | Float_t centVal = centrality->GetCentralityPercentileUnchecked("V0A"); | |
652 | Float_t centValV0C = centrality->GetCentralityPercentileUnchecked("V0C"); | |
653 | Float_t centValCL1 = centrality->GetCentralityPercentileUnchecked("CL1"); | |
654 | ||
655 | if(isMB) { | |
656 | ((TH1F*)fListV0A->UncheckedAt(kV0AMB))->Fill(v0AMult); | |
657 | ((TH1F*)fListV0A->UncheckedAt(kV0ACentMB))->Fill(centVal); | |
658 | ((TH2F*)fListV0A->UncheckedAt(kV0AMultvsCentMB))->Fill(v0AMult,centVal); | |
659 | ((TH2F*)fListV0A->UncheckedAt(kV0ACentvsV0CCentMB))->Fill(centVal,centValV0C); | |
660 | ((TH2F*)fListV0A->UncheckedAt(kV0ACentvsCL1CentMB))->Fill(centVal,centValCL1); | |
661 | ((TH2F*)fListV0A->UncheckedAt(kV0CCentvsCL1CentMB))->Fill(centValV0C,centValCL1); | |
662 | } | |
663 | if (isMUL){ | |
664 | ((TH1F*)fListV0A->UncheckedAt(kV0AMUL))->Fill(v0AMult); | |
665 | ((TH1F*)fListV0A->UncheckedAt(kV0ACentMUL))->Fill(centVal); | |
666 | ((TH2F*)fListV0A->UncheckedAt(kV0ACentvsV0CCentMUL))->Fill(centVal,centValV0C); | |
667 | ((TH2F*)fListV0A->UncheckedAt(kV0ACentvsCL1CentMUL))->Fill(centVal,centValCL1); | |
668 | } | |
669 | ||
670 | //Fill histo related to ZN multiplicity | |
671 | Double_t znaTower = 0.; // common PMT of ZNA | |
672 | Double_t zncTower = 0.; // common PMT of ZNC | |
673 | Bool_t znaFired = kFALSE; | |
674 | Bool_t zncFired = kFALSE; | |
675 | ||
676 | if (fIsESD) { | |
677 | AliESDZDC *esdZDC = esd->GetESDZDC(); | |
678 | if (esdZDC) { | |
679 | for (Int_t j = 0; j < 4; ++j) | |
680 | if (esdZDC->GetZDCTDCData(12,j) != 0) | |
681 | znaFired = kTRUE; | |
682 | ||
683 | for (Int_t j = 0; j < 4; ++j) | |
684 | if (esdZDC->GetZDCTDCData(10,j) != 0) | |
685 | zncFired = kTRUE; | |
686 | ||
687 | const Double_t *ZNAtower = esdZDC->GetZN2TowerEnergy(); | |
688 | const Double_t *ZNCtower = esdZDC->GetZN1TowerEnergy(); | |
689 | if (znaFired) znaTower = ZNAtower[0]; | |
690 | if (zncFired) zncTower = ZNCtower[0]; | |
691 | } | |
692 | } | |
693 | else { | |
694 | AliAODZDC *aodZDC = aod->GetZDCData(); | |
695 | if (aodZDC) { | |
696 | //this works only on full AOD | |
697 | const Double_t *ZNAtower = aodZDC->GetZNATowerEnergy(); | |
698 | const Double_t *ZNCtower = aodZDC->GetZNCTowerEnergy(); | |
699 | znaTower = ZNAtower[0]; | |
700 | zncTower = ZNCtower[0]; | |
701 | } | |
702 | } | |
703 | ||
704 | Double_t zNE = 0; | |
705 | ||
706 | if ( !fBeamConf.CompareTo("p-Pb") ) zNE = znaTower; | |
707 | else zNE = zncTower; | |
708 | ||
709 | centVal = 0; | |
710 | if ( !fBeamConf.CompareTo("p-Pb") ) centVal = centrality->GetCentralityPercentileUnchecked("ZNA"); | |
711 | else centVal = centrality->GetCentralityPercentileUnchecked("ZNC"); | |
712 | ||
713 | // AliInfo(Form("ZN energy %.2f centrality %.2f ",zNE,centVal)); | |
714 | ||
715 | if(isMB) { | |
716 | ((TH1F*)fListZN->UncheckedAt(kZNMB))->Fill(zNE); | |
717 | ((TH1F*)fListZN->UncheckedAt(kZNCentMB))->Fill(centVal); | |
718 | ((TH2F*)fListZN->UncheckedAt(kZNMultvsCentMB))->Fill(zNE,centVal); | |
719 | } | |
720 | if (isMUL){ | |
721 | ((TH1F*)fListZN->UncheckedAt(kZNMUL))->Fill(zNE); | |
722 | ((TH1F*)fListZN->UncheckedAt(kZNCentMUL))->Fill(centVal); | |
723 | } | |
724 | ||
725 | return; | |
726 | } | |
727 | ||
728 | //________________________________________________________________________ | |
729 | TList* AliAnalysisTaskNorm::BuildListOfPileUp(const AliVEvent *event) | |
730 | { | |
731 | /// build the list of different cases of spd pileup (different options) | |
732 | /// returned TList must be deleted by user | |
733 | ||
734 | TList* list = new TList(); | |
735 | list->SetOwner(); | |
736 | ||
737 | //add any | |
738 | list->AddLast(new TObjString("isspdpu:any")); | |
739 | ||
740 | //Get SPD pile-up (same bunch pile-up) | |
741 | const AliAODEvent *aod = 0; | |
742 | const AliESDEvent *esd = 0; | |
743 | ||
744 | if ( !fIsESD ){ | |
745 | aod = static_cast<const AliAODEvent *>(event); | |
746 | } | |
747 | else { | |
748 | esd = dynamic_cast<const AliESDEvent *>(event); | |
749 | } | |
750 | if ( !esd && !aod ){ | |
751 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
752 | return 0; | |
753 | } | |
754 | ||
755 | const Int_t nSpdPileUp = 10; | |
756 | Bool_t spdpileup[nSpdPileUp] = {kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE}; | |
757 | TString sSpdPileUp[nSpdPileUp] = {"n3d6","n3d8","n4d6","n4d8","n5d6","n5d8","n6d6","n6d8","multbinstd","mv"}; | |
758 | spdpileup[0] = ( fIsESD ) ? esd->IsPileupFromSPD(3,0.6,3.,2.,5.) : aod->IsPileupFromSPD(3,0.6,3.,2.,5.); | |
759 | spdpileup[1] = ( fIsESD ) ? esd->IsPileupFromSPD(3,0.8,3.,2.,5.) : aod->IsPileupFromSPD(3,0.8,3.,2.,5.); | |
760 | spdpileup[2] = ( fIsESD ) ? esd->IsPileupFromSPD(4,0.6,3.,2.,5.) : aod->IsPileupFromSPD(4,0.6,3.,2.,5.); | |
761 | spdpileup[3] = ( fIsESD ) ? esd->IsPileupFromSPD(4,0.8,3.,2.,5.) : aod->IsPileupFromSPD(4,0.8,3.,2.,5.); | |
762 | spdpileup[4] = ( fIsESD ) ? esd->IsPileupFromSPD(5,0.6,3.,2.,5.) : aod->IsPileupFromSPD(5,0.6,3.,2.,5.); | |
763 | spdpileup[5] = ( fIsESD ) ? esd->IsPileupFromSPD(5,0.8,3.,2.,5.) : aod->IsPileupFromSPD(5,0.8,3.,2.,5.); | |
764 | spdpileup[6] = ( fIsESD ) ? esd->IsPileupFromSPD(6,0.6,3.,2.,5.) : aod->IsPileupFromSPD(6,0.6,3.,2.,5.); | |
765 | spdpileup[7] = ( fIsESD ) ? esd->IsPileupFromSPD(6,0.8,3.,2.,5.) : aod->IsPileupFromSPD(6,0.8,3.,2.,5.); | |
766 | spdpileup[8] = kFALSE; | |
767 | AliAODTracklets *tracklets = dynamic_cast<AliAODTracklets*> ((fIsESD) ? 0 : aod->GetTracklets()); | |
768 | if (tracklets) { | |
769 | spdpileup[8] = ( fIsESD ) ? esd->IsPileupFromSPDInMultBins() : aod->IsPileupFromSPDInMultBins(); | |
770 | } | |
771 | ||
772 | AliAnalysisUtils analysis; | |
773 | spdpileup[9] = analysis.IsPileUpMV( const_cast<AliVEvent*> (event) ); | |
774 | ||
775 | // local SPDInMultBins function | |
776 | // spdpileup[9] = IsPileupFromSPDInMultBins(event); | |
777 | ||
778 | for ( Int_t iSpdPileUp = 0; iSpdPileUp < nSpdPileUp; iSpdPileUp++ ) { | |
779 | if (spdpileup[iSpdPileUp]) list->AddLast(new TObjString(Form("isspdpu:%s",sSpdPileUp[iSpdPileUp].Data()))); | |
780 | } | |
781 | ||
782 | return list; | |
783 | ||
784 | } | |
785 | ||
786 | //________________________________________________________________________ | |
787 | Bool_t AliAnalysisTaskNorm::IsPileupFromSPDInMultBins(const AliVEvent *event) const { | |
788 | ||
789 | const AliAODEvent *aod = 0; | |
790 | const AliESDEvent *esd = 0; | |
791 | ||
792 | if ( !fIsESD ){ | |
793 | aod = static_cast<const AliAODEvent *>(event); | |
794 | } | |
795 | else { | |
796 | esd = dynamic_cast<const AliESDEvent *>(event); | |
797 | } | |
798 | if ( !esd && !aod ){ | |
799 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
800 | return 0; | |
801 | } | |
802 | ||
803 | AliAODTracklets *tracklets = dynamic_cast<AliAODTracklets*> ((fIsESD) ? 0 : aod->GetTracklets()); | |
804 | if ( !tracklets) return kFALSE; | |
805 | ||
806 | Int_t nTracklets = (fIsESD) ? 0 : tracklets->GetNumberOfTracklets(); | |
807 | if(nTracklets<40) return (fIsESD) ? esd->IsPileupFromSPD(3,0.8) : aod->IsPileupFromSPD(3,0.8); | |
808 | else return (fIsESD) ? esd->IsPileupFromSPD(5,0.8) : aod->IsPileupFromSPD(5,0.8); | |
809 | ||
810 | } | |
811 | ||
812 | //________________________________________________________________________ | |
813 | TList* AliAnalysisTaskNorm::BuildListOfCentrality(AliCentrality *centrality) | |
814 | { | |
815 | /// build the list of centrality bins for each estimator | |
816 | /// returned TList must be deleted by user | |
817 | ||
818 | TList* list = new TList(); | |
819 | list->SetOwner(); | |
820 | ||
821 | if ( centrality ){ | |
822 | for ( Int_t iMethod = 0; iMethod < fSCentEst->GetEntriesFast(); iMethod++ ) { | |
823 | ||
824 | TString sMethod = ((TObjString*)fSCentEst->At(iMethod))->GetString(); | |
825 | TString sMethodCentrality; | |
826 | ||
827 | if ( !sMethod.CompareTo("any") ) { | |
828 | list->AddLast(new TObjString(Form("centest:any/centbin:any"))); | |
829 | continue; | |
830 | } | |
831 | ||
832 | //pA or Ap? | |
833 | if ( !sMethod.CompareTo("ZN") ) { | |
834 | if ( !fBeamConf.CompareTo("p-Pb") ) sMethodCentrality = "ZNA"; | |
835 | else sMethodCentrality = "ZNC"; | |
836 | } | |
837 | else sMethodCentrality = sMethod; | |
838 | ||
839 | Float_t centVal = centrality->GetCentralityPercentileUnchecked( sMethodCentrality.Data() ); | |
840 | // if (centVal == 0) centVal = -1; Now centval==0 goes to bin 0-5 | |
841 | if ( !sMethod.CompareTo("ZN") && centVal == 101 ) centVal = 100; | |
842 | Int_t centBin = -1; | |
843 | Int_t index = 0; | |
844 | while (centBin == -1 && index < fCentBin.GetSize()-1 ) { | |
845 | index++; | |
846 | if ( centVal >= 0 && centVal <= fCentBin.At(index) ) centBin = index - 1; | |
847 | } | |
848 | ||
849 | if(DebugLevel() > 0) { | |
850 | if (centBin !=-1) { | |
851 | TString sCentBin = ((TObjString*)fSCentBin->At(centBin))->GetString(); | |
852 | printf("test method %s-%s centrality %f bin found %d bin from centrality table %s\n",sMethod.Data(),sMethodCentrality.Data(),centVal,centBin, sCentBin.Data()); | |
853 | } | |
854 | else | |
855 | printf("test method %s centrality %f centbin:other \n",sMethod.Data(),centVal); | |
856 | } | |
857 | ||
858 | if (centBin == -1) { | |
859 | printf("test method %s centrality %f centbin:other \n",sMethod.Data(),centVal); | |
860 | list->AddLast(new TObjString(Form("centest:%s/centbin:other",sMethod.Data() ))); | |
861 | list->AddLast(new TObjString(Form("centest:%s/centbin:any",sMethod.Data()))); | |
862 | } | |
863 | else { | |
864 | //Add specific event centrality estimator and bin | |
865 | TString sCentBin = ((TObjString*)fSCentBin->At(centBin))->GetString(); | |
866 | list->AddLast(new TObjString(Form("centest:%s/centbin:%s",sMethod.Data(),sCentBin.Data()))); | |
867 | list->AddLast(new TObjString(Form("centest:%s/centbin:any",sMethod.Data()))); | |
868 | } | |
869 | } | |
870 | } | |
871 | ||
872 | return list; | |
873 | } | |
874 | ||
875 | ||
876 | ||
877 | //________________________________________________________________________ | |
878 | TList* AliAnalysisTaskNorm::BuildListOfV0AMult(const AliVEvent *event) { | |
879 | /// build the list of V0A multiplicity bins | |
880 | /// returned TList must be deleted by user | |
881 | ||
882 | TList* list = new TList(); | |
883 | list->SetOwner(); | |
884 | ||
885 | const AliAODEvent *aod = 0; | |
886 | const AliESDEvent *esd = 0; | |
887 | ||
888 | if ( !fIsESD ){ | |
889 | aod = static_cast<const AliAODEvent *>(event); | |
890 | } | |
891 | else { | |
892 | esd = dynamic_cast<const AliESDEvent *>(event); | |
893 | } | |
894 | if ( !esd && !aod ){ | |
895 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
896 | list->AddLast(new TObjString(Form("v0amult:other"))); | |
897 | return list; | |
898 | } | |
899 | ||
900 | AliVVZERO *v0Data = (fIsESD) ? (AliVVZERO*) esd->GetVZEROData() : (AliVVZERO*) aod->GetVZEROData(); | |
901 | if ( !v0Data ) { | |
902 | list->AddLast(new TObjString(Form("v0amult:other"))); | |
903 | return list; | |
904 | } | |
905 | ||
906 | Float_t v0AMult = 0; | |
907 | for (Int_t i = 0 ; i < 32 ; i++) v0AMult += v0Data->GetMultiplicityV0A(i); | |
908 | ||
909 | Int_t bin = -1, index = -1; | |
910 | ||
911 | while (bin == -1 && index < fV0AMultBin.GetSize()-1 ) { | |
912 | index++; | |
913 | if ( v0AMult >= 0 && v0AMult < fV0AMultBin.At(index) ) bin = index - 1; | |
914 | } | |
915 | ||
916 | if(DebugLevel() > 0) { | |
917 | if (bin !=-1) { | |
918 | TString sBin = ((TObjString*)fSV0AMultBin->At(bin))->GetString(); | |
919 | printf("test v0Amult %.2f bin found %d bin from v0AMult table %s\n",v0AMult,bin, sBin.Data()); | |
920 | } | |
921 | else | |
922 | printf("test v0AMult %.2f no bin\n",v0AMult); | |
923 | } | |
924 | ||
925 | if (bin == -1) { | |
926 | list->AddLast(new TObjString(Form("v0amult:other"))); | |
927 | } | |
928 | else { | |
929 | //Add specific event centrality estimator and bin | |
930 | TString sBin = ((TObjString*)fSV0AMultBin->At(bin))->GetString(); | |
931 | list->AddLast(new TObjString(Form("v0amult:%s",sBin.Data()))); | |
932 | } | |
933 | ||
934 | return list; | |
935 | } | |
936 | ||
937 | ||
938 | ||
939 | //________________________________________________________________________ | |
940 | TList* AliAnalysisTaskNorm::BuildListOfTracklets(const AliVEvent *event) { | |
941 | /// build the list of tracklets multiplicity bins | |
942 | /// returned TList must be deleted by user | |
943 | ||
944 | TList* list = new TList(); | |
945 | list->SetOwner(); | |
946 | ||
947 | const AliAODEvent *aod = 0; | |
948 | const AliESDEvent *esd = 0; | |
949 | ||
950 | if ( !fIsESD ){ | |
951 | aod = static_cast<const AliAODEvent *>(event); | |
952 | } | |
953 | else { | |
954 | esd = dynamic_cast<const AliESDEvent *>(event); | |
955 | } | |
956 | if ( !esd && !aod ){ | |
957 | AliFatal(Form("ERROR: Could not retrieve ESD (fIsESD=%d) or AOD event. Return!",fIsESD)); | |
958 | list->AddLast(new TObjString(Form("ntracklets:other"))); | |
959 | return list; | |
960 | } | |
961 | ||
962 | AliAODTracklets *tracklets = dynamic_cast<AliAODTracklets*> ((fIsESD) ? 0 : aod->GetTracklets()); | |
963 | if ( !tracklets) { | |
964 | list->AddLast(new TObjString(Form("ntracklets:other"))); | |
965 | return list; | |
966 | } | |
967 | ||
968 | Int_t nTracklets = (fIsESD) ? 0 : tracklets->GetNumberOfTracklets(); | |
969 | Int_t trBin = -1, index = -1; | |
970 | ||
971 | while (trBin == -1 && index < fTrackletsBin.GetSize()-1 ) { | |
972 | index++; | |
973 | if ( nTracklets >= 0 && nTracklets < fTrackletsBin.At(index) ) trBin = index - 1; | |
974 | } | |
975 | ||
976 | if(DebugLevel() > 0) { | |
977 | if (trBin !=-1) { | |
978 | TString sTrBin = ((TObjString*)fSTrackletsBin->At(trBin))->GetString(); | |
979 | printf("test ntracklets %d bin found %d bin from ntracklets table %s\n",nTracklets,trBin, sTrBin.Data()); | |
980 | } | |
981 | else | |
982 | printf("test ntracklets %d no bin\n",nTracklets); | |
983 | } | |
984 | ||
985 | if (trBin == -1) { | |
986 | list->AddLast(new TObjString(Form("ntracklets:other"))); | |
987 | } | |
988 | else { | |
989 | //Add specific event centrality estimator and bin | |
990 | TString sTrBin = ((TObjString*)fSTrackletsBin->At(trBin))->GetString(); | |
991 | list->AddLast(new TObjString(Form("ntracklets:%s",sTrBin.Data()))); | |
992 | } | |
993 | ||
994 | return list; | |
995 | } | |
996 | ||
997 | ||
998 | ||
999 | //________________________________________________________________________ | |
1000 | TList* AliAnalysisTaskNorm::BuildListOfTrigger(const TObjArray *obj) | |
1001 | { | |
1002 | /// build the list of trigger for the counters from the selected trigger objarray | |
1003 | /// returned TList must be deleted by user | |
1004 | ||
1005 | TList* list = new TList(); | |
1006 | list->SetOwner(); | |
1007 | ||
1008 | // add case any | |
1009 | list->AddLast(new TObjString("trigger:any")); | |
1010 | ||
1011 | if ( obj ){ | |
1012 | for ( Int_t itrig = 0; itrig<obj->GetEntries(); itrig++ ) { | |
1013 | TString sTrigClassName = ((TObjString*)obj->At(itrig))->GetString(); | |
1014 | //Add specific trigger | |
1015 | list->AddLast(new TObjString(Form("trigger:%s",sTrigClassName.Data()))); | |
1016 | } | |
1017 | } | |
1018 | ||
1019 | // add case other if no specific trigger was found | |
1020 | if (list->GetSize() == 1) list->AddLast(new TObjString("trigger:other")); | |
1021 | ||
1022 | return list; | |
1023 | } | |
1024 | ||
1025 | ||
1026 | //_____________________________________________________________________________ | |
1027 | Bool_t AliAnalysisTaskNorm::CheckPattern ( TString trigName, TObjArray* keepArray, TObjArray* rejectArray ) | |
1028 | { | |
1029 | for ( Int_t ipat=0; ipat<rejectArray->GetEntries(); ++ipat ) { | |
1030 | if ( trigName.Contains(rejectArray->At(ipat)->GetName() ) ) return kFALSE; | |
1031 | } // loop on reject pattern | |
1032 | ||
1033 | for ( Int_t ipat=0; ipat<keepArray->GetEntries(); ++ipat ) { | |
1034 | if ( trigName.Contains(keepArray->At(ipat)->GetName() ) ) return kTRUE; | |
1035 | } // loop on keep pattern | |
1036 | ||
1037 | return ( keepArray->GetEntries() == 0 ) ? kTRUE : kFALSE; | |
1038 | } | |
1039 | ||
1040 | ||
1041 | //_____________________________________________________________________________ | |
1042 | TObjArray* AliAnalysisTaskNorm::BuildArrayOfTrigger ( const TObjArray* triggerArray, TString keepPattern, TString rejectPattern ) | |
1043 | { | |
1044 | ||
1045 | /// build the selected list of trigger from the trigger objarray | |
1046 | /// returned TObjArray must be deleted by user | |
1047 | ||
1048 | TObjArray* selectedList = new TObjArray(); | |
1049 | selectedList->SetOwner(); | |
1050 | TObjArray* rejectArray = rejectPattern.Tokenize(","); | |
1051 | TObjArray* keepArray = keepPattern.Tokenize(","); | |
1052 | ||
1053 | for ( Int_t iTrig = 0; iTrig < triggerArray->GetEntries(); iTrig++ ){ | |
1054 | TString currTrigName = ((TObjString*)triggerArray->At(iTrig))->GetName(); | |
1055 | if ( CheckPattern(currTrigName, keepArray, rejectArray) ) selectedList->AddLast(new TObjString(currTrigName.Data())); | |
1056 | } | |
1057 | ||
1058 | delete rejectArray; | |
1059 | delete keepArray; | |
1060 | ||
1061 | return selectedList; | |
1062 | ||
1063 | } | |
1064 | ||
1065 | //________________________________________________________________________ | |
1066 | TList* AliAnalysisTaskNorm::BuildListOfNormFactor(const TObjArray *trig ) { | |
1067 | // returned TList must be deleted by user | |
1068 | TList *list = new TList(); | |
1069 | list->SetOwner(); | |
1070 | ||
1071 | //fEventCounters->AddRubric("norm", "MBinMB/MSLinMSL/MULinMUL/MSLinMB/MULinMSL/MULinMB/any"); | |
1072 | ||
1073 | //any event | |
1074 | list->AddLast(new TObjString("norm:any")); | |
1075 | ||
1076 | if ( trig ) { | |
1077 | ||
1078 | Bool_t isMUL = kFALSE, isMSL = kFALSE, isMB = kFALSE; | |
1079 | Bool_t isMULInMSL = kFALSE, isMSLInMB = kFALSE, isMULInMB = kFALSE; | |
1080 | TString sNorm; | |
1081 | ||
1082 | for ( Int_t itrig=0; itrig< trig->GetEntries(); itrig++ ) { | |
1083 | TString sTrigClassName = ((TObjString*) trig->At(itrig))->GetString(); | |
1084 | if (sTrigClassName.Contains("CINT7-B-NOPF-ALLNOTRD")) isMB = kTRUE; | |
1085 | if (sTrigClassName.Contains("CMUL7-B-NOPF-MUON")) isMUL = kTRUE; | |
1086 | if (sTrigClassName.Contains("CMSL7-B-NOPF-MUON")) isMSL = kTRUE; | |
1087 | if (sTrigClassName.Contains("CINT7-B-NOPF-ALLNOTRD&0MSL")) isMSLInMB = kTRUE; | |
1088 | if (sTrigClassName.Contains("CMSL7-B-NOPF-MUON&0MUL")) isMULInMSL = kTRUE; | |
1089 | if (sTrigClassName.Contains("CINT7-B-NOPF-ALLNOTRD&0MUL")) isMULInMB = kTRUE; | |
1090 | } | |
1091 | ||
1092 | if (isMB){ | |
1093 | sNorm = "MBinMB"; | |
1094 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1095 | } | |
1096 | if (isMSL){ | |
1097 | sNorm = "MSLinMSL"; | |
1098 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1099 | } | |
1100 | if (isMUL){ | |
1101 | sNorm = "MULinMUL"; | |
1102 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1103 | } | |
1104 | if (isMSLInMB){ | |
1105 | sNorm = "MSLinMB"; | |
1106 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1107 | } | |
1108 | if (isMULInMSL){ | |
1109 | sNorm = "MULinMSL"; | |
1110 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1111 | } | |
1112 | if (isMULInMB){ | |
1113 | sNorm = "MULinMB"; | |
1114 | list->AddLast(new TObjString(Form("norm:%s",sNorm.Data()))); | |
1115 | } | |
1116 | ||
1117 | // add case other if no specific trigger was found | |
1118 | if ( list->GetSize() == 1 ) list->AddLast(new TObjString("norm:other")); | |
1119 | ||
1120 | } | |
1121 | ||
1122 | return list; | |
1123 | ||
1124 | } | |
1125 | ||
1126 | //_____________________________________________________________________________ | |
1127 | void AliAnalysisTaskNorm::FillEventCounters( Int_t runNr, TList *triggerList, TList *normFactorList, TList *centralityList, TList *spdPileUpList, TList *trackletsList, TList *v0AMultList, Bool_t physsel, Bool_t isVertex, TString sVertexCut, Bool_t outofbunchpileup) { | |
1128 | ||
1129 | TIter nextTriggerKey(triggerList); | |
1130 | TObjString *triggerKey = 0x0; | |
1131 | ||
1132 | TIter nextNormFactorKey(normFactorList); | |
1133 | TObjString *normFactorKey = 0x0; | |
1134 | ||
1135 | TIter nextCentralityKey(centralityList); | |
1136 | TObjString *centralityKey = 0x0; | |
1137 | ||
1138 | TIter nextSpdPileUpKey(spdPileUpList); | |
1139 | TObjString *spdPileUpKey = 0x0; | |
1140 | ||
1141 | TIter nextTrackletsKey(trackletsList); | |
1142 | //TObjString *trackletsKey = 0x0; | |
1143 | ||
1144 | TIter nextV0AMultKey(v0AMultList); | |
1145 | //TObjString *v0AMultKey = 0x0; | |
1146 | ||
1147 | TString selected; | |
1148 | selected = (physsel) ? "physsel:yes" : "physsel:no"; | |
1149 | selected += (isVertex) ? "/vertex:yes" : "/vertex:no"; | |
1150 | selected += Form("/%s",sVertexCut.Data()); | |
1151 | ||
1152 | TString selected2; | |
1153 | selected2 = (outofbunchpileup) ? "/outofbunchpileup:yes" : "/outofbunchpileup:no"; | |
1154 | ||
1155 | //Loop over triggerList | |
1156 | while ( ( triggerKey = (TObjString*) nextTriggerKey() ) ) { | |
1157 | ||
1158 | //Loop over normFactor List | |
1159 | nextNormFactorKey.Reset(); | |
1160 | while ( ( normFactorKey = (TObjString*) nextNormFactorKey() ) ) { | |
1161 | ||
1162 | //Loop over centrality List | |
1163 | nextCentralityKey.Reset(); | |
1164 | while ( ( centralityKey = (TObjString*) nextCentralityKey() ) ) { | |
1165 | ||
1166 | //Loop over spd pileup list | |
1167 | nextSpdPileUpKey.Reset(); | |
1168 | while ( ( spdPileUpKey = (TObjString*) nextSpdPileUpKey() ) ) { | |
1169 | ||
1170 | //Loop over ntracklets list | |
1171 | //nextTrackletsKey.Reset(); | |
1172 | //while ( ( trackletsKey = (TObjString*) nextTrackletsKey() ) ) { | |
1173 | ||
1174 | //Loop over V0Amult list | |
1175 | //nextV0AMultKey.Reset(); | |
1176 | //while ( ( v0AMultKey = (TObjString*) nextV0AMultKey() ) ) { | |
1177 | ||
1178 | TString sEventCounters; | |
1179 | //sEventCounters = Form("run:%d/%s/%s/%s/%s/%s/%s/%s",runNr,selected.Data(),triggerKey->GetName(),normFactorKey->GetName(),centralityKey->GetName(),spdPileUpKey->GetName(),trackletsKey->GetName(),v0AMultKey->GetName()); | |
1180 | sEventCounters = Form("run:%d/%s/%s/%s/%s/%s",runNr,selected.Data(),triggerKey->GetName(),normFactorKey->GetName(),centralityKey->GetName(),spdPileUpKey->GetName()); | |
1181 | fEventCounters->Count(sEventCounters); | |
1182 | // printf("event counters = %s\n",sEventCounters.Data()); | |
1183 | ||
1184 | // }//end loop on V0A multiplcity list | |
1185 | // }//end loop on ntracklets list | |
1186 | }// end loop on spd pile up list | |
1187 | }//end loop on centrality list | |
1188 | }//end loop on normfactor list | |
1189 | }//end loop on triggerList | |
1190 | ||
1191 | return; | |
1192 | } | |
1193 |