]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/macros/dptdptcorrelations/AddTaskDptDptCorrelations2010.C
change for the centrality bins (Prabhat Ranjan Pujahari <p.pujahari@cern.ch>)
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / dptdptcorrelations / AddTaskDptDptCorrelations2010.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 *AddTaskDptDptCorrelations2010(int    system                 = 0,
13                                                                  int    singlesOnly            = 0,
14                                                                  int    useWeights             = 1,
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
36         /*nCentrality = 6;
37         minCentrality[0] = 0.0; maxCentrality[0] = 5.0;
38         minCentrality[1] = 5.0; maxCentrality[1] = 10.;
39         minCentrality[2] = 30.; maxCentrality[2] = 40.;
40         minCentrality[3] = 40.; maxCentrality[3] = 50.;
41         minCentrality[4] = 70.; maxCentrality[4] = 80.;
42         minCentrality[5] = 80.; maxCentrality[5] = 90.;*/
43         
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                 = -0.8;
90   double etaMax                 =  0.8;
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;//TPC only
99   int    trackFilterBit         =  272; //Hybrid
100   
101   int    requestedCharge1       =  1; //default
102   int    requestedCharge2       = -1; //default
103   
104   
105   // Get the pointer to the existing analysis manager via the static access method.
106   // ==============================================================================
107   AliAnalysisManager *analysisManager = AliAnalysisManager::GetAnalysisManager();
108   
109   if (!analysisManager) 
110     {
111     ::Error("AddTaskDptDptCorrelations", "No analysis manager to connect to.");
112     return NULL;
113     }  
114   
115   TString part1Name;
116   TString part2Name;
117   TString eventName;
118   TString prefixName        = "Corr_";
119   TString pileupRejecSuffix = "_PileupRejec";
120   TString pairRejecSuffix   = "_PairRejec";
121   TString calibSuffix       = "_calib";
122   TString singlesOnlySuffix = "_SO";
123   TString suffix;
124   
125   TString inputPath         = ".";
126   TString outputPath        = ".";
127   TString baseName;
128   TString listName;
129   TString taskName;
130   TString inputHistogramFileName;
131   TString outputHistogramFileName;
132   
133   // Create the task and add subtask.
134   // ===========================================================================
135   int iTask = 0; // task counter
136   AliAnalysisDataContainer *taskInputContainer;
137   AliAnalysisDataContainer *taskOutputContainer;
138   AliAnalysisTaskDptDptCorrelations* task;
139   
140   for (int iCentrality=0; iCentrality < nCentrality; ++iCentrality)
141     {
142       switch (chargeSet)
143         {
144           case 0: part1Name = "P_"; part2Name = "P_"; requestedCharge1 =  1; requestedCharge2 =  1; sameFilter = 1; break;
145           case 1: part1Name = "P_"; part2Name = "M_"; requestedCharge1 =  1; requestedCharge2 = -1; sameFilter = 0;   break;
146           case 2: part1Name = "M_"; part2Name = "P_"; requestedCharge1 = -1; requestedCharge2 =  1; sameFilter = 0;   break;
147           case 3: part1Name = "M_"; part2Name = "M_"; requestedCharge1 = -1; requestedCharge2 = -1; sameFilter = 1;   break;
148         }
149       //part1Name += int(1000*etaMin);
150       part1Name += "eta";
151       part1Name += int(1000*etaMax);
152       part1Name += "_";
153       part1Name += int(1000*ptMin);
154       part1Name += "pt";
155       part1Name += int(1000*ptMax);
156       part1Name += "_";
157       //part2Name += int(1000*etaMin);
158       part2Name += "eta";
159       part2Name += int(1000*etaMax);
160       part2Name += "_";
161       part2Name += int(1000*ptMin);
162       part2Name += "pt";
163       part2Name += int(1000*ptMax);
164       part2Name += "_";
165       eventName =  "";
166       eventName += int(10.*minCentrality[iCentrality] );
167       eventName += "Vo";
168       eventName += int(10.*maxCentrality[iCentrality] );
169       //eventName += "_";
170       //eventName += int(10*zMin ); 
171       //eventName += "Z";
172       //eventName += int(10*zMax ); 
173       //if (rejectPileup)         eventName += pileupRejecSuffix;
174       //if (rejectPairConversion) eventName += pairRejecSuffix;
175       baseName     =   prefixName;
176       baseName     +=  part1Name;
177       baseName     +=  part2Name;
178       baseName     +=  eventName;
179       listName     =   baseName;
180       taskName     =   baseName;
181
182       inputHistogramFileName =  "/Users/prabhat/MyTestforEta/PbPb276Calibration_2010.root";
183       //inputHistogramFileName =  "alien:///alice/cern.ch/user/p/prabhat/CalibFiles/PbPb276Calibration_2010.root";
184
185       outputHistogramFileName = baseName;
186       if (singlesOnly) outputHistogramFileName += singlesOnlySuffix;
187       outputHistogramFileName += ".root";
188       
189       /*cout << "============================================================" << endl;
190     cout << "                   iTask: " << iTask << endl;
191       cout << "               Task Name: " << taskName << endl;
192       cout << "               List Name: " << listName << endl;
193       cout << "  inputHistogramFileName: " << inputHistogramFileName  << endl;
194       cout << " outputHistogramFileName: " << outputHistogramFileName << endl;
195       cout << "                  system: " << system << endl;
196       cout << "             singlesOnly: " << singlesOnly << endl;
197       cout << "           using weights: " << useWeights << endl;
198       cout << "        centralityMethod: " << centralityMethod << endl;
199       cout << "               chargeSet: " << chargeSet    << endl;
200       cout << "              debugLevel: " << debugLevel   << endl;
201       cout << "            rejectPileup: " << rejectPileup << endl;
202       cout << "    rejectPairConversion: " << rejectPairConversion  << endl;
203       cout << "              sameFilter: " << sameFilter  << endl;
204       cout << "                    zMin: " << zMin        << endl;
205       cout << "                    zMax: " << zMax        << endl;
206       cout << "                   ptMin: " << ptMin       << endl;
207       cout << "                   ptMax: " << ptMax       << endl;
208       cout << "                  etaMin: " << etaMin   << endl;
209       cout << "                  etaMax: " << etaMax   << endl;
210       cout << "                 dcaZMin: " << dcaZMin  << endl;
211       cout << "                 dcaZMax: " << dcaZMax  << endl;
212       cout << "                dcaXYMin: " << dcaXYMin << endl;
213       cout << "                dcaXYMax: " << dcaXYMax << endl;
214       cout << "                 dedxMin: " << dedxMin  << endl;
215       cout << "                 dedxMax: " << dedxMax  << endl;
216       cout << "             nClusterMin: " << nClusterMin      << endl;
217       cout << "          trackFilterBit: " << trackFilterBit   << endl;
218       cout << "        requestedCharge1: " << requestedCharge1 << endl;
219       cout << "        requestedCharge2: " << requestedCharge2 << endl;
220     cout << "============================================================" << endl;
221       */
222     TFile  * inputFile  = 0;
223       TList  * histoList  = 0;
224       TH3F   * weight_1   = 0;
225       TH3F   * weight_2   = 0;
226       if (useWeights)
227         {
228         TGrid::Connect("alien:");
229         inputFile = TFile::Open(inputHistogramFileName,"OLD");
230         if (!inputFile)
231           {
232             //cout << "Requested file:" << inputHistogramFileName << " was not opened. ABORT." << endl;
233           return;
234           }
235         TString nameHistoBase = "correction_";
236         TString nameHisto;
237         nameHistoBase += eventName;
238         if (requestedCharge1 == 1)
239           {
240           nameHisto = nameHistoBase + "_p";
241           //cout << "Input Histogram named: " << nameHisto << endl;
242           weight_1 = (TH3F *) inputFile->Get(nameHisto);
243           }
244         else
245           {
246           nameHisto = nameHistoBase + "_m";
247           //cout << "Input Histogram named: " << nameHisto << endl;
248           weight_1 = (TH3F *) inputFile->Get(nameHisto);
249           }
250         if (!weight_1) 
251           {
252             //cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
253           return 0;
254           }
255         
256         if (!sameFilter)
257           {
258           weight_2 = 0;
259           if (requestedCharge2 == 1)
260             {
261             nameHisto = nameHistoBase + "_p";
262             //cout << "Input Histogram named: " << nameHisto << endl;
263             weight_2 = (TH3F *) inputFile->Get(nameHisto);
264             }
265           else
266             {
267             nameHisto = nameHistoBase + "_m";
268             //cout << "Input Histogram named: " << nameHisto << endl;
269             weight_2 = (TH3F *) inputFile->Get(nameHisto);
270             }
271           if (!weight_2) 
272             {
273               //cout << "Requested histogram 'correction_p/m' was not found. ABORT." << endl;
274             return 0;
275             }
276           }  
277         }
278       task = new  AliAnalysisTaskDptDptCorrelations(taskName);
279       //configure my task
280       task->SetDebugLevel(          debugLevel      ); 
281       task->SetSameFilter(          sameFilter      );
282       task->SetSinglesOnly(         singlesOnly     ); 
283       task->SetUseWeights(          useWeights      ); 
284       task->SetRejectPileup(        rejectPileup    ); 
285       task->SetRejectPairConversion(rejectPairConversion); 
286       task->SetVertexZMin(          zMin            ); 
287       task->SetVertexZMax(          zMax            ); 
288       task->SetVertexXYMin(         -1.            ); 
289       task->SetVertexXYMax(          1.            ); 
290       task->SetCentralityMethod(    centralityMethod);
291       task->SetCentrality(          minCentrality[iCentrality], maxCentrality[iCentrality]);
292       task->SetPtMin1(              ptMin           ); 
293       task->SetPtMax1(              ptMax           ); 
294       task->SetEtaMin1(             etaMin          ); 
295       task->SetEtaMax1(             etaMax          ); 
296       task->SetPtMin2(              ptMin           ); 
297       task->SetPtMax2(              ptMax           ); 
298       task->SetEtaMin2(             etaMin          ); 
299       task->SetEtaMax2(             etaMax          ); 
300       task->SetDcaZMin(             dcaZMin         ); 
301       task->SetDcaZMax(             dcaZMax         ); 
302       task->SetDcaXYMin(            dcaXYMin        ); 
303       task->SetDcaXYMax(            dcaXYMax        ); 
304       task->SetDedxMin(             dedxMin         ); 
305       task->SetDedxMax(             dedxMax         ); 
306       task->SetNClusterMin(         nClusterMin     ); 
307       task->SetTrackFilterBit(      trackFilterBit  );
308       task->SetRequestedCharge_1(   requestedCharge1); 
309       task->SetRequestedCharge_2(   requestedCharge2); 
310       task->SetWeigth_1(            weight_1        );
311       task->SetWeigth_2(            weight_2        );
312       
313       
314       //cout << "Creating task output container" << endl;
315       taskOutputContainer = analysisManager->CreateContainer(listName, 
316                                                              TList::Class(),    
317                                                              AliAnalysisManager::kOutputContainer, 
318                                                              Form("%s:Histos", AliAnalysisManager::GetCommonFileName()));
319       //cout << "Add task to analysis manager and connect it to input and output containers" << endl;
320       analysisManager->AddTask(task);
321       analysisManager->ConnectInput( task,  0, analysisManager->GetCommonInputContainer());
322       analysisManager->ConnectOutput(task,  0, taskOutputContainer );
323       //cout << "Task added ...." << endl;
324       
325       iTask++;
326     
327     }
328   
329   
330   
331   return task;
332 }