]>
Commit | Line | Data |
---|---|---|
8c1c76e9 | 1 | void SetupPar(char* pararchivename); |
2 | void SwitchBranches(TChain *c); | |
3 | TChain * CreateXMLChain(char* xmlfile); | |
4 | TChain * CreateAODChain(const char * name = 0x0); | |
5 | ||
6 | void runPIDqa(const char *treelist = 0x0, Bool_t hasMC = kTRUE, Int_t nFiles = 5, Int_t nSkip = 0){ | |
7 | if(!treelist){ | |
8 | printf("Error: No ESD list specified\n"); | |
9 | return; | |
10 | } | |
11 | if(gSystem->Getenv("ALICE_ROOT")){ | |
12 | gSystem->Load("libANALYSIS"); | |
13 | gSystem->Load("libANALYSISalice"); | |
14 | gSystem->Load("libCORRFW"); | |
15 | } | |
16 | else{ | |
17 | SetupPar("STEERBase"); | |
18 | SetupPar("ESD"); | |
19 | SetupPar("AOD"); | |
20 | SetupPar("ANALYSIS"); | |
21 | SetupPar("ANALYSISalice"); | |
22 | SetupPar("CORRFW"); | |
23 | SetupPar("Util"); | |
24 | } | |
25 | //SetupPar("HFE"); | |
26 | gSystem->Load("libPWG3hfeDevel.so"); | |
27 | AliLog::SetClassDebugLevel("AliHFEV0pid", 0); | |
28 | AliLog::SetClassDebugLevel("AliHFEpidQA", 0); | |
29 | // gROOT->LoadMacro("AliAnalysisTaskHFE.cxx++"); | |
30 | AliLog::SetGlobalLogLevel(AliLog::kWarning); | |
31 | ||
32 | AliHFEtools::SetLogLevel(0); | |
33 | ||
34 | // Make the ESD chain | |
35 | TString treename = treelist; | |
36 | TChain *inputChain = 0x0; | |
37 | Bool_t isAOD = kFALSE; | |
38 | if(treename.EndsWith(".xml")){ | |
39 | esdchain = CreateXMLChain(treelist); | |
40 | SwitchBranches(inputChain); | |
41 | }else{ | |
42 | inputChain = CreateAODChain(treelist); | |
43 | if(inputChain) isAOD = kTRUE; | |
44 | else{ | |
45 | gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); | |
46 | inputChain = CreateESDChain(treelist, nFiles, nSkip); | |
47 | SwitchBranches(inputChain); | |
48 | } | |
49 | } | |
50 | ||
51 | // Start the Analysis Manager and Create Handlers | |
52 | AliAnalysisManager *hfeAnalysis = new AliAnalysisManager("Single Electron Analysis"); | |
53 | AliESDInputHandler *esdInputHandler; | |
54 | if(!isAOD) { | |
55 | hfeAnalysis->SetInputEventHandler(esdInputHandler = new AliESDInputHandler); | |
56 | // otherwise your proof analysis crashes if no ESD friends are available | |
57 | //esdInputHandler->SetReadFriends(kFALSE); | |
58 | } | |
59 | else hfeAnalysis->SetInputEventHandler(new AliAODInputHandler); | |
60 | if(hasMC && !isAOD) hfeAnalysis->SetMCtruthEventHandler(new AliMCEventHandler); | |
61 | ||
62 | // test the NN reference file | |
63 | TFile *f = new TFile("NNref_v2_data.root", "READ"); | |
64 | if(!f){ | |
65 | AliError("NN reference file not found"); | |
66 | return; | |
67 | } | |
68 | ||
69 | AliAnalysisTaskHFEpidQA *qaTask = new AliAnalysisTaskHFEpidQA("HFEpidQA"); | |
70 | qaTask->SetV0pidQA(); | |
71 | qaTask->SetNNref(f); | |
72 | hfeAnalysis->AddTask(qaTask); | |
73 | qaTask->ConnectInput(0, hfeAnalysis->GetCommonInputContainer()); | |
74 | qaTask->ConnectOutput(1, hfeAnalysis->CreateContainer("PIDResults", TList::Class(), AliAnalysisManager::kOutputContainer, "PIDqa.root")); | |
75 | // Run the Analysis | |
76 | if(hfeAnalysis->InitAnalysis()){ | |
77 | TStopwatch timer; | |
78 | timer.Start(); | |
79 | hfeAnalysis->StartAnalysis("local", inputChain); | |
80 | timer.Stop(); | |
81 | timer.Print(); | |
82 | } | |
83 | } | |
84 | ||
85 | //____________________________________________ | |
86 | TChain * CreateXMLChain(char* xmlfile) | |
87 | { | |
88 | ||
89 | //TChain *chain = 0x0; | |
90 | const char *chainname="esdTree"; | |
91 | TChain* chain = new TChain(chainname); | |
92 | ||
93 | TString input =xmlfile; | |
94 | cout<<" the input is::"<< xmlfile<<endl; | |
95 | ||
96 | char kXML [1000]; | |
97 | if(gSystem->Getenv("XML") ) | |
98 | kXML = gSystem->Getenv("XML"); | |
99 | else | |
100 | sprintf(kXML, xmlfile) ; | |
101 | ||
102 | // sprintf(kXML, "collection.xml") ; | |
103 | ||
104 | cout<<"XML file "<<kXML<<endl; | |
105 | ||
106 | if (!TFile::Open(kXML)) { | |
107 | printf("No collection file with name -- %s -- was found\n",kXML); | |
108 | return ; | |
109 | } | |
110 | gSystem->Load("libNetx.so") ; | |
111 | gSystem->Load("libRAliEn.so"); | |
112 | TGrid::Connect("alien://") ; | |
113 | ||
114 | ||
115 | ||
116 | // TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML)); | |
117 | TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML); | |
118 | if (! collection) { | |
119 | AliError(Form("%s not found", kXML)) ; | |
120 | return kFALSE ; | |
121 | } | |
122 | //collection->CheckIfOnline(); | |
123 | ||
124 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
125 | ||
126 | // TList* analysisfilelist = result->GetFileInfoList(); | |
127 | ||
128 | // Makes the ESD chain | |
129 | printf("*** Getting the Chain ***\n"); | |
130 | ||
131 | for (Int_t index = 0; index < result->GetEntries(); index++) { | |
132 | TString alienURL = result->GetKey(index, "turl") ; | |
133 | cout << "================== " << alienURL << endl ; | |
134 | chain->Add(alienURL) ; | |
135 | //alienURL.ReplaceAll("AliESDs.root",kXSFileName); | |
136 | // chainxs->Add(alienURL) ; | |
137 | } | |
138 | ||
139 | ||
140 | // chain->AddFileInfoList(analysisfilelist); | |
141 | if (chain) chain->ls(); | |
142 | chain->SetBranchStatus("*Calo*",0); | |
143 | chain->SetBranchStatus("*FMD*",0); | |
144 | return chain; | |
145 | } | |
146 | ||
147 | //______________________________________________________________________________ | |
148 | TChain *CreateAODChain(const char * name){ | |
149 | if(!name) return NULL; | |
150 | ifstream filelist(name); | |
151 | string filename; | |
152 | TChain *c = new TChain("aodTree"); | |
153 | Bool_t isAODlist = kTRUE; | |
154 | while(getline(filelist,filename)){ | |
155 | if(!strstr(filename.c_str(), "AliAOD")){ | |
156 | isAODlist = kFALSE; | |
157 | break; | |
158 | } | |
159 | c->Add(filename.c_str()); | |
160 | } | |
161 | if(!isAODlist){ | |
162 | printf("No AOD anlysis\n"); | |
163 | delete c; | |
164 | return NULL; | |
165 | } | |
166 | return c; | |
167 | } | |
168 | ||
169 | //______________________________________________________________________________ | |
170 | void SetupPar(char* pararchivename) | |
171 | { | |
172 | if (pararchivename) { | |
173 | char processline[1024]; | |
174 | sprintf(processline,".! tar xvzf %s.par",pararchivename); | |
175 | gROOT->ProcessLine(processline); | |
176 | TString ocwd = gSystem->WorkingDirectory(); | |
177 | gSystem->ChangeDirectory(pararchivename); | |
178 | ||
179 | // check for BUILD.sh and execute | |
180 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
181 | printf("*******************************\n"); | |
182 | printf("*** Building PAR archive ***\n"); | |
183 | printf("*******************************\n"); | |
184 | ||
185 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
186 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
187 | return -1; | |
188 | } | |
189 | } | |
190 | // check for SETUP.C and execute | |
191 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
192 | printf("*******************************\n"); | |
193 | printf("*** Setup PAR archive ***\n"); | |
194 | printf("*******************************\n"); | |
195 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
196 | } | |
197 | ||
198 | gSystem->ChangeDirectory(ocwd.Data()); | |
199 | printf("Current dir: %s\n", ocwd.Data()); | |
200 | } | |
201 | } | |
202 | ||
203 | void SwitchBranches(TChain *c){ | |
204 | //esdchain->SetBranchStatus("*", 0); | |
205 | c->SetBranchStatus("Calo*", 0); | |
206 | c->SetBranchStatus("*FMD*", 1); | |
207 | c->SetBranchStatus("Tracks", 1); | |
208 | } |