Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : //*****************************************************
17 : // Class AliVZEROEPSelectionTask
18 : // author: Cvetan Cheshkov
19 : // 30/01/2012
20 : // This analysis task reads the OADB and
21 : // provides the parameters needed to flatten
22 : // the VZERO event plane in AliEventplane
23 : //*****************************************************
24 :
25 : #include "AliVZEROEPSelectionTask.h"
26 :
27 : #include <TList.h>
28 : #include <TProfile.h>
29 : #include <TFile.h>
30 : #include <TString.h>
31 : #include <TDirectory.h>
32 :
33 : #include "AliLog.h"
34 : #include "AliVEvent.h"
35 : #include "AliAnalysisManager.h"
36 : #include "AliOADBContainer.h"
37 : #include "AliEventplane.h"
38 : #include "AliCentrality.h"
39 :
40 170 : ClassImp(AliVZEROEPSelectionTask)
41 :
42 : //________________________________________________________________________
43 : AliVZEROEPSelectionTask::AliVZEROEPSelectionTask():
44 0 : AliAnalysisTaskSE(),
45 0 : fRunNumber(-1),
46 0 : fUserParams(kFALSE),
47 0 : fUseVZEROCentrality(kFALSE),
48 0 : fVZEROEPContainer(0)
49 0 : {
50 : // Default constructor
51 : // Initialize pointers
52 0 : AliInfo("VZERO Event Plane Selection enabled.");
53 0 : for(Int_t i = 0; i < 11; ++i) fX2In[i] = fY2In[i] = fX2Y2In[i] = fCos8PsiIn[i] = NULL;
54 0 : }
55 :
56 : //________________________________________________________________________
57 : AliVZEROEPSelectionTask::AliVZEROEPSelectionTask(const char *name):
58 0 : AliAnalysisTaskSE(name),
59 0 : fRunNumber(-1),
60 0 : fUserParams(kFALSE),
61 0 : fUseVZEROCentrality(kFALSE),
62 0 : fVZEROEPContainer(0)
63 0 : {
64 : // Default constructor
65 : // Initialize pointers
66 0 : AliInfo("Event Plane Selection enabled.");
67 0 : for(Int_t i = 0; i < 11; ++i) fX2In[i] = fY2In[i] = fX2Y2In[i] = fCos8PsiIn[i] = NULL;
68 0 : }
69 :
70 : //________________________________________________________________________
71 : AliVZEROEPSelectionTask::~AliVZEROEPSelectionTask()
72 0 : {
73 : // Destructor
74 : // ...
75 0 : if (fUserParams) {
76 0 : for(Int_t i = 0; i < 11; ++i) {
77 0 : delete fX2In[i];
78 0 : fX2In[i] = NULL;
79 0 : delete fY2In[i];
80 0 : fY2In[i] = NULL;
81 0 : delete fX2Y2In[i];
82 0 : fX2Y2In[i] = NULL;
83 0 : delete fCos8PsiIn[i];
84 0 : fCos8PsiIn[i] = NULL;
85 : }
86 0 : }
87 0 : if (fVZEROEPContainer){
88 0 : delete fVZEROEPContainer;
89 0 : fVZEROEPContainer = NULL;
90 0 : }
91 0 : }
92 :
93 : //________________________________________________________________________
94 : void AliVZEROEPSelectionTask::UserCreateOutputObjects()
95 : {
96 : // Create the output containers (none in this case)
97 : // Open the OADB file
98 :
99 0 : if(!fUserParams) {
100 0 : TString oadbFileName = Form("%s/COMMON/EVENTPLANE/data/vzero.root", AliAnalysisManager::GetOADBPath());
101 0 : TFile *fOADB = TFile::Open(oadbFileName);
102 0 : if(!fOADB->IsOpen()) AliFatal(Form("Cannot open OADB file %s", oadbFileName.Data()));
103 :
104 0 : AliInfo("Using Standard OADB");
105 0 : AliOADBContainer *cont = (AliOADBContainer*)fOADB->Get("vzeroEP");
106 0 : if (!cont) AliFatal("Cannot fetch OADB container for VZERO EP selection");
107 0 : fVZEROEPContainer = new AliOADBContainer(*cont);
108 0 : fOADB->Close();
109 0 : delete fOADB;
110 0 : }
111 0 : }
112 :
113 : //________________________________________________________________________
114 : void AliVZEROEPSelectionTask::UserExec(Option_t */*option*/)
115 : {
116 : // Execute analysis for current event:
117 : // Fill the flatenning parameters in
118 : // AliEventplane object
119 :
120 0 : AliVEvent* event = InputEvent();
121 0 : if (!(fRunNumber == event->GetRunNumber())) {
122 0 : fRunNumber = event->GetRunNumber();
123 0 : SetParamsFromOADB();
124 0 : }
125 :
126 0 : AliCentrality *centrality = event->GetCentrality();
127 0 : Float_t percentile = (fUseVZEROCentrality) ? centrality->GetCentralityPercentile("V0M") : centrality->GetCentralityPercentile("CL1");
128 0 : AliEventplane *esdEP = event->GetEventplane();
129 0 : if(esdEP) SetEventplaneParams(esdEP,percentile);
130 0 : }
131 :
132 : //________________________________________________________________________
133 : void AliVZEROEPSelectionTask::Terminate(Option_t */*option*/)
134 : {
135 : // Terminate analysis
136 : // Nothing here
137 0 : }
138 :
139 : //________________________________________________________________________
140 : void AliVZEROEPSelectionTask::SetEventplaneParams(AliEventplane *esdEP,Float_t percentile)
141 : {
142 : // Read the OADB histograms and
143 : // prepare parameters used in order to
144 : // flatten the event-plane
145 0 : if(!esdEP)
146 0 : AliFatal("No event plane received");
147 :
148 0 : if (percentile < 0 || percentile > 100) {
149 0 : for(Int_t ring = 0; ring < 11; ++ring) esdEP->SetVZEROEPParams(ring,0.,0.,1.,1.,0.,0.,0.);
150 0 : return;
151 : }
152 :
153 0 : for(Int_t ring = 0; ring < 11; ++ring) {
154 0 : Int_t ibin = fX2In[ring]->FindBin(percentile);
155 0 : if (fX2In[ring]->GetBinEntries(ibin) == 0) {
156 0 : esdEP->SetVZEROEPParams(ring,0.,0.,1.,1.,0.,0.,0.);
157 0 : continue;
158 : }
159 0 : Double_t meanX2 = fX2In[ring]->GetBinContent(ibin);
160 0 : Double_t meanY2 = fY2In[ring]->GetBinContent(ibin);
161 0 : Double_t sigmaX2 = fX2In[ring]->GetBinError(ibin);
162 0 : Double_t sigmaY2 = fY2In[ring]->GetBinError(ibin);
163 0 : Double_t rho = (fX2Y2In[ring]->GetBinContent(ibin)-meanX2*meanY2)/sigmaX2/sigmaY2;
164 :
165 0 : Double_t b = rho*sigmaX2*sigmaY2*
166 0 : TMath::Sqrt(2.*(sigmaX2*sigmaX2+sigmaY2*sigmaY2-2.*sigmaX2*sigmaY2*TMath::Sqrt(1.-rho*rho))/
167 0 : ((sigmaX2*sigmaX2-sigmaY2*sigmaY2)*(sigmaX2*sigmaX2-sigmaY2*sigmaY2)+
168 0 : 4.*sigmaX2*sigmaX2*sigmaY2*sigmaY2*rho*rho));
169 0 : Double_t aPlus = TMath::Sqrt(2.*sigmaX2*sigmaX2-b*b);
170 0 : Double_t aMinus= TMath::Sqrt(2.*sigmaY2*sigmaY2-b*b);
171 :
172 0 : Double_t lambdaPlus = b/aPlus;
173 0 : Double_t lambdaMinus = b/aMinus;
174 :
175 0 : Double_t cos8Psi = fCos8PsiIn[ring]->GetBinContent(ibin);
176 0 : esdEP->SetVZEROEPParams(ring,meanX2,meanY2,aPlus,aMinus,lambdaPlus,lambdaMinus,cos8Psi);
177 0 : }
178 0 : }
179 :
180 : //__________________________________________________________________________
181 : void AliVZEROEPSelectionTask::SetParamsFromOADB()
182 : {
183 0 : if(!fUserParams) {
184 0 : TList *list = (TList*)fVZEROEPContainer->GetObject(fRunNumber, "Default");
185 0 : if (!list) AliFatal(Form("Cannot find VZERO OADB list for run %d", fRunNumber));
186 0 : SetHistograms(list);
187 0 : }
188 : else
189 0 : AliInfo("Using custom VZERO event-plane params");
190 0 : }
191 :
192 : //__________________________________________________________________________
193 : void AliVZEROEPSelectionTask::SetUserParams(const char* inFileName, const char* listName)
194 : {
195 :
196 0 : fUserParams = kTRUE;
197 :
198 0 : TFile f(inFileName);
199 0 : TList* list = (TList*)f.Get(listName);
200 0 : if (!list) AliFatal(Form("Cannot find list %s in file %s", listName, inFileName));
201 0 : SetHistograms(list);
202 0 : f.Close();
203 0 : }
204 :
205 : //__________________________________________________________________________
206 : void AliVZEROEPSelectionTask::SetHistograms(TList *list)
207 : {
208 : // Set the flatenning parameters
209 : // histograms from a given list
210 :
211 0 : for(Int_t i = 0; i < 11; ++i) {
212 0 : if (fX2In[i]) delete fX2In[i];
213 0 : fX2In[i] = (TProfile*)list->FindObject(Form("fX2_%d",i))->Clone(Form("fX2In_%d",i));
214 0 : fX2In[i]->SetDirectory(0);
215 0 : if (fY2In[i]) delete fY2In[i];
216 0 : fY2In[i] = (TProfile*)list->FindObject(Form("fY2_%d",i))->Clone(Form("fY2In_%d",i));
217 0 : fY2In[i]->SetDirectory(0);
218 0 : if (fX2Y2In[i]) delete fX2Y2In[i];
219 0 : fX2Y2In[i] = (TProfile*)list->FindObject(Form("fX2Y2_%d",i))->Clone(Form("fX2Y2In_%d",i));
220 0 : fX2Y2In[i]->SetDirectory(0);
221 0 : if (fCos8PsiIn[i]) delete fCos8PsiIn[i];
222 0 : fCos8PsiIn[i] = (TProfile*)list->FindObject(Form("fCos8Psi_%d",i))->Clone(Form("fCos8PsiIn_%d",i));
223 0 : fCos8PsiIn[i]->SetDirectory(0);
224 : }
225 0 : }
|