]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/EMCALTasks/AliAnalysisTaskEMCALClusterize.cxx
reviewing typos -- Cath
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliAnalysisTaskEMCALClusterize.cxx
CommitLineData
eef481c6 1 /**************************************************************************
6fdd30c4 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 **************************************************************************/
6fdd30c4 15
16//_________________________________________________________________________
17// This analysis provides a new list of clusters to be used in other analysis
18//
19// Author: Gustavo Conesa Balbastre,
20// Adapted from analysis class from Deepa Thomas
21//
cd231d42 22// $Id$
6fdd30c4 23//_________________________________________________________________________
24
25// --- Root ---
04fcfa08 26#include <TString.h>
27#include <TRefArray.h>
28#include <TClonesArray.h>
29#include <TTree.h>
30#include <TGeoManager.h>
31#include <TROOT.h>
32#include <TInterpreter.h>
33#include <TFile.h>
6fdd30c4 34
35// --- AliRoot Analysis Steering
36#include "AliAnalysisTask.h"
37#include "AliAnalysisManager.h"
38#include "AliESDEvent.h"
39#include "AliGeomManager.h"
40#include "AliVCaloCells.h"
41#include "AliAODCaloCluster.h"
42#include "AliCDBManager.h"
43#include "AliCDBStorage.h"
44#include "AliCDBEntry.h"
45#include "AliLog.h"
46#include "AliVEventHandler.h"
6060ed91 47#include "AliAODInputHandler.h"
3769e0cb 48#include "AliOADBContainer.h"
6fdd30c4 49
50// --- EMCAL
6fdd30c4 51#include "AliEMCALAfterBurnerUF.h"
52#include "AliEMCALGeometry.h"
53#include "AliEMCALClusterizerNxN.h"
54#include "AliEMCALClusterizerv1.h"
cfcbe5d2 55#include "AliEMCALClusterizerv2.h"
6fdd30c4 56#include "AliEMCALRecPoint.h"
57#include "AliEMCALDigit.h"
58#include "AliCaloCalibPedestal.h"
59#include "AliEMCALCalibData.h"
60
61#include "AliAnalysisTaskEMCALClusterize.h"
62
63ClassImp(AliAnalysisTaskEMCALClusterize)
64
6544055e 65//______________________________________________________________________________
6fdd30c4 66AliAnalysisTaskEMCALClusterize::AliAnalysisTaskEMCALClusterize(const char *name)
6544055e 67: AliAnalysisTaskSE(name)
68, fEvent(0)
3769e0cb 69, fGeom(0), fGeomName("")
6544055e 70, fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
71, fCalibData(0), fPedestalData(0)
3769e0cb 72, fOCDBpath(""), fAccessOCDB(kFALSE)
6544055e 73, fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
74, fRecParam(0), fClusterizer(0)
75, fUnfolder(0), fJustUnfold(kFALSE)
6a797202 76, fOutputAODBranch(0), fOutputAODBranchName(""), fOutputAODBranchSet(0)
77, fFillAODFile(kFALSE), fFillAODHeader(0)
6544055e 78, fFillAODCaloCells(0), fRun(-1)
79, fRecoUtils(0), fConfigName("")
80, fCellLabels(), fCellSecondLabels(), fCellTime()
adad4ea9 81, fCellMatchdEta(), fCellMatchdPhi()
3769e0cb 82, fMaxEvent(0), fDoTrackMatching(kFALSE)
83, fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
cb68426a 84, fRemoveLEDEvents(kTRUE),fRemoveExoticEvents(kFALSE)
3769e0cb 85, fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
cb68426a 86, fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath("")
87, fCentralityClass("")
6a8be5c3 88{
b43bdd14 89 // Constructor
90
e3990982 91 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
92 for(Int_t j = 0; j < 24*48*11; j++)
93 {
6a8be5c3 94 fCellLabels[j] = -1;
95 fCellSecondLabels[j] = -1;
adad4ea9 96 fCellTime[j] = 0.;
97 fCellMatchdEta[j] = -999;
98 fCellMatchdPhi[j] = -999;
6a8be5c3 99 }
a39f5b70 100
cb68426a 101 fCentralityBin[0] = fCentralityBin[1]=-1;
a39f5b70 102
6fdd30c4 103}
104
6544055e 105//______________________________________________________________
6fdd30c4 106AliAnalysisTaskEMCALClusterize::AliAnalysisTaskEMCALClusterize()
6544055e 107: AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskEMCALClusterize")
108, fEvent(0)
3769e0cb 109, fGeom(0), fGeomName("")
6544055e 110, fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
111, fCalibData(0), fPedestalData(0)
3769e0cb 112, fOCDBpath(""), fAccessOCDB(kFALSE)
6544055e 113, fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
114, fRecParam(0), fClusterizer(0)
115, fUnfolder(0), fJustUnfold(kFALSE)
6a797202 116, fOutputAODBranch(0), fOutputAODBranchName(""), fOutputAODBranchSet(0)
117, fFillAODFile(kFALSE), fFillAODHeader(0)
6544055e 118, fFillAODCaloCells(0), fRun(-1)
119, fRecoUtils(0), fConfigName("")
120, fCellLabels(), fCellSecondLabels(), fCellTime()
adad4ea9 121, fCellMatchdEta(), fCellMatchdPhi()
3769e0cb 122, fMaxEvent(0), fDoTrackMatching(kFALSE)
123, fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
cb68426a 124, fRemoveLEDEvents(kTRUE), fRemoveExoticEvents(kFALSE)
9ac44255 125, fImportGeometryFromFile(kFALSE), fImportGeometryFilePath("")
cb68426a 126, fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath("")
127, fCentralityClass("")
6fdd30c4 128{
129 // Constructor
b43bdd14 130
e3990982 131 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
132 for(Int_t j = 0; j < 24*48*11; j++)
133 {
37d2296c 134 fCellLabels[j] = -1;
135 fCellSecondLabels[j] = -1;
adad4ea9 136 fCellTime[j] = 0.;
137 fCellMatchdEta[j] = -999;
138 fCellMatchdPhi[j] = -999;
37d2296c 139 }
3af5a372 140
141 fCentralityBin[0] = fCentralityBin[1]=-1;
142
6fdd30c4 143}
144
5994e71f 145
6544055e 146//_______________________________________________________________
6fdd30c4 147AliAnalysisTaskEMCALClusterize::~AliAnalysisTaskEMCALClusterize()
148{
149 //dtor
150
b43bdd14 151 if (fDigitsArr)
152 {
6fdd30c4 153 fDigitsArr->Clear("C");
542e1379 154 delete fDigitsArr;
6fdd30c4 155 }
156
b43bdd14 157 if (fClusterArr)
158 {
6fdd30c4 159 fClusterArr->Delete();
542e1379 160 delete fClusterArr;
6fdd30c4 161 }
162
b43bdd14 163 if (fCaloClusterArr)
164 {
6fdd30c4 165 fCaloClusterArr->Delete();
542e1379 166 delete fCaloClusterArr;
6fdd30c4 167 }
6a8be5c3 168
385b7abf 169 if(fClusterizer) delete fClusterizer;
170 if(fUnfolder) delete fUnfolder;
171 if(fRecoUtils) delete fRecoUtils;
6a8be5c3 172
6fdd30c4 173}
174
3769e0cb 175//_______________________________________________
176void AliAnalysisTaskEMCALClusterize::AccessOADB()
177{
178 // Set the AODB calibration, bad channels etc. parameters at least once
179 // alignment matrices from OADB done in SetGeometryMatrices
180
181 //Set it only once
182 if(fOADBSet) return ;
183
184 Int_t runnumber = InputEvent()->GetRunNumber() ;
185 TString pass = GetPass();
186
187 printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Get AODB parameters from EMCAL in %s for run %d, and <%s> \n",fOADBFilePath.Data(),runnumber,pass.Data());
188
189 Int_t nSM = fGeom->GetNumberOfSuperModules();
190
191 // Bad map
192 if(fRecoUtils->IsBadChannelsRemovalSwitchedOn())
193 {
194 AliOADBContainer *contBC=new AliOADBContainer("");
195 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fOADBFilePath.Data()),"AliEMCALBadChannels");
196
197 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber);
198
199 if(arrayBC)
200 {
3769e0cb 201 fRecoUtils->SwitchOnDistToBadChannelRecalculation();
202 printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Remove EMCAL bad cells \n");
203
204 for (Int_t i=0; i<nSM; ++i)
205 {
206 TH2I *hbm = fRecoUtils->GetEMCALChannelStatusMap(i);
207
208 if (hbm)
209 delete hbm;
210
17e1c80e 211 hbm=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
3769e0cb 212
213 if (!hbm)
214 {
215 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
216 continue;
217 }
218
219 hbm->SetDirectory(0);
220 fRecoUtils->SetEMCALChannelStatusMap(i,hbm);
221
222 } // loop
17e1c80e 223 } else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT remove EMCAL bad channels\n"); // run array
3769e0cb 224 } // Remove bad
225
226 // Energy Recalibration
227 if(fRecoUtils->IsRecalibrationOn())
228 {
229 AliOADBContainer *contRF=new AliOADBContainer("");
230
231 contRF->InitFromFile(Form("%s/EMCALRecalib.root",fOADBFilePath.Data()),"AliEMCALRecalib");
232
233 TObjArray *recal=(TObjArray*)contRF->GetObject(runnumber);
234
235 if(recal)
236 {
237 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
238
239 if(recalpass)
240 {
241 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
242
243 if(recalib)
244 {
245 printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Recalibrate EMCAL \n");
246 for (Int_t i=0; i<nSM; ++i)
247 {
248 TH2F *h = fRecoUtils->GetEMCALChannelRecalibrationFactors(i);
249
250 if (h)
251 delete h;
252
253 h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
254
255 if (!h)
256 {
257 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
258 continue;
259 }
260
261 h->SetDirectory(0);
262
263 fRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
264 } // SM loop
17e1c80e 265 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate EMCAL, no params object array \n"); // array ok
266 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate EMCAL, no params for pass\n"); // array pass ok
267 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate EMCAL, no params for run\n"); // run number array ok
7bf608c9 268
3769e0cb 269 } // Recalibration on
270
7bf608c9 271 // Energy Recalibration, apply on top of previous calibration factors
272 if(fRecoUtils->IsRunDepRecalibrationOn())
273 {
274 AliOADBContainer *contRFTD=new AliOADBContainer("");
275
276 contRFTD->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fOADBFilePath.Data()),"AliEMCALRunDepTempCalibCorrections");
277
278 TH1S *htd=(TH1S*)contRFTD->GetObject(runnumber);
279
280 if(htd)
281 {
282 printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Recalibrate (Temperature) EMCAL \n");
283
284 for (Int_t ism=0; ism<nSM; ++ism)
285 {
286 for (Int_t icol=0; icol<48; ++icol)
287 {
288 for (Int_t irow=0; irow<24; ++irow)
289 {
290 Float_t factor = fRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
291
292 Int_t absID = fGeom->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor
293 factor *= htd->GetBinContent(absID) / 10000. ; // correction dependent on T
294 //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID,
295 // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , htd->GetBinContent(absID) / 10000., factor);
296 fRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
297 } // columns
298 } // rows
299 } // SM loop
300 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate EMCAL with T variations, no params TH1 \n");
301 } // Run by Run T calibration
3769e0cb 302
303 // Time Recalibration
304 if(fRecoUtils->IsTimeRecalibrationOn())
305 {
306 AliOADBContainer *contTRF=new AliOADBContainer("");
307
f46af216 308 contTRF->InitFromFile(Form("%s/EMCALTimeCalib.root",fOADBFilePath.Data()),"AliEMCALTimeCalib");
3769e0cb 309
310 TObjArray *trecal=(TObjArray*)contTRF->GetObject(runnumber);
311
312 if(trecal)
313 {
61841488 314 TString passTmp = pass;
7764134d 315 if(pass!="pass1" && pass!="pass2") passTmp = "pass2"; // TEMPORARY FIX FOR LHC11a analysis
61841488 316 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passTmp);
317
3769e0cb 318 if(trecalpass)
319 {
b43bdd14 320 printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Time Recalibrate EMCAL \n");
f46af216 321 for (Int_t ibc = 0; ibc < 4; ++ibc)
3769e0cb 322 {
f46af216 323 TH1F *h = fRecoUtils->GetEMCALChannelTimeRecalibrationFactors(ibc);
324
325 if (h)
326 delete h;
327
328 h = (TH1F*)trecalpass->FindObject(Form("hAllTimeAvBC%d",ibc));
329
330 if (!h)
3769e0cb 331 {
f46af216 332 AliError(Form("Could not load hAllTimeAvBC%d",ibc));
333 continue;
334 }
335
336 h->SetDirectory(0);
337
338 fRecoUtils->SetEMCALChannelTimeRecalibrationFactors(ibc,h);
339 } // bunch crossing loop
17e1c80e 340 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate time EMCAL, no params for pass\n"); // array pass ok
341 }else printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT recalibrate time EMCAL, no params for run\n"); // run number array ok
3769e0cb 342
343 } // Time recalibration on
344
345 // Parameters already set once, so do not it again
346 fOADBSet = kTRUE;
347
348}
349
6544055e 350//_________________________________________________
351Bool_t AliAnalysisTaskEMCALClusterize::AccessOCDB()
352{
353 //Access to OCDB stuff
1f77507b 354
6544055e 355 fEvent = InputEvent();
356 if (!fEvent)
357 {
358 Warning("AccessOCDB","Event not available!!!");
359 return kFALSE;
1f77507b 360 }
1f77507b 361
6544055e 362 if (fEvent->GetRunNumber()==fRun)
363 return kTRUE;
364 fRun = fEvent->GetRunNumber();
1f77507b 365
6544055e 366 if(DebugLevel() > 1 )
596697e6 367 printf("AliAnalysisTaksEMCALClusterize::AccessOCDB() - Begin");
b43bdd14 368
6544055e 369 AliCDBManager *cdb = AliCDBManager::Instance();
1f77507b 370
1f77507b 371
b43bdd14 372 if (fOCDBpath.Length())
373 {
6544055e 374 cdb->SetDefaultStorage(fOCDBpath.Data());
375 printf("AliAnalysisTaksEMCALClusterize::AccessOCDB() - Default storage %s",fOCDBpath.Data());
376 }
377
378 cdb->SetRun(fEvent->GetRunNumber());
1f77507b 379
380 //
6544055e 381 // EMCAL from RAW OCDB
382 if (fOCDBpath.Contains("alien:"))
383 {
384 cdb->SetSpecificStorage("EMCAL/Calib/Data","alien://Folder=/alice/data/2010/OCDB");
385 cdb->SetSpecificStorage("EMCAL/Calib/Pedestals","alien://Folder=/alice/data/2010/OCDB");
386 }
1f77507b 387
6544055e 388 TString path = cdb->GetDefaultStorage()->GetBaseFolder();
1f77507b 389
6544055e 390 // init parameters:
1f77507b 391
6544055e 392 //Get calibration parameters
393 if(!fCalibData)
394 {
395 AliCDBEntry *entry = (AliCDBEntry*)
396 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
397
398 if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject();
1f77507b 399 }
6544055e 400
401 if(!fCalibData)
402 AliFatal("Calibration parameters not found in CDB!");
403
404 //Get calibration parameters
405 if(!fPedestalData)
406 {
407 AliCDBEntry *entry = (AliCDBEntry*)
408 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
409
410 if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
1f77507b 411 }
412
6544055e 413 if(!fPedestalData)
414 AliFatal("Dead map not found in CDB!");
1f77507b 415
6544055e 416 return kTRUE;
6fdd30c4 417}
418
9ac44255 419//_____________________________________________________
6544055e 420void AliAnalysisTaskEMCALClusterize::CheckAndGetEvent()
6fdd30c4 421{
6544055e 422 // Get the input event, it can depend in embedded events what you want to get
423 // Also check if the quality of the event is good if not reject it
424
425 fEvent = 0x0;
6a8be5c3 426
220447cd 427 AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
428 Int_t eventN = Entry();
429 if(aodIH) eventN = aodIH->GetReadEntry();
430
6544055e 431 if (eventN > fMaxEvent)
432 return ;
f5036bcb 433
c50e6949 434 //printf("Clusterizer --- Event %d-- \n",eventN);
b43bdd14 435
6060ed91 436 //Check if input event are embedded events
437 //If so, take output event
3769e0cb 438 if (aodIH && aodIH->GetMergeEvents())
439 {
6544055e 440 fEvent = AODEvent();
1f77507b 441
442 if(!aodIH->GetMergeEMCALCells())
443 AliFatal("Events merged but not EMCAL cells, check analysis settings!");
444
3769e0cb 445 if(DebugLevel() > 1)
446 {
447 printf("AliAnalysisTaksEMCALClusterize::UserExec() - Use embedded events\n");
448
449 printf("\t InputEvent N Clusters %d, N Cells %d\n",InputEvent()->GetNumberOfCaloClusters(),
450 InputEvent()->GetEMCALCells()->GetNumberOfCells());
451
452 printf("\t MergedEvent N Clusters %d, N Cells %d\n",aodIH->GetEventToMerge()->GetNumberOfCaloClusters(),
453 aodIH->GetEventToMerge()->GetEMCALCells()->GetNumberOfCells());
454
455 for (Int_t icl=0; icl < aodIH->GetEventToMerge()->GetNumberOfCaloClusters(); icl++)
456 {
457 AliAODCaloCluster *sigCluster = aodIH->GetEventToMerge()->GetCaloCluster(icl);
458 if(sigCluster->IsEMCAL()) printf("\t \t Signal cluster: i %d, E %f\n",icl,sigCluster->E());
459 }
460
461 printf("\t OutputEvent N Clusters %d, N Cells %d\n", AODEvent()->GetNumberOfCaloClusters(),
462 AODEvent()->GetEMCALCells()->GetNumberOfCells());
6544055e 463 }
6060ed91 464 }
3769e0cb 465 else
466 {
6544055e 467 fEvent = InputEvent();
1f77507b 468 if(fFillAODCaloCells) FillAODCaloCells();
469 if(fFillAODHeader) FillAODHeader();
6060ed91 470 }
471
3769e0cb 472 if (!fEvent)
473 {
3fa4fb85 474 Error("UserExec","Event not available");
6544055e 475 return ;
6fdd30c4 476 }
6a8be5c3 477
cd2e4ce6 478 //-------------------------------------------------------------------------------------
6544055e 479 // Reject events if LED was firing, use only for LHC11a data
480 // Reject event if triggered by exotic cell and remove exotic cells if not triggered
cd2e4ce6 481 //-------------------------------------------------------------------------------------
6544055e 482
3769e0cb 483 if( IsLEDEvent( InputEvent()->GetRunNumber() ) ) { fEvent = 0x0 ; return ; }
6544055e 484
3769e0cb 485 if( IsExoticEvent() ) { fEvent = 0x0 ; return ; }
cd2e4ce6 486
6a797202 487 //-------------------------------------------------------------------------------------
488 // Set the cluster array in the event (output or input)
489 //-------------------------------------------------------------------------------------
490
491 if ( fFillAODFile )
492 {
493 //Magic line to write events to AOD filem put after event rejection
494 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
495 }
496 else if( !fOutputAODBranchSet )
497 {
498 // Create array and put it in the input event, if output AOD not selected, only once
499 InputEvent()->AddObject(fOutputAODBranch);
500 fOutputAODBranchSet = kTRUE;
501 printf("AliAnalysisTaskEMCALClusterize::UserExec() - Add AOD branch <%s> to input event\n",fOutputAODBranchName.Data());
502 }
6544055e 503
504}
505
506//____________________________________________________
507void AliAnalysisTaskEMCALClusterize::ClusterizeCells()
508{
509 // Recluster calocells, transform them into digits,
510 // feed the clusterizer with them and get new list of clusters
511
512 //In case of MC, first loop on the clusters and fill MC label to array
513 Int_t nClusters = fEvent->GetNumberOfCaloClusters();
514 Int_t nClustersOrg = 0;
b43bdd14 515
6544055e 516 AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
517 if(aodIH && aodIH->GetEventToMerge()) //Embedding
518 nClusters = aodIH->GetEventToMerge()->GetNumberOfCaloClusters(); //Get clusters directly from embedded signal
f5036bcb 519
6544055e 520 for (Int_t i = 0; i < nClusters; i++)
521 {
522 AliVCluster *clus = 0;
523 if(aodIH && aodIH->GetEventToMerge()) //Embedding
524 clus = aodIH->GetEventToMerge()->GetCaloCluster(i); //Get clusters directly from embedded signal
525 else
526 clus = fEvent->GetCaloCluster(i);
5994e71f 527
6544055e 528 if(!clus) return;
6a8be5c3 529
f46af216 530 if(clus->IsEMCAL())
531 {
6544055e 532 Int_t label = clus->GetLabel();
533 Int_t label2 = -1 ;
73a4ed8f 534 //printf("Org cluster E %f, Time %e, Id = ", clus->E(), clus->GetTOF() );
6544055e 535 if (clus->GetNLabels()>=2) label2 = clus->GetLabelAt(1) ;
536 UShort_t * index = clus->GetCellsAbsId() ;
f46af216 537 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
538 {
6544055e 539 fCellLabels[index[icell]] = label;
540 fCellSecondLabels[index[icell]] = label2;
73a4ed8f 541 fCellTime[index[icell]] = clus->GetTOF();
542 fCellMatchdEta[index[icell]] = clus->GetTrackDz();
543 fCellMatchdPhi[index[icell]] = clus->GetTrackDx();
544 //printf(" %d,", index[icell] );
6fdd30c4 545 }
6544055e 546 nClustersOrg++;
6fdd30c4 547 }
b43bdd14 548 // printf("\n");
6544055e 549 }
550
551 // Transform CaloCells into Digits
b43bdd14 552
6544055e 553 Int_t idigit = 0;
554 Int_t id = -1;
555 Float_t amp = -1;
556 Double_t time = -1;
557
558 AliVCaloCells *cells = fEvent->GetEMCALCells();
b43bdd14 559
a7e5a381 560 Int_t bc = InputEvent()->GetBunchCrossNumber();
6544055e 561 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
562 {
6544055e 563 // Get cell values, recalibrate and not include bad channels found in analysis, nor cells with too low energy, nor exotic cell
564 id = cells->GetCellNumber(icell);
a7e5a381 565 Bool_t accept = fRecoUtils->AcceptCalibrateCell(id,bc,amp,time,cells);
566
567 // Do not include cells with too low energy, nor exotic cell
568 if(amp < fRecParam->GetMinECut() ) accept = kFALSE;
569
570 // In case of AOD analysis cell time is 0, approximate replacing by time of the cluster the digit belongs.
3769e0cb 571 if (time*1e9 < 1.)
572 {
a7e5a381 573 time = fCellTime[id];
f46af216 574 //printf("cell %d time org %f - ",id, time*1.e9);
a7e5a381 575 fRecoUtils->RecalibrateCellTime(id,bc,time);
f46af216 576 //printf("recal %f\n",time*1.e9);
a7e5a381 577 }
578
3769e0cb 579 if( accept && fRecoUtils->IsExoticCell(id,cells,bc))
580 {
a7e5a381 581 accept = kFALSE;
582 }
b43bdd14 583
f46af216 584 if( !accept )
585 {
6544055e 586 fCellLabels[id] =-1; //reset the entry in the array for next event
587 fCellSecondLabels[id]=-1; //reset the entry in the array for next event
adad4ea9 588 fCellTime[id] = 0.;
589 fCellMatchdEta[id] =-999;
590 fCellMatchdPhi[id] =-999;
f46af216 591 if( DebugLevel() > 2 )
592 printf("AliAnalysisTaksEMCALClusterize::ClusterizeCells() - Remove channel absId %d, index %d of %d, amp %f, time %f\n",
b43bdd14 593 id,icell, cells->GetNumberOfCells(), amp, time*1.e9);
6544055e 594 continue;
595 }
b43bdd14 596
6544055e 597 //Create the digit, put a fake primary deposited energy to trick the clusterizer when checking the most likely primary
598 new((*fDigitsArr)[idigit]) AliEMCALDigit( fCellLabels[id], fCellLabels[id],id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, 1);
b43bdd14 599
04fcfa08 600 fCellLabels[id] =-1; //reset the entry in the array for next event
6fdd30c4 601
6544055e 602 idigit++;
603 }
6a8be5c3 604
04fcfa08 605 fDigitsArr->Sort();
b43bdd14 606
6544055e 607 //-------------------------------------------------------------------------------------
608 //Do the clusterization
609 //-------------------------------------------------------------------------------------
b43bdd14 610
6544055e 611 fClusterizer->Digits2Clusters("");
612
613 //-------------------------------------------------------------------------------------
614 //Transform the recpoints into AliVClusters
615 //-------------------------------------------------------------------------------------
616
b43bdd14 617 RecPoints2Clusters();
6544055e 618
3769e0cb 619 if(!fCaloClusterArr)
620 {
6544055e 621 printf("AliAnalysisTaksEMCALClusterize::UserExec() - No array with CaloClusters, input RecPoints entries %d\n",fClusterArr->GetEntriesFast());
622 return;
623 }
624
3769e0cb 625 if( DebugLevel() > 0 )
626 {
6544055e 627 printf("AliAnalysisTaksEMCALClusterize::ClusterizeCells() - N clusters: before recluster %d, after recluster %d\n",nClustersOrg, fCaloClusterArr->GetEntriesFast());
b43bdd14 628
629 if(fCaloClusterArr->GetEntriesFast() != fClusterArr->GetEntriesFast())
630 {
6544055e 631 printf("\t Some RecRoints not transformed into CaloClusters (clusterizer %d, unfold %d): Input entries %d - Output entries %d - %d (not fast)\n",
632 fRecParam->GetClusterizerFlag(),fRecParam->GetUnfold(),
633 fClusterArr->GetEntriesFast(), fCaloClusterArr->GetEntriesFast(), fCaloClusterArr->GetEntries());
634 }
635 }
636
637 //Reset the array with second labels for this event
638 memset(fCellSecondLabels, -1, sizeof(fCellSecondLabels));
b43bdd14 639
6544055e 640}
a39f5b70 641
73a4ed8f 642//_____________________________________________________
6544055e 643void AliAnalysisTaskEMCALClusterize::ClusterUnfolding()
644{
645 // Take the event clusters and unfold them
646
647 AliVCaloCells *cells = fEvent->GetEMCALCells();
648 Double_t cellAmplitude = 0;
649 Double_t cellTime = 0;
650 Short_t cellNumber = 0;
77e93dc2 651 Short_t cellMCLabel = 0;
652 Double_t cellEFrac = 0;
6544055e 653 Int_t nClustersOrg = 0;
654
655 // Fill the array with the EMCAL clusters, copy them
656 for (Int_t i = 0; i < fEvent->GetNumberOfCaloClusters(); i++)
657 {
658 AliVCluster *clus = fEvent->GetCaloCluster(i);
b43bdd14 659 if(clus->IsEMCAL())
660 {
6544055e 661 //recalibrate/remove bad channels/etc if requested
b43bdd14 662 if(fRecoUtils->ClusterContainsBadChannel(fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
663 {
5994e71f 664 continue;
6544055e 665 }
3bfc4732 666
b43bdd14 667 if(fRecoUtils->IsRecalibrationOn())
668 {
6544055e 669 //Calibrate cluster
670 fRecoUtils->RecalibrateClusterEnergy(fGeom, clus, cells);
671
672 //CalibrateCells
673 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
674 {
77e93dc2 675 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
6544055e 676 break;
677
678 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
679 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
680 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
681
682 //Do not include bad channels found in analysis?
683 if( fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
b43bdd14 684 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
685 {
6544055e 686 fCellLabels[cellNumber] =-1; //reset the entry in the array for next event
687 fCellSecondLabels[cellNumber]=-1; //reset the entry in the array for next event
adad4ea9 688 fCellTime[cellNumber] = 0.;
689 fCellMatchdEta[cellNumber] =-999;
690 fCellMatchdPhi[cellNumber] =-999;
6544055e 691 continue;
692 }
693
694 cells->SetCell(icell, cellNumber, cellAmplitude*fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
695
696 }// cells loop
697 }// recalibrate
5994e71f 698
6544055e 699 //Cast to ESD or AOD, needed to create the cluster array
700 AliESDCaloCluster * esdCluster = dynamic_cast<AliESDCaloCluster*> (clus);
701 AliAODCaloCluster * aodCluster = dynamic_cast<AliAODCaloCluster*> (clus);
b43bdd14 702
703 if (esdCluster)
704 {
6544055e 705 fCaloClusterArr->Add( new AliESDCaloCluster(*esdCluster) );
706 }//ESD
b43bdd14 707 else if(aodCluster)
708 {
6544055e 709 fCaloClusterArr->Add( new AliAODCaloCluster(*aodCluster) );
710 }//AOD
711 else
712 Warning("UserExec()"," - Wrong CaloCluster type?");
b43bdd14 713
6544055e 714 nClustersOrg++;
6a8be5c3 715 }
6fdd30c4 716 }
717
6544055e 718 //Do the unfolding
719 fUnfolder->UnfoldClusters(fCaloClusterArr, cells);
6a8be5c3 720
6544055e 721 //CLEAN-UP
722 fUnfolder->Clear();
385b7abf 723
6544055e 724}
725
726//_____________________________________________________
727void AliAnalysisTaskEMCALClusterize::FillAODCaloCells()
728{
729 // Put calo cells in standard branch
730 AliVCaloCells &eventEMcells = *(fEvent->GetEMCALCells());
731 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
6fdd30c4 732
6544055e 733 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
734 aodEMcells.CreateContainer(nEMcell);
735 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
736 Double_t calibFactor = 1.;
b43bdd14 737 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
738 {
6544055e 739 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
740 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
741 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
385b7abf 742
b43bdd14 743 if(fRecoUtils->IsRecalibrationOn())
744 {
6544055e 745 calibFactor = fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
385b7abf 746 }
0821ba9f 747
b43bdd14 748 if(!fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
749 { //Channel is not declared as bad
77e93dc2 750 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
751 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
6544055e 752 }
b43bdd14 753 else
754 {
77e93dc2 755 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
5994e71f 756 }
6fdd30c4 757 }
6544055e 758 aodEMcells.Sort();
6fdd30c4 759
6544055e 760}
6fdd30c4 761
6544055e 762//__________________________________________________
763void AliAnalysisTaskEMCALClusterize::FillAODHeader()
6fdd30c4 764{
6544055e 765 //Put event header information in standard AOD branch
e9dd2d80 766
6544055e 767 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (fEvent);
768 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (fEvent);
e9dd2d80 769
6544055e 770 Double_t pos[3] ;
771 Double_t covVtx[6];
772 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
773
774 AliAODHeader* header = AODEvent()->GetHeader();
775 header->SetRunNumber(fEvent->GetRunNumber());
776
b43bdd14 777 if(esdevent)
778 {
6544055e 779 TTree* tree = fInputHandler->GetTree();
b43bdd14 780 if (tree)
781 {
6544055e 782 TFile* file = tree->GetCurrentFile();
783 if (file) header->SetESDFileName(file->GetName());
784 }
785 }
786 else if (aodevent) header->SetESDFileName(aodevent->GetHeader()->GetESDFileName());
e9dd2d80 787
6544055e 788 header->SetBunchCrossNumber(fEvent->GetBunchCrossNumber());
789 header->SetOrbitNumber(fEvent->GetOrbitNumber());
790 header->SetPeriodNumber(fEvent->GetPeriodNumber());
791 header->SetEventType(fEvent->GetEventType());
385b7abf 792
6544055e 793 //Centrality
b43bdd14 794 if(fEvent->GetCentrality())
6544055e 795 header->SetCentrality(new AliCentrality(*(fEvent->GetCentrality())));
b43bdd14 796 else
6544055e 797 header->SetCentrality(0);
385b7abf 798
6544055e 799 //Trigger
800 header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection
801 if (esdevent) header->SetFiredTriggerClasses(esdevent->GetFiredTriggerClasses());
802 else if (aodevent) header->SetFiredTriggerClasses(aodevent->GetFiredTriggerClasses());
b43bdd14 803
6544055e 804 header->SetTriggerMask(fEvent->GetTriggerMask());
805 header->SetTriggerCluster(fEvent->GetTriggerCluster());
b43bdd14 806
807 if (esdevent)
808 {
6544055e 809 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
810 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
811 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
812 }
b43bdd14 813 else if (aodevent)
814 {
6544055e 815 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
816 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
817 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
818 }
e9dd2d80 819
6544055e 820 header->SetMagneticField(fEvent->GetMagneticField());
821 //header->SetMuonMagFieldScale(esdevent->GetCurrentDip()/6000.);
e9dd2d80 822
6544055e 823 header->SetZDCN1Energy(fEvent->GetZDCN1Energy());
824 header->SetZDCP1Energy(fEvent->GetZDCP1Energy());
825 header->SetZDCN2Energy(fEvent->GetZDCN2Energy());
826 header->SetZDCP2Energy(fEvent->GetZDCP2Energy());
827 header->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0),fEvent->GetZDCEMEnergy(1));
385b7abf 828
6544055e 829 Float_t diamxy[2]={fEvent->GetDiamondX(),fEvent->GetDiamondY()};
830 Float_t diamcov[3];
831 fEvent->GetDiamondCovXY(diamcov);
832 header->SetDiamond(diamxy,diamcov);
833 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
834 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
e9dd2d80 835
6544055e 836 //
837 Int_t nVertices = 1 ;/* = prim. vtx*/;
838 Int_t nCaloClus = fEvent->GetNumberOfCaloClusters();
e9dd2d80 839
6544055e 840 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
385b7abf 841
6544055e 842 // Access to the AOD container of vertices
843 TClonesArray &vertices = *(AODEvent()->GetVertices());
844 Int_t jVertices=0;
385b7abf 845
6544055e 846 // Add primary vertex. The primary tracks will be defined
847 // after the loops on the composite objects (V0, cascades, kinks)
848 fEvent->GetPrimaryVertex()->GetXYZ(pos);
849 Float_t chi = 0;
b43bdd14 850 if (esdevent)
851 {
6544055e 852 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
853 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
854 }
b43bdd14 855 else if (aodevent)
856 {
6544055e 857 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
858 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();//Different from ESD?
6fdd30c4 859 }
bd9e8ebd 860
6544055e 861 AliAODVertex * primary = new(vertices[jVertices++])
862 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
863 primary->SetName(fEvent->GetPrimaryVertex()->GetName());
864 primary->SetTitle(fEvent->GetPrimaryVertex()->GetTitle());
e9dd2d80 865
6544055e 866}
867
afc22931 868//___________________________________________________________
869void AliAnalysisTaskEMCALClusterize::FillCaloClusterInEvent()
b43bdd14 870{
871 // Get the CaloClusters array, do some final calculations
afc22931 872 // and put the clusters in the output or input event
873 // as a separate branch
b43bdd14 874
875 //First recalculate track-matching for the new clusters
876 if(fDoTrackMatching)
877 {
878 fRecoUtils->FindMatches(fEvent,fCaloClusterArr,fGeom);
879 }
880 //Put the new clusters in the AOD list
881
882 Int_t kNumberOfCaloClusters = fCaloClusterArr->GetEntriesFast();
596697e6 883
b43bdd14 884 for(Int_t i = 0; i < kNumberOfCaloClusters; i++)
885 {
886 AliAODCaloCluster *newCluster = (AliAODCaloCluster *) fCaloClusterArr->At(i);
887
888 newCluster->SetID(i);
889
afc22931 890 // Correct cluster energy non linearity
891 newCluster->SetE(fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
892
b43bdd14 893 //Add matched track
894 if(fDoTrackMatching)
895 {
896 Int_t trackIndex = fRecoUtils->GetMatchedTrackIndex(i);
897 if(trackIndex >= 0)
898 {
899 newCluster->AddTrackMatched(fEvent->GetTrack(trackIndex));
900 if(DebugLevel() > 1)
901 printf("AliAnalysisTaksEMCALClusterize::UserExec() - Matched Track index %d to new cluster %d \n",trackIndex,i);
902 }
903
904 Float_t dR = 999., dZ = 999.;
905 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dR,dZ);
906 newCluster->SetTrackDistance(dR,dZ);
907
908 }
909 else
910 {// Assign previously assigned matched track in reco, very very rough
911 Int_t absId0 = newCluster->GetCellsAbsId()[0]; // Assign match of first cell in cluster
912 newCluster->SetTrackDistance(fCellMatchdPhi[absId0],fCellMatchdEta[absId0]);
913 }
914
915 //printf("New cluster E %f, Time %e, Id = ", newCluster->E(), newCluster->GetTOF() );
916 //for(Int_t icell=0; icell < newCluster->GetNCells(); icell++ ) printf(" %d,", newCluster->GetCellsAbsId() [icell] );
917 //printf("\n");
918
919 // Calculate distance to bad channel for new cluster. Make sure you give the list of bad channels.
920 fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fEvent->GetEMCALCells(), newCluster);
921
922 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
923
924 if(DebugLevel() > 1 )
925 printf("AliAnalysisTaksEMCALClusterize::UserExec() - New cluster %d of %d, energy %f\n",newCluster->GetID(), kNumberOfCaloClusters, newCluster->E());
926
927 } // cluster loop
928
929 fOutputAODBranch->Expand(kNumberOfCaloClusters); // resize TObjArray to 'remove' slots
930
b43bdd14 931
932}
933
3769e0cb 934//_______________________________________________
935TString AliAnalysisTaskEMCALClusterize::GetPass()
936{
937 // Get passx from filename.
938
939 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
940 {
941 AliError("AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null\n");
942 return TString("");
943 }
944
945 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
946 {
947 AliError("AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null\n");
948 return TString("");
949 }
950
951 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
952 if (pass.Contains("ass1")) return TString("pass1");
953 else if (pass.Contains("ass2")) return TString("pass2");
954 else if (pass.Contains("ass3")) return TString("pass3");
61841488 955 else if (pass.Contains("ass4")) return TString("pass4");
956 else if (pass.Contains("ass5")) return TString("pass5");
3769e0cb 957
958 // No condition fullfilled, give a default value
959 printf("AliAnalysisTaskEMCALClusterize::GetPass() - Pass number string not found \n");
960 return TString("");
961
962}
963
6544055e 964//_________________________________________
965void AliAnalysisTaskEMCALClusterize::Init()
966{
967 //Init analysis with configuration macro if available
968
3769e0cb 969 fOADBSet = kFALSE;
970 if(fOADBFilePath == "") fOADBFilePath = "$ALICE_ROOT/OADB/EMCAL" ;
971
3769e0cb 972 fBranchNames = "ESD:AliESDHeader.,EMCALCells.";
973
974 if(!fRecParam) fRecParam = new AliEMCALRecParam;
975 if(!fRecoUtils) fRecoUtils = new AliEMCALRecoUtils();
976
977 if(fMaxEvent <= 0) fMaxEvent = 1000000000;
978 if(fSelectCellMinE <= 0) fSelectCellMinE = 0.005;
979 if(fSelectCellMinFrac <= 0) fSelectCellMinFrac = 0.001;
980
cb68426a 981 //Centrality
982 if(fCentralityClass == "") fCentralityClass = "V0M";
cb68426a 983
3769e0cb 984 if (fOCDBpath == "") fOCDBpath = "raw://" ;
985 if (fOutputAODBranchName == "") fOutputAODBranchName = "newEMCALClusters" ;
986
987 if(gROOT->LoadMacro(fConfigName) >=0)
988 {
6544055e 989 printf("AliAnalysisTaksEMCALClusterize::Init() - Configure analysis with %s\n",fConfigName.Data());
990 AliAnalysisTaskEMCALClusterize *clus = (AliAnalysisTaskEMCALClusterize*)gInterpreter->ProcessLine("ConfigEMCALClusterize()");
991 fGeomName = clus->fGeomName;
992 fLoadGeomMatrices = clus->fLoadGeomMatrices;
993 fOCDBpath = clus->fOCDBpath;
994 fAccessOCDB = clus->fAccessOCDB;
995 fRecParam = clus->fRecParam;
996 fJustUnfold = clus->fJustUnfold;
997 fFillAODFile = clus->fFillAODFile;
998 fRecoUtils = clus->fRecoUtils;
999 fConfigName = clus->fConfigName;
1000 fMaxEvent = clus->fMaxEvent;
1001 fDoTrackMatching = clus->fDoTrackMatching;
1002 fOutputAODBranchName = clus->fOutputAODBranchName;
e3990982 1003 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = clus->fGeomMatrix[i] ;
cb68426a 1004 fCentralityClass = clus->fCentralityClass;
1005 fCentralityBin[0] = clus->fCentralityBin[0];
1006 fCentralityBin[1] = clus->fCentralityBin[1];
6fdd30c4 1007 }
e9dd2d80 1008
9ac44255 1009 // Init geometry, I do not like much to do it like this ...
3769e0cb 1010 if(fImportGeometryFromFile && !gGeoManager)
1011 {
d86974bb 1012 if (fImportGeometryFilePath == "") fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root" ; // "$ALICE_ROOT/EVE/alice-data/default_geo.root"
3769e0cb 1013 printf("AliAnalysisTaskEMCALClusterize::Init() - Import %s\n",fImportGeometryFilePath.Data());
1014 TGeoManager::Import(fImportGeometryFilePath) ;
9ac44255 1015 }
b43bdd14 1016
6544055e 1017}
6fdd30c4 1018
6544055e 1019//_______________________________________________________
6fdd30c4 1020void AliAnalysisTaskEMCALClusterize::InitClusterization()
1021{
1022 //Select clusterization/unfolding algorithm and set all the needed parameters
1023
04fcfa08 1024 if (fJustUnfold)
1025 {
bd9e8ebd 1026 // init the unfolding afterburner
1027 delete fUnfolder;
1759f743 1028 fUnfolder = new AliEMCALAfterBurnerUF(fRecParam->GetW0(),fRecParam->GetLocMaxCut(),fRecParam->GetMinECut());
bd9e8ebd 1029 return;
6a8be5c3 1030 }
1031
bd9e8ebd 1032 //First init the clusterizer
1033 delete fClusterizer;
1034 if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1035 fClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData, fPedestalData);
cfcbe5d2 1036 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1037 fClusterizer = new AliEMCALClusterizerv2(fGeom, fCalibData, fPedestalData);
b43bdd14 1038 else if(fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1039 {
bd9e8ebd 1040 fClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData, fPedestalData);
212ac797 1041 fClusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
1042 fClusterizer->SetNColDiff(fRecParam->GetNColDiff());
04fcfa08 1043 }
1044 else
1045 {
bd9e8ebd 1046 AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
1047 }
6a8be5c3 1048
bd9e8ebd 1049 //Now set the parameters
1050 fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() );
1051 fClusterizer->SetECALogWeight ( fRecParam->GetW0() );
1052 fClusterizer->SetMinECut ( fRecParam->GetMinECut() );
1053 fClusterizer->SetUnfolding ( fRecParam->GetUnfold() );
1054 fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() );
1055 fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() );
1056 fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() );
1057 fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() );
1058 fClusterizer->SetInputCalibrated ( kTRUE );
2af35150 1059 fClusterizer->SetJustClusters ( kTRUE );
04fcfa08 1060
1061 // Initialize the cluster rec points and digits arrays and get them.
1062 fClusterizer->SetOutput(0);
1063 fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
1064 fDigitsArr = fClusterizer->GetDigits();
1065
bd9e8ebd 1066 //In case of unfolding after clusterization is requested, set the corresponding parameters
04fcfa08 1067 if(fRecParam->GetUnfold())
1068 {
bd9e8ebd 1069 Int_t i=0;
04fcfa08 1070 for (i = 0; i < 8; i++)
1071 {
bd9e8ebd 1072 fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i));
1073 }//end of loop over parameters
04fcfa08 1074
1075 for (i = 0; i < 3; i++)
1076 {
bd9e8ebd 1077 fClusterizer->SetPar5 (i, fRecParam->GetPar5(i));
1078 fClusterizer->SetPar6 (i, fRecParam->GetPar6(i));
1079 }//end of loop over parameters
6fdd30c4 1080
bd9e8ebd 1081 fClusterizer->InitClusterUnfolding();
6544055e 1082
bd9e8ebd 1083 }// to unfold
6fdd30c4 1084}
3fa4fb85 1085
6544055e 1086//_________________________________________________
1087void AliAnalysisTaskEMCALClusterize::InitGeometry()
1088{
3769e0cb 1089 // Init geometry and set the geometry matrix, for the first event, skip the rest
6544055e 1090 // Also set once the run dependent calibrations
1091
3769e0cb 1092 if(fGeomMatrixSet) return;
1093
1094 Int_t runnumber = InputEvent()->GetRunNumber() ;
1095 if (!fGeom)
1096 {
1097 if(fGeomName=="")
1098 {
1099 if (runnumber < 140000) fGeomName = "EMCAL_FIRSTYEARV1";
1100 else if(runnumber < 171000) fGeomName = "EMCAL_COMPLETEV1";
1101 else fGeomName = "EMCAL_COMPLETE12SMV1";
1102 printf("AliAnalysisTaskEMCALClusterize::InitGeometry() - Set EMCAL geometry name to <%s> for run %d\n",fGeomName.Data(),runnumber);
1103 }
6544055e 1104
3769e0cb 1105 fGeom = AliEMCALGeometry::GetInstance(fGeomName);
6544055e 1106
3769e0cb 1107 if(fDebug > 0)
1108 {
1109 printf("AliAnalysisTaskEMCALClusterize::InitGeometry(run=%d)",runnumber);
1110 if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices");
1111 printf("\n");
1112 }
1113 } // geometry pointer did not exist before
1114
1115 if(fLoadGeomMatrices)
1116 {
1117 printf("AliAnalysisTaskEMCALClusterize::InitGeometry() - Load user defined EMCAL geometry matrices\n");
1118
1119 // OADB if available
1120 AliOADBContainer emcGeoMat("AliEMCALgeo");
1121 emcGeoMat.InitFromFile(Form("%s/EMCALlocal2master.root",fOADBFilePath.Data()),"AliEMCALgeo");
1122 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,"EmcalMatrices");
1123
1124
1125 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1126 {
1127
1128 if (!fGeomMatrix[mod]) // Get it from OADB
1129 {
1130 if(fDebug > 1 )
1131 printf("AliAnalysisTaskEMCALClusterize::InitGeometry() - EMCAL matrices SM %d, %p\n",
1132 mod,((TGeoHMatrix*) matEMCAL->At(mod)));
1133 //((TGeoHMatrix*) matEMCAL->At(mod))->Print();
1134
1135 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1136 }
1137
1138 if(fGeomMatrix[mod])
1139 {
1140 if(DebugLevel() > 1)
1141 fGeomMatrix[mod]->Print();
1142
1143 fGeom->SetMisalMatrix(fGeomMatrix[mod],mod) ;
1144 }
1145
1146 fGeomMatrixSet=kTRUE;
1147
1148 }//SM loop
1149 }//Load matrices
1150 else if(!gGeoManager)
1151 {
1152 printf("AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1153 //Still not implemented in AOD, just a workaround to be able to work at least with ESDs
1154 if(!strcmp(fEvent->GetName(),"AliAODEvent"))
1155 {
1156 if(DebugLevel() > 1)
1157 Warning("UserExec","Use ideal geometry, values geometry matrix not kept in AODs.");
1158 }//AOD
1159 else
1160 {
1161 if(DebugLevel() > 1)
1162 printf("AliAnalysisTaksEMCALClusterize::InitGeometry() - AliAnalysisTaskEMCALClusterize Load Misaligned matrices.");
1163
1164 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(fEvent) ;
1165
1166 if(!esd)
1167 {
1168 Error("InitGeometry"," - This event does not contain ESDs?");
6a797202 1169 if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
3769e0cb 1170 return;
1171 }
1172
1173 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1174 {
1175 if(DebugLevel() > 1)
1176 esd->GetEMCALMatrix(mod)->Print();
1177
1178 if(esd->GetEMCALMatrix(mod)) fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1179
1180 }
1181
1182 fGeomMatrixSet=kTRUE;
1183
1184 }//ESD
1185 }//Load matrices from Data
1186
6544055e 1187}
1188
6544055e 1189//____________________________________________________
1190Bool_t AliAnalysisTaskEMCALClusterize::IsExoticEvent()
1191{
1192
1193 // Check if event is exotic, get an exotic cell and compare with triggered patch
1194 // If there is a match remove event ... to be completed, filled with something provisional
1195
1196 if(!fRemoveExoticEvents) return kFALSE;
1197
1198 // Loop on cells
1199 AliVCaloCells * cells = fEvent->GetEMCALCells();
1200 Float_t totCellE = 0;
a7e5a381 1201 Int_t bc = InputEvent()->GetBunchCrossNumber();
b43bdd14 1202 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1203 {
6544055e 1204
1205 Float_t ecell = 0 ;
1206 Double_t tcell = 0 ;
1207
1208 Int_t absID = cells->GetCellNumber(icell);
a7e5a381 1209 Bool_t accept = fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1210 if(accept && !fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
6544055e 1211 }
1212
1213 // TString triggerclasses = "";
1214 // if(esdevent) triggerclasses = esdevent ->GetFiredTriggerClasses();
1215 // else triggerclasses = ((AliAODEvent*)event)->GetFiredTriggerClasses();
1216 // //
1217 // printf("AliAnalysisTaskEMCALClusterize - reject event %d with cluster - reject event with ncells in SM3 %d and SM4 %d\n",(Int_t)Entry(),ncellsSM3, ncellsSM4);
6a797202 1218 // if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
6544055e 1219 // return;
1220 //
1221
1222 //printf("TotE cell %f\n",totCellE);
1223 if(totCellE < 1) return kTRUE;
1224
1225 return kFALSE;
1226
1227}
1228
3769e0cb 1229//________________________________________________________________
1230Bool_t AliAnalysisTaskEMCALClusterize::IsLEDEvent(const Int_t run)
6544055e 1231{
1232 //Check if event is LED
1233
1234 if(!fRemoveLEDEvents) return kFALSE;
3769e0cb 1235
1236 //check events of LHC11a period
b9d6234e 1237 if(run < 146858 || run > 146860) return kFALSE ;
3769e0cb 1238
6544055e 1239 // Count number of cells with energy larger than 0.1 in SM3, cut on this number
1240 Int_t ncellsSM3 = 0;
6544055e 1241 AliVCaloCells * cells = fEvent->GetEMCALCells();
3769e0cb 1242 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1243 {
6544055e 1244 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
6544055e 1245 }
1246
1247 TString triggerclasses = "";
1248
1249 AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(fEvent);
1250 if(esdevent) triggerclasses = esdevent ->GetFiredTriggerClasses();
1251 else triggerclasses = ((AliAODEvent*)fEvent)->GetFiredTriggerClasses();
1252
1253 Int_t ncellcut = 21;
1254 if(triggerclasses.Contains("EMC")) ncellcut = 35;
1255
b9d6234e 1256 if( ncellsSM3 >= ncellcut)
3769e0cb 1257 {
b9d6234e 1258 printf("AliAnalysisTaksEMCALClusterize::IsLEDEvent() - reject event %d with ncells in SM3 %d\n",(Int_t)Entry(),ncellsSM3);
6a797202 1259 if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
6544055e 1260 return kTRUE;
1261 }
1262
1263 return kFALSE;
1264
1265}
1266
b43bdd14 1267//_______________________________________________________
1268void AliAnalysisTaskEMCALClusterize::RecPoints2Clusters()
6fdd30c4 1269{
1270 // Restore clusters from recPoints
b43bdd14 1271 // Cluster energy, global position, cells and their amplitude
1272 // fractions are restored
1273
6a8be5c3 1274 Int_t j = 0;
b43bdd14 1275 for(Int_t i = 0; i < fClusterArr->GetEntriesFast(); i++)
6fdd30c4 1276 {
b43bdd14 1277 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*) fClusterArr->At(i);
6fdd30c4 1278
1279 const Int_t ncells = recPoint->GetMultiplicity();
f6e45fe0 1280 Int_t ncellsTrue = 0;
6fdd30c4 1281
6a8be5c3 1282 if(recPoint->GetEnergy() < fRecParam->GetClusteringThreshold()) continue;
1283
6fdd30c4 1284 // cells and their amplitude fractions
1285 UShort_t absIds[ncells];
1286 Double32_t ratios[ncells];
1287
f6e45fe0 1288 //For later check embedding
1289 AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
f053064e 1290
1291 Float_t clusterE = 0;
f46af216 1292 for (Int_t c = 0; c < ncells; c++)
1293 {
b43bdd14 1294 AliEMCALDigit *digit = (AliEMCALDigit*) fDigitsArr->At(recPoint->GetDigitsList()[c]);
6fdd30c4 1295
f6e45fe0 1296 absIds[ncellsTrue] = digit->GetId();
1297 ratios[ncellsTrue] = recPoint->GetEnergiesList()[c]/digit->GetAmplitude();
6544055e 1298
d390e7cb 1299 // In case of unfolding, remove digits with unfolded energy too low
b43bdd14 1300 if(fSelectCell)
1301 {
f46af216 1302 if (recPoint->GetEnergiesList()[c] < fSelectCellMinE || ratios[ncellsTrue] < fSelectCellMinFrac)
1303 {
1304 if(DebugLevel() > 1)
1305 {
6544055e 1306 printf("AliAnalysisTaksEMCALClusterize::RecPoints2Clusters() - Too small energy in cell of cluster: cluster cell %f, digit %f\n",
d390e7cb 1307 recPoint->GetEnergiesList()[c],digit->GetAmplitude());
1308 }
1309
1310 continue;
1311
1312 } // if cuts
1313 }// Select cells
6544055e 1314
d390e7cb 1315 //Recalculate cluster energy and number of cluster cells in case any of the cells was rejected
1316 ncellsTrue++;
1317 clusterE +=recPoint->GetEnergiesList()[c];
f053064e 1318
f6e45fe0 1319 // In case of embedding, fill ratio with amount of signal,
f46af216 1320 if (aodIH && aodIH->GetMergeEvents())
1321 {
f6e45fe0 1322 //AliVCaloCells* inEMCALCells = InputEvent()->GetEMCALCells();
1323 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1324 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1325
1326 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1327 //Float_t bkgAmplitude = inEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1328 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1329 //printf("\t AbsID %d, amplitude : bkg %f, sigAmplitude %f, summed %f - %f\n",absIds[ncellsTrue], bkgAmplitude, sigAmplitude, sumAmplitude, digit->GetAmplitude());
1330
1331 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1332 //printf("\t \t ratio %f\n",ratios[ncellsTrue]);
1333
1334 }//Embedding
1335
f6e45fe0 1336 }// cluster cell loop
6fdd30c4 1337
f46af216 1338 if (ncellsTrue < 1)
1339 {
f053064e 1340 if (DebugLevel() > 1)
1341 printf("AliAnalysisTaskEMCALClusterize::RecPoints2Clusters() - Skipping cluster with no cells avobe threshold E = %f, ncells %d\n",
1342 recPoint->GetEnergy(), ncells);
1343 continue;
1344 }
1345
1346 //if(ncellsTrue != ncells) printf("Old E %f, ncells %d; New E %f, ncells %d\n",recPoint->GetEnergy(),ncells,clusterE,ncellsTrue);
1347
f46af216 1348 if(clusterE < fRecParam->GetClusteringThreshold())
1349 {
f053064e 1350 if (DebugLevel()>1)
1351 printf("AliAnalysisTaskEMCALClusterize::RecPoints2Clusters() - Remove cluster with energy below seed threshold %f\n",clusterE);
6fdd30c4 1352 continue;
1353 }
1354
1355 TVector3 gpos;
1356 Float_t g[3];
1357
1358 // calculate new cluster position
596697e6 1359
b43bdd14 1360 recPoint->EvalGlobalPosition(fRecParam->GetW0(), fDigitsArr);
6fdd30c4 1361 recPoint->GetGlobalPosition(gpos);
1362 gpos.GetXYZ(g);
1363
1364 // create a new cluster
596697e6 1365
b43bdd14 1366 (*fCaloClusterArr)[j] = new AliAODCaloCluster() ;
1367 AliAODCaloCluster *clus = dynamic_cast<AliAODCaloCluster *>( fCaloClusterArr->At(j) ) ;
6a8be5c3 1368 j++;
6fdd30c4 1369 clus->SetType(AliVCluster::kEMCALClusterv1);
6544055e 1370 clus->SetE(clusterE);
6fdd30c4 1371 clus->SetPosition(g);
f6e45fe0 1372 clus->SetNCells(ncellsTrue);
6fdd30c4 1373 clus->SetCellsAbsId(absIds);
1374 clus->SetCellsAmplitudeFraction(ratios);
6fdd30c4 1375 clus->SetChi2(-1); //not yet implemented
bd9e8ebd 1376 clus->SetTOF(recPoint->GetTime()) ; //time-of-flight
6fdd30c4 1377 clus->SetNExMax(recPoint->GetNExMax()); //number of local maxima
5994e71f 1378 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
b43bdd14 1379
f46af216 1380 if(ncells == ncellsTrue)
1381 {
f053064e 1382 Float_t elipAxis[2];
1383 recPoint->GetElipsAxis(elipAxis);
1384 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1385 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1386 clus->SetDispersion(recPoint->GetDispersion());
1387 }
f46af216 1388 else if(fSelectCell)
1389 {
afaaef51 1390 // In case some cells rejected, in unfolding case, recalculate
1391 // shower shape parameters and position
d20bc070 1392 if(DebugLevel() > 1)
f46af216 1393 printf("AliAnalysisTaskEMCALClusterize::RecPoints2Clusters() - Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape\n",ncells,ncellsTrue);
b43bdd14 1394
f053064e 1395 AliVCaloCells* cells = 0x0;
1396 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1397 else cells = InputEvent()->GetEMCALCells();
b43bdd14 1398
f053064e 1399 fRecoUtils->RecalculateClusterShowerShapeParameters(fGeom,cells,clus);
1400 fRecoUtils->RecalculateClusterPID(clus);
afaaef51 1401 fRecoUtils->RecalculateClusterPosition(fGeom,cells,clus);
f053064e 1402
f053064e 1403 }
6060ed91 1404
1405 //MC
b65291bf 1406 Int_t parentMult = 0;
6060ed91 1407 Int_t *parentList = recPoint->GetParents(parentMult);
1408 clus->SetLabel(parentList, parentMult);
1409
37d2296c 1410 //Write the second major contributor to each MC cluster.
1411 Int_t iNewLabel ;
f46af216 1412 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1413 {
37d2296c 1414
1415 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
b43bdd14 1416 if(idCell>=0)
1417 {
6ffa213f 1418 iNewLabel = 1 ; //iNewLabel makes sure we don't write twice the same label.
1419 for ( UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1420 {
1421 if ( fCellSecondLabels[idCell] == -1 ) iNewLabel = 0; // -1 is never a good second label.
1422 if ( fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1423 }
1424 if (iNewLabel == 1)
1425 {
937b6c91 1426 Int_t * newLabelArray = new Int_t[clus->GetNLabels()+1] ;
f46af216 1427 for ( UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1428 {
6ffa213f 1429 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1430 }
6a8be5c3 1431
6ffa213f 1432 newLabelArray[clus->GetNLabels()] = fCellSecondLabels[idCell] ;
1433 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
abf0860a 1434 delete [] newLabelArray;
6ffa213f 1435 }
1436 }//positive cell number
37d2296c 1437 }
1438
6fdd30c4 1439 } // recPoints loop
6544055e 1440
1441}
1442
3769e0cb 1443
6544055e 1444//____________________________________________________________
1445void AliAnalysisTaskEMCALClusterize::UserCreateOutputObjects()
1446{
1447 // Init geometry, create list of output clusters
1448
6a797202 1449
1450 fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
1451
1452 if(fOutputAODBranchName.Length()==0)
3769e0cb 1453 {
6a797202 1454 fOutputAODBranchName = "newEMCALClustersArray";
1455 printf("Cluster branch name not set, set it to newEMCALClustersArray \n");
6544055e 1456 }
6a797202 1457
1458 fOutputAODBranch->SetName(fOutputAODBranchName);
1459
1460 if( fFillAODFile )
3769e0cb 1461 {
6a797202 1462 //fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
1463
1464
1465 //fOutputAODBranch->SetOwner(kFALSE);
1466
1467 AddAODBranch("TClonesArray", &fOutputAODBranch);
6544055e 1468 }
b43bdd14 1469
6fdd30c4 1470}
6544055e 1471
1472//_______________________________________________________
1473void AliAnalysisTaskEMCALClusterize::UserExec(Option_t *)
1474{
b43bdd14 1475 // Do clusterization event by event, execute different steps
596697e6 1476 // 1) Do some checks on the kind of events (ESD, AOD) or if some filtering is needed, initializations
1477 // load things and clear arrays
b43bdd14 1478 // 2) Clusterize a) just unfolding existing clusters (fJustUnfold)
1479 // b) recluster cells
1480 // + convert cells into digits (calibrating them)
1481 // + recluster digits into recPoints with the chosen clusterizer (V1, V1+Unfold,V2, NxN)
1482 // with methods in AliEMCALClusterizer
1483 // + transform recPoints into CaloClusters
1484 // 3) Do some final calculations in the found clusters (track-matching) and put them in an AOD branch
1485
596697e6 1486 //-------
b43bdd14 1487 // Step 1
1488
b0f874d4 1489
b43bdd14 1490 //Remove the contents of AOD branch output list set in the previous event
6544055e 1491 fOutputAODBranch->Clear("C");
596697e6 1492
cb68426a 1493 LoadBranches();
1494
1495 //Check if there is a centrality value, PbPb analysis, and if a centrality bin selection is requested
1496 //If we need a centrality bin, we select only those events in the corresponding bin.
1497 if( GetCentrality() && fCentralityBin[0] >= 0 && fCentralityBin[1] >= 0 )
1498 {
8fa7608a 1499 Float_t cen = GetEventCentrality();
cb68426a 1500 if(cen > fCentralityBin[1] || cen < fCentralityBin[0]) return ; //reject events out of bin.
1501 }
b0f874d4 1502
596697e6 1503 // intermediate array with new clusters : init the array only once or clear from previous event
1504 if(!fCaloClusterArr) fCaloClusterArr = new TObjArray(10000);
1505 else fCaloClusterArr->Delete();//Clear("C"); it leaks?
1506
6544055e 1507 //Get the event, do some checks and settings
1508 CheckAndGetEvent() ;
1509
a1eeb25d 1510 if (!fEvent)
1511 {
6544055e 1512 if(DebugLevel() > 0 ) printf("AliAnalysisTaksEMCALClusterize::UserExec() - Skip Event %d", (Int_t) Entry());
1513 return ;
1514 }
6a797202 1515
3769e0cb 1516 //Init pointers, geometry, clusterizer, ocdb, aodb
6544055e 1517
3769e0cb 1518 InitGeometry(); // only once, must be done before OADB, geo OADB accessed here
6544055e 1519
3769e0cb 1520 if(fAccessOCDB) AccessOCDB();
1521 if(fAccessOADB) AccessOADB(); // only once
b43bdd14 1522
3769e0cb 1523 InitClusterization();
6544055e 1524
596697e6 1525 //-------
b43bdd14 1526 // Step 2
1527
6544055e 1528 // Make clusters
1529 if (fJustUnfold) ClusterUnfolding();
1530 else ClusterizeCells() ;
6544055e 1531
596697e6 1532 //-------
b43bdd14 1533 // Step 3
6544055e 1534
afc22931 1535 FillCaloClusterInEvent();
b65291bf 1536
6544055e 1537}
1538