if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
// Connect input handlers (multi input handler is handled)
- ConnectMultiHandler();
-
+ ConnectMultiHandler();
+
if (fInputHandler) {
if ((fInputHandler->GetTree())->GetBranch("ESDfriend."))
fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
if (aodIH) {
if (aodIH->GetMergeEvents()) merging = kTRUE;
}
-
// Check if AOD replication has been required
-
if (handler) {
fOutputAOD = handler->GetAOD();
fTreeA = handler->GetTree();
if (fOutputAOD && !(handler->IsStandard())) {
- if ((handler->NeedsHeaderReplication()) && !(fgAODHeader))
+ if ((handler->NeedsHeaderReplication() || merging) && !(fgAODHeader))
{
if (fDebug > 1) AliInfo("Replicating header");
fgAODHeader = new AliAODHeader;
fgAODCaloClusters->SetName("caloClusters");
handler->AddBranch("TClonesArray", &fgAODCaloClusters);
- fgAODEmcalCells = new AliAODCaloCells();
- fgAODEmcalCells->SetName("emcalCells");
+ fgAODEmcalCells = new AliAODCaloCells("emcalCells","emcalCells",AliVCaloCells::kEMCALCell);
handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells);
- fgAODPhosCells = new AliAODCaloCells();
- fgAODPhosCells->SetName("phosCells");
+ fgAODPhosCells = new AliAODCaloCells("phosCells","phosCells",AliVCaloCells::kPHOSCell);
handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
+
}
if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))
{
//
// Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
UInt_t isSelected = AliVEvent::kAny;
- if( fInputHandler && fInputHandler->GetEventSelection()) {
+ if( fInputHandler && (fInputHandler->GetEventSelection() || aodH)) {
// Get the actual offline trigger mask for the event and AND it with the
// requested mask. If no mask requested select by default the event.
if (fOfflineTriggerMask)
if (handler && aodH) {
fMCEvent = aodH->MCEvent();
Bool_t merging = aodH->GetMergeEvents();
+
+ // Do not analyze merged events if last embedded file has less events than normal event,
+ // skip analysis after last embeded event
+ if(merging){
+ if(aodH->GetReadEntry() + aodH->GetMergeOffset() >= aodH->GetTreeToMerge()->GetEntriesFast()){
+ //printf("Skip Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
+
+ // Do I need to add the lines before the return?
+ // Added protection in case the derived task is not an AOD producer.
+ AliAnalysisDataSlot *out0 = GetOutputSlot(0);
+ if (out0 && out0->IsConnected()) PostData(0, fTreeA);
+
+ DisconnectMultiHandler();
+
+ return;
+ }
+ //else printf("MERGE Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
+ }
+
AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) {
- if ((handler->NeedsHeaderReplication()) && (fgAODHeader))
+ if ((handler->NeedsHeaderReplication() || merging) && (fgAODHeader))
{
// copy the contents by assigment
*fgAODHeader = *(aod->GetHeader());
}
- if ((handler->NeedsTracksBranchReplication() || merging) && (fgAODTracks))
+ if ((handler->NeedsTracksBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODTracks))
{
TClonesArray* tracks = aod->GetTracks();
new (fgAODTracks) TClonesArray(*tracks);
TClonesArray* pmdClusters = aod->GetPmdClusters();
new (fgAODPMDClusters) TClonesArray(*pmdClusters);
}
- if ((handler->NeedsJetsBranchReplication() || merging) && (fgAODJets))
+ if ((handler->NeedsJetsBranchReplication() || (merging &&aodH->GetMergeTracks())) && (fgAODJets))
{
TClonesArray* jets = aod->GetJets();
new (fgAODJets) TClonesArray(*jets);
TClonesArray* fmdClusters = aod->GetFmdClusters();
new (fgAODFMDClusters) TClonesArray(*fmdClusters);
}
- if ((handler->NeedsCaloClustersBranchReplication() || merging) && (fgAODCaloClusters))
+ if ((handler->NeedsCaloClustersBranchReplication() ||
+ (merging && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())))
+ && (fgAODCaloClusters))
{
TClonesArray* caloClusters = aod->GetCaloClusters();
new (fgAODCaloClusters) TClonesArray(*caloClusters);
if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
{
TClonesArray* mcParticles = (TClonesArray*) (aod->FindListObject("mcparticles"));
- new (fgAODMCParticles) TClonesArray(*mcParticles);
+ if( mcParticles )
+ new (fgAODMCParticles) TClonesArray(*mcParticles);
}
- if ((handler->NeedsDimuonsBranchReplication() || merging) && (fgAODDimuons))
+ if ((handler->NeedsDimuonsBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODDimuons))
{
fgAODDimuons->Clear();
TClonesArray& dimuons = *fgAODDimuons;
}
}
}
-
// Additional merging if needed
if (merging) {
+ Int_t nc;
+
// mcParticles
TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles"));
- Int_t npart = mcparticles->GetEntries();
- Int_t nc = fgAODMCParticles->GetEntries();
- Int_t nc0 = nc;
-
- for (Int_t i = 0; i < npart; i++) {
+ if( mcparticles ){
+ Int_t npart = mcparticles->GetEntries();
+ nc = fgAODMCParticles->GetEntries();
+
+ for (Int_t i = 0; i < npart; i++) {
AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i);
new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle);
+ }
}
-
+
// tracks
TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
- Int_t ntr = tracks->GetEntries();
- nc = fgAODTracks->GetEntries();
- for (Int_t i = 0; i < ntr; i++) {
+ if(tracks && aodH->GetMergeTracks()){
+ Int_t ntr = tracks->GetEntries();
+ nc = fgAODTracks->GetEntries();
+ for (Int_t i = 0; i < ntr; i++) {
AliAODTrack* track = (AliAODTrack*) tracks->At(i);
AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track);
- newtrack->SetLabel(newtrack->GetLabel() + nc0);
- }
-
- for (Int_t i = 0; i < nc; i++)
- {
- AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i);
- track->ResetBit(kIsReferenced);
- track->SetUniqueID(0);
+ newtrack->SetLabel(newtrack->GetLabel() + fgAODMCParticles->GetEntries());
+ }
+
+ for (Int_t i = 0; i < nc; i++)
+ {
+ AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i);
+ track->ResetBit(kIsReferenced);
+ track->SetUniqueID(0);
+ }
}
-
// clusters
TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
- Int_t ncl = clusters->GetEntries();
- nc = fgAODCaloClusters->GetEntries();
- for (Int_t i = 0; i < ncl; i++) {
+ if( clusters && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())) {
+ Int_t ncl = clusters->GetEntries();
+ nc = fgAODCaloClusters->GetEntries();
+ for (Int_t i = 0; i < ncl; i++) {
AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i);
+ if(cluster->IsEMCAL() && !aodH->GetMergeEMCALClusters() ) continue;
+ if(cluster->IsPHOS() && !aodH->GetMergePHOSClusters() ) continue;
new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
+ }
}
- // cells
- AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
- Int_t ncells = cellsA->GetNumberOfCells();
- nc = fgAODEmcalCells->GetNumberOfCells();
-
- for (Int_t i = 0; i < ncells; i++) {
- Int_t cn = cellsA->GetCellNumber(i);
- Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
- if (pos >= 0) {
- Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
- fgAODEmcalCells->SetCell(pos, cn, amp);
- } else {
- Double_t amp = cellsA->GetAmplitude(i);
- fgAODEmcalCells->SetCell(nc++, cn, amp);
+
+ // EMCAL cells
+ //*fgAODEmcalCells = *(aod->GetEMCALCells()); // This will be valid after 10.Mar.2011.
+ if(aodH->GetMergeEMCALCells()) {
+ AliAODCaloCells* copycells = aod->GetEMCALCells();
+ fgAODEmcalCells->CreateContainer(copycells->GetNumberOfCells());
+ nc = copycells->GetNumberOfCells();
+ while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); }
+
+ AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
+ if( cellsA ){
+ Int_t ncells = cellsA->GetNumberOfCells();
+ nc = fgAODEmcalCells->GetNumberOfCells();
+ for (Int_t i = 0; i < ncells; i++) {
+ Int_t cn = cellsA->GetCellNumber(i);
+ Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
+ if (pos >= 0) {
+ Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
+ fgAODEmcalCells->SetCell(pos, cn, amp);
+ } else {
+ AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODEmcalCells);
+ fgAODEmcalCells->CreateContainer(nc+1);
+ Int_t nn = copycells1->GetNumberOfCells();
+ while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn)); }
+ fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i));
+ delete copycells1;
+ }
+ }
fgAODEmcalCells->Sort();
}
- }
+ } // 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)); }
+ 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
+
} // merging
handler->SetAODIsReplicated();
}
}
+
// Call the user analysis
if (!fMCEventHandler) {
if (isSelected)
// Added protection in case the derived task is not an AOD producer.
AliAnalysisDataSlot *out0 = GetOutputSlot(0);
if (out0 && out0->IsConnected()) PostData(0, fTreeA);
-
+
DisconnectMultiHandler();
}