]>
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 | ||
7a4cf423 | 16 | ////////////////////////////////////////////////////////// |
17 | // Filter the ESDCaloClusters and ESDCaloCells of EMCAL, | |
18 | // PHOS or both, creating the corresponing AODCaloClusters | |
19 | // and AODCaloCells. | |
20 | // Keep also the AODHeader information and the vertex. | |
e4de0408 | 21 | // Keep tracks if requested |
7a4cf423 | 22 | // Copy of AliAnalysisTaskESDfilter. |
23 | // Author: Gustavo Conesa Balbastre (INFN - Frascati) | |
24 | ////////////////////////////////////////////////////////// | |
25 | ||
44cf05d7 | 26 | //Root |
27 | #include "TGeoManager.h" | |
5994e71f | 28 | #include "TFile.h" |
5994e71f | 29 | #include "TROOT.h" |
30 | #include "TInterpreter.h" | |
44cf05d7 | 31 | |
32 | //STEER | |
7a4cf423 | 33 | #include "AliESDEvent.h" |
34 | #include "AliAODEvent.h" | |
7a4cf423 | 35 | #include "AliLog.h" |
247abff4 | 36 | #include "AliVCluster.h" |
37 | #include "AliVCaloCells.h" | |
247abff4 | 38 | #include "AliVEventHandler.h" |
39 | #include "AliAnalysisManager.h" | |
40 | #include "AliInputEventHandler.h" | |
44cf05d7 | 41 | |
42 | //EMCAL | |
43 | #include "AliEMCALRecoUtils.h" | |
44 | #include "AliEMCALGeometry.h" | |
45 | ||
46 | #include "AliAnalysisTaskCaloFilter.h" | |
7a4cf423 | 47 | |
48 | ClassImp(AliAnalysisTaskCaloFilter) | |
e4de0408 | 49 | |
7a4cf423 | 50 | //////////////////////////////////////////////////////////////////////// |
51 | ||
52 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(): | |
e4de0408 | 53 | AliAnalysisTaskSE("CaloFilterTask"), //fCuts(0x0), |
54 | fCaloFilter(0), fCorrect(kFALSE), | |
55 | fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), | |
56 | fEMCALRecoUtils(new AliEMCALRecoUtils), | |
57 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), | |
58 | fGeoMatrixSet(kFALSE), | |
59 | fConfigName(""),fFillAODFile(kTRUE), fFillTracks(kFALSE), | |
60 | fEnergyCut(0.), fNcellsCut (0), fVzCut(100.) | |
7a4cf423 | 61 | { |
62 | // Default constructor | |
e4de0408 | 63 | |
e3990982 | 64 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
3b13c34c | 65 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; |
5994e71f | 66 | |
7a4cf423 | 67 | } |
68 | ||
69 | //__________________________________________________ | |
70 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name): | |
e4de0408 | 71 | AliAnalysisTaskSE(name), //fCuts(0x0), |
72 | fCaloFilter(0), fCorrect(kFALSE), | |
73 | fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), | |
74 | fEMCALRecoUtils(new AliEMCALRecoUtils), | |
75 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), | |
76 | fGeoMatrixSet(kFALSE), | |
77 | fConfigName(""),fFillAODFile(kTRUE),fFillTracks(kFALSE), | |
78 | fEnergyCut(0.), fNcellsCut (0), fVzCut(100.) | |
7a4cf423 | 79 | { |
80 | // Constructor | |
e4de0408 | 81 | |
e3990982 | 82 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
3b13c34c | 83 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; |
e4de0408 | 84 | |
7a4cf423 | 85 | } |
86 | ||
87 | //__________________________________________________ | |
247abff4 | 88 | AliAnalysisTaskCaloFilter::~AliAnalysisTaskCaloFilter() |
7a4cf423 | 89 | { |
247abff4 | 90 | //Destructor. |
91 | ||
44cf05d7 | 92 | if(fEMCALGeo) delete fEMCALGeo; |
93 | if(fEMCALRecoUtils) delete fEMCALRecoUtils; | |
5994e71f | 94 | |
247abff4 | 95 | } |
96 | ||
5994e71f | 97 | //------------------------------------------------------------------- |
98 | void AliAnalysisTaskCaloFilter::Init() | |
99 | { | |
100 | //Init analysis with configuration macro if available | |
101 | ||
e4de0408 | 102 | if(gROOT->LoadMacro(fConfigName) >=0) |
103 | { | |
5994e71f | 104 | printf("Configure analysis with %s\n",fConfigName.Data()); |
e4de0408 | 105 | |
5994e71f | 106 | AliAnalysisTaskCaloFilter *filter = (AliAnalysisTaskCaloFilter*)gInterpreter->ProcessLine("ConfigCaloFilter()"); |
e4de0408 | 107 | |
5994e71f | 108 | fEMCALGeoName = filter->fEMCALGeoName; |
109 | fLoadEMCALMatrices = filter->fLoadEMCALMatrices; | |
110 | fFillAODFile = filter->fFillAODFile; | |
e4de0408 | 111 | fFillTracks = filter->fFillTracks; |
5994e71f | 112 | fEMCALRecoUtils = filter->fEMCALRecoUtils; |
113 | fConfigName = filter->fConfigName; | |
114 | fCaloFilter = filter->fCaloFilter; | |
115 | fCorrect = filter->fCorrect; | |
e4de0408 | 116 | fEnergyCut = filter->fEnergyCut; |
117 | fNcellsCut = filter->fNcellsCut; | |
118 | fVzCut = filter->fVzCut; | |
119 | ||
e3990982 | 120 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = filter->fEMCALMatrix[i] ; |
5994e71f | 121 | } |
122 | } | |
123 | ||
247abff4 | 124 | //__________________________________________________ |
125 | void AliAnalysisTaskCaloFilter::UserCreateOutputObjects() | |
126 | { | |
127 | // Init geometry | |
128 | ||
129 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ; | |
7a4cf423 | 130 | |
247abff4 | 131 | } |
132 | ||
e4de0408 | 133 | //____________________________________________________________ |
247abff4 | 134 | void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/) |
135 | { | |
136 | // Execute analysis for current event | |
44cf05d7 | 137 | // Copy input ESD or AOD header, vertex, CaloClusters and CaloCells to output AOD |
e4de0408 | 138 | |
247abff4 | 139 | if (fDebug > 0) |
140 | printf("CaloFilter: Analysing event # %d\n", (Int_t)Entry()); | |
7a4cf423 | 141 | |
247abff4 | 142 | AliVEvent* event = InputEvent(); |
e4de0408 | 143 | if(!event) |
144 | { | |
44cf05d7 | 145 | printf("AliAnalysisTaskCaloFilter::UserExec - This event does not contain Input?"); |
2dfb1428 | 146 | return; |
147 | } | |
e4de0408 | 148 | |
149 | // Select the event | |
150 | ||
151 | if(!AcceptEventVertex()) return; | |
152 | if(!AcceptEventEMCAL()) return; | |
153 | ||
fbad5435 | 154 | //Magic line to write events to file |
5994e71f | 155 | AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(fFillAODFile); |
3a58eee6 | 156 | |
e4de0408 | 157 | Int_t nVertices = event->GetNumberOfV0s()+event->GetNumberOfCascades();; |
158 | Int_t nCaloClus = event->GetNumberOfCaloClusters(); | |
159 | Int_t nTracks = event->GetNumberOfTracks(); | |
160 | ||
161 | AODEvent()->ResetStd(nTracks, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
162 | ||
163 | // | |
164 | FillAODHeader(); | |
165 | ||
166 | // | |
167 | FillAODVertices(); | |
168 | ||
169 | // | |
170 | FillAODTracks(); | |
171 | ||
172 | // | |
173 | CorrectionsInEMCAL(); | |
174 | ||
175 | // | |
176 | FillAODCaloClusters(); | |
177 | ||
178 | // | |
179 | FillAODCaloCells(); | |
180 | ||
181 | } | |
182 | ||
183 | //___________________________________________________ | |
184 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventVertex() | |
185 | { | |
186 | // Accept event with good vertex | |
187 | ||
188 | Double_t v[3]; | |
189 | InputEvent()->GetPrimaryVertex()->GetXYZ(v) ; | |
190 | ||
191 | if(TMath::Abs(v[2]) > fVzCut) return kFALSE ; | |
192 | ||
193 | return CheckForPrimaryVertex(); | |
194 | } | |
195 | ||
196 | //__________________________________________________ | |
197 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventEMCAL() | |
198 | { | |
199 | // Accept event given there is a cluster with enough energy | |
200 | ||
201 | if(fCaloFilter!=kEMCAL) return kTRUE; // accept all | |
202 | ||
203 | Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters(); | |
204 | AliVCaloCells * caloCell = InputEvent() -> GetEMCALCells(); | |
205 | Int_t bc = InputEvent() -> GetBunchCrossNumber(); | |
206 | ||
207 | for(Int_t icalo = 0; icalo < nCluster; icalo++) | |
208 | { | |
209 | AliESDCaloCluster *clus = (AliESDCaloCluster*) (InputEvent()->GetCaloCluster(icalo)); | |
210 | ||
211 | if( ( clus->IsEMCAL() ) && ( clus->GetNCells() > fNcellsCut ) && ( clus->E() > fEnergyCut ) && | |
212 | fEMCALRecoUtils->IsGoodCluster(clus,fEMCALGeo,caloCell,bc)) | |
213 | { | |
214 | ||
215 | // printf("Accept event %d, E %2.2f > %2.2f, nCells %d > %d \n", | |
216 | // (Int_t) Entry(),clus->E(), fEnergyCut, clus->GetNCells(), fNcellsCut); | |
217 | ||
218 | return kTRUE; | |
219 | } | |
44cf05d7 | 220 | |
e4de0408 | 221 | }// loop |
44cf05d7 | 222 | |
e4de0408 | 223 | return kFALSE; |
44cf05d7 | 224 | |
e4de0408 | 225 | } |
226 | ||
227 | //________________________________________________ | |
228 | void AliAnalysisTaskCaloFilter::FillAODCaloCells() | |
229 | { | |
230 | // Fill EMCAL/PHOS cell info | |
3a58eee6 | 231 | |
e4de0408 | 232 | AliVEvent * event = InputEvent(); |
7a4cf423 | 233 | |
e4de0408 | 234 | // EMCAL |
235 | if ((fCaloFilter==kBoth || fCaloFilter==kEMCAL) && event->GetEMCALCells()) | |
236 | { // protection against missing ESD information | |
237 | AliVCaloCells &eventEMcells = *(event->GetEMCALCells()); | |
238 | Int_t nEMcell = eventEMcells.GetNumberOfCells() ; | |
239 | ||
240 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
241 | aodEMcells.CreateContainer(nEMcell); | |
242 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); | |
243 | Double_t calibFactor = 1.; | |
244 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) | |
245 | { | |
246 | Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1; | |
247 | fEMCALGeo->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta); | |
248 | fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta); | |
249 | ||
250 | if(fCorrect && fEMCALRecoUtils->IsRecalibrationOn()) | |
251 | { | |
252 | calibFactor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi); | |
253 | } | |
254 | ||
255 | if(!fEMCALRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi)) | |
256 | { //Channel is not declared as bad | |
257 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor, | |
258 | eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell)); | |
259 | //printf("GOOD channel\n"); | |
260 | } | |
261 | else | |
262 | { | |
263 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0); | |
264 | //printf("BAD channel\n"); | |
265 | } | |
266 | } | |
267 | aodEMcells.Sort(); | |
268 | } | |
269 | ||
270 | // PHOS | |
271 | if ((fCaloFilter==kBoth || fCaloFilter==kPHOS) && event->GetPHOSCells()) | |
272 | { // protection against missing ESD information | |
273 | AliVCaloCells &eventPHcells = *(event->GetPHOSCells()); | |
274 | Int_t nPHcell = eventPHcells.GetNumberOfCells() ; | |
275 | ||
276 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
277 | aodPHcells.CreateContainer(nPHcell); | |
278 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); | |
279 | ||
280 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) | |
281 | { | |
282 | aodPHcells.SetCell(iCell,eventPHcells.GetCellNumber(iCell),eventPHcells.GetAmplitude(iCell), | |
283 | eventPHcells.GetTime(iCell),eventPHcells.GetMCLabel(iCell),eventPHcells.GetEFraction(iCell)); | |
284 | } | |
285 | ||
286 | aodPHcells.Sort(); | |
287 | } | |
288 | } | |
289 | ||
290 | ||
291 | //___________________________________________________ | |
292 | void AliAnalysisTaskCaloFilter::FillAODCaloClusters() | |
293 | { | |
294 | // Fill the AOD with caloclusters | |
295 | ||
296 | AliVEvent * event = InputEvent(); | |
297 | ||
298 | // Access to the AOD container of clusters | |
299 | ||
300 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
301 | Int_t jClusters=0; | |
5994e71f | 302 | Float_t posF[3] ; |
e4de0408 | 303 | |
304 | Int_t nCaloClus = event->GetNumberOfCaloClusters(); | |
305 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) | |
306 | { | |
307 | ||
308 | AliVCluster * cluster = event->GetCaloCluster(iClust); | |
309 | ||
310 | //Check which calorimeter information we want to keep. | |
311 | ||
312 | if(fCaloFilter!=kBoth) | |
313 | { | |
314 | if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ; | |
315 | else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ; | |
316 | } | |
317 | ||
318 | // Get original residuals, in case of previous recalculation, reset them | |
319 | Float_t dR = cluster->GetTrackDx(); | |
320 | Float_t dZ = cluster->GetTrackDz(); | |
321 | ||
322 | if(DebugLevel() > 2) | |
323 | printf("Original residuals : dZ %f, dR %f\n ",dZ, dR); | |
324 | ||
325 | //-------------------------------------------------------------- | |
326 | //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters | |
327 | if(cluster->IsEMCAL() && fCorrect) | |
328 | { | |
329 | if(DebugLevel() > 2) | |
330 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
331 | ||
332 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
333 | ||
334 | if(fEMCALRecoUtils->IsExoticCluster(cluster, InputEvent()->GetEMCALCells(),InputEvent()->GetBunchCrossNumber())) continue; | |
247abff4 | 335 | |
e4de0408 | 336 | fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ); |
337 | cluster->SetTrackDistance(dR,dZ); | |
338 | } | |
339 | ||
340 | if(DebugLevel() > 2) | |
341 | { | |
342 | if(cluster->IsEMCAL()) printf("EMCAL Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
343 | if(cluster->IsPHOS()) printf("PHOS Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
344 | } | |
345 | ||
346 | //-------------------------------------------------------------- | |
347 | ||
348 | //Now fill AODs | |
349 | ||
350 | Int_t id = cluster->GetID(); | |
351 | Float_t energy = cluster->E(); | |
352 | cluster->GetPosition(posF); | |
353 | ||
354 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
355 | AliAODCaloCluster(id, | |
356 | cluster->GetNLabels(), | |
357 | cluster->GetLabels(), | |
358 | energy, | |
359 | posF, | |
360 | NULL, | |
361 | cluster->GetType()); | |
362 | ||
363 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), | |
364 | cluster->GetDispersion(), | |
365 | cluster->GetM20(), cluster->GetM02(), | |
366 | -1, | |
367 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
368 | ||
369 | caloCluster->SetPIDFromESD(cluster->GetPID()); | |
370 | caloCluster->SetNCells(cluster->GetNCells()); | |
371 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
372 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
373 | caloCluster->SetTrackDistance(dR, dZ); | |
374 | ||
375 | if(DebugLevel() > 2) | |
376 | { | |
377 | printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(), | |
378 | caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20()); | |
379 | caloCluster->GetPosition(posF); | |
380 | printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]); | |
381 | } | |
382 | ||
383 | //Matched tracks, just to know if there was any match, the track pointer is useless if tracks not stored | |
384 | if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990) | |
385 | { //Default value in PHOS 999, in EMCAL 1024, why? | |
386 | caloCluster->AddTrackMatched(new AliAODTrack); | |
387 | } | |
388 | // TO DO, in case Tracks available, think how to put the matched track in AOD | |
389 | } | |
390 | ||
391 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots | |
392 | ||
393 | } | |
394 | ||
395 | ||
396 | //______________________________________________ | |
397 | void AliAnalysisTaskCaloFilter::FillAODHeader() | |
398 | { | |
399 | // AOD header copy | |
400 | ||
401 | AliVEvent* event = InputEvent(); | |
402 | AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (event); | |
403 | AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event); | |
404 | ||
7a4cf423 | 405 | AliAODHeader* header = AODEvent()->GetHeader(); |
247abff4 | 406 | |
e4de0408 | 407 | // Copy from AODs |
408 | if(aodevent) | |
409 | { | |
410 | *header = *(aodevent->GetHeader()); | |
411 | return; | |
412 | } | |
413 | ||
a8088a22 | 414 | if(!esdevent) return; |
415 | ||
e4de0408 | 416 | // Copy from ESDs |
417 | ||
247abff4 | 418 | header->SetRunNumber(event->GetRunNumber()); |
5994e71f | 419 | |
e4de0408 | 420 | TTree* tree = fInputHandler->GetTree(); |
421 | if (tree) | |
422 | { | |
423 | TFile* file = tree->GetCurrentFile(); | |
424 | if (file) header->SetESDFileName(file->GetName()); | |
5994e71f | 425 | } |
247abff4 | 426 | |
427 | header->SetBunchCrossNumber(event->GetBunchCrossNumber()); | |
428 | header->SetOrbitNumber(event->GetOrbitNumber()); | |
429 | header->SetPeriodNumber(event->GetPeriodNumber()); | |
430 | header->SetEventType(event->GetEventType()); | |
7a4cf423 | 431 | |
5994e71f | 432 | //Centrality |
e4de0408 | 433 | if(event->GetCentrality()) |
434 | { | |
5994e71f | 435 | header->SetCentrality(new AliCentrality(*(event->GetCentrality()))); |
436 | } | |
a8088a22 | 437 | else |
438 | { | |
5994e71f | 439 | header->SetCentrality(0); |
440 | } | |
441 | ||
442 | //Trigger | |
443 | header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection | |
e4de0408 | 444 | header->SetFiredTriggerClasses(esdevent->GetFiredTriggerClasses()); |
247abff4 | 445 | header->SetTriggerMask(event->GetTriggerMask()); |
446 | header->SetTriggerCluster(event->GetTriggerCluster()); | |
e4de0408 | 447 | header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs()); |
448 | header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs()); | |
449 | header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs()); | |
450 | ||
247abff4 | 451 | header->SetMagneticField(event->GetMagneticField()); |
5994e71f | 452 | //header->SetMuonMagFieldScale(esdevent->GetCurrentDip()/6000.); |
e4de0408 | 453 | |
247abff4 | 454 | header->SetZDCN1Energy(event->GetZDCN1Energy()); |
455 | header->SetZDCP1Energy(event->GetZDCP1Energy()); | |
456 | header->SetZDCN2Energy(event->GetZDCN2Energy()); | |
457 | header->SetZDCP2Energy(event->GetZDCP2Energy()); | |
458 | header->SetZDCEMEnergy(event->GetZDCEMEnergy(0),event->GetZDCEMEnergy(1)); | |
5994e71f | 459 | |
247abff4 | 460 | Float_t diamxy[2]={event->GetDiamondX(),event->GetDiamondY()}; |
5994e71f | 461 | Float_t diamcov[3]; |
462 | event->GetDiamondCovXY(diamcov); | |
7a4cf423 | 463 | header->SetDiamond(diamxy,diamcov); |
e4de0408 | 464 | header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ()); |
5994e71f | 465 | |
e4de0408 | 466 | } |
467 | ||
468 | //_____________________________________________ | |
469 | void AliAnalysisTaskCaloFilter::FillAODTracks() | |
470 | { | |
471 | // AOD track copy | |
472 | ||
473 | if(!fFillTracks) return; | |
474 | ||
475 | AliVEvent* event = InputEvent(); | |
476 | AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (event); | |
477 | //AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event); | |
8ebce41d | 478 | |
e4de0408 | 479 | // Copy from AODs |
480 | if(aodevent) | |
481 | { | |
8ebce41d | 482 | //TClonesArray* inTracks = aodevent ->GetTracks(); |
e4de0408 | 483 | TClonesArray* ouTracks = AODEvent()->GetTracks(); |
8ebce41d | 484 | //new (ouTracks) TClonesArray(*inTracks); |
485 | ||
486 | for (Int_t nTrack = 0; nTrack < aodevent->GetNumberOfTracks(); ++nTrack) | |
487 | { | |
488 | AliAODTrack *track = aodevent->GetTrack(nTrack); | |
489 | ||
490 | new((*ouTracks)[nTrack]) AliAODTrack(*track); | |
491 | } | |
e4de0408 | 492 | |
493 | return; | |
494 | } | |
495 | ||
496 | } | |
497 | ||
498 | //_______________________________________________ | |
499 | void AliAnalysisTaskCaloFilter::FillAODVertices() | |
500 | { | |
501 | // Copy vertices | |
502 | ||
503 | AliVEvent* event = InputEvent(); | |
504 | AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (event); | |
505 | AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event); | |
506 | ||
507 | // set arrays and pointers | |
508 | Double_t pos[3] ; | |
509 | Double_t covVtx[6]; | |
510 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
511 | ||
512 | // Copy from AODs | |
513 | if(aodevent) | |
514 | { | |
515 | TClonesArray* inVertices = aodevent ->GetVertices(); | |
516 | TClonesArray* ouVertices = AODEvent()->GetVertices(); | |
8ebce41d | 517 | |
518 | //new (ouVertices) TClonesArray(*inVertices); | |
519 | ||
520 | for (Int_t nVertices = 0; nVertices < inVertices->GetEntriesFast(); ++nVertices) | |
521 | { | |
522 | AliAODVertex *vertex = (AliAODVertex*)inVertices->At(nVertices); | |
523 | ||
524 | new((*ouVertices)[nVertices]) AliAODVertex(*vertex); | |
525 | } | |
e4de0408 | 526 | |
e4de0408 | 527 | return; |
528 | } | |
7a4cf423 | 529 | |
a8088a22 | 530 | if(!esdevent) return; |
531 | ||
e4de0408 | 532 | // Copy from ESDs |
7a4cf423 | 533 | |
534 | // Access to the AOD container of vertices | |
7a4cf423 | 535 | Int_t jVertices=0; |
e4de0408 | 536 | TClonesArray &vertices = *(AODEvent()->GetVertices()); |
7a4cf423 | 537 | |
538 | // Add primary vertex. The primary tracks will be defined | |
539 | // after the loops on the composite objects (V0, cascades, kinks) | |
247abff4 | 540 | event->GetPrimaryVertex()->GetXYZ(pos); |
a8088a22 | 541 | esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx); |
542 | Float_t chi = esdevent->GetPrimaryVertex()->GetChi2toNDF(); | |
7a4cf423 | 543 | |
544 | AliAODVertex * primary = new(vertices[jVertices++]) | |
e4de0408 | 545 | AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary); |
247abff4 | 546 | primary->SetName(event->GetPrimaryVertex()->GetName()); |
547 | primary->SetTitle(event->GetPrimaryVertex()->GetTitle()); | |
7a4cf423 | 548 | |
e4de0408 | 549 | } |
550 | ||
551 | //__________________________________________________ | |
552 | void AliAnalysisTaskCaloFilter::CorrectionsInEMCAL() | |
553 | { | |
f2ccb5b8 | 554 | //If EMCAL, and requested, correct energy, position ... |
e4de0408 | 555 | |
f2ccb5b8 | 556 | //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations |
e4de0408 | 557 | |
558 | if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) ) | |
559 | { | |
560 | if(!fGeoMatrixSet) | |
561 | { | |
562 | if(fLoadEMCALMatrices) | |
563 | { | |
c0b85449 | 564 | printf("AliAnalysisTaskCaloFilter::UserExec() - Load user defined EMCAL geometry matrices\n"); |
3b13c34c | 565 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ |
566 | if(fEMCALMatrix[mod]){ | |
567 | if(DebugLevel() > 1) | |
568 | fEMCALMatrix[mod]->Print(); | |
569 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ; | |
570 | } | |
571 | fGeoMatrixSet=kTRUE; | |
572 | }//SM loop | |
573 | }//Load matrices | |
e4de0408 | 574 | else if(!gGeoManager) |
575 | { | |
3b13c34c | 576 | printf("AliAnalysisTaskCaloFilter::UserExec() - Get geo matrices from data\n"); |
577 | //Still not implemented in AOD, just a workaround to be able to work at least with ESDs | |
e4de0408 | 578 | if(!strcmp(InputEvent()->GetName(),"AliAODEvent")) |
579 | { | |
3b13c34c | 580 | if(DebugLevel() > 1) |
581 | printf("AliAnalysisTaskCaloFilter Use ideal geometry, values geometry matrix not kept in AODs.\n"); | |
582 | }//AOD | |
e4de0408 | 583 | else |
584 | { | |
3b13c34c | 585 | if(DebugLevel() > 1) printf("AliAnalysisTaskCaloFilter Load Misaligned matrices. \n"); |
e4de0408 | 586 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()) ; |
587 | if(!esd) | |
588 | { | |
3b13c34c | 589 | printf("AliAnalysisTaskCaloFilter::UserExec() - This event does not contain ESDs?"); |
590 | return; | |
591 | } | |
e4de0408 | 592 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++) |
593 | { | |
3b13c34c | 594 | //if(DebugLevel() > 1) |
595 | esd->GetEMCALMatrix(mod)->Print(); | |
596 | if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ; | |
597 | } | |
598 | fGeoMatrixSet=kTRUE; | |
599 | }//ESD | |
600 | }//Load matrices from Data | |
e4de0408 | 601 | |
3b13c34c | 602 | }//first event |
603 | ||
f2ccb5b8 | 604 | //Cluster Loop |
e4de0408 | 605 | Int_t nCaloClus = InputEvent()->GetNumberOfCaloClusters(); |
606 | ||
607 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) | |
608 | { | |
609 | AliVCluster * cluster = InputEvent()->GetCaloCluster(iClust); | |
f2ccb5b8 | 610 | |
f2ccb5b8 | 611 | if(cluster->IsPHOS()) continue ; |
e4de0408 | 612 | |
247abff4 | 613 | Float_t position[]={0,0,0}; |
614 | if(DebugLevel() > 2) | |
615 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
616 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
e4de0408 | 617 | |
247abff4 | 618 | if(DebugLevel() > 2) |
619 | { | |
3b13c34c | 620 | printf("Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",iClust,cluster->E(), |
621 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 622 | cluster->GetPosition(position); |
623 | printf("Filter, before : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
624 | } | |
f2ccb5b8 | 625 | |
3b13c34c | 626 | //Recalculate distance to bad channels, if new list of bad channels provided |
e4de0408 | 627 | fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, InputEvent()->GetEMCALCells(), cluster); |
628 | ||
629 | if(fEMCALRecoUtils->IsRecalibrationOn()) | |
630 | { | |
631 | fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, InputEvent()->GetEMCALCells()); | |
632 | fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster); | |
5ef94e1b | 633 | fEMCALRecoUtils->RecalculateClusterPID(cluster); |
5ef94e1b | 634 | } |
e4de0408 | 635 | |
636 | fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster); | |
f2ccb5b8 | 637 | |
247abff4 | 638 | if(DebugLevel() > 2) |
639 | { | |
3b13c34c | 640 | printf("Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",cluster->GetID(),cluster->E(), |
641 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 642 | cluster->GetPosition(position); |
643 | printf("Filter, after : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
644 | } | |
645 | ||
44907916 | 646 | cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster)); |
647 | ||
f2ccb5b8 | 648 | } |
e4de0408 | 649 | |
f2ccb5b8 | 650 | //Recalculate track-matching |
e4de0408 | 651 | fEMCALRecoUtils->FindMatches(InputEvent(),0,fEMCALGeo); |
f2ccb5b8 | 652 | |
653 | } // corrections in EMCAL | |
7a4cf423 | 654 | } |
655 | ||
e4de0408 | 656 | //_______________________________________________________ |
657 | Bool_t AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() | |
658 | { | |
44cf05d7 | 659 | //Check if the vertex was well reconstructed, copy from V0Reader of conversion group |
660 | //It only works for ESDs | |
661 | ||
662 | AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent()); | |
31364cb2 | 663 | |
e4de0408 | 664 | // AODs |
665 | if(!event) | |
666 | { | |
667 | // Check that the vertex is not (0,0,0) | |
668 | Double_t v[3]; | |
669 | InputEvent()->GetPrimaryVertex()->GetXYZ(v) ; | |
670 | ||
671 | if(TMath::Abs(v[2]) < 1e-6 && | |
672 | TMath::Abs(v[1]) < 1e-6 && | |
673 | TMath::Abs(v[0]) < 1e-6 ) return kFALSE ; | |
674 | ||
675 | return kTRUE; | |
676 | } | |
677 | ||
678 | // ESDs | |
679 | if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) | |
680 | { | |
31364cb2 | 681 | return kTRUE; |
44cf05d7 | 682 | } |
683 | ||
e4de0408 | 684 | if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) |
685 | { | |
44cf05d7 | 686 | // SPD vertex |
e4de0408 | 687 | if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) |
688 | { | |
44cf05d7 | 689 | //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; |
31364cb2 | 690 | return kTRUE; |
44cf05d7 | 691 | |
692 | } | |
e4de0408 | 693 | if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) |
694 | { | |
44cf05d7 | 695 | // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; |
31364cb2 | 696 | return kFALSE; |
44cf05d7 | 697 | } |
698 | } | |
31364cb2 | 699 | return kFALSE; |
e4de0408 | 700 | |
44cf05d7 | 701 | } |
702 | ||
e4de0408 | 703 | //_________________________________________ |
704 | void AliAnalysisTaskCaloFilter::PrintInfo() | |
705 | { | |
5ef94e1b | 706 | //Print settings |
e4de0408 | 707 | |
2ec3a257 | 708 | printf("AnalysisCaloFilter::PrintInfo() \n"); |
5ef94e1b | 709 | printf("\t Not only filter, correct Clusters? %d\n",fCorrect); |
710 | printf("\t Calorimeter Filtering Option ? %d\n",fCaloFilter); | |
3b13c34c | 711 | //printf("\t Use handmade geo matrices? EMCAL %d, PHOS %d\n",fLoadEMCALMatrices, fLoadPHOSMatrices); |
712 | printf("\t Use handmade geo matrices? EMCAL %d, PHOS 0\n",fLoadEMCALMatrices); | |
e4de0408 | 713 | printf("\t Fill AOD file? %d\n", fFillAODFile); |
714 | printf("\t Fill Tracks? %d\n" , fFillTracks); | |
2ec3a257 | 715 | printf("\t Event Selection : EMCAL E > %2.2f, EMCAL nCells >= %d, |vz| < %2.2f\n",fEnergyCut,fNcellsCut,fVzCut); |
7a4cf423 | 716 | } |
717 |