]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/AliTRDrecoTask.cxx
remove warnings during reloading the TRD track list in the prompt
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDrecoTask.cxx
CommitLineData
de520d8f 1#include "TClass.h"
2#include "TMethod.h"
3#include "TMethodCall.h"
4#include "TMethodArg.h"
d85cd79c 5#include "TFile.h"
de520d8f 6#include "TList.h"
fc0946a7 7#include "TH1.h"
8#include "TF1.h"
3d86166d 9#include "TObjArray.h"
10#include "TDirectory.h"
11#include "TTreeStream.h"
12
13#include "AliLog.h"
14#include "AliAnalysisTask.h"
15
16#include "AliTRDrecoTask.h"
17
18ClassImp(AliTRDrecoTask)
19
20//_______________________________________________________
21AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title)
22 : AliAnalysisTask(name, title)
23 ,fNRefFigures(0)
24 ,fDebugLevel(0)
de520d8f 25 ,fPlotFuncList(0x0)
3d86166d 26 ,fContainer(0x0)
27 ,fTracks(0x0)
de520d8f 28 ,fTrack(0x0)
29 ,fMC(0x0)
30 ,fESD(0x0)
3d86166d 31 ,fDebugStream(0x0)
32{
33 DefineInput(0, TObjArray::Class());
34 DefineOutput(0, TObjArray::Class());
35}
36
37//_______________________________________________________
38AliTRDrecoTask::~AliTRDrecoTask()
39{
40 if(fDebugStream){
41 delete fDebugStream;
42 fDebugStream = 0x0;
43 }
44
de520d8f 45 if(fPlotFuncList){
46 fPlotFuncList->Delete();
47 delete fPlotFuncList;
48 fPlotFuncList = 0x0;
49 }
50
3d86166d 51 if(fContainer){
52 //fContainer->Delete();
53 delete fContainer;
54 fContainer = 0x0;
55 }
56}
57
58//_______________________________________________________
59void AliTRDrecoTask::ConnectInputData(Option_t *)
60{
61 //
62 // Connect input data
63 //
64
65 fTracks = dynamic_cast<TObjArray *>(GetInputData(0));
66}
67
de520d8f 68//_______________________________________________________
69void AliTRDrecoTask::Exec(Option_t *)
70{
71 if(!fPlotFuncList){
72 AliWarning("No functor list defined for the reference plots");
73 return;
74 }
75 if(!fTracks) return;
76 if(!fTracks->GetEntriesFast()) return;
77
78 AliTRDtrackInfo *trackInfo = 0x0;
79 TIter plotIter(fPlotFuncList);
80 TObjArrayIter trackIter(fTracks);
81 while((trackInfo = dynamic_cast<AliTRDtrackInfo*>(trackIter()))){
82 fTrack = trackInfo->GetTrack();
83 fMC = trackInfo->GetMCinfo();
84 fESD = trackInfo->GetESDinfo();
85
86 TMethodCall *plot = 0x0;
87 plotIter.Reset();
88 while((plot=dynamic_cast<TMethodCall*>(plotIter()))){
89 plot->Execute(this);
90 }
91 }
92 PostData(0, fContainer);
93}
3d86166d 94
95//_______________________________________________________
a391a274 96void AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/)
3d86166d 97{
98 AliWarning("Retrieving reference figures not implemented.");
3d86166d 99}
100
de520d8f 101//_______________________________________________________
102void AliTRDrecoTask::InitFunctorList()
103{
104 TClass *c = this->IsA();
105
106 TMethod *m = 0x0;
107 TIter methIter(c->GetListOfMethods());
108 while((m=dynamic_cast<TMethod*>(methIter()))){
109 TString name(m->GetName());
110 if(!name.BeginsWith("Plot")) continue;
111 if(!fPlotFuncList) fPlotFuncList = new TList();
cf194b94 112 fPlotFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));
de520d8f 113 }
114}
115
3d86166d 116//_______________________________________________________
28efdace 117Bool_t AliTRDrecoTask::Load(const Char_t *filename)
3d86166d 118{
75d00a6d 119 if(!TFile::Open(filename)){
120 AliWarning(Form("Couldn't open file %s.", filename));
121 return kFALSE;
122 }
123 TObjArray *o = 0x0;
124 if(!(o = (TObjArray*)gFile->Get(GetName()))){
125 AliWarning("Missing histogram container.");
126 return kFALSE;
127 }
d85cd79c 128 fContainer = (TObjArray*)o->Clone(GetName());
129 gFile->Close();
75d00a6d 130 return kTRUE;
3d86166d 131}
132
133//_______________________________________________________
134Bool_t AliTRDrecoTask::PostProcess()
135{
136 AliWarning("Post processing of reference histograms not implemented.");
137 return kFALSE;
138}
139
140//_______________________________________________________
141void AliTRDrecoTask::SetDebugLevel(Int_t level)
142{
143 fDebugLevel = level;
b718144c 144 if(fDebugLevel>=1){
3d86166d 145 TDirectory *savedir = gDirectory;
146 fDebugStream = new TTreeSRedirector(Form("TRD.Debug%s.root", GetName()));
147 savedir->cd();
148 }
149}
fc0946a7 150
151//________________________________________________________
152void AliTRDrecoTask::Adjust(TF1 *f, TH1 *h)
153{
154// Helper function to avoid duplication of code
155// Make first guesses on the fit parameters
156
157 // find the intial parameters of the fit !! (thanks George)
158 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
159 Double_t sum = 0.;
160 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
161 f->SetParLimits(0, 0., 3.*sum);
162 f->SetParameter(0, .9*sum);
163
164 f->SetParLimits(1, -.2, .2);
165 f->SetParameter(1, -0.1);
166
167 f->SetParLimits(2, 0., 4.e-1);
168 f->SetParameter(2, 2.e-2);
169 if(f->GetNpar() <= 4) return;
170
171 f->SetParLimits(3, 0., sum);
172 f->SetParameter(3, .1*sum);
173
174 f->SetParLimits(4, -.3, .3);
175 f->SetParameter(4, 0.);
176
177 f->SetParLimits(5, 0., 1.e2);
178 f->SetParameter(5, 2.e-1);
179}