From ea90ffcdd421faf229ef44a8e69308da6a4e651a Mon Sep 17 00:00:00 2001 From: abercuci Date: Thu, 10 May 2012 08:13:41 +0000 Subject: [PATCH] fix 3D -> 2D projection algorithm fix/modify plotting in resolution --- PWGPP/TRD/AliTRDrecoTask.cxx | 25 ++++++++++++++++++------- PWGPP/TRD/AliTRDresolution.cxx | 32 ++++++++++++++++---------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/PWGPP/TRD/AliTRDrecoTask.cxx b/PWGPP/TRD/AliTRDrecoTask.cxx index 74a3dde02ca..37d260de980 100644 --- a/PWGPP/TRD/AliTRDrecoTask.cxx +++ b/PWGPP/TRD/AliTRDrecoTask.cxx @@ -545,10 +545,10 @@ void AliTRDrecoTask::SetNormZ(TH2 *h2, Int_t bxmin, Int_t bxmax, Int_t bymin, In s += c; is++; } } - s/= is?is:1; + s/= (is?is:1); for(Int_t ix(1); ix<=h2->GetXaxis()->GetNbins(); ix++){ for(Int_t iy(1); iy<=h2->GetYaxis()->GetNbins(); iy++){ - if((c = h2->GetBinContent(ix, iy))SetBinContent(ix, iy, thr-100); + if((c = h2->GetBinContent(ix, iy))SetBinContent(ix, iy, thr-1000); else h2->SetBinContent(ix, iy, 100.*(c/s-1.)); } } @@ -688,10 +688,16 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const // build the 2D projection and adjust binning const Char_t *title[] = {"Mean", "#mu", "MPV"}; - if(!fH) return NULL; + if(!fH){ + AliDebug(1, Form("Missing 3D in %s", GetName())); + return NULL; + } TAxis *ax(fH->GetXaxis()), *ay(fH->GetYaxis()), *az(fH->GetZaxis()); TH2D *h2s(NULL), *hyx(NULL); - if(!(h2s = (TH2D*)fH->Project3D("yx"))) return NULL; + if(!(h2s = (TH2D*)fH->Project3D("yx"))){ + AliDebug(1, Form("Failed Project3D(\"yx\") in %s", GetName())); + return NULL; + } // save a copy of the original distribution if(!del){ hyx = (TH2D*)h2s->Clone(); @@ -722,14 +728,16 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const AliDebug(2, Form("%s[%s] nx[%d] ny[%d]", h2->GetName(), h2->GetTitle(), nx, ny)); for(Int_t iy(0); iyProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, ix*dxBin+1, iy*dyBin+1, iy*dyBin+1); + h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin); Int_t ne((Int_t)h->Integral()); + //printf(" x[%2d %2d] y[%2d %2d] ne[%4d]\n", ix*dxBin+1, (ix+1)*dxBin, iy*dyBin+1, (iy+1)*dyBin, ne); if(neSetBinContent(ix+1, iy+1, -999); h2->SetBinError(ix+1, iy+1, 1.); n++; }else{ - h = fH->ProjectionZ(Form("%s_z", h2->GetName()), (ix-1)*dxBin+1, (ix+1)*dxBin+1, (iy-1)*dyBin+1, (iy+1)*dyBin+1); + // redo the projection by adding 1 bin @ left and 1 bin @ right for smoothing + h = fH->ProjectionZ(Form("%s_z", h2->GetName()), ix*dxBin, (ix+1)*dxBin+1, iy*dyBin, (iy+1)*dyBin+1); Float_t v(h->GetMean()), ve(h->GetRMS()); if(mid==1){ TF1 fg("fg", "gaus", az->GetXmin(), az->GetXmax()); @@ -756,7 +764,10 @@ TH2* AliTRDrecoTask::AliTRDrecoProjection::Projection2D(const Int_t nstat, const } } if(h) delete h; - if(n==nx*ny){delete h2; h2=NULL;} // clean empty projections + if(n==nx*ny){ // clean empty projections + AliDebug(1, Form("Empty projection in %s", GetName())); + delete h2; h2=NULL; + } return h2; } diff --git a/PWGPP/TRD/AliTRDresolution.cxx b/PWGPP/TRD/AliTRDresolution.cxx index 2affa6a85bc..1065a9ff64d 100644 --- a/PWGPP/TRD/AliTRDresolution.cxx +++ b/PWGPP/TRD/AliTRDresolution.cxx @@ -1088,11 +1088,11 @@ void AliTRDresolution::MakeSummary() for(Int_t ily(0); ilycd(icen*AliTRDgeometry::kNlayer+ily+1); p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712); if(!(h2 = (TH2*)arr->FindObject(Form("HDet%d%dEn", ily, icen)))) continue; - SetNormZ(h2, 1, 11, 1, -1, 10.); - SetRangeZ(h2, 0., 150, -25.); + SetNormZ(h2, 1, -1, 1, -1, 10.); + SetRangeZ(h2, -90., 90, -200.); h2->GetZaxis()->SetTitle("Rel. Det. Occup. [%]"); h2->GetZaxis()->CenterTitle(); - h2->Draw("colz"); + h2->SetContour(9); h2->Draw("colz"); MakeDetectorPlot(ily, "pad"); } } @@ -1102,8 +1102,8 @@ void AliTRDresolution::MakeSummary() for(Int_t ily(0); ilycd(ily+1); p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712); if(!(h2 = (TH2*)arr->FindObject(Form("HDet%d_2D", ily)))) continue; - SetNormZ(h2, 1, 11, 1, -1, 10.); - SetRangeZ(h2, 0., 45., -15.); + SetNormZ(h2, 1, -1, 1, -1, 10.); + SetRangeZ(h2, -30., 30., -80.); h2->GetZaxis()->SetTitle("Rel. Mean(q) [%]"); h2->GetZaxis()->CenterTitle(); h2->Draw("colz"); @@ -1666,19 +1666,19 @@ Bool_t AliTRDresolution::MakeProjectionTracklet(Bool_t mc) if(ndim > Int_t(kNdim)) ac = H->GetAxis(kNdim); // init centrality selection // calculate size depending on debug level const Int_t nCen(debug?Int_t(AliTRDeventInfo::kCentralityClasses):1); - const Int_t nPt(debug?Int_t(kNpt):1); + const Int_t nPt(debug?Int_t(kNpt+2):1); const Int_t nSpc(1);//ndim>kNdimTrklt?fgkNbins[kSpeciesChgRC]:1); const Int_t nCh(debug?Int_t(kNcharge):1); // build list of projections - const Int_t nsel(AliTRDeventInfo::kCentralityClasses*AliTRDgeometry::kNlayer*kNpt*(AliPID::kSPECIES*kNcharge + 1)); + const Int_t nsel(AliTRDeventInfo::kCentralityClasses*AliTRDgeometry::kNlayer*(kNpt+2)*(AliPID::kSPECIES*kNcharge + 1)); // define rebinning strategy const Int_t nEtaPhi(4); Int_t rebinEtaPhiX[nEtaPhi] = {1, 2, 5, 1}, rebinEtaPhiY[nEtaPhi] = {2, 1, 1, 5}; AliTRDrecoProjection hp[kTrkltNproj]; TObjArray php(kTrkltNproj); Int_t ih(0), isel(-1), np[nsel]; memset(np, 0, nsel*sizeof(Int_t)); const Char_t chName[kNcharge] = {'n', 'p'};const Char_t chSgn[kNcharge] = {'-', '+'}; - const Char_t ptName[kNpt] = {'l', 'i', 'h'}; - const Char_t *ptCut[kNpt] = {"p_{t}[GeV/c]<0.8", "0.8<=p_{t}[GeV/c]<1.5", "p_{t}[GeV/c]>=1.5"}; + const Char_t ptName[kNpt+2] = {'L', 'l', 'i', 'h', 'H'}; + const Char_t *ptCut[kNpt+2] = {"p_{t}[GeV/c]<0.5", "0.5<=p_{t}[GeV/c]<0.8", "0.8<=p_{t}[GeV/c]<1.5", "1.5<=p_{t}[GeV/c]<5.0", "p_{t}[GeV/c]>=5.0"}; // const Char_t *cenName[AliTRDeventInfo::kCentralityClasses] = {"0-10%", "10-20%", "20-50%", "50-80%", "80-100%"}; const Char_t *cenName[AliTRDeventInfo::kCentralityClasses] = {"2800-inf", "2100-2799", "1400-2099", "700-1399", "0-699"}; for(Int_t icen(0); icenH()->SetNameTitle(Form("H%sTrkInY%c", mc?"MC":"", ptName[2]), Form("TrackIn :: #Deltay{%s}", ptCut[2])); + pr0->H()->SetNameTitle(Form("H%sTrkInY%c", mc?"MC":"", ptName[3]), Form("TrackIn :: #Deltay{%s}", ptCut[3])); pr0->SetShowRange(-0.3, 0.3); if((h2 = pr0->Projection2D(kNstat, kNcontours, 1))) arr->AddAt(h2, jh++); } @@ -2281,10 +2281,10 @@ Bool_t AliTRDresolution::MakeProjectionTrackIn(Bool_t mc) if(ich==1 && (pr1 = (AliTRDrecoProjection*)php.FindObject(Form("H%sTrkInX%c%c%d", mc?"MC":"", chName[0], ptName[0], 0)))) (*pr1)+=(*pr0); } /*!dx low pt*/ - if(ich && (pr0 = (AliTRDrecoProjection*)php.FindObject(Form("H%sTrkInX%c%c%d", mc?"MC":"", chName[0], ptName[0], 5)))){ - if((pr1 = (AliTRDrecoProjection*)php.FindObject(Form("H%sTrkInX%c%c%d", mc?"MC":"", chName[ich], ptName[0], 5)))){ + if(ich && (pr0 = (AliTRDrecoProjection*)php.FindObject(Form("H%sTrkInX%c%c%d", mc?"MC":"", chName[0], ptName[1], 5)))){ + if((pr1 = (AliTRDrecoProjection*)php.FindObject(Form("H%sTrkInX%c%c%d", mc?"MC":"", chName[ich], ptName[1], 5)))){ (*pr0)+=(*pr1); - pr0->H()->SetNameTitle(Form("H%sTrkInX%c", mc?"MC":"", ptName[0]), Form("TrackIn :: #Deltax{%s}", ptCut[0])); + pr0->H()->SetNameTitle(Form("H%sTrkInX%c", mc?"MC":"", ptName[1]), Form("TrackIn :: #Deltax{%s}", ptCut[1])); if((h2 = pr0->Projection2D(kNstat, kNcontours, 1))) arr->AddAt(h2, jh++); } } -- 2.43.0