]>
Commit | Line | Data |
---|---|---|
809a4336 | 1 | void SetupPar(char* pararchivename); |
2 | TChain * CreateXMLChain(char* xmlfile); | |
3 | ||
4 | void runElectronTask(const char *treelist = 0x0){ | |
5 | if(!treelist){ | |
6 | printf("Error: No ESD list specified\n"); | |
7 | return; | |
8 | } | |
9 | if(gSystem->Getenv("ALICE_ROOT")){ | |
10 | gSystem->Load("libANALYSIS"); | |
11 | gSystem->Load("libANALYSISalice"); | |
12 | gSystem->Load("libCORRFW"); | |
13 | } | |
14 | else{ | |
15 | SetupPar("STEERBase"); | |
16 | SetupPar("ESD"); | |
17 | SetupPar("AOD"); | |
18 | SetupPar("ANALYSIS"); | |
19 | SetupPar("ANALYSISalice"); | |
20 | SetupPar("CORRFW"); | |
21 | SetupPar("Util"); | |
22 | } | |
23 | SetupPar("HFE"); | |
24 | gROOT->LoadMacro("AliAnalysisElectronTask.cxx++"); | |
25 | AliLog::SetGlobalLogLevel(AliLog::kError); | |
26 | ||
27 | // Make the ESD chain | |
28 | TString treename = treelist; | |
29 | TChain *esdchain = 0x0; | |
30 | if(treename.EndsWith(".xml")) | |
31 | esdchain = CreateXMLChain(treelist); | |
32 | else{ | |
33 | gROOT->LoadMacro("CreateESDChain.C"); | |
34 | esdchain = CreateESDChain(treelist, -1); | |
35 | } | |
36 | //esdchain->SetBranchStatus("*", 0); | |
37 | esdchain->SetBranchStatus("Calo*", 0); | |
38 | esdchain->SetBranchStatus("*FMD*", 1); | |
39 | esdchain->SetBranchStatus("Tracks", 1); | |
40 | ||
41 | // Start the Analysis Manager and Create Handlers | |
259c3296 | 42 | AliAnalysisManager *pidEffManager = new AliAnalysisManager("Single Electron Analysis"); |
809a4336 | 43 | pidEffManager->SetInputEventHandler(new AliESDInputHandler); |
44 | pidEffManager->SetMCtruthEventHandler(new AliMCEventHandler); | |
45 | AliAnalysisElectronTask *task = new AliAnalysisElectronTask; | |
46 | pidEffManager->AddTask(task); | |
47 | task->ConnectInput(0, pidEffManager->CreateContainer("esdTree", TChain::Class(), AliAnalysisManager::kInputContainer)); | |
48 | task->ConnectOutput(0, pidEffManager->CreateContainer("nEvents", TH1I::Class(), AliAnalysisManager::kOutputContainer, "HFEtask.root")); | |
259c3296 | 49 | task->ConnectOutput(1, pidEffManager->CreateContainer("Results", TList::Class(), AliAnalysisManager::kOutputContainer, "HFEtask.root")); |
809a4336 | 50 | task->ConnectOutput(2, pidEffManager->CreateContainer("QA", TList::Class(), AliAnalysisManager::kOutputContainer, "HFEtask.root")); |
51 | ||
52 | // Run the Analysis | |
53 | if(pidEffManager->InitAnalysis()){ | |
54 | TStopwatch timer; | |
55 | timer.Start(); | |
56 | pidEffManager->StartAnalysis("local", esdchain); | |
57 | timer.Stop(); | |
58 | timer.Print(); | |
59 | } | |
60 | } | |
61 | ||
62 | //____________________________________________ | |
63 | TChain * CreateXMLChain(char* xmlfile) | |
64 | { | |
65 | ||
66 | //TChain *chain = 0x0; | |
67 | const char *chainname="esdTree"; | |
68 | TChain* chain = new TChain(chainname); | |
69 | ||
70 | TString input =xmlfile; | |
71 | cout<<" the input is::"<< xmlfile<<endl; | |
72 | ||
73 | char kXML [1000]; | |
74 | if(gSystem->Getenv("XML") ) | |
75 | kXML = gSystem->Getenv("XML"); | |
76 | else | |
77 | sprintf(kXML, xmlfile) ; | |
78 | ||
79 | // sprintf(kXML, "collection.xml") ; | |
80 | ||
81 | cout<<"XML file "<<kXML<<endl; | |
82 | ||
83 | if (!TFile::Open(kXML)) { | |
84 | printf("No collection file with name -- %s -- was found\n",kXML); | |
85 | return ; | |
86 | } | |
87 | gSystem->Load("libNetx.so") ; | |
88 | gSystem->Load("libRAliEn.so"); | |
89 | TGrid::Connect("alien://") ; | |
90 | ||
91 | ||
92 | ||
93 | // TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML)); | |
94 | TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML); | |
95 | if (! collection) { | |
96 | AliError(Form("%s not found", kXML)) ; | |
97 | return kFALSE ; | |
98 | } | |
99 | //collection->CheckIfOnline(); | |
100 | ||
101 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
102 | ||
103 | // TList* analysisfilelist = result->GetFileInfoList(); | |
104 | ||
105 | // Makes the ESD chain | |
106 | printf("*** Getting the Chain ***\n"); | |
107 | ||
108 | for (Int_t index = 0; index < result->GetEntries(); index++) { | |
109 | TString alienURL = result->GetKey(index, "turl") ; | |
110 | cout << "================== " << alienURL << endl ; | |
111 | chain->Add(alienURL) ; | |
112 | //alienURL.ReplaceAll("AliESDs.root",kXSFileName); | |
113 | // chainxs->Add(alienURL) ; | |
114 | } | |
115 | ||
116 | ||
117 | // chain->AddFileInfoList(analysisfilelist); | |
118 | if (chain) chain->ls(); | |
119 | chain->SetBranchStatus("*Calo*",0); | |
120 | chain->SetBranchStatus("*FMD*",0); | |
121 | return chain; | |
122 | } | |
123 | ||
124 | //______________________________________________________________________________ | |
125 | void SetupPar(char* pararchivename) | |
126 | { | |
127 | if (pararchivename) { | |
128 | char processline[1024]; | |
129 | sprintf(processline,".! tar xvzf %s.par",pararchivename); | |
130 | gROOT->ProcessLine(processline); | |
131 | TString ocwd = gSystem->WorkingDirectory(); | |
132 | gSystem->ChangeDirectory(pararchivename); | |
133 | ||
134 | // check for BUILD.sh and execute | |
135 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
136 | printf("*******************************\n"); | |
137 | printf("*** Building PAR archive ***\n"); | |
138 | printf("*******************************\n"); | |
139 | ||
140 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
141 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
142 | return -1; | |
143 | } | |
144 | } | |
145 | // check for SETUP.C and execute | |
146 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
147 | printf("*******************************\n"); | |
148 | printf("*** Setup PAR archive ***\n"); | |
149 | printf("*******************************\n"); | |
150 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
151 | } | |
152 | ||
153 | gSystem->ChangeDirectory(ocwd.Data()); | |
154 | printf("Current dir: %s\n", ocwd.Data()); | |
155 | } | |
156 | } |