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