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: Zhongbao Yin <zbyin@mail.ccnu.edu.cn>, *
7 //* Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliAnalysisTaskHLT.cxx
20 @author Kalliopi Kanaki, Hege Erdal
22 @brief An analysis task containing
23 loops over HLT and offline ESD trees for comparing
24 AliESDtrack properties.
29 class AliAnalysisTask;
30 class AliAnalysisManager;
32 #include "AliAnalysisTaskHLT.h"
33 #include "AliHLTGlobalTriggerDecision.h"
37 #include "AliESDEvent.h"
38 #include "AliESDtrackCuts.h"
39 #include "AliESDInputHandler.h"
40 #include "AliTracker.h"
41 #include "AliCentrality.h"
44 #include "TTimeStamp.h"
46 ClassImp(AliAnalysisTaskHLT)
48 //===============================================================//
50 AliAnalysisTaskHLT::AliAnalysisTaskHLT()
53 ,fUseHLTTrigger(kFALSE)
54 //,fESDOfftrackCuts(0)
55 //,fESDHLTtrackCuts(0)
71 ,fEtaMomentumcutOff(0)
90 ,fEtaMomentumcutHLT(0)
101 // Define input and output slots here
102 // Input slot #0 works with a TChain
103 // DefineInput(0, TChain::Class());
104 // Output slot #0 writes into a TH1 container
107 AliAnalysisTaskHLT::AliAnalysisTaskHLT(const char *name)
109 AliAnalysisTaskSE(name)
110 ,fUseHLTTrigger(kFALSE)
111 //,fESDOfftrackCuts(0)
112 //,fESDHLTtrackCuts(0)
128 ,fEtaMomentumcutOff(0)
145 ,fEtaMomentumcutHLT(0)
156 // Define input and output slots here
157 // Input slot #0 works with a TChain
158 // DefineInput(0, TChain::Class());
159 // Output slot #0 writes into a TH1 container
160 DefineOutput(1, TList::Class());
163 //------------------------------------------------------------------------//
165 void AliAnalysisTaskHLT::UserCreateOutputObjects(){
169 fOutputList = new TList();
170 fOutputList->SetOwner();
171 fOutputList->SetName(GetName());
174 //0 mistriggered, 1 Good triggered, 2, triggered, 3 fake trigger,
175 //4 events with offline track, 5 total events processed,
176 //6 offline track thru CE, 7 online track to CE
177 fHistTrigger = new TH1F("fHistTrigger", "Trigger Status", 8, -0.5, 7.5);
178 fHistTrigger->GetXaxis()->SetTitle("");
179 fHistTrigger->GetYaxis()->SetTitle("Events");
180 fHistTrigger->SetMarkerStyle(kFullCircle);
181 fHistTrigger->SetStats(0);
182 fHistTrigger->SetFillColor(2);
183 //fHistTrigger->SetDrawOption("B TEXT60");
186 (fHistTrigger->GetXaxis())->SetBinLabel(1,"missed");
187 (fHistTrigger->GetXaxis())->SetBinLabel(2,"triggerWofflTrk");
188 (fHistTrigger->GetXaxis())->SetBinLabel(3,"triggered");
189 (fHistTrigger->GetXaxis())->SetBinLabel(4,"triggerWOofflTrk");
190 (fHistTrigger->GetXaxis())->SetBinLabel(5,"NevWofflTrk");
191 (fHistTrigger->GetXaxis())->SetBinLabel(6,"Nevt");
192 (fHistTrigger->GetXaxis())->SetBinLabel(7,"offlTrkThruCE");
193 (fHistTrigger->GetXaxis())->SetBinLabel(8,"onlTrkThruCE");
196 fHistTrigger = new TH1F("fHistTrigger", "CTP trigger counter", 24, 0, 24);
197 fHistTrigger->GetXaxis()->SetTitle("");
198 fHistTrigger->GetYaxis()->SetTitle("#Events");
200 //=========== event properties =================//
202 if(fBeamType.Contains("Pb")){
203 fMultOff = new TH1F("fMult_off","TPC track multiplicity (OFF)",200,0,2000);
204 fMultHLT = new TH1F("fMult_hlt","TPC track multiplicity (HLT)",200,0,2000);
205 fV0cent = new TH1F("fV0cent", "V0 centrality", 100,0, 100);
208 fMultOff = new TH1F("fMult_off","TPC track multiplicity (OFF)",200,0,200);
209 fMultHLT = new TH1F("fMult_hlt","TPC track multiplicity (HLT)",200,0,200);
212 fXYvertexOff = new TH2F("fXYvertex_off","XY primary vertex (OFF)",100,-1,1,100,-1,1);
213 fXYvertexHLT = new TH2F("fXYvertex_hlt","XY primary vertex (HLT)",100,-1,1,100,-1,1);
215 fXvertexOff = new TH1F("fXvertex_off","X primary vertex (OFF)",200,-0.5,0.5);
216 fXvertexHLT = new TH1F("fXvertex_hlt","X primary vertex (HLT)",200,-0.5,0.5);
218 fYvertexOff = new TH1F("fYvertex_off","Y primary vertex (OFF)",200,-0.5,0.5);
219 fYvertexHLT = new TH1F("fYvertex_hlt","Y primary vertex (HLT)",200,-0.5,0.5);
221 fZvertexOff = new TH1F("fZvertex_off","Z primary vertex (OFF)",100,-20,20);
222 fZvertexHLT = new TH1F("fZvertex_hlt","Z primary vertex (HLT)",100,-20,20);
224 fEventSpecieOff = new TH1F("fEventSpecie_off","Eventspecie for OFF",18, 0, 18);
225 fEventSpecieHLT = new TH1F("fEventSpecie_hlt","Eventspecie for HLT",18, 0, 18);
227 //============== track properties =================//
229 fChargeOff = new TH1F("fCharge_off", "Charge distribution (OFF)", 3, -1.5, 1.5);
230 fChargeHLT = new TH1F("fCharge_hlt", "Charge distribution (HLT)", 3, -1.5, 1.5);
232 fMomentumOff = new TH1F("fMomentum_off", "p_{T} (OFF)", 100, 0, 10);
233 fMomentumHLT = new TH1F("fMomentum_hlt", "p_{T} (HLT)", 100, 0, 10);
235 fDCArOff = new TH1F("fDCA_off", "DCAr to beam line (OFF)", 200, -15, 15);
236 fDCArHLT = new TH1F("fDCA_hlt", "DCAr to beam line (HLT)", 200, -15, 15);
238 fDCAzOff = new TH1F("fDCAz_off", "DCAz to beam line (OFF)", 200, -15, 15);
239 fDCAzHLT = new TH1F("fDCAz_hlt", "DCAz to beam line (HLT)", 200, -15, 15);
241 fNclusterOff = new TH1F("fNcluster_off","TPC clusters/track (OFF)", 200, 0, 200);
242 fNclusterHLT = new TH1F("fNcluster_hlt","TPC clusters/track (HLT)", 200, 0, 200);
244 fPhiOff = new TH1F("fPhi_off","azimuthal angle distribution (OFF)",90,0,360);
245 fPhiHLT = new TH1F("fPhi_hlt","azimuthal angle distribution (HLT)", 90,0,360);
247 fEtaOff = new TH1F("fEta_off","pseudorapidity (OFF)",100,-2,2);
248 fEtaHLT = new TH1F("fEta_hlt","pseudorapidity (HLT)",100,-2,2);
253 fNclusterOffwCut = new TH1F("fNcluster_wcut_off","TPC clusters per track with cuts (OFF)", 200, 0, 200);
254 fNclusterHLTwCut = new TH1F("fNcluster_wcut_hlt","TPC clusters per track with cuts (HLT)", 200, 0, 200);
256 fEtaMomentumcutOff = new TH1F("fEtaMomentumcut_off","pseudorapidity DCAcut (OFF)",100,-2,2);
257 fEtaMomentumcutHLT = new TH1F("fEtaMomentumcut_hlt","pseudorapidity DCAcut (HLT)", 100,-2,2);
259 fNclusVSphiOff = new TH2F("fNclus_vs_phi_off","clusters per track vs. #phi (OFF)",360,0,360,160,0,160);
260 fNclusVSphiHLT = new TH2F("fNclus_vs_phi_hlt","clusters per track vs. #phi (HLT)", 360,0,360,160,0,160);
262 fNclusVSthetaOff = new TH2F("fNclus_vs_theta_off","clusters per track vs. #theta (OFF)",180,0,180,160,0,160);
263 fNclusVSthetaHLT = new TH2F("fNclus_vs_theta_hlt","clusters per track vs. #theta (HLT)", 180,0,180,160,0,160);
265 //--------------------------------------------------//
267 fTextBox = new TText();
269 fOutputList->Add(fHistTrigger);
271 fOutputList->Add(fChargeOff); fOutputList->Add(fChargeHLT);
272 fOutputList->Add(fMomentumOff); fOutputList->Add(fMomentumHLT);
273 fOutputList->Add(fDCArOff); fOutputList->Add(fDCArHLT);
274 fOutputList->Add(fDCAzOff); fOutputList->Add(fDCAzHLT);
275 fOutputList->Add(fNclusterOff); fOutputList->Add(fNclusterHLT);
276 fOutputList->Add(fNclusterOffwCut); fOutputList->Add(fNclusterHLTwCut);
277 fOutputList->Add(fPhiOff); fOutputList->Add(fPhiHLT);
278 fOutputList->Add(fMultOff); fOutputList->Add(fMultHLT);
279 fOutputList->Add(fXYvertexOff); fOutputList->Add(fXYvertexHLT);
280 fOutputList->Add(fXvertexOff); fOutputList->Add(fXvertexHLT);
281 fOutputList->Add(fYvertexOff); fOutputList->Add(fYvertexHLT);
282 fOutputList->Add(fZvertexOff); fOutputList->Add(fZvertexHLT);
283 fOutputList->Add(fEtaOff); fOutputList->Add(fEtaHLT);
284 fOutputList->Add(fEtaMomentumcutOff); fOutputList->Add(fEtaMomentumcutHLT);
285 fOutputList->Add(fNclusVSphiOff); fOutputList->Add(fNclusVSphiHLT);
286 fOutputList->Add(fNclusVSthetaOff); fOutputList->Add(fNclusVSthetaHLT);
287 fOutputList->Add(fEventSpecieOff); fOutputList->Add(fEventSpecieHLT);
289 fOutputList->Add(fTextBox);
290 if(fBeamType.Contains("Pb")) fOutputList->Add(fV0cent);
292 //SetupESDtrackCuts();
293 PostData(1, fOutputList);
296 void AliAnalysisTaskHLT::UserExec(Option_t *){
297 // see header file of AliAnalysisTask for documentation
299 AliESDEvent *esdOFF = dynamic_cast<AliESDEvent*>(InputEvent());
301 printf("Error:UserExec OFF esd not available\n");
305 if(esdOFF->GetEventSpecie()==16) return; // skip calibration events, HLT doesn't set this flag yet
307 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(fInputHandler);
309 printf("The ESD input handler is empty\n");
313 AliESDEvent *esdHLT = NULL;
314 if(esdH) esdHLT = esdH->GetHLTEvent();
316 printf("Error:UserExec HLT esd not available\n");
321 TTimeStamp *timestamp = new TTimeStamp(esdHLT->GetTimeStamp());
322 fTextBox->SetName("text");
323 TString s = Form("Run %d, Date %d", esdHLT->GetRunNumber(), timestamp->GetDate());
324 printf("You are analyzing run %d from date %d\n\n", esdHLT->GetRunNumber(), timestamp->GetDate());
325 fTextBox->SetTitle(s);
329 Double_t bfield = esdOFF->GetMagneticField();
331 // UInt_t Statusnames[12]={AliESDtrack::kTPCin,
332 // AliESDtrack::kITSin,
333 // AliESDtrack::kTPCout,
334 // AliESDtrack::kITSout,
335 // AliESDtrack::kITSrefit,
336 // AliESDtrack::kTPCrefit,
337 // AliESDtrack::kTRDin,
338 // AliESDtrack::kTRDout,
339 // AliESDtrack::kTRDrefit,
340 // AliESDtrack::kTOFin,
341 // AliESDtrack::kTOFout,
342 // AliESDtrack::kTOFrefit};
346 //---------------- HLT ESD tree -----------------------//
348 Int_t nr_tracksHLT = 0;
349 const AliESDVertex *vertHLT = esdHLT->GetPrimaryVertexTracks();
351 // Int_t nr_contributorsHLT = vertHLT->GetNContributors();
353 // if(nr_contributorsHLT<1) {
355 // vertHLT = esdHLT->GetPrimaryVertexSPD();
356 // if(nr_contributorsHLT<1) {
357 // // NO GOOD VERTEX, SKIP EVENT
358 // testVertexHLT=kFALSE;
361 if(vertHLT->GetStatus()==kTRUE){
362 fXYvertexHLT->Fill(vertHLT->GetX(), vertHLT->GetY() );
363 fXvertexHLT->Fill( vertHLT->GetX() );
364 fYvertexHLT->Fill( vertHLT->GetY() );
365 fZvertexHLT->Fill( vertHLT->GetZ() );
367 //At the moment no constrains on vertex before filling histograms
370 fEventSpecieHLT->Fill(esdHLT->GetEventSpecie());
372 for(Int_t i=0; i<esdHLT->GetNumberOfTracks(); i++){
374 AliESDtrack *esdtrackHLT = esdHLT->GetTrack(i);
375 if(!esdtrackHLT) continue;
377 //Fill which status flags that are set for an event
378 //for(int jjj=0;jjj<12;jjj++){
379 // if(esdtrackHLT->GetStatus()&Statusnames[jjj]) fStatusHLT->Fill(jjj);
382 if(!(esdtrackHLT->GetStatus()&AliESDtrack::kTPCin)) continue; // only interested in tracks with kTPCin flag
383 if(esdtrackHLT->GetTPCNcls()<=0) continue;
386 //Calculating DCA "old" fashion
388 esdtrackHLT->GetDZ(esdHLT->GetPrimaryVertex()->GetXv(), esdHLT->GetPrimaryVertex()->GetYv(), esdHLT->GetPrimaryVertex()->GetZv(), bfield, dca);
390 fDCArHLT->Fill(dca[0]);
391 fDCAzHLT->Fill(dca[1]);
393 fChargeHLT->Fill(esdtrackHLT->Charge());
394 fNclusterHLT->Fill(esdtrackHLT->GetTPCNcls());
395 fEtaHLT->Fill(esdtrackHLT->Eta());
396 fPhiHLT->Fill(esdtrackHLT->Phi()*TMath::RadToDeg());
397 fMomentumHLT->Fill(TMath::Abs(esdtrackHLT->Pt()));
398 } // end of loop over hlt tracks
400 if(nr_tracksHLT>0) fMultHLT->Fill(nr_tracksHLT);
402 //----------------- OFFLINE ESD tree ----------------//
404 Int_t nr_tracksOff = 0;
405 const AliESDVertex *vertOff = esdOFF->GetPrimaryVertexTracks();
407 if(fBeamType.Contains("Pb")){
408 fCentrality = esdOFF->GetCentrality();
409 // this information is only available from the offline ESD for 2010 PbPb data, the V0 info was not stored in the HLTesd (17.04.11, Kelly)
411 printf("Centrality pointer is empty\n");
414 else fV0cent->Fill(fCentrality->GetCentralityPercentile("V0M"));
417 if(vertOff->GetStatus()==kTRUE){
418 fXYvertexOff->Fill(vertOff->GetX(), vertOff->GetY() );
419 fXvertexOff->Fill( vertOff->GetX() );
420 fYvertexOff->Fill( vertOff->GetY() );
421 fZvertexOff->Fill( vertOff->GetZ() );
424 fEventSpecieOff->Fill(esdOFF->GetEventSpecie());
426 for(Int_t i=0; i<esdOFF->GetNumberOfTracks(); i++){
428 AliESDtrack *esdtrackOFF = esdOFF->GetTrack(i);
429 if (!esdtrackOFF) continue;
431 if(!(esdtrackOFF->GetStatus()&AliESDtrack::kTPCin)) continue;
432 if(esdtrackOFF->GetTPCNcls()<=0) continue;
436 esdtrackOFF->GetXYZ(x);
438 AliTracker::GetBxByBz(x,b);
439 Bool_t isOK = esdtrackOFF->RelateToVertexTPCBxByBz(vertOff, b, kVeryBig);
442 const AliExternalTrackParam *track = esdtrackOFF->GetTPCInnerParam();
445 Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
446 esdtrackOFF->GetImpactParametersTPC(dca,cov);
448 fDCArOff->Fill(dca[0]);
449 fDCAzOff->Fill(dca[1]);
451 fChargeOff->Fill(esdtrackOFF->Charge());
452 fNclusterOff->Fill(esdtrackOFF->GetTPCNcls());
453 fEtaOff->Fill(esdtrackOFF->Eta());
454 fPhiOff->Fill(esdtrackOFF->Phi()*TMath::RadToDeg());
455 fMomentumOff->Fill( TMath::Abs(esdtrackOFF->Pt()) );
457 } // end of loop over offline tracks
459 if(nr_tracksOff>0) fMultOff->Fill(nr_tracksOff);
461 PostData(1, fOutputList);
464 void AliAnalysisTaskHLT::Terminate(Option_t *){
465 // see header file of AliAnalysisTask for documentation
468 // void AliAnalysisTaskHLT::SetupESDtrackCuts(){ // not called
470 // // NB! Work in progress!
472 // Bool_t selPrimaries = kTRUE;
474 // fESDOfftrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
475 // //To make Offline cuts = HLT cuts
476 // fESDOfftrackCuts->SetRequireITSRefit(kFALSE);
477 // fESDOfftrackCuts->SetEtaRange(-0.9,+0.9);
481 // //NB! Need to understand this a bit more! Which cuts should we keep?
482 // fESDHLTtrackCuts = new AliESDtrackCuts;
485 // fESDHLTtrackCuts->SetRequireTPCStandAlone(kTRUE); // to get chi2 and ncls of kTPCin
486 // fESDHLTtrackCuts->SetMinNClustersTPC(70);
487 // fESDHLTtrackCuts->SetMaxChi2PerClusterTPC(4);
488 // fESDHLTtrackCuts->SetAcceptKinkDaughters(kFALSE);
490 // fESDHLTtrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
491 // AliESDtrackCuts::kAny);
493 // if(selPrimaries) { // 7*(0.0050+0.0060/pt^0.9)
494 // fESDHLTtrackCuts->SetMaxDCAToVertexXYPtDep("0.0350+0.0420/pt^0.9");
497 // fESDHLTtrackCuts->SetMaxDCAToVertexZ(1.e6);
498 // fESDHLTtrackCuts->SetDCAToVertex2D(kFALSE);
499 // fESDHLTtrackCuts->SetRequireSigmaToVertex(kFALSE);
500 // fESDHLTtrackCuts->SetEtaRange(-0.9,+0.9);