X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FqaRec%2FAliTRDrecoTask.cxx;h=dadf364c7767ffdd863ff0831534f18883cf81c9;hb=fc0946a728317641ee5653cff70e38506e34c9f0;hp=7491ec2b747b99b58851c405b0e1dbe9fb81885b;hpb=3d86166d08e5f841540f71fe9ecbe0caa61eea85;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/qaRec/AliTRDrecoTask.cxx b/TRD/qaRec/AliTRDrecoTask.cxx index 7491ec2b747..dadf364c776 100644 --- a/TRD/qaRec/AliTRDrecoTask.cxx +++ b/TRD/qaRec/AliTRDrecoTask.cxx @@ -1,3 +1,11 @@ +#include "TClass.h" +#include "TMethod.h" +#include "TMethodCall.h" +#include "TMethodArg.h" +#include "TFile.h" +#include "TList.h" +#include "TH1.h" +#include "TF1.h" #include "TObjArray.h" #include "TDirectory.h" #include "TTreeStream.h" @@ -14,8 +22,12 @@ AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title) : AliAnalysisTask(name, title) ,fNRefFigures(0) ,fDebugLevel(0) + ,fPlotFuncList(0x0) ,fContainer(0x0) ,fTracks(0x0) + ,fTrack(0x0) + ,fMC(0x0) + ,fESD(0x0) ,fDebugStream(0x0) { DefineInput(0, TObjArray::Class()); @@ -30,6 +42,12 @@ AliTRDrecoTask::~AliTRDrecoTask() fDebugStream = 0x0; } + if(fPlotFuncList){ + fPlotFuncList->Delete(); + delete fPlotFuncList; + fPlotFuncList = 0x0; + } + if(fContainer){ //fContainer->Delete(); delete fContainer; @@ -47,19 +65,69 @@ void AliTRDrecoTask::ConnectInputData(Option_t *) fTracks = dynamic_cast(GetInputData(0)); } +//_______________________________________________________ +void AliTRDrecoTask::Exec(Option_t *) +{ + if(!fPlotFuncList){ + AliWarning("No functor list defined for the reference plots"); + return; + } + if(!fTracks) return; + if(!fTracks->GetEntriesFast()) return; + + AliTRDtrackInfo *trackInfo = 0x0; + TIter plotIter(fPlotFuncList); + TObjArrayIter trackIter(fTracks); + while((trackInfo = dynamic_cast(trackIter()))){ + fTrack = trackInfo->GetTrack(); + fMC = trackInfo->GetMCinfo(); + fESD = trackInfo->GetESDinfo(); + + TMethodCall *plot = 0x0; + plotIter.Reset(); + while((plot=dynamic_cast(plotIter()))){ + plot->Execute(this); + } + } + PostData(0, fContainer); +} //_______________________________________________________ -void AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/, Int_t &first, Int_t &last) +void AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/) { AliWarning("Retrieving reference figures not implemented."); - first = 0; last = 0; } //_______________________________________________________ -Bool_t AliTRDrecoTask::Load(Char_t */*filename*/) +void AliTRDrecoTask::InitFunctorList() { - AliWarning("Loading of reference histograms not implemented."); - return kFALSE; + TClass *c = this->IsA(); + + TMethod *m = 0x0; + TIter methIter(c->GetListOfMethods()); + while((m=dynamic_cast(methIter()))){ + TString name(m->GetName()); + if(!name.BeginsWith("Plot")) continue; + if(!fPlotFuncList) fPlotFuncList = new TList(); + fPlotFuncList->AddLast(new TMethodCall(c, (const char*)name, "")); + } +} + +//_______________________________________________________ +Bool_t AliTRDrecoTask::Load(const Char_t *filename) +{ + if(!TFile::Open(filename)){ + AliWarning(Form("Couldn't open file %s.", filename)); + return kFALSE; + } + TObjArray *o = 0x0; + if(!(o = (TObjArray*)gFile->Get(GetName()))){ + AliWarning("Missing histogram container."); + return kFALSE; + } + fContainer = (TObjArray*)o->Clone(GetName()); + gFile->Close(); + return kTRUE; } //_______________________________________________________ @@ -73,9 +141,39 @@ Bool_t AliTRDrecoTask::PostProcess() void AliTRDrecoTask::SetDebugLevel(Int_t level) { fDebugLevel = level; - if(fDebugLevel>=2){ + if(fDebugLevel>=1){ TDirectory *savedir = gDirectory; fDebugStream = new TTreeSRedirector(Form("TRD.Debug%s.root", GetName())); savedir->cd(); } } + +//________________________________________________________ +void AliTRDrecoTask::Adjust(TF1 *f, TH1 *h) +{ +// Helper function to avoid duplication of code +// Make first guesses on the fit parameters + + // find the intial parameters of the fit !! (thanks George) + Int_t nbinsy = Int_t(.5*h->GetNbinsX()); + Double_t sum = 0.; + for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.; + f->SetParLimits(0, 0., 3.*sum); + f->SetParameter(0, .9*sum); + + f->SetParLimits(1, -.2, .2); + f->SetParameter(1, -0.1); + + f->SetParLimits(2, 0., 4.e-1); + f->SetParameter(2, 2.e-2); + if(f->GetNpar() <= 4) return; + + f->SetParLimits(3, 0., sum); + f->SetParameter(3, .1*sum); + + f->SetParLimits(4, -.3, .3); + f->SetParameter(4, 0.); + + f->SetParLimits(5, 0., 1.e2); + f->SetParameter(5, 2.e-1); +}