1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // Cluster drawing object for AZ cluster finder
21 #include <Riostream.h>
30 #include "AliMUONClusterDrawAZ.h"
31 #include "AliMUONClusterFinderAZ.h"
32 #include "AliMUONGeometryModuleTransformer.h"
33 #include "AliHeader.h"
36 //#include "AliMUONChamber.h"
37 #include "AliMUONDigit.h"
38 #include "AliMUONHit.h"
39 #include "AliMUONRawCluster.h"
40 #include "AliMUONClusterInput.h"
41 #include "AliMUONPixel.h"
43 #include "AliMUONLoader.h"
46 ClassImp(AliMUONClusterDrawAZ)
48 //_____________________________________________________________________________
49 AliMUONClusterDrawAZ::AliMUONClusterDrawAZ()
52 // Default constructor
53 fFind = NULL; fData = NULL;
54 for (Int_t i=0; i<4; i++) fHist[i] = NULL;
57 //_____________________________________________________________________________
58 AliMUONClusterDrawAZ::AliMUONClusterDrawAZ(AliMUONClusterFinderAZ *clusFinder)
63 for (Int_t i=0; i<4; i++) fHist[i] = NULL;
65 fEvent = fChamber = fidDE = 0;
70 //_____________________________________________________________________________
71 AliMUONClusterDrawAZ::~AliMUONClusterDrawAZ()
76 //_____________________________________________________________________________
77 AliMUONClusterDrawAZ::AliMUONClusterDrawAZ(const AliMUONClusterDrawAZ& rhs)
80 // Protected copy constructor
82 AliFatal("Not implemented.");
86 //_____________________________________________________________________________
88 AliMUONClusterDrawAZ::operator=(const AliMUONClusterDrawAZ& rhs)
90 // Protected assignement operator
92 if (this == &rhs) return *this;
94 AliFatal("Not implemented.");
98 //_____________________________________________________________________________
99 void AliMUONClusterDrawAZ::Init()
103 TCanvas *c1 = new TCanvas("c1","Clusters",0,0,600,700);
104 //c1->SetFillColor(10);
106 new TCanvas("c2","Mlem",700,0,600,350);
108 // Get pointer to Alice detectors
109 //AliMUON *muon = (AliMUON*) gAlice->GetModule("MUON");
112 AliRunLoader *rl = AliRunLoader::GetRunLoader();
113 AliLoader *gime = rl->GetLoader("MUONLoader");
114 fData = ((AliMUONLoader*)gime)->GetMUONData();
116 gime->LoadHits("READ");
117 gime->LoadRecPoints("READ");
120 //_____________________________________________________________________________
121 Bool_t AliMUONClusterDrawAZ::FindEvCh(Int_t nev, Int_t ch)
123 // Find requested event and chamber (skip the ones before the selected)
125 if (nev < fEvent) return kFALSE;
126 else if (nev == fEvent) {
127 if (ch < fChamber) return kFALSE;
128 if (AliMUONClusterInput::Instance()->DetElemId() < fidDE) return kFALSE;
132 fidDE = AliMUONClusterInput::Instance()->DetElemId();
136 //_____________________________________________________________________________
137 void AliMUONClusterDrawAZ::DrawCluster()
141 TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
143 cout << " nev " << fEvent << endl;
146 for (Int_t cath = 0; cath < 2; cath++) {
148 //if (fHist[cath*2]) {fHist[cath*2]->Delete(); fHist[cath*2] = 0;}
149 //if (fHist[cath*2+1]) {fHist[cath*2+1]->Delete(); fHist[cath*2+1] = 0;}
150 if (fHist[cath*2]) fHist[cath*2] = 0;
151 if (fHist[cath*2+1]) fHist[cath*2+1] = 0;
152 if (fFind->GetNPads(cath) == 0) continue; // cluster on one cathode only
153 Float_t wxMin = 999, wxMax = 0, wyMin = 999, wyMax = 0;
154 Int_t minDx = 0, maxDx = 0, minDy = 0, maxDy = 0;
155 for (Int_t i = 0; i < fFind->GetNPads(0)+fFind->GetNPads(1); i++) {
156 if (fFind->GetIJ(0,i) != cath) continue;
157 if (fFind->GetXyq(3,i) < wxMin) { wxMin = fFind->GetXyq(3,i); minDx = i; }
158 if (fFind->GetXyq(3,i) > wxMax) { wxMax = fFind->GetXyq(3,i); maxDx = i; }
159 if (fFind->GetXyq(4,i) < wyMin) { wyMin = fFind->GetXyq(4,i); minDy = i; }
160 if (fFind->GetXyq(4,i) > wyMax) { wyMax = fFind->GetXyq(4,i); maxDy = i; }
162 cout << minDx << " " << maxDx << " " << minDy << " " << maxDy << endl;
163 Int_t nx, ny, padSize;
164 Float_t xmin = 9999, xmax = -9999, ymin = 9999, ymax = -9999;
165 if (TMath::Nint(fFind->GetXyq(3,minDx)*1000) == TMath::Nint(fFind->GetXyq(3,maxDx)*1000) &&
166 TMath::Nint(fFind->GetXyq(4,minDy)*1000) == TMath::Nint(fFind->GetXyq(4,maxDy)*1000)) {
167 // the same segmentation
168 cout << " Same" << endl;
169 cout << fFind->GetXyq(3,minDx) << " " << fFind->GetXyq(3,maxDx) << " "
170 << fFind->GetXyq(4,minDy) << " " << fFind->GetXyq(4,maxDy) << endl;
171 for (Int_t i = 0; i < fFind->GetNPads(0)+fFind->GetNPads(1); i++) {
172 if (fFind->GetIJ(0,i) != cath) continue;
173 if (fFind->GetXyq(0,i) < xmin) xmin = fFind->GetXyq(0,i);
174 if (fFind->GetXyq(0,i) > xmax) xmax = fFind->GetXyq(0,i);
175 if (fFind->GetXyq(1,i) < ymin) ymin = fFind->GetXyq(1,i);
176 if (fFind->GetXyq(1,i) > ymax) ymax = fFind->GetXyq(1,i);
178 xmin -= fFind->GetXyq(3,minDx); xmax += fFind->GetXyq(3,minDx);
179 ymin -= fFind->GetXyq(4,minDy); ymax += fFind->GetXyq(4,minDy);
180 nx = TMath::Nint ((xmax-xmin)/wxMin/2);
181 ny = TMath::Nint ((ymax-ymin)/wyMin/2);
182 cout << xmin << " " << xmax << " " << nx << " " << ymin << " " << ymax << " " << ny << endl;
183 sprintf(hName,"h%d",cath*2);
184 fHist[cath*2] = new TH2D(hName,"cluster",nx,xmin,xmax,ny,ymin,ymax);
185 for (Int_t i = 0; i < fFind->GetNPads(0)+fFind->GetNPads(1); i++) {
186 if (fFind->GetIJ(0,i) != cath) continue;
187 fHist[cath*2]->Fill(fFind->GetXyq(0,i),fFind->GetXyq(1,i),fFind->GetXyq(2,i));
188 //cout << fXyq[0][i] << fXyq[1][i] << fXyq[2][i] << endl;
191 // different segmentation in the cluster
192 cout << " Different" << endl;
193 cout << fFind->GetXyq(3,minDx) << " " << fFind->GetXyq(3,maxDx) << " "
194 << fFind->GetXyq(4,minDy) << " " << fFind->GetXyq(4,maxDy) << endl;
196 Int_t indx, locMin, locMax;
197 if (TMath::Nint(fFind->GetXyq(3,minDx)*1000) != TMath::Nint(fFind->GetXyq(3,maxDx)*1000)) {
198 // different segmentation along x
203 // different segmentation along y
209 for (Int_t i = 0; i < 2; i++) {
210 // loop over different pad sizes
211 if (i > 0) loc = locMax;
212 padSize = TMath::Nint(fFind->GetXyq(indx+3,loc)*1000);
213 xmin = 9999; xmax = -9999; ymin = 9999; ymax = -9999;
214 for (Int_t j = 0; j < fFind->GetNPads(0)+fFind->GetNPads(1); j++) {
215 if (fFind->GetIJ(0,j) != cath) continue;
216 if (TMath::Nint(fFind->GetXyq(indx+3,j)*1000) != padSize) continue;
218 xmin = TMath::Min (xmin,fFind->GetXyq(0,j));
219 xmax = TMath::Max (xmax,fFind->GetXyq(0,j));
220 ymin = TMath::Min (ymin,fFind->GetXyq(1,j));
221 ymax = TMath::Max (ymax,fFind->GetXyq(1,j));
223 xmin -= fFind->GetXyq(3,loc); xmax += fFind->GetXyq(3,loc);
224 ymin -= fFind->GetXyq(4,loc); ymax += fFind->GetXyq(4,loc);
225 nx = TMath::Nint ((xmax-xmin)/fFind->GetXyq(3,loc)/2);
226 ny = TMath::Nint ((ymax-ymin)/fFind->GetXyq(4,loc)/2);
227 sprintf(hName,"h%d",cath*2+i);
228 fHist[cath*2+i] = new TH2D(hName,"cluster",nx,xmin,xmax,ny,ymin,ymax);
229 for (Int_t j = 0; j < fFind->GetNPads(0)+fFind->GetNPads(1); j++) {
230 if (fFind->GetIJ(0,j) != cath) continue;
231 if (TMath::Nint(fFind->GetXyq(indx+3,j)*1000) != padSize) continue;
232 fHist[cath*2+i]->Fill(fFind->GetXyq(0,j),fFind->GetXyq(1,j),fFind->GetXyq(2,j));
235 if (nOK != fFind->GetNPads(cath)) cout << " *** Too many segmentations: nPads, nOK "
236 << fFind->GetNPads(cath) << " " << nOK << endl;
237 } // if (TMath::Nint(fFind->GetXyq(3,minDx)*1000)
238 } // for (Int_t cath = 0;
240 // Draw histograms and coordinates
243 // This part works only after a modification of THistPainter::PaintLego(Option_t *)
245 Double_t xmin = 9999, ymin = 9999, xmax = -9999, ymax = -9999, aMax = -1;
246 for (Int_t i = 0; i < 4; i++) {
247 if (!fHist[i]) continue;
248 xmin = TMath::Min (xmin, fHist[i]->GetXaxis()->GetXmin());
249 xmax = TMath::Max (xmax, fHist[i]->GetXaxis()->GetXmax());
250 ymin = TMath::Min (ymin, fHist[i]->GetYaxis()->GetXmin());
251 ymax = TMath::Max (ymax, fHist[i]->GetYaxis()->GetXmax());
252 aMax = TMath:: Max (aMax, fHist[i]->GetMaximum());
254 if (c1->FindObject("hFake")) delete c1->FindObject("hFake");
255 hFake = new TH2D ("hFake", "", 1, xmin, xmax, 1, ymin, ymax);
256 hFake->SetMaximum(aMax);
257 hFake->SetNdivisions(505,"Z");
258 hFake->SetStats(kFALSE);
261 TObject *stats = 0x0;
262 for (Int_t cath = 0; cath < 2; cath++) {
263 if (cath == 0) ModifyHistos();
264 if (fFind->GetNPads(cath) == 0) continue; // cluster on one cathode only
270 fHist[cath*2]->Draw();
272 stats = fHist[cath*2]->GetListOfFunctions()->FindObject("stats");
274 hFake->Draw("legoFb");
277 Double_t x, y, x0, y0, r1 = 999, r2 = 0;
278 if (fHist[cath*2+1]) {
280 x0 = fHist[cath*2]->GetXaxis()->GetXmin() - 1000*TMath::Cos(30*TMath::Pi()/180);
281 y0 = fHist[cath*2]->GetYaxis()->GetXmin() - 1000*TMath::Sin(30*TMath::Pi()/180);
284 for (Int_t iy = 1; iy <= fHist[ihist]->GetNbinsY(); iy++) {
285 y = fHist[ihist]->GetYaxis()->GetBinCenter(iy)
286 + fHist[ihist]->GetYaxis()->GetBinWidth(iy);
287 for (Int_t ix = 1; ix <= fHist[ihist]->GetNbinsX(); ix++) {
288 if (fHist[ihist]->GetCellContent(ix,iy) > 0.1) {
289 x = fHist[ihist]->GetXaxis()->GetBinCenter(ix)
290 + fHist[ihist]->GetXaxis()->GetBinWidth(ix);
291 r1 = TMath::Max (r1,TMath::Sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0)));
296 for (Int_t iy = 1; iy <= fHist[ihist]->GetNbinsY(); iy++) {
297 y = fHist[ihist]->GetYaxis()->GetBinCenter(iy)
298 + fHist[ihist]->GetYaxis()->GetBinWidth(iy);
299 for (Int_t ix = 1; ix <= fHist[ihist]->GetNbinsX(); ix++) {
300 if (fHist[ihist]->GetCellContent(ix,iy) > 0.1) {
301 x = fHist[ihist]->GetXaxis()->GetBinCenter(ix)
302 + fHist[ihist]->GetXaxis()->GetBinWidth(ix);
303 r2 = TMath::Max (r2,TMath::Sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0)));
307 cout << r1 << " " << r2 << endl;
308 } // if (fHist[cath*2+1])
310 if (fModif) fHist[cath*2]->Draw("lego1FbSame");
311 else fHist[cath*2]->Draw("lego1Fb");
312 if (fHist[cath*2+1]) fHist[cath*2+1]->Draw("lego1SameAxisBbFb");
314 if (fModif) fHist[cath*2+1]->Draw("lego1FbSame");
315 else fHist[cath*2+1]->Draw("lego1Fb");
316 fHist[cath*2]->Draw("lego1SameAxisFbBb");
319 if (fModif) stats->Draw();
320 } // for (Int_t cath = 0;
322 // Draw simulated and reconstructed hits
326 //_____________________________________________________________________________
327 void AliMUONClusterDrawAZ::DrawHits()
329 // Draw simulated and reconstructed hits
331 TView *view[2] = { 0x0, 0x0 };
332 Double_t p1[3]={0}, p2[3], xNDC[6], xl, yl, zl;
333 TLine *line[99] = {0};
334 TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
337 view[0] = c1->Pad()->GetView();
339 view[1] = c1->Pad()->GetView();
341 fData->SetTreeAddress("H RC");
343 TH2D *hist = fHist[0] ? fHist[0] : fHist[2];
344 p2[2] = hist->GetMaximum();
346 // Draw simulated hits
347 cout << " *** Simulated hits *** " << endl;
349 if (fData->TreeH()) ntracks = (Int_t) fData->GetNtracks();
351 Int_t ix, iy, iok, nLine = 0;
352 TClonesArray *hits = NULL;
353 for (Int_t i = 0; i < ntracks; i++) {
355 hits = fData->Hits();
356 Int_t nhits = (Int_t) hits->GetEntriesFast();
358 for (Int_t ihit = 0; ihit < nhits; ihit++) {
359 mHit = (AliMUONHit*) hits->UncheckedAt(ihit);
360 if (mHit->Chamber() != fChamber+1) continue; // chamber number
361 AliMUONClusterInput::Instance()->Segmentation2(0)->GetTransformer()->
362 Global2Local(fidDE, mHit->X(), mHit->Y(), mHit->Z(), xl, yl, zl);
363 if (TMath::Abs(zl-fFind->GetZpad()) > 1) continue; // different slat
364 p2[0] = p1[0] = xl; // x-pos of hit
365 p2[1] = p1[1] = yl; // y-pos
366 if (p1[0] < hist->GetXaxis()->GetXmin() ||
367 p1[0] > hist->GetXaxis()->GetXmax()) continue;
368 if (p1[1] < hist->GetYaxis()->GetXmin() ||
369 p1[1] > hist->GetYaxis()->GetXmax()) continue;
370 // Check if track comes thru pads with signal
372 for (Int_t ihist = 0; ihist < 4; ihist++) {
373 if (!fHist[ihist]) continue;
374 ix = fHist[ihist]->GetXaxis()->FindBin(p1[0]);
375 iy = fHist[ihist]->GetYaxis()->FindBin(p1[1]);
376 if (fHist[ihist]->GetCellContent(ix,iy) > 0.5) {iok = 1; break;}
379 gStyle->SetLineColor(1);
380 if (TMath::Abs((Int_t)mHit->Particle()) == 13) {
381 gStyle->SetLineColor(4);
383 fxyMu[fnMu][0] = p1[0];
384 fxyMu[fnMu++][1] = p1[1];
387 printf(" Local coord.: X=%10.4f, Y=%10.4f\n",p1[0],p1[1]);
388 printf(" Global coord.: X=%10.4f, Y=%10.4f, Z=%10.4f\n",mHit->X(),mHit->Y(),mHit->Z());
389 if (view[0] || view[1]) {
390 // Take into account track angles
391 p2[0] += mHit->Tlength() * TMath::Sin(mHit->Theta()/180*TMath::Pi())
392 * TMath::Cos(mHit->Phi()/180*TMath::Pi()) / 2;
393 p2[1] += mHit->Tlength() * TMath::Sin(mHit->Theta()/180*TMath::Pi())
394 * TMath::Sin(mHit->Phi()/180*TMath::Pi()) / 2;
395 for (Int_t ipad = 1; ipad < 3; ipad++) {
397 if (!view[ipad-1]) continue;
398 view[ipad-1]->WCtoNDC(p1, &xNDC[0]);
399 view[ipad-1]->WCtoNDC(p2, &xNDC[3]);
400 //c1->DrawLine(xpad[0],xpad[1],xpad[3],xpad[4]);
401 line[nLine] = new TLine(xNDC[0],xNDC[1],xNDC[3],xNDC[4]);
402 line[nLine++]->Draw();
405 } // for (Int_t ihit = 0; ihit < nhits;
406 } // for (Int_t i = 0; i < ntracks;
408 // Draw reconstructed coordinates
409 if (fData->TreeR()) fData->GetRawClusters();
410 TClonesArray *rawclust = fData->RawClusters(fChamber);
411 AliMUONRawCluster *mRaw;
412 gStyle->SetLineColor(3);
413 cout << " *** Reconstructed hits *** " << endl;
415 for (Int_t i = 0; i < rawclust ->GetEntriesFast(); i++) {
416 mRaw = (AliMUONRawCluster*)rawclust ->UncheckedAt(i);
417 AliMUONClusterInput::Instance()->Segmentation2(0)->GetTransformer()->
418 Global2Local(fidDE, mRaw->GetX(0), mRaw->GetY(0), mRaw->GetZ(0), xl, yl, zl);
419 if (TMath::Abs(zl-fFind->GetZpad()) > 1) continue; // different slat
420 p2[0] = p1[0] = xl; // x-pos of hit
421 p2[1] = p1[1] = yl; // y-pos
422 if (p1[0] < hist->GetXaxis()->GetXmin() ||
423 p1[0] > hist->GetXaxis()->GetXmax()) continue;
424 if (p1[1] < hist->GetYaxis()->GetXmin() ||
425 p1[1] > hist->GetYaxis()->GetXmax()) continue;
427 treeD->GetEvent(cath);
428 cout << mRaw->fMultiplicity[0] << mRaw->fMultiplicity[1] << endl;
429 for (Int_t j=0; j<mRaw->fMultiplicity[cath]; j++) {
430 Int_t digit = mRaw->fIndexMap[j][cath];
431 cout << ((AliMUONDigit*)fMuonDigits->UncheckedAt(digit))->Signal() << endl;
434 // Check if track comes thru pads with signal
436 for (Int_t ihist = 0; ihist < 4; ihist++) {
437 if (!fHist[ihist]) continue;
438 ix = fHist[ihist]->GetXaxis()->FindBin(p1[0]);
439 iy = fHist[ihist]->GetYaxis()->FindBin(p1[1]);
440 if (fHist[ihist]->GetCellContent(ix,iy) > 0.5) {iok = 1; break;}
443 printf(" Local coord.: X=%10.4f, Y=%10.4f\n",p1[0],p1[1]);
444 printf(" Global coord.: X=%10.4f, Y=%10.4f, Z=%10.4f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
445 if (view[0] || view[1]) {
446 for (Int_t ipad = 1; ipad < 3; ipad++) {
448 if (!view[ipad-1]) continue;
449 view[ipad-1]->WCtoNDC(p1, &xNDC[0]);
450 view[ipad-1]->WCtoNDC(p2, &xNDC[3]);
451 line[nLine] = new TLine(xNDC[0],xNDC[1],xNDC[3],xNDC[4]);
452 line[nLine++]->Draw();
455 } // for (Int_t i = 0; i < rawclust ->GetEntries();
460 //_____________________________________________________________________________
461 Int_t AliMUONClusterDrawAZ::Next()
466 //lun = fopen("pull.dat","w");
468 for (Int_t i = 0; i < fnMu; i++) {
469 // Check again if muon comes thru the used pads (due to extra splitting)
470 for (Int_t j = 0; j < fFind->GetNPads(0)+fFind->GetNPads(1); j++) {
471 if (TMath::Abs(fxyMu[i][0]-fFind->GetXyq(0,j))<fFind->GetXyq(3,j) &&
472 TMath::Abs(fxyMu[i][1]-fFind->GetXyq(1,j))<fFind->GetXyq(4,j)) {
473 if (fDebug) printf("%12.3e %12.3e %12.3e %12.3e\n",fxyMu[i][2],fxyMu[i][3],fxyMu[i][4],fxyMu[i][5]);
474 if (lun) fprintf(lun,"%4d %2d %12.3e %12.3e %12.3e %12.3e\n",fEvent,fChamber,fxyMu[i][2],fxyMu[i][3],fxyMu[i][4],fxyMu[i][5]);
478 } // for (Int_t i=0; i<fnMu;
482 cout << " What is next? " << endl;
485 if (command[0] == 'n' || command[0] == 'N') { fEvent++; fChamber = fidDE = 0; } // next event
486 else if (command[0] == 'q' || command[0] == 'Q') { if (lun) fclose(lun); } // exit display
487 else if (command[0] == 'c' || command[0] == 'C') sscanf(command+1,"%d",&fChamber); // new chamber
488 else if (command[0] == 'e' || command[0] == 'E') { sscanf(command+1,"%d",&fEvent); fChamber = fidDE = 0; } // new event
489 else if (command[0] == 'd' || command[0] == 'D') { sscanf(command+1,"%d",&fidDE); fChamber = fidDE / 100 - 1; } // new DetElem.
490 else return 1; // Next precluster
495 //_____________________________________________________________________________
496 void AliMUONClusterDrawAZ::ModifyHistos(void)
498 // Modify histograms to bring them to (approximately) the same size
500 Float_t hlim[4][4], hbin[4][4]; // first index - xmin, xmax, ymin, ymax
502 Float_t binMin[4] = {999,999,999,999};
504 for (Int_t i = 0; i < 4; i++) {
506 hlim[0][i] = hlim[2][i] = 999;
507 hlim[1][i] = hlim[3][i] = -999;
510 hlim[0][i] = fHist[i]->GetXaxis()->GetXmin(); // xmin
511 hlim[1][i] = fHist[i]->GetXaxis()->GetXmax(); // xmax
512 hlim[2][i] = fHist[i]->GetYaxis()->GetXmin(); // ymin
513 hlim[3][i] = fHist[i]->GetYaxis()->GetXmax(); // ymax
514 hbin[0][i] = hbin[1][i] = fHist[i]->GetXaxis()->GetBinWidth(1);
515 hbin[2][i] = hbin[3][i] = fHist[i]->GetYaxis()->GetBinWidth(1);
516 binMin[0] = TMath::Min(binMin[0],hbin[0][i]);
517 binMin[2] = TMath::Min(binMin[2],hbin[2][i]);
520 binMin[1] = binMin[0];
521 binMin[3] = binMin[2];
522 cout << " Nhist: " << nhist << endl;
524 // Adjust histo limits for cathode with different segmentation
525 for (Int_t i = 0; i < 4; i+=2) {
526 if (!fHist[i+1]) continue;
527 Int_t imin, imax, i1 = i + 1;
528 for (Int_t lim = 0; lim < 4; lim++) {
530 if (hlim[lim][i] < hlim[lim][i1]) {
537 if (TMath::Abs(hlim[lim][imin]-hlim[lim][imax])<0.01*binMin[lim]) break;
538 if (lim == 0 || lim == 2) {
540 hlim[lim][imax] -= hbin[lim][imax];
543 hlim[lim][imin] += hbin[lim][imin];
550 Int_t imnmx = 0, nExtra = 0;
551 for (Int_t lim = 0; lim < 4; lim++) {
552 if (lim == 0 || lim == 2) imnmx = TMath::LocMin(4,hlim[lim]); // find lower limit
553 else imnmx = TMath::LocMax(4,hlim[lim]); // find upper limit
555 // Adjust histogram limit
556 for (Int_t i = 0; i < 4; i++) {
557 if (!fHist[i]) continue;
558 nExtra = TMath::Nint ((hlim[lim][imnmx]-hlim[lim][i]) / hbin[lim][i]);
559 hlim[lim][i] += nExtra * hbin[lim][i];
563 // Rebuild histograms
566 Double_t x, y, cont, cmax=0;
568 for (Int_t ihist = 0; ihist < 4; ihist++) {
569 if (!fHist[ihist]) continue;
570 nx = TMath::Nint((hlim[1][ihist]-hlim[0][ihist])/hbin[0][ihist]);
571 ny = TMath::Nint((hlim[3][ihist]-hlim[2][ihist])/hbin[2][ihist]);
572 cout << ihist << " " << hlim[0][ihist] << " " << hlim[1][ihist] << " " << nx;
573 cout << " " << hlim[2][ihist] << " " << hlim[3][ihist] << " " << ny << endl;
574 sprintf(hName,"hh%d",ihist);
575 hist = new TH2D(hName,"hist",nx,hlim[0][ihist],hlim[1][ihist],ny,hlim[2][ihist],hlim[3][ihist]);
576 for (Int_t i=1; i<=fHist[ihist]->GetNbinsX(); i++) {
577 x = fHist[ihist]->GetXaxis()->GetBinCenter(i);
578 for (Int_t j=1; j<=fHist[ihist]->GetNbinsY(); j++) {
579 y = fHist[ihist]->GetYaxis()->GetBinCenter(j);
580 cont = fHist[ihist]->GetCellContent(i,j);
581 hist->Fill(x,y,cont);
584 cmax = TMath::Max (cmax,hist->GetMaximum());
585 sprintf(hName,"%s%d",fHist[ihist]->GetName(),ihist);
586 fHist[ihist]->Delete();
587 fHist[ihist] = new TH2D(*hist);
588 fHist[ihist]->SetName(hName);
589 fHist[ihist]->SetNdivisions(505,"Z");
592 if (fDebug) printf("%f \n",cmax);
594 for (Int_t ihist = 0; ihist < 4; ihist++) {
595 if (!fHist[ihist]) continue;
596 fHist[ihist]->SetMaximum(cmax);
597 fHist[ihist]->SetMinimum(0);
601 //_____________________________________________________________________________
602 void AliMUONClusterDrawAZ::AdjustHist(Double_t *xylim, const AliMUONPixel *pixPtr)
604 // Adjust histogram limits for pixel drawing
608 xypads[0] = fHist[0]->GetXaxis()->GetXmin();
609 xypads[1] = -fHist[0]->GetXaxis()->GetXmax();
610 xypads[2] = fHist[0]->GetYaxis()->GetXmin();
611 xypads[3] = -fHist[0]->GetYaxis()->GetXmax();
612 for (Int_t i = 0; i < 4; i++) {
614 if (xylim[i] < xypads[i]) break;
615 xylim[i] -= 2*pixPtr->Size(i/2);
621 //_____________________________________________________________________________
622 void AliMUONClusterDrawAZ::DrawHist(const char* canvas, TH2D *hist)
624 // Draw histogram in given canvas
627 //((TCanvas*)gROOT->FindObject("c2"))->cd();
628 ((TCanvas*)gROOT->FindObject(canvas))->cd();
631 hist->Draw("lego1Fb");
634 if (fnMu) gets((char*)&ix);
637 //_____________________________________________________________________________
638 void AliMUONClusterDrawAZ::FillMuon(Int_t nfit, const Double_t *parOk, const Double_t *errOk)
640 // Fill muon information
644 for (Int_t i = 0; i < fnMu; i++) {
646 for (Int_t j = 0; j < nfit; j++) {
647 indx = j<2 ? j*2 : j*2+1;
648 rad = (fxyMu[i][0]-parOk[indx])*(fxyMu[i][0]-parOk[indx]) +
649 (fxyMu[i][1]-parOk[indx+1])*(fxyMu[i][1]-parOk[indx+1]);
654 fxyMu[i][2] = parOk[imax] - fxyMu[i][0];
655 fxyMu[i][4] = parOk[imax+1] - fxyMu[i][1];
656 fxyMu[i][3] = errOk[imax];
657 fxyMu[i][5] = errOk[imax+1];
663 //_____________________________________________________________________________
664 void AliMUONClusterDrawAZ::UpdateCluster(Int_t npad)
666 // Update cluster after removing non-overlapped pads
668 Int_t cath = 0, ix = 0, iy = 0;
669 cout << " Update cluster " << endl;
671 for (Int_t i = 0; i < npad; i++) {
672 if (TMath::Nint (fFind->GetXyq(2,i)) != -2) continue;
673 cath = fFind->GetIJ(0,i);
674 for (Int_t j = 0; j < 2; j++) {
675 Int_t ihist = cath * 2 + j;
676 if (!fHist[ihist]) continue;
677 ix = fHist[ihist]->GetXaxis()->FindBin(fFind->GetXyq(0,i));
678 iy = fHist[ihist]->GetYaxis()->FindBin(fFind->GetXyq(1,i));
679 Double_t cont = fHist[ihist]->GetCellContent(ix, iy);
680 if (cont < 0.1) continue;
681 fHist[ihist]->Fill(fFind->GetXyq(0,i), fFind->GetXyq(1,i), -cont);
684 TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");