]>
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()); | |
2dfb1428 | 61 | if(!aod) { |
62 | printf("AliAnalysisTaskCaloFilter::CreateAODFromAOD() - This event does not contain AODs?"); | |
63 | return; | |
64 | } | |
7a4cf423 | 65 | |
66 | // set arrays and pointers | |
67 | Float_t posF[3]; | |
68 | Double_t pos[3]; | |
69 | ||
70 | Double_t covVtx[6]; | |
71 | ||
72 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
73 | ||
74 | // Update the header | |
c8fe2783 | 75 | AliAODHeader* headerin = aod->GetHeader(); |
7a4cf423 | 76 | AliAODHeader* header = AODEvent()->GetHeader(); |
77 | header->SetRunNumber(headerin->GetRunNumber()); | |
78 | header->SetBunchCrossNumber(headerin->GetBunchCrossNumber()); | |
79 | header->SetOrbitNumber(headerin->GetOrbitNumber()); | |
80 | header->SetPeriodNumber(headerin->GetPeriodNumber()); | |
81 | header->SetEventType(headerin->GetEventType()); | |
82 | header->SetMuonMagFieldScale(headerin->GetMuonMagFieldScale()); // FIXME | |
83 | header->SetCentrality(headerin->GetCentrality()); // FIXME | |
84 | ||
85 | ||
86 | header->SetTriggerMask(headerin->GetTriggerMask()); | |
87 | header->SetTriggerCluster(headerin->GetTriggerCluster()); | |
88 | header->SetMagneticField(headerin->GetMagneticField()); | |
89 | header->SetZDCN1Energy(headerin->GetZDCN1Energy()); | |
90 | header->SetZDCP1Energy(headerin->GetZDCP1Energy()); | |
91 | header->SetZDCN2Energy(headerin->GetZDCN2Energy()); | |
92 | header->SetZDCP2Energy(headerin->GetZDCP2Energy()); | |
93 | header->SetZDCEMEnergy(headerin->GetZDCEMEnergy(0),headerin->GetZDCEMEnergy(1)); | |
94 | Float_t diamxy[2]={aod->GetDiamondX(),aod->GetDiamondY()}; | |
95 | Float_t diamcov[3]; aod->GetDiamondCovXY(diamcov); | |
96 | header->SetDiamond(diamxy,diamcov); | |
97 | // | |
98 | // | |
99 | Int_t nVertices = 1 ;/* = prim. vtx*/; | |
c8fe2783 | 100 | Int_t nCaloClus = aod->GetNumberOfCaloClusters(); |
7a4cf423 | 101 | |
102 | AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
103 | ||
104 | // Access to the AOD container of vertices | |
105 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
106 | Int_t jVertices=0; | |
107 | ||
108 | // Add primary vertex. The primary tracks will be defined | |
109 | // after the loops on the composite objects (V0, cascades, kinks) | |
110 | const AliAODVertex *vtx = aod->GetPrimaryVertex(); | |
111 | ||
112 | vtx->GetXYZ(pos); // position | |
113 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
114 | ||
115 | AliAODVertex * primary = new(vertices[jVertices++]) | |
116 | AliAODVertex(pos, covVtx, vtx->GetChi2perNDF(), NULL, -1, AliAODVertex::kPrimary); | |
117 | primary->SetName(vtx->GetName()); | |
118 | primary->SetTitle(vtx->GetTitle()); | |
119 | ||
120 | // Access to the AOD container of clusters | |
121 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
122 | Int_t jClusters=0; | |
123 | ||
124 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
125 | ||
126 | AliAODCaloCluster * cluster = aod->GetCaloCluster(iClust); | |
127 | ||
128 | //Check which calorimeter information we want to keep. | |
c8fe2783 | 129 | if (fCalorimeter.Contains("PHOS") && !fCalorimeter.Contains("EMCAL") && cluster->IsEMCAL()) continue ; |
130 | else if(fCalorimeter.Contains("EMCAL") && !fCalorimeter.Contains("PHOS") && cluster->IsPHOS()) continue ; | |
7a4cf423 | 131 | |
132 | Int_t id = cluster->GetID(); | |
133 | Float_t energy = cluster->E(); | |
134 | cluster->GetPosition(posF); | |
135 | Char_t ttype = cluster->GetType(); | |
136 | ||
137 | ||
138 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
139 | AliAODCaloCluster(id, | |
140 | 0, | |
141 | 0x0, | |
142 | energy, | |
143 | posF, | |
144 | NULL, | |
145 | ttype); | |
146 | ||
c8fe2783 | 147 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), |
7a4cf423 | 148 | cluster->GetDispersion(), |
149 | cluster->GetM20(), cluster->GetM02(), | |
150 | cluster->GetEmcCpvDistance(), | |
151 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
152 | ||
c8fe2783 | 153 | caloCluster->SetPIDFromESD(cluster->GetPID()); |
7a4cf423 | 154 | caloCluster->SetNCells(cluster->GetNCells()); |
155 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
156 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
157 | ||
158 | } | |
159 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
160 | // end of loop on calo clusters | |
161 | ||
162 | // fill EMCAL cell info | |
163 | if (fCalorimeter.Contains("EMCAL") && aod->GetEMCALCells()) { // protection against missing ESD information | |
164 | AliAODCaloCells &aodinEMcells = *(aod->GetEMCALCells()); | |
165 | Int_t nEMcell = aodinEMcells.GetNumberOfCells() ; | |
166 | ||
167 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
168 | aodEMcells.CreateContainer(nEMcell); | |
c8fe2783 | 169 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); |
7a4cf423 | 170 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { |
171 | aodEMcells.SetCell(iCell,aodinEMcells.GetCellNumber(iCell),aodinEMcells.GetAmplitude(iCell)); | |
172 | } | |
173 | aodEMcells.Sort(); | |
174 | } | |
175 | ||
176 | // fill PHOS cell info | |
177 | if (fCalorimeter.Contains("PHOS") && aod->GetPHOSCells()) { // protection against missing ESD information | |
178 | AliAODCaloCells &aodinPHcells = *(aod->GetPHOSCells()); | |
179 | Int_t nPHcell = aodinPHcells.GetNumberOfCells() ; | |
180 | ||
181 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
182 | aodPHcells.CreateContainer(nPHcell); | |
c8fe2783 | 183 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); |
7a4cf423 | 184 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { |
185 | aodPHcells.SetCell(iCell,aodinPHcells.GetCellNumber(iCell),aodinPHcells.GetAmplitude(iCell)); | |
186 | } | |
187 | aodPHcells.Sort(); | |
188 | } | |
189 | ||
190 | ||
191 | return; | |
192 | } | |
193 | ||
194 | //__________________________________________________ | |
195 | void AliAnalysisTaskCaloFilter::CreateAODFromESD() | |
196 | { | |
197 | ||
198 | // Copy ESD header, vertex, CaloClusters and CaloCells to output AOD | |
199 | ||
200 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()); | |
2dfb1428 | 201 | if(!esd) { |
202 | printf("AliAnalysisTaskCaloFilter::CreateAODFromESD() - This event does not contain AODs?"); | |
203 | return; | |
204 | } | |
7a4cf423 | 205 | |
206 | // set arrays and pointers | |
207 | Float_t posF[3]; | |
208 | Double_t pos[3]; | |
209 | ||
210 | Double_t covVtx[6]; | |
211 | ||
212 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
213 | ||
214 | // Update the header | |
215 | ||
216 | AliAODHeader* header = AODEvent()->GetHeader(); | |
217 | header->SetRunNumber(esd->GetRunNumber()); | |
218 | header->SetBunchCrossNumber(esd->GetBunchCrossNumber()); | |
219 | header->SetOrbitNumber(esd->GetOrbitNumber()); | |
220 | header->SetPeriodNumber(esd->GetPeriodNumber()); | |
221 | header->SetEventType(esd->GetEventType()); | |
222 | header->SetMuonMagFieldScale(-999.); // FIXME | |
223 | header->SetCentrality(-999.); // FIXME | |
224 | ||
225 | ||
226 | header->SetTriggerMask(esd->GetTriggerMask()); | |
227 | header->SetTriggerCluster(esd->GetTriggerCluster()); | |
228 | header->SetMagneticField(esd->GetMagneticField()); | |
229 | header->SetZDCN1Energy(esd->GetZDCN1Energy()); | |
230 | header->SetZDCP1Energy(esd->GetZDCP1Energy()); | |
231 | header->SetZDCN2Energy(esd->GetZDCN2Energy()); | |
232 | header->SetZDCP2Energy(esd->GetZDCP2Energy()); | |
233 | header->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1)); | |
234 | Float_t diamxy[2]={esd->GetDiamondX(),esd->GetDiamondY()}; | |
235 | Float_t diamcov[3]; esd->GetDiamondCovXY(diamcov); | |
236 | header->SetDiamond(diamxy,diamcov); | |
237 | // | |
238 | // | |
239 | Int_t nVertices = 1 ;/* = prim. vtx*/; | |
240 | Int_t nCaloClus = esd->GetNumberOfCaloClusters(); | |
241 | ||
242 | AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
243 | ||
244 | // Access to the AOD container of vertices | |
245 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
246 | Int_t jVertices=0; | |
247 | ||
248 | // Add primary vertex. The primary tracks will be defined | |
249 | // after the loops on the composite objects (V0, cascades, kinks) | |
250 | const AliESDVertex *vtx = esd->GetPrimaryVertex(); | |
251 | ||
252 | vtx->GetXYZ(pos); // position | |
253 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
254 | ||
255 | AliAODVertex * primary = new(vertices[jVertices++]) | |
256 | AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, -1, AliAODVertex::kPrimary); | |
257 | primary->SetName(vtx->GetName()); | |
258 | primary->SetTitle(vtx->GetTitle()); | |
259 | ||
260 | // Access to the AOD container of clusters | |
261 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
262 | Int_t jClusters=0; | |
263 | ||
264 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
265 | ||
266 | AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust); | |
267 | ||
268 | //Check which calorimeter information we want to keep. | |
269 | if (fCalorimeter.Contains("PHOS") && !fCalorimeter.Contains("EMCAL") && cluster->IsEMCAL()) continue ; | |
270 | else if(fCalorimeter.Contains("EMCAL") && !fCalorimeter.Contains("PHOS") && cluster->IsPHOS()) continue ; | |
271 | ||
272 | Int_t id = cluster->GetID(); | |
273 | Float_t energy = cluster->E(); | |
274 | cluster->GetPosition(posF); | |
7a4cf423 | 275 | |
276 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
277 | AliAODCaloCluster(id, | |
278 | 0, | |
279 | 0x0, | |
280 | energy, | |
281 | posF, | |
282 | NULL, | |
c8fe2783 | 283 | cluster->GetType()); |
7a4cf423 | 284 | |
285 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), | |
c8fe2783 | 286 | cluster->GetDispersion(), |
7a4cf423 | 287 | cluster->GetM20(), cluster->GetM02(), |
288 | cluster->GetEmcCpvDistance(), | |
289 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
290 | ||
c8fe2783 | 291 | caloCluster->SetPIDFromESD(cluster->GetPID()); |
7a4cf423 | 292 | caloCluster->SetNCells(cluster->GetNCells()); |
293 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
294 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
295 | ||
296 | } | |
297 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
298 | // end of loop on calo clusters | |
299 | ||
300 | // fill EMCAL cell info | |
301 | if (fCalorimeter.Contains("EMCAL") && esd->GetEMCALCells()) { // protection against missing ESD information | |
302 | AliESDCaloCells &esdEMcells = *(esd->GetEMCALCells()); | |
303 | Int_t nEMcell = esdEMcells.GetNumberOfCells() ; | |
304 | ||
305 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
306 | aodEMcells.CreateContainer(nEMcell); | |
c8fe2783 | 307 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); |
7a4cf423 | 308 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { |
309 | aodEMcells.SetCell(iCell,esdEMcells.GetCellNumber(iCell),esdEMcells.GetAmplitude(iCell)); | |
310 | } | |
311 | aodEMcells.Sort(); | |
312 | } | |
313 | ||
314 | // fill PHOS cell info | |
315 | if (fCalorimeter.Contains("PHOS") && esd->GetPHOSCells()) { // protection against missing ESD information | |
316 | AliESDCaloCells &esdPHcells = *(esd->GetPHOSCells()); | |
317 | Int_t nPHcell = esdPHcells.GetNumberOfCells() ; | |
318 | ||
319 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
320 | aodPHcells.CreateContainer(nPHcell); | |
c8fe2783 | 321 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); |
7a4cf423 | 322 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { |
323 | aodPHcells.SetCell(iCell,esdPHcells.GetCellNumber(iCell),esdPHcells.GetAmplitude(iCell)); | |
324 | } | |
325 | aodPHcells.Sort(); | |
326 | } | |
327 | ||
328 | ||
329 | return; | |
330 | } | |
331 | ||
332 | //__________________________________________________ | |
333 | void AliAnalysisTaskCaloFilter::Init() | |
334 | { | |
335 | // Initialization | |
336 | if (fDebug > 1) AliInfo("Init() \n"); | |
337 | ||
338 | } | |
339 | ||
340 | //__________________________________________________ | |
341 | void AliAnalysisTaskCaloFilter::UserCreateOutputObjects() | |
342 | { | |
343 | // Create the output container | |
344 | } | |
345 | ||
346 | //__________________________________________________ | |
347 | void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/) | |
348 | { | |
349 | // Execute analysis for current event | |
350 | // | |
351 | ||
352 | Long64_t ientry = Entry(); | |
29a41d05 | 353 | if (fDebug > 0) printf("CaloFilter: Analysing event # %5d\n", (Int_t) ientry); |
7a4cf423 | 354 | |
355 | const char * dataevent =InputEvent()->GetName(); | |
356 | if(!strcmp(dataevent,"AliAODEvent")) CreateAODFromAOD(); | |
357 | ||
358 | else if(!strcmp(dataevent,"AliESDEvent")) CreateAODFromESD(); | |
359 | else { | |
360 | AliFatal(Form("Unknown event type %s, ABORT",dataevent)); | |
361 | ||
362 | } | |
363 | ||
364 | } | |
365 | ||
366 | //__________________________________________________ | |
367 | void AliAnalysisTaskCaloFilter::Terminate(Option_t */*option*/) | |
368 | { | |
369 | // Terminate analysis | |
370 | // | |
371 | if (fDebug > 1) printf("AnalysisCaloFilter: Terminate() \n"); | |
372 | } | |
373 |