]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisTaskFilter.cxx
Small update
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskFilter.cxx
index ce9e98f2d6ef1afbfdacaa819b771e81c8449f1f..7b2c0883a98be9a568bbe951bb864b9bfe2ceb9a 100644 (file)
@@ -48,9 +48,9 @@ AliAnalysisTaskFilter::AliAnalysisTaskFilter():
        fEntry(0),
        fInputEvent(0x0),
        fInputHandler(0x0),
-       fOutputESD(0x0),
        fOutputESDfriend(0x0),
-       fTreeE(0x0)
+       fTreeEF(0x0),
+       fInputESDfriend(0x0)
 {
        //
        // Default constructor
@@ -65,9 +65,9 @@ AliAnalysisTaskFilter::AliAnalysisTaskFilter(const char* name):
        fEntry(0),
        fInputEvent(0x0),
        fInputHandler(0x0),
-       fOutputESD(0x0),
        fOutputESDfriend(0x0),
-       fTreeE(0x0)
+       fTreeEF(0x0),
+       fInputESDfriend(0x0)
 {
        //
        // Default constructor
@@ -85,9 +85,9 @@ AliAnalysisTaskFilter::AliAnalysisTaskFilter(const AliAnalysisTaskFilter& obj):
        fEntry(0),
        fInputEvent(0x0),
        fInputHandler(0x0),
-       fOutputESD(0x0),
        fOutputESDfriend(0x0),
-       fTreeE(0x0)
+       fTreeEF(0x0),
+       fInputESDfriend(0x0)
 {
        //
        // Copy constructor
@@ -97,9 +97,9 @@ AliAnalysisTaskFilter::AliAnalysisTaskFilter(const AliAnalysisTaskFilter& obj):
        fEntry        = obj.fEntry;
        fInputEvent   = obj.fInputEvent;
        fInputHandler = obj.fInputHandler;
-       fOutputESD    = obj.fOutputESD;
        fOutputESDfriend = obj.fOutputESDfriend;
-       fTreeE        = obj.fTreeE;    
+       fTreeEF        = obj.fTreeEF;    
+       fInputESDfriend = obj.fInputESDfriend;
 }
 
 
@@ -111,14 +111,16 @@ AliAnalysisTaskFilter& AliAnalysisTaskFilter::operator=(const AliAnalysisTaskFil
        // Assignment
        //
 
-       AliAnalysisTask::operator=(other);
-       fDebug        = other.fDebug;
-       fEntry        = other.fEntry;
-       fInputEvent   = other.fInputEvent;
-       fInputHandler = other.fInputHandler;
-       fOutputESD    = other.fOutputESD;
-       fOutputESDfriend = other.fOutputESDfriend;
-       fTreeE        = other.fTreeE;    
+       if (&other != this) {
+               AliAnalysisTask::operator=(other);
+               fDebug        = other.fDebug;
+               fEntry        = other.fEntry;
+               fInputEvent   = other.fInputEvent;
+               fInputHandler = other.fInputHandler;
+               fOutputESDfriend = other.fOutputESDfriend;
+               fTreeEF        = other.fTreeEF;    
+               fInputESDfriend = other.fInputESDfriend;
+       }
        return *this;
 }
 
@@ -136,7 +138,17 @@ void AliAnalysisTaskFilter::ConnectInputData(Option_t* /*option*/)
                ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
        if (fInputHandler) {
                fInputEvent = fInputHandler->GetEvent();
-       } else {
+               if (fInputEvent){
+                       fInputESDfriend = (AliESDfriend*)(fInputEvent->FindListObject("AliESDfriend"));
+                       if (!fInputESDfriend){
+                               AliError("No friend found");
+                       }
+               }
+               else {
+                       AliError("No Input Event found, the friend will remain empty");
+               }
+       } 
+       else {
                AliError("No Input Event Handler connected") ; 
                return ; 
        }
@@ -155,9 +167,7 @@ void AliAnalysisTaskFilter::CreateOutputObjects()
        AliESDHandler* handler = (AliESDHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     
        if (handler) {
-               fOutputESD   = handler->GetESD();
-               fTreeE = handler->GetTree();
-               fOutputESD->GetStdContent();
+               fTreeEF = handler->GetTree();
        }
        else {
                AliWarning("No AOD Event Handler connected.") ; 
@@ -188,13 +198,23 @@ void AliAnalysisTaskFilter::Exec(Option_t* option)
        
        if (UserSelectESDfriendForCurrentEvent()){
                // Call the user analysis only if the event was selected   
+               handler->SelectEventForFriends();
                fOutputESDfriend   = handler->GetESDfriend();
                UserExec(option);
+               // copy the VZERO friend only if it is not already there
+               if (fOutputESDfriend->GetVZEROfriend() == 0x0){
+                       AliDebug(2,"Copying VZERO friend object");
+                       AliESDVZEROfriend* vZEROfriend = fInputESDfriend->GetVZEROfriend();
+                       fOutputESDfriend->SetVZEROfriend(vZEROfriend);
+               }
+       }
+       else {
+               // Event not selected
+               AliDebug(2,"The event was not selected");
        }
 
-       // Added protection in case the derived task is not an AOD producer.
        AliAnalysisDataSlot *out0 = GetOutputSlot(0);
-       if (out0 && out0->IsConnected()) PostData(0, fTreeE);    
+       if (out0 && out0->IsConnected()) PostData(0, fTreeEF);    
 }
 
 //______________________________________________________________________
@@ -218,11 +238,42 @@ void AliAnalysisTaskFilter::AddFriendTrackAt(AliESDfriendTrack* t, Int_t index)
        //
 
        AliESDfriendTrack* currentTrack = (AliESDfriendTrack*)fOutputESDfriend->GetTrack(index);
-       if(currentTrack && currentTrack->GetCalibObject(0)){
-               AliWarning("Friend already there");
+       if(currentTrack){
+               if (currentTrack->TestSkipBit()){
+                       AliDebug(2,Form("Friend at index %d already there but dummy - the skip bit will be set to FALSE", index));
+                       t->SetSkipBit(kFALSE);
+               }
+               else{
+                       AliDebug(2,Form("Friend at index %d already there and not dummy", index));
+                       return;
+               }
+       }
+       else{
+               AliDebug(2,Form("Track at %d not there yet ",index));
+       }
+       AliDebug(2,Form("Adding track at %d",index));
+       fOutputESDfriend->AddTrackAt(t,index);
+       return;
+}
+
+//______________________________________________________________________
+
+void AliAnalysisTaskFilter::SkipFriendTrackAt(Int_t index)
+{
+       //
+       // Skip the friend track at the i-th position in the TClonesArray
+       // of the ESD friend tracks
+       //
+
+       AliESDfriendTrack* currentTrack = (AliESDfriendTrack*)fOutputESDfriend->GetTrack(index);
+       if (currentTrack){
+               AliDebug(2,Form("Track already there (no matter what validity) at %d, keeping it as it is", index));
        }
        else {
-               //              AliInfo("Adding track");
-               fOutputESDfriend->AddTrackAt(t,index);
+               AliDebug(2,Form("Adding NULL track at %d, and setting skip bit to TRUE",index));
+               AliESDfriendTrack* tNull = new AliESDfriendTrack();
+               tNull->SetSkipBit(kTRUE);
+               fOutputESDfriend->AddTrackAt(tNull,index);
        }
+       return;
 }