]>
Commit | Line | Data |
---|---|---|
7a4cf423 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliAnalysisTaskCaloFilter.cxx $ */ | |
17 | ||
18 | ////////////////////////////////////////////////////////// | |
19 | // Filter the ESDCaloClusters and ESDCaloCells of EMCAL, | |
20 | // PHOS or both, creating the corresponing AODCaloClusters | |
21 | // and AODCaloCells. | |
22 | // Keep also the AODHeader information and the vertex. | |
23 | // Needed for calorimeter calibration. | |
24 | // Copy of AliAnalysisTaskESDfilter. | |
25 | // Author: Gustavo Conesa Balbastre (INFN - Frascati) | |
26 | ////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "AliAnalysisTaskCaloFilter.h" | |
29 | #include "AliESDEvent.h" | |
30 | #include "AliAODEvent.h" | |
31 | #include "AliESDCaloCluster.h" | |
32 | #include "AliESDCaloCells.h" | |
33 | #include "AliLog.h" | |
34 | ||
35 | ClassImp(AliAnalysisTaskCaloFilter) | |
36 | ||
37 | //////////////////////////////////////////////////////////////////////// | |
38 | ||
39 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(): | |
40 | AliAnalysisTaskSE(), | |
41 | fCalorimeter("EMCAL PHOS") | |
42 | { | |
43 | // Default constructor | |
44 | } | |
45 | ||
46 | //__________________________________________________ | |
47 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name): | |
48 | AliAnalysisTaskSE(name), | |
49 | fCalorimeter("EMCAL PHOS") | |
50 | { | |
51 | // Constructor | |
52 | } | |
53 | ||
54 | //__________________________________________________ | |
55 | void AliAnalysisTaskCaloFilter::CreateAODFromAOD() | |
56 | { | |
57 | ||
58 | // Copy AOD header, vertex, CaloClusters and CaloCells to output AOD | |
59 | ||
60 | AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent()); | |
61 | ||
62 | // set arrays and pointers | |
63 | Float_t posF[3]; | |
64 | Double_t pos[3]; | |
65 | ||
66 | Double_t covVtx[6]; | |
67 | ||
68 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
69 | ||
70 | // Update the header | |
c8fe2783 | 71 | AliAODHeader* headerin = aod->GetHeader(); |
7a4cf423 | 72 | AliAODHeader* header = AODEvent()->GetHeader(); |
73 | header->SetRunNumber(headerin->GetRunNumber()); | |
74 | header->SetBunchCrossNumber(headerin->GetBunchCrossNumber()); | |
75 | header->SetOrbitNumber(headerin->GetOrbitNumber()); | |
76 | header->SetPeriodNumber(headerin->GetPeriodNumber()); | |
77 | header->SetEventType(headerin->GetEventType()); | |
78 | header->SetMuonMagFieldScale(headerin->GetMuonMagFieldScale()); // FIXME | |
79 | header->SetCentrality(headerin->GetCentrality()); // FIXME | |
80 | ||
81 | ||
82 | header->SetTriggerMask(headerin->GetTriggerMask()); | |
83 | header->SetTriggerCluster(headerin->GetTriggerCluster()); | |
84 | header->SetMagneticField(headerin->GetMagneticField()); | |
85 | header->SetZDCN1Energy(headerin->GetZDCN1Energy()); | |
86 | header->SetZDCP1Energy(headerin->GetZDCP1Energy()); | |
87 | header->SetZDCN2Energy(headerin->GetZDCN2Energy()); | |
88 | header->SetZDCP2Energy(headerin->GetZDCP2Energy()); | |
89 | header->SetZDCEMEnergy(headerin->GetZDCEMEnergy(0),headerin->GetZDCEMEnergy(1)); | |
90 | Float_t diamxy[2]={aod->GetDiamondX(),aod->GetDiamondY()}; | |
91 | Float_t diamcov[3]; aod->GetDiamondCovXY(diamcov); | |
92 | header->SetDiamond(diamxy,diamcov); | |
93 | // | |
94 | // | |
95 | Int_t nVertices = 1 ;/* = prim. vtx*/; | |
c8fe2783 | 96 | Int_t nCaloClus = aod->GetNumberOfCaloClusters(); |
7a4cf423 | 97 | |
98 | AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
99 | ||
100 | // Access to the AOD container of vertices | |
101 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
102 | Int_t jVertices=0; | |
103 | ||
104 | // Add primary vertex. The primary tracks will be defined | |
105 | // after the loops on the composite objects (V0, cascades, kinks) | |
106 | const AliAODVertex *vtx = aod->GetPrimaryVertex(); | |
107 | ||
108 | vtx->GetXYZ(pos); // position | |
109 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
110 | ||
111 | AliAODVertex * primary = new(vertices[jVertices++]) | |
112 | AliAODVertex(pos, covVtx, vtx->GetChi2perNDF(), NULL, -1, AliAODVertex::kPrimary); | |
113 | primary->SetName(vtx->GetName()); | |
114 | primary->SetTitle(vtx->GetTitle()); | |
115 | ||
116 | // Access to the AOD container of clusters | |
117 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
118 | Int_t jClusters=0; | |
119 | ||
120 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
121 | ||
122 | AliAODCaloCluster * cluster = aod->GetCaloCluster(iClust); | |
123 | ||
124 | //Check which calorimeter information we want to keep. | |
c8fe2783 | 125 | if (fCalorimeter.Contains("PHOS") && !fCalorimeter.Contains("EMCAL") && cluster->IsEMCAL()) continue ; |
126 | else if(fCalorimeter.Contains("EMCAL") && !fCalorimeter.Contains("PHOS") && cluster->IsPHOS()) continue ; | |
7a4cf423 | 127 | |
128 | Int_t id = cluster->GetID(); | |
129 | Float_t energy = cluster->E(); | |
130 | cluster->GetPosition(posF); | |
131 | Char_t ttype = cluster->GetType(); | |
132 | ||
133 | ||
134 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
135 | AliAODCaloCluster(id, | |
136 | 0, | |
137 | 0x0, | |
138 | energy, | |
139 | posF, | |
140 | NULL, | |
141 | ttype); | |
142 | ||
c8fe2783 | 143 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), |
7a4cf423 | 144 | cluster->GetDispersion(), |
145 | cluster->GetM20(), cluster->GetM02(), | |
146 | cluster->GetEmcCpvDistance(), | |
147 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
148 | ||
c8fe2783 | 149 | caloCluster->SetPIDFromESD(cluster->GetPID()); |
7a4cf423 | 150 | caloCluster->SetNCells(cluster->GetNCells()); |
151 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
152 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
153 | ||
154 | } | |
155 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
156 | // end of loop on calo clusters | |
157 | ||
158 | // fill EMCAL cell info | |
159 | if (fCalorimeter.Contains("EMCAL") && aod->GetEMCALCells()) { // protection against missing ESD information | |
160 | AliAODCaloCells &aodinEMcells = *(aod->GetEMCALCells()); | |
161 | Int_t nEMcell = aodinEMcells.GetNumberOfCells() ; | |
162 | ||
163 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
164 | aodEMcells.CreateContainer(nEMcell); | |
c8fe2783 | 165 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); |
7a4cf423 | 166 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { |
167 | aodEMcells.SetCell(iCell,aodinEMcells.GetCellNumber(iCell),aodinEMcells.GetAmplitude(iCell)); | |
168 | } | |
169 | aodEMcells.Sort(); | |
170 | } | |
171 | ||
172 | // fill PHOS cell info | |
173 | if (fCalorimeter.Contains("PHOS") && aod->GetPHOSCells()) { // protection against missing ESD information | |
174 | AliAODCaloCells &aodinPHcells = *(aod->GetPHOSCells()); | |
175 | Int_t nPHcell = aodinPHcells.GetNumberOfCells() ; | |
176 | ||
177 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
178 | aodPHcells.CreateContainer(nPHcell); | |
c8fe2783 | 179 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); |
7a4cf423 | 180 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { |
181 | aodPHcells.SetCell(iCell,aodinPHcells.GetCellNumber(iCell),aodinPHcells.GetAmplitude(iCell)); | |
182 | } | |
183 | aodPHcells.Sort(); | |
184 | } | |
185 | ||
186 | ||
187 | return; | |
188 | } | |
189 | ||
190 | //__________________________________________________ | |
191 | void AliAnalysisTaskCaloFilter::CreateAODFromESD() | |
192 | { | |
193 | ||
194 | // Copy ESD header, vertex, CaloClusters and CaloCells to output AOD | |
195 | ||
196 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()); | |
197 | ||
198 | // set arrays and pointers | |
199 | Float_t posF[3]; | |
200 | Double_t pos[3]; | |
201 | ||
202 | Double_t covVtx[6]; | |
203 | ||
204 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
205 | ||
206 | // Update the header | |
207 | ||
208 | AliAODHeader* header = AODEvent()->GetHeader(); | |
209 | header->SetRunNumber(esd->GetRunNumber()); | |
210 | header->SetBunchCrossNumber(esd->GetBunchCrossNumber()); | |
211 | header->SetOrbitNumber(esd->GetOrbitNumber()); | |
212 | header->SetPeriodNumber(esd->GetPeriodNumber()); | |
213 | header->SetEventType(esd->GetEventType()); | |
214 | header->SetMuonMagFieldScale(-999.); // FIXME | |
215 | header->SetCentrality(-999.); // FIXME | |
216 | ||
217 | ||
218 | header->SetTriggerMask(esd->GetTriggerMask()); | |
219 | header->SetTriggerCluster(esd->GetTriggerCluster()); | |
220 | header->SetMagneticField(esd->GetMagneticField()); | |
221 | header->SetZDCN1Energy(esd->GetZDCN1Energy()); | |
222 | header->SetZDCP1Energy(esd->GetZDCP1Energy()); | |
223 | header->SetZDCN2Energy(esd->GetZDCN2Energy()); | |
224 | header->SetZDCP2Energy(esd->GetZDCP2Energy()); | |
225 | header->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1)); | |
226 | Float_t diamxy[2]={esd->GetDiamondX(),esd->GetDiamondY()}; | |
227 | Float_t diamcov[3]; esd->GetDiamondCovXY(diamcov); | |
228 | header->SetDiamond(diamxy,diamcov); | |
229 | // | |
230 | // | |
231 | Int_t nVertices = 1 ;/* = prim. vtx*/; | |
232 | Int_t nCaloClus = esd->GetNumberOfCaloClusters(); | |
233 | ||
234 | AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
235 | ||
236 | // Access to the AOD container of vertices | |
237 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
238 | Int_t jVertices=0; | |
239 | ||
240 | // Add primary vertex. The primary tracks will be defined | |
241 | // after the loops on the composite objects (V0, cascades, kinks) | |
242 | const AliESDVertex *vtx = esd->GetPrimaryVertex(); | |
243 | ||
244 | vtx->GetXYZ(pos); // position | |
245 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
246 | ||
247 | AliAODVertex * primary = new(vertices[jVertices++]) | |
248 | AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, -1, AliAODVertex::kPrimary); | |
249 | primary->SetName(vtx->GetName()); | |
250 | primary->SetTitle(vtx->GetTitle()); | |
251 | ||
252 | // Access to the AOD container of clusters | |
253 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
254 | Int_t jClusters=0; | |
255 | ||
256 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
257 | ||
258 | AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust); | |
259 | ||
260 | //Check which calorimeter information we want to keep. | |
261 | if (fCalorimeter.Contains("PHOS") && !fCalorimeter.Contains("EMCAL") && cluster->IsEMCAL()) continue ; | |
262 | else if(fCalorimeter.Contains("EMCAL") && !fCalorimeter.Contains("PHOS") && cluster->IsPHOS()) continue ; | |
263 | ||
264 | Int_t id = cluster->GetID(); | |
265 | Float_t energy = cluster->E(); | |
266 | cluster->GetPosition(posF); | |
7a4cf423 | 267 | |
268 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
269 | AliAODCaloCluster(id, | |
270 | 0, | |
271 | 0x0, | |
272 | energy, | |
273 | posF, | |
274 | NULL, | |
c8fe2783 | 275 | cluster->GetType()); |
7a4cf423 | 276 | |
277 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), | |
c8fe2783 | 278 | cluster->GetDispersion(), |
7a4cf423 | 279 | cluster->GetM20(), cluster->GetM02(), |
280 | cluster->GetEmcCpvDistance(), | |
281 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
282 | ||
c8fe2783 | 283 | caloCluster->SetPIDFromESD(cluster->GetPID()); |
7a4cf423 | 284 | caloCluster->SetNCells(cluster->GetNCells()); |
285 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
286 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
287 | ||
288 | } | |
289 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
290 | // end of loop on calo clusters | |
291 | ||
292 | // fill EMCAL cell info | |
293 | if (fCalorimeter.Contains("EMCAL") && esd->GetEMCALCells()) { // protection against missing ESD information | |
294 | AliESDCaloCells &esdEMcells = *(esd->GetEMCALCells()); | |
295 | Int_t nEMcell = esdEMcells.GetNumberOfCells() ; | |
296 | ||
297 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
298 | aodEMcells.CreateContainer(nEMcell); | |
c8fe2783 | 299 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); |
7a4cf423 | 300 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { |
301 | aodEMcells.SetCell(iCell,esdEMcells.GetCellNumber(iCell),esdEMcells.GetAmplitude(iCell)); | |
302 | } | |
303 | aodEMcells.Sort(); | |
304 | } | |
305 | ||
306 | // fill PHOS cell info | |
307 | if (fCalorimeter.Contains("PHOS") && esd->GetPHOSCells()) { // protection against missing ESD information | |
308 | AliESDCaloCells &esdPHcells = *(esd->GetPHOSCells()); | |
309 | Int_t nPHcell = esdPHcells.GetNumberOfCells() ; | |
310 | ||
311 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
312 | aodPHcells.CreateContainer(nPHcell); | |
c8fe2783 | 313 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); |
7a4cf423 | 314 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { |
315 | aodPHcells.SetCell(iCell,esdPHcells.GetCellNumber(iCell),esdPHcells.GetAmplitude(iCell)); | |
316 | } | |
317 | aodPHcells.Sort(); | |
318 | } | |
319 | ||
320 | ||
321 | return; | |
322 | } | |
323 | ||
324 | //__________________________________________________ | |
325 | void AliAnalysisTaskCaloFilter::Init() | |
326 | { | |
327 | // Initialization | |
328 | if (fDebug > 1) AliInfo("Init() \n"); | |
329 | ||
330 | } | |
331 | ||
332 | //__________________________________________________ | |
333 | void AliAnalysisTaskCaloFilter::UserCreateOutputObjects() | |
334 | { | |
335 | // Create the output container | |
336 | } | |
337 | ||
338 | //__________________________________________________ | |
339 | void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/) | |
340 | { | |
341 | // Execute analysis for current event | |
342 | // | |
343 | ||
344 | Long64_t ientry = Entry(); | |
29a41d05 | 345 | if (fDebug > 0) printf("CaloFilter: Analysing event # %5d\n", (Int_t) ientry); |
7a4cf423 | 346 | |
347 | const char * dataevent =InputEvent()->GetName(); | |
348 | if(!strcmp(dataevent,"AliAODEvent")) CreateAODFromAOD(); | |
349 | ||
350 | else if(!strcmp(dataevent,"AliESDEvent")) CreateAODFromESD(); | |
351 | else { | |
352 | AliFatal(Form("Unknown event type %s, ABORT",dataevent)); | |
353 | ||
354 | } | |
355 | ||
356 | } | |
357 | ||
358 | //__________________________________________________ | |
359 | void AliAnalysisTaskCaloFilter::Terminate(Option_t */*option*/) | |
360 | { | |
361 | // Terminate analysis | |
362 | // | |
363 | if (fDebug > 1) printf("AnalysisCaloFilter: Terminate() \n"); | |
364 | } | |
365 |