]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/eventStats/run.C
added separate histogram entry for V0A and C BG flag
[u/mrichter/AliRoot.git] / PWG0 / eventStats / run.C
1 void Load(const char* taskName, Bool_t debug)
2 {
3   TString compileTaskName;
4   compileTaskName.Form("%s.cxx++", taskName);
5   if (debug)
6     compileTaskName += "g";
7
8   if (gProof) {
9     gProof->Load(compileTaskName);
10   } else
11     gROOT->Macro(compileTaskName);
12
13   // Enable debug printouts
14   if (debug)
15   {
16     AliLog::SetClassDebugLevel(taskName, AliLog::kDebug+2);
17   }
18   else
19     AliLog::SetClassDebugLevel(taskName, AliLog::kWarning);
20 }
21
22 void run(const Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aDebug = kFALSE, Int_t aProof = kFALSE, const char* option = "")
23 {
24   // aProof option: 0 no proof
25   //                1 proof with chain
26   //                2 proof with dataset
27   //
28   // option is passed to the task(s)
29
30   if (nRuns < 0)
31     nRuns = 1234567890;
32
33   if (aProof > 0)
34   {
35     TProof::Open("alicecaf"); 
36     //gProof->SetParallel(2);
37
38     // Enable the needed package
39     if (1)
40     {
41       gProof->UploadPackage("$ALICE_ROOT/STEERBase");
42       gProof->EnablePackage("$ALICE_ROOT/STEERBase");
43       gProof->UploadPackage("$ALICE_ROOT/ESD");
44       gProof->EnablePackage("$ALICE_ROOT/ESD");
45       gProof->UploadPackage("$ALICE_ROOT/AOD");
46       gProof->EnablePackage("$ALICE_ROOT/AOD");
47       gProof->UploadPackage("$ALICE_ROOT/ANALYSIS");
48       gProof->EnablePackage("$ALICE_ROOT/ANALYSIS");
49       gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice");
50       gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice");
51     }
52     else
53     {
54       gProof->UploadPackage("$ALICE_ROOT/AF-v4-18-12-AN.par");
55       gProof->EnablePackage("AF-v4-18-12-AN");
56     }
57
58     gProof->UploadPackage("$ALICE_ROOT/PWG0base");
59     gProof->EnablePackage("$ALICE_ROOT/PWG0base");
60   }
61   else
62   {
63     gSystem->AddIncludePath("-I${ALICE_ROOT}/include/ -I${ALICE_ROOT}/PWG0/ -I${ALICE_ROOT}/PWG0/dNdEta/"); 
64     gSystem->Load("libVMC");
65     gSystem->Load("libTree");
66     gSystem->Load("libProof");
67     gSystem->Load("libSTEERBase");
68     gSystem->Load("libESD");
69     gSystem->Load("libAOD");
70     gSystem->Load("libANALYSIS");
71     gSystem->Load("libANALYSISalice");
72     gSystem->Load("libPWG0base");
73     gSystem->Load("libPWG0dep");
74   }
75   
76   // Create the analysis manager
77   mgr = new AliAnalysisManager;
78
79   // Add ESD handler
80   AliESDInputHandler* esdH = new AliESDInputHandler;
81   esdH->SetInactiveBranches("AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks Kinks Cascades AliESDTZERO MuonTracks TrdTracks CaloClusters");
82   mgr->SetInputEventHandler(esdH);
83
84   cInput = mgr->GetCommonInputContainer();
85   
86   Load("AliEventStatsTask", aDebug);
87   TString optStr(option);
88   
89   // remove SAVE option if set
90   Bool_t save = kFALSE;
91   if (optStr.Contains("SAVE"))
92   {
93     optStr = optStr(0,optStr.Index("SAVE")) + optStr(optStr.Index("SAVE")+4, optStr.Length());
94     save = kTRUE;
95   }
96   
97   task = new AliEventStatsTask(optStr);
98   physicsSelection = new AliPhysicsSelection;
99   if (aDebug)
100     AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kDebug);
101   task->SetPhysicsSelection(physicsSelection);
102   //AliBackgroundSelection* background = new AliBackgroundSelection("AliBackgroundSelection", "AliBackgroundSelection");
103   //physicsSelection->AddBackgroundIdentification(background);
104   
105   mgr->AddTask(task);
106
107   // Attach input
108   mgr->ConnectInput(task, 0, cInput);
109
110   // Attach output
111   cOutput = mgr->CreateContainer("cOutput", TList::Class(), AliAnalysisManager::kOutputContainer);
112   mgr->ConnectOutput(task, 1, cOutput);
113
114   // Enable debug printouts
115   if (aDebug)
116     mgr->SetDebugLevel(2);
117
118   // Run analysis
119   mgr->InitAnalysis();
120   mgr->PrintStatus();
121
122   if (aProof == 2)
123   {
124     // process dataset
125
126     mgr->StartAnalysis("proof", data, nRuns, offset);
127
128     if (save)
129     {
130       TString path("maps/");
131       path += TString(data).Tokenize("/")->Last()->GetName();
132       
133       gSystem->mkdir(path, kTRUE);
134       gSystem->Rename("event_stats.root", path + "/event_stats.root");
135       
136       Printf(">>>>> Moved files to %s", path.Data());
137     }  
138   }
139   else if (aProof == 3)
140   {
141     gROOT->ProcessLine(".L CreateChainFromDataSet.C");
142     ds = gProof->GetDataSet(data)->GetStagedSubset();
143     file = TFile::Open("dataset.root", "RECREATE");
144     ds->Write("dataset");
145     file->Close();
146     chain = CreateChainFromDataSet(ds);
147     mgr->StartAnalysis("local", chain, nRuns, offset);
148   }
149   else if (aProof == -1)
150   {
151     gROOT->ProcessLine(".L CreateChainFromDataSet.C");
152     TFile::Open("dataset.root");
153     ds = (TFileCollection*) gFile->Get("dataset");
154     chain = CreateChainFromDataSet(ds);
155     mgr->StartAnalysis("local", chain, nRuns, offset);
156   }
157   else
158   {
159     // Create chain of input files
160     gROOT->LoadMacro("../CreateESDChain.C");
161
162     chain = CreateESDChain(data, nRuns, offset);
163     //chain = CreateChain("TE", data, nRuns, offset);
164
165     mgr->StartAnalysis((aProof > 0) ? "proof" : "local", chain);
166   }
167
168 }