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/AliTRDchmbInfo.h"
\r
41 #include "info/AliTRDeventInfo.h"
\r
42 #include "info/AliTRDtrendingManager.h"
\r
43 #include "AliTRDrecoTask.h"
\r
44 #include "AliTRDtrackV1.h"
\r
45 #include "AliTRDpidUtil.h"
\r
47 ClassImp(AliTRDrecoTask)
\r
49 Float_t AliTRDrecoTask::fgPt[AliTRDrecoTask::fgNPt] = {0.};
\r
50 TTreeSRedirector* AliTRDrecoTask::fgDebugStream(NULL);
\r
51 //_______________________________________________________
\r
52 AliTRDrecoTask::AliTRDrecoTask()
\r
53 : AliAnalysisTaskSE()
\r
72 ,fPlotFuncList(NULL)
\r
74 ,fRunTerminate(kFALSE)
\r
76 // Default constructor
\r
77 snprintf(fNameId, 10, "no name");
\r
80 //_______________________________________________________
\r
81 AliTRDrecoTask::AliTRDrecoTask(const char *name, const char *title)
\r
82 : AliAnalysisTaskSE(name)
\r
100 ,fTriggerList(NULL)
\r
101 ,fPlotFuncList(NULL)
\r
102 ,fDetFuncList(NULL)
\r
103 ,fRunTerminate(kFALSE)
\r
105 // Constructor for all derived performance tasks
\r
108 snprintf(fNameId, 10, "no name");
\r
109 DefineInput (1, TObjArray::Class()); // track list
\r
110 DefineInput (2, AliTRDeventInfo::Class()); // event info object
\r
111 DefineInput (3, TObjArray::Class()); // cluster list object
\r
112 DefineOutput(1, TObjArray::Class()); // histogram list
\r
115 //_______________________________________________________
\r
116 AliTRDrecoTask::~AliTRDrecoTask()
\r
119 // Generic task destructor
\r
121 AliDebug(2, Form(" Ending task %s[%s]", GetName(), GetTitle()));
\r
122 if(fgDebugStream){
\r
123 delete fgDebugStream;
\r
124 fgDebugStream = NULL;
\r
128 fPlotFuncList->Delete();
\r
129 delete fPlotFuncList;
\r
130 fPlotFuncList = NULL;
\r
133 fDetFuncList->Delete();
\r
134 delete fDetFuncList;
\r
135 fDetFuncList = NULL;
\r
139 if(fDets->IsOwner()) fDets->Delete();
\r
143 if(fDetsV) delete fDetsV; fDetsV=NULL;
\r
144 if(fTriggerList){fTriggerList->Delete(); delete fTriggerList;}
\r
146 if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){
\r
147 if(fContainer->IsOwner()) fContainer->Delete();
\r
152 /* if(fgTrendPoint){
\r
153 TFile::Open("TRD.PerformanceTrend.root", "UPDATE");
\r
154 fgTrendPoint->Write();
\r
155 delete fgTrendPoint;
\r
161 //_______________________________________________________
\r
162 Int_t AliTRDrecoTask::GetNRefFigures() const
\r
164 if(!fNRefFigures) AliWarning("No reference plots available.");
\r
165 return fNRefFigures;
\r
168 //____________________________________________________________________
\r
169 Int_t AliTRDrecoTask::GetPtBin(Float_t pt)
\r
171 // Get significant (very low, low, medium, high, very high) pt bin
\r
175 if(pt<fgPt[ipt]) break;
\r
181 //_______________________________________________________
\r
182 Bool_t AliTRDrecoTask::MakeMomSegmentation()
\r
187 for(Int_t j(1); j<=fgNPt; j++) fgPt[j]=fgPt[j-1]+(TMath::Exp(j*j*2.e-3)-1.);
\r
188 AliDebug(2, "Using debug momentum segmentation");
\r
191 fgPt[0]=0.5; fgPt[1]=0.8; fgPt[2]=1.5; fgPt[3]=5.;
\r
192 AliDebug(2, "Using default momentum segmentation");
\r
195 AliError(Form("Momentum segmentation %d not supported.", fNpt));
\r
202 //_______________________________________________________
\r
203 void AliTRDrecoTask::UserCreateOutputObjects()
\r
205 if(!HasFunctorList()) InitFunctorList();
\r
206 if(DebugLevel()) fNpt = fgNPt;
\r
208 MakeMomSegmentation();
\r
210 fContainer = Histos();
\r
211 PostData(1, fContainer);
\r
214 //_______________________________________________________
\r
215 void AliTRDrecoTask::UserExec(Option_t *)
\r
217 // Loop over Plot functors published by particular tasks
\r
219 fTracks = dynamic_cast<TObjArray *>(GetInputData(1));
\r
220 fEvent = dynamic_cast<AliTRDeventInfo *>(GetInputData(2));
\r
223 for(Int_t itrig(0); itrig<fTriggerList->GetEntries(); itrig++){
\r
224 if(!fEvent->GetFiredTriggerClasses().Contains(((TObjString*)(*fTriggerList)[itrig])->GetName())) continue;
\r
225 //printf("\"%s\" selected\n", ((TObjString*)(*fTriggerList)[itrig])->GetName());
\r
226 SETBIT(fTriggerSlot,itrig);
\r
229 AliDebug(2, Form("Triggers[%s] not used for %s", fEvent->GetFiredTriggerClasses().Data(), GetName()));
\r
233 fClusters = dynamic_cast<TObjArray*>(GetInputData(3));
\r
235 if(!fPlotFuncList){
\r
236 AliWarning("No track functor list defined for the task");
\r
239 if(!fTracks) return;
\r
240 if(!fTracks->GetEntriesFast()) return;
\r
241 else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));
\r
244 AliTRDtrackInfo *trackInfo(NULL);
\r
245 TIter plotIter(fPlotFuncList);
\r
246 TObjArrayIter trackIter(fTracks);
\r
247 while((trackInfo = dynamic_cast<AliTRDtrackInfo*>(trackIter()))){
\r
248 itrk++; fPt=-1; fEta=0.; fPhi=0.; fSpecies=-6;
\r
249 fkMC = trackInfo->GetMCinfo();
\r
250 fkESD = trackInfo->GetESDinfo();
\r
251 if((fkTrack = trackInfo->GetTrack())){
\r
252 // cache properties of the track at TRD entrance
\r
253 // check input track status
\r
254 AliExternalTrackParam *tin(NULL);
\r
255 if(!(tin = fkTrack->GetTrackIn())) AliDebug(2, Form("Missing TRD track[%d] :: entry point.", itrk));
\r
260 if(!tin->GetXYZ(xyz)) AliDebug(2, Form("Failed TRD track[%d] :: global track postion", itrk));
\r
261 else fPhi = TMath::ATan2(xyz[1], xyz[0]);
\r
262 fSpecies= fkTrack->Charge()*(AliTRDpidUtil::Mass2Pid(fkTrack->GetMass())+1);
\r
264 } else AliDebug(2, Form("Missing TRD track[%d].", itrk));
\r
266 TMethodCall *plot(NULL);
\r
268 while((plot=dynamic_cast<TMethodCall*>(plotIter()))) plot->Execute(this);
\r
270 if(!fClusters) return;
\r
272 AliDebug(1, "No detector functor list defined for task");
\r
275 TIter detIter(fDetFuncList);
\r
276 for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
\r
277 if(!(fkClusters = (TObjArray*)fClusters->At(idet))) continue;
\r
278 TMethodCall *det(NULL);
\r
280 while((det=dynamic_cast<TMethodCall*>(detIter()))) det->Execute(this);
\r
284 //_______________________________________________________
\r
285 Bool_t AliTRDrecoTask::GetRefFigure(Int_t /*ifig*/)
\r
287 AliWarning("Retrieving reference figures not implemented.");
\r
291 //_______________________________________________________
\r
292 Bool_t AliTRDrecoTask::PutTrendValue(const Char_t *name, Double_t val, Double_t err)
\r
294 // Generic publisher for trend values
\r
296 AliTRDtrendingManager *tm = AliTRDtrendingManager::Instance();
\r
298 AliError("Wrong usage of the trending functionality. Could not instantiate AliTRDtrendingManager singleton.");
\r
301 tm->AddValue(Form("%s_%s", GetName(), name), val, err);
\r
305 //_______________________________________________________
\r
306 void AliTRDrecoTask::InitFunctorList()
\r
308 // Initialize list of functors
\r
310 TClass *c = this->IsA();
\r
311 if(fPlotFuncList) fPlotFuncList->Clear();
\r
312 if(fDetFuncList) fDetFuncList->Clear();
\r
315 TIter methIter(c->GetListOfMethods());
\r
316 while((m=dynamic_cast<TMethod*>(methIter()))){
\r
317 TString name(m->GetName());
\r
318 if(name.BeginsWith("Plot")){
\r
319 if(!fPlotFuncList) fPlotFuncList = new TList();
\r
320 fPlotFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));
\r
321 } else if(name.BeginsWith("Det")){
\r
322 if(!fDetFuncList) fDetFuncList = new TList();
\r
323 fDetFuncList->AddLast(new TMethodCall(c, (const char*)name, ""));
\r
328 //_______________________________________________________
\r
329 Bool_t AliTRDrecoTask::Load(const Char_t *file, const Char_t *dir)
\r
331 // Generic container loader
\r
333 if(!TFile::Open(file)){
\r
334 AliWarning(Form("Couldn't open file %s.", file));
\r
337 if(!gFile->cd(dir)){
\r
338 AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
\r
341 TObjArray *o = NULL;
\r
342 if(!(o = (TObjArray*)gDirectory->Get(GetName()))){
\r
343 AliWarning("Missing histogram container.");
\r
346 fContainer = (TObjArray*)o->Clone(GetName());
\r
351 //________________________________________________________
\r
352 Bool_t AliTRDrecoTask::LoadDetectorMap(const Char_t *file, const Char_t *dir)
\r
354 // Load detector map.
\r
356 if(!TFile::Open(file)){
\r
357 AliWarning(Form("Couldn't open file %s.", file));
\r
360 if(!gFile->cd(dir)){
\r
361 AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
\r
364 TObjArray *info = NULL;
\r
365 if(!(info = (TObjArray*)gDirectory->Get("TRDinfoGen"))){
\r
366 AliWarning("Missing TRDinfoGen container.");
\r
369 TObjArray *dets = (TObjArray*)info->FindObject("Chambers Status");
\r
371 if(!info->At(4) || strcmp("TObjArray", info->At(4)->IsA()->GetName())) AliError("Looking for old style chamber status map. Failed.");
\r
373 AliWarning("Looking for old style chamber status map.");
\r
374 TObjArray *vdets = (TObjArray*)info->At(4);
\r
375 fDetsV = (TObjArray*)vdets->Clone();
\r
377 } else fDets = (TObjArray*)dets->Clone();
\r
383 //________________________________________________________
\r
384 Bool_t AliTRDrecoTask::Save(TObjArray * const results){
\r
386 // Store the output graphs in a ROOT file
\r
387 // Input TObject array will not be written as Key to the file,
\r
388 // only content itself
\r
391 TDirectory *cwd = gDirectory;
\r
392 if(!TFile::Open(Form("TRD.Result%s.root", GetName()), "RECREATE")) return kFALSE;
\r
394 TIterator *iter = results->MakeIterator();
\r
395 TObject *inObject = NULL, *outObject = NULL;
\r
396 while((inObject = iter->Next())){
\r
397 outObject = inObject->Clone();
\r
398 outObject->Write(NULL, TObject::kSingleKey);
\r
401 gFile->Close(); delete gFile;
\r
406 //_______________________________________________________
\r
407 Bool_t AliTRDrecoTask::PostProcess()
\r
409 // To be implemented by particular tasks
\r
411 AliWarning("Post processing of reference histograms not implemented.");
\r
415 //_______________________________________________________
\r
416 void AliTRDrecoTask::MakeDetectorPlot(Int_t ly, const Option_t *opt)
\r
418 // Draw chamber boundaries in eta/phi plots with misalignments
\r
419 // based on info collected by AliTRDinfoGen
\r
422 AliWarning("NEW Detector map and status not available. Try OLD");
\r
423 MakeDetectorPlotOLD(ly, opt);
\r
426 AliTRDchmbInfo *ci(NULL);
\r
427 for(Int_t idet(0); idet<fDets->GetEntriesFast(); idet++){
\r
428 if(!(ci = (AliTRDchmbInfo*)fDets->At(idet))) continue;
\r
429 if(AliTRDgeometry::GetLayer(ci->GetDetector()) != ly) continue;
\r
433 Float_t dsm = TMath::TwoPi()/AliTRDgeometry::kNsector;
\r
435 if(strcmp(opt, "pad")==0) xmed=38.;
\r
436 TLatex *sm = new TLatex(); sm->SetTextAlign(22);sm->SetTextColor(kBlack); sm->SetTextFont(32);sm->SetTextSize(0.03);
\r
437 for(Int_t is(0); is<AliTRDgeometry::kNsector; is++) sm->DrawLatex(xmed, -TMath::Pi()+(is+0.5)*dsm, Form("%02d", is>=9?(is-9):(is+9)));
\r
440 //_______________________________________________________
\r
441 void AliTRDrecoTask::MakeDetectorPlotOLD(Int_t ly, const Option_t *opt)
\r
443 // Draw chamber boundaries in eta/phi plots with misalignments
\r
444 // based on info collected by AliTRDinfoGen OLD data storage
\r
447 AliError("OLD Detector map and status not available.");
\r
450 if(!fDetsV->GetEntries()){
\r
451 AliError("OLD Detector map and status not filled.");
\r
455 Float_t xmin(0.), xmax(0.);
\r
456 TBox *gdet = new TBox();
\r
457 gdet->SetLineColor(kBlack);gdet->SetFillColor(kBlack);
\r
458 Int_t style[] = {0, 3003};
\r
459 for(Int_t idet(0); idet<540; idet++){
\r
460 if(idet%6 != ly) continue;
\r
461 TVectorF *det((TVectorF*)fDetsV->At(idet));
\r
463 Int_t iopt = Int_t((*det)[4]);
\r
464 if(strcmp(opt, "eta")==0){
\r
465 xmin=(*det)[0]; xmax=(*det)[2];
\r
466 } else if(strcmp(opt, "pad")==0){
\r
467 Int_t stk(AliTRDgeometry::GetStack(idet));
\r
468 xmin=-0.6+16*(4-stk)-(stk<2?4:0); xmax=xmin+(stk==2?12:16)-0.2;
\r
470 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
472 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kBlack);
\r
473 gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);
\r
475 gdet->SetFillStyle(style[0]);
\r
476 gdet->DrawBox(xmin, (*det)[1], xmax, (*det)[3]);
\r
478 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kGreen);
\r
479 gdet->DrawBox(xmin, (*det)[1], xmax, 0.5*((*det)[3]+(*det)[1]));
\r
480 } else if(iopt==3){
\r
481 gdet->SetFillStyle(style[1]);gdet->SetFillColor(kRed);
\r
482 gdet->DrawBox(xmin, 0.5*((*det)[3]+(*det)[1]), xmax, (*det)[3]);
\r
483 } else if(iopt!=0) AliError(Form("Wrong chmb. status[%d] for det[%03d]", iopt, idet));
\r
486 Float_t dsm = TMath::TwoPi()/AliTRDgeometry::kNsector;
\r
488 if(strcmp(opt, "pad")==0) xmin=38.;
\r
489 TLatex *sm = new TLatex(); sm->SetTextAlign(22);sm->SetTextColor(kBlack); sm->SetTextFont(32);sm->SetTextSize(0.03);
\r
490 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
494 //_______________________________________________________
\r
495 void AliTRDrecoTask::MakeSummary()
\r
497 // To be implemented by particular tasks
\r
498 AliWarning("Summary not available");
\r
501 //_______________________________________________________
\r
502 void AliTRDrecoTask::SetDebugLevel(Int_t level)
\r
504 // Generic debug handler
\r
506 AliAnalysisTaskSE::SetDebugLevel(level);
\r
507 if(DebugLevel()>=1){
\r
508 AliInfo(Form("Debug Level for Task %s set to %d", GetName(), level));
\r
509 TDirectory *savedir = gDirectory;
\r
510 fgDebugStream = new TTreeSRedirector("TRD.DebugPerformance.root");
\r
515 //____________________________________________________________________
\r
516 void AliTRDrecoTask::Terminate(Option_t *)
\r
522 if(fgDebugStream){
\r
523 delete fgDebugStream;
\r
524 fgDebugStream = NULL;
\r
526 fContainer = dynamic_cast<TObjArray *>(GetOutputData(1));
\r
527 if(fContainer && fRunTerminate){
\r
533 //________________________________________________________
\r
534 Float_t AliTRDrecoTask::SetNormZ(TH2 *h2, Int_t bxmin, Int_t bxmax, Int_t bymin, Int_t bymax, Float_t thr)
\r
536 // Normalize histo content to the mean value in the range specified by bin ranges
\r
537 // [bxmin, bxmax] on the x axis and [bymin, bymax] on the y axis.
\r
538 // Optionally a threshold "thr" can be specified to disregard entries with no meaning
\r
540 Float_t s = 0., c=0.; Int_t is(0);
\r
541 for(Int_t ix(bxmin); ix<=(bxmax>0?bxmax:(h2->GetXaxis()->GetNbins())); ix++){
\r
542 for(Int_t iy(bymin); iy<=(bymax>0?bymax:(h2->GetYaxis()->GetNbins())); iy++){
\r
543 if((c = h2->GetBinContent(ix, iy))<thr) continue;
\r
548 for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){
\r
549 for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){
\r
550 if((c = h2->GetBinContent(ix, iy))<thr) h2->SetBinContent(ix, iy, thr-1000);
\r
551 else h2->SetBinContent(ix, iy, 100.*(c/s-1.));
\r
557 //________________________________________________________
\r
558 void AliTRDrecoTask::SetRangeZ(TH2 *h2, Float_t min, Float_t max, Float_t thr)
\r
560 // Set range on Z axis such to avoid outliers
\r
562 Float_t c(0.), dz(1.e-3*(max-min));
\r
563 for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){
\r
564 for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){
\r
565 if((c = h2->GetBinContent(ix, iy))<thr) continue;
\r
566 if(c<=min) h2->SetBinContent(ix, iy, min+dz);
\r
569 h2->GetZaxis()->SetRangeUser(min, max);
\r
572 //________________________________________________________
\r
573 Float_t AliTRDrecoTask::GetMeanStat(TH1 *h, Float_t cut, Option_t *opt)
\r
575 // return mean number of entries/bin of histogram "h"
\r
576 // if option "opt" is given the following values are accepted:
\r
577 // "<" : consider only entries less than "cut"
\r
578 // ">" : consider only entries greater than "cut"
\r
580 //Int_t dim(h->GetDimension());
\r
581 Int_t nbx(h->GetNbinsX()), nby(h->GetNbinsY()), nbz(h->GetNbinsZ());
\r
582 Double_t sum(0.); Int_t n(0);
\r
583 for(Int_t ix(1); ix<=nbx; ix++)
\r
584 for(Int_t iy(1); iy<=nby; iy++)
\r
585 for(Int_t iz(1); iz<=nbz; iz++){
\r
586 if(strcmp(opt, "")==0){sum += h->GetBinContent(ix, iy, iz); n++;}
\r
588 if(strcmp(opt, "<")==0) {
\r
589 if(h->GetBinContent(ix, iy, iz)<cut) {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
590 } else if(strcmp(opt, ">")==0){
\r
591 if(h->GetBinContent(ix, iy, iz)>cut) {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
592 } else {sum += h->GetBinContent(ix, iy, iz); n++;}
\r
595 return n>0?sum/n:0.;
\r
598 //________________________________________________________
\r
599 AliTRDrecoTask::AliTRDrecoProjection::AliTRDrecoProjection()
\r
607 memset(fAx, 0, 3*sizeof(Int_t));
\r
608 memset(fRange, 0, 4*sizeof(Float_t));
\r
611 //________________________________________________________
\r
612 AliTRDrecoTask::AliTRDrecoProjection::~AliTRDrecoProjection()
\r
618 //________________________________________________________
\r
619 void AliTRDrecoTask::AliTRDrecoProjection::Build(const Char_t *n, const Char_t *t, Int_t ix, Int_t iy, Int_t iz, TAxis *aa[])
\r
621 // check and build (if neccessary) projection determined by axis "ix", "iy" and "iz"
\r
622 if(!aa[ix] || !aa[iy] || !aa[iz]) return;
\r
623 TAxis *ax(aa[ix]), *ay(aa[iy]), *az(aa[iz]);
\r
624 // check ax definiton to protect against older versions of the data
\r
625 if(ax->GetNbins()<=0 || (ax->GetXmax()-ax->GetXmin())<=0.){
\r
626 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax()));
\r
629 if(ay->GetNbins()<=0 || (ay->GetXmax()-ay->GetXmin())<=0.){
\r
630 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax()));
\r
633 if(az->GetNbins()<=0 || (az->GetXmax()-az->GetXmin())<=0.){
\r
634 AliWarning(Form("Wrong definition of axis[%d] \"%s\"[%d](%f %f).", ix, az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));
\r
638 fH = new TH3I(n, Form("%s;%s;%s;%s", t, ax->GetTitle(), ay->GetTitle(), az->GetTitle()),
\r
639 ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),
\r
640 ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),
\r
641 az->GetNbins(), az->GetXmin(), az->GetXmax());
\r
642 fAx[0] = ix; fAx[1] = iy; fAx[2] = iz;
\r
643 fRange[0] = az->GetXmin()/3.; fRange[1] = az->GetXmax()/3.;
\r
644 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
645 ax->GetTitle(), ax->GetNbins(), ax->GetXmin(), ax->GetXmax(),
\r
646 ay->GetTitle(), ay->GetNbins(), ay->GetXmin(), ay->GetXmax(),
\r
647 az->GetTitle(), az->GetNbins(), az->GetXmin(), az->GetXmax()));
\r
650 //________________________________________________________
\r
651 AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator=(const AliTRDrecoProjection& rhs)
\r
653 // copy projections
\r
654 if(this == &rhs) return *this;
\r
656 TNamed::operator=(rhs);
\r
657 if(fNrebin){fNrebin=0; delete [] fRebinX; delete [] fRebinY;}
\r
658 if(rhs.fNrebin) SetRebinStrategy(rhs.fNrebin, rhs.fRebinX, rhs.fRebinY);
\r
659 memcpy(fAx, rhs.fAx, 3*sizeof(Int_t));
\r
660 memcpy(fRange, rhs.fRange, 4*sizeof(Float_t));
\r
662 if(rhs.fH) fH=(TH3I*)rhs.fH->Clone(Form("%s_CLONE", rhs.fH->GetName()));
\r
666 //________________________________________________________
\r
667 AliTRDrecoTask::AliTRDrecoProjection& AliTRDrecoTask::AliTRDrecoProjection::operator+=(const AliTRDrecoProjection& other)
\r
669 // increment projections
\r
670 if(!fH || !other.fH) return *this;
\r
671 AliDebug(2, Form("%s+=%s [%s+=%s]", GetName(), other.GetName(), fH->GetName(), (other.fH)->GetName()));
\r
676 //________________________________________________________
\r
677 void AliTRDrecoTask::AliTRDrecoProjection::Increment(Int_t bin[], Double_t v)
\r
679 // increment bin with value "v" pointed by general coord in "bin"
\r
681 AliDebug(4, Form(" %s[%2d]", fH->GetName(), Int_t(v)));
\r
682 fH->AddBinContent(fH->GetBin(bin[fAx[0]],bin[fAx[1]],bin[fAx[2]]), Int_t(v));
\r
685 //________________________________________________________
\r
686 Double_t AliTRDrecoTask::AliTRDrecoProjection::GetTrendValue(const Int_t mid, Double_t *m, Double_t *s) const
\r
688 // Return result of fitting the main distribution (represented on the z axis) with the function selected
\r
689 // "mid". Optionally return the Mean and RMS of the distribution pointing to "m" and "s"
\r
692 AliDebug(1, Form("Missing 3D in %s", GetName()));
\r
696 if(!(h1s = (TH1D*)fH->Project3D("z"))){
\r
697 AliDebug(1, Form("Failed Project3D(\"z\") in %s", GetName()));
\r
700 Int_t ne((Int_t)h1s->Integral());
\r
702 AliDebug(1, Form("Statistics too low[%2d] in %s", ne, GetName()));
\r
705 TAxis *az(h1s->GetXaxis());
\r
706 Float_t vm(h1s->GetMean()), v(vm), ve(h1s->GetRMS());
\r
708 TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());
\r
709 fg.SetParameter(0, Float_t(ne)); fg.SetParameter(1, vm); fg.SetParameter(2, ve);
\r
710 h1s->Fit(&fg, "WQ0");
\r
711 v = fg.GetParameter(1);
\r
712 } else if (mid==2) {
\r
713 TF1 fl("fl", "landau", az->GetXmin(), az->GetXmax());
\r
714 fl.SetParameter(0, Float_t(ne)); fl.SetParameter(1, vm); fl.SetParameter(2, ve);
\r
715 h1s->Fit(&fl, "WQ0");
\r
716 v = fl.GetMaximumX();
\r
720 AliDebug(2, Form("%s[%d]:: %f {%f %f} Entries[%d]", fH->GetName(), mid, v, m?(*m):0., s?(*s):0., (Int_t)h1s->Integral()));
\r
725 //________________________________________________________
\r
726 TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const Int_t ncol, const Int_t mid, Bool_t del)
\r
728 // build the 2D projection and adjust binning
\r
730 const Char_t *title[] = {"Mean", "#mu", "MPV"};
\r
732 AliDebug(1, Form("Missing 3D in %s", GetName()));
\r
735 TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis());
\r
736 TH2D *h2s(NULL), *hyx(NULL);
\r
737 if(!(h2s = (TH2D*)fH->Project3D("yx"))){
\r
738 AliDebug(1, Form("Failed Project3D(\"yx\") in %s", GetName()));
\r
741 // save a copy of the original distribution
\r
743 hyx = (TH2D*)h2s->Clone();
\r
744 hyx->SetName(Form("%sEn", fH->GetName()));
\r
746 Int_t irebin(0), dxBin(1), dyBin(1);
\r
747 while(irebin<fNrebin && (AliTRDrecoTask::GetMeanStat(h2s, .5, ">")<nstat)){
\r
748 h2s->Rebin2D(fRebinX[irebin], fRebinY[irebin]);
\r
749 dxBin*=fRebinX[irebin];dyBin*=fRebinY[irebin];
\r
752 Int_t nx(h2s->GetNbinsX()), ny(h2s->GetNbinsY());
\r
754 if(mid<0) return NULL;
\r
756 // start projection
\r
757 TH1 *h(NULL); Int_t n(0);
\r
758 Float_t dz=(fRange[1]-fRange[1])/ncol;
\r
759 TString titlez(az->GetTitle()); TObjArray *tokenTitle(titlez.Tokenize(" "));
\r
760 Int_t nt(tokenTitle->GetEntriesFast());
\r
762 if((h2 = (TH2*)gDirectory->Get(Form("%s_2D", fH->GetName())))) delete h2; // avoid ROOT warning messages
\r
763 h2 = new TH2F(Form("%s_2D", fH->GetName()),
\r
764 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
765 nx, ax->GetXmin(), ax->GetXmax(), ny, ay->GetXmin(), ay->GetXmax());
\r
766 tokenTitle->Delete(); delete tokenTitle;
\r
767 h2->SetContour(ncol);
\r
768 h2->GetZaxis()->CenterTitle();
\r
769 h2->GetZaxis()->SetTitleOffset(1.4);
\r
770 h2->GetZaxis()->SetRangeUser(fRange[0], fRange[1]);
\r
771 AliDebug(2, Form("%s[%s] nx[%d] ny[%d]", h2->GetName(), h2->GetTitle(), nx, ny));
\r
772 for(Int_t iy(0); iy<ny; iy++){
\r
773 for(Int_t ix(0); ix<nx; ix++){
\r
774 h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin);
\r
775 Int_t ne((Int_t)h->Integral());
\r
776 //printf(" x[%2d %2d] y[%2d %2d] ne[%4d]\n", ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin, ne);
\r
778 h2->SetBinContent(ix+1, iy+1, -999);
\r
779 h2->SetBinError(ix+1, iy+1, 1.);
\r
782 // redo the projection by adding 1 bin @ left and 1 bin @ right for smoothing
\r
783 h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin, (ix+1)*dxBin+1, iy*dyBin, (iy+1)*dyBin+1);
\r
784 Float_t v(h->GetMean()), ve(h->GetRMS());
\r
786 TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax());
\r
787 fg.SetParameter(0, Float_t(ne)); fg.SetParameter(1, v); fg.SetParameter(2, ve);
\r
788 h->Fit(&fg, "WQ0");
\r
789 v = fg.GetParameter(1); ve = fg.GetParameter(2);
\r
790 } else if (mid==2) {
\r
791 TF1 fl("fl", "landau", az->GetXmin(), az->GetXmax());
\r
792 fl.SetParameter(0, Float_t(ne)); fl.SetParameter(1, v); fl.SetParameter(2, ve);
\r
793 h->Fit(&fl, "WQ0");
\r
794 v = fl.GetMaximumX(); ve = fl.GetParameter(2);
\r
795 /* TF1 fgle("gle", "[0]*TMath::Landau(x, [1], [2], 1)*TMath::Exp(-[3]*x/[1])", az->GetXmin(), az->GetXmax());
\r
796 fgle.SetParameter(0, fl.GetParameter(0));
\r
797 fgle.SetParameter(1, fl.GetParameter(1));
\r
798 fgle.SetParameter(2, fl.GetParameter(2));
\r
799 fgle.SetParameter(3, 1.);fgle.SetParLimits(3, 0., 5.);
\r
800 h->Fit(&fgle, "WQ");
\r
801 v = fgle.GetMaximumX(); ve = fgle.GetParameter(2);*/
\r
803 if(v<fRange[0]) h2->SetBinContent(ix+1, iy+1, fRange[0]+0.1*dz);
\r
804 else h2->SetBinContent(ix+1, iy+1, v);
\r
805 h2->SetBinError(ix+1, iy+1, ve);
\r
810 if(n==nx*ny){ // clean empty projections
\r
811 AliDebug(1, Form("Empty projection in %s", GetName()));
\r
812 delete h2; h2=NULL;
\r
817 //________________________________________________________
\r
818 void AliTRDrecoTask::AliTRDrecoProjection::SetRebinStrategy(Int_t n, Int_t rebx[], Int_t reby[])
\r
820 // define rebinning strategy for this projection
\r
822 fRebinX = new Int_t[n]; memcpy(fRebinX, rebx, n*sizeof(Int_t));
\r
823 fRebinY = new Int_t[n]; memcpy(fRebinY, reby, n*sizeof(Int_t));
\r
826 //________________________________________________________
\r
827 void AliTRDrecoTask::SetTriggerList(const Char_t *tl)
\r
829 // Store list of triggers to be monitored
\r
831 if(fTriggerList){ fTriggerList->Delete(); delete fTriggerList;}
\r
832 TObjArray *atl = stl.Tokenize(" ");
\r
833 fTriggerList = (TObjArray*)atl->Clone("");
\r
834 atl->Delete(); delete atl;
\r
835 AliInfo("Running only for triggers::");
\r
836 fTriggerList->Print();
\r