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"
63 : AliAnalysisTaskSE(name)
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)
104 : AliAnalysisTaskSE(
"DefaultAnalysis_AliAnalysisTaskEMCALClusterize")
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();
182 Int_t bc =
fEvent -> GetBunchCrossNumber();
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()));
219 Int_t nSM =
fGeom->GetNumberOfSuperModules();
222 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn())
224 AliOADBContainer *contBC=
new AliOADBContainer(
"");
225 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePath.Data()),
"AliEMCALBadChannels");
227 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber);
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");
265 TObjArray *recal=(TObjArray*)contRF->GetObject(runnumber);
269 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
273 TObjArray *recalib=(TObjArray*)recalpass->FindObject(
"Recalib");
277 AliInfo(
"Recalibrate EMCAL");
278 for (Int_t i=0; i<nSM; ++i)
280 TH2F *h =
fRecoUtils->GetEMCALChannelRecalibrationFactors(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)
347 Float_t factor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,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");
369 TObjArray *trecal=(TObjArray*)contTRF->GetObject(runnumber);
373 TString passM = pass;
374 if(pass==
"spc_calo") passM =
"pass1";
375 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
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");
418 Warning(
"AccessOCDB",
"Event not available!!!");
428 AliCDBManager *cdb = AliCDBManager::Instance();
433 cdb->SetDefaultStorage(
fOCDBpath.Data());
434 AliInfo(Form(
"Default storage %s",
fOCDBpath.Data()));
437 cdb->SetRun(
fEvent->GetRunNumber());
443 cdb->SetSpecificStorage(
"EMCAL/Calib/Data",
"raw://");
444 cdb->SetSpecificStorage(
"EMCAL/Calib/Time",
"raw://");
445 cdb->SetSpecificStorage(
"EMCAL/Calib/Pedestals",
"raw://");
448 TString path = cdb->GetDefaultStorage()->GetBaseFolder();
463 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
464 Int_t eventN = Entry();
465 if(aodIH) eventN = aodIH->GetReadEntry();
474 if (aodIH && aodIH->GetMergeEvents())
478 if(!aodIH->GetMergeEMCALCells())
479 AliFatal(
"Events merged but not EMCAL cells, check analysis settings!");
481 AliDebug(1,
"Use embedded events");
483 AliDebug(1,Form(
"\t InputEvent N Clusters %d, N Cells %d",
484 InputEvent()->GetNumberOfCaloClusters(),InputEvent()->GetEMCALCells()->GetNumberOfCells()));
486 AliDebug(1,Form(
"\t MergedEvent N Clusters %d, N Cells %d",
487 aodIH->GetEventToMerge()->GetNumberOfCaloClusters(), aodIH->GetEventToMerge()->GetEMCALCells()->GetNumberOfCells()));
498 AliDebug(1,Form(
"\t OutputEvent N Clusters %d, N Cells %d",
499 AODEvent()->GetNumberOfCaloClusters(), AODEvent()->GetEMCALCells()->GetNumberOfCells()));
515 AliError(
"Event not available");
538 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
557 Int_t nClusters =
fEvent->GetNumberOfCaloClusters();
558 Int_t nClustersOrg = 0;
560 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
561 if(aodIH && aodIH->GetEventToMerge())
562 nClusters = aodIH->GetEventToMerge()->GetNumberOfCaloClusters();
570 for (Int_t i = 0; i < nClusters; i++)
572 AliVCluster *clus = 0;
573 if(aodIH && aodIH->GetEventToMerge())
574 clus = aodIH->GetEventToMerge()->GetCaloCluster(i);
576 clus =
fEvent->GetCaloCluster(i);
582 Int_t label = clus->GetLabel();
584 if (clus->GetNLabels() >=2 ) label2 = clus->GetLabelAt(1) ;
594 UShort_t * index = clus->GetCellsAbsId() ;
595 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
598 fCellTime[index[icell]] = clus->GetTOF();
609 clus->GetCellMCEdepFractionArray(icell,eDepFrac);
623 AliVCaloCells * cells =
fEvent->GetEMCALCells();
625 Int_t bc = InputEvent()->GetBunchCrossNumber();
627 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
630 id = cells->GetCellNumber(icell);
631 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(
id,bc,amp,time,cells);
635 if( amp < fRecParam->GetMinECut() ||
637 time <
fRecParam->GetTimeMin() ) accept = kFALSE;
649 if (accept &&
fRecoUtils->IsExoticCell(
id,cells,bc))
654 AliDebug(2,Form(
"Remove channel absId %d, index %d of %d, amp %f, time %f",
655 id,icell, cells->GetNumberOfCells(), amp, time*1.e9));
659 Int_t mcLabel = cells->GetMCLabel(icell);
675 Float_t efrac = cells->GetEFraction(icell);
678 if (mcLabel > 0 && efrac < 1.e-6) efrac = 1;
680 AliEMCALDigit* digit =
new((*fDigitsArr)[idigit]) AliEMCALDigit( mcLabel, mcLabel,
id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, amp*efrac);
694 AliVCluster *clus = 0;
699 AliInfo(
"Negative original cluster index, skip \n");
703 if(aodIH && aodIH->GetEventToMerge())
704 clus = aodIH->GetEventToMerge()->GetCaloCluster(iclus);
706 clus =
fEvent->GetCaloCluster(iclus);
708 for(Int_t icluscell=0; icluscell < clus->GetNCells(); icluscell++ )
710 if(
id != clus->GetCellAbsId(icluscell))
continue ;
714 clus->GetCellMCEdepFractionArray(icluscell,eDepFrac);
720 for(Int_t imc = 0; imc < 4; imc++)
722 if(eDepFrac[imc] > 0 && clus->GetNLabels() > imc)
726 labeArr.Set(nLabels);
727 labeArr.AddAt(clus->GetLabelAt(imc), nLabels-1);
729 eDepArr.Set(nLabels);
730 eDepArr.AddAt(eDepFrac[imc]*amp , nLabels-1);
737 digit->SetListOfParents(nLabels,labeArr.GetArray(),eDepArr.GetArray());
762 AliWarning(Form(
"No array with CaloClusters, input RecPoints entries %d",
fClusterArr->GetEntriesFast()));
766 AliDebug(1,Form(
"N clusters: before recluster %d, after recluster %d, recpoints %d",
782 AliVCaloCells *cells =
fEvent->GetEMCALCells();
783 Double_t cellAmplitude = 0;
784 Double_t cellTime = 0;
785 Short_t cellNumber = 0;
786 Int_t cellMCLabel = 0;
787 Double_t cellEFrac = 0;
788 Int_t nClustersOrg = 0;
791 for (Int_t i = 0; i <
fEvent->GetNumberOfCaloClusters(); i++)
793 AliVCluster *clus =
fEvent->GetCaloCluster(i);
797 if(
fRecoUtils->ClusterContainsBadChannel(
fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
808 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
810 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
813 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
814 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
815 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
818 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
819 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
822 cells->SetCell(icell, cellNumber, cellAmplitude*
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
828 AliESDCaloCluster * esdCluster =
dynamic_cast<AliESDCaloCluster*
> (clus);
829 AliAODCaloCluster * aodCluster =
dynamic_cast<AliAODCaloCluster*
> (clus);
840 AliWarning(
"Wrong CaloCluster type?");
858 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
859 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
861 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
862 aodEMcells.CreateContainer(nEMcell);
863 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
864 Double_t calibFactor = 1.;
865 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
867 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
868 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
869 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
873 calibFactor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
876 if(!
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
878 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
879 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
883 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
895 AliESDEvent* esdevent =
dynamic_cast<AliESDEvent*
> (
fEvent);
896 AliAODEvent* aodevent =
dynamic_cast<AliAODEvent*
> (
fEvent);
900 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
902 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
903 if(!header) AliFatal(
"Not a standard AOD");
904 header->SetRunNumber(
fEvent->GetRunNumber());
908 TTree* tree = fInputHandler->GetTree();
911 TFile*
file = tree->GetCurrentFile();
912 if (file) header->SetESDFileName(file->GetName());
916 AliAODHeader * aodheader =
dynamic_cast<AliAODHeader*
>(aodevent->GetHeader());
917 if(!aodheader) AliFatal(
"Not a standard AOD");
918 header->SetESDFileName(aodheader->GetESDFileName());
921 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
922 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
923 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
924 header->SetEventType(
fEvent->GetEventType());
929 if(
fEvent->GetCentrality())
930 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
932 header->SetCentrality(0);
936 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
938 header->SetFiredTriggerClasses(
fEvent->GetFiredTriggerClasses());
940 header->SetTriggerMask(
fEvent->GetTriggerMask());
941 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
945 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
946 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
947 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
951 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
952 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
953 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
956 header->SetMagneticField(
fEvent->GetMagneticField());
959 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
960 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
961 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
962 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
963 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
965 Float_t diamxy[2]={(Float_t)
fEvent->GetDiamondX(),(Float_t)
fEvent->GetDiamondY()};
967 fEvent->GetDiamondCovXY(diamcov);
968 header->SetDiamond(diamxy,diamcov);
969 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
970 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
973 Int_t nVertices = 1 ;;
974 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
976 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
979 TClonesArray &vertices = *(AODEvent()->GetVertices());
984 fEvent->GetPrimaryVertex()->GetXYZ(pos);
988 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
989 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
993 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
994 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();
997 AliAODVertex * primary =
new(vertices[jVertices++])
998 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
999 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
1000 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
1020 for(Int_t i = 0; i < kNumberOfCaloClusters; i++)
1022 AliAODCaloCluster *newCluster = (AliAODCaloCluster *)
fCaloClusterArr->At(i);
1024 newCluster->SetID(i);
1027 newCluster->SetE(
fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
1032 Int_t trackIndex =
fRecoUtils->GetMatchedTrackIndex(i);
1035 newCluster->AddTrackMatched(
fEvent->GetTrack(trackIndex));
1036 AliDebug(2,Form(
"Matched Track index %d to new cluster %d",trackIndex,i));
1039 Float_t dR = 999., dZ = 999.;
1040 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dZ,dR);
1041 newCluster->SetTrackDistance(dR,dZ);
1045 Int_t absId0 = newCluster->GetCellsAbsId()[0];
1064 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
1066 AliDebug(2,Form(
"New cluster %d of %d, energy %f, mc label %d",
1067 newCluster->GetID(), kNumberOfCaloClusters, newCluster->E(), newCluster->GetLabel()));
1099 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1101 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null");
1105 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1107 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null");
1111 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1112 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1113 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1114 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1115 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1116 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1117 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1118 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1120 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1121 return TString(
"pass1");
1125 AliInfo(
"Pass number string not found");
1136 if(fDebug >=0) (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
1141 fBranchNames =
"ESD:AliESDHeader.,EMCALCells.";
1159 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
1197 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1199 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1201 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1209 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1234 for (i = 0; i < 8; i++)
1239 for (i = 0; i < 3; i++)
1259 Int_t runnumber = InputEvent()->GetRunNumber() ;
1264 fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(runnumber);
1265 AliInfo(Form(
"Get EMCAL geometry name <%s> for run %d",
fGeom->GetName(),runnumber));
1270 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fGeomName.Data()));
1290 AliDebug(1,Form(
"Init for run=%d",runnumber));
1291 if (!gGeoManager) AliDebug(1,
"Careful!, gGeoManager not loaded, load misalign matrices");
1296 AliInfo(
"Load user defined EMCAL geometry matrices");
1299 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
1300 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePath.Data()),
"AliEMCALgeo");
1301 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,
"EmcalMatrices");
1303 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1308 AliDebug(2,Form(
"EMCAL matrices SM %d, %p",mod,((TGeoHMatrix*) matEMCAL->At(mod))));
1311 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1316 if(DebugLevel() > 1)
1321 else if(gGeoManager)
1323 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
1324 fGeom->SetMisalMatrix(
fGeom->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
1328 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
1335 else if(!gGeoManager)
1337 AliInfo(
"AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1339 if(!strcmp(
fEvent->GetName(),
"AliAODEvent"))
1341 AliWarning(
"Use ideal geometry, values geometry matrix not kept in AODs");
1345 AliDebug(1,
"Load Misaligned matrices");
1347 AliESDEvent* esd =
dynamic_cast<AliESDEvent*
>(
fEvent) ;
1351 AliError(
"This event does not contain ESDs?");
1352 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
1356 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1358 if(DebugLevel() > 1)
1359 esd->GetEMCALMatrix(mod)->Print();
1361 if(esd->GetEMCALMatrix(mod))
fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1383 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1384 Float_t totCellE = 0;
1385 Int_t bc = InputEvent()->GetBunchCrossNumber();
1387 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1390 Double_t tcell = 0 ;
1392 Int_t absID = cells->GetCellNumber(icell);
1393 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1396 if(accept && !
fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
1406 if(totCellE < 1)
return kTRUE;
1419 if(run < 146858 || run > 146860)
return kFALSE ;
1422 Int_t ncellsSM3 = 0;
1423 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1424 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1426 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
1429 TString triggerclasses =
fEvent->GetFiredTriggerClasses();
1431 Int_t ncellcut = 21;
1432 if(triggerclasses.Contains(
"EMC")) ncellcut = 35;
1434 if( ncellsSM3 >= ncellcut)
1436 AliInfo(Form(
"Reject event %d with ncells in SM3 %d",(Int_t)Entry(),ncellsSM3));
1437 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
1452 for(Int_t i = 0; i <
fClusterArr->GetEntriesFast(); i++)
1454 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*)
fClusterArr->At(i);
1456 const Int_t ncells = recPoint->GetMultiplicity();
1457 Int_t ncellsTrue = 0;
1459 if(recPoint->GetEnergy() <
fRecParam->GetClusteringThreshold())
continue;
1462 UShort_t absIds[ncells];
1463 Double32_t ratios[ncells];
1466 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1468 Float_t clusterE = 0;
1469 for (Int_t c = 0; c < ncells; c++)
1471 AliEMCALDigit *digit = (AliEMCALDigit*)
fDigitsArr->At(recPoint->GetDigitsList()[c]);
1473 absIds[ncellsTrue] = digit->GetId();
1474 ratios[ncellsTrue] = recPoint->GetEnergiesList()[c]/digit->GetAmplitude();
1482 AliDebug(2,Form(
"Too small energy in cell of cluster: cluster cell %f, digit %f",
1483 recPoint->GetEnergiesList()[c],digit->GetAmplitude()));
1489 clusterE +=recPoint->GetEnergiesList()[c];
1492 if (aodIH && aodIH->GetMergeEvents())
1495 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1496 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1498 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1500 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1503 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1514 AliDebug(2,Form(
"Skipping cluster with no cells avobe threshold E = %f, ncells %d",
1515 recPoint->GetEnergy(), ncells));
1521 if(clusterE < fRecParam->GetClusteringThreshold())
1523 AliDebug(2,Form(
"Remove cluster with energy below seed threshold %f",clusterE));
1533 recPoint->GetGlobalPosition(gpos);
1538 (*fCaloClusterArr)[j] =
new AliAODCaloCluster() ;
1539 AliAODCaloCluster *clus =
dynamic_cast<AliAODCaloCluster *
>(
fCaloClusterArr->At(j) ) ;
1541 clus->SetType(AliVCluster::kEMCALClusterv1);
1542 clus->SetE(clusterE);
1543 clus->SetPosition(g);
1544 clus->SetNCells(ncellsTrue);
1545 clus->SetCellsAbsId(absIds);
1546 clus->SetCellsAmplitudeFraction(ratios);
1548 clus->SetTOF(recPoint->GetTime()) ;
1549 clus->SetNExMax(recPoint->GetNExMax());
1550 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
1552 if(ncells == ncellsTrue)
1554 Float_t elipAxis[2];
1555 recPoint->GetElipsAxis(elipAxis);
1556 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1557 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1558 clus->SetDispersion(recPoint->GetDispersion());
1564 AliDebug(2,Form(
"Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape",ncells,ncellsTrue));
1566 AliVCaloCells* cells = 0x0;
1567 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1568 else cells = InputEvent()->GetEMCALCells();
1570 fRecoUtils->RecalculateClusterShowerShapeParameters(
fGeom,cells,clus);
1584 Int_t parentMult = 0;
1585 Int_t *parentList = recPoint->GetParents(parentMult);
1586 Float_t *parentListDE = recPoint->GetParentsDE();
1588 clus->SetLabel(parentList, parentMult);
1589 clus->SetClusterMCEdepFractionFromEdepArray(parentListDE);
1596 UInt_t * mcEdepFracPerCell =
new UInt_t[ncellsTrue];
1599 AliVCaloCells* cells = 0x0;
1600 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1601 else cells = InputEvent()->GetEMCALCells();
1603 for(Int_t icell = 0; icell < ncellsTrue ; icell++)
1607 const AliEMCALDigit * dig = (
const AliEMCALDigit*)
fDigitsArr->At(idigit);
1612 mcEdepFracPerCell[icell] = 0;
1614 Int_t nparents = dig->GetNiparent();
1617 Int_t digLabel =-1 ;
1619 Float_t edepTot = 0 ;
1620 Float_t mcEDepFrac[4] = {0,0,0,0};
1623 for ( Int_t jndex = 0 ; jndex < nparents ; jndex++ )
1625 digLabel = dig->GetIparent (jndex+1);
1626 edep = dig->GetDEParent(jndex+1);
1629 if ( digLabel == parentList[0] ) mcEDepFrac[0] = edep;
1630 else if ( digLabel == parentList[1] ) mcEDepFrac[1] = edep;
1631 else if ( digLabel == parentList[2] ) mcEDepFrac[2] = edep;
1632 else if ( digLabel == parentList[3] ) mcEDepFrac[3] = edep;
1639 mcEdepFracPerCell[icell] = clus->PackMCEdepFraction(mcEDepFrac);
1644 clus->SetCellsMCEdepFractionMap(mcEdepFracPerCell);
1646 delete [] mcEdepFracPerCell;
1659 if(label < 0) return ;
1661 AliAODEvent * evt =
dynamic_cast<AliAODEvent*
> (
fEvent) ;
1664 TClonesArray * arr =
dynamic_cast<TClonesArray*
>(evt->FindListObject(
"mcparticles")) ;
1667 if(label < arr->GetEntriesFast())
1669 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(label));
1670 if(!particle) return ;
1672 if(label == particle->Label())
return ;
1678 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1680 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(ind));
1681 if(!particle) continue ;
1683 if(label == particle->Label())
1718 AliAODCaloCluster * clus)
1720 Int_t parentMult = 0;
1721 Int_t *parentList = recPoint->GetParents(parentMult);
1722 clus->SetLabel(parentList, parentMult);
1726 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1729 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1733 for ( UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1736 if (
fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1740 Int_t * newLabelArray =
new Int_t[clus->GetNLabels()+1] ;
1741 for ( UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1743 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1747 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
1748 delete [] newLabelArray;
1761 TArrayI clArray(300) ;
1764 Int_t nLabTotOrg = 0;
1768 AliVEvent *
event =
fEvent;
1771 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1772 if(aodIH && aodIH->GetEventToMerge())
1773 event = aodIH->GetEventToMerge();
1777 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1779 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1786 for(Int_t icl =0; icl < nClu; icl++)
1788 if(((Int_t)clArray.GetAt(icl))==-1 )
continue;
1789 if( idCluster == ((Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1793 if( set && idCluster >= 0)
1795 clArray.SetAt(idCluster,nClu++);
1797 nLabTotOrg+=(
event->GetCaloCluster(idCluster))->GetNLabels();
1802 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1804 if(emax < clOrg->E())
1813 if(nClu==0 || nLabTotOrg == 0)
1821 if(idMax != ((Int_t)clArray.GetAt(0)))
1823 Int_t maxIndex = -1;
1824 Int_t firstCluster = ((Int_t)clArray.GetAt(0));
1825 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1827 if(idMax == ((Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1830 if(firstCluster >=0 && idMax >=0)
1832 clArray.SetAt(idMax,0);
1833 clArray.SetAt(firstCluster,maxIndex);
1838 TArrayI clMCArray(nLabTotOrg) ;
1842 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1844 Int_t idCluster = (Int_t) clArray.GetAt(iLoopCluster);
1846 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1847 Int_t nLab = clOrg->GetNLabels();
1849 for ( Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1851 Int_t lab = clOrg->GetLabelAt(iLab) ;
1856 for(Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1858 if( lab == ((Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1862 if( set ) clMCArray.SetAt(lab,nLabTot++);
1869 clus->SetLabel(clMCArray.GetArray(), nLabTot);
1893 AliInfo(
"Cluster branch name not set, set it to newEMCALClustersArray");
1949 AliDebug(1,Form(
"Skip Event %d", (Int_t) Entry()));
void FillAODCaloCells()
Put calo cells in standard branch.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
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.
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.