]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/AliSelectorRL.cxx
Adding a selector that can be used for analysis requiring the RunLoader (and thus...
[u/mrichter/AliRoot.git] / PWG0 / AliSelectorRL.cxx
CommitLineData
0c7e8af2 1#include "AliSelectorRL.h"
2
3#include <AliLog.h>
4#include <AliRun.h>
5#include <AliRunLoader.h>
6
7ClassImp(AliSelectorRL)
8
9AliSelectorRL::AliSelectorRL() :
10 AliSelector(),
11 fRunLoader(0)
12{
13 //
14 // Constructor. Initialization of pointers
15 //
16}
17
18AliSelectorRL::~AliSelectorRL()
19{
20 //
21 // Destructor
22 //
23
24 // histograms are in the output list and deleted when the output
25 // list is deleted by the TSelector dtor
26}
27
28Bool_t AliSelectorRL::Notify()
29{
30 // Calls base class Notify
31 // On top of that run loader is closed, because we change the input file
32
33 if (AliSelector::Notify() == kFALSE)
34 return kFALSE;
35
36 DeleteRunLoader();
37
38 return kTRUE;
39}
40
41void AliSelectorRL::SlaveTerminate()
42{
43 // removes runloader
44
45 AliSelector::SlaveTerminate();
46
47 DeleteRunLoader();
48}
49
50AliRun* AliSelectorRL::GetAliRun()
51{
52 // Returns AliRun instance corresponding to current ESD active in fChain
53 // Loads galice.root, the file is identified by replacing "AliESDs" to
54 // "galice" in the file path of the ESD file. This is a hack, to be changed!
55
56 if (!fRunLoader)
57 {
58 if (!fChain->GetCurrentFile())
59 return 0;
60
61 TString fileName(fChain->GetCurrentFile()->GetName());
62 fileName.ReplaceAll("AliESDs", "galice");
63
64 fRunLoader = AliRunLoader::Open(fileName);
65 if (!fRunLoader)
66 return 0;
67
68 fRunLoader->LoadgAlice();
69 }
70
71 return fRunLoader->GetAliRun();
72}
73
74void AliSelectorRL::DeleteRunLoader()
75{
76 //
77 // deletes the runloader
78 //
79
80 if (fRunLoader)
81 {
82 fRunLoader->Delete();
83 fRunLoader = 0;
84 }
85}