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