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