+ }
+ } // merge emcal cells
+
+
+ // PHOS cells
+ //*fgAODPhosCells = *(aod->GetPHOSCells()); // This will be valid after 10.Mar.2011.
+ if(aodH->GetMergePHOSCells())
+ {
+ AliAODCaloCells* copycells = aod->GetPHOSCells();
+ fgAODPhosCells->CreateContainer(copycells->GetNumberOfCells());
+ nc = copycells->GetNumberOfCells();
+
+ while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc),
+ copycells->GetTime(nc),copycells->GetMCLabel(nc),copycells->GetEFraction(nc)); }
+
+ AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells();
+ if( cellsP )
+ {
+ Int_t ncellsP = cellsP->GetNumberOfCells();
+ nc = fgAODPhosCells->GetNumberOfCells();
+
+ for (Int_t i = 0; i < ncellsP; i++)
+ {
+ Int_t cn = cellsP->GetCellNumber(i);
+ Int_t pos = fgAODPhosCells->GetCellPosition(cn);
+
+ if (pos >= 0)
+ {
+ Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos);
+
+ //Check if it is MC, depending on that assing the mc lable, time and e fraction
+// Double_t time = 0;
+ Int_t mclabel =-1;
+ Double_t efrac = 0;
+ if(cellsP->GetMCLabel(i) >= 0 && fgAODPhosCells->GetMCLabel(pos) < 0)
+ {
+ mclabel = cellsP->GetMCLabel(i) ;
+// time = fgAODPhosCells->GetTime(pos) ; // Time from data
+ if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
+ }
+ else if(fgAODPhosCells->GetMCLabel(pos) >= 0 && cellsP->GetMCLabel(i) < 0)
+ {
+ mclabel = fgAODPhosCells->GetMCLabel(pos) ;
+// time = cellsP->GetTime(i) ; // Time from data
+ if(amp > 0) efrac = fgAODPhosCells->GetAmplitude(pos) / amp;
+ }
+ else
+ { // take all from input
+ mclabel = cellsP->GetMCLabel(i) ;
+// time = cellsP->GetTime(i) ;
+ if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
+ }
+
+ fgAODPhosCells->SetCell(pos, cn, amp,cellsP->GetTime(i),mclabel,efrac);
+
+ } else
+ {
+ AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODPhosCells);
+ fgAODPhosCells->CreateContainer(nc+1);
+ Int_t nn = copycells1->GetNumberOfCells();
+
+ while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn),
+ copycells1->GetTime(nn),copycells1->GetMCLabel(nn),copycells1->GetEFraction(nn)); }
+
+ fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i),cellsP->GetTime(i), cellsP->GetMCLabel(i),1.);
+
+ delete copycells1;
+ }
+ }
+ fgAODPhosCells->Sort();
+ }
+ } // Merge PHOS Cells