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"
43 #include "AliEMCALAfterBurnerUF.h"
44 #include "AliEMCALGeometry.h"
45 #include "AliEMCALClusterizerNxN.h"
46 #include "AliEMCALClusterizerv1.h"
47 #include "AliEMCALClusterizerv2.h"
48 #include "AliEMCALRecPoint.h"
49 #include "AliEMCALDigit.h"
61 : AliAnalysisTaskSE(name)
63 , fGeom(0), fGeomName(
"")
64 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
65 , fOCDBpath(
""), fAccessOCDB(kFALSE)
66 , fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
67 , fRecParam(0), fClusterizer(0)
68 , fUnfolder(0), fJustUnfold(kFALSE)
69 , fOutputAODBranch(0), fOutputAODBranchName(
""), fOutputAODBranchSet(0)
70 , fFillAODFile(kFALSE), fFillAODHeader(0)
71 , fFillAODCaloCells(0), fRun(-1)
72 , fRecoUtils(0), fConfigName(
"")
74 , fCellLabels(), fCellSecondLabels(), fCellTime()
75 , fCellMatchdEta(), fCellMatchdPhi()
76 , fRecalibrateWithClusterTime(0)
77 , fMaxEvent(0), fDoTrackMatching(kFALSE)
78 , fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
79 , fRejectBelowThreshold(kFALSE)
80 , fRemoveLEDEvents(kTRUE),fRemoveExoticEvents(kFALSE)
81 , fImportGeometryFromFile(kTRUE), fImportGeometryFilePath(
"")
82 , fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath(
"")
83 , fCentralityClass(
""), fSelectEMCALEvent(0)
84 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
85 , fSetCellMCLabelFromCluster(0)
86 , fRemapMCLabelForAODs(0)
100 : AliAnalysisTaskSE(
"DefaultAnalysis_AliAnalysisTaskEMCALClusterize")
102 , fGeom(0), fGeomName(
"")
103 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
104 , fOCDBpath(
""), fAccessOCDB(kFALSE)
105 , fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
106 , fRecParam(0), fClusterizer(0)
107 , fUnfolder(0), fJustUnfold(kFALSE)
108 , fOutputAODBranch(0), fOutputAODBranchName(
""), fOutputAODBranchSet(0)
109 , fFillAODFile(kFALSE), fFillAODHeader(0)
110 , fFillAODCaloCells(0), fRun(-1)
111 , fRecoUtils(0), fConfigName(
"")
112 , fOrgClusterCellId()
113 , fCellLabels(), fCellSecondLabels(), fCellTime()
114 , fCellMatchdEta(), fCellMatchdPhi()
115 , fRecalibrateWithClusterTime(0)
116 , fMaxEvent(0), fDoTrackMatching(kFALSE)
117 , fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
118 , fRejectBelowThreshold(kFALSE)
119 , fRemoveLEDEvents(kTRUE), fRemoveExoticEvents(kFALSE)
120 , fImportGeometryFromFile(kTRUE), fImportGeometryFilePath(
"")
121 , fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath(
"")
122 , fCentralityClass(
""), fSelectEMCALEvent(0)
123 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
124 , fSetCellMCLabelFromCluster(0)
125 , fRemapMCLabelForAODs(0)
126 , fInputFromFilter(0)
174 Int_t nCluster =
fEvent -> GetNumberOfCaloClusters();
175 AliVCaloCells * caloCell =
fEvent -> GetEMCALCells();
176 Int_t bc =
fEvent -> GetBunchCrossNumber();
178 for(Int_t icalo = 0; icalo < nCluster; icalo++)
180 AliVCluster *clus = (AliVCluster*) (
fEvent->GetCaloCluster(icalo));
186 AliDebug(1, Form(
"Accept : E %2.2f > %2.2f, nCells %d > %d",
194 AliDebug(1,
"Reject");
208 Int_t runnumber = InputEvent()->GetRunNumber() ;
211 AliInfo(Form(
"Get AODB parameters from EMCAL in %s for run %d, and <%s>",
fOADBFilePath.Data(),runnumber,pass.Data()));
213 Int_t nSM =
fGeom->GetNumberOfSuperModules();
216 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn())
218 AliOADBContainer *contBC=
new AliOADBContainer(
"");
219 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePath.Data()),
"AliEMCALBadChannels");
221 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber);
225 fRecoUtils->SwitchOnDistToBadChannelRecalculation();
226 AliInfo(
"Remove EMCAL bad cells");
228 for (Int_t i=0; i < nSM; ++i)
230 TH2I *hbm =
fRecoUtils->GetEMCALChannelStatusMap(i);
235 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
239 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
243 hbm->SetDirectory(0);
247 }
else AliInfo(
"Do NOT remove EMCAL bad channels");
255 AliOADBContainer *contRF=
new AliOADBContainer(
"");
257 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePath.Data()),
"AliEMCALRecalib");
259 TObjArray *recal=(TObjArray*)contRF->GetObject(runnumber);
263 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
267 TObjArray *recalib=(TObjArray*)recalpass->FindObject(
"Recalib");
271 AliInfo(
"Recalibrate EMCAL");
272 for (Int_t i=0; i<nSM; ++i)
274 TH2F *h =
fRecoUtils->GetEMCALChannelRecalibrationFactors(i);
279 h = (TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
283 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
289 fRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
291 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
292 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
293 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
301 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
303 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePath.Data()),
"AliEMCALRunDepTempCalibCorrections");
305 TH1S *htd=(TH1S*)contRFTD->GetObject(runnumber);
310 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",runnumber));
314 Int_t maxEntry = contRFTD->GetNumberOfEntries();
316 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) < runnumber) ) {
321 Int_t closest = lower;
322 if ( (ic<maxEntry) &&
323 (contRFTD->LowerLimit(ic)-runnumber) < (runnumber - contRFTD->UpperLimit(lower)) ) {
327 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
328 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
333 AliInfo(
"Recalibrate (Temperature) EMCAL");
335 for (Int_t ism=0; ism<nSM; ++ism)
337 for (Int_t icol=0; icol<48; ++icol)
339 for (Int_t irow=0; irow<24; ++irow)
341 Float_t factor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
343 Int_t absID =
fGeom->GetAbsCellIdFromCellIndexes(ism, irow, icol);
344 factor *= htd->GetBinContent(absID) / 10000. ;
347 fRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
351 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
359 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
361 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePath.Data()),
"AliEMCALTimeCalib");
363 TObjArray *trecal=(TObjArray*)contTRF->GetObject(runnumber);
367 TString passM = pass;
368 if(pass==
"spc_calo") passM =
"pass1";
369 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
373 AliInfo(
"Time Recalibrate EMCAL");
374 for (Int_t ibc = 0; ibc < 4; ++ibc)
376 TH1F *h =
fRecoUtils->GetEMCALChannelTimeRecalibrationFactors(ibc);
381 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
385 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
391 fRecoUtils->SetEMCALChannelTimeRecalibrationFactors(ibc,h);
393 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
394 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
412 Warning(
"AccessOCDB",
"Event not available!!!");
422 AliCDBManager *cdb = AliCDBManager::Instance();
427 cdb->SetDefaultStorage(
fOCDBpath.Data());
428 AliInfo(Form(
"Default storage %s",
fOCDBpath.Data()));
431 cdb->SetRun(
fEvent->GetRunNumber());
437 cdb->SetSpecificStorage(
"EMCAL/Calib/Data",
"raw://");
438 cdb->SetSpecificStorage(
"EMCAL/Calib/Time",
"raw://");
439 cdb->SetSpecificStorage(
"EMCAL/Calib/Pedestals",
"raw://");
442 TString path = cdb->GetDefaultStorage()->GetBaseFolder();
457 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
458 Int_t eventN = Entry();
459 if(aodIH) eventN = aodIH->GetReadEntry();
468 if (aodIH && aodIH->GetMergeEvents())
472 if(!aodIH->GetMergeEMCALCells())
473 AliFatal(
"Events merged but not EMCAL cells, check analysis settings!");
475 AliDebug(1,
"Use embedded events");
477 AliDebug(1,Form(
"\t InputEvent N Clusters %d, N Cells %d",
478 InputEvent()->GetNumberOfCaloClusters(),InputEvent()->GetEMCALCells()->GetNumberOfCells()));
480 AliDebug(1,Form(
"\t MergedEvent N Clusters %d, N Cells %d",
481 aodIH->GetEventToMerge()->GetNumberOfCaloClusters(), aodIH->GetEventToMerge()->GetEMCALCells()->GetNumberOfCells()));
492 AliDebug(1,Form(
"\t OutputEvent N Clusters %d, N Cells %d",
493 AODEvent()->GetNumberOfCaloClusters(), AODEvent()->GetEMCALCells()->GetNumberOfCells()));
509 AliError(
"Event not available");
532 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
551 Int_t nClusters =
fEvent->GetNumberOfCaloClusters();
552 Int_t nClustersOrg = 0;
554 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
555 if(aodIH && aodIH->GetEventToMerge())
556 nClusters = aodIH->GetEventToMerge()->GetNumberOfCaloClusters();
561 for (Int_t i = 0; i < nClusters; i++)
563 AliVCluster *clus = 0;
564 if(aodIH && aodIH->GetEventToMerge())
565 clus = aodIH->GetEventToMerge()->GetCaloCluster(i);
567 clus =
fEvent->GetCaloCluster(i);
573 Int_t label = clus->GetLabel();
579 if (clus->GetNLabels()>=2) label2 = clus->GetLabelAt(1) ;
580 UShort_t * index = clus->GetCellsAbsId() ;
581 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
587 fCellTime[index[icell]] = clus->GetTOF();
603 AliVCaloCells * cells =
fEvent->GetEMCALCells();
605 Int_t bc = InputEvent()->GetBunchCrossNumber();
607 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
610 id = cells->GetCellNumber(icell);
611 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(
id,bc,amp,time,cells);
614 if( amp < fRecParam->GetMinECut() ||
616 time <
fRecParam->GetTimeMin() ) accept = kFALSE;
628 if (accept &&
fRecoUtils->IsExoticCell(
id,cells,bc))
633 AliDebug(2,Form(
"Remove channel absId %d, index %d of %d, amp %f, time %f",
634 id,icell, cells->GetNumberOfCells(), amp, time*1.e9));
638 Int_t mcLabel = cells->GetMCLabel(icell);
651 Float_t efrac = cells->GetEFraction(icell);
654 if (mcLabel > 0 && efrac < 1.e-6) efrac = 1;
658 new((*fDigitsArr)[idigit]) AliEMCALDigit( mcLabel, mcLabel,
id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, amp*efrac);
681 AliWarning(Form(
"No array with CaloClusters, input RecPoints entries %d",
fClusterArr->GetEntriesFast()));
685 AliDebug(1,Form(
"N clusters: before recluster %d, after recluster %d, recpoints %d",
701 AliVCaloCells *cells =
fEvent->GetEMCALCells();
702 Double_t cellAmplitude = 0;
703 Double_t cellTime = 0;
704 Short_t cellNumber = 0;
705 Int_t cellMCLabel = 0;
706 Double_t cellEFrac = 0;
707 Int_t nClustersOrg = 0;
710 for (Int_t i = 0; i <
fEvent->GetNumberOfCaloClusters(); i++)
712 AliVCluster *clus =
fEvent->GetCaloCluster(i);
716 if(
fRecoUtils->ClusterContainsBadChannel(
fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
727 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
729 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
732 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
733 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
734 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
737 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
738 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
741 cells->SetCell(icell, cellNumber, cellAmplitude*
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
747 AliESDCaloCluster * esdCluster =
dynamic_cast<AliESDCaloCluster*
> (clus);
748 AliAODCaloCluster * aodCluster =
dynamic_cast<AliAODCaloCluster*
> (clus);
759 AliWarning(
"Wrong CaloCluster type?");
777 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
778 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
780 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
781 aodEMcells.CreateContainer(nEMcell);
782 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
783 Double_t calibFactor = 1.;
784 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
786 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
787 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
788 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
792 calibFactor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
795 if(!
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
797 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
798 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
802 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
814 AliESDEvent* esdevent =
dynamic_cast<AliESDEvent*
> (
fEvent);
815 AliAODEvent* aodevent =
dynamic_cast<AliAODEvent*
> (
fEvent);
819 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
821 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
822 if(!header) AliFatal(
"Not a standard AOD");
823 header->SetRunNumber(
fEvent->GetRunNumber());
827 TTree* tree = fInputHandler->GetTree();
830 TFile*
file = tree->GetCurrentFile();
831 if (file) header->SetESDFileName(file->GetName());
835 AliAODHeader * aodheader =
dynamic_cast<AliAODHeader*
>(aodevent->GetHeader());
836 if(!aodheader) AliFatal(
"Not a standard AOD");
837 header->SetESDFileName(aodheader->GetESDFileName());
840 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
841 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
842 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
843 header->SetEventType(
fEvent->GetEventType());
846 if(
fEvent->GetCentrality())
847 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
849 header->SetCentrality(0);
852 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
854 header->SetFiredTriggerClasses(
fEvent->GetFiredTriggerClasses());
856 header->SetTriggerMask(
fEvent->GetTriggerMask());
857 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
861 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
862 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
863 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
867 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
868 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
869 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
872 header->SetMagneticField(
fEvent->GetMagneticField());
875 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
876 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
877 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
878 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
879 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
881 Float_t diamxy[2]={(Float_t)
fEvent->GetDiamondX(),(Float_t)
fEvent->GetDiamondY()};
883 fEvent->GetDiamondCovXY(diamcov);
884 header->SetDiamond(diamxy,diamcov);
885 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
886 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
889 Int_t nVertices = 1 ;;
890 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
892 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
895 TClonesArray &vertices = *(AODEvent()->GetVertices());
900 fEvent->GetPrimaryVertex()->GetXYZ(pos);
904 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
905 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
909 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
910 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();
913 AliAODVertex * primary =
new(vertices[jVertices++])
914 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
915 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
916 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
936 for(Int_t i = 0; i < kNumberOfCaloClusters; i++)
938 AliAODCaloCluster *newCluster = (AliAODCaloCluster *)
fCaloClusterArr->At(i);
940 newCluster->SetID(i);
943 newCluster->SetE(
fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
948 Int_t trackIndex =
fRecoUtils->GetMatchedTrackIndex(i);
951 newCluster->AddTrackMatched(
fEvent->GetTrack(trackIndex));
952 AliDebug(2,Form(
"Matched Track index %d to new cluster %d",trackIndex,i));
955 Float_t dR = 999., dZ = 999.;
956 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dZ,dR);
957 newCluster->SetTrackDistance(dR,dZ);
961 Int_t absId0 = newCluster->GetCellsAbsId()[0];
972 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
974 AliDebug(2,Form(
"New cluster %d of %d, energy %f, mc label %d",
975 newCluster->GetID(), kNumberOfCaloClusters, newCluster->E(), newCluster->GetLabel()));
987 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
989 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null");
993 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
995 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null");
999 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1000 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1001 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1002 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1003 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1004 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1005 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1006 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1008 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1009 return TString(
"pass1");
1013 AliInfo(
"Pass number string not found");
1024 if(fDebug >=0) (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
1029 fBranchNames =
"ESD:AliESDHeader.,EMCALCells.";
1047 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
1084 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1086 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1088 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1096 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1121 for (i = 0; i < 8; i++)
1126 for (i = 0; i < 3; i++)
1146 Int_t runnumber = InputEvent()->GetRunNumber() ;
1151 fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(runnumber);
1152 AliInfo(Form(
"Get EMCAL geometry name <%s> for run %d",
fGeom->GetName(),runnumber));
1157 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fGeomName.Data()));
1177 AliDebug(1,Form(
"Init for run=%d",runnumber));
1178 if (!gGeoManager) AliDebug(1,
"Careful!, gGeoManager not loaded, load misalign matrices");
1183 AliInfo(
"Load user defined EMCAL geometry matrices");
1186 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
1187 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePath.Data()),
"AliEMCALgeo");
1188 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,
"EmcalMatrices");
1190 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1195 AliDebug(2,Form(
"EMCAL matrices SM %d, %p",mod,((TGeoHMatrix*) matEMCAL->At(mod))));
1198 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1203 if(DebugLevel() > 1)
1208 else if(gGeoManager)
1210 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
1211 fGeom->SetMisalMatrix(
fGeom->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
1215 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
1222 else if(!gGeoManager)
1224 AliInfo(
"AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1226 if(!strcmp(
fEvent->GetName(),
"AliAODEvent"))
1228 AliWarning(
"Use ideal geometry, values geometry matrix not kept in AODs");
1232 AliDebug(1,
"Load Misaligned matrices");
1234 AliESDEvent* esd =
dynamic_cast<AliESDEvent*
>(
fEvent) ;
1238 AliError(
"This event does not contain ESDs?");
1239 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
1243 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1245 if(DebugLevel() > 1)
1246 esd->GetEMCALMatrix(mod)->Print();
1248 if(esd->GetEMCALMatrix(mod))
fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1270 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1271 Float_t totCellE = 0;
1272 Int_t bc = InputEvent()->GetBunchCrossNumber();
1274 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1277 Double_t tcell = 0 ;
1279 Int_t absID = cells->GetCellNumber(icell);
1280 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1281 if(accept && !
fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
1291 if(totCellE < 1)
return kTRUE;
1304 if(run < 146858 || run > 146860)
return kFALSE ;
1307 Int_t ncellsSM3 = 0;
1308 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1309 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1311 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
1314 TString triggerclasses =
fEvent->GetFiredTriggerClasses();
1316 Int_t ncellcut = 21;
1317 if(triggerclasses.Contains(
"EMC")) ncellcut = 35;
1319 if( ncellsSM3 >= ncellcut)
1321 AliInfo(Form(
"Reject event %d with ncells in SM3 %d",(Int_t)Entry(),ncellsSM3));
1322 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
1337 for(Int_t i = 0; i <
fClusterArr->GetEntriesFast(); i++)
1339 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*)
fClusterArr->At(i);
1341 const Int_t ncells = recPoint->GetMultiplicity();
1342 Int_t ncellsTrue = 0;
1344 if(recPoint->GetEnergy() <
fRecParam->GetClusteringThreshold())
continue;
1347 UShort_t absIds[ncells];
1348 Double32_t ratios[ncells];
1351 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1353 Float_t clusterE = 0;
1354 for (Int_t c = 0; c < ncells; c++)
1356 AliEMCALDigit *digit = (AliEMCALDigit*)
fDigitsArr->At(recPoint->GetDigitsList()[c]);
1358 absIds[ncellsTrue] = digit->GetId();
1359 ratios[ncellsTrue] = recPoint->GetEnergiesList()[c]/digit->GetAmplitude();
1367 AliDebug(2,Form(
"Too small energy in cell of cluster: cluster cell %f, digit %f",
1368 recPoint->GetEnergiesList()[c],digit->GetAmplitude()));
1374 clusterE +=recPoint->GetEnergiesList()[c];
1377 if (aodIH && aodIH->GetMergeEvents())
1380 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1381 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1383 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1385 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1388 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1399 AliDebug(2,Form(
"Skipping cluster with no cells avobe threshold E = %f, ncells %d",
1400 recPoint->GetEnergy(), ncells));
1406 if(clusterE < fRecParam->GetClusteringThreshold())
1408 AliDebug(2,Form(
"Remove cluster with energy below seed threshold %f",clusterE));
1418 recPoint->GetGlobalPosition(gpos);
1423 (*fCaloClusterArr)[j] =
new AliAODCaloCluster() ;
1424 AliAODCaloCluster *clus =
dynamic_cast<AliAODCaloCluster *
>(
fCaloClusterArr->At(j) ) ;
1426 clus->SetType(AliVCluster::kEMCALClusterv1);
1427 clus->SetE(clusterE);
1428 clus->SetPosition(g);
1429 clus->SetNCells(ncellsTrue);
1430 clus->SetCellsAbsId(absIds);
1431 clus->SetCellsAmplitudeFraction(ratios);
1433 clus->SetTOF(recPoint->GetTime()) ;
1434 clus->SetNExMax(recPoint->GetNExMax());
1435 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
1437 if(ncells == ncellsTrue)
1439 Float_t elipAxis[2];
1440 recPoint->GetElipsAxis(elipAxis);
1441 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1442 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1443 clus->SetDispersion(recPoint->GetDispersion());
1449 AliDebug(2,Form(
"Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape",ncells,ncellsTrue));
1451 AliVCaloCells* cells = 0x0;
1452 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1453 else cells = InputEvent()->GetEMCALCells();
1455 fRecoUtils->RecalculateClusterShowerShapeParameters(
fGeom,cells,clus);
1468 Int_t parentMult = 0;
1469 Int_t *parentList = recPoint->GetParents(parentMult);
1470 clus->SetLabel(parentList, parentMult);
1485 if(label < 0) return ;
1487 AliAODEvent * evt =
dynamic_cast<AliAODEvent*
> (
fEvent) ;
1490 TClonesArray * arr =
dynamic_cast<TClonesArray*
>(evt->FindListObject(
"mcparticles")) ;
1493 if(label < arr->GetEntriesFast())
1495 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(label));
1496 if(!particle) return ;
1498 if(label == particle->Label())
return ;
1504 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1506 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(ind));
1507 if(!particle) continue ;
1509 if(label == particle->Label())
1544 AliAODCaloCluster * clus)
1546 Int_t parentMult = 0;
1547 Int_t *parentList = recPoint->GetParents(parentMult);
1548 clus->SetLabel(parentList, parentMult);
1552 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1555 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1559 for ( UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1562 if (
fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1566 Int_t * newLabelArray =
new Int_t[clus->GetNLabels()+1] ;
1567 for ( UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1569 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1573 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
1574 delete [] newLabelArray;
1587 TArrayI clArray(300) ;
1590 Int_t nLabTotOrg = 0;
1594 AliVEvent *
event =
fEvent;
1597 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1598 if(aodIH && aodIH->GetEventToMerge())
1599 event = aodIH->GetEventToMerge();
1603 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1605 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1612 for(Int_t icl =0; icl < nClu; icl++)
1614 if(((Int_t)clArray.GetAt(icl))==-1 )
continue;
1615 if( idCluster == ((Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1619 if( set && idCluster >= 0)
1621 clArray.SetAt(idCluster,nClu++);
1623 nLabTotOrg+=(
event->GetCaloCluster(idCluster))->GetNLabels();
1628 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1630 if(emax < clOrg->E())
1639 if(nClu==0 || nLabTotOrg == 0)
1647 if(idMax != ((Int_t)clArray.GetAt(0)))
1649 Int_t maxIndex = -1;
1650 Int_t firstCluster = ((Int_t)clArray.GetAt(0));
1651 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1653 if(idMax == ((Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1656 if(firstCluster >=0 && idMax >=0)
1658 clArray.SetAt(idMax,0);
1659 clArray.SetAt(firstCluster,maxIndex);
1664 TArrayI clMCArray(nLabTotOrg) ;
1668 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1670 Int_t idCluster = (Int_t) clArray.GetAt(iLoopCluster);
1672 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1673 Int_t nLab = clOrg->GetNLabels();
1675 for ( Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1677 Int_t lab = clOrg->GetLabelAt(iLab) ;
1682 for(Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1684 if( lab == ((Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1688 if( set ) clMCArray.SetAt(lab,nLabTot++);
1695 clus->SetLabel(clMCArray.GetArray(), nLabTot);
1719 AliInfo(
"Cluster branch name not set, set it to newEMCALClustersArray");
1775 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 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()
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.
AliCentrality * GetCentrality()
Bool_t fRejectBelowThreshold
split (false-default) or reject (true) cell energy below threshold after UF
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.
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.
TString fCentralityClass
Name of selected centrality class.
Float_t GetEventCentrality()
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.
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.