#include "AliAnalysisDataSlot.h"
#include "AliESDEvent.h"
+#include "AliESDfriend.h"
#include "AliESD.h"
#include "AliAODEvent.h"
#include "AliAODHeader.h"
#include "AliAODInputHandler.h"
#include "AliMCEventHandler.h"
#include "AliInputEventHandler.h"
+#include "AliESDInputHandler.h"
#include "AliMCEvent.h"
#include "AliStack.h"
#include "AliLog.h"
+#include "AliAODDimuon.h"
ClassImp(AliAnalysisTaskSE)
AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL;
AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL;
AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL;
+TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL;
AliAnalysisTaskSE::AliAnalysisTaskSE():
AliAnalysisTask(),
fDebug(0),
fEntry(0),
fInputEvent(0x0),
+ fESDfriend(0x0),
fInputHandler(0x0),
fOutputAOD(0x0),
fMCEvent(0x0),
fDebug(0),
fEntry(0),
fInputEvent(0x0),
+ fESDfriend(0x0),
fInputHandler(0x0),
fOutputAOD(0x0),
fMCEvent(0x0),
fDebug(0),
fEntry(0),
fInputEvent(0x0),
+ fESDfriend(0x0),
fInputHandler(0x0),
fOutputAOD(0x0),
fMCEvent(0x0),
fDebug = obj.fDebug;
fEntry = obj.fEntry;
fInputEvent = obj.fInputEvent;
+ fESDfriend = obj.fESDfriend;
fInputHandler = obj.fInputHandler;
fOutputAOD = obj.fOutputAOD;
fMCEvent = obj.fMCEvent;
fDebug = other.fDebug;
fEntry = other.fEntry;
fInputEvent = other.fInputEvent;
+ fESDfriend = other.fESDfriend;
fInputHandler = other.fInputHandler;
fOutputAOD = other.fOutputAOD;
fMCEvent = other.fMCEvent;
}
if (fInputHandler) {
- fInputEvent = fInputHandler->GetEvent();
+ if ((fInputHandler->GetTree())->GetBranch("ESDfriend."))
+ fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
+
+ fInputEvent = fInputHandler->GetEvent();
} else if( fMCEvent ) {
AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ;
} else {
fgAODMCParticles->SetName("mcparticles");
handler->AddBranch("TClonesArray", &fgAODMCParticles);
}
+ if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
+ {
+ if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
+ fgAODDimuons = new TClonesArray("AliAODDimuon",0);
+ fgAODDimuons->SetName("dimuons");
+ handler->AddBranch("TClonesArray", &fgAODDimuons);
+ }
+
// cache the pointerd in the AODEvent
fOutputAOD->GetStdContent();
}
{
//
// Exec analysis of one event
+ if ( fDebug >= 10)
+ printf("Task is active %5d\n", IsActive());
+
if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
//
AliAODHandler* handler = (AliAODHandler*)
//
// Was event selected ?
Bool_t isSelected = kTRUE;
- if( fInputHandler ) {
+ if( fInputHandler && fInputHandler->GetEventSelection() && fSelectCollisions) {
isSelected = fInputHandler->IsEventSelected();
- fEntry = fInputHandler->GetReadEntry();
}
-
+
if (handler) handler->SetFillAOD(isSelected);
-
+
+ if( fInputHandler ) {
+ fEntry = fInputHandler->GetReadEntry();
+ fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
+ }
+
// Notify the change of run number
- if (InputEvent()->GetRunNumber() != fCurrentRunNumber) {
+ if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
fCurrentRunNumber = InputEvent()->GetRunNumber();
NotifyRun();
}
TClonesArray* mcParticles = (TClonesArray*) ((dynamic_cast<AliAODEvent*>(InputEvent()))->FindListObject("mcparticles"));
new (fgAODMCParticles) TClonesArray(*mcParticles);
}
-
+
+ if ((handler->NeedsDimuonsBranchReplication() || merging) && (fgAODDimuons))
+ {
+ fgAODDimuons->Clear();
+ TClonesArray& dimuons = *fgAODDimuons;
+ TClonesArray& tracksnew = *fgAODTracks;
+
+ Int_t nMuonTrack[10];
+ for(Int_t imuon = 0; imuon < 10; imuon++) nMuonTrack[imuon] = 0;
+ Int_t nMuons=0;
+ for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){
+ AliAODTrack *track = (AliAODTrack*) fgAODTracks->At(ii);
+ if(track->IsMuonTrack()) {
+ nMuonTrack[nMuons]= ii;
+ nMuons++;
+ }
+ }
+ Int_t jDimuons=0;
+ if(nMuons >= 2){
+ for(Int_t i = 0; i < nMuons; i++){
+ Int_t index0 = nMuonTrack[i];
+ for(Int_t j = i+1; j < nMuons; j++){
+ Int_t index1 = nMuonTrack[j];
+ tracksnew.At(index0)->ResetBit(kIsReferenced);
+ tracksnew.At(index0)->SetUniqueID(0);
+ tracksnew.At(index1)->ResetBit(kIsReferenced);
+ tracksnew.At(index1)->SetUniqueID(0);
+ new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1));
+ }
+ }
+ }
+ }
+
// Additional merging if needed
if (merging) {
// mcParticles
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);
}