Example macro on how to use selector
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / AliRsnSelectRL.C
CommitLineData
2e77262c 1#include "Riostream.h"
2#include "TChain.h"
3
4void CreateXML(const char *name, Int_t from, Int_t to, const char *path)
5{
6 const char *fixed1 = "<file name=\"AliESDs.root\" aclId=\"\" ctime=\"2006-08-14 17:17:43\" dir=\"2736575\" entryId=\"2736577\" expiretime=\"\" gowner=\"aliprod\" guid=\"0096DCE6-F62B-14DE-97BF-5519E793BEEF\"";
7 const char *fixed2 = "md5=\"aaa\" owner=\"pulvir\" perm=\"755\" replicated=\"0\" seStringlist=\",72,\" size=\"19050411\"";
8
9 char fileName[100];
10 sprintf(fileName, "%s.xml", name);
11 fstream file(fileName, ios::out);
12
13 // header
14 file << "<?xml version=\"1.0\"?>" << endl;
15 file << "<alien>" << endl;
16 file << "\t<collection name=\"" << name << "\">" << endl;
17
18 // events
19 for (int i = from; i <= to; i++) {
20 file << "\t\t<event name=\"" << i << "\">" << endl;
21 file << "\t\t\t" << fixed1 << " ";
22 file << "lfn=\"" << path << "/" << i << "/AliESDs.root\" ";
23 file << fixed2 << " turl=\"" << path << "/" << i << "/AliESDs.root\" type=\"f\" />" << endl;
24 file << "\t\t</event>" << endl;
25 }
26
27 // footer
28 file << "\t</collection>" << endl;
29 file << "</alien>" << endl;
30 file.close();
31}
32
33Bool_t AliRsnSelectRL
34(
35 Int_t first_event = 1,
36 Int_t last_event = 10,
37 const char * path = "/home/pulvir/events/head-2006-11-22/hijing",
38 const char * chainName = "esdTree",
39 Long64_t nentries = TChain::kBigNumber
40)
41{
42 gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ALICE_ROOT/PWG0/ -I$ROOTSYS/include -I$ALICE_ROOT/PWG2/RESONANCES");
43 gSystem->Load("libXMLIO.so");
44 gSystem->Load("libRAliEn.so");
45 gSystem->Load("libPWG2.so");
46
47 // Create automatically the XML collection
48 char collection[255], collectionFile[255];
49 sprintf(collection, "local_%d-%d", first_event, last_event);
50 sprintf(collectionFile, "local_%d-%d.xml", first_event, last_event);
51 CreateXML(collection, first_event, last_event, path);
52
53 Info("Run", Form("Creating the collection from %s", collectionFile));
54 TAlienCollection * myCollection = new TAlienCollection(collectionFile);
55 if (!myCollection) {
56 Error("Run", Form("Cannot create an AliEn collection from %s", collectionFile));
57 return kFALSE;
58 }
59
60 Info("Run", Form("Creating the analysis chain %s", chainName));
61 TChain* analysisChain = new TChain(chainName);
62
63 Info("Run", "Preparing the file list");
64 myCollection->Reset();
65 while ( myCollection->Next() ) {
66 char esdFile[255];
67 sprintf(esdFile, "%s", myCollection->GetTURL(""));
68 Info("Run", Form("Adding %s", esdFile));
69 analysisChain->Add(esdFile);
70 }
71
72 Info("Run", "Setting parameters to selector...");
73 AliRsnSelectorRL* selector = new AliRsnSelectorRL;
74 selector->SetDebugFlag(kFALSE);
75 selector->SetStoreKineInfo(1);
76 selector->SetCheckITSRefit(1);
77 selector->SetRejectFakes(0);
78 selector->SetCopyMomentum(0);
79
80 // Define prior probabilities (only for ESD PID)
81 selector->SetPriorProbability(AliPID::kElectron, 0.042);
82 selector->SetPriorProbability(AliPID::kMuon, 0.124);
83 selector->SetPriorProbability(AliPID::kPion, 0.655);
84 selector->SetPriorProbability(AliPID::kKaon, 0.041);
85 selector->SetPriorProbability(AliPID::kProton, 0.130);
86
87 // Define PID method
88 selector->SetPIDMethod(AliRsnSelectorRL::kPerfectPID); // kESDPID or kPerfectPID
89
90 // Set output file name
91 selector->SetOutputFile(Form("selection_%d-%d.root", first_event, last_event));
92
93 // Process the chain
94 Info("Run", "Processing the chain...");
95 analysisChain->Process(selector, chainName, nentries, 0);
96
97 return kTRUE;
98}