+ // 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)); }
+ 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);
+ fgAODPhosCells->SetCell(pos, cn, amp);
+ } 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)); }
+ fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i));
+ delete copycells1;
+ }
+ }
+ fgAODPhosCells->Sort();
+ }
+ } // Merge PHOS Cells
+
+ if (aodH->GetMergeEMCALTrigger())
+ {
+ Int_t EMCALts[48][64], px, py, ts;
+ Float_t EMCALfo[48][64], am;
+
+ for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++)
+ {
+ EMCALts[i][j] = 0;
+ EMCALfo[i][j] = 0.;
+ }
+
+ AliAODCaloTrigger& trg0 = *(aod->GetCaloTrigger("EMCAL"));
+
+ trg0.Reset();
+ while (trg0.Next())
+ {
+ trg0.GetPosition(px, py);
+
+ if (px > -1 && py > -1)
+ {
+ trg0.GetL1TimeSum(ts);
+ if (ts > -1) EMCALts[px][py] += ts;
+
+ trg0.GetAmplitude(am);
+ if (am > -1) EMCALfo[px][py] += am;
+ }
+ }
+
+ AliAODCaloTrigger& trg1 = *((aodH->GetEventToMerge())->GetCaloTrigger("EMCAL"));
+
+ trg1.Reset();
+ while (trg1.Next())
+ {
+ trg1.GetPosition(px, py);
+
+ if (px > -1 && py > -1)
+ {
+ trg1.GetL1TimeSum(ts);
+ if (ts > -1) EMCALts[px][py] += ts;
+
+ trg1.GetAmplitude(am);
+ if (am > -1) EMCALfo[px][py] += am;
+ }
+ }
+
+ int nEntries = 0;
+ for (Int_t i = 0; i < 48; i++)
+ for (Int_t j = 0; j < 64; j++)
+ if (EMCALts[i][j] || EMCALfo[i][j]) nEntries++;