18 #include <TRefArray.h>
19 #include <TClonesArray.h>
21 #include <TGeoManager.h>
23 #include <TInterpreter.h>
27 #include "AliAnalysisTask.h"
28 #include "AliAnalysisManager.h"
29 #include "AliESDEvent.h"
30 #include "AliGeomManager.h"
31 #include "AliVCaloCells.h"
32 #include "AliAODCaloCluster.h"
33 #include "AliCDBManager.h"
34 #include "AliCDBStorage.h"
35 #include "AliCDBEntry.h"
37 #include "AliVEventHandler.h"
38 #include "AliAODInputHandler.h"
39 #include "AliOADBContainer.h"
40 #include "AliAODMCParticle.h"
41 #include "AliCentrality.h"
42 #include "AliMultSelection.h"
45 #include "AliEMCALAfterBurnerUF.h"
46 #include "AliEMCALGeometry.h"
47 #include "AliEMCALClusterizerNxN.h"
48 #include "AliEMCALClusterizerv1.h"
49 #include "AliEMCALClusterizerv2.h"
50 #include "AliEMCALRecPoint.h"
51 #include "AliEMCALDigit.h"
65 , fGeom(0), fGeomName(
"")
66 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
67 , fOCDBpath(
""), fAccessOCDB(kFALSE)
68 , fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
69 , fRecParam(0), fClusterizer(0)
70 , fUnfolder(0), fJustUnfold(kFALSE)
71 , fOutputAODBranch(0), fOutputAODBranchName(
""), fOutputAODBranchSet(0)
72 , fFillAODFile(kFALSE), fFillAODHeader(0)
73 , fFillAODCaloCells(0), fRun(-1)
74 , fRecoUtils(0), fConfigName(
"")
76 , fCellLabels(), fCellSecondLabels(), fCellTime()
77 , fCellMatchdEta(), fCellMatchdPhi()
78 , fRecalibrateWithClusterTime(0)
79 , fMaxEvent(0), fDoTrackMatching(kFALSE)
80 , fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
81 , fRejectBelowThreshold(kFALSE)
82 , fRemoveLEDEvents(kTRUE),fRemoveExoticEvents(kFALSE)
83 , fImportGeometryFromFile(kTRUE), fImportGeometryFilePath(
"")
84 , fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath(
"")
85 , fConstantTimeShift(0)
86 , fCentralityClass(
""), fUseAliCentrality(0), fSelectEMCALEvent(0)
87 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
88 , fSetCellMCLabelFromCluster(0)
89 , fSetCellMCLabelFromEdepFrac(0)
90 , fRemapMCLabelForAODs(0)
106 , fGeom(0), fGeomName(
"")
107 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
108 , fOCDBpath(
""), fAccessOCDB(kFALSE)
109 , fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
110 , fRecParam(0), fClusterizer(0)
111 , fUnfolder(0), fJustUnfold(kFALSE)
112 , fOutputAODBranch(0), fOutputAODBranchName(
""), fOutputAODBranchSet(0)
113 , fFillAODFile(kFALSE), fFillAODHeader(0)
114 , fFillAODCaloCells(0), fRun(-1)
115 , fRecoUtils(0), fConfigName(
"")
116 , fOrgClusterCellId()
117 , fCellLabels(), fCellSecondLabels(), fCellTime()
118 , fCellMatchdEta(), fCellMatchdPhi()
119 , fRecalibrateWithClusterTime(0)
120 , fMaxEvent(0), fDoTrackMatching(kFALSE)
121 , fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
122 , fRejectBelowThreshold(kFALSE)
123 , fRemoveLEDEvents(kTRUE), fRemoveExoticEvents(kFALSE)
124 , fImportGeometryFromFile(kTRUE), fImportGeometryFilePath(
"")
125 , fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath(
"")
126 , fConstantTimeShift(0)
127 , fCentralityClass(
""), fUseAliCentrality(0), fSelectEMCALEvent(0)
128 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
129 , fSetCellMCLabelFromCluster(0)
130 , fSetCellMCLabelFromEdepFrac(0)
131 , fRemapMCLabelForAODs(0)
132 , fInputFromFilter(0)
180 Int_t nCluster =
fEvent -> GetNumberOfCaloClusters();
181 AliVCaloCells * caloCell =
fEvent -> GetEMCALCells();
184 for(
Int_t icalo = 0; icalo < nCluster; icalo++)
186 AliVCluster *clus = (AliVCluster*) (
fEvent->GetCaloCluster(icalo));
192 AliDebug(1, Form(
"Accept : E %2.2f > %2.2f, nCells %d > %d",
200 AliDebug(1,
"Reject");
214 Int_t runnumber = InputEvent()->GetRunNumber() ;
217 AliInfo(Form(
"Get AODB parameters from EMCAL in %s for run %d, and <%s>",
fOADBFilePath.Data(),runnumber,pass.Data()));
222 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn())
224 AliOADBContainer *contBC=
new AliOADBContainer(
"");
225 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePath.Data()),
"AliEMCALBadChannels");
231 fRecoUtils->SwitchOnDistToBadChannelRecalculation();
232 AliInfo(
"Remove EMCAL bad cells");
234 for (
Int_t i=0; i < nSM; ++i)
236 TH2I *hbm =
fRecoUtils->GetEMCALChannelStatusMap(i);
241 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
245 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
249 hbm->SetDirectory(0);
253 }
else AliInfo(
"Do NOT remove EMCAL bad channels");
261 AliOADBContainer *contRF=
new AliOADBContainer(
"");
263 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePath.Data()),
"AliEMCALRecalib");
277 AliInfo(
"Recalibrate EMCAL");
278 for (
Int_t i=0; i<nSM; ++i)
285 h = (
TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
289 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
295 fRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
297 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
298 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
299 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
307 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
309 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePath.Data()),
"AliEMCALRunDepTempCalibCorrections");
311 TH1S *htd=(TH1S*)contRFTD->GetObject(runnumber);
316 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",runnumber));
320 Int_t maxEntry = contRFTD->GetNumberOfEntries();
322 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) < runnumber) ) {
327 Int_t closest = lower;
328 if ( (ic<maxEntry) &&
329 (contRFTD->LowerLimit(ic)-runnumber) < (runnumber - contRFTD->UpperLimit(lower)) ) {
333 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
334 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
339 AliInfo(
"Recalibrate (Temperature) EMCAL");
341 for (
Int_t ism=0; ism<nSM; ++ism)
343 for (
Int_t icol=0; icol<48; ++icol)
345 for (
Int_t irow=0; irow<24; ++irow)
349 Int_t absID =
fGeom->GetAbsCellIdFromCellIndexes(ism, irow, icol);
350 factor *= htd->GetBinContent(absID) / 10000. ;
353 fRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
357 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
365 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
367 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePath.Data()),
"AliEMCALTimeCalib");
374 if(pass==
"spc_calo") passM =
"pass1";
379 AliInfo(
"Time Recalibrate EMCAL");
380 for (
Int_t ibc = 0; ibc < 4; ++ibc)
382 TH1F *h =
fRecoUtils->GetEMCALChannelTimeRecalibrationFactors(ibc);
387 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
391 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
397 fRecoUtils->SetEMCALChannelTimeRecalibrationFactors(ibc,h);
399 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
400 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
406 if(
fRecoUtils->IsL1PhaseInTimeRecalibrationOn() )
409 if (!
fRecoUtils->GetEMCALL1PhaseInTimeRecalibrationArray())
410 fRecoUtils->InitEMCALL1PhaseInTimeRecalibration() ;
412 AliOADBContainer *contBC =
new AliOADBContainer(
"");
414 TFile *timeFile=
new TFile(Form(
"%s/EMCALTimeL1PhaseCalib.root",
fOADBFilePath.Data()),
"read");
415 if (!timeFile || timeFile->IsZombie())
417 AliFatal(Form(
"EMCALTimeL1PhaseCalib.root was not found in the path provided: %s",
fOADBFilePath.Data()));
421 if (timeFile)
delete timeFile;
423 contBC->InitFromFile(Form(
"%s/EMCALTimeL1PhaseCalib.root",
fOADBFilePath.Data()),
"AliEMCALTimeL1PhaseCalib");
428 AliError(Form(
"No external L1 phase in time calibration set for run number: %d", runnumber));
429 fRecoUtils->SwitchOffL1PhaseInTimeRecalibration();
435 if (pass==
"calo_spc") pass2 =
"pass1";
436 if (pass==
"muon_calo_pass1") pass2 =
"pass0";
437 if (pass==
"muon_calo_pass2" || pass==
"pass2" || pass==
"pass3" || pass==
"pass4") pass2 =
"pass1";
442 AliError(Form(
"No external L1 phase in time calibration set for: %d -%s", runnumber,pass2.Data()));
443 fRecoUtils->SwitchOffL1PhaseInTimeRecalibration();
445 else AliInfo(
"Recalibrate L1 Phase time");
449 if ( DebugLevel()>0 ) arrayBCpass->Print();
451 TH1C *h =
fRecoUtils->GetEMCALL1PhaseInTimeRecalibrationForAllSM();
454 h = (TH1C*)arrayBCpass->FindObject(Form(
"h%d",runnumber));
458 AliFatal(Form(
"There is no calibration histogram h%d for this run",runnumber));
463 fRecoUtils->SetEMCALL1PhaseInTimeRecalibrationForAllSM(h);
483 Warning(
"AccessOCDB",
"Event not available!!!");
493 AliCDBManager *cdb = AliCDBManager::Instance();
498 cdb->SetDefaultStorage(
fOCDBpath.Data());
499 AliInfo(Form(
"Default storage %s",
fOCDBpath.Data()));
502 cdb->SetRun(
fEvent->GetRunNumber());
508 cdb->SetSpecificStorage(
"EMCAL/Calib/Data",
"raw://");
509 cdb->SetSpecificStorage(
"EMCAL/Calib/Time",
"raw://");
510 cdb->SetSpecificStorage(
"EMCAL/Calib/Pedestals",
"raw://");
513 TString path = cdb->GetDefaultStorage()->GetBaseFolder();
528 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
529 Int_t eventN = Entry();
530 if(aodIH) eventN = aodIH->GetReadEntry();
539 if (aodIH && aodIH->GetMergeEvents())
543 if(!aodIH->GetMergeEMCALCells())
544 AliFatal(
"Events merged but not EMCAL cells, check analysis settings!");
546 AliDebug(1,
"Use embedded events");
548 AliDebug(1,Form(
"\t InputEvent N Clusters %d, N Cells %d",
549 InputEvent()->GetNumberOfCaloClusters(),InputEvent()->GetEMCALCells()->GetNumberOfCells()));
551 AliDebug(1,Form(
"\t MergedEvent N Clusters %d, N Cells %d",
552 aodIH->GetEventToMerge()->GetNumberOfCaloClusters(), aodIH->GetEventToMerge()->GetEMCALCells()->GetNumberOfCells()));
563 AliDebug(1,Form(
"\t OutputEvent N Clusters %d, N Cells %d",
564 AODEvent()->GetNumberOfCaloClusters(), AODEvent()->GetEMCALCells()->GetNumberOfCells()));
580 AliError(
"Event not available");
603 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
622 Int_t nClusters =
fEvent->GetNumberOfCaloClusters();
623 Int_t nClustersOrg = 0;
625 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
626 if(aodIH && aodIH->GetEventToMerge())
627 nClusters = aodIH->GetEventToMerge()->GetNumberOfCaloClusters();
635 for (
Int_t i = 0; i < nClusters; i++)
637 AliVCluster *clus = 0;
638 if(aodIH && aodIH->GetEventToMerge())
639 clus = aodIH->GetEventToMerge()->GetCaloCluster(i);
641 clus =
fEvent->GetCaloCluster(i);
647 if(!clus->IsEMCAL())
continue;
649 Int_t label = clus->GetLabel();
651 if (clus->GetNLabels() >=2 ) label2 = clus->GetLabelAt(1) ;
661 UShort_t * index = clus->GetCellsAbsId() ;
662 for(
Int_t icell=0; icell < clus->GetNCells(); icell++ )
665 fCellTime[index[icell]] = clus->GetTOF();
684 AliVCaloCells * cells =
fEvent->GetEMCALCells();
686 Int_t bc = InputEvent()->GetBunchCrossNumber();
688 for (
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
691 id = cells->GetCellNumber(icell);
696 if( amp < fRecParam->GetMinECut() ||
698 time <
fRecParam->GetTimeMin() ) accept = kFALSE;
710 if (accept &&
fRecoUtils->IsExoticCell(
id,cells,bc))
715 AliDebug(2,Form(
"Remove channel absId %d, index %d of %d, amp %f, time %f",
716 id,icell, cells->GetNumberOfCells(), amp, time*1.e9));
725 Int_t mcLabel = cells->GetMCLabel(icell);
749 Float_t efrac = cells->GetEFraction(icell);
752 if (mcLabel > 0 && efrac < 1.e-6) efrac = 1;
766 AliVCluster *clus = 0;
771 AliInfo(
"Negative original cluster index, skip \n");
775 if(aodIH && aodIH->GetEventToMerge())
776 clus = aodIH->GetEventToMerge()->GetCaloCluster(iclus);
778 clus =
fEvent->GetCaloCluster(iclus);
780 for(
Int_t icluscell=0; icluscell < clus->GetNCells(); icluscell++ )
782 if(
id != clus->GetCellAbsId(icluscell))
continue ;
786 clus->GetCellMCEdepFractionArray(icluscell,eDepFrac);
790 for(
Int_t imc = 0; imc < 4; imc++)
792 if(eDepFrac[imc] > 0 && clus->GetNLabels() > imc)
796 labeArr.Set(nLabels);
797 labeArr.AddAt(clus->GetLabelAt(imc), nLabels-1);
799 eDepArr.Set(nLabels);
800 eDepArr.AddAt(eDepFrac[imc]*amp , nLabels-1);
810 AliEMCALDigit* digit =
new((*fDigitsArr)[idigit]) AliEMCALDigit( mcLabel, mcLabel,
id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, eDep);
813 digit->SetListOfParents(nLabels,labeArr.GetArray(),eDepArr.GetArray());
834 AliWarning(Form(
"No array with CaloClusters, input RecPoints entries %d",
fClusterArr->GetEntriesFast()));
838 AliDebug(1,Form(
"N clusters: before recluster %d, after recluster %d, recpoints %d",
854 AliVCaloCells *cells =
fEvent->GetEMCALCells();
858 Int_t cellMCLabel = 0;
860 Int_t nClustersOrg = 0;
863 for (
Int_t i = 0; i <
fEvent->GetNumberOfCaloClusters(); i++)
865 AliVCluster *clus =
fEvent->GetCaloCluster(i);
869 if(
fRecoUtils->ClusterContainsBadChannel(
fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
880 for (
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
882 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
885 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
886 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
887 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
890 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
891 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
894 cells->SetCell(icell, cellNumber, cellAmplitude*
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
900 AliESDCaloCluster * esdCluster =
dynamic_cast<AliESDCaloCluster*
> (clus);
901 AliAODCaloCluster * aodCluster =
dynamic_cast<AliAODCaloCluster*
> (clus);
912 AliWarning(
"Wrong CaloCluster type?");
930 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
931 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
933 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
934 aodEMcells.CreateContainer(nEMcell);
935 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
937 for (
Int_t iCell = 0; iCell < nEMcell; iCell++)
939 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
940 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
941 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
945 calibFactor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
948 if(!
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
950 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
951 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
955 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
972 for (
Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
974 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
975 if(!header) AliFatal(
"Not a standard AOD");
976 header->SetRunNumber(
fEvent->GetRunNumber());
980 TTree* tree = fInputHandler->GetTree();
983 TFile*
file = tree->GetCurrentFile();
984 if (file) header->SetESDFileName(file->GetName());
988 AliAODHeader * aodheader =
dynamic_cast<AliAODHeader*
>(aodevent->GetHeader());
989 if(!aodheader) AliFatal(
"Not a standard AOD");
990 header->SetESDFileName(aodheader->GetESDFileName());
993 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
994 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
995 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
996 header->SetEventType(
fEvent->GetEventType());
1001 if(
fEvent->GetCentrality())
1002 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
1004 header->SetCentrality(0);
1008 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
1010 header->SetFiredTriggerClasses(
fEvent->GetFiredTriggerClasses());
1012 header->SetTriggerMask(
fEvent->GetTriggerMask());
1013 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
1017 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
1018 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
1019 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
1023 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
1024 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
1025 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
1028 header->SetMagneticField(
fEvent->GetMagneticField());
1031 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
1032 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
1033 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
1034 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
1035 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
1039 fEvent->GetDiamondCovXY(diamcov);
1040 header->SetDiamond(diamxy,diamcov);
1041 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
1042 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
1045 Int_t nVertices = 1 ;;
1046 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
1048 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
1051 TClonesArray &vertices = *(AODEvent()->GetVertices());
1056 fEvent->GetPrimaryVertex()->GetXYZ(pos);
1060 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
1061 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
1065 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
1066 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();
1069 AliAODVertex * primary =
new(vertices[jVertices++])
1070 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
1071 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
1072 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
1092 for(
Int_t i = 0; i < kNumberOfCaloClusters; i++)
1094 AliAODCaloCluster *newCluster = (AliAODCaloCluster *)
fCaloClusterArr->At(i);
1096 newCluster->SetID(i);
1099 newCluster->SetE(
fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
1107 newCluster->AddTrackMatched(
fEvent->GetTrack(trackIndex));
1108 AliDebug(2,Form(
"Matched Track index %d to new cluster %d",trackIndex,i));
1112 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dZ,dR);
1113 newCluster->SetTrackDistance(dR,dZ);
1117 Int_t absId0 = newCluster->GetCellsAbsId()[0];
1136 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
1138 AliDebug(2,Form(
"New cluster %d of %d, energy %f, mc label %d",
1139 newCluster->GetID(), kNumberOfCaloClusters, newCluster->E(), newCluster->GetLabel()));
1171 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1173 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null");
1177 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1179 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null");
1183 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1184 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1185 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1186 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1187 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1188 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1189 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1190 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1192 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1195 else if (pass.Contains(
"LHC14a1a"))
1197 AliInfo(
"Enable EMCal energy calibration for this MC production!!");
1205 AliInfo(
"Pass number string not found");
1216 if(fDebug >=0) (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
1221 fBranchNames =
"ESD:AliESDHeader.,EMCALCells.";
1239 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
1277 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1279 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1281 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1289 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1314 for (i = 0; i < 8; i++)
1319 for (i = 0; i < 3; i++)
1339 Int_t runnumber = InputEvent()->GetRunNumber() ;
1344 fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(runnumber);
1345 AliInfo(Form(
"Get EMCAL geometry name <%s> for run %d",
fGeom->GetName(),runnumber));
1350 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fGeomName.Data()));
1370 AliDebug(1,Form(
"Init for run=%d",runnumber));
1371 if (!gGeoManager) AliDebug(1,
"Careful!, gGeoManager not loaded, load misalign matrices");
1376 AliInfo(
"Load user defined EMCAL geometry matrices");
1379 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
1380 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePath.Data()),
"AliEMCALgeo");
1383 for(
Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1388 AliDebug(2,Form(
"EMCAL matrices SM %d, %p",mod,((TGeoHMatrix*) matEMCAL->At(mod))));
1391 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1396 if(DebugLevel() > 1)
1401 else if(gGeoManager)
1403 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
1404 fGeom->SetMisalMatrix(
fGeom->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
1408 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
1415 else if(!gGeoManager)
1417 AliInfo(
"AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1419 if(!strcmp(
fEvent->GetName(),
"AliAODEvent"))
1421 AliWarning(
"Use ideal geometry, values geometry matrix not kept in AODs");
1425 AliDebug(1,
"Load Misaligned matrices");
1431 AliError(
"This event does not contain ESDs?");
1432 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
1436 for(
Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1438 if(DebugLevel() > 1)
1439 esd->GetEMCALMatrix(mod)->Print();
1441 if(esd->GetEMCALMatrix(mod))
fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1463 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1465 Int_t bc = InputEvent()->GetBunchCrossNumber();
1467 for(
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1472 Int_t absID = cells->GetCellNumber(icell);
1473 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1476 if(accept && !
fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
1486 if(totCellE < 1)
return kTRUE;
1499 if(run < 146858 || run > 146860)
return kFALSE ;
1502 Int_t ncellsSM3 = 0;
1503 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1504 for(
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1506 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
1511 Int_t ncellcut = 21;
1512 if(triggerclasses.Contains(
"EMC")) ncellcut = 35;
1514 if( ncellsSM3 >= ncellcut)
1516 AliInfo(Form(
"Reject event %d with ncells in SM3 %d",(
Int_t)Entry(),ncellsSM3));
1517 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
1534 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*)
fClusterArr->At(i);
1536 const Int_t ncells = recPoint->GetMultiplicity();
1537 Int_t ncellsTrue = 0;
1539 if(recPoint->GetEnergy() <
fRecParam->GetClusteringThreshold())
continue;
1543 Double32_t ratios[ncells];
1546 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1551 AliEMCALDigit *digit = (AliEMCALDigit*)
fDigitsArr->At(recPoint->GetDigitsList()[
c]);
1553 absIds[ncellsTrue] = digit->GetId();
1554 ratios[ncellsTrue] = recPoint->GetEnergiesList()[
c]/digit->GetAmplitude();
1562 AliDebug(2,Form(
"Too small energy in cell of cluster: cluster cell %f, digit %f",
1563 recPoint->GetEnergiesList()[
c],digit->GetAmplitude()));
1569 clusterE +=recPoint->GetEnergiesList()[
c];
1572 if (aodIH && aodIH->GetMergeEvents())
1575 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1576 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1578 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1580 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1583 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1594 AliDebug(2,Form(
"Skipping cluster with no cells avobe threshold E = %f, ncells %d",
1595 recPoint->GetEnergy(), ncells));
1601 if(clusterE < fRecParam->GetClusteringThreshold())
1603 AliDebug(2,Form(
"Remove cluster with energy below seed threshold %f",clusterE));
1613 recPoint->GetGlobalPosition(gpos);
1618 (*fCaloClusterArr)[j] =
new AliAODCaloCluster() ;
1619 AliAODCaloCluster *clus =
dynamic_cast<AliAODCaloCluster *
>(
fCaloClusterArr->At(j) ) ;
1621 clus->SetType(AliVCluster::kEMCALClusterv1);
1622 clus->SetE(clusterE);
1623 clus->SetPosition(g);
1624 clus->SetNCells(ncellsTrue);
1625 clus->SetCellsAbsId(absIds);
1626 clus->SetCellsAmplitudeFraction(ratios);
1628 clus->SetTOF(recPoint->GetTime()) ;
1629 clus->SetNExMax(recPoint->GetNExMax());
1630 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
1632 if(ncells == ncellsTrue)
1635 recPoint->GetElipsAxis(elipAxis);
1636 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1637 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1638 clus->SetDispersion(recPoint->GetDispersion());
1644 AliDebug(2,Form(
"Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape",ncells,ncellsTrue));
1646 AliVCaloCells* cells = 0x0;
1647 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1648 else cells = InputEvent()->GetEMCALCells();
1650 fRecoUtils->RecalculateClusterShowerShapeParameters(
fGeom,cells,clus);
1664 Int_t parentMult = 0;
1665 Int_t *parentList = recPoint->GetParents(parentMult);
1666 Float_t *parentListDE = recPoint->GetParentsDE();
1668 clus->SetLabel(parentList, parentMult);
1669 clus->SetClusterMCEdepFractionFromEdepArray(parentListDE);
1679 AliVCaloCells* cells = 0x0;
1680 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1681 else cells = InputEvent()->GetEMCALCells();
1683 for(
Int_t icell = 0; icell < ncellsTrue ; icell++)
1687 const AliEMCALDigit * dig = (
const AliEMCALDigit*)
fDigitsArr->At(idigit);
1692 mcEdepFracPerCell[icell] = 0;
1694 Int_t nparents = dig->GetNiparent();
1697 Int_t digLabel =-1 ;
1700 Float_t mcEDepFrac[4] = {0,0,0,0};
1703 for (
Int_t jndex = 0 ; jndex < nparents ; jndex++ )
1705 digLabel = dig->GetIparent (jndex+1);
1706 edep = dig->GetDEParent(jndex+1);
1709 if ( digLabel == parentList[0] ) mcEDepFrac[0] = edep;
1710 else if ( digLabel == parentList[1] ) mcEDepFrac[1] = edep;
1711 else if ( digLabel == parentList[2] ) mcEDepFrac[2] = edep;
1712 else if ( digLabel == parentList[3] ) mcEDepFrac[3] = edep;
1719 mcEdepFracPerCell[icell] = clus->PackMCEdepFraction(mcEDepFrac);
1724 clus->SetCellsMCEdepFractionMap(mcEdepFracPerCell);
1726 delete [] mcEdepFracPerCell;
1739 if(label < 0) return ;
1744 TClonesArray * arr =
dynamic_cast<TClonesArray*
>(evt->FindListObject(
"mcparticles")) ;
1747 if(label < arr->GetEntriesFast())
1749 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(label));
1750 if(!particle) return ;
1752 if(label == particle->Label())
return ;
1758 for(
Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1760 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(ind));
1761 if(!particle) continue ;
1763 if(label == particle->Label())
1798 AliAODCaloCluster * clus)
1800 Int_t parentMult = 0;
1801 Int_t *parentList = recPoint->GetParents(parentMult);
1802 clus->SetLabel(parentList, parentMult);
1806 for (
Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1809 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1813 for (
UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1816 if (
fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1820 Int_t * newLabelArray =
new Int_t[clus->GetNLabels()+1] ;
1821 for (
UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1823 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1827 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
1828 delete [] newLabelArray;
1844 Int_t nLabTotOrg = 0;
1848 AliVEvent *
event =
fEvent;
1851 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1852 if(aodIH && aodIH->GetEventToMerge())
1853 event = aodIH->GetEventToMerge();
1857 for (
Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1859 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1866 for(
Int_t icl =0; icl < nClu; icl++)
1868 if(((
Int_t)clArray.GetAt(icl))==-1 )
continue;
1869 if( idCluster == ((
Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1873 if( set && idCluster >= 0)
1875 clArray.SetAt(idCluster,nClu++);
1877 nLabTotOrg+=(
event->GetCaloCluster(idCluster))->GetNLabels();
1882 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1884 if(emax < clOrg->E())
1893 if(nClu==0 || nLabTotOrg == 0)
1901 if(idMax != ((
Int_t)clArray.GetAt(0)))
1903 Int_t maxIndex = -1;
1904 Int_t firstCluster = ((
Int_t)clArray.GetAt(0));
1905 for (
Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1907 if(idMax == ((
Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1910 if(firstCluster >=0 && idMax >=0)
1912 clArray.SetAt(idMax,0);
1913 clArray.SetAt(firstCluster,maxIndex);
1918 TArrayI clMCArray(nLabTotOrg) ;
1922 for (
Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1924 Int_t idCluster = (
Int_t) clArray.GetAt(iLoopCluster);
1926 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1927 Int_t nLab = clOrg->GetNLabels();
1929 for (
Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1931 Int_t lab = clOrg->GetLabelAt(iLab) ;
1936 for(
Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1938 if( lab == ((
Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1942 if( set ) clMCArray.SetAt(lab,nLabTot++);
1949 clus->SetLabel(clMCArray.GetArray(), nLabTot);
1973 AliInfo(
"Cluster branch name not set, set it to newEMCALClustersArray");
2029 AliDebug(1,Form(
"Skip Event %d", (
Int_t) Entry()));
void FillAODCaloCells()
Put calo cells in standard branch.
virtual void ResetArrays()
Reset arrays containing information for all possible cells.
TString GetPass()
Get or guess pass number/string from path of filename.
Bool_t fSetCellMCLabelFromEdepFrac
Bool_t fFillAODHeader
Copy header to standard branch.
TClonesArray * fDigitsArr
! Digits array
AliEMCALClusterizer * fClusterizer
! EMCAL clusterizer
AliAnalysisTaskEMCALClusterize()
Constructor.
Bool_t fJustUnfold
Just unfold, do not recluster.
Bool_t fImportGeometryFromFile
Import geometry settings in geometry.root file.
Bool_t fSelectCell
Reject cells from cluster if energy is too low and recalculate position/energy and other...
TString fConfigName
Name of analysis configuration file.
Int_t fCellSecondLabels[fgkNEMCalCells]
Array with Second MC label to be passed to digit.
void SetClustersMCLabelFrom2SelectedLabels(AliEMCALRecPoint *recPoint, AliAODCaloCluster *clus)
Int_t fSetCellMCLabelFromCluster
Float_t fCellMatchdEta[fgkNEMCalCells]
Array with cluster-track dPhi.
TClonesArray * fOutputAODBranch
! AOD Branch with output clusters
TString fOADBFilePath
Default path $ALICE_PHYSICS/OADB/EMCAL, if needed change.
virtual ~AliAnalysisTaskEMCALClusterize()
Destructor.
TString fImportGeometryFilePath
path fo geometry.root file
Bool_t fSelectEMCALEvent
Process the event if there is some high energy cluster.
Bool_t AcceptEventEMCAL()
Float_t GetEventCentrality() const
Get centrality/multiplicity percentile.
Bool_t fInputFromFilter
Get the input from AODs from the filter.
TString fOutputAODBranchName
New of output AOD branch.
AliEMCALGeometry * fGeom
EMCAL geometry.
void ClusterUnfolding()
Take the event clusters and unfold them.
Bool_t fAccessOADB
Get calibration from OADB for EMCAL.
Bool_t fRemoveLEDEvents
Remove LED events, use only for LHC11a.
AliEMCALRecoUtils * fRecoUtils
Access to factorized reconstruction algorithms.
Bool_t fRejectBelowThreshold
split (false-default) or reject (true) cell energy below threshold after UF
Float_t fConstantTimeShift
Apply a 600 ns time shift in case of simulation, shift in ns.
void SetClustersMCLabelFromOriginalClusters(AliAODCaloCluster *clus)
Float_t fSelectCellMinE
Min energy cell threshold, after unfolding.
Bool_t fOADBSet
AODB parameters already set.
virtual void UserCreateOutputObjects()
virtual void FillCaloClusterInEvent()
Int_t fCellLabels[fgkNEMCalCells]
Array with MC label to be passed to digit.
Bool_t fRemoveExoticEvents
Remove exotic events.
Bool_t fDoTrackMatching
On/Off the matching recalulation to speed up analysis in PbPb.
virtual void UserExec(Option_t *option)
Float_t fCellMatchdPhi[fgkNEMCalCells]
Array with cluster-track dEta.
AliMultSelection * GetMultSelCen() const
TGeoHMatrix * fGeomMatrix[22]
Geometry matrices with alignments.
Bool_t IsLEDEvent(const Int_t run)
Check if event is LED, is so remove it. Affected LHC11a runs.
AliEMCALRecParam * fRecParam
Reconstruction parameters container.
TString fGeomName
Name of geometry to use.
Bool_t fOutputAODBranchSet
Set the AOD clusters branch in the input event once.
void RemapMCLabelForAODs(Int_t &label)
TString fOCDBpath
Path with OCDB location.
AliEMCALAfterBurnerUF * fUnfolder
! Unfolding procedure
Bool_t fGeomMatrixSet
Set geometry matrices only once, for the first event.
Float_t fCentralityBin[2]
Minimum and maximum value of the centrality for the analysis.
Int_t fMaxEvent
Set a maximum event.
Bool_t fFillAODCaloCells
Copy calocells to standard branch.
TObjArray * fCaloClusterArr
! CaloClusters array
Double_t fCellTime[fgkNEMCalCells]
Array with cluster time to be passed to digit in case of AODs.
AliCentrality * GetCentrality() const
TString fCentralityClass
Name of selected centrality class.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Bool_t fAccessOCDB
Need to access info from OCDB (not really)
TObjArray * fClusterArr
! Recpoints array
Bool_t fRecalibrateWithClusterTime
Use fCellTime to store time of cells in cluster.
Int_t GetRunNumber(TString)
void InitClusterization()
void FillAODHeader()
Put event header information in standard AOD branch.
static const Int_t fgkNEMCalCells
Total number of cells in the calorimeter, 10*48*24 (EMCal) + 4*48*8 (EMCal/DCal 1/3) + 6*32*24 (DCal)...
virtual void RecPoints2Clusters()
Int_t fEMCALNcellsCut
At least an EMCAL cluster with fNCellsCut cells over fEnergyCut.
Reclusterize EMCal clusters, put them in a new branch for other following analysis.
Bool_t fLoadGeomMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
Float_t fEMCALEnergyCut
At least an EMCAL cluster with this energy in the event.
Bool_t fUseAliCentrality
Use the centrality estimator from AliCentrality or AliMultSelection.
Int_t fOrgClusterCellId[fgkNEMCalCells]
Array ID of cluster to wich the cell belongs in unmodified clusters.
Float_t fSelectCellMinFrac
Min fraction of cell energy after unfolding cut.
Bool_t fRemapMCLabelForAODs
Remap AOD cells MC label. Needed in old AOD productions.