Adding a selector that can be used for analysis requiring the RunLoader (and thus...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 May 2006 17:03:07 +0000 (17:03 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 May 2006 17:03:07 +0000 (17:03 +0000)
PWG0/AliSelectorRL.cxx [new file with mode: 0644]
PWG0/AliSelectorRL.h [new file with mode: 0644]

diff --git a/PWG0/AliSelectorRL.cxx b/PWG0/AliSelectorRL.cxx
new file mode 100644 (file)
index 0000000..7384fd7
--- /dev/null
@@ -0,0 +1,85 @@
+#include "AliSelectorRL.h"
+
+#include <AliLog.h>
+#include <AliRun.h>
+#include <AliRunLoader.h>
+
+ClassImp(AliSelectorRL)
+
+AliSelectorRL::AliSelectorRL() :
+  AliSelector(),
+  fRunLoader(0)
+{
+  //
+  // Constructor. Initialization of pointers
+  //
+}
+
+AliSelectorRL::~AliSelectorRL()
+{
+  //
+  // Destructor
+  //
+
+  // histograms are in the output list and deleted when the output
+  // list is deleted by the TSelector dtor
+}
+
+Bool_t AliSelectorRL::Notify()
+{
+  // Calls base class Notify
+  // On top of that run loader is closed, because we change the input file
+
+  if (AliSelector::Notify() == kFALSE)
+    return kFALSE;
+
+  DeleteRunLoader();
+
+  return kTRUE;
+}
+
+void AliSelectorRL::SlaveTerminate()
+{
+  // removes runloader
+
+  AliSelector::SlaveTerminate();
+
+  DeleteRunLoader();
+}
+
+AliRun* AliSelectorRL::GetAliRun()
+{
+  // Returns AliRun instance corresponding to current ESD active in fChain
+  // Loads galice.root, the file is identified by replacing "AliESDs" to
+  // "galice" in the file path of the ESD file. This is a hack, to be changed!
+
+  if (!fRunLoader)
+  {
+    if (!fChain->GetCurrentFile())
+      return 0;
+
+    TString fileName(fChain->GetCurrentFile()->GetName());
+    fileName.ReplaceAll("AliESDs", "galice");
+
+    fRunLoader = AliRunLoader::Open(fileName);
+    if (!fRunLoader)
+      return 0;
+
+    fRunLoader->LoadgAlice();
+  }
+
+  return fRunLoader->GetAliRun();
+}
+
+void AliSelectorRL::DeleteRunLoader()
+{
+  //
+  // deletes the runloader
+  //
+
+  if (fRunLoader)
+  {
+    fRunLoader->Delete();
+    fRunLoader = 0;
+  }
+}
diff --git a/PWG0/AliSelectorRL.h b/PWG0/AliSelectorRL.h
new file mode 100644 (file)
index 0000000..ae0e252
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef ALISELECTORRL_H
+#define ALISELECTORRL_H
+
+// Use this selector, if you have AliROOT installed (at the moment only ESD, STEER + deps)
+
+#include "AliSelector.h"
+
+class AliRun;
+class AliRunLoader;
+
+class AliSelectorRL : public AliSelector {
+  public:
+    AliSelectorRL();
+    virtual ~AliSelectorRL();
+
+    virtual Bool_t  Notify();
+    virtual void    SlaveTerminate();
+
+ protected:
+    AliRun* GetAliRun();
+
+ private:
+    void DeleteRunLoader();
+    AliRunLoader* fRunLoader;    //! pointer to the RunLoader if galice.root was opened
+
+    ClassDef(AliSelectorRL,0);
+};
+
+#endif