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"
50 #include "AliCaloCalibPedestal.h"
51 #include "AliEMCALCalibData.h"
63 : AliAnalysisTaskSE(name)
65 , fGeom(0), fGeomName(
"")
66 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
67 , fCalibData(0), fPedestalData(0)
68 , fOCDBpath(
""), fAccessOCDB(kFALSE)
69 , fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
70 , fRecParam(0), fClusterizer(0)
71 , fUnfolder(0), fJustUnfold(kFALSE)
72 , fOutputAODBranch(0), fOutputAODBranchName(
""), fOutputAODBranchSet(0)
73 , fFillAODFile(kFALSE), fFillAODHeader(0)
74 , fFillAODCaloCells(0), fRun(-1)
75 , fRecoUtils(0), fConfigName(
"")
77 , fCellLabels(), fCellSecondLabels(), fCellTime()
78 , fCellMatchdEta(), fCellMatchdPhi()
79 , fRecalibrateWithClusterTime(0)
80 , fMaxEvent(0), fDoTrackMatching(kFALSE)
81 , fSelectCell(kFALSE), fSelectCellMinE(0), fSelectCellMinFrac(0)
82 , fRejectBelowThreshold(kFALSE)
83 , fRemoveLEDEvents(kTRUE),fRemoveExoticEvents(kFALSE)
84 , fImportGeometryFromFile(kTRUE), fImportGeometryFilePath(
"")
85 , fOADBSet(kFALSE), fAccessOADB(kTRUE), fOADBFilePath(
"")
86 , fCentralityClass(
""), fSelectEMCALEvent(0)
87 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
88 , fSetCellMCLabelFromCluster(0)
89 , fRemapMCLabelForAODs(0)
103 : AliAnalysisTaskSE(
"DefaultAnalysis_AliAnalysisTaskEMCALClusterize")
105 , fGeom(0), fGeomName(
"")
106 , fGeomMatrixSet(kFALSE), fLoadGeomMatrices(kFALSE)
107 , fCalibData(0), fPedestalData(0)
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 , fCentralityClass(
""), fSelectEMCALEvent(0)
127 , fEMCALEnergyCut(0.), fEMCALNcellsCut (0)
128 , fSetCellMCLabelFromCluster(0)
129 , fRemapMCLabelForAODs(0)
130 , fInputFromFilter(0)
178 Int_t nCluster =
fEvent -> GetNumberOfCaloClusters();
179 AliVCaloCells * caloCell =
fEvent -> GetEMCALCells();
180 Int_t bc =
fEvent -> GetBunchCrossNumber();
182 for(Int_t icalo = 0; icalo < nCluster; icalo++)
184 AliVCluster *clus = (AliVCluster*) (
fEvent->GetCaloCluster(icalo));
190 AliDebug(1, Form(
"Accept : E %2.2f > %2.2f, nCells %d > %d",
198 AliDebug(1,
"Reject");
212 Int_t runnumber = InputEvent()->GetRunNumber() ;
215 AliInfo(Form(
"Get AODB parameters from EMCAL in %s for run %d, and <%s>",
fOADBFilePath.Data(),runnumber,pass.Data()));
217 Int_t nSM =
fGeom->GetNumberOfSuperModules();
220 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn())
222 AliOADBContainer *contBC=
new AliOADBContainer(
"");
223 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePath.Data()),
"AliEMCALBadChannels");
225 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber);
229 fRecoUtils->SwitchOnDistToBadChannelRecalculation();
230 AliInfo(
"Remove EMCAL bad cells");
232 for (Int_t i=0; i < nSM; ++i)
234 TH2I *hbm =
fRecoUtils->GetEMCALChannelStatusMap(i);
239 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
243 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
247 hbm->SetDirectory(0);
251 }
else AliInfo(
"Do NOT remove EMCAL bad channels");
257 AliOADBContainer *contRF=
new AliOADBContainer(
"");
259 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePath.Data()),
"AliEMCALRecalib");
261 TObjArray *recal=(TObjArray*)contRF->GetObject(runnumber);
265 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
269 TObjArray *recalib=(TObjArray*)recalpass->FindObject(
"Recalib");
273 AliInfo(
"Recalibrate EMCAL");
274 for (Int_t i=0; i<nSM; ++i)
276 TH2F *h =
fRecoUtils->GetEMCALChannelRecalibrationFactors(i);
281 h = (TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
285 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
291 fRecoUtils->SetEMCALChannelRecalibrationFactors(i,h);
293 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
294 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
295 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
302 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
304 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePath.Data()),
"AliEMCALRunDepTempCalibCorrections");
306 TH1S *htd=(TH1S*)contRFTD->GetObject(runnumber);
311 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",runnumber));
315 Int_t maxEntry = contRFTD->GetNumberOfEntries();
317 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) < runnumber) ) {
322 Int_t closest = lower;
323 if ( (ic<maxEntry) &&
324 (contRFTD->LowerLimit(ic)-runnumber) < (runnumber - contRFTD->UpperLimit(lower)) ) {
328 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
329 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
334 AliInfo(
"Recalibrate (Temperature) EMCAL");
336 for (Int_t ism=0; ism<nSM; ++ism)
338 for (Int_t icol=0; icol<48; ++icol)
340 for (Int_t irow=0; irow<24; ++irow)
342 Float_t factor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow);
344 Int_t absID =
fGeom->GetAbsCellIdFromCellIndexes(ism, irow, icol);
345 factor *= htd->GetBinContent(absID) / 10000. ;
348 fRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor);
352 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
358 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
360 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePath.Data()),
"AliEMCALTimeCalib");
362 TObjArray *trecal=(TObjArray*)contTRF->GetObject(runnumber);
366 TString passM = pass;
367 if(pass==
"spc_calo") passM =
"pass1";
368 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
372 AliInfo(
"Time Recalibrate EMCAL");
373 for (Int_t ibc = 0; ibc < 4; ++ibc)
375 TH1F *h =
fRecoUtils->GetEMCALChannelTimeRecalibrationFactors(ibc);
380 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
384 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
390 fRecoUtils->SetEMCALChannelTimeRecalibrationFactors(ibc,h);
392 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
393 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
409 Warning(
"AccessOCDB",
"Event not available!!!");
419 AliCDBManager *cdb = AliCDBManager::Instance();
424 cdb->SetDefaultStorage(
fOCDBpath.Data());
425 AliInfo(Form(
"Default storage %s",
fOCDBpath.Data()));
428 cdb->SetRun(
fEvent->GetRunNumber());
434 cdb->SetSpecificStorage(
"EMCAL/Calib/Data",
"alien://Folder=/alice/data/2010/OCDB");
435 cdb->SetSpecificStorage(
"EMCAL/Calib/Pedestals",
"alien://Folder=/alice/data/2010/OCDB");
438 TString path = cdb->GetDefaultStorage()->GetBaseFolder();
445 AliCDBEntry *entry = (AliCDBEntry*)
446 AliCDBManager::Instance()->Get(
"EMCAL/Calib/Data");
448 if (entry)
fCalibData = (AliEMCALCalibData*) entry->GetObject();
452 AliFatal(
"Calibration parameters not found in CDB!");
457 AliCDBEntry *entry = (AliCDBEntry*)
458 AliCDBManager::Instance()->Get(
"EMCAL/Calib/Pedestals");
460 if (entry)
fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
464 AliFatal(
"Dead map not found in CDB!");
479 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
480 Int_t eventN = Entry();
481 if(aodIH) eventN = aodIH->GetReadEntry();
490 if (aodIH && aodIH->GetMergeEvents())
494 if(!aodIH->GetMergeEMCALCells())
495 AliFatal(
"Events merged but not EMCAL cells, check analysis settings!");
497 AliDebug(1,
"Use embedded events");
499 AliDebug(1,Form(
"\t InputEvent N Clusters %d, N Cells %d",
500 InputEvent()->GetNumberOfCaloClusters(),InputEvent()->GetEMCALCells()->GetNumberOfCells()));
502 AliDebug(1,Form(
"\t MergedEvent N Clusters %d, N Cells %d",
503 aodIH->GetEventToMerge()->GetNumberOfCaloClusters(), aodIH->GetEventToMerge()->GetEMCALCells()->GetNumberOfCells()));
514 AliDebug(1,Form(
"\t OutputEvent N Clusters %d, N Cells %d",
515 AODEvent()->GetNumberOfCaloClusters(), AODEvent()->GetEMCALCells()->GetNumberOfCells()));
531 AliError(
"Event not available");
554 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
573 Int_t nClusters =
fEvent->GetNumberOfCaloClusters();
574 Int_t nClustersOrg = 0;
576 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
577 if(aodIH && aodIH->GetEventToMerge())
578 nClusters = aodIH->GetEventToMerge()->GetNumberOfCaloClusters();
583 for (Int_t i = 0; i < nClusters; i++)
585 AliVCluster *clus = 0;
586 if(aodIH && aodIH->GetEventToMerge())
587 clus = aodIH->GetEventToMerge()->GetCaloCluster(i);
589 clus =
fEvent->GetCaloCluster(i);
595 Int_t label = clus->GetLabel();
601 if (clus->GetNLabels()>=2) label2 = clus->GetLabelAt(1) ;
602 UShort_t * index = clus->GetCellsAbsId() ;
603 for(Int_t icell=0; icell < clus->GetNCells(); icell++ )
609 fCellTime[index[icell]] = clus->GetTOF();
625 AliVCaloCells * cells =
fEvent->GetEMCALCells();
627 Int_t bc = InputEvent()->GetBunchCrossNumber();
629 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
632 id = cells->GetCellNumber(icell);
633 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(
id,bc,amp,time,cells);
636 if( amp < fRecParam->GetMinECut() ||
638 time <
fRecParam->GetTimeMin() ) accept = kFALSE;
650 if (accept &&
fRecoUtils->IsExoticCell(
id,cells,bc))
655 AliDebug(2,Form(
"Remove channel absId %d, index %d of %d, amp %f, time %f",
656 id,icell, cells->GetNumberOfCells(), amp, time*1.e9));
660 Int_t mcLabel = cells->GetMCLabel(icell);
673 Float_t efrac = cells->GetEFraction(icell);
676 if (mcLabel > 0 && efrac < 1.e-6) efrac = 1;
680 new((*fDigitsArr)[idigit]) AliEMCALDigit( mcLabel, mcLabel,
id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, amp*efrac);
703 AliWarning(Form(
"No array with CaloClusters, input RecPoints entries %d",
fClusterArr->GetEntriesFast()));
707 AliDebug(1,Form(
"N clusters: before recluster %d, after recluster %d, recpoints %d",
723 AliVCaloCells *cells =
fEvent->GetEMCALCells();
724 Double_t cellAmplitude = 0;
725 Double_t cellTime = 0;
726 Short_t cellNumber = 0;
727 Int_t cellMCLabel = 0;
728 Double_t cellEFrac = 0;
729 Int_t nClustersOrg = 0;
732 for (Int_t i = 0; i <
fEvent->GetNumberOfCaloClusters(); i++)
734 AliVCluster *clus =
fEvent->GetCaloCluster(i);
738 if(
fRecoUtils->ClusterContainsBadChannel(
fGeom,clus->GetCellsAbsId(), clus->GetNCells()))
749 for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
751 if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, cellMCLabel, cellEFrac) != kTRUE)
754 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
755 fGeom->GetCellIndex(cellNumber,imod,iTower,iIphi,iIeta);
756 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
759 if(
fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
760 fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
763 cells->SetCell(icell, cellNumber, cellAmplitude*
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi),cellTime);
769 AliESDCaloCluster * esdCluster =
dynamic_cast<AliESDCaloCluster*
> (clus);
770 AliAODCaloCluster * aodCluster =
dynamic_cast<AliAODCaloCluster*
> (clus);
781 AliWarning(
"Wrong CaloCluster type?");
799 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
800 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
802 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
803 aodEMcells.CreateContainer(nEMcell);
804 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
805 Double_t calibFactor = 1.;
806 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
808 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
809 fGeom->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
810 fGeom->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
814 calibFactor =
fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
817 if(!
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
819 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
820 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
824 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
836 AliESDEvent* esdevent =
dynamic_cast<AliESDEvent*
> (
fEvent);
837 AliAODEvent* aodevent =
dynamic_cast<AliAODEvent*
> (
fEvent);
841 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
843 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
844 if(!header) AliFatal(
"Not a standard AOD");
845 header->SetRunNumber(
fEvent->GetRunNumber());
849 TTree* tree = fInputHandler->GetTree();
852 TFile*
file = tree->GetCurrentFile();
853 if (file) header->SetESDFileName(file->GetName());
857 AliAODHeader * aodheader =
dynamic_cast<AliAODHeader*
>(aodevent->GetHeader());
858 if(!aodheader) AliFatal(
"Not a standard AOD");
859 header->SetESDFileName(aodheader->GetESDFileName());
862 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
863 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
864 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
865 header->SetEventType(
fEvent->GetEventType());
868 if(
fEvent->GetCentrality())
869 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
871 header->SetCentrality(0);
874 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
876 header->SetFiredTriggerClasses(
fEvent->GetFiredTriggerClasses());
878 header->SetTriggerMask(
fEvent->GetTriggerMask());
879 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
883 header->SetL0TriggerInputs(esdevent->GetHeader()->GetL0TriggerInputs());
884 header->SetL1TriggerInputs(esdevent->GetHeader()->GetL1TriggerInputs());
885 header->SetL2TriggerInputs(esdevent->GetHeader()->GetL2TriggerInputs());
889 header->SetL0TriggerInputs(aodevent->GetHeader()->GetL0TriggerInputs());
890 header->SetL1TriggerInputs(aodevent->GetHeader()->GetL1TriggerInputs());
891 header->SetL2TriggerInputs(aodevent->GetHeader()->GetL2TriggerInputs());
894 header->SetMagneticField(
fEvent->GetMagneticField());
897 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
898 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
899 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
900 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
901 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
903 Float_t diamxy[2]={(Float_t)
fEvent->GetDiamondX(),(Float_t)
fEvent->GetDiamondY()};
905 fEvent->GetDiamondCovXY(diamcov);
906 header->SetDiamond(diamxy,diamcov);
907 if (esdevent) header->SetDiamondZ(esdevent->GetDiamondZ(),esdevent->GetSigma2DiamondZ());
908 else if (aodevent) header->SetDiamondZ(aodevent->GetDiamondZ(),aodevent->GetSigma2DiamondZ());
911 Int_t nVertices = 1 ;;
912 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
914 AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0);
917 TClonesArray &vertices = *(AODEvent()->GetVertices());
922 fEvent->GetPrimaryVertex()->GetXYZ(pos);
926 esdevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
927 chi = esdevent->GetPrimaryVertex()->GetChi2toNDF();
931 aodevent->GetPrimaryVertex()->GetCovMatrix(covVtx);
932 chi = aodevent->GetPrimaryVertex()->GetChi2perNDF();
935 AliAODVertex * primary =
new(vertices[jVertices++])
936 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
937 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
938 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
958 for(Int_t i = 0; i < kNumberOfCaloClusters; i++)
960 AliAODCaloCluster *newCluster = (AliAODCaloCluster *)
fCaloClusterArr->At(i);
962 newCluster->SetID(i);
965 newCluster->SetE(
fRecoUtils->CorrectClusterEnergyLinearity(newCluster));
970 Int_t trackIndex =
fRecoUtils->GetMatchedTrackIndex(i);
973 newCluster->AddTrackMatched(
fEvent->GetTrack(trackIndex));
974 AliDebug(2,Form(
"Matched Track index %d to new cluster %d",trackIndex,i));
977 Float_t dR = 999., dZ = 999.;
978 fRecoUtils->GetMatchedResiduals(newCluster->GetID(),dR,dZ);
979 newCluster->SetTrackDistance(dR,dZ);
983 Int_t absId0 = newCluster->GetCellsAbsId()[0];
994 new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
996 AliDebug(2,Form(
"New cluster %d of %d, energy %f, mc label %d",
997 newCluster->GetID(), kNumberOfCaloClusters, newCluster->E(), newCluster->GetLabel()));
1009 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1011 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Pointer to tree = 0, returning null");
1015 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1017 AliError(
"AliAnalysisTaskEMCALClusterize::GetPass() - Null pointer input file, returning null");
1021 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1022 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1023 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1024 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1025 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1026 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1027 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1028 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1030 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1031 return TString(
"pass1");
1035 AliInfo(
"Pass number string not found");
1046 if(fDebug >=0) (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
1051 fBranchNames =
"ESD:AliESDHeader.,EMCALCells.";
1069 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
1106 if (
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
1108 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2)
1110 else if(
fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN)
1118 AliFatal(Form(
"Clusterizer < %d > not available",
fRecParam->GetClusterizerFlag()));
1142 for (i = 0; i < 8; i++)
1147 for (i = 0; i < 3; i++)
1167 Int_t runnumber = InputEvent()->GetRunNumber() ;
1172 if (runnumber < 140000)
fGeomName =
"EMCAL_FIRSTYEARV1";
1173 else if(runnumber < 171000)
fGeomName =
"EMCAL_COMPLETEV1";
1174 else if(runnumber < 198000)
fGeomName =
"EMCAL_COMPLETE12SMV1";
1175 else fGeomName =
"EMCAL_COMPLETE12SMV1_DCAL_8SM";
1178 AliInfo(Form(
"Set EMCAL geometry name to <%s> for run %d",
fGeomName.Data(),runnumber));
1199 AliDebug(1,Form(
"Init for run=%d",runnumber));
1200 if (!gGeoManager) AliDebug(1,
"Careful!, gGeoManager not loaded, load misalign matrices");
1205 AliInfo(
"Load user defined EMCAL geometry matrices");
1208 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
1209 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePath.Data()),
"AliEMCALgeo");
1210 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,
"EmcalMatrices");
1212 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1217 AliDebug(2,Form(
"EMCAL matrices SM %d, %p",mod,((TGeoHMatrix*) matEMCAL->At(mod))));
1220 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
1225 if(DebugLevel() > 1)
1235 else if(!gGeoManager)
1237 AliInfo(
"AliAnalysisTaksEMCALClusterize::InitGeometry() - Get geo matrices from data");
1239 if(!strcmp(
fEvent->GetName(),
"AliAODEvent"))
1241 AliWarning(
"Use ideal geometry, values geometry matrix not kept in AODs");
1245 AliDebug(1,
"Load Misaligned matrices");
1247 AliESDEvent* esd =
dynamic_cast<AliESDEvent*
>(
fEvent) ;
1251 AliError(
"This event does not contain ESDs?");
1252 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
1256 for(Int_t mod=0; mod < (
fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
1258 if(DebugLevel() > 1)
1259 esd->GetEMCALMatrix(mod)->Print();
1261 if(esd->GetEMCALMatrix(mod))
fGeom->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
1283 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1284 Float_t totCellE = 0;
1285 Int_t bc = InputEvent()->GetBunchCrossNumber();
1287 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1290 Double_t tcell = 0 ;
1292 Int_t absID = cells->GetCellNumber(icell);
1293 Bool_t accept =
fRecoUtils->AcceptCalibrateCell(absID,bc,ecell,tcell,cells);
1294 if(accept && !
fRecoUtils->IsExoticCell(absID,cells,bc)) totCellE += ecell;
1304 if(totCellE < 1)
return kTRUE;
1317 if(run < 146858 || run > 146860)
return kFALSE ;
1320 Int_t ncellsSM3 = 0;
1321 AliVCaloCells * cells =
fEvent->GetEMCALCells();
1322 for(Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
1324 if(cells->GetAmplitude(icell) > 0.1 && cells->GetCellNumber(icell)/(24*48)==3) ncellsSM3++;
1327 TString triggerclasses =
fEvent->GetFiredTriggerClasses();
1329 Int_t ncellcut = 21;
1330 if(triggerclasses.Contains(
"EMC")) ncellcut = 35;
1332 if( ncellsSM3 >= ncellcut)
1334 AliInfo(Form(
"Reject event %d with ncells in SM3 %d",(Int_t)Entry(),ncellsSM3));
1335 if(
fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
1350 for(Int_t i = 0; i <
fClusterArr->GetEntriesFast(); i++)
1352 AliEMCALRecPoint *recPoint = (AliEMCALRecPoint*)
fClusterArr->At(i);
1354 const Int_t ncells = recPoint->GetMultiplicity();
1355 Int_t ncellsTrue = 0;
1357 if(recPoint->GetEnergy() <
fRecParam->GetClusteringThreshold())
continue;
1360 UShort_t absIds[ncells];
1361 Double32_t ratios[ncells];
1364 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1366 Float_t clusterE = 0;
1367 for (Int_t c = 0; c < ncells; c++)
1369 AliEMCALDigit *digit = (AliEMCALDigit*)
fDigitsArr->At(recPoint->GetDigitsList()[c]);
1371 absIds[ncellsTrue] = digit->GetId();
1372 ratios[ncellsTrue] = recPoint->GetEnergiesList()[c]/digit->GetAmplitude();
1380 AliDebug(2,Form(
"Too small energy in cell of cluster: cluster cell %f, digit %f",
1381 recPoint->GetEnergiesList()[c],digit->GetAmplitude()));
1387 clusterE +=recPoint->GetEnergiesList()[c];
1390 if (aodIH && aodIH->GetMergeEvents())
1393 AliVCaloCells* meEMCALCells = aodIH->GetEventToMerge()->GetEMCALCells();
1394 AliVCaloCells* ouEMCALCells = AODEvent()->GetEMCALCells();
1396 Float_t sigAmplitude = meEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1398 Float_t sumAmplitude = ouEMCALCells->GetCellAmplitude(absIds[ncellsTrue]);
1401 if(sumAmplitude > 0) ratios[ncellsTrue] = sigAmplitude/sumAmplitude;
1412 AliDebug(2,Form(
"Skipping cluster with no cells avobe threshold E = %f, ncells %d",
1413 recPoint->GetEnergy(), ncells));
1419 if(clusterE < fRecParam->GetClusteringThreshold())
1421 AliDebug(2,Form(
"Remove cluster with energy below seed threshold %f",clusterE));
1431 recPoint->GetGlobalPosition(gpos);
1436 (*fCaloClusterArr)[j] =
new AliAODCaloCluster() ;
1437 AliAODCaloCluster *clus =
dynamic_cast<AliAODCaloCluster *
>(
fCaloClusterArr->At(j) ) ;
1439 clus->SetType(AliVCluster::kEMCALClusterv1);
1440 clus->SetE(clusterE);
1441 clus->SetPosition(g);
1442 clus->SetNCells(ncellsTrue);
1443 clus->SetCellsAbsId(absIds);
1444 clus->SetCellsAmplitudeFraction(ratios);
1446 clus->SetTOF(recPoint->GetTime()) ;
1447 clus->SetNExMax(recPoint->GetNExMax());
1448 clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
1450 if(ncells == ncellsTrue)
1452 Float_t elipAxis[2];
1453 recPoint->GetElipsAxis(elipAxis);
1454 clus->SetM02(elipAxis[0]*elipAxis[0]) ;
1455 clus->SetM20(elipAxis[1]*elipAxis[1]) ;
1456 clus->SetDispersion(recPoint->GetDispersion());
1462 AliDebug(2,Form(
"Cells removed from cluster (ncells %d, ncellsTrue %d), recalculate Shower Shape",ncells,ncellsTrue));
1464 AliVCaloCells* cells = 0x0;
1465 if (aodIH && aodIH->GetMergeEvents()) cells = AODEvent() ->GetEMCALCells();
1466 else cells = InputEvent()->GetEMCALCells();
1468 fRecoUtils->RecalculateClusterShowerShapeParameters(
fGeom,cells,clus);
1481 Int_t parentMult = 0;
1482 Int_t *parentList = recPoint->GetParents(parentMult);
1483 clus->SetLabel(parentList, parentMult);
1498 if(label < 0) return ;
1500 AliAODEvent * evt =
dynamic_cast<AliAODEvent*
> (
fEvent) ;
1503 TClonesArray * arr =
dynamic_cast<TClonesArray*
>(evt->FindListObject(
"mcparticles")) ;
1506 if(label < arr->GetEntriesFast())
1508 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(label));
1509 if(!particle) return ;
1511 if(label == particle->Label())
return ;
1517 for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
1519 AliAODMCParticle * particle =
dynamic_cast<AliAODMCParticle *
>(arr->At(ind));
1520 if(!particle) continue ;
1522 if(label == particle->Label())
1557 AliAODCaloCluster * clus)
1559 Int_t parentMult = 0;
1560 Int_t *parentList = recPoint->GetParents(parentMult);
1561 clus->SetLabel(parentList, parentMult);
1565 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1568 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1572 for ( UInt_t iLoopLabels = 0 ; iLoopLabels < clus->GetNLabels() ; iLoopLabels++ )
1575 if (
fCellSecondLabels[idCell] == clus->GetLabelAt(iLoopLabels) ) iNewLabel = 0;
1579 Int_t * newLabelArray =
new Int_t[clus->GetNLabels()+1] ;
1580 for ( UInt_t iLoopNewLabels = 0 ; iLoopNewLabels < clus->GetNLabels() ; iLoopNewLabels++ )
1582 newLabelArray[iLoopNewLabels] = clus->GetLabelAt(iLoopNewLabels) ;
1586 clus->SetLabel(newLabelArray,clus->GetNLabels()+1) ;
1587 delete [] newLabelArray;
1600 TArrayI clArray(300) ;
1603 Int_t nLabTotOrg = 0;
1607 AliVEvent *
event =
fEvent;
1610 AliAODInputHandler* aodIH =
dynamic_cast<AliAODInputHandler*
>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1611 if(aodIH && aodIH->GetEventToMerge())
1612 event = aodIH->GetEventToMerge();
1616 for ( Int_t iLoopCell = 0 ; iLoopCell < clus->GetNCells() ; iLoopCell++ )
1618 Int_t idCell = clus->GetCellAbsId(iLoopCell) ;
1625 for(Int_t icl =0; icl < nClu; icl++)
1627 if(((Int_t)clArray.GetAt(icl))==-1 )
continue;
1628 if( idCluster == ((Int_t)clArray.GetAt(icl)) ) set = kFALSE;
1632 if( set && idCluster >= 0)
1634 clArray.SetAt(idCluster,nClu++);
1636 nLabTotOrg+=(
event->GetCaloCluster(idCluster))->GetNLabels();
1641 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1643 if(emax < clOrg->E())
1652 if(nClu==0 || nLabTotOrg == 0)
1660 if(idMax != ((Int_t)clArray.GetAt(0)))
1662 Int_t maxIndex = -1;
1663 Int_t firstCluster = ((Int_t)clArray.GetAt(0));
1664 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1666 if(idMax == ((Int_t)clArray.GetAt(iLoopCluster))) maxIndex = iLoopCluster;
1669 if(firstCluster >=0 && idMax >=0)
1671 clArray.SetAt(idMax,0);
1672 clArray.SetAt(firstCluster,maxIndex);
1677 TArrayI clMCArray(nLabTotOrg) ;
1681 for ( Int_t iLoopCluster = 0 ; iLoopCluster < nClu ; iLoopCluster++ )
1683 Int_t idCluster = (Int_t) clArray.GetAt(iLoopCluster);
1685 AliVCluster * clOrg =
event->GetCaloCluster(idCluster);
1686 Int_t nLab = clOrg->GetNLabels();
1688 for ( Int_t iLab = 0 ; iLab < nLab ; iLab++ )
1690 Int_t lab = clOrg->GetLabelAt(iLab) ;
1695 for(Int_t iLabTot =0; iLabTot < nLabTot; iLabTot++)
1697 if( lab == ((Int_t)clMCArray.GetAt(iLabTot)) ) set = kFALSE;
1701 if( set ) clMCArray.SetAt(lab,nLabTot++);
1708 clus->SetLabel(clMCArray.GetArray(), nLabTot);
1732 AliInfo(
"Cluster branch name not set, set it to newEMCALClustersArray");
1788 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.
AliEMCALCalibData * fCalibData
EMCAL calib data.
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.
AliCaloCalibPedestal * fPedestalData
EMCAL pedestal.
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.
Bool_t AccessOCDB()
Access to OCDB stuff, avoid.
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.