AOD Tag creator task.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Sep 2008 16:23:31 +0000 (16:23 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Sep 2008 16:23:31 +0000 (16:23 +0000)
ANALYSIS/ANALYSISaliceLinkDef.h
ANALYSIS/AliAnalysisTaskTagCreator.cxx [new file with mode: 0644]
ANALYSIS/AliAnalysisTaskTagCreator.h [new file with mode: 0644]
ANALYSIS/libANALYSISalice.pkg

index 327e1fe..13ff006 100644 (file)
@@ -8,6 +8,7 @@
 #pragma link C++ class  AliAnalysisTaskME+;
 #pragma link C++ class  AliAnalysisTaskESDfilter+;
 #pragma link C++ class  AliAnalysisTaskKineFilter+;
+#pragma link C++ class  AliAnalysisTaskTagCreator+;
 #pragma link C++ class  AliKineTrackCuts+;
 #pragma link C++ class  AliESDtrackCuts+;
 #pragma link C++ class  AliESDv0Cuts+;
@@ -17,6 +18,7 @@
 
 #pragma link C++ class AliEventPoolSparse+;
 
+
 #ifdef WITHXML
 #pragma link C++ class AliTagAnalysis+;
 #pragma link C++ class AliXMLCollection+;
diff --git a/ANALYSIS/AliAnalysisTaskTagCreator.cxx b/ANALYSIS/AliAnalysisTaskTagCreator.cxx
new file mode 100644 (file)
index 0000000..fe72036
--- /dev/null
@@ -0,0 +1,140 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+#include <TChain.h>
+#include <TTree.h>
+#include <TString.h>
+#include <TFile.h>
+
+#include "AliAnalysisTaskTagCreator.h"
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliAODHandler.h"
+#include "AliRunTag.h"
+#include "AliEventTag.h"
+#include "AliAODTagCreator.h"
+#include "AliLog.h"
+
+ClassImp(AliAnalysisTaskTagCreator)
+
+////////////////////////////////////////////////////////////////////////
+
+AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator():
+    AliAnalysisTaskSE(),
+    fFirstFile(kTRUE),
+    fRunTag(0), 
+    fTreeT(0),
+    fTagCreator(0)
+{
+  // Default constructor
+}
+
+AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name):
+    AliAnalysisTaskSE(name),
+    fFirstFile(kTRUE),
+    fRunTag(0), 
+    fTreeT(0),
+    fTagCreator(0)
+{
+  // Constructor
+    DefineOutput(1, TTree::Class());   
+}
+
+void AliAnalysisTaskTagCreator::UserCreateOutputObjects()
+{
+// Create the output container
+    OpenFile(1);
+    fTreeT  = new TTree("T", "AOD Tags");
+    fRunTag = new AliRunTag();
+    TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag);
+    btag->SetCompressionLevel(9);
+    fTagCreator = new AliAODTagCreator();
+}
+
+void AliAnalysisTaskTagCreator::Init()
+{
+    // Initialization
+    if (fDebug > 1) AliInfo("Init() \n");
+    // Call configuration file
+}
+
+
+void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/)
+{
+    // Create Tags for the current event
+    AliEventTag* evtTag = new AliEventTag();
+    fTagCreator->FillEventTag(AODEvent(), evtTag);
+    // Reference to the input file
+    TString fturl, fturltemp, fguid;
+    
+    TString opt(fInputHandler->GetAnalysisType());
+    opt.ToLower();
+    
+    TFile *file = OutputTree()->GetCurrentFile();
+    const TUrl *url = file->GetEndpointUrl();
+    fguid = file->GetUUID().AsString();
+    if (opt.Contains("grid")) {
+       fturltemp = "alien://"; fturltemp += url->GetFile();
+       fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
+    } else {
+       fturl = url->GetFile();
+    }
+    evtTag->SetEventId(fInputHandler->GetReadEntry() + 1);
+    evtTag->SetGUID(fguid);
+    if(opt.Contains("grid")) {
+       evtTag->SetMD5(0);
+       evtTag->SetTURL(fturl);
+       evtTag->SetSize(0);
+    }
+    else evtTag->SetPath(fturl);
+    //
+    // Add the event tag
+    fRunTag->AddEventTag(*evtTag);
+    PostData(1, fTreeT);
+}
+
+
+void AliAnalysisTaskTagCreator::FinishTaskOutput()
+{
+// Terminate analysis
+//
+    if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());      
+    fTreeT->Fill();
+}
+
+Bool_t AliAnalysisTaskTagCreator::Notify()
+{
+    // Notify file change
+    if (!fFirstFile) {
+       if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());           
+       fTreeT->Fill();
+       fRunTag->Clear();
+    } else {
+       fFirstFile = kFALSE;
+    }
+}
+
+
+void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
+{
+// Terminate analysis
+//
+    if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");
+}
+
diff --git a/ANALYSIS/AliAnalysisTaskTagCreator.h b/ANALYSIS/AliAnalysisTaskTagCreator.h
new file mode 100644 (file)
index 0000000..e433c36
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef ALIANALYSISTASKTAGCREATOR_H
+#define ALIANALYSISTASKTAGCREATOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+#include "AliAnalysisTaskSE.h"
+class AliRunTag;
+class AliAODTagCreator;
+class TTree;
+
+
+class AliAnalysisTaskTagCreator : public AliAnalysisTaskSE
+{
+ public:
+    AliAnalysisTaskTagCreator();
+    AliAnalysisTaskTagCreator(const char* name);
+    virtual ~AliAnalysisTaskTagCreator() {;}
+    // Implementation of interface methods
+    virtual void   UserCreateOutputObjects();
+    virtual void   Init();
+    virtual void   LocalInit() {Init();}
+    virtual void   UserExec(Option_t *option);
+    virtual Bool_t Notify();
+    virtual void   Terminate(Option_t *option);
+    virtual void   FinishTaskOutput();
+ private:
+    AliAnalysisTaskTagCreator(const AliAnalysisTaskTagCreator&);
+    AliAnalysisTaskTagCreator& operator=(const AliAnalysisTaskTagCreator&);
+    Bool_t                   fCreateTags;             //  Flag for tag creation
+    Bool_t                   fFirstFile;              //! To flag the first file   
+    AliRunTag               *fRunTag;                 //! Pointer to run tag
+    TTree                   *fTreeT;                  //! tree for  aod tags
+    AliAODTagCreator        *fTagCreator;             //! The tag creator
+    
+    ClassDef(AliAnalysisTaskTagCreator, 1); // Analysis task for standard ESD filtering
+};
+#endif
index 50d379d..a14c418 100644 (file)
@@ -3,7 +3,8 @@
 SRCS =         AliAnalysisTaskSE.cxx AliAnalysisTaskME.cxx \
        AliAnalysisTaskESDfilter.cxx AliAnalysisTaskKineFilter.cxx \
        AliKineTrackCuts.cxx AliESDtrackCuts.cxx AliESDv0Cuts.cxx \
-       AliEventPoolOTF.cxx AliEventPoolLoop.cxx AliEventPoolSparse.cxx
+       AliEventPoolOTF.cxx AliEventPoolLoop.cxx AliEventPoolSparse.cxx \
+       AliAnalysisTaskTagCreator.cxx
 
 CHECKALIEN = $(shell root-config --has-alien)
 ifeq (yes,$(CHECKALIEN))