]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/multiplicity/run.C
adding trigger as flag
[u/mrichter/AliRoot.git] / PWG0 / multiplicity / run.C
CommitLineData
745d6088 1void run(Char_t* data, Long64_t nRuns = -1, Long64_t offset = 0, Bool_t aDebug = kFALSE, Int_t aProof = 0, Bool_t mc = kTRUE, const char* option = "")
a9017e49 2{
745d6088 3 // aProof option: 0 no proof
4 // 1 proof with chain
5 // 2 proof with dataset
6
7 if (nRuns < 0)
8 nRuns = 1234567890;
9
a9017e49 10 if (aProof)
11 {
12 TProof::Open("lxb6046");
13
14 // Enable the needed package
dca331bb 15 if (1)
16 {
17 gProof->UploadPackage("$ALICE_ROOT/STEERBase");
18 gProof->EnablePackage("$ALICE_ROOT/STEERBase");
19 gProof->UploadPackage("$ALICE_ROOT/ESD");
20 gProof->EnablePackage("$ALICE_ROOT/ESD");
21 gProof->UploadPackage("$ALICE_ROOT/AOD");
22 gProof->EnablePackage("$ALICE_ROOT/AOD");
23 gProof->UploadPackage("$ALICE_ROOT/ANALYSIS");
24 gProof->EnablePackage("$ALICE_ROOT/ANALYSIS");
25 gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice");
26 gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice");
27 }
28 else
29 {
30 gProof->UploadPackage("$ALICE_ROOT/AF-v4-12");
31 gProof->EnablePackage("$ALICE_ROOT/AF-v4-12");
32 }
745d6088 33
34 gProof->UploadPackage("$ALICE_ROOT/PWG0base");
35 gProof->EnablePackage("$ALICE_ROOT/PWG0base");
a9017e49 36 }
37 else
38 {
39 gSystem->Load("libVMC");
40 gSystem->Load("libTree");
41 gSystem->Load("libSTEERBase");
42 gSystem->Load("libESD");
dca331bb 43 gSystem->Load("libAOD");
a9017e49 44 gSystem->Load("libANALYSIS");
dca331bb 45 gSystem->Load("libANALYSISalice");
a9017e49 46 gSystem->Load("libPWG0base");
47 }
48
a9017e49 49 // Create the analysis manager
dca331bb 50 mgr = new AliAnalysisManager;
a9017e49 51
a2cdb42c 52 AliPWG0Helper::AnalysisMode analysisMode = AliPWG0Helper::kTPC;
53 AliPWG0Helper::Trigger trigger = AliPWG0Helper::kMB1;
54
55 AliPWG0Helper::PrintConf(analysisMode, trigger);
a9017e49 56
57 TString taskName("AliMultiplicityTask.cxx+");
58 if (aDebug)
59 taskName += "+g";
60
61 // Create, add task
745d6088 62 if (aProof > 0) {
a9017e49 63 gProof->Load(taskName);
64 } else
65 gROOT->Macro(taskName);
66
2fa65f52 67 task = new AliMultiplicityTask(option);
f3eb27f6 68
69 if (analysisMode != AliPWG0Helper::kSPD)
70 {
71 // selection of esd tracks
72 gROOT->ProcessLine(".L ../CreateStandardCuts.C");
73 AliESDtrackCuts* esdTrackCuts = CreateTrackCuts(analysisMode);
74 if (!esdTrackCuts)
75 {
76 printf("ERROR: esdTrackCuts could not be created\n");
77 return;
78 }
79
80 task->SetTrackCuts(esdTrackCuts);
81 }
82
745d6088 83 task->SetAnalysisMode(analysisMode);
a2cdb42c 84 task->SetTrigger(trigger);
2fa65f52 85
86 if (mc)
87 task->SetReadMC();
88
f3eb27f6 89 //task->SetUseMCVertex();
90
a9017e49 91 mgr->AddTask(task);
92
2fa65f52 93 if (mc) {
94 // Enable MC event handler
95 AliMCEventHandler* handler = new AliMCEventHandler;
96 handler->SetReadTR(kFALSE);
97 mgr->SetMCtruthEventHandler(handler);
98 }
a9017e49 99
dca331bb 100 // pt study
101 TString optionStr(option);
102 if (optionStr.Contains("pt-spectrum-func"))
103 {
104 //TF1* func = new TF1("func", "0.7 + x", 0, 0.3);
105 //TF1* func = new TF1("func", "1.3 - x", 0, 0.3);
106 //TF1* func = new TF1("func", "1", 0, 0.3);
107 //new TCanvas; func->Draw();
108 //inputList.Add(func->GetHistogram()->Clone("pt-spectrum"));
109
110 TFile* file = TFile::Open("ptspectrum_fit.root");
111 if (!file)
112 {
113 Printf("Could not open ptspectrum_fit.root");
114 return;
115 }
116
117 TString subStr(optionStr(optionStr.Index("pt-spectrum-func")+17, 3));
118 TString histName(Form("ptspectrum_%s", subStr.Data()));
119 Printf("Pt-Spectrum modification. Using %s.", histName.Data());
120 TH1* hist = (TH1*) file->Get(histName);
121 if (!hist)
122 {
123 Printf("Could not read histogram.");
124 return;
125 }
126
127 new TCanvas; hist->Draw();
128 task->SetPtSpectrum((TH1*) hist->Clone("pt-spectrum"));
129 }
130
a9017e49 131 // Add ESD handler
132 AliESDInputHandler* esdH = new AliESDInputHandler;
133 mgr->SetInputEventHandler(esdH);
134
135 // Attach input
136 cInput = mgr->CreateContainer("cInput", TChain::Class(), AliAnalysisManager::kInputContainer);
137 mgr->ConnectInput(task, 0, cInput);
138
139 // Attach output
140 cOutput = mgr->CreateContainer("cOutput", TList::Class(), AliAnalysisManager::kOutputContainer);
141 //cOutput->SetDataOwned(kTRUE);
142 mgr->ConnectOutput(task, 0, cOutput);
143
144 // Enable debug printouts
145 if (aDebug)
146 mgr->SetDebugLevel(2);
147
148 // Run analysis
149 mgr->InitAnalysis();
150 mgr->PrintStatus();
745d6088 151
152 if (aProof == 2)
153 {
154 // process dataset
155
156 mgr->StartAnalysis("proof", data, nRuns, offset);
157 }
158 else
159 {
160 // Create chain of input files
161 gROOT->LoadMacro("../CreateESDChain.C");
162 chain = CreateESDChain(data, nRuns, offset);
163
164 mgr->StartAnalysis((aProof > 0) ? "proof" : "local", chain);
165 }
a9017e49 166}