2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 //* for The ALICE HLT Project. *
9 //* Permission to use, copy, modify and distribute this software and its *
10 //* documentation strictly for non-commercial purposes is hereby granted *
11 //* without fee, provided that the above copyright notice appears in all *
12 //* copies and that both the copyright notice and this permission notice *
13 //* appear in the supporting documentation. The authors make no claims *
14 //* about the suitability of this software for any purpose. It is *
15 //* provided "as is" without express or implied warranty. *
16 //**************************************************************************
19 /** @file AliAnalysisTaskHLTCentralBarrel.cxx
20 @author Per Ivar Lønne, Hege Erdal, Kalliopi Kanaki
22 @brief An analysis task containing
23 loops over HLT and offline ESD trees for comparing
24 event and track properties
29 #include "AliAnalysisTaskHLTCentralBarrel.h"
30 #include "AliESDEvent.h"
31 #include "AliESDtrack.h"
32 #include "AliESDInputHandler.h"
33 #include "AliTracker.h"
34 #include "AliESDVZERO.h"
35 //#include "AliHLTGlobalTriggerDecision.h"
36 #include "AliCentrality.h"
41 #include "TTimeStamp.h"
44 ClassImp(AliAnalysisTaskHLTCentralBarrel)
45 //_______________________________________________________________________________________________//
47 AliAnalysisTaskHLTCentralBarrel::AliAnalysisTaskHLTCentralBarrel()
49 ,fUseHLTTrigger(kFALSE)
62 // Define input and output slots here
63 // Input slot #0 works with a TChain
64 // DefineInput(0, TChain::Class());
65 // Output slot #0 writes into a TH1 container
67 //DefineOutput(1, TList::Class());
70 AliAnalysisTaskHLTCentralBarrel::AliAnalysisTaskHLTCentralBarrel(const char *name)
71 :AliAnalysisTaskSE(name)
72 ,fUseHLTTrigger(kFALSE)
85 // Define input and output slots here
86 // Input slot #0 works with a TChain
87 // DefineInput(0, TChain::Class());
88 // Output slot #0 writes into a TH1 container
90 DefineOutput(1, TList::Class());
93 AliAnalysisTaskHLTCentralBarrel::~AliAnalysisTaskHLTCentralBarrel(){
97 void AliAnalysisTaskHLTCentralBarrel::UserCreateOutputObjects(){
98 // Create THnSparse objects
101 fOutputList = new TList();
102 fOutputList->SetOwner();
103 fOutputList->SetName(GetName());
105 if(fBeamType.Contains("Pb")){ // in case of a Pb+Pb run the V0 centrality is added to the THnSparse
106 static const int sizeEvent = 7;
108 // x y z #contr mult vertexStatus V0centrality
109 int binsEvent[sizeEvent] = { 100, 100, 60, 200, 200, 2, 100 }; // binning
110 double minEvent [sizeEvent] = { -1, -1, -20, 0, 3, 0, 0 }; // min x
111 double maxEvent [sizeEvent] = { 1, 1, 20, 2000, 2000, 2, 100 }; // max x
112 fEventHLT = CreateEventTHnSparse("fEventHLT",sizeEvent,binsEvent,minEvent,maxEvent);
113 fEventOFF = CreateEventTHnSparse("fEventOFF",sizeEvent,binsEvent,minEvent,maxEvent);
116 static const int sizeEvent = 6;
118 // x y z #contr mult vertexStatus
119 int binsEvent[sizeEvent] = { 100, 100, 60, 200, 200, 2 }; // binning
120 double minEvent [sizeEvent] = { -1, -1, -20, 0, 3, 0 }; // min x
121 double maxEvent [sizeEvent] = { 1, 1, 20, 2000, 2000, 2 }; // max x
122 fEventHLT = CreateEventTHnSparse("fEventHLT",sizeEvent,binsEvent,minEvent,maxEvent);
123 fEventOFF = CreateEventTHnSparse("fEventOFF",sizeEvent,binsEvent,minEvent,maxEvent);
126 if(fBeamType.Contains("Pb")){ // in case of a Pb+Pb run the V0 centrality is added to the THnSparse
127 static const int sizeTrack = 13;
128 // 0 1 2 3 4 5 6 7 8 9 10 11 12
129 // pt TPCcl theta eta phi DCAr DCAz charge ITScl mult vertex status vertexZ V0centrality
130 Int_t binsTrack[sizeTrack] = { 200, 200, 200, 200, 200, 100, 100, 3, 10, 1000, 2, 60, 100 }; // binning
131 Double_t minTrack [sizeTrack] = { 0, 0, -1, -2, -1, -10, -10, -1.5, 0, 3, 0, -20, 0 }; // min x
132 Double_t maxTrack [sizeTrack] = { 5, 200, 4, 2, 7, 10, -10, 1.5, 10, 10000, 2, 20, 100 }; // max x
133 fTrackHLT = CreateTrackTHnSparse("fTrackHLT",sizeTrack,binsTrack,minTrack,maxTrack);
134 fTrackOFF = CreateTrackTHnSparse("fTrackOFF",sizeTrack,binsTrack,minTrack,maxTrack);
137 static const int sizeTrack = 12;
138 // 0 1 2 3 4 5 6 7 8 9 10 11
139 // pt TPCcl theta eta phi DCAr DCAz charge ITScl mult vertex status vertexZ
140 Int_t binsTrack[sizeTrack] = {200, 200, 200, 200, 200, 100, 100, 3, 10, 1000, 2, 60 }; // binning
141 Double_t minTrack [sizeTrack] = { 0, 0, -1, -2, -1, -10, -10, -1.5, 0, 3, 0, -20 }; // min x
142 Double_t maxTrack [sizeTrack] = { 5, 200, 4, 2, 7, 10, 10, 1.5, 10, 10000, 2, 20 }; // max x
143 fTrackHLT = CreateTrackTHnSparse("fTrackHLT",sizeTrack,binsTrack,minTrack,maxTrack);
144 fTrackOFF = CreateTrackTHnSparse("fTrackOFF",sizeTrack,binsTrack,minTrack,maxTrack);
147 fTextBox = new TText();
148 fOutputList->Add(fEventOFF);
149 fOutputList->Add(fEventHLT);
150 fOutputList->Add(fTrackOFF);
151 fOutputList->Add(fTrackHLT);
152 fOutputList->Add(fTextBox);
154 PostData(1, fOutputList);
157 void AliAnalysisTaskHLTCentralBarrel::UserExec(Option_t *){
158 // see header for documentation
160 AliESDEvent *esdOFF = dynamic_cast<AliESDEvent*>(InputEvent());
162 printf("ERROR: offline ESD is not available.\n");
166 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(fInputHandler);
167 AliESDEvent *esdHLT = NULL;
169 if(esdH) esdHLT = esdH->GetHLTEvent();
171 printf("ERROR: HLT ESD is not available.\n");
176 TTimeStamp *timestamp = new TTimeStamp(esdHLT->GetTimeStamp());
177 fTextBox->SetName("text");
178 TString s = Form("Run %d, Date %d", esdHLT->GetRunNumber(), timestamp->GetDate());
179 printf("You are analyzing run %d from date %d\n", esdHLT->GetRunNumber(), timestamp->GetDate());
180 fTextBox->SetTitle(s);
184 // if(fUseHLTTrigger && !((AliHLTGlobalTriggerDecision*)esdHLT->GetHLTTriggerDecision())->Result()) return;
186 //============================ OFFLINE =============================//
188 const AliESDVertex *vertOFF = esdOFF->GetPrimaryVertexTracks();
190 Double_t bfield = esdOFF->GetMagneticField();
191 Int_t nr_tracksOFF = 0;
193 if(esdOFF->GetEventSpecie()==16) return; // skip calibration events
195 if(fBeamType.Contains("Pb")){
196 fCentrality = esdOFF->GetCentrality();
197 // this information is only available from the offline ESD for 2011, the V0 info was not stored in the HLTesd (23.03.11,Kelly)
199 printf("Centrality pointer is empty\n");
204 for(Int_t i=0; i<esdOFF->GetNumberOfTracks(); i++){
206 AliESDtrack *esdTrackOFF = esdOFF->GetTrack(i);
207 if (!esdTrackOFF) continue;
208 if(!(esdTrackOFF->GetStatus()&AliESDtrack::kTPCin)) continue;
211 //DCA calculations(from offline)
214 esdTrackOFF->GetXYZ(x);
216 AliTracker::GetBxByBz(x,b);
217 Bool_t isOK = esdTrackOFF->RelateToVertexTPCBxByBz(vertOFF, b, kVeryBig);
220 const AliExternalTrackParam *track = esdTrackOFF->GetTPCInnerParam();
223 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
224 if(vertOFF->GetX()==0 && vertOFF->GetY()==0 && vertOFF->GetZ()==0 ){
228 esdTrackOFF->GetImpactParametersTPC(dca,cov);
230 //Float_t DCAr =-99, DCAz = -99.;
232 if(fBeamType.Contains("Pb")){
233 Double_t trackOFF[] = {
234 TMath::Abs(esdTrackOFF->Pt())
235 ,esdTrackOFF->GetTPCNcls()
236 ,esdTrackOFF->Theta()
241 ,esdTrackOFF->Charge()
244 ,esdTrackOFF->GetNcls(0)
246 ,vertOFF->GetStatus()
248 ,fCentrality->GetCentralityPercentile("V0M")
250 if(fOptions.Contains("track-off")) fTrackOFF->Fill(trackOFF);
252 Double_t trackOFF[] = {
253 TMath::Abs(esdTrackOFF->Pt())
254 ,esdTrackOFF->GetTPCNcls()
255 ,esdTrackOFF->Theta()
260 ,esdTrackOFF->Charge()
263 ,esdTrackOFF->GetNcls(0)
265 ,vertOFF->GetStatus()
268 if(fOptions.Contains("track-off")) fTrackOFF->Fill(trackOFF);
270 } // end of track loop
272 if(fBeamType.Contains("Pb")){
273 Double_t eventOFF[] = { vertOFF->GetX(), vertOFF->GetY(), vertOFF->GetZ(), vertOFF->GetNContributors(), nr_tracksOFF, vertOFF->GetStatus(),fCentrality->GetCentralityPercentile("V0M")};
274 if(fOptions.Contains("event-off")) fEventOFF->Fill(eventOFF);
277 Double_t eventOFF[] = { vertOFF->GetX(), vertOFF->GetY(), vertOFF->GetZ(), vertOFF->GetNContributors(), nr_tracksOFF, vertOFF->GetStatus()};
278 if(fOptions.Contains("event-off")) fEventOFF->Fill(eventOFF);
280 // Inspite of the different options to fill event or track properties, all the loops are being executed.
281 // The options influence only whether the respective THnSparse is filled or not.
282 // Can definitely be improved to save processing time in unnecessary loops that won't fill anything at the end.
284 //======================================== HLT ==========================================//
286 Int_t nr_tracksHLT = 0;
287 if(esdHLT->GetEventSpecie()==16) return; // skip calibration events
289 const AliESDVertex *vertHLT = esdHLT->GetPrimaryVertexTracks();
291 for(Int_t i=0; i<esdHLT->GetNumberOfTracks(); i++){
293 AliESDtrack *esdTrackHLT = esdHLT->GetTrack(i);
294 if(!esdTrackHLT) continue;
295 if(!(esdTrackHLT->GetStatus()&AliESDtrack::kTPCin)) continue;
299 //Float_t DCAr=-99; // for the DCA of the HLTesd
302 if(vertHLT->GetX()==0 && vertHLT->GetY()==0 && vertHLT->GetZ() ==0 ){
307 //Calculating DCA "old" fashion
308 esdTrackHLT->GetDZ(esdHLT->GetPrimaryVertex()->GetXv(), esdHLT->GetPrimaryVertex()->GetYv(), esdHLT->GetPrimaryVertex()->GetZv(), bfield, dca);
309 // plotting the DCA calculated by Sergey
310 //esdTrackHLT->GetImpactParametersTPC(DCAr,DCAz);
313 if(fBeamType.Contains("Pb")){
314 Double_t trackHLT[] = {
315 TMath::Abs(esdTrackHLT->Pt())
316 ,esdTrackHLT->GetTPCNcls()
317 ,esdTrackHLT->Theta()
322 ,esdTrackHLT->Charge()
325 ,esdTrackHLT->GetNcls(0)
327 ,vertHLT->GetStatus()
329 ,fCentrality->GetCentralityPercentile("V0M")
331 if(fOptions.Contains("track-hlt")) fTrackHLT->Fill(trackHLT);
333 Double_t trackHLT[] = {
334 TMath::Abs(esdTrackHLT->Pt())
335 ,esdTrackHLT->GetTPCNcls()
336 ,esdTrackHLT->Theta()
341 ,esdTrackHLT->Charge()
344 ,esdTrackHLT->GetNcls(0)
346 ,vertHLT->GetStatus()
349 if(fOptions.Contains("track-hlt")) fTrackHLT->Fill(trackHLT);
351 } // end of track loop
353 if(fBeamType.Contains("Pb")){
354 Double_t eventHLT[] = { vertHLT->GetX(), vertHLT->GetY(), vertHLT->GetZ(), vertHLT->GetNContributors(), nr_tracksHLT, vertHLT->GetStatus(),fCentrality->GetCentralityPercentile("V0M")};
355 if(fOptions.Contains("event-hlt")) fEventHLT->Fill(eventHLT);
358 Double_t eventHLT[] = { vertHLT->GetX(), vertHLT->GetY(), vertHLT->GetZ(), vertHLT->GetNContributors(), nr_tracksHLT, vertHLT->GetStatus()};
359 if(fOptions.Contains("event-hlt")) fEventHLT->Fill(eventHLT);
363 PostData(1, fOutputList);
366 void AliAnalysisTaskHLTCentralBarrel::Terminate(Option_t *){
367 // see header file of AliAnalysisTask for documentation
370 THnSparseF* AliAnalysisTaskHLTCentralBarrel::CreateEventTHnSparse(const char* name, Int_t size, const Int_t* bins, Double_t* min, Double_t* max){
371 //see header for documentation
373 THnSparseF *thn = new THnSparseF(name,"",size,bins,min,max);
374 thn->GetAxis(0)->SetTitle("primary vertex x");
375 thn->GetAxis(1)->SetTitle("primary vertex y");
376 thn->GetAxis(2)->SetTitle("primary vertex z");
377 thn->GetAxis(3)->SetTitle("number of contributors");
378 thn->GetAxis(4)->SetTitle("track multiplicity");
379 thn->GetAxis(5)->SetTitle("vertex status");
380 if(fBeamType.Contains("Pb")) thn->GetAxis(6)->SetTitle("V0 centrality");
384 THnSparseF* AliAnalysisTaskHLTCentralBarrel::CreateTrackTHnSparse(const char* name, Int_t size, const Int_t* bins, Double_t* min, Double_t* max){
385 //see header for documentation
387 THnSparseF *thn = new THnSparseF(name,"",size,bins,min,max);
388 thn->GetAxis(0)->SetTitle("p_{T}");
389 thn->GetAxis(1)->SetTitle("TPC clusters/track");
390 thn->GetAxis(2)->SetTitle("#theta");
391 thn->GetAxis(3)->SetTitle("#eta");
392 thn->GetAxis(4)->SetTitle("#phi");
393 thn->GetAxis(5)->SetTitle("DCAr");
394 thn->GetAxis(6)->SetTitle("DCAz");
395 thn->GetAxis(7)->SetTitle("polarity");
396 //thn->GetAxis(8)->SetTitle("DCArSG");
397 //thn->GetAxis(9)->SetTitle("DCAzSG");
398 thn->GetAxis(8)->SetTitle("ITS clusters/track");
402 // void AliAnalysisTaskHLTCentralBarrel::Fill(AliESDevent *esd, THnSparseF* thn){
403 // //see header for documentation
407 // for(int i=0; i<esdHLT->GetNumberOfTracks(); i++){
409 // AliESDtrack *esdTrack = esd->GetTrack(i);
410 // if(!esdTrack) continue;
411 // if(!(esdTrack->GetStatus()&AliESDtrack::kTPCin)) continue;
413 // //DCA calculations
417 // if(vertHLT->GetX()==0 && vertHLT->GetY()==0 && vertHLT->GetZ() ==0 ){
422 // //Calculating DCA "old" fashion
423 // esdTrackHLT->GetDZ(esdHLT->GetPrimaryVertex()->GetXv(), esdHLT->GetPrimaryVertex()->GetYv(), esdHLT->GetPrimaryVertex()->GetZv(), bfield, dca);
424 // // plotting the DCA calculated by Sergey
425 // esdTrackHLT->GetImpactParametersTPC(DCAr,DCAz);
428 // Double_t trackHLT[] = {
429 // TMath::Abs(esdTrackHLT->Pt())
430 // ,esdTrackHLT->GetTPCNcls()
431 // ,esdTrackHLT->Theta()
432 // ,esdTrackHLT->Eta()
433 // ,esdTrackHLT->Phi()
436 // ,esdTrackHLT->Charge()
439 // ,esdTrackHLT->GetStatus()
440 // ,esdTrackHLT->GetNcls(0)
442 // fTrackHLT->Fill(trackHLT);
445 // Double_t eventHLT[] = { vertHLT->GetX(), vertHLT->GetY(), vertHLT->GetZ(), vertHLT->GetNContributors(), nr_tracksHLT, vertHLT->GetStatus()};
446 // fEventHLT->Fill(eventHLT);