]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/TenderSupplies/AliAnalysisTaskVZEROEqFactorTask.cxx
Disable caching for async prefetching
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliAnalysisTaskVZEROEqFactorTask.cxx
CommitLineData
21c2a03e 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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//
18// AliAnalysisTaskVZEROEqFactorTask.cxx, February 12th 2014
19// --- David Dobrigkeit Chinellato
20//
21// This task is meant to set correct VZERO equalization factors in AliESDRun
22// so that AliCentrality makes use of the correct values. NB This task has to
23// be executed prior to AliCentrality for this to work properly! It is meant
24// to be used as a Tender.
25//
26// Comments, Suggestions, Bug reports: Please send them to:
27// --- daviddc@ifi.unicamp.br
28//
29// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30
31class TTree;
32class TParticle;
33class TVector3;
34
35//class AliMCEventHandler;
36//class AliMCEvent;
37//class AliStack;
38
39class AliESDVertex;
40class AliAODVertex;
41class AliESDv0;
42class AliAODv0;
43
44#include <Riostream.h>
45#include "TList.h"
46#include "TH1.h"
47#include "TH2.h"
48#include "TH3.h"
49#include "TFile.h"
50#include "THnSparse.h"
51#include "TVector3.h"
52#include "TCanvas.h"
53#include "TMath.h"
54#include "TLegend.h"
55//#include "AliLog.h"
56
57#include "AliAnalysisTaskSE.h"
58#include "AliESDEvent.h"
59#include "AliAODEvent.h"
60#include "AliV0vertexer.h"
61#include "AliCascadeVertexer.h"
62#include "AliESDpid.h"
63#include "AliESDRun.h"
64#include "AliESDtrack.h"
65#include "AliESDtrackCuts.h"
66#include "AliInputEventHandler.h"
67#include "AliAnalysisManager.h"
68#include "AliMCEventHandler.h"
69#include "AliMCEvent.h"
70#include "AliStack.h"
71
72#include "AliCFContainer.h"
73#include "AliMultiplicity.h"
74#include "AliAODMCParticle.h"
75#include "AliESDcascade.h"
76#include "AliAODcascade.h"
77#include "AliESDUtils.h"
78#include "AliGenEventHeader.h"
79
80#include "AliAnalysisUtils.h"
81#include "AliAnalysisTaskVZEROEqFactorTask.h"
82#include "AliCDBManager.h"
83#include "AliCDBStorage.h"
84#include "AliCDBEntry.h"
85
86#include "AliVZEROCalibData.h"
87
88using std::cout;
89using std::endl;
90
91ClassImp(AliAnalysisTaskVZEROEqFactorTask)
92
93AliAnalysisTaskVZEROEqFactorTask::AliAnalysisTaskVZEROEqFactorTask()
94 : AliAnalysisTaskSE(), fListHist(0), fEqFactors(0), fCalibData(0), fRunNumber(0), fHistEventCounter(0)
95//------------------------------------------------
96// Tree Variables
97{
98 // Dummy Constructor
99}
100
101AliAnalysisTaskVZEROEqFactorTask::AliAnalysisTaskVZEROEqFactorTask(const char *name)
102 : AliAnalysisTaskSE(name), fListHist(0), fEqFactors(0), fCalibData(0), fRunNumber(0), fHistEventCounter(0)
103{
104 // Constructor
105 DefineOutput(1, TList::Class());
106}
107
108
109AliAnalysisTaskVZEROEqFactorTask::~AliAnalysisTaskVZEROEqFactorTask()
110{
111//------------------------------------------------
112// DESTRUCTOR
113//------------------------------------------------
114
115 if (fListHist){
116 delete fListHist;
117 fListHist = 0x0;
118 }
119}
120
121//________________________________________________________________________
122void AliAnalysisTaskVZEROEqFactorTask::UserCreateOutputObjects()
123{
124//------------------------------------------------
125// Output: Empty at the moment
126//------------------------------------------------
127
128 fListHist = new TList();
129 fListHist->SetOwner(); // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
130
131 if(! fHistEventCounter ) {
132 //Histogram Output: Event-by-Event
133 // --- Single "Events Processed" Counter at this stage
134 fHistEventCounter = new TH1D( "fHistEventCounter", ";Evt. Sel. Step;Count",4,0,4);
135 fHistEventCounter->GetXaxis()->SetBinLabel(1, "Processed");
136 fHistEventCounter->GetXaxis()->SetBinLabel(2, "Has ESD");
137 fHistEventCounter->GetXaxis()->SetBinLabel(3, "Has ESDRun");
138 fHistEventCounter->GetXaxis()->SetBinLabel(4, "Rewrote EqFactors");
139 fListHist->Add(fHistEventCounter);
140 }
141
142 //List of Histograms
143 PostData(1, fListHist);
144}// end UserCreateOutputObjects
145
146
147//________________________________________________________________________
148void AliAnalysisTaskVZEROEqFactorTask::UserExec(Option_t *)
149{
150 // Main loop
151 // Called for each event
152
153 AliESDEvent *lESDevent = 0x0;
154 // Connect to the InputEvent
155 // After these lines, we should have an ESD/AOD event + the number of V0s in it.
156
157 // Appropriate for ESD analysis!
158 //Count Processed Events
159 fHistEventCounter->Fill(0.5);
160
161 lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
162 if (!lESDevent) {
163 AliWarning("ERROR: lESDevent not available \n");
164 return;
165 }
166 fHistEventCounter->Fill(1.5);
167
168
169 //Acquire ESDRun object - Will be needed to invoke AliESDEvent::SetVZEROEqFactors
170 const AliESDRun *lESDRun = lESDevent->GetESDRun();
171 if (!lESDRun) {
172 AliWarning("ERROR: lESDRun not available, won't be able to write Equalization Factors! Exiting. \n");
173 return;
174 }
175
176 fHistEventCounter->Fill(2.5);
177
178 //CDB Processing only necessary if Run Number changed! Check for change (no need to redo this every event)
179 if( lESDevent->GetRunNumber() != fRunNumber ){
180 AliWarning("Run Changed! Reloading CDB values!");
181 //Load CDB Entries - Mirroring AliVZEROReconstructor
182 AliCDBEntry *entry7 = AliCDBManager::Instance()->Get("VZERO/Calib/EqualizationFactors");
183 if (!entry7) AliFatal("ERROR: VZERO equalization factors are not found in OCDB !");
184 fEqFactors = (TH1F*)entry7->GetObject();
185
186 //Load Calibration object fCalibData
187 fCalibData = GetCalibData(); // Mirror AliVZEROReconstructor Functionality
188 fRunNumber = lESDevent->GetRunNumber(); //New Run
189 }
190
191
192 Float_t factors[64];
193 Float_t factorSum = 0;
194 for(Int_t i = 0; i < 64; ++i) {
195 factors[i] = fEqFactors->GetBinContent(i+1)*fCalibData->GetMIPperADC(i);
196 factorSum += factors[i];
197 }
198 for(Int_t i = 0; i < 64; ++i) {
199 factors[i] *= (64./factorSum);
200 }
201 lESDevent->SetVZEROEqFactors(factors);
202 fHistEventCounter->Fill(3.5);
203
204
205 // Post output data.
206 PostData(1, fListHist);
207}
208
209//________________________________________________________________________
210void AliAnalysisTaskVZEROEqFactorTask::Terminate(Option_t *)
211{
212 // Draw result to the screen
213 // Called once at the end of the query
214
215 TList *cRetrievedList = 0x0;
216 cRetrievedList = (TList*)GetOutputData(1);
217 if(!cRetrievedList){
218 Printf("ERROR - AliAnalysisTaskVZEROEqFactorTask : ouput data container list not available\n");
219 return;
220 }
221
222 fHistEventCounter = dynamic_cast<TH1D*> ( cRetrievedList->FindObject("fHistEventCounter") );
223 if (!fHistEventCounter) {
224 Printf("ERROR - AliAnalysisTaskVZEROEqFactorTask : fHistEventCounter not available");
225 return;
226 }
227
228 TCanvas *canCheck = new TCanvas("AliAnalysisTaskVZEROEqFactorTask","V0 Multiplicity",10,10,510,510);
229 canCheck->cd(1)->SetLogy();
230
231 fHistEventCounter->SetMarkerStyle(22);
232 fHistEventCounter->DrawCopy("E");
233}
234
235//_____________________________________________________________________________
236AliVZEROCalibData* AliAnalysisTaskVZEROEqFactorTask::GetCalibData() const
237{
238 // Gets calibration object for VZERO set
239
240 AliCDBManager *man = AliCDBManager::Instance();
241 AliCDBEntry *entry=0;
242 entry = man->Get("VZERO/Calib/Data");
243 AliVZEROCalibData *calibdata = 0;
244 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
245 if (!calibdata) AliFatal("No calibration data from calibration database !");
246 return calibdata;
247}