]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaAnalysis/AliTRDqaBasic.cxx
Replace deprecated methods
[u/mrichter/AliRoot.git] / TRD / qaAnalysis / AliTRDqaBasic.cxx
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 /* $Id: AliTRDqaBasic.cxx 23387 2008-01-17 17:25:16Z cblume $ */
17
18 //
19 // This class is a part of a package of high level QA monitoring for TRD.
20 //
21 // S. Radomski
22 // radomski@physi.uni-heidelberg.de
23 // March 2008
24 //
25
26 #include "AliTRDqaBasic.h"
27 #include "AliTRDqaAT.h"
28
29 #include "TMath.h"
30 #include "TH1D.h"
31 #include "TH2D.h"
32 #include "TFile.h"
33 #include "TTree.h"
34 #include "TChain.h"
35
36 #include "AliESDEvent.h"
37 #include "AliESDtrack.h"
38 #include "AliESDtrackCuts.h"
39
40 //______________________________________________________________________________
41
42 AliTRDqaBasic::AliTRDqaBasic() 
43   : AliAnalysisTask("",""),  
44     fChain(0),
45     fESD(0),
46     fOutputContainer(0),
47     fTrackCuts(0),
48     fStatus(0),
49     fnTracks(0),
50     fPtIn(0),
51     fPtOut(0),
52     fPtVtx(0),
53     fPtVtxSec(0),
54     fPtPt(0)
55 {
56   //
57   // default dummy constructor
58   //
59  
60 }
61 //______________________________________________________________________________
62
63 AliTRDqaBasic:: AliTRDqaBasic(AliTRDqaBasic& /*trd*/)
64   : AliAnalysisTask("",""),  
65     fChain(0),
66     fESD(0),
67     fOutputContainer(0),
68     fTrackCuts(0),
69     fStatus(0),
70     fnTracks(0),
71     fPtIn(0),
72     fPtOut(0),
73     fPtVtx(0),
74     fPtVtxSec(0),
75     fPtPt(0)
76 {
77   //
78   // Dummy copy constructor
79   //
80
81   //return *this;
82 }
83
84
85 //______________________________________________________________________________
86 AliTRDqaBasic::AliTRDqaBasic(const char *name) 
87   : AliAnalysisTask(name,""),  
88     fChain(0),
89     fESD(0),
90     fOutputContainer(0),
91     fTrackCuts(0),
92     fStatus(0),
93     fnTracks(0),
94     fPtIn(0),
95     fPtOut(0),
96     fPtVtx(0),
97     fPtVtxSec(0),
98     fPtPt(0)
99 {
100   // Constructor.
101   // Input slot #0 works with an Ntuple
102   DefineInput(0, TChain::Class());
103   // Output slot #0 writes into a TH1 container
104   DefineOutput(0,  TObjArray::Class()) ; 
105 }
106
107 //______________________________________________________________________________
108 void AliTRDqaBasic::ConnectInputData(const Option_t *)
109 {
110   // Initialisation of branch container and histograms 
111
112   //AliInfo(Form("*** Initialization of %s", GetName())) ; 
113
114   fChain = (TChain*)GetInputData(0);
115   fESD = new AliESDEvent();
116   fESD->ReadFromTree(fChain);
117 }
118
119 //________________________________________________________________________
120 void AliTRDqaBasic::CreateOutputObjects()
121 {
122   // build histograms
123  
124   fStatus   = new TH1D("status", ";status bit", 32, -0.5, 31.5);
125   fPtIn     = new TH1D("ptIn", ";p_{T}, GeV/c", 100, 0, 15);
126   fPtOut    = new TH1D("ptOut", ";p_{T}, GeV/c", 100, 0, 15);
127   fPtVtx    = new TH1D("ptVtx", ";p_{T}, GeV/c", 100, 0, 15);
128   fPtVtxSec = new TH1D("ptVtxSec", ";p_{T}, GeV/c", 100, 0, 15);
129   fnTracks  = new TH1D("nTracks", "", 200, -0.5, 199.5);
130   
131   fPtPt     = new TH2D("ptpt", ";p_{T} from inner plane, GeV/c;p_{T} at vertex, GeV/c", 
132                        100, 0, 10, 100, 0, 10);
133
134   Int_t c = 0;
135   fOutputContainer = new TObjArray(50);
136
137   fOutputContainer->AddAt(fStatus, c++);
138   fOutputContainer->AddAt(fPtIn, c++);
139   fOutputContainer->AddAt(fPtOut, c++);
140   fOutputContainer->AddAt(fPtVtx, c++);
141   fOutputContainer->AddAt(fPtVtxSec, c++);
142   fOutputContainer->AddAt(fnTracks, c++);
143   fOutputContainer->AddAt(fPtPt, c++);  
144
145   printf("n hist = %d\n", c);
146   
147   // initialize cuts
148   fTrackCuts =  new AliESDtrackCuts("AliESDtrackCuts");
149   fTrackCuts->DefineHistograms(0);
150
151   // default cuts for ITS+TPC
152   Double_t cov1 = 2;
153   Double_t cov2 = 2;
154   Double_t cov3 = 0.5;
155   Double_t cov4 = 0.5;
156   Double_t cov5 = 2;
157   Double_t nSigma = 3;
158
159   TString tag("Global tracking");
160
161   fTrackCuts->SetMaxCovDiagonalElements(cov1, cov2, cov3, cov4, cov5);
162
163   fTrackCuts->SetMaxNsigmaToVertex(nSigma);
164   fTrackCuts->SetRequireSigmaToVertex(kTRUE);
165
166   fTrackCuts->SetRequireTPCRefit(kTRUE);
167   fTrackCuts->SetAcceptKinkDaughters(kFALSE);
168
169   fTrackCuts->SetMinNClustersTPC(50);
170   fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
171 }
172 //______________________________________________________________________________
173 void AliTRDqaBasic::Exec(Option_t *) 
174 {
175   // Process one event
176   Long64_t entry = fChain->GetReadEntry() ;
177   if (!(entry%100)) Info("Exec", "Entry = %ld", entry);
178
179   // Processing of one event 
180    
181   if (!fESD) {
182     //AliError("fESD is not connected to the input!") ; 
183     return ; 
184   }
185   
186   Int_t nTracks = fESD->GetNumberOfTracks();
187   fnTracks->Fill(nTracks); 
188
189   // track loop
190   for(Int_t i=0; i<nTracks; i++) {
191     
192     //
193     // track selection 
194     //
195     // param in and Out
196     // TRDrefit and TRDPid bit
197     //
198  
199     AliESDtrack *track = fESD->GetTrack(i);
200     const AliExternalTrackParam *paramOut = track->GetOuterParam();
201     const AliExternalTrackParam *paramIn = track->GetInnerParam();
202
203     // long track ..
204     if (!paramIn) continue;
205     if (!paramOut) continue;
206     
207     UInt_t status = track->GetStatus();
208     if (!(status & AliESDtrack::kTPCrefit)) continue;
209
210     //if (!fTrackCuts->AcceptTrack(track)) continue;
211     
212     AliTRDqaAT::FillStatus(fStatus, status);
213
214     fPtIn->Fill(paramIn->Pt());
215     fPtOut->Fill(paramOut->Pt());
216     fPtVtx->Fill(track->Pt());
217     if (track->GetConstrainedParam())
218       fPtVtxSec->Fill(track->GetConstrainedParam()->Pt());
219     
220     fPtPt->Fill(paramIn->Pt(), track->Pt());
221   }
222
223   PostData(0, fOutputContainer);
224 }
225
226 //______________________________________________________________________________
227 void AliTRDqaBasic::Terminate(Option_t *)
228 {
229   // save histograms
230   fOutputContainer = (TObjArray*)GetOutputData(0);
231   
232   TFile *file = new TFile("outBasic.root", "RECREATE");
233   fOutputContainer->Write();
234  
235   file->Flush();
236   file->Close();
237   delete file;
238
239   //for(Int_t i=0; i<fOutputContainer->GetEntries(); i++) {
240   //  TObject *obj = fOu
241   // }
242 }
243
244 //______________________________________________________________________________