Transition PWG0 -> PWGUD
[u/mrichter/AliRoot.git] / PWGUD / dNdPt / macros / rundNdPt.C
1 void rundNdPt(const char *fileList ="inputList.txt",const char *outFile = "outputFile.root", Int_t NumberOfFiles=10,Int_t fromFile=0, Int_t nEvents=1000, Int_t firstEvent =0, Bool_t bUseMCInfo=kTRUE, Float_t zvWindow=20., Int_t cutMode=9,Float_t etaWindow=0.9, Float_t ptMin=0.15,AlidNdPtHelper::AnalysisMode analysisMode = AlidNdPtHelper::kTPC, AlidNdPtHelper::ParticleMode particleMode = AlidNdPtHelper::kAllPart,  AlidNdPtHelper::OutputObject outputObject=AlidNdPtHelper::kCorrection,const char *corrFile = "corrMatricesFile.root",Bool_t bProof=kFALSE)
2 {
3   // set Proof
4   if(bProof) { 
5     
6     //cout << "*** START PROOF Lite SESSION ***" << endl;
7     //TProof::Open(""); // 1. Enter your username here
8     
9     //TProofMgr * proofmgr = TProof::Mgr("lxialpod2.gsi.de:21001");
10     //TProofMgr * proofmgr = TProof::Mgr("lxialpod.gsi.de:21001");
11     TProofMgr * proofmgr = TProof::Mgr("lxialpod.gsi.de:21004");
12     //TProofMgr * proofmgr = TProof::Mgr("lxial39.gsi.de:21001");
13     TProof * proof = proofmgr->CreateSession();
14     proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)10000);
15
16     // -- Load AliRoot Libraries
17     gROOT->LoadMacro("ProofEnableAliRootGSI.C");
18     ProofEnableAliRootGSI("/u/jacek/alice/AliRoot/trunk");
19   }
20
21   // Swtich off all AliInfo (too much output!!!)
22   AliLog::SetGlobalLogLevel(AliLog::kError);
23
24   // Create analysis manager
25   AliAnalysisManager *mgr = new AliAnalysisManager;
26
27   //
28   // Create physics trigger selection class
29   //
30   AliPhysicsSelection *physTrigSel =  new AliPhysicsSelection();
31
32   //
33   // Create event cuts
34   //
35   AlidNdPtEventCuts *evtCuts = new AlidNdPtEventCuts("AlidNdPtEventCuts","Event cuts");
36   evtCuts->SetZvRange(-zvWindow,zvWindow);
37   evtCuts->SetMeanXYZv(0.0,0.0,0.0);
38   evtCuts->SetSigmaMeanXYZv(1.0,1.0,10.0);
39   evtCuts->SetTriggerRequired(kTRUE);
40   //evtCuts->SetTriggerRequired(kFALSE);
41
42   // Create geom. acceptance cuts
43   AlidNdPtAcceptanceCuts *accCuts = new AlidNdPtAcceptanceCuts("AlidNdPtAcceptanceCuts","Geom. acceptance cuts");
44   accCuts->SetEtaRange(-etaWindow,etaWindow);
45   accCuts->SetPtRange(ptMin,1.e10);
46   accCuts->SetMaxDCAr(3.0);
47   accCuts->SetMaxDCAz(30.0);
48
49   // Create standard esd track cuts
50   gROOT->LoadMacro("$ALICE_ROOT/PWG0/dNdPt/macros/CreatedNdPtTrackCuts.C");
51   AliESDtrackCuts* esdTrackCuts = CreatedNdPtTrackCuts(cutMode);
52   if (!esdTrackCuts) {
53     printf("ERROR: esdTrackCuts could not be created\n");
54     return;
55   } else {
56     esdTrackCuts->SetHistogramsOn(kTRUE);
57   }
58
59   //
60   // Create task
61   //
62   AlidNdPtTask *task = new AlidNdPtTask("AlidNdPtTask");
63   if (bUseMCInfo) task->SetUseMCInfo(kTRUE);
64
65   // create cut analysis object
66   if(outputObject==AlidNdPtHelper::kCutAnalysis) 
67   {
68     AlidNdPtCutAnalysis *fdNdPtCutAnalysis = new AlidNdPtCutAnalysis("dNdPtCutAnalysis","dN/dPt Cut Analysis");
69     fdNdPtCutAnalysis->SetEventCuts(evtCuts);
70     fdNdPtCutAnalysis->SetAcceptanceCuts(accCuts);
71     fdNdPtCutAnalysis->SetTrackCuts(esdTrackCuts);
72     fdNdPtCutAnalysis->SetAnalysisMode(analysisMode); 
73     fdNdPtCutAnalysis->SetParticleMode(particleMode); 
74     if(bUseMCInfo) 
75     {
76        //fdNdPtCutAnalysis->SetTrigger(AliTriggerAnalysis::kMB1); 
77        physTrigSel->SetAnalyzeMC();
78        fdNdPtCutAnalysis->SetPhysicsTriggerSelection(physTrigSel); 
79        fdNdPtCutAnalysis->SetUseMCInfo(kTRUE);
80     }
81     else { // online trigger
82     fdNdPtCutAnalysis->SetPhysicsTriggerSelection(physTrigSel); 
83     //fdNdPtCutAnalysis->SetTriggerClass("CBEAMB-ABCE-NOPF-ALL"); 
84     //fdNdPtCutAnalysis->SetTriggerClass("CINT1B-ABCE-NOPF-ALL");
85     //fdNdPtCutAnalysis->SetTriggerClass("CINT1A-ABCE-NOPF-ALL"); 
86     //fdNdPtCutAnalysis->SetTriggerClass("CINT1C-ABCE-NOPF-ALL"); 
87     //fdNdPtCutAnalysis->SetTriggerClass("CINT1-E-NOPF-ALL"); 
88     }
89
90     task->AddAnalysisObject( fdNdPtCutAnalysis );
91   }
92
93   // create analysis object
94   if(outputObject==AlidNdPtHelper::kAnalysis) 
95   {
96     AlidNdPtAnalysis *fdNdPtAnalysis = new AlidNdPtAnalysis("dNdPtAnalysis","dN/dPt Analysis");
97     fdNdPtAnalysis->SetEventCuts(evtCuts);
98     fdNdPtAnalysis->SetAcceptanceCuts(accCuts);
99     fdNdPtAnalysis->SetTrackCuts(esdTrackCuts);
100     fdNdPtAnalysis->SetAnalysisMode(analysisMode); 
101     fdNdPtAnalysis->SetParticleMode(particleMode); 
102     if(bUseMCInfo) 
103     {
104        //fdNdPtAnalysis->SetTrigger(AliTriggerAnalysis::kMB1); 
105        physTrigSel->SetAnalyzeMC();
106        fdNdPtAnalysis->SetPhysicsTriggerSelection(physTrigSel); 
107
108        fdNdPtAnalysis->SetUseMCInfo(kTRUE);
109        //fdNdPtAnalysis->SetHistogramsOn(kTRUE);
110        fdNdPtAnalysis->SetHistogramsOn(kFALSE);
111     }
112     else { // online trigger
113     fdNdPtAnalysis->SetPhysicsTriggerSelection(physTrigSel); 
114     //fdNdPtAnalysis->SetTriggerClass("CBEAMB-ABCE-NOPF-ALL"); 
115     //fdNdPtAnalysis->SetTriggerClass("CINT1B-ABCE-NOPF-ALL");
116     //fdNdPtAnalysis->SetTriggerClass("CINT1A-ABCE-NOPF-ALL"); 
117     //fdNdPtAnalysis->SetTriggerClass("CINT1C-ABCE-NOPF-ALL"); 
118     //fdNdPtAnalysis->SetTriggerClass("CINT1-E-NOPF-ALL"); 
119     }
120
121     task->AddAnalysisObject( fdNdPtAnalysis );
122   }
123
124   // create correction object
125   if(outputObject == AlidNdPtHelper::kCorrection) 
126   {
127     AlidNdPtCorrection *fdNdPtCorrection = new AlidNdPtCorrection("dNdPtCorrection","dN/dPt Correction", corrFile);
128
129     fdNdPtCorrection->SetEventCuts(evtCuts);
130     fdNdPtCorrection->SetAcceptanceCuts(accCuts);
131     fdNdPtCorrection->SetTrackCuts(esdTrackCuts);
132     fdNdPtCorrection->SetAnalysisMode(analysisMode); 
133     fdNdPtCorrection->SetParticleMode(particleMode); 
134     if(bUseMCInfo) 
135     {
136        //fdNdPtCorrection->SetTrigger(AliTriggerAnalysis::kMB1); 
137        physTrigSel->SetAnalyzeMC();
138        fdNdPtCorrection->SetPhysicsTriggerSelection(physTrigSel); 
139        fdNdPtCorrection->SetUseMCInfo(kTRUE);
140     }
141     else { // online trigger
142     fdNdPtCorrection->SetPhysicsTriggerSelection(physTrigSel); 
143     //fdNdPtCorrection->SetTriggerClass("CBEAMB-ABCE-NOPF-ALL"); 
144     //fdNdPtCorrection->SetTriggerClass("CINT1B-ABCE-NOPF-ALL");
145     //fdNdPtCorrection->SetTriggerClass("CINT1A-ABCE-NOPF-ALL"); 
146     //fdNdPtCorrection->SetTriggerClass("CINT1C-ABCE-NOPF-ALL"); 
147     //fdNdPtCorrection->SetTriggerClass("CINT1-E-NOPF-ALL"); 
148     }
149
150     task->AddAnalysisObject( fdNdPtCorrection );
151   }
152
153   // Add task
154   mgr->AddTask(task);
155
156   // Add ESD handler
157   AliESDInputHandler* esdH = new AliESDInputHandler;
158   //esdH->SetInactiveBranches("*");
159   mgr->SetInputEventHandler(esdH);
160
161   if(bUseMCInfo) {
162   // Enable MC event handler
163     AliMCEventHandler* handler = new AliMCEventHandler;
164     handler->SetReadTR(kFALSE);
165     //handler->SetReadTR(kTRUE);
166     mgr->SetMCtruthEventHandler(handler);
167   }
168
169   // Create input chain
170   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
171   TChain* chain = CreateESDChain(fileList, NumberOfFiles, fromFile);
172   if(!chain) {
173     printf("ERROR: chain cannot be created\n");
174     return;
175   }
176
177   // Create containers for input
178   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
179   mgr->ConnectInput(task, 0, cinput);
180
181   // Create containers for output
182   AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, outFile);
183   mgr->ConnectOutput(task, 0, coutput);
184
185   // Enable debug printouts
186   mgr->SetDebugLevel(0);
187
188   if (!mgr->InitAnalysis())
189     return;
190
191   mgr->PrintStatus();
192
193   if(bProof) mgr->StartAnalysis("proof",chain, nEvents, firstEvent);
194   else mgr->StartAnalysis("local",chain,nEvents, firstEvent);
195 }
196