New representation of the raw TRD PID signal in ESD (Alex, Yuri)
[u/mrichter/AliRoot.git] / TRD / qaAnalysis / AliTRDqaESDFriends.cxx
CommitLineData
917559ee 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: AliTRDqaESDFriends.cxx $ */
17
18//
19// This class is a part of a package of high level QA monitoring for TRD.
20// The residuals of cluster with respect to tracklets are analyzed
21// in this class. This class needs ESDfriends.root
22//
23// S. Radomski
24// radomski@physi.uni-heidelberg.de
25// March 2008
26//
27
28#include "AliTRDqaESDFriends.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#include "AliESDfriend.h"
41
42//______________________________________________________________________________
43
44AliTRDqaESDFriends::AliTRDqaESDFriends()
45 : AliAnalysisTask("",""),
46 fChain(0),
47 fESD(0),
48 fOutputContainer(0),
49 fResiduals(0),
50 fResidualsAngle(0)
51{
52 // Dummy default constructor
53}
54//______________________________________________________________________________
55
56AliTRDqaESDFriends:: AliTRDqaESDFriends(AliTRDqaESDFriends& /*trd*/)
57 : AliAnalysisTask("",""),
58 fChain(0),
59 fESD(0),
60 fOutputContainer(0),
61 fResiduals(0),
62 fResidualsAngle(0)
63{
64 // dummy copy constructor
65
66 //return *this;
67}
68
69
70//______________________________________________________________________________
71AliTRDqaESDFriends::AliTRDqaESDFriends(const char *name)
72 : AliAnalysisTask(name,""),
73 fChain(0),
74 fESD(0),
75 fOutputContainer(0),
76 fResiduals(0),
77 fResidualsAngle(0)
78{
79 // Constructor.
80 // Input slot #0 works with an Ntuple
81 DefineInput(0, TChain::Class());
82 // Output slot #0 writes into a TH1 container
83 DefineOutput(0, TObjArray::Class()) ;
84}
85
86//______________________________________________________________________________
87void AliTRDqaESDFriends::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//________________________________________________________________________
99void AliTRDqaESDFriends::CreateOutputObjects()
100{
101 // build histograms
102
103 fResiduals = new TH1D("residuals", ";residuals (cm)", 1000, -1, 1);
104 fResidualsAngle = new TH2D("residualsAngle", ";angle (rad);residuals (cm)", 100, -1, 1, 100, -1, 1);
105
106 Int_t c = 0;
107 fOutputContainer = new TObjArray(50);
108
109 fOutputContainer->AddAt(fResiduals, c++);
110 fOutputContainer->AddAt(fResidualsAngle, c++);
111
112 printf("n hist = %d\n", c);
113}
114//______________________________________________________________________________
115void AliTRDqaESDFriends::Exec(Option_t *)
116{
117 // Process one event
118
119 //Long64_t entry = fChain->GetReadEntry() ;
120
121 // Processing of one event
122
123 if (!fESD) {
124 //AliError("fESD is not connected to the input!") ;
125 return ;
126 }
127
128 Int_t nTracks = fESD->GetNumberOfTracks();
129 //fNTracks->Fill(nTracks);
130
131 // track loop
132 for(Int_t i=0; i<nTracks; i++) {
133
134 //
135 // track selection
136 //
137 // param in and Out
138 // TRDrefit and TRDPid bit
139 //
140
141 AliESDtrack *track = fESD->GetTrack(i);
142 const AliExternalTrackParam *paramOut = track->GetOuterParam();
143 const AliExternalTrackParam *paramIn = track->GetInnerParam();
144
145 // long track ..
146 if (!paramIn) continue;
147 if (!paramOut) continue;
148
149 UInt_t status = track->GetStatus();
150 if (!(status & AliESDtrack::kTRDrefit)) continue;
151 if (!(status & AliESDtrack::kTRDpid)) continue;
152 if (track->GetTRDpidQuality() < 6) continue;
153
154 // standard selection
155
156 // fESD->GetList()->Print();
157 //AliESDfriend *f = (AliESDfriend*)fESD->FindListObject("ESDfriend");
158 //if (f) f->Print();
159 // AliKalmanTrack *trdTrack = track->GetTRDtrack();
160 //if (trdTrack) trdTrack->Print();
161 }
162
163 PostData(0, fOutputContainer);
164}
165
166//______________________________________________________________________________
167void AliTRDqaESDFriends::Terminate(Option_t *)
168{
169 // retrieve histograms
170 fOutputContainer = (TObjArray*)GetOutputData(0);
171
172 // post processing
173
174
175 // save the results
176 TFile *file = new TFile("outESDFriends.root", "RECREATE");
177 fOutputContainer->Write();
178
179 file->Flush();
180 file->Close();
181 delete file;
182
183 //for(Int_t i=0; i<fOutputContainer->GetEntries(); i++) {
184 // TObject *obj = fOu
185 // }
186}
187
188//______________________________________________________________________________