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();
436 if ( pass==
"muon_calo_pass1" && runnumber > 209121 && runnumber < 244284 )
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();
685 AliVCaloCells * cells =
fEvent->GetEMCALCells();
687 Int_t bc = InputEvent()->GetBunchCrossNumber();
689 for (
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
692 id = cells->GetCellNumber(icell);
697 if( amp < fRecParam->GetMinECut() ||
699 time <
fRecParam->GetTimeMin() ) accept = kFALSE;
711 if (accept &&
fRecoUtils->IsExoticCell(
id,cells,bc))
716 AliDebug(2,Form(
"Remove channel absId %d, index %d of %d, amp %f, time %f",
717 id,icell, cells->GetNumberOfCells(), amp, time*1.e9));
726 Int_t mcLabel = cells->GetMCLabel(icell);
752 Float_t efrac = cells->GetEFraction(icell);
755 if (mcLabel > 0 && efrac < 1.e-6) efrac = 1;
770 AliVCluster *clus = 0;
775 AliInfo(
"Negative original cluster index, skip \n");
779 if(aodIH && aodIH->GetEventToMerge())
780 clus = aodIH->GetEventToMerge()->GetCaloCluster(iclus);
782 clus =
fEvent->GetCaloCluster(iclus);
784 fRecoUtils->RecalculateCellLabelsRemoveAddedGenerator(
id, clus, MCEvent(), amp, labeArr, eDepArr);
785 nLabels = labeArr.GetSize();
792 if(amp <= 0.01) continue ;
796 AliEMCALDigit* digit =
new((*fDigitsArr)[idigit]) AliEMCALDigit( mcLabel, mcLabel,
id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, eDep);
799 digit->SetListOfParents(nLabels,labeArr.GetArray(),eDepArr.GetArray());
821 AliWarning(Form(
"No array with CaloClusters, input RecPoints entries %d",
fClusterArr->GetEntriesFast()));
825 AliDebug(1,Form(
"N clusters: before recluster %d, after recluster %d, recpoints %d",
842 AliVCaloCells *cells =
fEvent->GetEMCALCells();
846 Int_t cellMCLabel = 0;
848 Int_t nClustersOrg = 0;
851 for (
Int_t i = 0; i <
fEvent->GetNumberOfCaloClusters(); i++)
853 AliVCluster *clus =
fEvent->GetCaloCluster(i);
857 if(
fRecoUtils->ClusterContainsBadChannel(
fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
868 for (
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
870 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
873 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
874 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
875 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
878 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
879 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
882 cells->SetCell(icell, cellNumber, cellAmplitude*
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
888 AliESDCaloCluster * esdCluster =
dynamic_cast<AliESDCaloCluster*
> (clus);
889 AliAODCaloCluster * aodCluster =
dynamic_cast<AliAODCaloCluster*
> (clus);
900 AliWarning(
"Wrong CaloCluster type?");
918 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
919 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
921 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
922 aodEMcells.CreateContainer(nEMcell);
923 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
925 for (
Int_t iCell = 0; iCell < nEMcell; iCell++)
927 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
928 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
929 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
933 calibFactor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
936 if(!
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
938 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
939 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
943 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
960 for (
Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
962 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
963 if(!header) AliFatal(
"Not a standard AOD");
964 header->SetRunNumber(
fEvent->GetRunNumber());
968 TTree* tree = fInputHandler->GetTree();
971 TFile*
file = tree->GetCurrentFile();
972 if (file) header->SetESDFileName(file->GetName());
976 AliAODHeader * aodheader =
dynamic_cast<AliAODHeader*
>(aodevent->GetHeader());
977 if(!aodheader) AliFatal(
"Not a standard AOD");
978 header->SetESDFileName(aodheader->GetESDFileName());
981 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
982 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
983 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
984 header->SetEventType(
fEvent->GetEventType());
989 if(
fEvent->GetCentrality())
990 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
992 header->SetCentrality(0);
996 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
998 header->SetFiredTriggerClasses(
fEvent->GetFiredTriggerClasses());
1000 header->SetTriggerMask(
fEvent->GetTriggerMask());
1001 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
1005 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
1006 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
1007 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
1011 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
1012 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
1013 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
1016 header->SetMagneticField(
fEvent->GetMagneticField());
1019 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
1020 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
1021 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
1022 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
1023 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
1027 fEvent->GetDiamondCovXY(diamcov);
1028 header->SetDiamond(diamxy,diamcov);
1029 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
1030 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
1033 Int_t nVertices = 1 ;;
1034 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
1036 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
1039 TClonesArray &vertices = *(AODEvent()->GetVertices());
1044 fEvent->GetPrimaryVertex()->GetXYZ(pos);
1048 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
1049 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
1053 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
1054 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();
1057 AliAODVertex * primary =
new(vertices[jVertices++])
1058 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
1059 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
1060 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
1080 for(
Int_t i = 0; i < kNumberOfCaloClusters; i++)
1082 AliAODCaloCluster *newCluster = (AliAODCaloCluster *)
fCaloClusterArr->At(i);
1084 newCluster->SetID(i);
1087 newCluster->SetE(
fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
1095 newCluster->AddTrackMatched(
fEvent->GetTrack(trackIndex));
1096 AliDebug(2,Form(
"Matched Track index %d to new cluster %d",trackIndex,i));
1100 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dZ,dR);
1101 newCluster->SetTrackDistance(dR,dZ);
1105 Int_t absId0 = newCluster->GetCellsAbsId()[0];
1124 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
1126 AliDebug(2,Form(
"New cluster %d of %d, energy %f, mc label %d",
1127 newCluster->GetID(), kNumberOfCaloClusters, newCluster->E(), newCluster->GetLabel()));
1159 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1161 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null");
1165 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1167 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null");
1171 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1172 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1173 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1174 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1175 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1176 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1177 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1178 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1180 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1183 else if (pass.Contains(
"LHC14a1a"))
1185 AliInfo(
"Enable EMCal energy calibration for this MC production!!");
1193 AliInfo(
"Pass number string not found");
1204 if(fDebug >=0) (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
1209 fBranchNames =
"ESD:AliESDHeader.,EMCALCells.";
1227 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
1265 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1267 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1269 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1277 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1302 for (i = 0; i < 8; i++)
1307 for (i = 0; i < 3; i++)
1327 Int_t runnumber = InputEvent()->GetRunNumber() ;
1332 fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(runnumber);
1333 AliInfo(Form(
"Get EMCAL geometry name <%s> for run %d",
fGeom->GetName(),runnumber));
1338 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fGeomName.Data()));
1358 AliDebug(1,Form(
"Init for run=%d",runnumber));
1359 if (!gGeoManager) AliDebug(1,
"Careful!, gGeoManager not loaded, load misalign matrices");
1364 AliInfo(
"Load user defined EMCAL geometry matrices");
1367 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
1368 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePath.Data()),
"AliEMCALgeo");
1371 for(
Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1376 AliDebug(2,Form(
"EMCAL matrices SM %d, %p",mod,((TGeoHMatrix*) matEMCAL->At(mod))));
1379 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1384 if(DebugLevel() > 1)
1389 else if(gGeoManager)
1391 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
1392 fGeom->SetMisalMatrix(
fGeom->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
1396 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
1403 else if(!gGeoManager)
1405 AliInfo(
"AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1407 if(!strcmp(
fEvent->GetName(),
"AliAODEvent"))
1409 AliWarning(
"Use ideal geometry, values geometry matrix not kept in AODs");
1413 AliDebug(1,
"Load Misaligned matrices");
1419 AliError(
"This event does not contain ESDs?");
1420 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
1424 for(
Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1426 if(DebugLevel() > 1)
1427 esd->GetEMCALMatrix(mod)->Print();
1429 if(esd->GetEMCALMatrix(mod))
fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1451 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1453 Int_t bc = InputEvent()->GetBunchCrossNumber();
1455 for(
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1460 Int_t absID = cells->GetCellNumber(icell);
1461 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1464 if(accept && !
fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
1474 if(totCellE < 1)
return kTRUE;
1487 if(run < 146858 || run > 146860)
return kFALSE ;
1490 Int_t ncellsSM3 = 0;
1491 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1492 for(
Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1494 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
1499 Int_t ncellcut = 21;
1500 if(triggerclasses.Contains(
"EMC")) ncellcut = 35;
1502 if( ncellsSM3 >= ncellcut)
1504 AliInfo(Form(
"Reject event %d with ncells in SM3 %d",(
Int_t)Entry(),ncellsSM3));
1505 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
1522 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*)
fClusterArr->At(i);
1524 const Int_t ncells = recPoint->GetMultiplicity();
1525 Int_t ncellsTrue = 0;
1527 if(recPoint->GetEnergy() <
fRecParam->GetClusteringThreshold())
continue;
1531 Double32_t ratios[ncells];
1534 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1539 AliEMCALDigit *digit = (AliEMCALDigit*)
fDigitsArr->At(recPoint->GetDigitsList()[
c]);
1541 absIds[ncellsTrue] = digit->GetId();
1542 ratios[ncellsTrue] = recPoint->GetEnergiesList()[
c]/digit->GetAmplitude();
1550 AliDebug(2,Form(
"Too small energy in cell of cluster: cluster cell %f, digit %f",
1551 recPoint->GetEnergiesList()[
c],digit->GetAmplitude()));
1557 clusterE +=recPoint->GetEnergiesList()[
c];
1560 if (aodIH && aodIH->GetMergeEvents())
1563 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1564 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1566 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1568 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1571 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1582 AliDebug(2,Form(
"Skipping cluster with no cells avobe threshold E = %f, ncells %d",
1583 recPoint->GetEnergy(), ncells));
1589 if(clusterE < fRecParam->GetClusteringThreshold())
1591 AliDebug(2,Form(
"Remove cluster with energy below seed threshold %f",clusterE));
1601 recPoint->GetGlobalPosition(gpos);
1606 (*fCaloClusterArr)[j] =
new AliAODCaloCluster() ;
1607 AliAODCaloCluster *clus =
dynamic_cast<AliAODCaloCluster *
>(
fCaloClusterArr->At(j) ) ;
1609 clus->SetType(AliVCluster::kEMCALClusterv1);
1610 clus->SetE(clusterE);
1611 clus->SetPosition(g);
1612 clus->SetNCells(ncellsTrue);
1613 clus->SetCellsAbsId(absIds);
1614 clus->SetCellsAmplitudeFraction(ratios);
1616 clus->SetTOF(recPoint->GetTime()) ;
1617 clus->SetNExMax(recPoint->GetNExMax());
1618 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
1620 if(ncells == ncellsTrue)
1623 recPoint->GetElipsAxis(elipAxis);
1624 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1625 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1626 clus->SetDispersion(recPoint->GetDispersion());
1632 AliDebug(2,Form(
"Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape",ncells,ncellsTrue));
1634 AliVCaloCells* cells = 0x0;
1635 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1636 else cells = InputEvent()->GetEMCALCells();
1638 fRecoUtils->RecalculateClusterShowerShapeParameters(
fGeom,cells,clus);
1652 Int_t parentMult = 0;
1653 Int_t *parentList = recPoint->GetParents(parentMult);
1654 Float_t *parentListDE = recPoint->GetParentsDE();
1656 clus->SetLabel(parentList, parentMult);
1658 clus->SetClusterMCEdepFractionFromEdepArray(parentListDE);
1668 AliVCaloCells* cells = 0x0;
1669 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1670 else cells = InputEvent()->GetEMCALCells();
1672 for(
Int_t icell = 0; icell < ncellsTrue ; icell++)
1676 const AliEMCALDigit * dig = (
const AliEMCALDigit*)
fDigitsArr->At(idigit);
1681 mcEdepFracPerCell[icell] = 0;
1683 Int_t nparents = dig->GetNiparent();
1686 Int_t digLabel =-1 ;
1689 Float_t mcEDepFrac[4] = {0,0,0,0};
1692 for (
Int_t jndex = 0 ; jndex < nparents ; jndex++ )
1694 digLabel = dig->GetIparent (jndex+1);
1695 edep = dig->GetDEParent(jndex+1);
1698 if ( digLabel == parentList[0] ) mcEDepFrac[0] = edep;
1699 else if ( digLabel == parentList[1] ) mcEDepFrac[1] = edep;
1700 else if ( digLabel == parentList[2] ) mcEDepFrac[2] = edep;
1701 else if ( digLabel == parentList[3] ) mcEDepFrac[3] = edep;
1708 mcEdepFracPerCell[icell] = clus->PackMCEdepFraction(mcEDepFrac);
1713 clus->SetCellsMCEdepFractionMap(mcEdepFracPerCell);
1715 delete [] mcEdepFracPerCell;
1728 if(label < 0) return ;
1733 TClonesArray * arr =
dynamic_cast<TClonesArray*
>(evt->FindListObject(
"mcparticles")) ;
1736 if(label < arr->GetEntriesFast())
1738 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(label));
1739 if(!particle) return ;
1741 if(label == particle->Label())
return ;
1747 for(
Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1749 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(ind));
1750 if(!particle) continue ;
1752 if(label == particle->Label())
1787 AliAODCaloCluster * clus)
1789 Int_t parentMult = 0;
1790 Int_t *parentList = recPoint->GetParents(parentMult);
1791 clus->SetLabel(parentList, parentMult);
1795 for (
Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1798 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1802 for (
UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1805 if (
fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1809 Int_t * newLabelArray =
new Int_t[clus->GetNLabels()+1] ;
1810 for (
UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1812 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1816 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
1817 delete [] newLabelArray;
1833 Int_t nLabTotOrg = 0;
1837 AliVEvent *
event =
fEvent;
1840 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1841 if(aodIH && aodIH->GetEventToMerge())
1842 event = aodIH->GetEventToMerge();
1846 for (
Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1848 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1855 for(
Int_t icl =0; icl < nClu; icl++)
1857 if(((
Int_t)clArray.GetAt(icl))==-1 )
continue;
1858 if( idCluster == ((
Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1862 if( set && idCluster >= 0)
1864 clArray.SetAt(idCluster,nClu++);
1866 nLabTotOrg+=(
event->GetCaloCluster(idCluster))->GetNLabels();
1871 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1873 if(emax < clOrg->E())
1882 if(nClu==0 || nLabTotOrg == 0)
1890 if(idMax != ((
Int_t)clArray.GetAt(0)))
1892 Int_t maxIndex = -1;
1893 Int_t firstCluster = ((
Int_t)clArray.GetAt(0));
1894 for (
Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1896 if(idMax == ((
Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1899 if(firstCluster >=0 && idMax >=0)
1901 clArray.SetAt(idMax,0);
1902 clArray.SetAt(firstCluster,maxIndex);
1907 TArrayI clMCArray(nLabTotOrg) ;
1911 for (
Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1913 Int_t idCluster = (
Int_t) clArray.GetAt(iLoopCluster);
1915 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1916 Int_t nLab = clOrg->GetNLabels();
1918 for (
Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1920 Int_t lab = clOrg->GetLabelAt(iLab) ;
1925 for(
Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1927 if( lab == ((
Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1931 if( set ) clMCArray.SetAt(lab,nLabTot++);
1938 clus->SetLabel(clMCArray.GetArray(), nLabTot);
1962 AliInfo(
"Cluster branch name not set, set it to newEMCALClustersArray");
2018 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.