]>
Commit | Line | Data |
---|---|---|
94ef1a28 | 1 | //-------------------------------------------------------------------------- |
2 | // Base macro for submitting muon QA analysis. | |
3 | // | |
4 | // In case it is not run with full aliroot, it needs the following libraries: | |
5 | // - libSTEERBase.so | |
6 | // - libESD.so | |
7 | // - libAOD.so | |
8 | // - libANALYSIS.so | |
9 | // - libANALYSISalice.so | |
10 | // - libCORRFW.so | |
11 | // - libPWG3muon.so | |
12 | // | |
13 | // The macro reads ESDs and store outputs in standard output file (AnalysisResults.root) | |
14 | // | |
15 | // Author: Philippe Pillot - SUBATECH Nantes | |
16 | //-------------------------------------------------------------------------- | |
17 | ||
18 | enum {kLocal, kInteractif_xml, kInteractif_ESDList}; | |
19 | ||
b4f7418a | 20 | void RunMuonQA(TString inputFileName = "AliESDs.root", Bool_t selectPhysics = kTRUE, |
76e3d5d4 | 21 | Bool_t selectTrigger = kTRUE, Bool_t selectMatched = kFALSE, Short_t selectCharge = 0) |
94ef1a28 | 22 | { |
23 | TStopwatch timer; | |
24 | timer.Start(); | |
25 | ||
26 | // Check runing mode | |
27 | Int_t mode = GetMode(inputFileName); | |
28 | if(mode < 0){ | |
29 | Error("RunMuonQA","Please provide either an ESD root file or a collection of ESDs."); | |
30 | return; | |
31 | } | |
32 | ||
33 | // Load common libraries | |
34 | gSystem->Load("libTree"); | |
35 | gSystem->Load("libGeom"); | |
36 | gSystem->Load("libVMC"); | |
37 | gSystem->Load("libPhysics"); | |
38 | gSystem->Load("libSTEERBase"); | |
39 | gSystem->Load("libESD"); | |
40 | gSystem->Load("libAOD"); | |
41 | gSystem->Load("libANALYSIS"); | |
42 | gSystem->Load("libANALYSISalice"); | |
43 | gSystem->Load("libCORRFW"); | |
44 | gSystem->Load("libPWG3muon"); | |
45 | ||
46 | // Create input chain | |
47 | TChain* chain = CreateChain(inputFileName); | |
48 | if (!chain) return; | |
49 | ||
50 | // Create the analysis manager | |
51 | AliAnalysisManager *mgr = new AliAnalysisManager("MuonQAAnalysis"); | |
52 | ||
53 | // ESD input handler | |
54 | AliESDInputHandler* esdH = new AliESDInputHandler(); | |
55 | esdH->SetReadFriends(kFALSE); | |
56 | mgr->SetInputEventHandler(esdH); | |
57 | ||
58 | // event selection | |
59 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
60 | AliPhysicsSelectionTask* physicsSelection = AddTaskPhysicsSelection(); | |
61 | if(!physicsSelection) { | |
62 | Error("RunMuonQA","AliPhysicsSelectionTask not created!"); | |
63 | return; | |
64 | } | |
65 | ||
66 | // Muon QA analysis | |
67 | gROOT->LoadMacro("$ALICE_ROOT/PWG3/muon/AddTaskMuonQA.C"); | |
76e3d5d4 | 68 | AliAnalysisTaskMuonQA* muonQA = AddTaskMuonQA(selectPhysics, selectTrigger, selectMatched, selectCharge); |
94ef1a28 | 69 | if(!muonQA) { |
70 | Error("RunMuonQA","AliAnalysisTaskMuonQA not created!"); | |
71 | return; | |
72 | } | |
73 | ||
74 | // Enable debug printouts | |
75 | //mgr->SetDebugLevel(2); | |
76 | ||
77 | // start local analysis | |
78 | if (mgr->InitAnalysis()) { | |
79 | mgr->PrintStatus(); | |
80 | mgr->StartAnalysis("local", chain); | |
81 | } | |
82 | ||
83 | timer.Stop(); | |
84 | timer.Print(); | |
85 | } | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | Int_t GetMode(TString inputFileName) | |
89 | { | |
90 | if ( inputFileName.EndsWith(".xml") ) return kInteractif_xml; | |
91 | else if ( inputFileName.EndsWith(".txt") ) return kInteractif_ESDList; | |
92 | else if ( inputFileName.EndsWith(".root") ) return kLocal; | |
93 | return -1; | |
94 | } | |
95 | ||
96 | //______________________________________________________________________________ | |
97 | TChain* CreateChainFromCollection(const char *xmlfile) | |
98 | { | |
99 | // Create a chain from the collection of tags. | |
100 | TAlienCollection* coll = TAlienCollection::Open(xmlfile); | |
101 | if (!coll) { | |
102 | ::Error("CreateChainFromTags", "Cannot create an AliEn collection from %s", xmlfile); | |
103 | return NULL; | |
104 | } | |
105 | ||
106 | TGridResult* tagResult = coll->GetGridResult("",kFALSE,kFALSE); | |
107 | AliTagAnalysis *tagAna = new AliTagAnalysis("ESD"); | |
108 | tagAna->ChainGridTags(tagResult); | |
109 | ||
110 | AliRunTagCuts *runCuts = new AliRunTagCuts(); | |
111 | AliLHCTagCuts *lhcCuts = new AliLHCTagCuts(); | |
112 | AliDetectorTagCuts *detCuts = new AliDetectorTagCuts(); | |
113 | AliEventTagCuts *evCuts = new AliEventTagCuts(); | |
114 | ||
115 | // Check if the cuts configuration file was provided | |
116 | if (!gSystem->AccessPathName("ConfigureCuts.C")) { | |
117 | gROOT->LoadMacro("ConfigureCuts.C"); | |
118 | ConfigureCuts(runCuts, lhcCuts, detCuts, evCuts); | |
119 | } | |
120 | ||
121 | TChain *chain = tagAna->QueryTags(runCuts, lhcCuts, detCuts, evCuts); | |
122 | if (!chain || !chain->GetNtrees()) return NULL; | |
123 | chain->ls(); | |
124 | return chain; | |
125 | } | |
126 | ||
127 | //______________________________________________________________________________ | |
128 | TChain* CreateChainFromFile(const char *rootfile) | |
129 | { | |
130 | // Create a chain using the root file. | |
131 | TChain* chain = new TChain("esdTree"); | |
132 | chain->Add(rootfile); | |
133 | if (!chain->GetNtrees()) return NULL; | |
134 | chain->ls(); | |
135 | return chain; | |
136 | } | |
137 | ||
138 | //______________________________________________________________________________ | |
139 | TChain* CreateChainFromESDList(const char *esdList) | |
140 | { | |
141 | // Create a chain using tags from the run list. | |
142 | TChain* chain = new TChain("esdTree"); | |
143 | ifstream inFile(esdList); | |
144 | TString inFileName; | |
145 | if (inFile.is_open()) { | |
146 | while (! inFile.eof() ) { | |
147 | inFileName.ReadLine(inFile,kFALSE); | |
148 | if(!inFileName.EndsWith(".root")) continue; | |
149 | chain->Add(inFileName.Data()); | |
150 | } | |
151 | } | |
152 | inFile.close(); | |
153 | if (!chain->GetNtrees()) return NULL; | |
154 | chain->ls(); | |
155 | return chain; | |
156 | } | |
157 | ||
158 | //______________________________________________________________________________ | |
159 | TChain* CreateChain(TString inputFileName) | |
160 | { | |
161 | printf("*******************************\n"); | |
162 | printf("*** Getting the Chain ***\n"); | |
163 | printf("*******************************\n"); | |
164 | Int_t mode = GetMode(inputFileName); | |
165 | if(mode == kInteractif_xml) return CreateChainFromCollection(inputFileName.Data()); | |
166 | else if (mode == kInteractif_ESDList) return CreateChainFromESDList(inputFileName.Data()); | |
167 | else if (mode == kLocal) return CreateChainFromFile(inputFileName.Data()); | |
168 | else return NULL; | |
169 | } | |
170 |