]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/macros/dptdptcorrelations/AddTaskDptDptCorrelationsforWeight.C
3bc9940ed13a641f9453e5d0e8403da118e5ce12
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / dptdptcorrelations / AddTaskDptDptCorrelationsforWeight.C
1 //
2 // Macro designed for use with the AliAnalysisTaskDptDptCorrelations task.
3 //
4 // Author: Prabhat Pujahari & Claude Pruneau, Wayne State
5 // 
6 //           system:  0: PbPb                 1: pp
7 //      singlesOnly:  0: full correlations    1: singles only
8 //       useWeights:  0: no                   1: yes
9 // centralityMethod:  3: track count  4: V0 centrality
10 //        chargeSet:  0: ++    1: +-    2: -+    3: --
11 /////////////////////////////////////////////////////////////////////////////////
12 AliAnalysisTaskDptDptCorrelations *AddTaskDptDptCorrelationsforWeight(int    system                 = 0,
13                                                                       int    singlesOnly            = 1,
14                                                                       int    useWeights             = 0,
15                                                                       int    centralityMethod       = 4,
16                                                                       int    chargeSet              = 1)
17
18 {
19   // Set Default Configuration of this analysis
20   // ==========================================
21   int    debugLevel             = 0;
22   int    rejectPileup           = 1;
23   int    rejectPairConversion   = 1;
24   int    sameFilter             = 1;
25
26   
27   int    nCentrality;
28   double minCentrality[10];
29   double maxCentrality[10];
30
31   if (system==0) // PbPb
32     {
33     if (centralityMethod == 4)
34       {
35         nCentrality = 6;
36         minCentrality[0] = 0.0; maxCentrality[0] = 5.0;
37         minCentrality[1] = 5.0; maxCentrality[1] = 10.;
38         minCentrality[2] = 30.; maxCentrality[2] = 40.;
39         minCentrality[3] = 40.; maxCentrality[3] = 50.;
40         minCentrality[4] = 70.; maxCentrality[4] = 80.;
41         minCentrality[5] = 80.; maxCentrality[5] = 90.;
42
43         /* //To Get rid of Memory problem
44            nCentrality = 10;
45            minCentrality[0] = 0.0; maxCentrality[0] = 5.0;
46            minCentrality[1] = 5.0; maxCentrality[1] = 10.;
47            minCentrality[2] = 10.; maxCentrality[2] = 20.;
48            minCentrality[3] = 20.; maxCentrality[3] = 30.;
49            minCentrality[4] = 30.; maxCentrality[4] = 40.;
50            minCentrality[5] = 40.; maxCentrality[5] = 50.;
51            minCentrality[6] = 50.; maxCentrality[6] = 60.;
52            minCentrality[7] = 60.; maxCentrality[7] = 70.;
53            minCentrality[8] = 70.; maxCentrality[8] = 80.;
54            minCentrality[9] = 80.; maxCentrality[9] = 90.;
55         */
56       }
57     else
58       {
59       cout << "-F- AddTaskDptDptCorrelations() system:" << system << ". centralityMethod:" << centralityMethod << " Option NOT AVAILABLE. ABORT."
60       return 0;
61       }
62     }
63   else if (system==1) // pp
64     {
65     if (centralityMethod == 3)
66       {
67       nCentrality = 4;
68       minCentrality[0] = 2;   maxCentrality[0] = 100.0;
69       minCentrality[1] = 2;   maxCentrality[1] = 20.;
70       minCentrality[2] = 20.; maxCentrality[2] = 50.;
71       minCentrality[3] = 50.; maxCentrality[3] = 100.;
72       }
73     else
74       {
75         //cout << "-F- AddTaskDptDptCorrelations() system:" << system << ". centralityMethod:" << centralityMethod << " Option NOT AVAILABLE. ABORT."
76       return 0;
77       }
78     }
79   else
80     {
81       //cout << "-F- AddTaskDptDptCorrelations() system:" << system << ". Option NOT CURRENTLY AVAILABLE. ABORT."
82     return 0;
83     }
84
85   double zMin                   = -10.;
86   double zMax                   =  10.;
87   double ptMin                  =  0.2;
88   double ptMax                  =  2.0;
89   double etaMin                 = -1.0;
90   double etaMax                 =  1.0;
91   double dcaZMin                = -3.0;
92   double dcaZMax                =  3.0;
93   double dcaXYMin               = -2.4;
94   double dcaXYMax               =  2.4;
95   double dedxMin                =  0.0;
96   double dedxMax                =  20000.0;
97   int    nClusterMin            =   70;
98   int    trackFilterBit         =  128;
99   
100   int    requestedCharge1       =  1; //default
101   int    requestedCharge2       = -1; //default
102   
103   
104   // Get the pointer to the existing analysis manager via the static access method.
105   // ==============================================================================
106   AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
107   
108   if (!analysisManager) 
109     {
110     ::Error("AddTaskDptDptCorrelations", "No analysis manager to connect to.");
111     return NULL;
112     }  
113   
114   TString part1Name;
115   TString part2Name;
116   TString eventName;
117   TString prefixName        = "Corr_";
118   TString pileupRejecSuffix = "_PileupRejec";
119   TString pairRejecSuffix   = "_PairRejec";
120   TString calibSuffix       = "_calib";
121   TString singlesOnlySuffix = "_SO";
122   TString suffix;
123   
124   TString inputPath         = ".";
125   TString outputPath        = ".";
126   TString baseName;
127   TString listName;
128   TString taskName;
129   TString inputHistogramFileName;
130   TString outputHistogramFileName;
131   
132   // Create the task and add subtask.
133   // ===========================================================================
134   int iTask = 0; // task counter
135   AliAnalysisDataContainer *taskInputContainer;
136   AliAnalysisDataContainer *taskOutputContainer;
137   AliAnalysisTaskDptDptCorrelations* task;
138   
139   for (int iCentrality=0; iCentrality < nCentrality; ++iCentrality)
140     {
141       switch (chargeSet)
142         {
143           case 0: part1Name = "P_"; part2Name = "P_"; requestedCharge1 =  1; requestedCharge2 =  1; sameFilter = 1; break;
144           case 1: part1Name = "P_"; part2Name = "M_"; requestedCharge1 =  1; requestedCharge2 = -1; sameFilter = 0;   break;
145           case 2: part1Name = "M_"; part2Name = "P_"; requestedCharge1 = -1; requestedCharge2 =  1; sameFilter = 0;   break;
146           case 3: part1Name = "M_"; part2Name = "M_"; requestedCharge1 = -1; requestedCharge2 = -1; sameFilter = 1;   break;
147         }
148       //part1Name += int(1000*etaMin);
149       part1Name += "eta";
150       part1Name += int(1000*etaMax);
151       part1Name += "_";
152       part1Name += int(1000*ptMin);
153       part1Name += "pt";
154       part1Name += int(1000*ptMax);
155       part1Name += "_";
156       //part2Name += int(1000*etaMin);
157       part2Name += "eta";
158       part2Name += int(1000*etaMax);
159       part2Name += "_";
160       part2Name += int(1000*ptMin);
161       part2Name += "pt";
162       part2Name += int(1000*ptMax);
163       part2Name += "_";
164       eventName =  "";
165       eventName += int(10.*minCentrality[iCentrality] );
166       eventName += "Vo";
167       eventName += int(10.*maxCentrality[iCentrality] );
168       //eventName += "_";
169       //eventName += int(10*zMin ); 
170       //eventName += "Z";
171       //eventName += int(10*zMax ); 
172       //if (rejectPileup)         eventName += pileupRejecSuffix;
173       //if (rejectPairConversion) eventName += pairRejecSuffix;
174       baseName     =   prefixName;
175       baseName     +=  part1Name;
176       baseName     +=  part2Name;
177       baseName     +=  eventName;
178       listName     =   baseName;
179       taskName     =   baseName;
180
181       //inputHistogramFileName =  "/Users/prabhat/Archive/calib/PbPb276Calibration_PP_2010.root";
182       
183       outputHistogramFileName = baseName;
184       if (singlesOnly) outputHistogramFileName += singlesOnlySuffix;
185       outputHistogramFileName += ".root";
186       
187       /* cout << "============================================================" << endl;
188     cout << "                   iTask: " << iTask << endl;
189       cout << "               Task Name: " << taskName << endl;
190       cout << "               List Name: " << listName << endl;
191       cout << "  inputHistogramFileName: " << inputHistogramFileName  << endl;
192       cout << " outputHistogramFileName: " << outputHistogramFileName << endl;
193       cout << "                  system: " << system << endl;
194       cout << "             singlesOnly: " << singlesOnly << endl;
195       cout << "           using weights: " << useWeights << endl;
196       cout << "        centralityMethod: " << centralityMethod << endl;
197       cout << "               chargeSet: " << chargeSet    << endl;
198       cout << "              debugLevel: " << debugLevel   << endl;
199       cout << "            rejectPileup: " << rejectPileup << endl;
200       cout << "    rejectPairConversion: " << rejectPairConversion  << endl;
201       cout << "              sameFilter: " << sameFilter  << endl;
202       cout << "                    zMin: " << zMin        << endl;
203       cout << "                    zMax: " << zMax        << endl;
204       cout << "                   ptMin: " << ptMin       << endl;
205       cout << "                   ptMax: " << ptMax       << endl;
206       cout << "                  etaMin: " << etaMin   << endl;
207       cout << "                  etaMax: " << etaMax   << endl;
208       cout << "                 dcaZMin: " << dcaZMin  << endl;
209       cout << "                 dcaZMax: " << dcaZMax  << endl;
210       cout << "                dcaXYMin: " << dcaXYMin << endl;
211       cout << "                dcaXYMax: " << dcaXYMax << endl;
212       cout << "                 dedxMin: " << dedxMin  << endl;
213       cout << "                 dedxMax: " << dedxMax  << endl;
214       cout << "             nClusterMin: " << nClusterMin      << endl;
215       cout << "          trackFilterBit: " << trackFilterBit   << endl;
216       cout << "        requestedCharge1: " << requestedCharge1 << endl;
217       cout << "        requestedCharge2: " << requestedCharge2 << endl;
218     cout << "============================================================" << endl;
219       */
220     TFile  * inputFile  = 0;
221       TList  * histoList  = 0;
222       TH3F   * weight_1   = 0;
223       TH3F   * weight_2   = 0;
224       if (useWeights)
225         {
226         TGrid::Connect("alien:");
227         inputFile = TFile::Open(inputHistogramFileName,"OLD");
228         if (!inputFile)
229           {
230           cout << "Requested file:" << inputHistogramFileName << " was not opened. ABORT." << endl;
231           return;
232           }
233         TString nameHistoBase = "correction_";
234         TString nameHisto;
235         nameHistoBase += eventName;
236         if (requestedCharge1 == 1)
237           {
238           nameHisto = nameHistoBase + "_p";
239           cout << "Input Histogram named: " << nameHisto << endl;
240           weight_1 = (TH3F *) inputFile->Get(nameHisto);
241           }
242         else
243           {
244           nameHisto = nameHistoBase + "_m";
245           cout << "Input Histogram named: " << nameHisto << endl;
246           weight_1 = (TH3F *) inputFile->Get(nameHisto);
247           }
248         if (!weight_1) 
249           {
250           cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
251           return 0;
252           }
253         
254         if (!sameFilter)
255           {
256           weight_2 = 0;
257           if (requestedCharge2 == 1)
258             {
259             nameHisto = nameHistoBase + "_p";
260             cout << "Input Histogram named: " << nameHisto << endl;
261             weight_2 = (TH3F *) inputFile->Get(nameHisto);
262             }
263           else
264             {
265             nameHisto = nameHistoBase + "_m";
266             cout << "Input Histogram named: " << nameHisto << endl;
267             weight_2 = (TH3F *) inputFile->Get(nameHisto);
268             }
269           if (!weight_2) 
270             {
271             cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
272             return 0;
273             }
274           }  
275         }
276       task = new  AliAnalysisTaskDptDptCorrelations(taskName);
277       //configure my task
278       task->SetDebugLevel(          debugLevel      ); 
279       task->SetSameFilter(          sameFilter      );
280       task->SetSinglesOnly(         singlesOnly     ); 
281       task->SetUseWeights(          useWeights      ); 
282       task->SetRejectPileup(        rejectPileup    ); 
283       task->SetRejectPairConversion(rejectPairConversion); 
284       task->SetVertexZMin(          zMin            ); 
285       task->SetVertexZMax(          zMax            ); 
286       task->SetVertexXYMin(         -1.            ); 
287       task->SetVertexXYMax(          1.            ); 
288       task->SetCentralityMethod(    centralityMethod);
289       task->SetCentrality(          minCentrality[iCentrality], maxCentrality[iCentrality]);
290       task->SetPtMin1(              ptMin           ); 
291       task->SetPtMax1(              ptMax           ); 
292       task->SetEtaMin1(             etaMin          ); 
293       task->SetEtaMax1(             etaMax          ); 
294       task->SetPtMin2(              ptMin           ); 
295       task->SetPtMax2(              ptMax           ); 
296       task->SetEtaMin2(             etaMin          ); 
297       task->SetEtaMax2(             etaMax          ); 
298       task->SetDcaZMin(             dcaZMin         ); 
299       task->SetDcaZMax(             dcaZMax         ); 
300       task->SetDcaXYMin(            dcaXYMin        ); 
301       task->SetDcaXYMax(            dcaXYMax        ); 
302       task->SetDedxMin(             dedxMin         ); 
303       task->SetDedxMax(             dedxMax         ); 
304       task->SetNClusterMin(         nClusterMin     ); 
305       task->SetTrackFilterBit(      trackFilterBit  );
306       task->SetRequestedCharge_1(   requestedCharge1); 
307       task->SetRequestedCharge_2(   requestedCharge2); 
308       task->SetWeigth_1(            weight_1        );
309       task->SetWeigth_2(            weight_2        );
310       
311       
312       cout << "Creating task output container" << endl;
313       taskOutputContainer = analysisManager->CreateContainer(listName, 
314                                                              TList::Class(),    
315                                                              AliAnalysisManager::kOutputContainer, 
316                                                              Form("%s:Histos", AliAnalysisManager::GetCommonFileName()));
317       cout << "Add task to analysis manager and connect it to input and output containers" << endl;
318       analysisManager->AddTask(task);
319       analysisManager->ConnectInput( task,  0, analysisManager->GetCommonInputContainer());
320       analysisManager->ConnectOutput(task,  0, taskOutputContainer );
321       cout << "Task added ...." << endl;
322       
323       iTask++;
324     
325     }
326   
327   
328   
329   return task;
330 }