- if(fDebug > 1)
- printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n",
- absIdMax, ampMax, cluster->E());
-
- if(absIdMax==-1) return kFALSE;
-
- //Check if the cell is close to the borders:
- Bool_t okrow = kFALSE;
- Bool_t okcol = kFALSE;
-
- if(cells->GetType()==AliAODCaloCells::kEMCAL){
-
- Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1;
- fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta);
- fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta);
-
- //Check rows/phi
- if(iSM < 10){
- if(iphi >= fNCellsFromEMCALBorder && iphi < 24-fNCellsFromEMCALBorder) okrow =kTRUE;
- }
- else{
- if(iphi >= fNCellsFromEMCALBorder && iphi < 12-fNCellsFromEMCALBorder) okrow =kTRUE;
- }
-
- //Check collumns/eta
- if(!fNoEMCALBorderAtEta0){
- if(ieta > fNCellsFromEMCALBorder && ieta < 48-fNCellsFromEMCALBorder) okcol =kTRUE;
- }
- else{
- if(iSM%2==0){
- if(ieta >= fNCellsFromEMCALBorder) okcol = kTRUE;
- }
- else {
- if(ieta < 48-fNCellsFromEMCALBorder) okcol = kTRUE;
- }
- }//eta 0 not checked
- if(fDebug > 1)
- {
- printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?",
- fNCellsFromEMCALBorder, ieta, iphi, iSM);
- if (okcol && okrow ) printf(" YES \n");
- else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
- }
- }//EMCAL
- else if(cells->GetType()==AliAODCaloCells::kPHOS){
- Int_t relId[4];
- Int_t irow = -1, icol = -1;
- fPHOSGeo->AbsToRelNumbering(absIdMax,relId);
- irow = relId[2];
- icol = relId[3];
- //imod = relId[0]-1;
- if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE;
- if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE;
- if(fDebug > 1)
- {
- printf("AliCalorimeterUtils::CheckCellFiducialRegion(AOD) - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?",
- fNCellsFromPHOSBorder, icol, irow, relId[0]-1);
- if (okcol && okrow ) printf(" YES \n");
- else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow);
- }
- }//PHOS
-
- if (okcol && okrow) return kTRUE;
- else return kFALSE;
-
-}
-
-//_______________________________________________________________
-Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliESDCaloCluster* cluster, AliESDCaloCells* cells) const {
- // Given the list of AbsId of the cluster, get the maximum cell and
- // check if there are fNCellsFromBorder from the calorimeter border
-
- //If the distance to the border is 0 or negative just exit accept all clusters
- if(cells->GetType()==AliESDCaloCells::kEMCALCell && fNCellsFromEMCALBorder <= 0 ) return kTRUE;
- if(cells->GetType()==AliESDCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE;
-
- //Find cell with maximum amplitude
- Int_t absIdMax = -1;
- Float_t ampMax = -1;
- for(Int_t i = 0; i < cluster->GetNCells() ; i++){
- Int_t absId = cluster->GetCellAbsId(i) ;
- Float_t amp = cells->GetCellAmplitude(absId);
- if(amp > ampMax){
- ampMax = amp;
- absIdMax = absId;
- }
- }
+ AliMixedEvent * mixEvent = dynamic_cast<AliMixedEvent*> (event);
+ Int_t nMixedEvents = 0 ;
+ Int_t * cellsCumul = NULL ;
+ Int_t numberOfCells = 0 ;
+ if (mixEvent){
+ nMixedEvents = mixEvent->GetNumberOfEvents() ;
+ if (cells->GetType()==AliVCaloCells::kEMCALCell) {
+ cellsCumul = mixEvent->GetEMCALCellsCumul() ;
+ numberOfCells = mixEvent->GetNumberOfEMCALCells() ;
+ }
+
+ else if (cells->GetType()==AliVCaloCells::kPHOSCell) {
+ cellsCumul = mixEvent->GetPHOSCellsCumul() ;
+ numberOfCells = mixEvent->GetNumberOfPHOSCells() ;
+ }
+
+ if(cellsCumul){
+
+ Int_t startCell = cellsCumul[iev] ;
+ Int_t endCell = (iev+1 < nMixedEvents)?cellsCumul[iev+1]:numberOfCells;
+ //Find cells with maximum amplitude
+ for(Int_t i = 0; i < cluster->GetNCells() ; i++){
+ Int_t absId = cluster->GetCellAbsId(i) ;
+ for (Int_t j = startCell; j < endCell ; j++) {
+ Short_t cellNumber;
+ Double_t amp ;
+ Double_t time;
+ cells->GetCell(j, cellNumber, amp, time) ;
+ if (absId == cellNumber) {
+ if(amp > ampMax){
+ ampMax = amp;
+ absIdMax = absId;
+ }
+ }
+ }
+ }//loop on cluster cells
+ }// cells cumul available
+ else {
+ printf("AliCalorimeterUtils::CheckCellFiducialRegion() - CellsCumul is NULL!!!\n");
+ abort();
+ }
+ } else {//Normal SE Events
+ for(Int_t i = 0; i < cluster->GetNCells() ; i++){
+ Int_t absId = cluster->GetCellAbsId(i) ;
+ Float_t amp = cells->GetCellAmplitude(absId);
+ if(amp > ampMax){
+ ampMax = amp;
+ absIdMax = absId;
+ }
+ }
+ }