1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //Task for analysis if TPC base QA
23 // 1 - number of clusters
24 // 2 - number of findable clusters
25 // 3 - number of clusters/ findable clusters
26 // 4 - pt - at the entrance of the TPC
27 // 5 - eta - at the entrance of the TPC
28 // 6 - phi - at the entrance of the TPC
30 //-----------------------------------------------------------------------
31 // Author : M.Ivanov marian.ivanov@cern.ch -
32 //-----------------------------------------------------------------------
43 #include <TParticle.h>
46 #include <AliAnalysisManager.h>
47 #include <AliESDInputHandler.h>
49 #include "AliMCEvent.h"
50 #include "AliMCEventHandler.h"
51 #include "AliMathBase.h"
54 #include "AliExternalTrackParam.h"
55 #include "AliTracker.h"
56 #include "AliTPCseed.h"
58 #include "AliTPCtaskQA.h"
60 #include <THnSparse.h>
70 ClassImp(AliTPCtaskQA)
72 //________________________________________________________________________
73 AliTPCtaskQA::AliTPCtaskQA() :
75 fMCinfo(0), //! MC event handler
81 // Default constructor (should not be used)
85 AliTPCtaskQA::AliTPCtaskQA(const AliTPCtaskQA& info) :
86 AliAnalysisTask(info),
87 fMCinfo(info.fMCinfo), //! MC event handler
93 // Dummy Copy constructor - no copy constructor for THnSparse
95 fList = (TObjArray*)(info.fList->Clone());
100 //________________________________________________________________________
101 AliTPCtaskQA::AliTPCtaskQA(const char *name) :
102 AliAnalysisTask(name, "AliTPCtaskQA"),
103 fMCinfo(0), //! MC event handler
109 // Normal constructor
111 // Input slot #0 works with a TChain
112 DefineInput(0, TChain::Class());
113 // Output slot #0 writes into a TList
114 DefineOutput(0, TObjArray::Class());
120 void AliTPCtaskQA::Init(){
126 // 1 - number of clusters
127 // 2 - number of findable clusters
128 // 3 - number of clusters/ findable clusters
129 // 4 - pt - at the entrance of the TPC
130 // 5 - eta - at the entrance of the TPC
131 // 6 - phi - at the entrance of the TPC
135 Double_t xmin[7], xmax[7];
138 nbins[0]=100; // chi2
139 xmin[0]=0; xmax[0]=10;
142 xmin[1]=0; xmax[1]=160;
144 nbins[2]=80; // nclsf
145 xmin[2]=0; xmax[2]=160;
147 nbins[3]=40; // ncls/nclsf
148 xmin[3] =-0.1; xmax[3]=1.1;
151 xmin[4] =0.1; xmax[4]=100;
154 xmin[5] =-2; xmax[5]=2;
156 nbins[6]= 360; // phi - 10 bins per sector
157 xmin[6] = -TMath::Pi(); xmax[6]=TMath::Pi();
161 fTPCqa = new THnSparseS("TPC qa","TPC qa",7,nbins,xmin,xmax);
164 BinLogX(fTPCqa->GetAxis(4));
166 char *hisAxisName[7] ={"chi2/N_{cl}","N_{cl}","N_{clF}","N_{clR}","p_{t}","#eta","#phi"};
168 for (Int_t i=0;i<7;i++) {
169 fTPCqa->GetAxis(i)->SetTitle(hisAxisName[i]);
170 fTPCqa->GetAxis(i)->SetName(hisAxisName[i]);
172 fList = new TObjArray(3);
173 fList->AddAt(fTPCqa,0);
179 AliTPCtaskQA::~AliTPCtaskQA(){
187 //________________________________________________________________________
188 void AliTPCtaskQA::ConnectInputData(Option_t *)
191 // Connect the input data
194 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
196 //Printf("ERROR: Could not read chain from input slot 0");
199 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
201 //Printf("ERROR: Could not get ESDInputHandler");
204 fESD = esdH->GetEvent();
205 //Printf("*** CONNECTED NEW EVENT ****");
208 AliMCEventHandler* mcinfo = (AliMCEventHandler*) (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
209 mcinfo->SetReadTR(kTRUE);
211 fMCinfo = mcinfo->MCEvent();
221 //________________________________________________________________________
222 void AliTPCtaskQA::CreateOutputObjects()
225 // Connect the output objects
231 //________________________________________________________________________
232 void AliTPCtaskQA::Exec(Option_t *) {
234 // Execute analysis for current event
238 // If MC has been connected
241 cout << "Not MC info\n" << endl;
258 void AliTPCtaskQA::ProcessMCInfo(){
265 Int_t npart = fMCinfo->GetNumberOfTracks();
266 Int_t ntracks = fESD->GetNumberOfTracks();
267 if (npart<=0) return;
268 if (ntracks<=0) return;
271 TParticle * particle= new TParticle;
272 TClonesArray * trefs = new TClonesArray("AliTrackReference");
274 for (Int_t itrack=0;itrack<ntracks;itrack++){
275 AliESDtrack *track = fESD->GetTrack(itrack);
277 if ((track->GetStatus()&AliESDtrack::kTPCrefit)==0) continue; // only refited tracks
278 Int_t ipart = TMath::Abs(track->GetLabel());
280 Int_t status = fMCinfo->GetParticleAndTR(ipart, particle, trefs);
281 if (status<0) continue;
282 if (!particle) continue;
283 if (!trefs) continue;
286 AliTrackReference *tpcRef=0;
287 for (Int_t iref=0; iref<trefs->GetEntries(); iref++){
288 AliTrackReference *ref = (AliTrackReference*)trefs->At(iref);
289 if (ref->DetectorId()== AliTrackReference::kTPC){
294 if (!tpcRef) continue;
300 x[0]= track->GetTPCchi2()/track->GetTPCNcls();
301 x[1]= track->GetTPCNcls();
302 x[2]= track->GetTPCNclsF();
303 x[3]= Float_t(track->GetTPCNcls())/Float_t(track->GetTPCNclsF());
305 x[5]= -0.5*TMath::Log((tpcRef->P()+tpcRef->Pz())/(tpcRef->P()-tpcRef->Pz()));
306 x[6]= TMath::ATan2(tpcRef->Y(),tpcRef->X());
317 void AliTPCtaskQA::BinLogX(TAxis *axis) {
321 Int_t bins = axis->GetNbins();
323 Double_t from = axis->GetXmin();
324 Double_t to = axis->GetXmax();
325 Double_t *new_bins = new Double_t[bins + 1];
328 Double_t factor = pow(to/from, 1./bins);
330 for (Int_t i = 1; i <= bins; i++) {
331 new_bins[i] = factor * new_bins[i-1];
333 axis->Set(bins, new_bins);
338 AliTPCtaskQA* AliTPCtaskQA::ReadFromFile(const char *fname){
342 AliTPCtaskQA *qa = new AliTPCtaskQA;
343 TFile *f = new TFile(fname);
344 TObjArray *array= (TObjArray*)f->Get("tpcTaskQA");
345 qa->fTPCqa = (THnSparse*)array->At(0);