17 #include <TGeoManager.h>
23 #include <TParticle.h>
27 #include "AliESDEvent.h"
28 #include "AliMCEvent.h"
30 #include "AliAODPWG4Particle.h"
31 #include "AliVCluster.h"
32 #include "AliVCaloCells.h"
33 #include "AliAODCaloCluster.h"
34 #include "AliOADBContainer.h"
35 #include "AliAnalysisManager.h"
36 #include "AliAODMCParticle.h"
40 #include "AliEMCALGeometry.h"
41 #include "AliPHOSGeoUtils.h"
55 fEMCALGeo(0x0), fPHOSGeo(0x0),
56 fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE),
57 fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE),
58 fRemoveBadChannels(kFALSE), fPHOSBadChannelMap(0x0),
59 fNCellsFromPHOSBorder(0),
60 fNMaskCellColumns(0), fMaskCellColumns(0x0),
61 fRecalibration(kFALSE), fRunDependentCorrection(kFALSE),
62 fPHOSRecalibrationFactors(), fEMCALRecoUtils(new AliEMCALRecoUtils),
63 fRecalculatePosition(kFALSE), fCorrectELinearity(kFALSE),
64 fRecalculateMatching(kFALSE),
66 fCutEta(20), fCutPhi(20),
67 fLocMaxCutE(0), fLocMaxCutEDiff(0),
68 fPlotCluster(0), fOADBSet(kFALSE),
69 fOADBForEMCAL(kFALSE), fOADBForPHOS(kFALSE),
70 fOADBFilePathEMCAL(
""), fOADBFilePathPHOS(
""),
71 fImportGeometryFromFile(0), fImportGeometryFilePath(
""),
72 fNSuperModulesUsed(0), fRunNumber(0),
73 fMCECellClusFracCorrOn(0), fMCECellClusFracCorrParam()
121 Int_t nSM =
fEMCALGeo->GetNumberOfSuperModules();
126 AliOADBContainer *contBC=
new AliOADBContainer(
"");
127 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALBadChannels");
129 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(
fRunNumber);
134 AliInfo(
"Remove EMCAL bad cells");
136 for (Int_t i=0; i<nSM; ++i)
143 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
147 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
151 hbm->SetDirectory(0);
155 }
else AliInfo(
"Do NOT remove EMCAL bad channels\n");
163 AliOADBContainer *contRF=
new AliOADBContainer(
"");
165 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRecalib");
167 TObjArray *recal=(TObjArray*)contRF->GetObject(
fRunNumber);
171 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
175 TObjArray *recalib=(TObjArray*)recalpass->FindObject(
"Recalib");
179 AliInfo(
"Recalibrate EMCAL");
180 for (Int_t i=0; i < nSM; ++i)
187 h = (TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
191 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
199 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
200 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
201 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
212 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
214 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRunDepTempCalibCorrections");
216 TH1S *htd=(TH1S*)contRFTD->GetObject(
fRunNumber);
221 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",
fRunNumber));
225 Int_t maxEntry = contRFTD->GetNumberOfEntries();
227 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) <
fRunNumber) )
233 Int_t closest = lower;
234 if ( (ic<maxEntry) &&
240 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
241 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
246 AliInfo(
"Recalibrate (Temperature) EMCAL");
248 for (Int_t ism=0; ism<nSM; ++ism)
250 for (Int_t icol=0; icol<48; ++icol)
252 for (Int_t irow=0; irow<24; ++irow)
256 Int_t absID =
fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol);
257 factor *= htd->GetBinContent(absID) / 10000. ;
266 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
274 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
276 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALTimeCalib");
278 TObjArray *trecal=(TObjArray*)contTRF->GetObject(
fRunNumber);
282 TString passM = pass;
283 if(pass==
"spc_calo") passM =
"pass3";
284 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
288 AliInfo(
"Time Recalibrate EMCAL");
289 for (Int_t ibc = 0; ibc < 4; ++ibc)
296 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
300 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
308 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
309 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
324 AliOADBContainer badmapContainer(Form(
"phosBadMap"));
325 TString
fileName=
"$ALICE_PHYSICS/OADB/PHOS/PHOSBadMaps.root";
326 badmapContainer.InitFromFile(Form(
"%s/PHOSBadMaps.root",
fOADBFilePathPHOS.Data()),
"phosBadMap");
329 TObjArray *maps = (TObjArray*)badmapContainer.GetObject(139000,
"phosBadMap");
332 AliInfo(Form(
"Can not read PHOS bad map for run %d",
fRunNumber)) ;
336 AliInfo(Form(
"Setting PHOS bad map with name %s",maps->GetName())) ;
338 for(Int_t mod = 1; mod < 5; mod++)
345 hbmPH = (TH2I*)maps->At(mod);
347 if(hbmPH) hbmPH->SetDirectory(0);
377 AliInfo(
"Load user defined EMCAL geometry matrices");
380 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
381 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALgeo");
382 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(
fRunNumber,
"EmcalMatrices");
384 for(Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
388 AliDebug(1,Form(
"EMCAL matrices SM %d, %p", mod,((TGeoHMatrix*) matEMCAL->At(mod))));
403 AliWarning(Form(
"Set matrix for SM %d from gGeoManager",mod));
404 fEMCALGeo->SetMisalMatrix(
fEMCALGeo->GetMatrixForSuperModuleFromGeoManager(mod),mod) ;
408 AliError(Form(
"Alignment atrix for SM %d is not available",mod));
415 else if (!gGeoManager)
417 AliDebug(1,
"Load EMCAL misalignment matrices");
418 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
420 for(Int_t mod = 0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
423 if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod))
425 fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ;
434 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
448 AliInfo(
"Load user defined PHOS geometry matrices");
451 AliOADBContainer geomContainer(
"phosGeo");
452 geomContainer.InitFromFile(Form(
"%s/PHOSGeometry.root",
fOADBFilePathPHOS.Data()),
"PHOSRotationMatrixes");
453 TObjArray *matPHOS = (TObjArray*)geomContainer.GetObject(139000,
"PHOSRotationMatrixes");
455 for(Int_t mod = 0 ; mod < 5 ; mod++)
459 AliDebug(1,Form(
"PHOS matrices module %d, %p",mod,((TGeoHMatrix*) matPHOS->At(mod))));
462 fPHOSMatrix[mod] = (TGeoHMatrix*) matPHOS->At(mod) ;
478 else if (!gGeoManager)
480 AliDebug(1,
"Load PHOS misalignment matrices.");
481 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
483 for(Int_t mod = 0; mod < 5; mod++)
485 if( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod))
488 fPHOSGeo->SetMisalMatrix( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ;
496 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
512 Bool_t areNeighbours = kFALSE ;
514 Int_t iRCU1 = -1, irow1 = -1, icol1 = -1;
515 Int_t iRCU2 = -1, irow2 = -1, icol2 = -1;
517 Int_t rowdiff = 0, coldiff = 0;
522 if(calo==
kEMCAL && nSupMod1!=nSupMod2)
526 if(nSupMod1%2) icol1+=AliEMCALGeoParams::fgkEMCALCols;
527 else icol2+=AliEMCALGeoParams::fgkEMCALCols;
530 rowdiff = TMath::Abs( irow1 - irow2 ) ;
531 coldiff = TMath::Abs( icol1 - icol2 ) ;
534 if ((coldiff + rowdiff == 1 ))
535 areNeighbours = kTRUE ;
537 return areNeighbours;
545 AliVCluster* cluster)
555 for(Int_t iDigit = 0; iDigit < cluster->GetNCells(); iDigit++)
558 geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
559 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
562 if (iDigit == 0 ) iSM0 = iSupMod;
563 else if(iSupMod != iSM0)
565 if(iSupMod > 11 && iSupMod < 18)
566 AliWarning(Form(
"Cluster shared in 2 DCal: SM%d, SM%d??",iSupMod,iSM0));
580 AliVCaloCells* cells)
const
584 if ( cells->GetType()==AliVCaloCells::kEMCALCell &&
fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 )
return kTRUE;
591 for(Int_t i = 0; i < cluster->GetNCells() ; i++)
593 Int_t absId = cluster->GetCellAbsId(i) ;
594 Float_t amp = cells->GetCellAmplitude(absId);
603 AliDebug(1,Form(
"Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f",
604 absIdMax, ampMax, cluster->E()));
606 if ( absIdMax == -1 )
return kFALSE;
609 Bool_t okrow = kFALSE;
610 Bool_t okcol = kFALSE;
612 if ( cells->GetType() == AliVCaloCells::kEMCALCell )
617 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
619 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
621 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
623 if(iSM < 0 || iphi < 0 || ieta < 0 )
625 AliFatal(Form(
"Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name",iSM,ieta,iphi));
631 if ( iSM < 10 || (iSM > 11 && iSM < 18) )
633 if(iphi >= nborder && iphi < 24-nborder) okrow = kTRUE;
637 if(iphi >= nborder && iphi < 8-nborder) okrow = kTRUE;
643 if(!
fEMCALRecoUtils->IsEMCALNoBorderAtEta0() || (iSM > 11 && iSM < 18))
645 if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE;
651 if(ieta >= nborder) okcol = kTRUE;
655 if(ieta < 48-nborder) okcol = kTRUE;
659 AliDebug(1,Form(
"EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
660 nborder, ieta, iphi, iSM,okrow,okcol));
663 else if ( cells->GetType() == AliVCaloCells::kPHOSCell )
666 Int_t irow = -1, icol = -1;
667 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
672 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
673 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
675 AliDebug(1,Form(
"PHOS Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
676 fNCellsFromPHOSBorder, icol, irow, relId[0]-1,okrow,okcol));
679 if (okcol && okrow)
return kTRUE;
698 for(Int_t iCell = 0; iCell<nCells; iCell++)
701 if ( calorimeter ==
kEMCAL )
705 else if ( calorimeter ==
kPHOS )
708 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
737 Float_t & clusterFraction)
const
741 AliInfo(
"Cluster or cells pointer is null!");
748 Float_t fraction = 1.;
749 Float_t recalFactor = 1.;
750 Int_t cellAbsId =-1 , absId =-1 ;
751 Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1;
754 if(clu->IsPHOS()) calo =
kPHOS ;
756 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++)
758 cellAbsId = clu->GetCellAbsId(iDig);
760 fraction = clu->GetCellAmplitudeFraction(iDig);
761 if(fraction < 1e-4) fraction = 1.;
771 eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
784 clusterFraction = (eTot-eMax)/eTot;
797 AliVEvent* event, Int_t index)
const
799 AliVTrack *track = 0x0;
806 Int_t trackIndex =
fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID());
810 AliInfo(Form(
"Wrong track index %d, from recalculation", trackIndex));
812 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(trackIndex));
822 if( cluster->GetNTracksMatched() < 1 )
return 0x0;
828 if(!strcmp(
"AliESDCaloCluster",Form(
"%s",cluster->ClassName())))
830 if( index >= 0 ) iTrack = index;
831 else iTrack = cluster->GetTrackMatchedIndex();
833 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(iTrack) );
837 if( index > 0 ) iTrack = index;
839 track =
dynamic_cast<AliVTrack*
>( cluster->GetTrackMatched(iTrack) );
851 if( eCluster <= 0 || eCluster < eCell )
853 AliWarning(Form(
"Bad values eCell=%f, eCluster %f",eCell,eCluster));
857 Float_t frac = eCell / eCluster;
877 if(particle->GetDetectorTag()==
kEMCAL)
879 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
881 AliDebug(2,Form(
"EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d",
882 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
884 return fEMCALGeo->GetSuperModuleNumber(absId) ;
886 else if ( particle->GetDetectorTag() ==
kPHOS )
890 if(strcmp(inputEvent->ClassName(),
"AliMCEvent") == 0 )
893 Double_t z = 0., x=0.;
894 TParticle* primary = 0x0;
895 AliStack * stack = ((AliMCEvent*)inputEvent)->Stack();
899 primary = stack->Particle(particle->GetCaloLabel(0));
903 AliFatal(
"Stack not available, stop!");
908 fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ;
912 AliFatal(
"Primary not available, stop!");
937 AliDebug(1,
"AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!");
942 if ( cluster->GetNCells() <= 0 )
return -1;
944 Int_t absId = cluster->GetCellAbsId(0);
946 if ( absId < 0 )
return -1;
948 if( cluster->IsEMCAL() )
950 AliDebug(2,Form(
"EMCAL absid %d, SuperModule %d",absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
952 return fEMCALGeo->GetSuperModuleNumber(absId) ;
954 else if ( cluster->IsPHOS() )
957 fPHOSGeo->AbsToRelNumbering(absId,relId);
959 AliDebug(2,Form(
"PHOS absid %d Module %d",absId, relId[0]-1));
971 Int_t & icol, Int_t & irow, Int_t & iRCU)
const
975 if ( absId < 0 )
return -1 ;
979 Int_t iTower = -1, iIphi = -1, iIeta = -1;
980 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
981 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
983 if(imod < 0 || irow < 0 || icol < 0 )
985 AliFatal(Form(
"Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name",imod,icol,irow));
992 if ( imod == 13 || imod == 15 || imod == 17 ) ico2 += 16;
995 if(imod < 10 || (imod > 11 && imod < 18))
998 if ( 0 <= irow && irow < 8 ) iRCU = 0;
999 else if ( 8 <= irow && irow < 16 &&
1000 0 <= ico2 && ico2 < 24 ) iRCU = 0;
1004 else if ( 8 <= irow && irow < 16 &&
1005 24 <= ico2 && ico2 < 48 ) iRCU = 1;
1007 else if ( 16 <= irow && irow < 24 ) iRCU = 1;
1009 if ( imod%2 == 1 ) iRCU = 1 - iRCU;
1018 AliFatal(Form(
"Wrong EMCAL RCU number = %d", iRCU));
1025 fPHOSGeo->AbsToRelNumbering(absId,relId);
1030 iRCU= (Int_t)(relId[2]-1)/16 ;
1035 AliFatal(Form(
"Wrong PHOS RCU number = %d", iRCU));
1048 const Int_t nc = cluster->GetNCells();
1050 Int_t absIdList[nc];
1051 Float_t maxEList[nc];
1062 Int_t *absIdList, Float_t *maxEList)
1068 const Int_t nCells = cluster->GetNCells();
1072 Float_t simuTotWeight = 0;
1076 simuTotWeight/= eCluster;
1080 if(!cluster->IsEMCAL()) calorimeter =
kPHOS;
1086 for(iDigit = 0; iDigit < nCells ; iDigit++)
1088 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ;
1089 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1098 idmax = absIdList[iDigit] ;
1105 for(iDigit = 0 ; iDigit < nCells; iDigit++)
1107 if( absIdList[iDigit] >= 0 )
1109 absId1 = cluster->GetCellsAbsId()[iDigit];
1111 Float_t en1 = cells->GetCellAmplitude(absId1);
1119 for(iDigitN = 0; iDigitN < nCells; iDigitN++)
1121 absId2 = cluster->GetCellsAbsId()[iDigitN] ;
1123 if(absId2==-1 || absId2==absId1)
continue;
1127 Float_t en2 = cells->GetCellAmplitude(absId2);
1140 absIdList[iDigitN] = -1 ;
1145 absIdList[iDigit] = -1 ;
1150 absIdList[iDigit] = -1 ;
1155 absIdList[iDigitN] = -1 ;
1166 for(iDigit = 0; iDigit < nCells; iDigit++)
1168 if( absIdList[iDigit] >= 0 )
1170 absIdList[iDigitN] = absIdList[iDigit] ;
1172 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1180 maxEList[iDigitN] = en ;
1189 AliDebug(1,Form(
"No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f",
1190 idmax,emax,cluster->E()));
1192 maxEList[0] = emax ;
1193 absIdList[0] = idmax ;
1197 AliDebug(1,Form(
"In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d",
1198 cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN));
1213 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1215 AliError(
"AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null");
1219 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1221 AliError(
"AliCalorimeterUtils::GetPass() - Null pointer input file, returning null");
1225 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1226 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1227 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1228 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1229 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1230 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1231 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1232 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1234 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1235 return TString(
"pass1");
1239 AliInfo(
"Pass number string not found");
1291 AliDebug(1,
"Init bad channel map");
1294 Bool_t oldStatus = TH1::AddDirectoryStatus();
1295 TH1::AddDirectory(kFALSE);
1298 for (
int i = 0; i < 5; i++)
fPHOSBadChannelMap->Add(
new TH2I(Form(
"PHOS_BadMap_mod%d",i),
1299 Form(
"PHOS_BadMap_mod%d",i),
1300 64, 0, 64, 56, 0, 56));
1306 TH1::AddDirectory(oldStatus);
1314 AliDebug(1,
"Init recalibration map");
1317 Bool_t oldStatus = TH1::AddDirectoryStatus();
1318 TH1::AddDirectory(kFALSE);
1321 for (
int i = 0; i < 5; i++)
1324 Form(
"PHOSRecalFactors_Mod%d",i),
1325 64, 0, 64, 56, 0, 56));
1329 for (Int_t m = 0; m < 5; m++)
1331 for (Int_t i = 0; i < 56; i++)
1333 for (Int_t j = 0; j < 64; j++)
1344 TH1::AddDirectory(oldStatus);
1359 AliInfo(Form(
"Get EMCAL geometry name to <%s> for run %d",
fEMCALGeo->GetName(),
fRunNumber));
1364 AliInfo(Form(
"Set EMCAL geometry name to <%s>",
fEMCALGeoName.Data()));
1383 else if (!gGeoManager) AliInfo(
"Careful!, gGeoManager not loaded, load misalign matrices");
1407 if(!particle || (calo!=
kEMCAL && calo!=
kPHOS))
return kFALSE ;
1412 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1419 Double_t x = 0, z = 0 ;
1425 Bool_t ok =
GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID);
1428 Int_t icol = -1, irow = -1, iRCU = -1;
1431 if(status > 0) ok = kFALSE;
1445 if(!particle || (calo!=
kEMCAL && calo!=
kPHOS))
return kFALSE ;
1450 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1454 Float_t phi = particle->Phi();
1455 if(phi < 0) phi+=TMath::TwoPi();
1460 Double_t x = 0, z = 0 ;
1461 Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1462 return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1467 Bool_t ok =
GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID);
1470 Int_t icol = -1, irow = -1, iRCU = -1;
1473 if(status > 0) ok = kFALSE;
1486 Float_t phiOrg, Int_t & absID)
1493 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1497 Float_t phi = phiOrg;
1498 if(phi < 0) phi+=TMath::TwoPi();
1503 Double_t x = 0, z = 0 ;
1504 Double_t vtx[]={0,0,0} ;
1512 Int_t icol = -1, irow = -1, iRCU = -1;
1515 if(status > 0) ok = kFALSE;
1531 if ( iSM%2 ) icol+=48;
1552 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1554 printf(
"Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1556 if(
fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf(
"Do not remove EMCAL clusters at Eta = 0\n");
1560 printf(
"Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",
fCutR,
fCutZ);
1573 Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1;
1604 AliVCaloCells * cells)
1607 Float_t frac = 0.,
energy = 0.;
1613 UShort_t * index = cluster->GetCellsAbsId() ;
1614 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1616 Int_t ncells = cluster->GetNCells();
1619 if(cluster->IsPHOS()) calo =
kPHOS ;
1622 for(Int_t icell = 0; icell < ncells; icell++)
1624 Int_t absId = index[icell];
1626 frac = fraction[icell];
1627 if(frac < 1e-3) frac = 1;
1629 Float_t amp = cells->GetCellAmplitude(absId);
1632 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1633 calo,frac,cells->GetCellAmplitude(absId),amp));
1638 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),
energy));
1643 AliFatal(
"Cells pointer does not exist!");
1654 AliVCaloCells * cells, Float_t energyOrg)
1657 Float_t frac = 0.,
energy = 0.;
1663 UShort_t * index = cluster->GetCellsAbsId() ;
1664 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1666 Int_t ncells = cluster->GetNCells();
1669 if(cluster->IsPHOS()) calo =
kPHOS ;
1672 for(Int_t icell = 0; icell < ncells; icell++)
1674 Int_t absId = index[icell];
1676 frac = fraction[icell];
1677 if(frac < 1e-3) frac = 1;
1679 Float_t amp = cells->GetCellAmplitude(absId);
1684 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
1685 calo,frac,cells->GetCellAmplitude(absId)));
1690 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),
energy));
1694 AliFatal(
"Cells pointer does not exist!");
1712 TObjArray* clusterArray)
1740 AliVCluster* cluster,
1741 AliVCaloCells* cells,
1743 AliAODCaloCluster* cluster1,
1744 AliAODCaloCluster* cluster2,
1745 Int_t nMax, Int_t eventNumber)
1747 TH2F* hClusterMap = 0 ;
1748 TH2F* hClusterLocMax = 0 ;
1749 TH2F* hCluster1 = 0 ;
1750 TH2F* hCluster2 = 0 ;
1754 hClusterMap =
new TH2F(
"hClusterMap",
"Cluster Map",48,0,48,24,0,24);
1755 hClusterLocMax =
new TH2F(
"hClusterLocMax",
"Cluster 2 highest local maxima",48,0,48,24,0,24);
1756 hCluster1 =
new TH2F(
"hCluster1",
"Cluster 1",48,0,48,24,0,24);
1757 hCluster2 =
new TH2F(
"hCluster2",
"Cluster 2",48,0,48,24,0,24);
1758 hClusterMap ->SetXTitle(
"column");
1759 hClusterMap ->SetYTitle(
"row");
1760 hClusterLocMax ->SetXTitle(
"column");
1761 hClusterLocMax ->SetYTitle(
"row");
1762 hCluster1 ->SetXTitle(
"column");
1763 hCluster1 ->SetYTitle(
"row");
1764 hCluster2 ->SetXTitle(
"column");
1765 hCluster2 ->SetYTitle(
"row");
1769 if(cluster->IsPHOS())
1772 AliWarning(
"Not supported for PHOS yet");
1776 const Int_t ncells = cluster->GetNCells();
1777 Int_t absIdList[ncells];
1779 Float_t e1 = 0, e2 = 0 ;
1780 Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
1781 Float_t eCluster = 0;
1782 Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
1783 for(Int_t iDigit = 0; iDigit < ncells; iDigit++ )
1785 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
1787 Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
1795 if(sm > -1 && sm < 12)
1797 if(icol > maxCol) maxCol = icol;
1798 if(icol < minCol) minCol = icol;
1799 if(irow > maxRow) maxRow = irow;
1800 if(irow < minRow) minRow = irow;
1801 hClusterMap->Fill(icol,irow,ec);
1808 UShort_t absIdList1[9] ;
1809 Double_t fracList1 [9] ;
1810 absIdList1[0] = absId1 ;
1811 fracList1 [0] = 1. ;
1813 Float_t ecell1 = cells->GetCellAmplitude(absId1);
1818 UShort_t absIdList2[9] ;
1819 Double_t fracList2 [9] ;
1820 absIdList2[0] = absId2 ;
1821 fracList2 [0] = 1. ;
1823 Float_t ecell2 = cells->GetCellAmplitude(absId2);
1829 Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
1831 hClusterLocMax->Fill(icol1,irow1,ecell1);
1833 hClusterLocMax->Fill(icol2,irow2,ecell2);
1837 Float_t eRemain = (eCluster-ecell1-ecell2)/2;
1838 Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
1839 Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
1841 for(Int_t iDigit = 0; iDigit < ncells; iDigit++)
1843 Int_t absId = absIdList[iDigit];
1845 if ( absId==absId1 || absId==absId2 || absId < 0 )
continue;
1847 Float_t ecell = cells->GetCellAmplitude(absId);
1852 absIdList1[ncells1]= absId;
1856 fracList1[ncells1] = shareFraction1;
1857 e1 += ecell*shareFraction1;
1861 fracList1[ncells1] = 1.;
1871 absIdList2[ncells2]= absId;
1875 fracList2[ncells2] = shareFraction2;
1876 e2 += ecell*shareFraction2;
1880 fracList2[ncells2] = 1.;
1889 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",
1890 nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
1895 cluster1->SetNCells(ncells1);
1896 cluster2->SetNCells(ncells2);
1898 cluster1->SetCellsAbsId(absIdList1);
1899 cluster2->SetCellsAbsId(absIdList2);
1901 cluster1->SetCellsAmplitudeFraction(fracList1);
1902 cluster2->SetCellsAmplitudeFraction(fracList2);
1917 for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
1923 Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
1926 if(
AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
1927 hCluster1->Fill(icol,irow,ecell*shareFraction1);
1929 hCluster1->Fill(icol,irow,ecell);
1935 for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
1941 Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
1944 if(
AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
1945 hCluster2->Fill(icol,irow,ecell*shareFraction2);
1947 hCluster2->Fill(icol,irow,ecell);
1951 gStyle->SetPadRightMargin(0.1);
1952 gStyle->SetPadLeftMargin(0.1);
1953 gStyle->SetOptStat(0);
1954 gStyle->SetOptFit(000000);
1956 if(maxCol-minCol > maxRow-minRow)
1958 maxRow+= maxCol-minCol;
1962 maxCol+= maxRow-minRow;
1965 TCanvas * c=
new TCanvas(
"canvas",
"canvas", 4000, 4000) ;
1971 hClusterMap ->SetAxisRange(minCol, maxCol,
"X");
1972 hClusterMap ->SetAxisRange(minRow, maxRow,
"Y");
1973 hClusterMap ->Draw(
"colz TEXT");
1978 hClusterLocMax ->SetAxisRange(minCol, maxCol,
"X");
1979 hClusterLocMax ->SetAxisRange(minRow, maxRow,
"Y");
1980 hClusterLocMax ->Draw(
"colz TEXT");
1985 hCluster1 ->SetAxisRange(minCol, maxCol,
"X");
1986 hCluster1 ->SetAxisRange(minRow, maxRow,
"Y");
1987 hCluster1 ->Draw(
"colz TEXT");
1992 hCluster2 ->SetAxisRange(minCol, maxCol,
"X");
1993 hCluster2 ->SetAxisRange(minRow, maxRow,
"Y");
1994 hCluster2 ->Draw(
"colz TEXT");
1996 if(eCluster > 6 )c->Print(Form(
"clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
1997 eventNumber,cluster->E(),nMax,ncells1,ncells2));
2001 delete hClusterLocMax;
Bool_t fRecalculatePosition
Recalculate cluster position.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
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.
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 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
void RecalculateClusterTrackMatching(AliVEvent *event, TObjArray *clusterArray=0x0)
Recalculate track matching.
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.
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 fRecalculateMatching
Recalculate cluster position.
Bool_t MaskFrameCluster(Int_t iSM, Int_t ieta) const
Int_t GetMaxEnergyCell(AliVCaloCells *cells, const AliVCluster *clu, Float_t &fraction) const
For a given CaloCluster, it gets the absId of the cell with maximum energy deposit.
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()
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)
Recalculate EMCAL cluster position.
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
Bool_t fMCECellClusFracCorrOn
Correct or not the weight of cells in cluster.
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.
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)
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...
Bool_t CheckCellFiducialRegion(AliVCluster *cluster, AliVCaloCells *cells) const