1 void SetupPar(char* pararchivename);
2 void SwitchBranches(TChain *c);
3 TChain * CreateXMLChain(char* xmlfile);
4 TChain * CreateAODChain(const char * name = 0x0);
6 void runPIDqa(const char *treelist = 0x0, Bool_t hasMC = kTRUE, Int_t nFiles = 5, Int_t nSkip = 0){
8 printf("Error: No ESD list specified\n");
11 if(gSystem->Getenv("ALICE_ROOT")){
12 gSystem->Load("libANALYSIS");
13 gSystem->Load("libANALYSISalice");
14 gSystem->Load("libCORRFW");
17 SetupPar("STEERBase");
21 SetupPar("ANALYSISalice");
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);
32 AliHFEtools::SetLogLevel(0);
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);
42 inputChain = CreateAODChain(treelist);
43 if(inputChain) isAOD = kTRUE;
45 gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
46 inputChain = CreateESDChain(treelist, nFiles, nSkip);
47 SwitchBranches(inputChain);
51 // Start the Analysis Manager and Create Handlers
52 AliAnalysisManager *hfeAnalysis = new AliAnalysisManager("Single Electron Analysis");
53 AliESDInputHandler *esdInputHandler;
55 hfeAnalysis->SetInputEventHandler(esdInputHandler = new AliESDInputHandler);
56 // otherwise your proof analysis crashes if no ESD friends are available
57 //esdInputHandler->SetReadFriends(kFALSE);
59 else hfeAnalysis->SetInputEventHandler(new AliAODInputHandler);
60 if(hasMC && !isAOD) hfeAnalysis->SetMCtruthEventHandler(new AliMCEventHandler);
62 // test the NN reference file
63 TFile *f = new TFile("NNref_v2_data.root", "READ");
65 AliError("NN reference file not found");
69 AliAnalysisTaskHFEpidQA *qaTask = new AliAnalysisTaskHFEpidQA("HFEpidQA");
72 hfeAnalysis->AddTask(qaTask);
73 qaTask->ConnectInput(0, hfeAnalysis->GetCommonInputContainer());
74 qaTask->ConnectOutput(1, hfeAnalysis->CreateContainer("PIDResults", TList::Class(), AliAnalysisManager::kOutputContainer, "PIDqa.root"));
76 if(hfeAnalysis->InitAnalysis()){
79 hfeAnalysis->StartAnalysis("local", inputChain);
85 //____________________________________________
86 TChain * CreateXMLChain(char* xmlfile)
89 //TChain *chain = 0x0;
90 const char *chainname="esdTree";
91 TChain* chain = new TChain(chainname);
93 TString input =xmlfile;
94 cout<<" the input is::"<< xmlfile<<endl;
97 if(gSystem->Getenv("XML") )
98 kXML = gSystem->Getenv("XML");
100 sprintf(kXML, xmlfile) ;
102 // sprintf(kXML, "collection.xml") ;
104 cout<<"XML file "<<kXML<<endl;
106 if (!TFile::Open(kXML)) {
107 printf("No collection file with name -- %s -- was found\n",kXML);
110 gSystem->Load("libNetx.so") ;
111 gSystem->Load("libRAliEn.so");
112 TGrid::Connect("alien://") ;
116 // TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\", 0)", kXML));
117 TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
119 AliError(Form("%s not found", kXML)) ;
122 //collection->CheckIfOnline();
124 TGridResult* result = collection->GetGridResult("",0 ,0);
126 // TList* analysisfilelist = result->GetFileInfoList();
128 // Makes the ESD chain
129 printf("*** Getting the Chain ***\n");
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) ;
140 // chain->AddFileInfoList(analysisfilelist);
141 if (chain) chain->ls();
142 chain->SetBranchStatus("*Calo*",0);
143 chain->SetBranchStatus("*FMD*",0);
147 //______________________________________________________________________________
148 TChain *CreateAODChain(const char * name){
149 if(!name) return NULL;
150 ifstream filelist(name);
152 TChain *c = new TChain("aodTree");
153 Bool_t isAODlist = kTRUE;
154 while(getline(filelist,filename)){
155 if(!strstr(filename.c_str(), "AliAOD")){
159 c->Add(filename.c_str());
162 printf("No AOD anlysis\n");
169 //______________________________________________________________________________
170 void SetupPar(char* pararchivename)
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);
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");
185 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
186 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
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");
198 gSystem->ChangeDirectory(ocwd.Data());
199 printf("Current dir: %s\n", ocwd.Data());
203 void SwitchBranches(TChain *c){
204 //esdchain->SetBranchStatus("*", 0);
205 c->SetBranchStatus("Calo*", 0);
206 c->SetBranchStatus("*FMD*", 1);
207 c->SetBranchStatus("Tracks", 1);