#include <TObjArray.h>
#include <TString.h>
#include <TTree.h>
+#include <TArrayI.h>
// --- AliRoot ---
#include "AliAODCaloCluster.h"
ClassImp(AliAnalysisTaskEMCALClusterizeFast)
//________________________________________________________________________
-AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast()
- : AliAnalysisTaskSE(),
- fRun(-1),
- fDigitsArr(0),
- fClusterArr(0),
- fRecParam(0),
- fClusterizer(0),
- fUnfolder(0),
- fJustUnfold(kFALSE),
- fGeomName(),
- fGeomMatrixSet(kFALSE),
- fLoadGeomMatrices(kFALSE),
- fOCDBpath(),
- fCalibData(0),
- fPedestalData(0),
- fOutputAODBranch(0),
- fOutputAODBrName(),
- fRecoUtils(0),
- fLoadCalib(0),
- fLoadPed(0),
- fAttachClusters(1),
- fRecalibOnly(0),
- fSubBackground(0),
- fOverwrite(0),
- fNewClusterArrayName("newCaloClusters"),
- fNPhi(4),
- fNEta(4),
- fShiftPhi(2),
- fShiftEta(2),
- fTRUShift(0),
- fInputCellType(kFEEData),
- fTrackName()
+AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast() :
+ AliAnalysisTaskSE(),
+ fRun(-1),
+ fDigitsArr(0),
+ fClusterArr(0),
+ fRecParam(new AliEMCALRecParam),
+ fClusterizer(0),
+ fUnfolder(0),
+ fJustUnfold(kFALSE),
+ fGeomName(),
+ fGeomMatrixSet(kFALSE),
+ fLoadGeomMatrices(kFALSE),
+ fOCDBpath(),
+ fCalibData(0),
+ fPedestalData(0),
+ fOutputAODBranch(0),
+ fOutputAODBrName(),
+ fRecoUtils(0),
+ fLoadCalib(kFALSE),
+ fLoadPed(kFALSE),
+ fAttachClusters(kTRUE),
+ fSubBackground(kFALSE),
+ fNPhi(4),
+ fNEta(4),
+ fShiftPhi(2),
+ fShiftEta(2),
+ fTRUShift(0),
+ fInputCellType(kFEEData),
+ fTrackName(),
+ fCaloCellsName(),
+ fCaloClustersName("newCaloClusters"),
+ fDoUpdateCells(kTRUE),
+ fDoClusterize(kTRUE),
+ fClusterBadChannelCheck(kTRUE),
+ fRejectExoticClusters(kFALSE),
+ fFiducial(kFALSE),
+ fDoNonLinearity(kFALSE),
+ fRecalDistToBadChannels(kTRUE),
+ fCaloCells(0),
+ fCaloClusters(0),
+ fEsd(0),
+ fAod(0),
+ fGeom(0)
{
// Constructor
}
//________________________________________________________________________
-AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const char *name)
- : AliAnalysisTaskSE(name),
- fRun(-1),
- fDigitsArr(0),
- fClusterArr(0),
- fRecParam(new AliEMCALRecParam),
- fClusterizer(0),
- fUnfolder(0),
- fJustUnfold(kFALSE),
- fGeomName(""),
- fGeomMatrixSet(kFALSE),
- fLoadGeomMatrices(kFALSE),
- fOCDBpath(),
- fCalibData(0),
- fPedestalData(0),
- fOutputAODBranch(0),
- fOutputAODBrName(),
- fRecoUtils(0),
- fLoadCalib(0),
- fLoadPed(0),
- fAttachClusters(1),
- fRecalibOnly(0),
- fSubBackground(0),
- fOverwrite(0),
- fNewClusterArrayName("newCaloClusters"),
- fNPhi(4),
- fNEta(4),
- fShiftPhi(2),
- fShiftEta(2),
- fTRUShift(0),
- fInputCellType(kFEEData),
- fTrackName()
+AliAnalysisTaskEMCALClusterizeFast::AliAnalysisTaskEMCALClusterizeFast(const char *name) :
+ AliAnalysisTaskSE(name),
+ fRun(-1),
+ fDigitsArr(0),
+ fClusterArr(0),
+ fRecParam(new AliEMCALRecParam),
+ fClusterizer(0),
+ fUnfolder(0),
+ fJustUnfold(kFALSE),
+ fGeomName(),
+ fGeomMatrixSet(kFALSE),
+ fLoadGeomMatrices(kFALSE),
+ fOCDBpath(),
+ fCalibData(0),
+ fPedestalData(0),
+ fOutputAODBranch(0),
+ fOutputAODBrName(),
+ fRecoUtils(0),
+ fLoadCalib(kFALSE),
+ fLoadPed(kFALSE),
+ fAttachClusters(kTRUE),
+ fSubBackground(kFALSE),
+ fNPhi(4),
+ fNEta(4),
+ fShiftPhi(2),
+ fShiftEta(2),
+ fTRUShift(0),
+ fInputCellType(kFEEData),
+ fTrackName(),
+ fCaloCellsName(),
+ fCaloClustersName("newCaloClusters"),
+ fDoUpdateCells(kTRUE),
+ fDoClusterize(kTRUE),
+ fClusterBadChannelCheck(kTRUE),
+ fRejectExoticClusters(kFALSE),
+ fFiducial(kFALSE),
+ fDoNonLinearity(kFALSE),
+ fRecalDistToBadChannels(kTRUE),
+ fCaloCells(0),
+ fCaloClusters(0),
+ fEsd(0),
+ fAod(0),
+ fGeom(0)
{
// Constructor
delete fClusterizer;
delete fUnfolder;
delete fRecoUtils;
+ delete fRecParam;
}
-//-------------------------------------------------------------------
+//________________________________________________________________________
void AliAnalysisTaskEMCALClusterizeFast::UserCreateOutputObjects()
{
// Create output objects.
if (fOutputAODBranch)
fOutputAODBranch->Clear("C");
- AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
- AliAODEvent *aodevent = dynamic_cast<AliAODEvent*>(InputEvent());
+ fEsd = dynamic_cast<AliESDEvent*>(InputEvent());
+ fAod = dynamic_cast<AliAODEvent*>(InputEvent());
- if (!esdevent&&!aodevent) {
+ if (!fEsd&&!fAod) {
Error("UserExec","Event not available");
return;
}
LoadBranches();
UInt_t offtrigger = 0;
- if (esdevent) {
- UInt_t mask1 = esdevent->GetESDRun()->GetDetectorsInDAQ();
- UInt_t mask2 = esdevent->GetESDRun()->GetDetectorsInReco();
+ if (fEsd) {
+ UInt_t mask1 = fEsd->GetESDRun()->GetDetectorsInDAQ();
+ UInt_t mask2 = fEsd->GetESDRun()->GetDetectorsInReco();
Bool_t desc1 = (mask1 >> 18) & 0x1;
Bool_t desc2 = (mask2 >> 18) & 0x1;
if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(180=="EMCAL"
AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
- mask1, esdevent->GetESDRun()->GetDetectorsInReco(),
- mask2, esdevent->GetESDRun()->GetDetectorsInDAQ()));
+ mask1, fEsd->GetESDRun()->GetDetectorsInReco(),
+ mask2, fEsd->GetESDRun()->GetDetectorsInDAQ()));
return;
}
AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
- } else if (aodevent) {
- offtrigger = aodevent->GetHeader()->GetOfflineTrigger();
+ } else {
+ offtrigger = fAod->GetHeader()->GetOfflineTrigger();
}
- if (esdevent) {
- AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
- Bool_t mcmode = 0;
- if (am->GetMCtruthEventHandler())
- mcmode = 1;
- if (!mcmode) {
- if (offtrigger & AliVEvent::kFastOnly) {
- AliWarning(Form("EMCAL not in fast only partition"));
- return;
- }
+ if (!MCEvent()) {
+ if (offtrigger & AliVEvent::kFastOnly) {
+ AliError(Form("EMCAL not in fast only partition"));
+ return;
}
}
FillDigitsArray();
- if (fRecalibOnly) {
+ if (fDoClusterize)
+ Clusterize();
+
+ if (fDoUpdateCells)
UpdateCells();
- return; // not requested to run clusterizer
- }
- Clusterize();
- UpdateCells();
+ if (!fDoClusterize || (!fAttachClusters && !fOutputAODBranch))
+ return;
+
UpdateClusters();
+ CalibrateClusters();
- if (fOutputAODBranch)
- RecPoints2Clusters(fOutputAODBranch);
+ if (fCaloClusters && fOutputAODBranch && fCaloClusters != fOutputAODBranch)
+ CopyClusters(fCaloClusters, fOutputAODBranch);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEMCALClusterizeFast::CopyClusters(TClonesArray *orig, TClonesArray *dest)
+{
+ const Int_t Ncls = orig->GetEntries();
+
+ for(Int_t i=0; i < Ncls; ++i) {
+ AliVCluster *oc = static_cast<AliVCluster*>(orig->At(i));
+
+ if (!oc)
+ continue;
+
+ if (!oc->IsEMCAL())
+ continue;
+
+ AliVCluster *dc = static_cast<AliVCluster*>(dest->New(i));
+ dc->SetType(AliVCluster::kEMCALClusterv1);
+ dc->SetE(oc->E());
+ Float_t pos[3] = {0};
+ oc->GetPosition(pos);
+ dc->SetPosition(pos);
+ dc->SetNCells(oc->GetNCells());
+ dc->SetCellsAbsId(oc->GetCellsAbsId());
+ dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
+ dc->SetID(oc->GetID());
+ dc->SetDispersion(oc->GetDispersion());
+ dc->SetEmcCpvDistance(-1);
+ dc->SetChi2(-1);
+ dc->SetTOF(oc->GetTOF()); //time-of-flight
+ dc->SetNExMax(oc->GetNExMax()); //number of local maxima
+ dc->SetM02(oc->GetM02());
+ dc->SetM20(oc->GetM20());
+ dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
+
+ //MC
+ UInt_t nlabels = oc->GetNLabels();
+ Int_t *labels = oc->GetLabels();
+
+ if (nlabels == 0 || !labels)
+ continue;
+
+ AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(dc);
+ if (esdClus) {
+ TArrayI parents(nlabels, labels);
+ esdClus->AddLabels(parents);
+ }
+ else {
+ AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(dc);
+ if (aodClus)
+ aodClus->SetLabel(labels, nlabels);
+ }
+ }
}
//________________________________________________________________________
{
// Fill digits array
- AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
-
fDigitsArr->Clear("C");
switch (fInputCellType) {
case kFEEData :
+ case kFEEDataMCOnly :
+ case kFEEDataExcludeMC :
{
- AliVCaloCells *cells = InputEvent()->GetEMCALCells();
Double_t avgE = 0; // for background subtraction
- const Int_t ncells = cells->GetNumberOfCells();
+ const Int_t ncells = fCaloCells->GetNumberOfCells();
for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) {
Double_t cellAmplitude=0, cellTime=0, cellEFrac = 0;
Short_t cellNumber=0;
Int_t cellMCLabel=-1;
- if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
- break;
- AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
- digit->SetId(cellNumber);
- digit->SetTime(cellTime);
- digit->SetTimeR(cellTime);
- digit->SetIndexInList(idigit);
- digit->SetType(AliEMCALDigit::kHG);
- if (fRecalibOnly||fSubBackground) {
+ if (fCaloCells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
+ break;
+
+ if ((fInputCellType == kFEEDataMCOnly && cellMCLabel <= 0) ||
+ (fInputCellType == kFEEDataExcludeMC && cellMCLabel > 0))
+ continue;
+
+ if (cellMCLabel > 0 && cellEFrac < 1e-6) cellEFrac = 1;
+
+ AliEMCALDigit *digit = new((*fDigitsArr)[idigit]) AliEMCALDigit(cellMCLabel, cellMCLabel, cellNumber,
+ (Float_t)cellAmplitude, (Float_t)cellTime,
+ AliEMCALDigit::kHG,idigit, 0, 0, cellEFrac*cellAmplitude);
+
+ if (!fDoClusterize||fSubBackground) {
Float_t energy = cellAmplitude;
Float_t time = cellTime;
fClusterizer->Calibrate(energy,time,cellNumber);
digit->SetAmplitude(energy);
- avgE += energy;
- } else {
- digit->SetAmplitude(cellAmplitude);
- }
+ avgE += energy;
+ }
idigit++;
}
fDigitsArr->Sort();
if (fSubBackground) {
- avgE /= geom->GetNumberOfSuperModules()*48*24;
+ avgE /= fGeom->GetNumberOfSuperModules()*48*24;
Int_t ndigis = fDigitsArr->GetEntries();
for (Int_t i = 0; i < ndigis; ++i) {
- AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
- Double_t energy = digit->GetAmplitude() - avgE;
- if (energy<=0.001) {
- digit->SetAmplitude(0);
- } else {
- digit->SetAmplitude(energy);
- }
+ AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(i));
+ Double_t energy = digit->GetAmplitude() - avgE;
+ if (energy<=0.001) {
+ digit->SetAmplitude(0);
+ } else {
+ digit->SetAmplitude(energy);
+ }
}
}
}
case kPattern :
{
// Fill digits from a pattern
- Int_t maxd = geom->GetNCells() / 4;
+ Int_t maxd = fGeom->GetNCells() / 4;
for (Int_t idigit = 0; idigit < maxd; idigit++){
if (idigit % 24 == 12) idigit += 12;
AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->New(idigit));
triggers->GetPosition(triggerCol, triggerRow);
Int_t find = -1;
- geom->GetAbsFastORIndexFromPositionInEMCAL(triggerCol, triggerRow, find);
+ fGeom->GetAbsFastORIndexFromPositionInEMCAL(triggerCol, triggerRow, find);
if (find < 0)
continue;
Int_t cidx[4] = {-1};
- Bool_t ret = geom->GetCellIndexFromFastORIndex(find, cidx);
+ Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
if (!ret)
continue;
}
//________________________________________________________________________________________
-void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
+void AliAnalysisTaskEMCALClusterizeFast::CalibrateClusters()
{
- // Cluster energy, global position, cells and their amplitude fractions are restored.
+ // PROCESS SINGLE CLUSTER RECALIBRATION -------------------------------------
+ // now go through clusters one by one and process separate correction
+ // as those were defined or not
+ Int_t nclusters = fCaloClusters->GetEntriesFast();
+ for (Int_t icluster=0; icluster < nclusters; ++icluster) {
+ AliVCluster *clust = static_cast<AliVCluster*>(fCaloClusters->At(icluster));
+ if (!clust)
+ continue;
+ if (!clust->IsEMCAL())
+ continue;
- AliVCaloCells *cells = InputEvent()->GetEMCALCells();
- AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
- AliVEvent *event = InputEvent();
- if (!event) {
- AliError("Cannot get the event");
- return;
- }
+ // REMOVE CLUSTERS WITH BAD CELLS -----------------------------
+ if (fClusterBadChannelCheck) {
+ // careful, the the ClusterContainsBadChannel is dependent on
+ // SwitchOnBadChannelsRemoval, switching it ON automatically
+ // and returning to original value after processing
+ Bool_t badRemoval = fRecoUtils->IsBadChannelsRemovalSwitchedOn();
+ fRecoUtils->SwitchOnBadChannelsRemoval();
+
+ Bool_t badResult = fRecoUtils->ClusterContainsBadChannel(fGeom, clust->GetCellsAbsId(), clust->GetNCells());
+
+ // switch the bad channels removal back
+ if (!badRemoval)
+ fRecoUtils->SwitchOffBadChannelsRemoval();
+
+ if (badResult) {
+ delete fCaloClusters->RemoveAt(icluster);
+ continue; //TODO is it really needed to remove it? Or should we flag it?
+ }
+ }
+
+ // REMOVE EXOTIC CLUSTERS -------------------------------------
+ // does process local cell recalibration energy and time without replacing
+ // the global cell values, in case of no cell recalib done yet
+ if (fRejectExoticClusters) {
+ // careful, the IsExoticCluster is dependent on
+ // SwitchOnRejectExoticCell, switching it ON automatically
+ // and returning to original value after processing
+ Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
+ fRecoUtils->SwitchOnRejectExoticCell();
+
+ // get bunch crossing
+ Int_t bunchCrossNo = InputEvent()->GetBunchCrossNumber();
+
+ Bool_t exResult = fRecoUtils->IsExoticCluster(clust, fCaloCells, bunchCrossNo);
+
+ // switch the exotic channels removal back
+ if (!exRemoval)
+ fRecoUtils->SwitchOffRejectExoticCell();
+
+ if (exResult) {
+ delete fCaloClusters->RemoveAt(icluster);
+ continue; //TODO is it really needed to remove it? Or should we flag it?
+ }
+ }
+
+ // FIDUCIAL CUT -----------------------------------------------
+ if (fFiducial) {
+ // depends on SetNumberOfCellsFromEMCALBorder
+ // SwitchOnNoFiducialBorderInEMCALEta0
+ if (!fRecoUtils->CheckCellFiducialRegion(fGeom, clust, fCaloCells)){
+ delete fCaloClusters->RemoveAt(icluster);
+ continue; //TODO it would be nice to store the distance
+ }
+ }
+
+ // NONLINEARITY -----------------------------------------------
+ if (fDoNonLinearity) {
+ Float_t correctedEnergy = fRecoUtils->CorrectClusterEnergyLinearity(clust);
+ clust->SetE(correctedEnergy);
+ }
+ // DISTANCE TO BAD CHANNELS -----------------------------------
+ if (fRecalDistToBadChannels)
+ fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fCaloCells, clust);
+ }
+
+ fCaloClusters->Compress();
+}
+
+//________________________________________________________________________________________
+void AliAnalysisTaskEMCALClusterizeFast::TrackClusterMatching(AliVCluster *c, TClonesArray *tarr)
+{
+ Float_t g[3]={0};
+ c->GetPosition(g);
+ TVector3 gpos(g);
+
+ Double_t dEtaMin = 1e9;
+ Double_t dPhiMin = 1e9;
+ Int_t imin = -1;
+ Double_t ceta = gpos.Eta();
+ Double_t cphi = gpos.Phi();
+ const Int_t ntrks = tarr->GetEntries();
+ for(Int_t t = 0; t<ntrks; ++t) {
+ AliVTrack *track = static_cast<AliVTrack*>(tarr->At(t));
+ if (!track)
+ continue;
+ const AliExternalTrackParam *outp = track->GetOuterParam();
+ if (!outp)
+ continue;
+ Double_t trkPos[3] = {0.,0.,0.};
+ if (!outp->GetXYZ(trkPos))
+ continue;
+ TVector3 vec(trkPos[0],trkPos[1],trkPos[2]);
+ Double_t veta = vec.Eta();
+ Double_t vphi = vec.Phi();
+ if(vphi<0)
+ vphi += 2*TMath::Pi();
+ if (TMath::Abs(veta)>0.75 || (vphi<70*TMath::DegToRad()) || (vphi>190*TMath::DegToRad()))
+ continue;
+ Double_t dR = vec.DeltaR(gpos);
+ if(dR > 25)
+ continue;
+ Float_t tmpEta=0, tmpPhi=0;
+ if (0) {
+ AliExternalTrackParam trkParTemp(*outp); // retrieve the starting point every time before the extrapolation
+ Bool_t ret = fRecoUtils->ExtrapolateTrackToCluster(&trkParTemp, c, fRecoUtils->GetMass(), fRecoUtils->GetStep(), tmpEta, tmpPhi);
+ if (!ret)
+ continue;
+ } else {
+ tmpEta = ceta - veta;
+ tmpPhi = cphi - vphi;
+ }
+ if (TMath::Abs(tmpEta)<TMath::Abs(dEtaMin) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMin)) {
+ dEtaMin = tmpEta;
+ dPhiMin = tmpPhi;
+ imin = t;
+ }
+ }
+ c->SetEmcCpvDistance(imin);
+ c->SetTrackDistance(dPhiMin, dEtaMin);
+}
+
+//________________________________________________________________________________________
+void AliAnalysisTaskEMCALClusterizeFast::RecPoints2Clusters(TClonesArray *clus)
+{
+ // Cluster energy, global position, cells and their amplitude fractions are restored.
+
// tracks array for track/cluster matching
TClonesArray *tarr = 0;
if (!fTrackName.IsNull()) {
- tarr = dynamic_cast<TClonesArray*>(event->FindListObject(fTrackName));
+ tarr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTrackName));
if (!tarr) {
AliError(Form("Cannot get tracks named %s", fTrackName.Data()));
}
}
-
+
const Int_t Ncls = fClusterArr->GetEntries();
AliDebug(1, Form("total no of clusters %d", Ncls));
for(Int_t i=0, nout=clus->GetEntries(); i < Ncls; ++i) {
recpoint->GetElipsAxis(elipAxis);
c->SetM02(elipAxis[0]*elipAxis[0]);
c->SetM20(elipAxis[1]*elipAxis[1]);
+ // Now it is done in CalibrateClusters()
+ /*
if (fPedestalData) {
c->SetDistanceToBadChannel(recpoint->GetDistanceToBadTower());
} else {
if (fRecoUtils && fRecoUtils->IsBadChannelsRemovalSwitchedOn()) {
- fRecoUtils->RecalculateClusterDistanceToBadChannel(geom, cells, c);
+ fRecoUtils->RecalculateClusterDistanceToBadChannel(fGeom, fCaloCells, c);
}
}
-
- if (tarr) {
- Double_t dEtaMin = 1e9;
- Double_t dPhiMin = 1e9;
- Int_t imin = -1;
- Double_t ceta = gpos.Eta();
- Double_t cphi = gpos.Phi();
- const Int_t ntrks = tarr->GetEntries();
- for(Int_t t = 0; t<ntrks; ++t) {
- AliVTrack *track = static_cast<AliVTrack*>(tarr->At(t));
- if (!track)
- continue;
- const AliExternalTrackParam *outp = track->GetOuterParam();
- if (!outp)
- continue;
- Double_t trkPos[3] = {0.,0.,0.};
- if (!outp->GetXYZ(trkPos))
- continue;
- TVector3 vec(trkPos[0],trkPos[1],trkPos[2]);
- Double_t veta = vec.Eta();
- Double_t vphi = vec.Phi();
- if(vphi<0)
- vphi += 2*TMath::Pi();
- if (TMath::Abs(veta)>0.75 || (vphi<70*TMath::DegToRad()) || (vphi>190*TMath::DegToRad()))
- continue;
- Double_t dR = vec.DeltaR(gpos);
- if(dR > 25)
- continue;
- Float_t tmpEta=0, tmpPhi=0;
- if (0) {
- AliExternalTrackParam trkParTemp(*outp); // retrieve the starting point every time before the extrapolation
- Bool_t ret = fRecoUtils->ExtrapolateTrackToCluster(&trkParTemp, c, fRecoUtils->GetMass(), fRecoUtils->GetStep(), tmpEta, tmpPhi);
- if (!ret)
- continue;
- } else {
- tmpEta = ceta - veta;
- tmpPhi = cphi - vphi;
- }
- if (TMath::Abs(tmpEta)<TMath::Abs(dEtaMin) && TMath::Abs(tmpPhi)<TMath::Abs(dPhiMin)) {
- dEtaMin = tmpEta;
- dPhiMin = tmpPhi;
- imin = t;
- }
+ */
+
+ //MC
+ AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(c);
+ if (esdClus) {
+ Int_t parentMult = 0;
+ Int_t *parentList = recpoint->GetParents(parentMult);
+ if (parentMult > 0) {
+ TArrayI parents(parentMult, parentList);
+ esdClus->AddLabels(parents);
+ }
+ }
+ else {
+ AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(c);
+ if (aodClus) {
+ Int_t parentMult = 0;
+ Int_t *parentList = recpoint->GetParents(parentMult);
+ aodClus->SetLabel(parentList, parentMult);
}
- c->SetEmcCpvDistance(imin);
- c->SetTrackDistance(dPhiMin, dEtaMin);
}
+
+ if (tarr)
+ TrackClusterMatching(c, tarr);
}
}
if (!fCalibData&&!fSubBackground)
return;
- AliVCaloCells *cells = InputEvent()->GetEMCALCells();
- const Int_t ncells = cells->GetNumberOfCells();
+ const Int_t ncells = fCaloCells->GetNumberOfCells();
const Int_t ndigis = fDigitsArr->GetEntries();
if (ncells!=ndigis) {
- cells->DeleteContainer();
- cells->CreateContainer(ndigis);
+ fCaloCells->DeleteContainer();
+ fCaloCells->CreateContainer(ndigis);
}
for (Int_t idigit = 0; idigit < ndigis; ++idigit) {
AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(idigit));
Double_t cellAmplitude = digit->GetCalibAmp();
Short_t cellNumber = digit->GetId();
Double_t cellTime = digit->GetTime();
- cells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
+ fCaloCells->SetCell(idigit, cellNumber, cellAmplitude, cellTime);
}
}
{
// Update cells in case re-calibration was done.
- if (!fAttachClusters)
- return;
-
- TClonesArray *clus = 0;
-
- if (fOverwrite) {
- clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("caloClusters"));
- if (!clus)
- clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClusters"));
- if (!clus)
- return;
-
- const Int_t nents = clus->GetEntries();
- for (Int_t i=0;i<nents;++i) {
- AliVCluster *c = static_cast<AliVCluster*>(clus->At(i));
- if (!c)
- continue;
- if (c->IsEMCAL())
- delete clus->RemoveAt(i);
- }
- } else {
- clus = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fNewClusterArrayName));
- if (!clus) {
- clus = new TClonesArray("AliESDCaloCluster");
- clus->SetName(fNewClusterArrayName);
- InputEvent()->AddObject(clus);
- } else {
- clus->Delete();
- }
+ const Int_t nents = fCaloClusters->GetEntries();
+ for (Int_t i=0;i<nents;++i) {
+ AliVCluster *c = static_cast<AliVCluster*>(fCaloClusters->At(i));
+ if (!c)
+ continue;
+ if (c->IsEMCAL())
+ delete fCaloClusters->RemoveAt(i);
}
+
+ fCaloClusters->Compress();
- RecPoints2Clusters(clus);
+ RecPoints2Clusters(fCaloClusters);
}
//________________________________________________________________________________________
{
// Select clusterization/unfolding algorithm and set all the needed parameters.
- AliVEvent * event = InputEvent();
- if (!event) {
- AliWarning("Event not available!!!");
- return;
- }
-
- if (event->GetRunNumber()==fRun)
+ if (InputEvent()->GetRunNumber()==fRun)
return;
- fRun = event->GetRunNumber();
+ fRun = InputEvent()->GetRunNumber();
if (fJustUnfold){
// init the unfolding afterburner
return;
}
- AliEMCALGeometry *geometry = 0;
if (fGeomName.Length()>0)
- geometry = AliEMCALGeometry::GetInstance(fGeomName);
+ fGeom = AliEMCALGeometry::GetInstance(fGeomName);
else
- geometry = AliEMCALGeometry::GetInstance();
- if (!geometry) {
+ fGeom = AliEMCALGeometry::GetInstance();
+ if (!fGeom) {
AliFatal("Geometry not available!!!");
return;
}
if (!fGeomMatrixSet) {
if (fLoadGeomMatrices) {
- for(Int_t mod=0; mod < geometry->GetNumberOfSuperModules(); ++mod) {
+ for(Int_t mod=0; mod < fGeom->GetNumberOfSuperModules(); ++mod) {
if (fGeomMatrix[mod]){
if (DebugLevel() > 2)
fGeomMatrix[mod]->Print();
- geometry->SetMisalMatrix(fGeomMatrix[mod],mod);
+ fGeom->SetMisalMatrix(fGeomMatrix[mod],mod);
}
}
} else { // get matrix from file (work around bug in aliroot)
- for(Int_t mod=0; mod < geometry->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
+ for(Int_t mod=0; mod < fGeom->GetEMCGeometry()->GetNumberOfSuperModules(); ++mod) {
const TGeoHMatrix *gm = 0;
- AliESDEvent *esdevent = dynamic_cast<AliESDEvent*>(event);
- if (esdevent) {
- gm = esdevent->GetEMCALMatrix(mod);
+ if (fEsd) {
+ gm = fEsd->GetEMCALMatrix(mod);
} else {
- AliAODHeader *aodheader = dynamic_cast<AliAODHeader*>(event->GetHeader());
+ AliAODHeader *aodheader = fAod->GetHeader();
if (aodheader) {
gm = aodheader->GetEMCALMatrix(mod);
}
if (gm) {
if (DebugLevel() > 2)
gm->Print();
- geometry->SetMisalMatrix(gm,mod);
+ fGeom->SetMisalMatrix(gm,mod);
}
}
}
// then setup clusterizer
delete fClusterizer;
- if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
- fClusterizer = new AliEMCALClusterizerv1(geometry);
+ if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
+ fClusterizer = new AliEMCALClusterizerv1(fGeom);
else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) {
- AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(geometry);
+ AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fGeom);
clusterizer->SetNRowDiff(fRecParam->GetNRowDiff());
clusterizer->SetNColDiff(fRecParam->GetNColDiff());
fClusterizer = clusterizer;
- } else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
- fClusterizer = new AliEMCALClusterizerv2(geometry);
- else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW){
- AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(geometry);
+ }
+ else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
+ fClusterizer = new AliEMCALClusterizerv2(fGeom);
+ else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerFW) {
+ AliEMCALClusterizerFixedWindow *clusterizer = new AliEMCALClusterizerFixedWindow(fGeom);
clusterizer->SetNphi(fNPhi);
clusterizer->SetNeta(fNEta);
clusterizer->SetShiftPhi(fShiftPhi);
clusterizer->SetTRUshift(fTRUShift);
fClusterizer = clusterizer;
}
- else{
+ else {
AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag()));
}
fClusterizer->InitParameters(fRecParam);
fClusterizer->SetDigitsArr(fDigitsArr);
fClusterizer->SetOutput(0);
fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints());
+
+ // Get the emcal cells
+ if (fInputCellType == kFEEData && !fCaloCells) {
+ if (fCaloCellsName.IsNull()) {
+ fCaloCells = InputEvent()->GetEMCALCells();
+ }
+ else {
+ fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCaloCellsName));
+ if (!fCaloCells)
+ AliError(Form("%s: Could not retrieve cells %s!", GetName(), fCaloCellsName.Data()));
+ }
+ if (!fCaloCells)
+ AliFatal("Could not get EMCal cells!");
+ }
+
+ // Set output clusters collection
+ if (!fAttachClusters) {
+ fCaloClusters = fOutputAODBranch;
+ return;
+ }
+
+ if (!fCaloClusters) {
+ if (fCaloClustersName.IsNull()) { //overwrite mode
+ if (fEsd)
+ fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject("CaloClusters"));
+ else if (fAod)
+ fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject("caloClusters"));
+ }
+ else {
+ fCaloClusters = static_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloClustersName));
+
+ if (!fCaloClusters) {
+ if (fEsd)
+ fCaloClusters = new TClonesArray("AliESDCaloCluster");
+ else if (fAod)
+ fCaloClusters = new TClonesArray("AliAODCaloCluster");
+
+ fCaloClusters->SetName(fCaloClustersName);
+ InputEvent()->AddObject(fCaloClusters);
+ }
+ }
+
+ if (!fCaloClusters)
+ AliFatal("Could not get cluster collection!");
+
+ TClass *cl = fCaloClusters->GetClass();
+ if (!cl->GetBaseClass("AliVCluster")) {
+ AliFatal(Form("%s: Collection %s does not contain AliVCluster objects!", GetName(), fCaloClusters->GetName()));
+ fCaloClusters = 0;
+ return;
+ }
+ }
}
class AliEMCALAfterBurnerUF;
class AliEMCALRecParam;
class AliEMCALRecoUtils;
+class AliVCaloCells;
+class AliEMCALGeometry;
#include "AliAnalysisTaskSE.h"
public:
enum InputCellType {
kFEEData = 0,
+ kFEEDataMCOnly,
+ kFEEDataExcludeMC,
kPattern,
kL0FastORs,
kL0FastORsTC,
virtual void UserExec(Option_t *option);
Bool_t GetAttachClusters() const { return fAttachClusters ; }
- Bool_t GetRecalibrateOnly() const { return fRecalibOnly ; }
Bool_t GetSubBackground() const { return fSubBackground ; }
const TObjArray *GetClusters() const { return fClusterArr ; }
const TClonesArray *GetDigits() const { return fDigitsArr ; }
AliEMCALCalibData *GetCalibData() const { return fCalibData ; }
AliCaloCalibPedestal *GetPedData() const { return fPedestalData ; }
TGeoHMatrix *GetGeometryMatrix(Int_t i) const { return fGeomMatrix[i] ; }
- Bool_t GetOverwrite() const { return fOverwrite ; }
- const TString &GetNewClusterArrayName() const { return fNewClusterArrayName ; }
+ const TString &GetCaloClustersName() const { return fCaloClustersName ; }
Int_t GetnPhi() const { return fNPhi ; }
Int_t GetnEta() const { return fNEta ; }
Int_t GetShiftPhi() const { return fShiftPhi ; }
void SetLoadPed(Bool_t b) { fLoadPed = b ; }
void SetOCDBPath(const char *path) { fOCDBpath = path ; }
void SetPedestalData(AliCaloCalibPedestal *d) { fPedestalData = d ; }
- void SetRecalibrateCellsOnly(Bool_t b) { fRecalibOnly = b ; }
void SetSubBackground(Bool_t b) { fSubBackground = b ; }
- void SetOverwrite(Bool_t yes) { fOverwrite = yes ; }
- void SetNewClusterArrayName(const char *name) { fNewClusterArrayName = name ; }
void SetnPhi(Int_t n) { fNPhi = n ; }
void SetnEta(Int_t n) { fNEta = n ; }
void SetShiftPhi(Int_t n) { fShiftPhi = n ; }
void SetTRUShift(Bool_t yes) { fTRUShift = yes ; }
void SetInputCellType(InputCellType ic) { fInputCellType = ic ; }
void SetTrackName(const char *n) { fTrackName = n ; }
+ void SetCaloClustersName(const char *name) { fCaloClustersName = name ; }
+ void SetCaloCellsName(const char *name) { fCaloCellsName = name ; }
+ void SetUpdateCells(Bool_t b) { fDoUpdateCells = b ; }
+ void SetClusterize(Bool_t b) { fDoClusterize = b ; }
+ void SetClusterBadChannelCheck(Bool_t b) { fClusterBadChannelCheck = b ; }
+ void SetRejectExoticClusters(Bool_t b) { fRejectExoticClusters = b ; }
+ void SetFiducial(Bool_t b) { fFiducial = b ; }
+ void SetDoNonLinearity(Bool_t b) { fDoNonLinearity = b ; }
+ void SetRecalDistToBadChannels(Bool_t b) { fRecalDistToBadChannels = b ; }
+ // For backward compatibility
+ const TString &GetNewClusterArrayName() const { return GetCaloClustersName() ; }
+ void SetNewClusterArrayName(const char *name) { SetCaloClustersName(name) ; }
+ void SetOverwrite(Bool_t b) { if (b) SetCaloClustersName(""); else SetCaloClustersName("newCaloClusters");}
+ void SetRecalibrateCellsOnly(Bool_t b) { if (b) { SetUpdateCells(kTRUE); SetClusterize(kFALSE);} else { SetClusterize(kTRUE); } }
+ Bool_t GetRecalibrateOnly() const { return (Bool_t)(fDoUpdateCells && !fDoClusterize); }
+ Bool_t GetOverwrite() const { return fCaloClustersName.IsNull() ; }
+
protected:
virtual void Clusterize();
virtual void FillDigitsArray();
virtual void RecPoints2Clusters(TClonesArray *clus);
virtual void UpdateCells();
virtual void UpdateClusters();
+ virtual void CalibrateClusters();
+ virtual void TrackClusterMatching(AliVCluster *c, TClonesArray *tarr);
+ virtual void CopyClusters(TClonesArray *orig, TClonesArray *dest);
Int_t fRun; //!run number
TClonesArray *fDigitsArr; //!digits array
Bool_t fLoadCalib; // access calib object from OCDB (def=off)
Bool_t fLoadPed; // access ped object from OCDB (def=off)
Bool_t fAttachClusters; // attach clusters to input event (AOD or ESD)
- Bool_t fRecalibOnly; // only recalibrate cells if true (def=off)
Bool_t fSubBackground; // subtract background if true (def=off)
- Bool_t fOverwrite; // overwrite existing clusters
- TString fNewClusterArrayName; // if not overwriting, name of the new cluster array
Int_t fNPhi; // nPhi (for FixedWindowsClusterizer)
Int_t fNEta; // nEta (for FixedWinoswsClusterizer)
Int_t fShiftPhi; // shift in phi (for FixedWindowsClusterizer)
Bool_t fTRUShift; // shifting inside a TRU (true) or through the whole calorimeter (false) (for FixedWindowsClusterizer)
InputCellType fInputCellType; // input cells type to make clusters
TString fTrackName; // if not null use track collection for track/cluster matching
-
+ TString fCaloCellsName; // name of calo cells object
+ TString fCaloClustersName; // name of calo cluster collection
+ Bool_t fDoUpdateCells; // recalibrate cells
+ Bool_t fDoClusterize; // clusterize
+ Bool_t fClusterBadChannelCheck; // cluster bad channel check
+ Bool_t fRejectExoticClusters; // reject exotic cluster
+ Bool_t fFiducial; // fiducial cut
+ Bool_t fDoNonLinearity; // non linearity calib
+ Bool_t fRecalDistToBadChannels; // recalculate distance to bad channel
+ AliVCaloCells *fCaloCells; //!calo cells object
+ TClonesArray *fCaloClusters; //!calo clusters array
+ AliESDEvent *fEsd; //!esd event
+ AliAODEvent *fAod; //!aod event
+ AliEMCALGeometry *fGeom; //!geometry object
private:
AliAnalysisTaskEMCALClusterizeFast(const AliAnalysisTaskEMCALClusterizeFast&); // not implemented
AliAnalysisTaskEMCALClusterizeFast &operator=(const AliAnalysisTaskEMCALClusterizeFast&); // not implemented
- ClassDef(AliAnalysisTaskEMCALClusterizeFast, 8);
+ ClassDef(AliAnalysisTaskEMCALClusterizeFast, 9);
};
#endif //ALIANALYSISTASKEMCALCLUSTERIZEFAST_H