1 ///////////////////////////////////////////////////////
\r
3 // Basic class for Performance/Calibration TRD tasks
\r
5 // It performs generic tasks like :
\r
6 // - data file manegment
\r
7 // - reference container management
\r
8 // - debug container management
\r
9 // - interaction with AliAnalysisManager
\r
10 // - Plot functor loop
\r
12 // Author: Alexandru Bercuci <A.Bercuci@gsi.de>, 10/09/2008
\r
14 /////////////////////////////////////////////////////////
\r
17 #include "TMethod.h"
\r
18 #include "TMethodCall.h"
\r
19 #include "TMethodArg.h"
\r
28 #include "TObjArray.h"
\r
29 #include "TDirectory.h"
\r
30 #include "TTreeStream.h"
\r
33 #include "TVectorT.h"
\r
36 #include "AliAnalysisTask.h"
\r
37 #include "AliAnalysisManager.h"
\r
38 #include "AliExternalTrackParam.h"
\r
40 #include "info/AliTRDeventInfo.h"
\r
41 #include "AliTRDrecoTask.h"
\r
42 #include "AliTRDtrackV1.h"
\r
43 #include "AliTRDpidUtil.h"
\r
45 ClassImp(AliTRDrecoTask)
\r
47 TList* AliTRDrecoTask::fgTrendPoint(NULL);
\r
48 TTreeSRedirector* AliTRDrecoTask::fgDebugStream(NULL);
\r
49 //_______________________________________________________
\r
50 AliTRDrecoTask::AliTRDrecoTask()
\r
51 : AliAnalysisTaskSE()
\r
66 ,fPlotFuncList(NULL)
\r
68 ,fRunTerminate(kFALSE)
\r
70 // Default constructor
\r
71 snprintf(fNameId, 10, "no name");
\r
74 //_______________________________________________________
\r
75 AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title)
\r
76 : AliAnalysisTaskSE(name)
\r
91 ,fPlotFuncList(NULL)
\r
93 ,fRunTerminate(kFALSE)
\r
95 // Constructor for all derived performance tasks
\r
98 snprintf(fNameId, 10, "no name");
\r
99 DefineInput (1, TObjArray::Class()); // track list
\r
100 DefineInput (2, AliTRDeventInfo::Class()); // event info object
\r
101 DefineInput (3, TObjArray::Class()); // cluster list object
\r
102 DefineOutput(1, TObjArray::Class()); // histogram list
\r
105 //_______________________________________________________
\r
106 AliTRDrecoTask::~AliTRDrecoTask()
\r
109 // Generic task destructor
\r
111 AliDebug(2, Form(" Ending task %s[%s]", GetName(), GetTitle()));
\r
112 if(fgDebugStream){
\r
113 delete fgDebugStream;
\r
114 fgDebugStream = NULL;
\r
118 fPlotFuncList->Delete();
\r
119 delete fPlotFuncList;
\r
120 fPlotFuncList = NULL;
\r
123 fDetFuncList->Delete();
\r
124 delete fDetFuncList;
\r
125 fDetFuncList = NULL;
\r
129 if(fDets->IsOwner()) fDets->Delete();
\r
134 if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){
\r
135 if(fContainer->IsOwner()) fContainer->Delete();
\r
141 TFile::Open("TRD.PerformanceTrend.root", "UPDATE");
\r
142 fgTrendPoint->Write();
\r
143 delete fgTrendPoint;
\r
149 //_______________________________________________________
\r
150 Int_t AliTRDrecoTask::GetNRefFigures() const
\r
152 if(!fNRefFigures) AliWarning("No reference plots available.");
\r
153 return fNRefFigures;
\r
156 //_______________________________________________________
\r
157 void AliTRDrecoTask::UserCreateOutputObjects()
\r
159 if(!HasFunctorList()) InitFunctorList();
\r
160 fContainer = Histos();
\r
161 PostData(1, fContainer);
\r
164 //_______________________________________________________
\r
165 void AliTRDrecoTask::UserExec(Option_t *)
\r
167 // Loop over Plot functors published by particular tasks
\r
169 fTracks = dynamic_cast<TObjArray *>(GetInputData(1));
\r
170 fEvent = dynamic_cast<AliTRDeventInfo *>(GetInputData(2));
\r
171 fClusters = dynamic_cast<TObjArray*>(GetInputData(3));
\r
173 if(!fPlotFuncList){
\r
174 AliWarning("No track functor list defined for the task");
\r
177 if(!fTracks) return;
\r
178 if(!fTracks->GetEntriesFast()) return;
\r
179 else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));
\r
182 AliTRDtrackInfo *trackInfo(NULL);
\r
183 TIter plotIter(fPlotFuncList);
\r
184 TObjArrayIter trackIter(fTracks);
\r
185 while((trackInfo = dynamic_cast<AliTRDtrackInfo*>(trackIter()))){
\r
186 itrk++; fPt=-1; fEta=0.; fPhi=0.; fSpecies=-6;
\r
187 fkMC = trackInfo->GetMCinfo();
\r
188 fkESD = trackInfo->GetESDinfo();
\r
189 if((fkTrack = trackInfo->GetTrack())){
\r
190 // cache properties of the track at TRD entrance
\r
191 // check input track status
\r
192 AliExternalTrackParam *tin(NULL);
\r
193 if(!(tin = fkTrack->GetTrackIn())) AliDebug(2, Form("Missing TRD track[%d] :: entry point.", itrk));
\r
198 if(!tin->GetXYZ(xyz)) AliDebug(2, Form("Failed TRD track[%d] :: global track postion", itrk));
\r
199 else fPhi = TMath::ATan2(xyz[1], xyz[0]);
\r
200 fSpecies= fkTrack->Charge()*(AliTRDpidUtil::Mass2Pid(fkTrack->GetMass())+1);
\r
202 } else AliDebug(2, Form("Missing TRD track[%d].", itrk));
\r
204 TMethodCall *plot(NULL);
\r
206 while((plot=dynamic_cast<TMethodCall*>(plotIter()))) plot->Execute(this);
\r
208 if(!fClusters) return;
\r
210 AliDebug(1, "No detector functor list defined for task");
\r
213 TIter detIter(fDetFuncList);
\r
214 for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
\r
215 if(!(fkClusters = (TObjArray*)fClusters->At(idet))) continue;
\r
216 TMethodCall *det(NULL);
\r
218 while((det=dynamic_cast<TMethodCall*>(detIter()))) det->Execute(this);
\r
222 //_______________________________________________________
\r
223 Bool_t AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/)
\r
225 AliWarning("Retrieving reference figures not implemented.");
\r
229 //_______________________________________________________
\r
230 Bool_t AliTRDrecoTask::PutTrendValue(const Char_t *name, Double_t val)
\r
232 // Generic publisher for trend values
\r
235 fgTrendPoint = new TList();
\r
236 fgTrendPoint->SetOwner();
\r
238 fgTrendPoint->AddLast(new TNamed(Form("%s_%s", GetName(), name), Form("%f", val)));
\r
242 //_______________________________________________________
\r
243 void AliTRDrecoTask::InitFunctorList()
\r
245 // Initialize list of functors
\r
247 TClass *c = this->IsA();
\r
248 if(fPlotFuncList) fPlotFuncList->Clear();
\r
249 if(fDetFuncList) fDetFuncList->Clear();
\r
252 TIter methIter(c->GetListOfMethods());
\r
253 while((m=dynamic_cast<TMethod*>(methIter()))){
\r
254 TString name(m->GetName());
\r
255 if(name.BeginsWith("Plot")){
\r
256 if(!fPlotFuncList) fPlotFuncList = new TList();
\r
257 fPlotFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));
\r
258 } else if(name.BeginsWith("Det")){
\r
259 if(!fDetFuncList) fDetFuncList = new TList();
\r
260 fDetFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));
\r
265 //_______________________________________________________
\r
266 Bool_t AliTRDrecoTask::Load(const Char_t *file, const Char_t *dir)
\r
268 // Generic container loader
\r
270 if(!TFile::Open(file)){
\r
271 AliWarning(Form("Couldn't open file %s.", file));
\r
274 if(!gFile->cd(dir)){
\r
275 AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
\r
278 TObjArray *o = NULL;
\r
279 if(!(o = (TObjArray*)gDirectory->Get(GetName()))){
\r
280 AliWarning("Missing histogram container.");
\r
283 fContainer = (TObjArray*)o->Clone(GetName());
\r
288 //________________________________________________________
\r
289 Bool_t AliTRDrecoTask::LoadDetectorMap(const Char_t *file, const Char_t *dir)
\r
291 // Load detector map.
\r
293 if(!TFile::Open(file)){
\r
294 AliWarning(Form("Couldn't open file %s.", file));
\r
297 if(!gFile->cd(dir)){
\r
298 AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
\r
301 TObjArray *info = NULL;
\r
302 if(!(info = (TObjArray*)gDirectory->Get("TRDinfoGen"))){
\r
303 AliWarning("Missing TRDinfoGen container.");
\r
306 TObjArray *dets = (TObjArray*)info->FindObject("Chambers");
\r
308 AliWarning("Missing detector map from TRDinfoGen results.");
\r
312 fDets = (TObjArray*)dets->Clone("Chambers");
\r
318 //________________________________________________________
\r
319 Bool_t AliTRDrecoTask::Save(TObjArray * const results){
\r
321 // Store the output graphs in a ROOT file
\r
322 // Input TObject array will not be written as Key to the file,
\r
323 // only content itself
\r
326 TDirectory *cwd = gDirectory;
\r
327 if(!TFile::Open(Form("TRD.Result%s.root", GetName()), "RECREATE")) return kFALSE;
\r
329 TIterator *iter = results->MakeIterator();
\r
330 TObject *inObject = NULL, *outObject = NULL;
\r
331 while((inObject = iter->Next())){
\r
332 outObject = inObject->Clone();
\r
333 outObject->Write(NULL, TObject::kSingleKey);
\r
336 gFile->Close(); delete gFile;
\r
341 //_______________________________________________________
\r
342 Bool_t AliTRDrecoTask::PostProcess()
\r
344 // To be implemented by particular tasks
\r
346 AliWarning("Post processing of reference histograms not implemented.");
\r
350 //_______________________________________________________
\r
351 void AliTRDrecoTask::MakeDetectorPlot(Int_t ly, const Option_t *opt)
\r
353 // Draw chamber boundaries in eta/phi plots with misalignments
\r
354 // based on info collected by AliTRDinfoGen
\r
357 AliWarning("Detector map and status not available.");
\r
360 Float_t xmin(0.), xmax(0.);
\r
361 TBox *gdet = new TBox();
\r
362 gdet->SetLineColor(kBlack);gdet->SetFillColor(kBlack);
\r
363 Int_t style[] = {0, 3003};
\r
364 for(Int_t idet(0); idet<540; idet++){
\r
365 if(idet%6 != ly) continue;
\r
366 TVectorF *det((TVectorF*)fDets->At(idet));
\r
368 Int_t iopt = Int_t((*det)[4]);
\r
369 if(strcmp(opt, "eta")==0){
\r
370 xmin=(*det)[0]; xmax=(*det)[2];
\r
371 } else if(strcmp(opt, "pad")==0){
\r
372 Int_t stk(AliTRDgeometry::GetStack(idet));
\r
373 xmin=-0.6+16*(4-stk)-(stk<2?4:0); xmax=xmin+(stk==2?12:16)-0.2;
\r
375 AliDebug(2, Form("det[%03d] 0[%+4.1f(%+4.1f) %+4.1f] 1[%+4.1f(%+4.1f) %+4.1f] opt[%d]", idet, xmin, (*det)[0], (*det)[1], xmax, (*det)[2], (*det)[3], iopt));
\r
377 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kBlack);
\r
378 gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);
\r
380 gdet->SetFillStyle(style[0]);
\r
381 gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);
\r
383 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kGreen);
\r
384 gdet->DrawBox(xmin, (*det)[1], xmax, 0.5*((*det)[3]+(*det)[1]));
\r
385 } else if(iopt==3){
\r
386 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kRed);
\r
387 gdet->DrawBox(xmin, 0.5*((*det)[3]+(*det)[1]), xmax, (*det)[3]);
\r
388 } else if(iopt!=0) AliError(Form("Wrong chmb. status[%d] for det[%03d]", iopt, idet));
\r
391 Float_t dsm = TMath::TwoPi()/AliTRDgeometry::kNsector;
\r
393 if(strcmp(opt, "pad")==0) xmin=38.;
\r
394 TLatex *sm = new TLatex(); sm->SetTextAlign(22);sm->SetTextColor(0); sm->SetTextFont(32);sm->SetTextSize(0.03);
\r
395 for(Int_t is(0); is<AliTRDgeometry::kNsector; is++) sm->DrawLatex(xmin, -TMath::Pi()+(is+0.5)*dsm, Form("%02d", is>=9?(is-9):(is+9)));
\r
399 //_______________________________________________________
\r
400 void AliTRDrecoTask::MakeSummary()
\r
402 // To be implemented by particular tasks
\r
403 AliWarning("Summary not available");
\r
406 //_______________________________________________________
\r
407 void AliTRDrecoTask::SetDebugLevel(Int_t level)
\r
409 // Generic debug handler
\r
411 AliAnalysisTaskSE::SetDebugLevel(level);
\r
412 if(DebugLevel()>=1){
\r
413 AliInfo(Form("Debug Level for Task %s set to %d", GetName(), level));
\r
414 TDirectory *savedir = gDirectory;
\r
415 fgDebugStream = new TTreeSRedirector("TRD.DebugPerformance.root");
\r
420 //____________________________________________________________________
\r
421 void AliTRDrecoTask::Terminate(Option_t *)
\r
427 if(fgDebugStream){
\r
428 delete fgDebugStream;
\r
429 fgDebugStream = NULL;
\r
431 fContainer = dynamic_cast<TObjArray *>(GetOutputData(1));
\r
432 if(fContainer && fRunTerminate){
\r
438 //________________________________________________________
\r
439 void AliTRDrecoTask::Adjust(TF1 *f, TH1 * const h)
\r
441 // Helper function to avoid duplication of code
\r
442 // Make first guesses on the fit parameters
\r
444 // find the intial parameters of the fit !! (thanks George)
\r
445 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
\r
447 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
\r
448 f->SetParLimits(0, 0., 3.*sum);
\r
449 f->SetParameter(0, .9*sum);
\r
451 f->SetParLimits(1, -.2, .2);
\r
452 f->SetParameter(1, -0.1);
\r
454 f->SetParLimits(2, 0., 4.e-1);
\r
455 f->SetParameter(2, 2.e-2);
\r
456 if(f->GetNpar() <= 4) return;
\r
458 f->SetParLimits(3, 0., sum);
\r
459 f->SetParameter(3, .1*sum);
\r
461 f->SetParLimits(4, -.3, .3);
\r
462 f->SetParameter(4, 0.);
\r
464 f->SetParLimits(5, 0., 1.e2);
\r
465 f->SetParameter(5, 2.e-1);
\r
469 //________________________________________________________
\r
470 void AliTRDrecoTask::SetNormZ(TH2 *h2, Int_t bxmin, Int_t bxmax, Int_t bymin, Int_t bymax, Float_t thr)
\r
472 // Normalize histo content to the mean value in the range specified by bin ranges
\r
473 // [bxmin, bxmax] on the x axis and [bymin, bymax] on the y axis.
\r
474 // Optionally a threshold "thr" can be specified to disregard entries with no meaning
\r
476 Float_t s = 0., c=0.; Int_t is(0);
\r
477 for(Int_t ix(bxmin); ix<=(bxmax>0?bxmax:(h2->GetXaxis()->GetNbins())); ix++){
\r
478 for(Int_t iy(bymin); iy<=(bymax>0?bymax:(h2->GetYaxis()->GetNbins())); iy++){
\r
479 if((c = h2->GetBinContent(ix, iy))<thr) continue;
\r
484 for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){
\r
485 for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){
\r
486 if((c = h2->GetBinContent(ix, iy))<thr) h2->SetBinContent(ix, iy, thr-100);
\r
487 else h2->SetBinContent(ix, iy, 100.*(c/s-1.));
\r
492 //________________________________________________________
\r
493 void AliTRDrecoTask::SetRangeZ(TH2 *h2, Float_t min, Float_t max, Float_t thr)
\r
495 // Set range on Z axis such to avoid outliers
\r
497 Float_t c(0.), dz(1.e-3*(max-min));
\r
498 for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){
\r
499 for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){
\r
500 if((c = h2->GetBinContent(ix, iy))<thr) continue;
\r
501 if(c<=min) h2->SetBinContent(ix, iy, min+dz);
\r
504 h2->GetZaxis()->SetRangeUser(min, max);
\r
507 //________________________________________________________
\r
508 Float_t AliTRDrecoTask::GetMeanStat(TH1 *h, Float_t cut, Option_t *opt)
\r
510 // return mean number of entries/bin of histogram "h"
\r
511 // if option "opt" is given the following values are accepted:
\r
512 // "<" : consider only entries less than "cut"
\r
513 // ">" : consider only entries greater than "cut"
\r
515 //Int_t dim(h->GetDimension());
\r
516 Int_t nbx(h->GetNbinsX()), nby(h->GetNbinsY()), nbz(h->GetNbinsZ());
\r
517 Double_t sum(0.); Int_t n(0);
\r
518 for(Int_t ix(1); ix<=nbx; ix++)
\r
519 for(Int_t iy(1); iy<=nby; iy++)
\r
520 for(Int_t iz(1); iz<=nbz; iz++){
\r
521 if(strcmp(opt, "")==0){sum += h->GetBinContent(ix, iy, iz); n++;}
\r
523 if(strcmp(opt, "<")==0) {
\r
524 if(h->GetBinContent(ix, iy, iz)<cut) {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
525 } else if(strcmp(opt, ">")==0){
\r
526 if(h->GetBinContent(ix, iy, iz)>cut) {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
527 } else {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
530 return n>0?sum/n:0.;
\r
533 //________________________________________________________
\r
534 AliTRDrecoTask::AliTRDrecoProjection::AliTRDrecoProjection()
\r
542 memset(fAx, 0, 3*sizeof(Int_t));
\r
543 memset(fRange, 0, 4*sizeof(Float_t));
\r
546 //________________________________________________________
\r
547 AliTRDrecoTask::AliTRDrecoProjection::~AliTRDrecoProjection()
\r
553 //________________________________________________________
\r
554 void AliTRDrecoTask::AliTRDrecoProjection::Build(const Char_t *n, const Char_t *t, Int_t ix, Int_t iy, Int_t iz, TAxis *aa[])
\r
556 // check and build (if neccessary) projection determined by axis "ix", "iy" and "iz"
\r
557 if(!aa[ix] || !aa[iy] || !aa[iz]) return;
\r
558 TAxis *ax(aa[ix]), *ay(aa[iy]), *az(aa[iz]);
\r
559 // check ax definiton to protect against older versions of the data
\r
560 if(ax->GetNbins()<=0 || (ax->GetXmax()-ax->GetXmin())<=0.){
\r
561 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax()));
\r
564 if(ay->GetNbins()<=0 || (ay->GetXmax()-ay->GetXmin())<=0.){
\r
565 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax()));
\r
568 if(az->GetNbins()<=0 || (az->GetXmax()-az->GetXmin())<=0.){
\r
569 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));
\r
573 fH = new TH3I(n, Form("%s;%s;%s;%s", t, ax->GetTitle(), ay->GetTitle(), az->GetTitle()),
\r
574 ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),
\r
575 ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),
\r
576 az->GetNbins(), az->GetXmin(), az->GetXmax());
\r
577 fAx[0] = ix; fAx[1] = iy; fAx[2] = iz;
\r
578 fRange[0] = az->GetXmin()/3.; fRange[1] = az->GetXmax()/3.;
\r
579 AliDebug(2, Form("H3(%s, %s) :: %s[%3d %4.2f %4.2f]%s[%3d %4.2f %4.2f]%s[%3d %4.2f %4.2f]", n, t,
\r
580 ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),
\r
581 ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),
\r
582 az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));
\r
585 //________________________________________________________
\r
586 AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator=(const AliTRDrecoProjection& rhs)
\r
588 // copy projections
\r
589 if(this == &rhs) return *this;
\r
591 TNamed::operator=(rhs);
\r
592 if(fNrebin){fNrebin=0; delete [] fRebinX; delete [] fRebinY;}
\r
593 if(rhs.fNrebin) SetRebinStrategy(rhs.fNrebin, rhs.fRebinX, rhs.fRebinY);
\r
594 memcpy(fAx, rhs.fAx, 3*sizeof(Int_t));
\r
595 memcpy(fRange, rhs.fRange, 4*sizeof(Float_t));
\r
597 if(rhs.fH) fH=(TH3I*)rhs.fH->Clone(Form("%s_CLONE", rhs.fH->GetName()));
\r
601 //________________________________________________________
\r
602 AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator+=(const AliTRDrecoProjection& other)
\r
604 // increment projections
\r
605 if(!fH || !other.fH) return *this;
\r
606 AliDebug(2, Form("%s+=%s [%s+=%s]", GetName(), other.GetName(), fH->GetName(), (other.fH)->GetName()));
\r
611 //________________________________________________________
\r
612 void AliTRDrecoTask::AliTRDrecoProjection::Increment(Int_t bin[], Double_t v)
\r
614 // increment bin with value "v" pointed by general coord in "bin"
\r
616 AliDebug(4, Form(" %s[%2d]", fH->GetName(), Int_t(v)));
\r
617 fH->AddBinContent(fH->GetBin(bin[fAx[0]],bin[fAx[1]],bin[fAx[2]]), Int_t(v));
\r
620 //________________________________________________________
\r
621 TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const Int_t ncol, const Int_t mid, Bool_t del)
\r
623 // build the 2D projection and adjust binning
\r
625 const Char_t *title[] = {"Mean", "#mu", "MPV"};
\r
626 if(!fH) return NULL;
\r
627 TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis());
\r
628 TH2D *h2s(NULL), *hyx(NULL);
\r
629 if(!(h2s = (TH2D*)fH->Project3D("yx"))) return NULL;
\r
630 // save a copy of the original distribution
\r
632 hyx = (TH2D*)h2s->Clone();
\r
633 hyx->SetName(Form("%sEn", fH->GetName()));
\r
635 Int_t irebin(0), dxBin(1), dyBin(1);
\r
636 while(irebin<fNrebin && (AliTRDrecoTask::GetMeanStat(h2s, .5, ">")<nstat)){
\r
637 h2s->Rebin2D(fRebinX[irebin], fRebinY[irebin]);
\r
638 dxBin*=fRebinX[irebin];dyBin*=fRebinY[irebin];
\r
641 Int_t nx(h2s->GetNbinsX()), ny(h2s->GetNbinsY());
\r
643 if(mid<0) return NULL;
\r
645 // start projection
\r
646 TH1 *h(NULL); Int_t n(0);
\r
647 Float_t dz=(fRange[1]-fRange[1])/ncol;
\r
648 TString titlez(az->GetTitle()); TObjArray *tokenTitle(titlez.Tokenize(" "));
\r
649 Int_t nt(tokenTitle->GetEntriesFast());
\r
650 TH2 *h2 = new TH2F(Form("%s_2D", fH->GetName()),
\r
651 Form("%s;%s;%s;%s(%s) %s", fH->GetTitle(), ax->GetTitle(), ay->GetTitle(), title[mid], nt>0?(*tokenTitle)[0]->GetName():"", nt>1?(*tokenTitle)[1]->GetName():""),
\r
652 nx, ax->GetXmin(), ax->GetXmax(), ny, ay->GetXmin(), ay->GetXmax());
\r
653 h2->SetContour(ncol);
\r
654 h2->GetZaxis()->CenterTitle();
\r
655 h2->GetZaxis()->SetTitleOffset(1.4);
\r
656 h2->GetZaxis()->SetRangeUser(fRange[0], fRange[1]);
\r
657 AliDebug(2, Form("%s[%s] nx[%d] ny[%d]", h2->GetName(), h2->GetTitle(), nx, ny));
\r
658 for(Int_t iy(0); iy<ny; iy++){
\r
659 for(Int_t ix(0); ix<nx; ix++){
\r
660 h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, (ix+1)*dxBin+1, iy*dyBin+1, (iy+1)*dyBin+1);
\r
661 Int_t ne((Int_t)h->Integral());
\r
663 h2->SetBinContent(ix+1, iy+1, -999);
\r
664 h2->SetBinError(ix+1, iy+1, 1.);
\r
667 Float_t v(h->GetMean()), ve(h->GetRMS());
\r
669 TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());
\r
670 fg.SetParameter(0, Float_t(ne)); fg.SetParameter(1, v); fg.SetParameter(2, ve);
\r
672 v = fg.GetParameter(1); ve = fg.GetParameter(2);
\r
673 } else if (mid==2) {
\r
674 TF1 fl("fl", "landau", az->GetXmin(), az->GetXmax());
\r
675 fl.SetParameter(0, Float_t(ne)); fl.SetParameter(1, v); fl.SetParameter(2, ve);
\r
677 v = fl.GetMaximumX(); ve = fl.GetParameter(2);
\r
678 /* TF1 fgle("gle", "[0]*TMath::Landau(x, [1], [2], 1)*TMath::Exp(-[3]*x/[1])", az->GetXmin(), az->GetXmax());
\r
679 fgle.SetParameter(0, fl.GetParameter(0));
\r
680 fgle.SetParameter(1, fl.GetParameter(1));
\r
681 fgle.SetParameter(2, fl.GetParameter(2));
\r
682 fgle.SetParameter(3, 1.);fgle.SetParLimits(3, 0., 5.);
\r
683 h->Fit(&fgle, "WQ");
\r
684 v = fgle.GetMaximumX(); ve = fgle.GetParameter(2);*/
\r
686 if(v<fRange[0]) h2->SetBinContent(ix+1, iy+1, fRange[0]+0.1*dz);
\r
687 else h2->SetBinContent(ix+1, iy+1, v);
\r
688 h2->SetBinError(ix+1, iy+1, ve);
\r
693 if(n==nx*ny){delete h2; h2=NULL;} // clean empty projections
\r
697 //________________________________________________________
\r
698 void AliTRDrecoTask::AliTRDrecoProjection::SetRebinStrategy(Int_t n, Int_t rebx[], Int_t reby[])
\r
700 // define rebinning strategy for this projection
\r
702 fRebinX = new Int_t[n]; memcpy(fRebinX, rebx, n*sizeof(Int_t));
\r
703 fRebinY = new Int_t[n]; memcpy(fRebinY, reby, n*sizeof(Int_t));
\r