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()
119 Int_t nSM =
fEMCALGeo->GetNumberOfSuperModules();
124 AliOADBContainer *contBC=
new AliOADBContainer(
"");
125 contBC->InitFromFile(Form(
"%s/EMCALBadChannels.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALBadChannels");
127 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(
fRunNumber);
132 AliInfo(
"Remove EMCAL bad cells");
134 for (Int_t i=0; i<nSM; ++i)
141 hbm=(TH2I*)arrayBC->FindObject(Form(
"EMCALBadChannelMap_Mod%d",i));
145 AliError(Form(
"Can not get EMCALBadChannelMap_Mod%d",i));
149 hbm->SetDirectory(0);
153 }
else AliInfo(
"Do NOT remove EMCAL bad channels\n");
159 AliOADBContainer *contRF=
new AliOADBContainer(
"");
161 contRF->InitFromFile(Form(
"%s/EMCALRecalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRecalib");
163 TObjArray *recal=(TObjArray*)contRF->GetObject(
fRunNumber);
167 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
171 TObjArray *recalib=(TObjArray*)recalpass->FindObject(
"Recalib");
175 AliInfo(
"Recalibrate EMCAL");
176 for (Int_t i=0; i < nSM; ++i)
183 h = (TH2F*)recalib->FindObject(Form(
"EMCALRecalFactors_SM%d",i));
187 AliError(Form(
"Could not load EMCALRecalFactors_SM%d",i));
195 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params object array");
196 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for pass");
197 }
else AliInfo(
"Do NOT recalibrate EMCAL, no params for run");
207 AliOADBContainer *contRFTD=
new AliOADBContainer(
"");
209 contRFTD->InitFromFile(Form(
"%s/EMCALTemperatureCorrCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALRunDepTempCalibCorrections");
211 TH1S *htd=(TH1S*)contRFTD->GetObject(
fRunNumber);
216 AliWarning(Form(
"No TemperatureCorrCalib Objects for run: %d",
fRunNumber));
220 Int_t maxEntry = contRFTD->GetNumberOfEntries();
222 while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) <
fRunNumber) ) {
227 Int_t closest = lower;
228 if ( (ic<maxEntry) &&
233 AliWarning(Form(
"TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest)));
234 htd = (TH1S*) contRFTD->GetObjectByIndex(closest);
239 AliInfo(
"Recalibrate (Temperature) EMCAL");
241 for (Int_t ism=0; ism<nSM; ++ism)
243 for (Int_t icol=0; icol<48; ++icol)
245 for (Int_t irow=0; irow<24; ++irow)
249 Int_t absID =
fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol);
250 factor *= htd->GetBinContent(absID) / 10000. ;
257 }
else AliInfo(
"Do NOT recalibrate EMCAL with T variations, no params TH1");
263 AliOADBContainer *contTRF=
new AliOADBContainer(
"");
265 contTRF->InitFromFile(Form(
"%s/EMCALTimeCalib.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALTimeCalib");
267 TObjArray *trecal=(TObjArray*)contTRF->GetObject(
fRunNumber);
271 TString passM = pass;
272 if(pass==
"spc_calo") passM =
"pass3";
273 TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM);
277 AliInfo(
"Time Recalibrate EMCAL");
278 for (Int_t ibc = 0; ibc < 4; ++ibc)
285 h = (TH1F*)trecalpass->FindObject(Form(
"hAllTimeAvBC%d",ibc));
289 AliError(Form(
"Could not load hAllTimeAvBC%d",ibc));
297 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for pass");
298 }
else AliInfo(
"Do NOT recalibrate time EMCAL, no params for run");
312 AliOADBContainer badmapContainer(Form(
"phosBadMap"));
313 TString fileName=
"$ALICE_PHYSICS/OADB/PHOS/PHOSBadMaps.root";
314 badmapContainer.InitFromFile(Form(
"%s/PHOSBadMaps.root",
fOADBFilePathPHOS.Data()),
"phosBadMap");
317 TObjArray *maps = (TObjArray*)badmapContainer.GetObject(139000,
"phosBadMap");
320 AliInfo(Form(
"Can not read PHOS bad map for run %d",
fRunNumber)) ;
324 AliInfo(Form(
"Setting PHOS bad map with name %s",maps->GetName())) ;
325 for(Int_t mod=1; mod<5;mod++)
332 hbmPH = (TH2I*)maps->At(mod);
334 if(hbmPH) hbmPH->SetDirectory(0);
363 AliInfo(
"Load user defined EMCAL geometry matrices");
366 AliOADBContainer emcGeoMat(
"AliEMCALgeo");
367 emcGeoMat.InitFromFile(Form(
"%s/EMCALlocal2master.root",
fOADBFilePathEMCAL.Data()),
"AliEMCALgeo");
368 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(
fRunNumber,
"EmcalMatrices");
370 for(Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
374 AliDebug(1,Form(
"EMCAL matrices SM %d, %p", mod,((TGeoHMatrix*) matEMCAL->At(mod))));
392 else if (!gGeoManager)
394 AliDebug(1,
"Load EMCAL misalignment matrices");
395 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
397 for(Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
400 if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod))
402 fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ;
411 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
425 AliInfo(
"Load user defined PHOS geometry matrices");
428 AliOADBContainer geomContainer(
"phosGeo");
429 geomContainer.InitFromFile(Form(
"%s/PHOSGeometry.root",
fOADBFilePathPHOS.Data()),
"PHOSRotationMatrixes");
430 TObjArray *matPHOS = (TObjArray*)geomContainer.GetObject(139000,
"PHOSRotationMatrixes");
432 for(Int_t mod = 0 ; mod < 5 ; mod++)
436 AliDebug(1,Form(
"PHOS matrices module %d, %p",mod,((TGeoHMatrix*) matPHOS->At(mod))));
439 fPHOSMatrix[mod] = (TGeoHMatrix*) matPHOS->At(mod) ;
455 else if (!gGeoManager)
457 AliDebug(1,
"Load PHOS misalignment matrices.");
458 if(!strcmp(inputEvent->GetName(),
"AliESDEvent"))
460 for(Int_t mod = 0; mod < 5; mod++)
462 if( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod))
465 fPHOSGeo->SetMisalMatrix( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ;
472 AliDebug(1,
"Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file");
488 Bool_t areNeighbours = kFALSE ;
490 Int_t iRCU1 = -1, irow1 = -1, icol1 = -1;
491 Int_t iRCU2 = -1, irow2 = -1, icol2 = -1;
493 Int_t rowdiff = 0, coldiff = 0;
498 if(calo==
kEMCAL && nSupMod1!=nSupMod2)
502 if(nSupMod1%2) icol1+=AliEMCALGeoParams::fgkEMCALCols;
503 else icol2+=AliEMCALGeoParams::fgkEMCALCols;
506 rowdiff = TMath::Abs( irow1 - irow2 ) ;
507 coldiff = TMath::Abs( icol1 - icol2 ) ;
510 if ((coldiff + rowdiff == 1 ))
511 areNeighbours = kTRUE ;
513 return areNeighbours;
521 AliVCluster* cluster)
531 for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++)
534 geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
535 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
538 if (iDigit == 0 ) iSM0 = iSupMod;
539 else if(iSupMod!= iSM0)
return kTRUE;
550 AliVCaloCells* cells)
const
553 if(cells->GetType()==AliVCaloCells::kEMCALCell &&
fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 )
return kTRUE;
559 for(Int_t i = 0; i < cluster->GetNCells() ; i++)
561 Int_t absId = cluster->GetCellAbsId(i) ;
562 Float_t amp = cells->GetCellAmplitude(absId);
570 AliDebug(1,Form(
"Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f",
571 absIdMax, ampMax, cluster->E()));
573 if(absIdMax==-1)
return kFALSE;
576 Bool_t okrow = kFALSE;
577 Bool_t okcol = kFALSE;
579 if(cells->GetType()==AliVCaloCells::kEMCALCell)
581 Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
582 fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
583 fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
584 if(iSM < 0 || iphi < 0 || ieta < 0 )
586 AliFatal(Form(
"Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name",iSM,ieta,iphi));
593 if(iphi >= nborder && iphi < 24-nborder) okrow =kTRUE;
599 if(iphi >= nborder && iphi < 8-nborder) okrow =kTRUE;
603 if(iphi >= nborder && iphi <12-nborder) okrow =kTRUE;
610 if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE;
616 if(ieta >= nborder) okcol = kTRUE;
620 if(ieta < 48-nborder) okcol = kTRUE;
624 AliDebug(1,Form(
"EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
625 nborder, ieta, iphi, iSM,okrow,okcol));
628 else if ( cells->GetType() == AliVCaloCells::kPHOSCell )
631 Int_t irow = -1, icol = -1;
632 fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
637 if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
638 if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
640 AliDebug(1,Form(
"PHOS Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ? ok row %d, ok column %d",
641 fNCellsFromPHOSBorder, icol, irow, relId[0]-1,okrow,okcol));
644 if (okcol && okrow)
return kTRUE;
662 for(Int_t iCell = 0; iCell<nCells; iCell++){
665 if(calorimeter ==
kEMCAL){
668 else if(calorimeter==
kPHOS){
670 fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId);
698 Float_t & clusterFraction)
const
702 AliInfo(
"Cluster or cells pointer is null!");
709 Float_t fraction = 1.;
710 Float_t recalFactor = 1.;
711 Int_t cellAbsId =-1 , absId =-1 ;
712 Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1;
715 if(clu->IsPHOS()) calo =
kPHOS ;
717 for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
719 cellAbsId = clu->GetCellAbsId(iDig);
721 fraction = clu->GetCellAmplitudeFraction(iDig);
722 if(fraction < 1e-4) fraction = 1.;
731 eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor;
743 clusterFraction = (eTot-eMax)/eTot;
756 AliVEvent* event, Int_t index)
const
758 AliVTrack *track = 0x0;
765 Int_t trackIndex =
fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID());
769 AliInfo(Form(
"Wrong track index %d, from recalculation", trackIndex));
771 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(trackIndex));
781 if( cluster->GetNTracksMatched() < 1 )
return 0x0;
787 if(!strcmp(
"AliESDCaloCluster",Form(
"%s",cluster->ClassName())))
789 if( index >= 0 ) iTrack = index;
790 else iTrack = cluster->GetTrackMatchedIndex();
792 track =
dynamic_cast<AliVTrack*
> (
event->GetTrack(iTrack) );
796 if( index > 0 ) iTrack = index;
798 track =
dynamic_cast<AliVTrack*
>( cluster->GetTrackMatched(iTrack) );
810 if( eCluster <= 0 || eCluster < eCell )
812 AliWarning(Form(
"Bad values eCell=%f, eCluster %f",eCell,eCluster));
816 Float_t frac = eCell / eCluster;
835 if(particle->GetDetectorTag()==
kEMCAL)
837 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
839 AliDebug(2,Form(
"EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d",
840 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
842 return fEMCALGeo->GetSuperModuleNumber(absId) ;
844 else if(particle->GetDetectorTag()==
kPHOS)
848 if(strcmp(inputEvent->ClassName(),
"AliMCEvent") == 0 )
851 Double_t z = 0., x=0.;
852 TParticle* primary = 0x0;
853 AliStack * stack = ((AliMCEvent*)inputEvent)->Stack();
856 primary = stack->Particle(particle->GetCaloLabel(0));
860 AliFatal(
"Stack not available, stop!");
865 fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ;
869 AliFatal(
"Primary not available, stop!");
894 AliDebug(1,
"AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!");
899 if ( cluster->GetNCells() <= 0 )
return -1;
901 Int_t absId = cluster->GetCellAbsId(0);
903 if ( absId < 0 )
return -1;
905 if( cluster->IsEMCAL() )
907 AliDebug(2,Form(
"EMCAL absid %d, SuperModule %d",absId,
fEMCALGeo->GetSuperModuleNumber(absId)));
909 return fEMCALGeo->GetSuperModuleNumber(absId) ;
911 else if ( cluster->IsPHOS() )
914 fPHOSGeo->AbsToRelNumbering(absId,relId);
916 AliDebug(2,Form(
"PHOS absid %d Module %d",absId, relId[0]-1));
928 Int_t & icol, Int_t & irow, Int_t & iRCU)
const
932 if ( absId < 0)
return -1 ;
936 Int_t iTower = -1, iIphi = -1, iIeta = -1;
937 fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta);
938 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol);
940 if(imod < 0 || irow < 0 || icol < 0 )
942 AliFatal(Form(
"Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name",imod,icol,irow));
948 if (0<=irow&&irow<8) iRCU=0;
949 else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0;
952 else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1;
954 else if (16<=irow&&irow<24) iRCU=1;
956 if (imod%2==1) iRCU = 1 - iRCU;
966 AliFatal(Form(
"Wrong EMCAL RCU number = %d", iRCU));
975 fPHOSGeo->AbsToRelNumbering(absId,relId);
979 iRCU= (Int_t)(relId[2]-1)/16 ;
983 AliFatal(Form(
"Wrong PHOS RCU number = %d", iRCU));
996 const Int_t nc = cluster->GetNCells();
998 Float_t maxEList[nc];
1009 Int_t *absIdList, Float_t *maxEList)
1015 const Int_t nCells = cluster->GetNCells();
1019 Float_t simuTotWeight = 0;
1023 simuTotWeight/= eCluster;
1026 Int_t calorimeter =
kEMCAL;
1027 if(!cluster->IsEMCAL()) calorimeter =
kPHOS;
1033 for(iDigit = 0; iDigit < nCells ; iDigit++)
1035 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ;
1036 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1045 idmax = absIdList[iDigit] ;
1052 for(iDigit = 0 ; iDigit < nCells; iDigit++)
1054 if(absIdList[iDigit]>=0)
1056 absId1 = cluster->GetCellsAbsId()[iDigit];
1058 Float_t en1 = cells->GetCellAmplitude(absId1);
1066 for(iDigitN = 0; iDigitN < nCells; iDigitN++)
1068 absId2 = cluster->GetCellsAbsId()[iDigitN] ;
1070 if(absId2==-1 || absId2==absId1)
continue;
1074 Float_t en2 = cells->GetCellAmplitude(absId2);
1087 absIdList[iDigitN] = -1 ;
1092 absIdList[iDigit] = -1 ;
1097 absIdList[iDigit] = -1 ;
1102 absIdList[iDigitN] = -1 ;
1113 for(iDigit = 0; iDigit < nCells; iDigit++)
1115 if(absIdList[iDigit]>=0 )
1117 absIdList[iDigitN] = absIdList[iDigit] ;
1119 Float_t en = cells->GetCellAmplitude(absIdList[iDigit]);
1127 maxEList[iDigitN] = en ;
1136 AliDebug(1,Form(
"No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f",
1137 idmax,emax,cluster->E()));
1139 maxEList[0] = emax ;
1140 absIdList[0] = idmax ;
1144 AliDebug(1,Form(
"In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d",
1145 cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN));
1161 if (!AliAnalysisManager::GetAnalysisManager()->GetTree())
1163 AliError(
"AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null");
1167 if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile())
1169 AliError(
"AliCalorimeterUtils::GetPass() - Null pointer input file, returning null");
1173 TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1174 if (pass.Contains(
"ass1"))
return TString(
"pass1");
1175 else if (pass.Contains(
"ass2"))
return TString(
"pass2");
1176 else if (pass.Contains(
"ass3"))
return TString(
"pass3");
1177 else if (pass.Contains(
"ass4"))
return TString(
"pass4");
1178 else if (pass.Contains(
"ass5"))
return TString(
"pass5");
1179 else if (pass.Contains(
"LHC11c") && pass.Contains(
"spc_calo") )
return TString(
"spc_calo");
1180 else if (pass.Contains(
"calo") || pass.Contains(
"high_lumi"))
1182 AliInfo(
"Path contains <calo> or <high-lumi>, set as <pass1>");
1183 return TString(
"pass1");
1187 AliInfo(
"Pass number string not found");
1239 AliDebug(1,
"Init bad channel map");
1242 Bool_t oldStatus = TH1::AddDirectoryStatus();
1243 TH1::AddDirectory(kFALSE);
1246 for (
int i = 0; i < 5; i++)
fPHOSBadChannelMap->Add(
new TH2I(Form(
"PHOS_BadMap_mod%d",i),Form(
"PHOS_BadMap_mod%d",i), 64, 0, 64, 56, 0, 56));
1252 TH1::AddDirectory(oldStatus);
1260 AliDebug(1,
"Init recalibration map");
1263 Bool_t oldStatus = TH1::AddDirectoryStatus();
1264 TH1::AddDirectory(kFALSE);
1267 for (
int i = 0; i < 5; i++)
fPHOSRecalibrationFactors->Add(
new TH2F(Form(
"PHOSRecalFactors_Mod%d",i),Form(
"PHOSRecalFactors_Mod%d",i), 64, 0, 64, 56, 0, 56));
1269 for (Int_t m = 0; m < 5; m++) {
1270 for (Int_t i = 0; i < 56; i++) {
1271 for (Int_t j = 0; j < 64; j++) {
1281 TH1::AddDirectory(oldStatus);
1321 else if (!gGeoManager) AliInfo(
"Careful!, gGeoManager not loaded, load misalign matrices");
1346 if(!particle || (calo!=
kEMCAL && calo!=
kPHOS))
return kFALSE ;
1351 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1358 Double_t x = 0, z = 0 ;
1364 Bool_t ok =
GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID);
1367 Int_t icol = -1, irow = -1, iRCU = -1;
1370 if(status > 0) ok = kFALSE;
1383 if(!particle || (calo!=
kEMCAL && calo!=
kPHOS))
return kFALSE ;
1388 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1392 Float_t phi = particle->Phi();
1393 if(phi < 0) phi+=TMath::TwoPi();
1398 Double_t x = 0, z = 0 ;
1399 Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ;
1400 return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ;
1405 Bool_t ok =
GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID);
1408 Int_t icol = -1, irow = -1, iRCU = -1;
1411 if(status > 0) ok = kFALSE;
1423 Float_t phiOrg, Int_t & absID)
1430 AliFatal(Form(
"Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead",calo));
1434 Float_t phi = phiOrg;
1435 if(phi < 0) phi+=TMath::TwoPi();
1440 Double_t x = 0, z = 0 ;
1441 Double_t vtx[]={0,0,0} ;
1449 Int_t icol = -1, irow = -1, iRCU = -1;
1452 if(status > 0) ok = kFALSE;
1488 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
1490 printf(
"Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n",
1492 if(
fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf(
"Do not remove EMCAL clusters at Eta = 0\n");
1496 printf(
"Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",
fCutR,
fCutZ);
1509 Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1;
1540 AliVCaloCells * cells)
1543 Float_t frac = 0., energy = 0.;
1549 UShort_t * index = cluster->GetCellsAbsId() ;
1550 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1552 Int_t ncells = cluster->GetNCells();
1555 if(cluster->IsPHOS()) calo =
kPHOS ;
1558 for(Int_t icell = 0; icell < ncells; icell++){
1560 Int_t absId = index[icell];
1562 frac = fraction[icell];
1563 if(frac < 1e-3) frac = 1;
1565 Float_t amp = cells->GetCellAmplitude(absId);
1568 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy: before cal %f; after cal %f",
1569 calo,frac,cells->GetCellAmplitude(absId),amp));
1574 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),energy));
1579 AliFatal(
"Cells pointer does not exist!");
1590 AliVCaloCells * cells, Float_t energyOrg)
1593 Float_t frac = 0., energy = 0.;
1599 UShort_t * index = cluster->GetCellsAbsId() ;
1600 Double_t * fraction = cluster->GetCellsAmplitudeFraction() ;
1602 Int_t ncells = cluster->GetNCells();
1605 if(cluster->IsPHOS()) calo =
kPHOS ;
1608 for(Int_t icell = 0; icell < ncells; icell++)
1610 Int_t absId = index[icell];
1612 frac = fraction[icell];
1613 if(frac < 1e-3) frac = 1;
1615 Float_t amp = cells->GetCellAmplitude(absId);
1620 AliDebug(2,Form(
"Recalibrate cell: calo <%d>, cell fraction %f, cell energy %f",
1621 calo,frac,cells->GetCellAmplitude(absId)));
1626 AliDebug(1,Form(
"Energy before %f, after %f",cluster->E(),energy));
1631 AliFatal(
"Cells pointer does not exist!");
1649 TObjArray* clusterArray)
1677 AliVCluster* cluster,
1678 AliVCaloCells* cells,
1680 AliAODCaloCluster* cluster1,
1681 AliAODCaloCluster* cluster2,
1682 Int_t nMax, Int_t eventNumber)
1684 TH2F* hClusterMap = 0 ;
1685 TH2F* hClusterLocMax = 0 ;
1686 TH2F* hCluster1 = 0 ;
1687 TH2F* hCluster2 = 0 ;
1691 hClusterMap =
new TH2F(
"hClusterMap",
"Cluster Map",48,0,48,24,0,24);
1692 hClusterLocMax =
new TH2F(
"hClusterLocMax",
"Cluster 2 highest local maxima",48,0,48,24,0,24);
1693 hCluster1 =
new TH2F(
"hCluster1",
"Cluster 1",48,0,48,24,0,24);
1694 hCluster2 =
new TH2F(
"hCluster2",
"Cluster 2",48,0,48,24,0,24);
1695 hClusterMap ->SetXTitle(
"column");
1696 hClusterMap ->SetYTitle(
"row");
1697 hClusterLocMax ->SetXTitle(
"column");
1698 hClusterLocMax ->SetYTitle(
"row");
1699 hCluster1 ->SetXTitle(
"column");
1700 hCluster1 ->SetYTitle(
"row");
1701 hCluster2 ->SetXTitle(
"column");
1702 hCluster2 ->SetYTitle(
"row");
1705 Int_t calorimeter =
kEMCAL;
1706 if(cluster->IsPHOS())
1709 AliWarning(
"Not supported for PHOS yet");
1713 const Int_t ncells = cluster->GetNCells();
1714 Int_t absIdList[ncells];
1716 Float_t e1 = 0, e2 = 0 ;
1717 Int_t icol = -1, irow = -1, iRCU = -1, sm = -1;
1718 Float_t eCluster = 0;
1719 Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1;
1720 for(Int_t iDigit = 0; iDigit < ncells; iDigit++ )
1722 absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit];
1724 Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]);
1732 if(sm > -1 && sm < 12)
1734 if(icol > maxCol) maxCol = icol;
1735 if(icol < minCol) minCol = icol;
1736 if(irow > maxRow) maxRow = irow;
1737 if(irow < minRow) minRow = irow;
1738 hClusterMap->Fill(icol,irow,ec);
1746 UShort_t absIdList1[9] ;
1747 Double_t fracList1 [9] ;
1748 absIdList1[0] = absId1 ;
1749 fracList1 [0] = 1. ;
1751 Float_t ecell1 = cells->GetCellAmplitude(absId1);
1756 UShort_t absIdList2[9] ;
1757 Double_t fracList2 [9] ;
1758 absIdList2[0] = absId2 ;
1759 fracList2 [0] = 1. ;
1761 Float_t ecell2 = cells->GetCellAmplitude(absId2);
1767 Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1;
1769 hClusterLocMax->Fill(icol1,irow1,ecell1);
1771 hClusterLocMax->Fill(icol2,irow2,ecell2);
1775 Float_t eRemain = (eCluster-ecell1-ecell2)/2;
1776 Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster;
1777 Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster;
1779 for(Int_t iDigit = 0; iDigit < ncells; iDigit++)
1781 Int_t absId = absIdList[iDigit];
1783 if(absId==absId1 || absId==absId2 || absId < 0)
continue;
1785 Float_t ecell = cells->GetCellAmplitude(absId);
1790 absIdList1[ncells1]= absId;
1794 fracList1[ncells1] = shareFraction1;
1795 e1 += ecell*shareFraction1;
1799 fracList1[ncells1] = 1.;
1809 absIdList2[ncells2]= absId;
1813 fracList2[ncells2] = shareFraction2;
1814 e2 += ecell*shareFraction2;
1818 fracList2[ncells2] = 1.;
1828 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",
1829 nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2));
1834 cluster1->SetNCells(ncells1);
1835 cluster2->SetNCells(ncells2);
1837 cluster1->SetCellsAbsId(absIdList1);
1838 cluster2->SetCellsAbsId(absIdList2);
1840 cluster1->SetCellsAmplitudeFraction(fracList1);
1841 cluster2->SetCellsAmplitudeFraction(fracList2);
1856 for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ )
1862 Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]);
1865 if(
AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit])
1866 hCluster1->Fill(icol,irow,ecell*shareFraction1);
1868 hCluster1->Fill(icol,irow,ecell);
1874 for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ )
1880 Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]);
1883 if(
AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit])
1884 hCluster2->Fill(icol,irow,ecell*shareFraction2);
1886 hCluster2->Fill(icol,irow,ecell);
1891 gStyle->SetPadRightMargin(0.1);
1892 gStyle->SetPadLeftMargin(0.1);
1893 gStyle->SetOptStat(0);
1894 gStyle->SetOptFit(000000);
1896 if(maxCol-minCol > maxRow-minRow)
1898 maxRow+= maxCol-minCol;
1902 maxCol+= maxRow-minRow;
1905 TCanvas * c=
new TCanvas(
"canvas",
"canvas", 4000, 4000) ;
1911 hClusterMap ->SetAxisRange(minCol, maxCol,
"X");
1912 hClusterMap ->SetAxisRange(minRow, maxRow,
"Y");
1913 hClusterMap ->Draw(
"colz TEXT");
1918 hClusterLocMax ->SetAxisRange(minCol, maxCol,
"X");
1919 hClusterLocMax ->SetAxisRange(minRow, maxRow,
"Y");
1920 hClusterLocMax ->Draw(
"colz TEXT");
1925 hCluster1 ->SetAxisRange(minCol, maxCol,
"X");
1926 hCluster1 ->SetAxisRange(minRow, maxRow,
"Y");
1927 hCluster1 ->Draw(
"colz TEXT");
1932 hCluster2 ->SetAxisRange(minCol, maxCol,
"X");
1933 hCluster2 ->SetAxisRange(minRow, maxRow,
"Y");
1934 hCluster2 ->Draw(
"colz TEXT");
1936 if(eCluster > 6 )c->Print(Form(
"clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps",
1937 eventNumber,cluster->E(),nMax,ncells1,ncells2));
1941 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
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.
TGeoHMatrix * fEMCALMatrix[12]
Geometry matrices with alignments.
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
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).
void InitEMCALGeometry()
Initialize EMCAL geometry if it did not exist previously.
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 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