]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaAnalysis/AliTRDqaEnergyDeposit.cxx
Fix coding rule violations
[u/mrichter/AliRoot.git] / TRD / qaAnalysis / AliTRDqaEnergyDeposit.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 /* $Id: AliTRDqaEnergyDeposit.cxx $ */
18
19 //
20 // This class is a part of a package of high level QA monitoring for TRD.
21 // In this class the dEdX is analyzed as a function of the particle type,
22 // momentum and chamber.
23 //
24 // S. Radomski
25 // radomski@physi.uni-heidelberg.de
26 // March 2008
27 //
28
29 #include "AliTRDqaEnergyDeposit.h"
30
31 #include "TMath.h"
32 #include "TH1D.h"
33 #include "TH2D.h"
34 #include "TFile.h"
35 #include "TChain.h"
36
37 #include "AliESDEvent.h"
38 #include "AliESDtrack.h"
39
40 //______________________________________________________________________________
41
42 AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit() 
43   : AliAnalysisTask("",""),  
44     fChain(0),
45     fESD(0),
46     fOutputContainer(0)
47 {
48   //
49   // Default constructor
50   //
51
52 }
53
54 //______________________________________________________________________________
55
56 AliTRDqaEnergyDeposit:: AliTRDqaEnergyDeposit(const AliTRDqaEnergyDeposit & /*trd*/)
57   : AliAnalysisTask("",""),  
58     fChain(0),
59     fESD(0),
60     fOutputContainer(0)
61 {
62   //
63   // Copy constructor
64   //
65
66 }
67
68 //______________________________________________________________________________
69 AliTRDqaEnergyDeposit::AliTRDqaEnergyDeposit(const char *name) 
70   : AliAnalysisTask(name,""),  
71     fChain(0),
72     fESD(0),
73     fOutputContainer(0)
74 {
75   //
76   // Constructor.
77   //
78
79   // Input slot #0 works with an Ntuple
80   DefineInput(0, TChain::Class());
81   // Output slot #0 writes into a TH1 container
82   DefineOutput(0,  TObjArray::Class()) ; 
83
84 }
85
86 //______________________________________________________________________________
87 void AliTRDqaEnergyDeposit::ConnectInputData(const Option_t *)
88 {
89   // Initialisation of branch container and histograms 
90
91   //AliInfo(Form("*** Initialization of %s", GetName())) ; 
92
93   fChain = (TChain*)GetInputData(0);
94   fESD = new AliESDEvent();
95   fESD->ReadFromTree(fChain);
96 }
97
98 //________________________________________________________________________
99 void AliTRDqaEnergyDeposit::CreateOutputObjects()
100 {
101   // build histograms
102   
103   // prepare the scale from 0.5 to 10 GeV
104   const Int_t knbinsx = 50;
105   Double_t scalex[knbinsx+1];
106   Double_t dd = (TMath::Log(10) - TMath::Log(0.5)) / knbinsx;
107   for(Int_t ix=0; ix<knbinsx+1; ix++) {
108     scalex[ix] = 0.5 * TMath::Exp(dd * ix);
109   }
110
111   const Int_t knbinsy = 50;
112   Double_t scaley[knbinsy+1];
113   for(Int_t iy=0; iy<knbinsy+1; iy++) {
114     scaley[iy] = iy * (3e3/100.);
115   }
116   
117   const char *title = ";p_{T};dEdX (a. u.)";
118   const char *charge[2] = {"Pos", "Neg"};
119
120   // build histograms
121   fOutputContainer = new TObjArray(50);
122   Int_t c=0;
123
124   for(Int_t i=0; i<2; i++) {
125
126     fSignalPtSum[i] = new TH2D(Form("ptSig%s", charge[i]), title, knbinsx, scalex, knbinsy, scaley);
127     fOutputContainer->AddAt(fSignalPtSum[i], c++);
128
129     for(Int_t j=0; j<AliPID::kSPECIES; j++) {
130       Int_t idx = AliPID::kSPECIES*i+j;
131
132       //
133       fSignalPtType[idx] = 
134         new TH2D(Form("ptSig%s%d", charge[i], j), title, knbinsx, scalex, knbinsy, scaley);
135       fOutputContainer->AddAt(fSignalPtType[idx], c++);
136
137       //
138       fSignalPtPure[idx] = 
139         new TH2D(Form("ptSigPure%s%d", charge[i], j), title, knbinsx, scalex, knbinsy, scaley);
140       fOutputContainer->AddAt(fSignalPtPure[idx], c++);
141       
142       fProb[idx] = new TH1D(Form("prob%s%d", charge[i], j), ";LQ", 100, 0, 1);
143       fOutputContainer->AddAt(fProb[idx], c++);
144     }  
145   }
146
147   printf("n hist = %d\n", c);
148 }
149
150 //______________________________________________________________________________
151 void AliTRDqaEnergyDeposit::Exec(Option_t *) 
152 {
153   //
154   // Process one event
155   //
156
157   //  Long64_t entry = fChain->GetReadEntry() ;
158   
159   // Processing of one event 
160    
161   if (!fESD) {
162     //AliError("fESD is not connected to the input!") ; 
163     return ; 
164   }
165   
166   Int_t nTracks = fESD->GetNumberOfTracks();
167   //fNTracks->Fill(nTracks); 
168
169   // track loop
170   for(Int_t i=0; i<nTracks; i++) {
171     
172     //
173     // track selection 
174     //
175     // param in and Out
176     // TRDrefit and TRDPid bit
177     //
178  
179     AliESDtrack *track = fESD->GetTrack(i);
180     const AliExternalTrackParam *paramOut = track->GetOuterParam();
181     const AliExternalTrackParam *paramIn = track->GetInnerParam();
182
183     // long track ..
184     if (!paramIn) continue;
185     if (!paramOut) continue;
186     
187     UInt_t status = track->GetStatus();
188     if (!(status & AliESDtrack::kTRDrefit)) continue;
189     if (!(status & AliESDtrack::kTRDpid)) continue;
190     if (track->GetTRDntrackletsPID() < 6) continue;
191
192     // standard selection
193     
194     Int_t idx = (track->GetSign() > 0) ? 0 : 1;
195     Double_t pt = paramOut->Pt();
196
197     Double_t signal = 0;
198     for(Int_t k=0; k<6; ++k)
199       signal += track->GetTRDslice(k, -1);
200     signal /= 6;
201
202     fSignalPtSum[idx]->Fill(pt, signal);
203     
204     for(Int_t k=0; k<AliPID::kSPECIES; ++k) {
205       
206       Double_t lq = track->GetTRDpid(k);
207       fProb[AliPID::kSPECIES*idx+k]->Fill(lq);
208       if (lq > 0.8) fSignalPtType[AliPID::kSPECIES*idx+k]->Fill(pt, signal);
209     }
210   }
211
212   PostData(0, fOutputContainer);
213 }
214
215 //______________________________________________________________________________
216 void AliTRDqaEnergyDeposit::FillElectrons() const 
217 {
218   //
219   // Fill the electrons
220   //  
221
222 }
223
224 //______________________________________________________________________________
225 void AliTRDqaEnergyDeposit::Terminate(Option_t *)
226 {
227   //
228   // Retrieve histograms
229   //
230
231   fOutputContainer = (TObjArray*)GetOutputData(0);
232   
233   // post processing
234
235
236   // save the results
237   TFile *file = new TFile("outEnergyDeposit.root", "RECREATE");
238   fOutputContainer->Write();
239  
240   file->Flush();
241   file->Close();
242   delete file;
243
244   //for(Int_t i=0; i<fOutputContainer->GetEntries(); i++) {
245   //  TObject *obj = fOu
246   // }
247 }
248
249 //______________________________________________________________________________