17 #include <TGeoManager.h>
23 #include <TParticle.h>
24 #include <AliMCEvent.h>
28 #include "AliESDEvent.h"
29 #include "AliMCEvent.h"
31 #include "AliAODPWG4Particle.h"
32 #include "AliVCluster.h"
33 #include "AliVCaloCells.h"
34 #include "AliAODCaloCluster.h"
35 #include "AliOADBContainer.h"
36 #include "AliAnalysisManager.h"
37 #include "AliAODMCParticle.h"
41 #include "AliEMCALGeometry.h"
42 #include "AliPHOSGeoUtils.h"
58 fEMCALGeo(0x0), fPHOSGeo(0x0),
59 fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE),
60 fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE),
61 fRemoveBadChannels(kFALSE), fPHOSBadChannelMap(0x0),
62 fNCellsFromPHOSBorder(0),
63 fNMaskCellColumns(0), fMaskCellColumns(0x0),
64 fRecalibration(kFALSE), fRunDependentCorrection(kFALSE),
65 fPHOSRecalibrationFactors(), fEMCALRecoUtils(new AliEMCALRecoUtils),
66 fRecalculatePosition(kFALSE), fCorrectELinearity(kFALSE),
67 fRecalculateMatching(kFALSE),
69 fCutEta(20), fCutPhi(20),
70 fLocMaxCutE(0), fLocMaxCutEDiff(0),
71 fPlotCluster(0), fOADBSet(kFALSE),
72 fOADBForEMCAL(kFALSE), fOADBForPHOS(kFALSE),
73 fOADBFilePathEMCAL(
""), fOADBFilePathPHOS(
""),
74 fImportGeometryFromFile(0), fImportGeometryFilePath(
""),
75 fNSuperModulesUsed(0), fRunNumber(0),
76 fMCECellClusFracCorrOn(0), fMCECellClusFracCorrParam()
129 AliOADBContainer *contBC=
new AliOADBContainer(
"");
130 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALBadChannels");
137 AliInfo(
"Remove EMCAL bad cells");
139 for (
Int_t i=0; i<nSM; ++i)
146 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
150 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
154 hbm->SetDirectory(0);
158 }
else AliInfo(
"Do NOT remove EMCAL bad channels\n");
166 AliOADBContainer *contRF=
new AliOADBContainer(
"");
168 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRecalib");
182 AliInfo(
"Recalibrate EMCAL");
183 for (
Int_t i=0; i < nSM; ++i)
190 h = (
TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
194 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
202 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
203 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
204 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
215 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
217 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRunDepTempCalibCorrections");
219 TH1S *htd=(TH1S*)contRFTD->GetObject(
fRunNumber);
224 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",
fRunNumber));
228 Int_t maxEntry = contRFTD->GetNumberOfEntries();
230 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) <
fRunNumber) )
236 Int_t closest = lower;
237 if ( (ic<maxEntry) &&
243 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
244 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
249 AliInfo(
"Recalibrate (Temperature) EMCAL");
251 for (
Int_t ism=0; ism<nSM; ++ism)
253 for (
Int_t icol=0; icol<48; ++icol)
255 for (
Int_t irow=0; irow<24; ++irow)
259 Int_t absID =
fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol);
260 factor *= htd->GetBinContent(absID) / 10000. ;
269 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
277 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
279 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALTimeCalib");
286 if(pass==
"spc_calo") passM =
"pass3";
291 AliInfo(
"Time Recalibrate EMCAL");
292 for (
Int_t ibc = 0; ibc < 4; ++ibc)
299 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
303 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
311 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
312 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
320 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
321 contTRF->InitFromFile(Form(
"%s/EMCALTimeL1PhaseCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALTimeL1PhaseCalib");
326 AliError(Form(
"L1 phase time recal: No params for run %d. Default used.",
fRunNumber));
327 trecal=(
TObjArray*)contTRF->GetObject(0);
341 AliInfo(Form(
"L1 phase time recal: No params for run %d and pass %s, try default",
fRunNumber, passM.Data()));
345 trecal=(
TObjArray*)contTRF->GetObject(0);
348 trecalpass=(
TObjArray*)trecal->FindObject(
"pass1");
350 AliInfo(
"Time L1 phase Recalibrate EMCAL");
359 h = (TH1C*)trecalpass->FindObject(Form(
"h%d",
fRunNumber));
361 if (!h) AliError(Form(
"Could not load h%d",
fRunNumber));
369 AliError(
"Do not calibrate L1 phase time");
375 AliError(
"Do not calibrate L1 phase time");
392 AliOADBContainer badmapContainer(Form(
"phosBadMap"));
394 badmapContainer.InitFromFile(Form(
"%s/PHOSBadMaps.root",
fOADBFilePathPHOS.Data()),
"phosBadMap");
400 AliInfo(Form(
"Can not read PHOS bad map for run %d",
fRunNumber)) ;
404 AliInfo(Form(
"Setting PHOS bad map with name %s",maps->GetName())) ;
406 for(
Int_t mod = 1; mod < 5; mod++)
413 hbmPH = (TH2I*)maps->At(mod);
415 if(hbmPH) hbmPH->SetDirectory(0);
445 AliInfo(
"Load user defined EMCAL geometry matrices");
448 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
449 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALgeo");
452 for(
Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
456 AliDebug(1,Form(
"EMCAL matrices SM %d, %p", mod,((TGeoHMatrix*) matEMCAL->At(mod))));
471 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
472 fEMCALGeo->SetMisalMatrix(
fEMCALGeo->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
476 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
483 else if (!gGeoManager)
485 AliDebug(1,
"Load EMCAL misalignment matrices");
486 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
488 for(
Int_t mod = 0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
491 if(((
AliESDEvent*)inputEvent)->GetEMCALMatrix(mod))
502 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
516 AliInfo(
"Load user defined PHOS geometry matrices");
519 AliOADBContainer geomContainer(
"phosGeo");
520 geomContainer.InitFromFile(Form(
"%s/PHOSGeometry.root",
fOADBFilePathPHOS.Data()),
"PHOSRotationMatrixes");
521 TObjArray *matPHOS = (
TObjArray*)geomContainer.GetObject(139000,
"PHOSRotationMatrixes");
523 for(
Int_t mod = 0 ; mod < 5 ; mod++)
527 AliDebug(1,Form(
"PHOS matrices module %d, %p",mod,((TGeoHMatrix*) matPHOS->At(mod))));
530 fPHOSMatrix[mod] = (TGeoHMatrix*) matPHOS->At(mod) ;
546 else if (!gGeoManager)
548 AliDebug(1,
"Load PHOS misalignment matrices.");
549 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
551 for(
Int_t mod = 0; mod < 5; mod++)
553 if( ((
AliESDEvent*)inputEvent)->GetPHOSMatrix(mod))
564 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
580 Bool_t areNeighbours = kFALSE ;
582 Int_t iRCU1 = -1, irow1 = -1, icol1 = -1;
583 Int_t iRCU2 = -1, irow2 = -1, icol2 = -1;
585 Int_t rowdiff = 0, coldiff = 0;
594 if(nSupMod1%2) icol1+=AliEMCALGeoParams::fgkEMCALCols;
595 else icol2+=AliEMCALGeoParams::fgkEMCALCols;
598 rowdiff = TMath::Abs( irow1 - irow2 ) ;
599 coldiff = TMath::Abs( icol1 - icol2 ) ;
602 if ((coldiff + rowdiff == 1 ))
603 areNeighbours = kTRUE ;
605 return areNeighbours;
613 AliVCluster* cluster)
623 for(
Int_t iDigit = 0; iDigit < cluster->GetNCells(); iDigit++)
626 geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
627 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
630 if (iDigit == 0 ) iSM0 = iSupMod;
631 else if(iSupMod != iSM0)
633 if(iSupMod > 11 && iSupMod < 18)
634 AliWarning(Form(
"Cluster shared in 2 DCal: SM%d, SM%d??",iSupMod,iSM0));
648 AliVCaloCells* cells)
const
652 if ( cells->GetType()==AliVCaloCells::kEMCALCell &&
fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 )
return kTRUE;
659 for(
Int_t i = 0; i < cluster->GetNCells() ; i++)
661 Int_t absId = cluster->GetCellAbsId(i) ;
662 Float_t amp = cells->GetCellAmplitude(absId);
671 AliDebug(1,Form(
"Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f",
672 absIdMax, ampMax, cluster->E()));
674 if ( absIdMax == -1 )
return kFALSE;
680 if ( cells->GetType() == AliVCaloCells::kEMCALCell )
685 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
687 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
689 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
691 if(iSM < 0 || iphi < 0 || ieta < 0 )
693 AliFatal(Form(
"Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name",iSM,ieta,iphi));
699 if ( iSM < 10 || (iSM > 11 && iSM < 18) )
701 if(iphi >= nborder && iphi < 24-nborder) okrow = kTRUE;
705 if(iphi >= nborder && iphi < 8-nborder) okrow = kTRUE;
711 if(!
fEMCALRecoUtils->IsEMCALNoBorderAtEta0() || (iSM > 11 && iSM < 18))
713 if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE;
719 if(ieta >= nborder) okcol = kTRUE;
723 if(ieta < 48-nborder) okcol = kTRUE;
727 AliDebug(1,Form(
"EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
728 nborder, ieta, iphi, iSM,okrow,okcol));
731 else if ( cells->GetType() == AliVCaloCells::kPHOSCell )
734 Int_t irow = -1, icol = -1;
735 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
737 if (relId[1] != 0 )
return kFALSE;
743 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
744 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
746 AliDebug(1,Form(
"PHOS Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
747 fNCellsFromPHOSBorder, icol, irow, relId[0]-1,okrow,okcol));
750 if (okcol && okrow)
return kTRUE;
769 for(
Int_t iCell = 0; iCell<nCells; iCell++)
779 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
781 if (relId[1] != 0 )
return kTRUE;
818 regEta = regPhi = -1 ;
820 if(!clus->IsEMCAL())
return ;
822 Int_t icol = -1, irow = -1, iRCU = -1;
830 if( sm%2 == 1) icol+=AliEMCALGeoParams::fgkEMCALCols;
833 if(icol < 2 || icol > 93 || irow < 2 || irow > 21)
return;
840 if ( icol > 9 && icol < 34 ) regEta = 0;
841 else if ( icol > 62 && icol < 87 ) regEta = 0;
845 else if ( icol <= 9 && icol >= 5 ) regEta = 3;
846 else if ( icol <= 38 && icol >= 34 ) regEta = 3;
847 else if ( icol <= 62 && icol >= 58 ) regEta = 3;
848 else if ( icol <= 91 && icol >= 87 ) regEta = 3;
852 else if ( icol < 58 && icol > 38 ) regEta = 1 ;
862 if ( irow >= 2 && irow <= 5 ) regPhi = 0;
863 else if ( irow >= 18 && irow <= 21 ) regPhi = 0;
864 else if ( irow >= 6 && irow <= 9 ) regPhi = 1;
865 else if ( irow >= 14 && irow <= 17 ) regPhi = 1;
884 Int_t absIdSMMin =
fEMCALGeo->GetAbsCellIdFromCellIndexes(sm,0,1);
887 for(
Int_t k = 0; k < 4; k++ )
889 for(
Int_t p = 0; p < 72; p++ )
891 Int_t n = absIdSMMin + 2*k + 16 *p;
893 if ( absId == n || absId == n+1 ||
894 absId == n+8 || absId == n+9 )
934 if(absId1 == absId2)
return kFALSE;
939 if ( sm1 != sm2 )
return kFALSE ;
942 Int_t iTower = -1, iIphi = -1, iIeta = -1;
945 fEMCALGeo->GetCellIndex(absId1,sm1,iTower,iIphi,iIeta);
946 fEMCALGeo->GetCellPhiEtaIndexInSModule(sm1,iTower,iIphi, iIeta,row1,col1);
949 fEMCALGeo->GetCellIndex(absId2,sm2,iTower,iIphi,iIeta);
950 fEMCALGeo->GetCellPhiEtaIndexInSModule(sm2,iTower,iIphi, iIeta,row2,col2);
955 Int_t rowDiff0 = row2-row0;
956 Int_t colDiff0 = col2-col0;
962 if ( colDiff0 >=0 && colDiff0 < 2 && rowDiff0 >=0 && rowDiff0 < 8 )
981 Float_t & clusterFraction)
const
985 AliInfo(
"Cluster or cells pointer is null!");
994 Int_t cellAbsId =-1 , absId =-1 ;
995 Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1;
1000 for (
Int_t iDig=0; iDig< clu->GetNCells(); iDig++)
1002 cellAbsId = clu->GetCellAbsId(iDig);
1004 fraction = clu->GetCellAmplitudeFraction(iDig);
1005 if(fraction < 1e-4) fraction = 1.;
1017 eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
1030 clusterFraction = (eTot-eMax)/eTot;
1032 clusterFraction =1.;
1043 AliVEvent* event,
Int_t index)
const
1045 AliVTrack *track = 0x0;
1056 AliInfo(Form(
"Wrong track index %d, from recalculation", trackIndex));
1058 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(trackIndex));
1068 if( cluster->GetNTracksMatched() < 1 )
return 0x0;
1074 if(!strcmp(
"AliESDCaloCluster",Form(
"%s",cluster->ClassName())))
1076 if( index >= 0 ) iTrack = index;
1077 else iTrack = ((AliESDCaloCluster*)cluster)->GetTracksMatched()->At(0);
1079 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(iTrack) );
1083 if( index > 0 ) iTrack = index;
1085 track =
dynamic_cast<AliVTrack*
>( cluster->GetTrackMatched(iTrack) );
1097 if( eCluster <= 0 || eCluster < eCell )
1099 AliWarning(Form(
"Bad values eCell=%f, eCluster %f",eCell,eCluster));
1103 Float_t frac = eCell / eCluster;
1125 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
1127 AliDebug(2,Form(
"EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d",
1128 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
1130 return fEMCALGeo->GetSuperModuleNumber(absId) ;
1136 if(strcmp(inputEvent->ClassName(),
"AliMCEvent") == 0 )
1140 TParticle* primary = 0x0;
1141 AliStack * stack = ((AliMCEvent*)inputEvent)->Stack();
1145 primary = stack->Particle(particle->GetCaloLabel(0));
1149 AliFatal(
"Stack not available, stop!");
1154 fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ;
1158 AliFatal(
"Primary not available, stop!");
1183 AliDebug(1,
"AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!");
1188 if ( cluster->GetNCells() <= 0 )
return -1;
1190 Int_t absId = cluster->GetCellAbsId(0);
1192 if ( absId < 0 )
return -1;
1194 if( cluster->IsEMCAL() )
1196 AliDebug(2,Form(
"EMCAL absid %d, SuperModule %d",absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
1198 return fEMCALGeo->GetSuperModuleNumber(absId) ;
1200 else if ( cluster->IsPHOS() )
1203 fPHOSGeo->AbsToRelNumbering(absId,relId);
1205 if (relId[1] != 0 )
return -1;
1207 AliDebug(2,Form(
"PHOS absid %d Module %d",absId, relId[0]-1));
1223 if ( absId < 0 )
return -1 ;
1227 Int_t iTower = -1, iIphi = -1, iIeta = -1;
1228 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
1229 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
1231 if(imod < 0 || irow < 0 || icol < 0 )
1233 AliFatal(Form(
"Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name",imod,icol,irow));
1240 if ( imod == 13 || imod == 15 || imod == 17 ) ico2 += 16;
1243 if(imod < 10 || (imod > 11 && imod < 18))
1246 if ( 0 <= irow && irow < 8 ) iRCU = 0;
1247 else if ( 8 <= irow && irow < 16 &&
1248 0 <= ico2 && ico2 < 24 ) iRCU = 0;
1252 else if ( 8 <= irow && irow < 16 &&
1253 24 <= ico2 && ico2 < 48 ) iRCU = 1;
1255 else if ( 16 <= irow && irow < 24 ) iRCU = 1;
1257 if ( imod%2 == 1 ) iRCU = 1 - iRCU;
1266 AliFatal(Form(
"Wrong EMCAL RCU number = %d", iRCU));
1273 fPHOSGeo->AbsToRelNumbering(absId,relId);
1275 if (relId[1] != 0 )
return -1;
1280 iRCU= (
Int_t)(relId[2]-1)/16 ;
1285 AliFatal(Form(
"Wrong PHOS RCU number = %d", iRCU));
1311 irowAbs = irow + 64 * imod;
1322 Int_t shiftEta = 48;
1325 if ( imod > 11 && imod < 18) shiftEta+=48/3;
1327 icolAbs = (imod % 2) ? icol + shiftEta : icol;
1331 irowAbs = irow + 24 *
Int_t(imod / 2);
1334 if ( imod > 11 && imod < 20) irowAbs -= (2*24 / 3);
1346 const Int_t nc = cluster->GetNCells();
1348 Int_t absIdList[nc];
1366 const Int_t nCells = cluster->GetNCells();
1374 simuTotWeight/= eCluster;
1384 for(iDigit = 0; iDigit < nCells ; iDigit++)
1386 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ;
1387 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1396 idmax = absIdList[iDigit] ;
1403 for(iDigit = 0 ; iDigit < nCells; iDigit++)
1405 if( absIdList[iDigit] >= 0 )
1407 absId1 = cluster->GetCellsAbsId()[iDigit];
1409 Float_t en1 = cells->GetCellAmplitude(absId1);
1417 for(iDigitN = 0; iDigitN < nCells; iDigitN++)
1419 absId2 = cluster->GetCellsAbsId()[iDigitN] ;
1421 if(absId2==-1 || absId2==absId1)
continue;
1425 Float_t en2 = cells->GetCellAmplitude(absId2);
1438 absIdList[iDigitN] = -1 ;
1443 absIdList[iDigit] = -1 ;
1448 absIdList[iDigit] = -1 ;
1453 absIdList[iDigitN] = -1 ;
1464 for(iDigit = 0; iDigit < nCells; iDigit++)
1466 if( absIdList[iDigit] >= 0 )
1468 absIdList[iDigitN] = absIdList[iDigit] ;
1470 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1478 maxEList[iDigitN] = en ;
1487 AliDebug(1,Form(
"No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f",
1488 idmax,emax,cluster->E()));
1490 maxEList[0] = emax ;
1491 absIdList[0] = idmax ;
1495 AliDebug(1,Form(
"In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d",
1496 cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN));
1511 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1513 AliError(
"AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null");
1517 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1519 AliError(
"AliCalorimeterUtils::GetPass() - Null pointer input file, returning null");
1523 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1524 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1525 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1526 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1527 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1528 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1529 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1530 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1532 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1535 else if (pass.Contains(
"LHC14a1a"))
1537 AliInfo(
"Check that Energy calibration was enabled for this MC production in the tender, clusterizer or here!!");
1543 AliInfo(
"Pass number string not found");
1595 AliDebug(1,
"Init bad channel map");
1598 Bool_t oldStatus = TH1::AddDirectoryStatus();
1599 TH1::AddDirectory(kFALSE);
1602 for (
int i = 0; i < 5; i++)
fPHOSBadChannelMap->Add(
new TH2I(Form(
"PHOS_BadMap_mod%d",i),
1603 Form(
"PHOS_BadMap_mod%d",i),
1604 64, 0, 64, 56, 0, 56));
1610 TH1::AddDirectory(oldStatus);
1618 AliDebug(1,
"Init recalibration map");
1621 Bool_t oldStatus = TH1::AddDirectoryStatus();
1622 TH1::AddDirectory(kFALSE);
1625 for (
int i = 0; i < 5; i++)
1628 Form(
"PHOSRecalFactors_Mod%d",i),
1629 64, 0, 64, 56, 0, 56));
1633 for (
Int_t m = 0; m < 5; m++)
1635 for (
Int_t i = 0; i < 56; i++)
1637 for (
Int_t j = 0; j < 64; j++)
1648 TH1::AddDirectory(oldStatus);
1663 AliInfo(Form(
"Get EMCAL geometry name to <%s> for run %d",
fEMCALGeo->GetName(),
fRunNumber));
1668 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fEMCALGeoName.Data()));
1687 else if (!gGeoManager) AliInfo(
"Careful!, gGeoManager not loaded, load misalign matrices");
1716 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1732 Int_t icol = -1, irow = -1, iRCU = -1;
1735 if(status > 0) ok = kFALSE;
1754 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1758 Float_t phi = particle->Phi();
1759 if(phi < 0) phi+=TMath::TwoPi();
1765 Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1766 return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1774 Int_t icol = -1, irow = -1, iRCU = -1;
1777 if(status > 0) ok = kFALSE;
1797 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1802 if(phi < 0) phi+=TMath::TwoPi();
1816 Int_t icol = -1, irow = -1, iRCU = -1;
1819 if(status > 0) ok = kFALSE;
1835 if ( iSM%2 ) icol+=48;
1856 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1858 printf(
"Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1860 if(
fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf(
"Do not remove EMCAL clusters at Eta = 0\n");
1864 printf(
"Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",
fCutR,
fCutZ);
1923 AliVCaloCells * cells)
1932 UShort_t * index = cluster->GetCellsAbsId() ;
1933 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1935 Int_t ncells = cluster->GetNCells();
1941 for(
Int_t icell = 0; icell < ncells; icell++)
1943 Int_t absId = index[icell];
1945 frac = fraction[icell];
1946 if(frac < 1e-3) frac = 1;
1948 Float_t amp = cells->GetCellAmplitude(absId);
1951 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1952 calo,frac,cells->GetCellAmplitude(absId),amp));
1957 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),
energy));
1962 AliFatal(
"Cells pointer does not exist!");
1973 AliVCaloCells * cells,
Float_t energyOrg)
1982 UShort_t * index = cluster->GetCellsAbsId() ;
1983 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1985 Int_t ncells = cluster->GetNCells();
1991 for(
Int_t icell = 0; icell < ncells; icell++)
1993 Int_t absId = index[icell];
1995 frac = fraction[icell];
1996 if(frac < 1e-3) frac = 1;
1998 Float_t amp = cells->GetCellAmplitude(absId);
2003 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
2004 calo,frac,cells->GetCellAmplitude(absId)));
2009 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),
energy));
2013 AliFatal(
"Cells pointer does not exist!");
2046 Int_t nClusters =
event->GetNumberOfCaloClusters();
2047 if(clusterArray) nClusters = clusterArray->GetEntriesFast();
2049 AliVCluster * clus = 0;
2051 for (
Int_t iclus = 0; iclus < nClusters ; iclus++)
2053 if ( clusterArray ) clus = (AliVCluster*) clusterArray->At(iclus) ;
2054 else clus =
event->GetCaloCluster(iclus) ;
2056 if (!clus->IsEMCAL())
continue ;
2063 if ( TMath::Abs(clus->GetTrackDx()) < 500 )
2064 AliDebug(2,Form(
"Residuals (Old, New): z (%2.4f,%2.4f), x (%2.4f,%2.4f)\n",
2065 clus->GetTrackDz(),dZ,clus->GetTrackDx(),dR));
2067 clus->SetTrackDistance(dR,dZ);
2072 if(clus->GetNTracksMatched() > 0)
2074 if(!strcmp(
"AliESDCaloCluster",Form(
"%s",clus->ClassName())))
2077 ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
2081 for(
Int_t iTrack = 0; iTrack < clus->GetNTracksMatched(); iTrack++)
2083 ((AliAODCaloCluster*)clus)->RemoveTrackMatched((
TObject*)((AliAODCaloCluster*)clus)->GetTrackMatched(iTrack));
2092 if ( trackIndex >= 0 )
2094 if(!strcmp(
"AliESDCaloCluster",Form(
"%s",clus->ClassName())))
2097 arrayTrackMatched[0] = trackIndex;
2098 ((AliESDCaloCluster*)clus)->AddTracksMatched(arrayTrackMatched);
2102 ((AliAODCaloCluster*)clus)->AddTrackMatched((
TObject*)event->GetTrack(trackIndex));
2124 AliVCluster* cluster,
2125 AliVCaloCells* cells,
2127 AliAODCaloCluster* cluster1,
2128 AliAODCaloCluster* cluster2,
2131 TH2F* hClusterMap = 0 ;
2132 TH2F* hClusterLocMax = 0 ;
2133 TH2F* hCluster1 = 0 ;
2134 TH2F* hCluster2 = 0 ;
2138 hClusterMap =
new TH2F(
"hClusterMap",
"Cluster Map",48,0,48,24,0,24);
2139 hClusterLocMax =
new TH2F(
"hClusterLocMax",
"Cluster 2 highest local maxima",48,0,48,24,0,24);
2140 hCluster1 =
new TH2F(
"hCluster1",
"Cluster 1",48,0,48,24,0,24);
2141 hCluster2 =
new TH2F(
"hCluster2",
"Cluster 2",48,0,48,24,0,24);
2142 hClusterMap ->SetXTitle(
"column");
2143 hClusterMap ->SetYTitle(
"row");
2144 hClusterLocMax ->SetXTitle(
"column");
2145 hClusterLocMax ->SetYTitle(
"row");
2146 hCluster1 ->SetXTitle(
"column");
2147 hCluster1 ->SetYTitle(
"row");
2148 hCluster2 ->SetXTitle(
"column");
2149 hCluster2 ->SetYTitle(
"row");
2153 if(cluster->IsPHOS())
2156 AliWarning(
"Not supported for PHOS yet");
2160 const Int_t ncells = cluster->GetNCells();
2161 Int_t absIdList[ncells];
2164 Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
2166 Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
2167 for(
Int_t iDigit = 0; iDigit < ncells; iDigit++ )
2169 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
2171 Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
2179 if(sm > -1 && sm < 12)
2181 if(icol > maxCol) maxCol = icol;
2182 if(icol < minCol) minCol = icol;
2183 if(irow > maxRow) maxRow = irow;
2184 if(irow < minRow) minRow = irow;
2185 hClusterMap->Fill(icol,irow,ec);
2194 absIdList1[0] = absId1 ;
2195 fracList1 [0] = 1. ;
2197 Float_t ecell1 = cells->GetCellAmplitude(absId1);
2204 absIdList2[0] = absId2 ;
2205 fracList2 [0] = 1. ;
2207 Float_t ecell2 = cells->GetCellAmplitude(absId2);
2213 Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
2215 hClusterLocMax->Fill(icol1,irow1,ecell1);
2217 hClusterLocMax->Fill(icol2,irow2,ecell2);
2221 Float_t eRemain = (eCluster-ecell1-ecell2)/2;
2222 Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
2223 Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
2225 for(
Int_t iDigit = 0; iDigit < ncells; iDigit++)
2227 Int_t absId = absIdList[iDigit];
2229 if ( absId==absId1 || absId==absId2 || absId < 0 )
continue;
2231 Float_t ecell = cells->GetCellAmplitude(absId);
2236 absIdList1[ncells1]= absId;
2240 fracList1[ncells1] = shareFraction1;
2241 e1 += ecell*shareFraction1;
2245 fracList1[ncells1] = 1.;
2255 absIdList2[ncells2]= absId;
2259 fracList2[ncells2] = shareFraction2;
2260 e2 += ecell*shareFraction2;
2264 fracList2[ncells2] = 1.;
2273 AliDebug(1,Form(
"N Local Max %d, Cluster energy = %f, Ecell1 = %f, Ecell2 = %f, Enew1 = %f, Enew2 = %f, Remain %f, \n ncells %d, ncells1 %d, ncells2 %d, f1 %f, f2 %f, sum f12 = %f",
2274 nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
2279 cluster1->SetNCells(ncells1);
2280 cluster2->SetNCells(ncells2);
2282 cluster1->SetCellsAbsId(absIdList1);
2283 cluster2->SetCellsAbsId(absIdList2);
2285 cluster1->SetCellsAmplitudeFraction(fracList1);
2286 cluster2->SetCellsAmplitudeFraction(fracList2);
2301 for(
Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
2307 Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
2310 if(
AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
2311 hCluster1->Fill(icol,irow,ecell*shareFraction1);
2313 hCluster1->Fill(icol,irow,ecell);
2319 for(
Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
2325 Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
2328 if(
AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
2329 hCluster2->Fill(icol,irow,ecell*shareFraction2);
2331 hCluster2->Fill(icol,irow,ecell);
2335 gStyle->SetPadRightMargin(0.1);
2336 gStyle->SetPadLeftMargin(0.1);
2337 gStyle->SetOptStat(0);
2338 gStyle->SetOptFit(000000);
2340 if(maxCol-minCol > maxRow-minRow)
2342 maxRow+= maxCol-minCol;
2346 maxCol+= maxRow-minRow;
2349 TCanvas *
c=
new TCanvas(
"canvas",
"canvas", 4000, 4000) ;
2355 hClusterMap ->SetAxisRange(minCol, maxCol,
"X");
2356 hClusterMap ->SetAxisRange(minRow, maxRow,
"Y");
2357 hClusterMap ->Draw(
"colz TEXT");
2362 hClusterLocMax ->SetAxisRange(minCol, maxCol,
"X");
2363 hClusterLocMax ->SetAxisRange(minRow, maxRow,
"Y");
2364 hClusterLocMax ->Draw(
"colz TEXT");
2369 hCluster1 ->SetAxisRange(minCol, maxCol,
"X");
2370 hCluster1 ->SetAxisRange(minRow, maxRow,
"Y");
2371 hCluster1 ->Draw(
"colz TEXT");
2376 hCluster2 ->SetAxisRange(minCol, maxCol,
"X");
2377 hCluster2 ->SetAxisRange(minRow, maxRow,
"Y");
2378 hCluster2 ->Draw(
"colz TEXT");
2380 if(eCluster > 6 )c->Print(Form(
"clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
2381 eventNumber,cluster->E(),nMax,ncells1,ncells2));
2385 delete hClusterLocMax;
Bool_t fRecalculatePosition
Recalculate cluster position.
AliEMCALGeometry * fEMCALGeo
! EMCAL geometry pointer.
void InitPHOSRecalibrationFactors()
Init PHOS recalibration factors.
Bool_t IsRecalculationOfClusterTrackMatchingOn() const
TGeoHMatrix * fEMCALMatrix[22]
Geometry matrices with alignments.
Int_t GetPHOSChannelStatus(Int_t imod, Int_t iCol, Int_t iRow) const
Float_t fLocMaxCutEDiff
Local maxima cut, when aggregating cells, next can be a bit higher.
Bool_t IsAbsIDsFromTCard(Int_t absId1, Int_t absId2, Int_t &rowDiff, Int_t &colDiff) const
TGeoHMatrix * fPHOSMatrix[5]
Geometry matrices with alignments.
Bool_t ClusterContainsBadChannel(Int_t calo, UShort_t *cellList, Int_t nCells)
AliPHOSGeoUtils * fPHOSGeo
! PHOS geometry pointer.
AliEMCALRecoUtils * GetEMCALRecoUtils() const
void SetEMCALL1PhaseInTimeRecalibrationForAllSM(TObjArray *map)
void SwitchOnDistToBadChannelRecalculation()
AliPHOSGeoUtils * GetPHOSGeometry() const
Bool_t fOADBForEMCAL
Get calibration from OADB for EMCAL.
Float_t GetPHOSChannelRecalibrationFactor(Int_t imod, Int_t iCol, Int_t iRow) const
Float_t fLocMaxCutE
Local maxima cut must have more than this energy.
Float_t GetMCECellClusFracCorrection(Float_t eCell, Float_t eCluster) const
void SetEMCALChannelStatusMap(Int_t iSM, TH2I *h)
Bool_t fRunDependentCorrection
Switch on or off the recalibration dependent on T.
TObjArray * fPHOSRecalibrationFactors
Array of histograms with map of recalibration factors, PHOS.
TString fEMCALGeoName
Name of geometry to use for EMCAL.
TH2F * GetEMCALChannelRecalibrationFactors(Int_t iSM) const
Bool_t fRecalibration
Switch on or off the recalibration.
Float_t GetEMCALChannelRecalibrationFactor(Int_t iSM, Int_t iCol, Int_t iRow) const
TH1F * GetEMCALChannelTimeRecalibrationFactors(Int_t bc) const
const TString calorimeter
Int_t fDebug
Debugging level.
TH1C * GetEMCALL1PhaseInTimeRecalibrationForAllSM() const
Bool_t IsRecalibrationOn() const
Bool_t IsMCParticleInCalorimeterAcceptance(Int_t calo, TParticle *particle)
virtual void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Int_t GetModuleNumber(AliAODPWG4Particle *particle, AliVEvent *inputEvent) const
Get the EMCAL/PHOS module number that corresponds to this particle.
Bool_t fLoadEMCALMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
AliEMCALGeometry * GetEMCALGeometry() const
Bool_t IsL1PhaseInTimeRecalibrationOn() const
Bool_t fRecalculateMatching
Recalculate cluster position.
Bool_t MaskFrameCluster(Int_t iSM, Int_t ieta) const
Bool_t fOADBForPHOS
Get calibration from OADB for PHOS.
Int_t * fMaskCellColumns
List of masked cells collumn index.
Bool_t fRemoveBadChannels
Check the channel status provided and remove clusters with bad channels.
void InitPHOSBadChannelStatusMap()
Init PHOS bad channels map.
virtual ~AliCalorimeterUtils()
void RecalculateClusterTrackMatching(AliVEvent *event, TObjArray *clusterArray=0x0, AliMCEvent *mc=0x0)
AliCalorimeterUtils()
Constructor. Initialize parameters.
virtual void InitParameters()
Initialize the parameters of the analysis.
Int_t fNMaskCellColumns
Number of masked columns.
Bool_t IsClusterSharedByTwoSuperModules(const AliEMCALGeometry *geom, AliVCluster *cluster)
Int_t GetNumberOfLocalMaxima(AliVCluster *cluster, AliVCaloCells *cells)
Find the number of local maxima in cluster.
Float_t fMCECellClusFracCorrParam[4]
Parameters for the function correcting the weight of the cells in the cluster.
Bool_t fEMCALGeoMatrixSet
Check if the transformation matrix is set for EMCAL.
TH2I * GetPHOSChannelStatusMap(Int_t imod) const
void SetEMCALChannelRecalibrationFactor(Int_t iSM, Int_t iCol, Int_t iRow, Double_t c=1)
TString GetPass()
Get passx from filename.
void RecalculateClusterPosition(AliVCaloCells *cells, AliVCluster *clu)
Bool_t fImportGeometryFromFile
Import geometry settings in geometry.root file.
Bool_t fCorrectELinearity
Correct cluster energy linearity.
Bool_t fPHOSGeoMatrixSet
Check if the transformation matrix is set for PHOS.
TString fOADBFilePathPHOS
Default path $ALICE_PHYSICS/OADB/PHOS, if needed change.
void CorrectClusterEnergy(AliVCluster *cl)
Correct cluster energy non linearity.
Float_t fCutZ
dZ cut on matching (EMCAL/PHOS).
Bool_t fLoadPHOSMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
void SetPHOSChannelStatusMap(Int_t imod, TH2I *h)
Int_t fNCellsFromPHOSBorder
Number of cells from PHOS border the cell with maximum amplitude has to be.
AliVTrack * GetMatchedTrack(AliVCluster *cluster, AliVEvent *event, Int_t index=-1) const
void RecalibrateCellTimeL1Phase(Double_t &time, Int_t calo, Int_t iSM, Int_t bunchCrossNumber) const
Recalculate time L1 phase shift if time recalibration available for EMCAL.
Bool_t fMCECellClusFracCorrOn
Correct or not the weight of cells in cluster.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Int_t fNSuperModulesUsed
Number of supermodules to be used in analysis, can be different than the real geo, to be used at initialization of histograms.
TString fImportGeometryFilePath
Path fo geometry.root file.
Bool_t fPlotCluster
Plot cluster in splitting method.
Int_t fRunNumber
Run number of the data, take it from data itself unless set by user.
void RecalibrateCellAmplitude(Float_t &, Int_t calo, Int_t absId) const
Recalculate cell energy if recalibration factor.
void SetEMCALChannelTimeRecalibrationFactors(TObjArray *map)
Bool_t IsPHOSGeoMatrixSet() const
Bool_t IsTimeRecalibrationOn() const
Bool_t fOADBSet
AODB parameters already set.
TObjArray * fPHOSBadChannelMap
Array of histograms with map of bad channels, PHOS.
TString fPHOSGeoName
Name of geometry to use for PHOS.
Bool_t AreNeighbours(Int_t calo, Int_t absId1, Int_t absId2) const
Int_t GetEMCALChannelStatus(Int_t iSM, Int_t iCol, Int_t iRow) const
Bool_t IsEMCALGeoMatrixSet() const
Class with utils specific to calorimeter clusters/cells.
void AccessGeometry(AliVEvent *inputEvent)
AliEMCALRecoUtils * fEMCALRecoUtils
EMCAL utils for cluster rereconstruction.
void SetEMCALChannelRecalibrationFactors(Int_t iSM, TH2F *h)
void AccessOADB(AliVEvent *event)
TString fOADBFilePathEMCAL
Default path $ALICE_PHYSICS/OADB/EMCAL, if needed change.
void RecalibrateCellTime(Double_t &time, Int_t calo, Int_t absId, Int_t bunchCrossNumber) const
Recalculate time if time recalibration available for EMCAL not ready for PHOS.
Int_t GetMaxEnergyCell(AliVCaloCells *cells, AliVCluster *clu, Float_t &fraction) const
For a given CaloCluster, it gets the absId of the cell with maximum energy deposit.
Float_t fCutR
dR cut on matching (PHOS).
Float_t RecalibrateClusterEnergyWeightCell(AliVCluster *cluster, AliVCaloCells *cells, Float_t energyOrg)
void SplitEnergy(Int_t absId1, Int_t absId2, AliVCluster *cluster, AliVCaloCells *cells, AliAODCaloCluster *cluster1, AliAODCaloCluster *cluster2, Int_t nMax, Int_t eventNumber=0)
Bool_t GetFECCorrelatedCellAbsId(Int_t absId, Int_t absIdCorr[4]) const
Int_t GetModuleNumberCellIndexes(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU) const
Get the EMCAL/PHOS module, columns, row and RCU/DDL number that corresponds to this absId...
TH2I * GetEMCALChannelStatusMap(Int_t iSM) const
void SetPHOSChannelRecalibrationFactor(Int_t imod, Int_t iCol, Int_t iRow, Double_t c=1)
Float_t RecalibrateClusterEnergy(AliVCluster *cluster, AliVCaloCells *cells)
Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that co...
void GetEMCALSubregion(AliVCluster *clus, AliVCaloCells *cells, Int_t ®Eta, Int_t ®Phi) const
Bool_t CheckCellFiducialRegion(AliVCluster *cluster, AliVCaloCells *cells) const
Int_t GetModuleNumberCellIndexesAbsCaloMap(Int_t absId, Int_t calo, Int_t &icol, Int_t &irow, Int_t &iRCU, Int_t &icolAbs, Int_t &irowAbs) const