17 #include <TClonesArray.h> 18 #include <TGeoManager.h> 19 #include <TObjArray.h> 25 #include "AliAODCaloCluster.h" 26 #include "AliAODEvent.h" 27 #include "AliAnalysisManager.h" 28 #include "AliCDBEntry.h" 29 #include "AliCDBManager.h" 30 #include "AliCaloCalibPedestal.h" 31 #include "AliEMCALAfterBurnerUF.h" 32 #include "AliEMCALCalibData.h" 33 #include "AliEMCALClusterizerNxN.h" 34 #include "AliEMCALClusterizerv1.h" 35 #include "AliEMCALClusterizerv2.h" 36 #include "AliEMCALClusterizerv3.h" 37 #include "AliEMCALClusterizerFixedWindow.h" 38 #include "AliEMCALDigit.h" 39 #include "AliEMCALGeometry.h" 40 #include "AliEMCALRecParam.h" 41 #include "AliEMCALRecPoint.h" 43 #include "AliESDEvent.h" 44 #include "AliInputEventHandler.h" 57 fRecParam(new AliEMCALRecParam),
62 fGeomMatrixSet(kFALSE),
63 fLoadGeomMatrices(kFALSE),
72 fAttachClusters(kTRUE),
73 fSubBackground(kFALSE),
79 fInputCellType(kFEEData),
82 fCaloClustersName("newCaloClusters"),
83 fDoUpdateCells(kFALSE),
85 fClusterBadChannelCheck(kFALSE),
86 fRejectExoticClusters(kFALSE),
87 fRejectExoticCells(kFALSE),
89 fDoNonLinearity(kFALSE),
90 fRecalDistToBadChannels(kFALSE),
91 fSetCellMCLabelFromCluster(0),
92 fSetCellMCLabelFromEdepFrac(0),
101 for(
Int_t i = 0; i < AliEMCALGeoParams::fgkEMCALModules; i++) fGeomMatrix[i] = 0 ;
102 for(
Int_t j = 0; j < fgkTotalCellNumber; j++)
103 { fOrgClusterCellId[j] =-1; fCellLabels[j] =-1 ; }
112 fRecParam(new AliEMCALRecParam),
117 fGeomMatrixSet(kFALSE),
118 fLoadGeomMatrices(kFALSE),
127 fAttachClusters(kTRUE),
128 fSubBackground(kFALSE),
134 fInputCellType(kFEEData),
137 fCaloClustersName(
"newCaloClusters"),
138 fDoUpdateCells(kFALSE),
139 fDoClusterize(kTRUE),
140 fClusterBadChannelCheck(kFALSE),
141 fRejectExoticClusters(kFALSE),
142 fRejectExoticCells(kFALSE),
144 fDoNonLinearity(kFALSE),
145 fRecalDistToBadChannels(kFALSE),
146 fSetCellMCLabelFromCluster(0),
147 fSetCellMCLabelFromEdepFrac(0),
156 fBranchNames =
"ESD:AliESDHeader.,AliESDRun.,EMCALCells.,EMCALTrigger. AOD:header,emcalCells";
158 for(
Int_t i = 0; i < AliEMCALGeoParams::fgkEMCALModules; i++)
fGeomMatrix[i] = 0 ;
204 Error(
"UserExec",
"Event not available");
212 UInt_t mask1 =
fEsd->GetESDRun()->GetDetectorsInDAQ();
213 UInt_t mask2 =
fEsd->GetESDRun()->GetDetectorsInReco();
214 Bool_t desc1 = (mask1 >> 18) & 0x1;
215 Bool_t desc2 = (mask2 >> 18) & 0x1;
216 if (desc1==0 || desc2==0) {
217 AliError(Form(
"EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
218 mask1,
fEsd->GetESDRun()->GetDetectorsInReco(),
219 mask2,
fEsd->GetESDRun()->GetDetectorsInDAQ()));
223 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
225 offtrigger = ((AliVAODHeader*)
fAod->GetHeader())->GetOfflineTrigger();
229 if (offtrigger & AliVEvent::kFastOnly) {
230 AliError(Form(
"EMCAL not in fast only partition"));
238 AliWarning(
"Unfolding not implemented");
264 const Int_t Ncls = orig->GetEntries();
266 for(
Int_t i=0; i < Ncls; ++i) {
267 AliVCluster *oc =
static_cast<AliVCluster*
>(orig->At(i));
275 AliVCluster *dc =
static_cast<AliVCluster*
>(dest->New(i));
276 dc->SetType(AliVCluster::kEMCALClusterv1);
279 oc->GetPosition(pos);
280 dc->SetPosition(pos);
281 dc->SetNCells(oc->GetNCells());
282 dc->SetCellsAbsId(oc->GetCellsAbsId());
283 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
284 dc->SetID(oc->GetID());
285 dc->SetDispersion(oc->GetDispersion());
286 dc->SetEmcCpvDistance(-1);
288 dc->SetTOF(oc->GetTOF());
289 dc->SetNExMax(oc->GetNExMax());
290 dc->SetM02(oc->GetM02());
291 dc->SetM20(oc->GetM20());
292 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
293 dc->SetMCEnergyFraction(oc->GetMCEnergyFraction());
296 UInt_t nlabels = oc->GetNLabels();
297 Int_t *labels = oc->GetLabels();
299 if (nlabels == 0 || !labels)
302 AliESDCaloCluster *esdClus =
dynamic_cast<AliESDCaloCluster*
>(dc);
304 TArrayI parents(nlabels, labels);
305 esdClus->AddLabels(parents);
308 AliAODCaloCluster *aodClus =
dynamic_cast<AliAODCaloCluster*
>(dc);
310 aodClus->SetLabel(labels, nlabels);
359 Int_t nClusters = InputEvent()->GetNumberOfCaloClusters();
360 for (
Int_t i = 0; i < nClusters; i++)
362 AliVCluster *clus = InputEvent()->GetCaloCluster(i);
366 if (!clus->IsEMCAL())
continue ;
368 Int_t label = clus->GetLabel();
369 UShort_t * index = clus->GetCellsAbsId() ;
371 for(
Int_t icell=0; icell < clus->GetNCells(); icell++)
383 for (
Int_t icell = 0, idigit = 0; icell < ncells; ++icell)
386 Double_t cellTime=0, amp = 0, cellEFrac = 0;
388 Int_t cellMCLabel=-1;
389 if (
fCaloCells->GetCell(icell, cellNumber, amp, cellTime, cellMCLabel, cellEFrac) != kTRUE)
396 if (cellMCLabel > 0 && cellEFrac < 1e-6)
399 if (cellAmplitude < 1e-6 || cellNumber < 0)
403 if (cellMCLabel <= 0)
406 cellAmplitude *= cellEFrac;
414 cellAmplitude *= 1 - cellEFrac;
439 AliInfo(
"Negative original cluster index, skip \n");
443 AliVCluster *clus = InputEvent()->GetCaloCluster(iclus);
445 for(
Int_t icluscell=0; icluscell < clus->GetNCells(); icluscell++ )
447 if(cellNumber != clus->GetCellAbsId(icluscell))
continue ;
452 nLabels = labeArr.GetSize();
456 AliEMCALDigit *digit =
new((*fDigitsArr)[idigit]) AliEMCALDigit(cellMCLabel, cellMCLabel, cellNumber,
457 cellAmplitude, (
Float_t)cellTime,
458 AliEMCALDigit::kHG,idigit, 0, 0, cellEFrac*cellAmplitude);
462 digit->SetListOfParents(nLabels,labeArr.GetArray(),eDepArr.GetArray());
471 digit->SetAmplitude(energy);
479 avgE /=
fGeom->GetNumberOfSuperModules()*48*24;
481 for (
Int_t i = 0; i < ndigis; ++i) {
482 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(
fDigitsArr->At(i));
485 digit->SetAmplitude(0);
487 digit->SetAmplitude(energy);
498 for (
Int_t idigit = 0; idigit < maxd; idigit++){
499 if (idigit % 24 == 12) idigit += 12;
500 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(
fDigitsArr->New(idigit));
501 digit->SetId(idigit * 4);
503 digit->SetTimeR(600);
504 digit->SetIndexInList(idigit);
505 digit->SetType(AliEMCALDigit::kHG);
506 digit->SetAmplitude(0.1);
517 AliVCaloTrigger *triggers = InputEvent()->GetCaloTrigger(
"EMCAL");
519 if (!triggers || !(triggers->GetEntries() > 0))
525 while ((triggers->Next())) {
527 triggers->GetAmplitude(L0Amplitude);
532 Int_t L1Amplitude = 0;
533 triggers->GetL1TimeSum(L1Amplitude);
538 Int_t triggerTime = 0;
540 triggers->GetNL0Times(ntimes);
547 triggers->GetL0Times(trgtimes);
548 triggerTime = trgtimes[0];
551 Int_t triggerCol = 0, triggerRow = 0;
552 triggers->GetPosition(triggerCol, triggerRow);
555 fGeom->GetAbsFastORIndexFromPositionInEMCAL(triggerCol, triggerRow, find);
560 Int_t cidx[4] = {-1};
561 Bool_t ret =
fGeom->GetCellIndexFromFastORIndex(find, cidx);
569 triggerAmplitude = 0.25 * L1Amplitude;
572 triggerAmplitude = L0Amplitude;
575 for (
Int_t idxpos = 0; idxpos < 4; idxpos++) {
576 Int_t triggerNumber = cidx[idxpos];
577 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(
fDigitsArr->New(idigit));
578 digit->SetId(triggerNumber);
579 digit->SetTime(triggerTime);
580 digit->SetTimeR(triggerTime);
581 digit->SetIndexInList(idigit);
582 digit->SetType(AliEMCALDigit::kHG);
583 digit->SetAmplitude(triggerAmplitude);
600 Int_t bunchCrossNo = InputEvent()->GetBunchCrossNumber();
602 if(isEx) accept = kFALSE;
615 for (
Int_t icluster=0; icluster < nclusters; ++icluster) {
616 AliVCluster *clust =
static_cast<AliVCluster*
>(
fCaloClusters->At(icluster));
619 if (!clust->IsEMCAL())
653 Int_t bunchCrossNo = InputEvent()->GetBunchCrossNumber();
680 clust->SetE(correctedEnergy);
703 const Int_t ntrks = tarr->GetEntries();
704 for(
Int_t t = 0; t<ntrks; ++t) {
705 AliVTrack *track =
static_cast<AliVTrack*
>(tarr->At(t));
708 const AliExternalTrackParam *outp = track->GetOuterParam();
712 if (!outp->GetXYZ(trkPos))
714 TVector3 vec(trkPos[0],trkPos[1],trkPos[2]);
718 vphi += 2*TMath::Pi();
719 if (TMath::Abs(veta)>0.75 || (vphi<70*TMath::DegToRad()) || (vphi>190*TMath::DegToRad()))
726 AliExternalTrackParam trkParTemp(*outp);
731 tmpEta = ceta - veta;
732 tmpPhi = cphi - vphi;
734 if (TMath::Abs(tmpEta)<TMath::Abs(dEtaMin) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMin)) {
740 c->SetEmcCpvDistance(imin);
741 c->SetTrackDistance(dPhiMin, dEtaMin);
750 TClonesArray *tarr = 0;
752 tarr =
dynamic_cast<TClonesArray*
>(InputEvent()->FindListObject(
fTrackName));
754 AliError(Form(
"Cannot get tracks named %s",
fTrackName.Data()));
759 AliDebug(1, Form(
"total no of clusters %d", Ncls));
761 for(
Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i)
763 AliEMCALRecPoint *recpoint =
static_cast<AliEMCALRecPoint*
>(
fClusterArr->At(i));
765 Int_t ncellsTrue = 0;
766 const Int_t ncells = recpoint->GetMultiplicity();
768 Double32_t ratios[ncells];
769 Int_t *dlist = recpoint->GetDigitsList();
770 Float_t *elist = recpoint->GetEnergiesList();
775 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(
fDigitsArr->At(dlist[
c]));
776 absIds[ncellsTrue] = digit->GetId();
777 ratios[ncellsTrue] = elist[
c]/digit->GetAmplitude();
779 if (digit->GetIparent(1) > 0)
780 mcEnergy += digit->GetDEParent(1)/recpoint->GetEnergy();
787 AliWarning(
"Skipping cluster with no cells");
793 recpoint->GetGlobalPosition(gpos);
797 AliDebug(1, Form(
"energy %f", recpoint->GetEnergy()));
799 AliVCluster *
c =
static_cast<AliVCluster*
>(clus->New(nout++));
800 c->SetType(AliVCluster::kEMCALClusterv1);
801 c->SetE(recpoint->GetEnergy());
803 c->SetNCells(ncellsTrue);
804 c->SetCellsAbsId(absIds);
805 c->SetCellsAmplitudeFraction(ratios);
806 c->SetID(recpoint->GetUniqueID());
807 c->SetDispersion(recpoint->GetDispersion());
808 c->SetEmcCpvDistance(-1);
810 c->SetTOF(recpoint->GetTime()) ;
811 c->SetNExMax(recpoint->GetNExMax());
813 recpoint->GetElipsAxis(elipAxis);
814 c->SetM02(elipAxis[0]*elipAxis[0]);
815 c->SetM20(elipAxis[1]*elipAxis[1]);
816 c->SetMCEnergyFraction(mcEnergy);
821 Int_t parentMult = 0;
822 Int_t *parentList = recpoint->GetParents(parentMult);
823 Float_t *parentListDE = recpoint->GetParentsDE();
825 c->SetLabel(parentList, parentMult);
828 c->SetClusterMCEdepFractionFromEdepArray(parentListDE);
840 for(
Int_t icell = 0; icell < ncellsTrue ; icell++)
844 const AliEMCALDigit * dig = (
const AliEMCALDigit*)
fDigitsArr->At(idigit);
849 mcEdepFracPerCell[icell] = 0;
851 Int_t nparents = dig->GetNiparent();
857 Float_t mcEDepFrac[4] = {0,0,0,0};
860 for (
Int_t jndex = 0 ; jndex < nparents ; jndex++ )
862 digLabel = dig->GetIparent (jndex+1);
863 edep = dig->GetDEParent(jndex+1);
866 if ( digLabel == parentList[0] ) mcEDepFrac[0] = edep;
867 else if ( digLabel == parentList[1] ) mcEDepFrac[1] = edep;
868 else if ( digLabel == parentList[2] ) mcEDepFrac[2] = edep;
869 else if ( digLabel == parentList[3] ) mcEDepFrac[3] = edep;
876 mcEdepFracPerCell[icell] = c->PackMCEdepFraction(mcEDepFrac);
881 c->SetCellsMCEdepFractionMap(mcEdepFracPerCell);
883 delete [] mcEdepFracPerCell;
904 if (ncells!=ndigis) {
908 for (
Int_t idigit = 0; idigit < ndigis; ++idigit) {
909 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(
fDigitsArr->At(idigit));
910 Double_t cellAmplitude = digit->GetCalibAmp();
911 Short_t cellNumber = digit->GetId();
912 Double_t cellTime = digit->GetTime();
913 fCaloCells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
923 for (
Int_t i=0;i<nents;++i) {
943 fRun = InputEvent()->GetRunNumber();
955 fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->
GetRunNumber());
957 AliFatal(
"Geometry not available!!!");
963 for(
Int_t mod=0; mod <
fGeom->GetNumberOfSuperModules(); ++mod) {
965 if (DebugLevel() > 2)
971 for(
Int_t mod=0; mod <
fGeom->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
972 const TGeoHMatrix *gm = 0;
974 gm =
fEsd->GetEMCALMatrix(mod);
976 AliAODHeader *aodheader =
dynamic_cast<AliAODHeader*
>(
fAod->GetHeader());
977 if(!aodheader) AliFatal(
"Not a standard AOD");
979 gm = aodheader->GetEMCALMatrix(mod);
983 if (DebugLevel() > 2)
985 fGeom->SetMisalMatrix(gm,mod);
994 fDigitsArr =
new TClonesArray(
"AliEMCALDigit", 1000);
1004 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1006 else if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
1007 AliEMCALClusterizerNxN *clusterizer =
new AliEMCALClusterizerNxN(
fGeom);
1008 clusterizer->SetNRowDiff(
fRecParam->GetNRowDiff());
1009 clusterizer->SetNColDiff(
fRecParam->GetNColDiff());
1012 else if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1014 else if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv3)
1016 else if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW) {
1017 AliEMCALClusterizerFixedWindow *clusterizer =
new AliEMCALClusterizerFixedWindow(
fGeom);
1018 clusterizer->SetNphi(
fNPhi);
1019 clusterizer->SetNeta(
fNEta);
1026 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1031 AliCDBManager *cdb = AliCDBManager::Instance();
1032 if (!cdb->IsDefaultStorageSet() && !
fOCDBpath.IsNull())
1034 if (
fRun!=cdb->GetRun())
1038 AliCDBEntry *entry =
static_cast<AliCDBEntry*
>(AliCDBManager::Instance()->Get(
"EMCAL/Calib/Data"));
1040 fCalibData =
static_cast<AliEMCALCalibData*
>(entry->GetObject());
1042 AliFatal(
"Calibration parameters not found in CDB!");
1045 AliCDBEntry *entry =
static_cast<AliCDBEntry*
>(AliCDBManager::Instance()->Get(
"EMCAL/Calib/Pedestals"));
1047 fPedestalData =
static_cast<AliCaloCalibPedestal*
>(entry->GetObject());
1069 AliError(Form(
"%s: Could not retrieve cells %s!", GetName(),
fCaloCellsName.Data()));
1072 AliFatal(
"Could not get EMCal cells!");
1084 fCaloClusters =
static_cast<TClonesArray*
>(InputEvent()->FindListObject(
"CaloClusters"));
1086 fCaloClusters =
static_cast<TClonesArray*
>(InputEvent()->FindListObject(
"caloClusters"));
1103 AliFatal(
"Could not get cluster collection!");
1106 if (!cl->GetBaseClass(
"AliVCluster")) {
1107 AliFatal(Form(
"%s: Collection %s does not contain AliVCluster objects!", GetName(),
fCaloClusters->GetName()));
virtual void UserExec(Option_t *option)
void RecalculateCellLabelsRemoveAddedGenerator(Int_t absID, AliVCluster *clus, AliMCEvent *mc, Float_t &, TArrayI &labeArr, TArrayF &eDepArr) const
AliEMCALClusterizer * fClusterizer
void Print(std::ostream &o, const char *name, Double_t dT, Double_t dVM, Double_t alldT, Double_t alldVM)
TString fOutputAODBrName
AOD Branch with output clusters.
AliAODEvent * fAod
esd event
Bool_t CheckCellFiducialRegion(const AliEMCALGeometry *geom, const AliVCluster *cluster, AliVCaloCells *cells)
virtual ~AliAnalysisTaskEMCALClusterizeFast()
EMCal data reclusterization.
TObjArray * fClusterArr
digits array
Bool_t IsExoticCluster(const AliVCluster *cluster, AliVCaloCells *cells, Int_t bc=0)
AliEMCALCalibData * fCalibData
Bool_t fSetCellMCLabelFromEdepFrac
TClonesArray * fDigitsArr
run number
AliEMCALAfterBurnerUF * fUnfolder
clusterizer
Bool_t IsBadChannelsRemovalSwitchedOn() const
Bool_t IsExoticCell(Int_t absId, AliVCaloCells *cells, Int_t bc=-1)
static const Int_t fgkTotalCellNumber
Bool_t fRecalDistToBadChannels
AliESDEvent * fEsd
calo clusters array
virtual void UserCreateOutputObjects()
AliEMCALRecParam * fRecParam
recpoints array
void RecalculateClusterDistanceToBadChannel(const AliEMCALGeometry *geom, AliVCaloCells *cells, AliVCluster *cluster)
void SwitchOffRejectExoticCell()
void SwitchOnBadChannelsRemoval()
virtual void TrackClusterMatching(AliVCluster *c, TClonesArray *tarr)
TClonesArray * fCaloClusters
calo cells object
virtual void Clusterize()
AliEMCALRecoUtils * fRecoUtils
virtual void FillDigitsArray()
TClonesArray * fOutputAODBranch
AliCaloCalibPedestal * fPedestalData
void SwitchOffBadChannelsRemoval()
virtual void CopyClusters(TClonesArray *orig, TClonesArray *dest)
Int_t fOrgClusterCellId[fgkTotalCellNumber]
Bool_t fRejectExoticCells
Bool_t fJustUnfold
unfolding procedure
AliEMCALGeometry * fGeom
aod event
Int_t fSetCellMCLabelFromCluster
virtual void CalibrateClusters()
virtual void UpdateCells()
static Bool_t ExtrapolateTrackToCluster(AliExternalTrackParam *trkParam, const AliVCluster *cluster, Double_t mass, Double_t step, Float_t &tmpEta, Float_t &tmpPhi)
TGeoHMatrix * fGeomMatrix[AliEMCALGeoParams::fgkEMCALModules]
virtual void RecPoints2Clusters(TClonesArray *clus)
Bool_t IsRejectExoticCell() const
Int_t GetRunNumber(TString)
AliVCaloCells * fCaloCells
Float_t CorrectClusterEnergyLinearity(AliVCluster *clu)
AliAnalysisTaskEMCALClusterizeFast()
Bool_t AcceptCell(Int_t cellNumber)
Bool_t ClusterContainsBadChannel(const AliEMCALGeometry *geom, const UShort_t *cellList, Int_t nCells)
TString fCaloClustersName
Bool_t fClusterBadChannelCheck
Bool_t fRejectExoticClusters
InputCellType fInputCellType
void SwitchOnRejectExoticCell()
virtual void UpdateClusters()
Int_t fCellLabels[fgkTotalCellNumber]