Line data Source code
1 : #ifndef ALIEXTERNALINFO_H
2 : #define ALIEXTERNALINFO_H
3 :
4 : /// \class AliExternalInfo
5 : /// \brief This class gives you an interface to different trees of information spread throughout ALICE
6 : ///
7 : /// Related task: https://alice.its.cern.ch/jira/browse/ATO-46
8 : /// With this class you can easily download and use information from different
9 : /// resources in ALICE, like the RCT, logbook, QA...
10 : ///
11 : /// For the correct usage of this class you need to have a certificate which does not need typing in your password.
12 : /**
13 :
14 : Examples:
15 :
16 : 1) Get the tree from a QA tree
17 :
18 : AliExternalInfo b(".", "config.cfg"); // first parameter is the working directory. Second parameter is the configuration file.
19 : b.Cache("QA.TPC", "LHC15f", "pass2"); // Actually not needed because "GetTree(...)" chechs if the resource has been if this is not the case it will automatically call Cache(...)
20 : TTree* treeTPCQA15fPass2 = b.GetTree("QA.TPC", "LHC15f", "pass2"); // Returns a tree with the information of the resource
21 : // TTree* treeTPCQA15fPass2 = b.GetTreeDataQA("TPC", "LHC15f", "pass2"); // Different method to get the tree. Calls internally the "Cache(...)" function
22 : treeTPCQA15fPass2->Print(); // Do something with the tree
23 :
24 : 2a) Create a chain
25 : b.Cache("QA.EVS", "LHC10b", "pass4"); Downloads the resource
26 : b.Cache("QA.EVS", "LHC10c", "pass4");
27 : b.Cache("QA.EVS", "LHC10d", "pass4");
28 : TChain* chain10evs = b.GetChain("QA.EVS", "LHC10*", "pass4"); // Creates a chain of all downloaded resources. Note the '*' which is used like in ls
29 : chain10evs->Draw("interactionRate:run", "", "*"); // Draws a histogram interaction rate vs run
30 :
31 : 2b) Create a chain
32 : TTree * treeProdCycle7076 = b.GetTreeProdCycleByID("7076");
33 : TTree * treeProdCycle7236 = b.GetTreeProdCycleByID("7236");
34 : TTree * treeProdCycle7214 = b.GetTreeProdCycleByID("7214");
35 : TChain* chainProdCycleIDs = b.GetChainProdCycleByID("[0-9]*"); // needs number wildcards because a ProdCycle.root is also available
36 : chainProdCycleIDs->Print();
37 :
38 : 3) Using the friends tree
39 : TTree* treeTPCQA15fPass1 = b.GetTree("QA.TPC", "LHC15f", "pass2");
40 : TTree* treeEVSQA15fPass1 = b.GetTree("QA.EVS", "LHC15f", "pass2");
41 : // TTree* treeTPCQA15hPass1 = b.GetTree("QA.TPC", "LHC15h", "pass1"); // Only one single tree of type can be added to the friends tree
42 : // TTree* treeEVSQA15hPass1 = b.GetTree("QA.EVS", "LHC15h", "pass1"); // Only one single tree of type can be added to the friends tree
43 : b.GetFriendsTree()->Draw("TPC.tpcItsMatchA:EVS.interactionRate","TPC.meanMult>0", "*");
44 : c1.SaveAs("c1.png");
45 : */
46 : /// \author Carsten Klein <Carsten.Klein@cern.ch>, Goethe Universität Frankfurt
47 : /// \date Jan 18, 2016
48 :
49 : #include <map>
50 :
51 : #include "TString.h"
52 :
53 : // forward declarations
54 : class TTree;
55 : class TChain;
56 :
57 0 : class AliExternalInfo : public TObject {
58 : public:
59 : AliExternalInfo (TString localStorageDirectory = ".", TString configLocation = "$ALICE_ROOT/STAT/Macros/AliExternalInfo.cfg"/*, Bool_t copyToLocalStorage = kTRUE*/);
60 : virtual ~AliExternalInfo();
61 : void ReadConfig();
62 : void PrintConfig();
63 : Bool_t Cache(TString type="", TString period = "", TString pass=""); // Downloads the tree in the working directory
64 0 : Bool_t CacheMC() {return Cache("MonALISA.MC", "", "");}
65 0 : Bool_t CacheRCT(TString period, TString pass) {return Cache("MonALISA.RCT", period, pass);}
66 0 : Bool_t CacheDataQA(TString detector, TString period, TString pass) {return Cache("QA." + detector, period, pass);}
67 0 : Bool_t CacheLogbook(TString period) {return Cache("Logbook", period, "");}
68 0 : Bool_t CacheTriggerClasses(TString period) {return Cache("TriggerClasses", period, "");}
69 0 : Bool_t CacheProdCycle() {return Cache("MonALISA.ProductionCycle", "", "");}
70 0 : Bool_t CacheProdCycleByID(TString ID) {return Cache("MonALISA.ProductionCycleID", ID, "");}
71 :
72 : TTree* GetTree(TString type, TString period, TString pass);
73 0 : TTree* GetTreeMC() {return GetTree("MonALISA.MC", "", "");}
74 : // TTree* GetTreeMC(TString period = "", TString anchorYear = "", TString productionTag = "") {return GetTree("MonALISA.MC", "", "");} // deprecated; not supported anymore
75 0 : TTree* GetTreeRCT(TString period, TString pass) {return GetTree("MonALISA.RCT", period, pass);}
76 0 : TTree* GetTreeDataQA(TString detector, TString period, TString pass) {return GetTree("QA." + detector, period, pass);}
77 0 : TTree* GetTreeLogbook(TString period) {return GetTree("Logbook", period, "");}
78 0 : TTree* GetTreeTriggerClasses(TString period) {return GetTree("TriggerClasses", period, "");}
79 0 : TTree* GetTreeProdCycle() {return GetTree("MonALISA.ProductionCycle", "", "");}
80 0 : TTree* GetTreeProdCycleByID(TString ID) {return GetTree("MonALISA.ProductionCycleID", ID, "");}
81 :
82 : TChain* GetChain(TString type, TString period, TString pass);
83 0 : TChain* GetChainMC() {return GetChain("MonALISA.MC", "", "");}
84 0 : TChain* GetChainRCT(TString period, TString pass) {return GetChain("MonALISA.RCT", period, pass);}
85 0 : TChain* GetChainDataQA(TString detector, TString period, TString pass){return GetChain("QA." + detector, period, pass);}
86 0 : TChain* GetChainLogbook(TString period) {return GetChain("Logbook", period, "");}
87 0 : TChain* GetChainTriggerClasses(TString period) {return GetChain("TriggerClasses", period, "");}
88 0 : TChain* GetChainProdCycle() {return GetChain("MonALISA.ProductionCycle", "", "");}
89 0 : TChain* GetChainProdCycleByID(TString ID) {return GetChain("MonALISA.ProductionCycleID", ID, "");}
90 :
91 0 : TTree* GetFriendsTree() const {return fTree;}
92 0 : TChain* GetFriendsChain() const {return fChain;} // _Not_ working properly!!!
93 :
94 0 : void SetMaxCacheSize(Long64_t size) { fMaxCacheSize=size; }
95 0 : Long64_t GetMaxCacheSize() const { return fMaxCacheSize; }
96 :
97 0 : static const TString& GetDefaultConfig() { return fgkDefaultConfig; }
98 :
99 : private:
100 : Bool_t AddTree(TTree* tree, TString type);
101 : Bool_t AddChain(TString type, TString period, TString pass);
102 : void SetupVariables(TString& internalFilename, TString& internalLocation, Bool_t& resourceIsTree, TString& pathStructure, \
103 : TString& detector, TString& rootFileName, TString& treeName, const TString& type, const TString& period, const TString& pass);
104 : const TString GetYearFromPeriod(const TString& period);
105 : const TString Wget(TString& mifFilePath, const TString& internalLocation, TString rootFileName, const TString& externalLocation);
106 : const TString CreatePath(TString type, TString period, TString pass);
107 : Bool_t IsDownloadNeeded(TString file, TString type);
108 :
109 : // Bool_t fCopyDataToLocalStorage;
110 : TString fConfigLocation; ///< location of the config file
111 : TString fLocalStorageDirectory; ///< location of the local cache directory
112 : std::map<TString, TString> fLocationTimeOutMap; ///< map with configuration parameters
113 : TTree* fTree; ///< master tree with friends
114 : TChain* fChain; ///< master chain with friends
115 : std::map<TString, TChain*> fChainMap; ///< map of chains
116 : Long64_t fMaxCacheSize; ///< maximum chache size for trees and chains
117 :
118 : static const TString fgkDefaultConfig; ///< default config file
119 :
120 128 : ClassDef(AliExternalInfo, 0); // interface to various trending trees
121 :
122 : };
123 :
124 : #endif // ALIEXTERNALINFO_H
|