]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx
aab57496d87658b2e6f18215d5f581f5b5b54fe2
[u/mrichter/AliRoot.git] / TRD / qaAnalysis / AliTRDqaEnergyDeposit.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: AliTRDqaEnergyDeposit.cxx $ */
17
18 //
19 // This class is a part of a package of high level QA monitoring for TRD.
20 // In this class the dEdX is analyzed as a function of the particle type,
21 // momentum and chamber.
22 //
23 // S. Radomski
24 // radomski@physi.uni-heidelberg.de
25 // March 2008
26 //
27
28 #include "AliTRDqaEnergyDeposit.h"
29
30 #include "TMath.h"
31 #include "TH1D.h"
32 #include "TH2D.h"
33 #include "TFile.h"
34 #include "TTree.h"
35 #include "TChain.h"
36
37 #include "AliESDEvent.h"
38 #include "AliESDtrack.h"
39 #include "AliKalmanTrack.h"
40
41 //______________________________________________________________________________
42
43 AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit() 
44   : AliAnalysisTask("",""),  
45     fChain(0),
46     fESD(0),
47     fOutputContainer(0)
48 {
49   // Dummy default constructor
50 }
51 //______________________________________________________________________________
52
53 AliTRDqaEnergyDeposit:: AliTRDqaEnergyDeposit(AliTRDqaEnergyDeposit& /*trd*/)
54   : AliAnalysisTask("",""),  
55     fChain(0),
56     fESD(0),
57     fOutputContainer(0)
58 {
59   // Dummy copy constructor
60   
61   //return *this;
62 }
63
64 //______________________________________________________________________________
65 AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit(const char *name) 
66   : AliAnalysisTask(name,""),  
67     fChain(0),
68     fESD(0),
69     fOutputContainer(0)
70 {
71   // Constructor.
72   // Input slot #0 works with an Ntuple
73   DefineInput(0, TChain::Class());
74   // Output slot #0 writes into a TH1 container
75   DefineOutput(0,  TObjArray::Class()) ; 
76 }
77
78 //______________________________________________________________________________
79 void AliTRDqaEnergyDeposit::ConnectInputData(const Option_t *)
80 {
81   // Initialisation of branch container and histograms 
82
83   //AliInfo(Form("*** Initialization of %s", GetName())) ; 
84
85   fChain = (TChain*)GetInputData(0);
86   fESD = new AliESDEvent();
87   fESD->ReadFromTree(fChain);
88 }
89
90 //________________________________________________________________________
91 void AliTRDqaEnergyDeposit::CreateOutputObjects()
92 {
93   // build histograms
94   
95   // prepare the scale from 0.5 to 10 GeV
96   const Int_t knbinsx = 50;
97   Double_t scalex[knbinsx+1];
98   Double_t dd = (TMath::Log(10) - TMath::Log(0.5)) / knbinsx;
99   for(Int_t ix=0; ix<knbinsx+1; ix++) {
100     scalex[ix] = 0.5 * TMath::Exp(dd * ix);
101   }
102
103   const Int_t knbinsy = 50;
104   Double_t scaley[knbinsy+1];
105   for(Int_t iy=0; iy<knbinsy+1; iy++) {
106     scaley[iy] = iy * (3e3/100.);
107   }
108   
109   const char *title = ";p_{T};dEdX (a. u.)";
110   const char *charge[2] = {"Pos", "Neg"};
111
112   // build histograms
113   fOutputContainer = new TObjArray(50);
114   Int_t c=0;
115
116   for(Int_t i=0; i<2; i++) {
117
118     fSignalPtSum[i] = new TH2D(Form("ptSig%s", charge[i]), title, knbinsx, scalex, knbinsy, scaley);
119     fOutputContainer->AddAt(fSignalPtSum[i], c++);
120
121     for(Int_t j=0; j<AliPID::kSPECIES; j++) {
122       Int_t idx = AliPID::kSPECIES*i+j;
123       fSignalPtType[idx] = 
124         new TH2D(Form("ptSig%s%d", charge[i], j), title, knbinsx, scalex, knbinsy, scaley);
125       fOutputContainer->AddAt(fSignalPtType[idx], c++);
126       
127       fProb[idx] = new TH1D(Form("prob%s%d", charge[i], j), ";LQ", 100, 0, 1);
128       fOutputContainer->AddAt(fProb[idx], c++);
129     }  
130   }
131
132   printf("n hist = %d\n", c);
133 }
134 //______________________________________________________________________________
135 void AliTRDqaEnergyDeposit::Exec(Option_t *) 
136 {
137   // Process one event
138   
139   //  Long64_t entry = fChain->GetReadEntry() ;
140   
141   // Processing of one event 
142    
143   if (!fESD) {
144     //AliError("fESD is not connected to the input!") ; 
145     return ; 
146   }
147   
148   Int_t nTracks = fESD->GetNumberOfTracks();
149   //fNTracks->Fill(nTracks); 
150
151   // track loop
152   for(Int_t i=0; i<nTracks; i++) {
153     
154     //
155     // track selection 
156     //
157     // param in and Out
158     // TRDrefit and TRDPid bit
159     //
160  
161     AliESDtrack *track = fESD->GetTrack(i);
162     const AliExternalTrackParam *paramOut = track->GetOuterParam();
163     const AliExternalTrackParam *paramIn = track->GetInnerParam();
164
165     // long track ..
166     if (!paramIn) continue;
167     if (!paramOut) continue;
168     
169     UInt_t status = track->GetStatus();
170     if (!(status & AliESDtrack::kTRDrefit)) continue;
171     if (!(status & AliESDtrack::kTRDpid)) continue;
172     if (track->GetTRDpidQuality() < 6) continue;
173
174     // standard selection
175     
176     Int_t idx = (track->GetSign() > 0) ? 0 : 1;
177     Double_t pt = paramOut->Pt();
178
179     Double_t signal = 0;
180     for(Int_t i=0; i<6; i++)
181       signal += track->GetTRDsignals(i, -1);
182     signal /= 6;
183
184     fSignalPtSum[idx]->Fill(pt, signal);
185     
186     for(Int_t i=0; i<AliPID::kSPECIES; i++) {
187       
188       Double_t lq = track->GetTRDpid(i);
189       fProb[AliPID::kSPECIES*idx+i]->Fill(lq);
190       fSignalPtType[AliPID::kSPECIES*idx+i]->Fill(pt, signal, lq);
191     }
192   }
193
194   PostData(0, fOutputContainer);
195 }
196
197 //______________________________________________________________________________
198 void AliTRDqaEnergyDeposit::Terminate(Option_t *)
199 {
200   // retrieve histograms
201   fOutputContainer = (TObjArray*)GetOutputData(0);
202   
203   // post processing
204
205
206   // save the results
207   TFile *file = new TFile("outEnergyDeposit.root", "RECREATE");
208   fOutputContainer->Write();
209  
210   file->Flush();
211   file->Close();
212   delete file;
213
214   //for(Int_t i=0; i<fOutputContainer->GetEntries(); i++) {
215   //  TObject *obj = fOu
216   // }
217 }
218
219 //______________________________________________________________________________