* provided "as is" without express or implied warranty. *
**************************************************************************/
-// Cluster drawing object for AZ cluster finder
+/* $Id$ */
+
+// -------------------------------------
+// Class AliMUONClusterDrawAZ
+// -------------------------------------
+// Cluster drawing for AZ cluster finder
+// Author: Alexander Zinchenko, JINR Dubna
#include <stdlib.h>
#include <Riostream.h>
-//#include <TROOT.h>
+#include <TROOT.h>
#include <TCanvas.h>
#include <TLine.h>
//#include <TTree.h>
#include "AliMUONClusterDrawAZ.h"
#include "AliMUONClusterFinderAZ.h"
+#include "AliMUONGeometryModuleTransformer.h"
#include "AliHeader.h"
#include "AliRun.h"
#include "AliMUON.h"
#include "AliMUONDigit.h"
#include "AliMUONHit.h"
#include "AliMUONRawCluster.h"
-//#include "AliMUONClusterInput.h"
+#include "AliMUONClusterInput.h"
#include "AliMUONPixel.h"
//#include "AliMC.h"
#include "AliMUONLoader.h"
//_____________________________________________________________________________
AliMUONClusterDrawAZ::AliMUONClusterDrawAZ()
- : TObject()
+ : TObject(),
+ fData(0x0),
+ fFind(0x0),
+ fnMu(0),
+ fEvent(0),
+ fChamber(0),
+ fidDE(0),
+ fDebug(0),
+ fModif(0)
{
-// Default constructor
- fFind = NULL; fData = NULL;
+/// Default constructor
for (Int_t i=0; i<4; i++) fHist[i] = NULL;
}
//_____________________________________________________________________________
AliMUONClusterDrawAZ::AliMUONClusterDrawAZ(AliMUONClusterFinderAZ *clusFinder)
- : TObject()
+ : TObject(),
+ fData(0x0),
+ fFind(clusFinder),
+ fnMu(0),
+ fEvent(0),
+ fChamber(0),
+ fidDE(0),
+ fDebug(1),
+ fModif(0)
{
-// Constructor
- fFind = clusFinder;
+/// Constructor
for (Int_t i=0; i<4; i++) fHist[i] = NULL;
- fDebug = 1;
- fEvent = fChamber = 0;
Init();
}
//_____________________________________________________________________________
AliMUONClusterDrawAZ::~AliMUONClusterDrawAZ()
{
- // Destructor
-}
-
-//_____________________________________________________________________________
-AliMUONClusterDrawAZ::AliMUONClusterDrawAZ(const AliMUONClusterDrawAZ& rhs)
- : TObject(rhs)
-{
-// Protected copy constructor
-
- AliFatal("Not implemented.");
+/// Destructor
}
-
-//_____________________________________________________________________________
-AliMUONClusterDrawAZ&
-AliMUONClusterDrawAZ::operator=(const AliMUONClusterDrawAZ& rhs)
-{
-// Protected assignement operator
-
- if (this == &rhs) return *this;
-
- AliFatal("Not implemented.");
- return *this;
-}
-
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::Init()
{
- // Initialization
+/// Initialization
TCanvas *c1 = new TCanvas("c1","Clusters",0,0,600,700);
//c1->SetFillColor(10);
//_____________________________________________________________________________
Bool_t AliMUONClusterDrawAZ::FindEvCh(Int_t nev, Int_t ch)
{
- // Find requested event and chamber (skip the ones before the selected)
+/// Find requested event and chamber (skip the ones before the selected)
if (nev < fEvent) return kFALSE;
- else if (nev == fEvent && ch < fChamber) return kFALSE;
+ else if (nev == fEvent) {
+ if (ch < fChamber) return kFALSE;
+ if (AliMUONClusterInput::Instance()->DetElemId() < fidDE) return kFALSE;
+ }
fEvent = nev;
fChamber = ch;
+ fidDE = AliMUONClusterInput::Instance()->DetElemId();
return kTRUE;
}
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::DrawCluster()
{
- // Draw preclusters
+/// Draw preclusters
TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
char hName[4];
for (Int_t cath = 0; cath < 2; cath++) {
// Build histograms
- if (fHist[cath*2]) {fHist[cath*2]->Delete(); fHist[cath*2] = 0;}
- if (fHist[cath*2+1]) {fHist[cath*2+1]->Delete(); fHist[cath*2+1] = 0;}
+ //if (fHist[cath*2]) {fHist[cath*2]->Delete(); fHist[cath*2] = 0;}
+ //if (fHist[cath*2+1]) {fHist[cath*2+1]->Delete(); fHist[cath*2+1] = 0;}
+ if (fHist[cath*2]) fHist[cath*2] = 0;
+ if (fHist[cath*2+1]) fHist[cath*2+1] = 0;
if (fFind->GetNPads(cath) == 0) continue; // cluster on one cathode only
Float_t wxMin = 999, wxMax = 0, wyMin = 999, wyMax = 0;
Int_t minDx = 0, maxDx = 0, minDy = 0, maxDy = 0;
for (Int_t i = 0; i < fFind->GetNPads(0)+fFind->GetNPads(1); i++) {
if (fFind->GetIJ(0,i) != cath) continue;
fHist[cath*2]->Fill(fFind->GetXyq(0,i),fFind->GetXyq(1,i),fFind->GetXyq(2,i));
- //cout << fXyq[0][i] << fXyq[1][i] << fXyq[2][i] << endl;
}
} else {
// different segmentation in the cluster
} // for (Int_t cath = 0;
// Draw histograms and coordinates
+ //TH2D *hFake = 0x0;
+ TH2D *hFake = (TH2D*) gROOT->FindObject("hFake");
+ if (hFake) hFake->Delete();
+ if (fModif) {
+ // This part works only after a modification of THistPainter::PaintLego(Option_t *)
+ // in ROOT
+ Double_t xmin = 9999, ymin = 9999, xmax = -9999, ymax = -9999, aMax = -1;
+ for (Int_t i = 0; i < 4; i++) {
+ if (!fHist[i]) continue;
+ xmin = TMath::Min (xmin, fHist[i]->GetXaxis()->GetXmin());
+ xmax = TMath::Max (xmax, fHist[i]->GetXaxis()->GetXmax());
+ ymin = TMath::Min (ymin, fHist[i]->GetYaxis()->GetXmin());
+ ymax = TMath::Max (ymax, fHist[i]->GetYaxis()->GetXmax());
+ aMax = TMath:: Max (aMax, fHist[i]->GetMaximum());
+ }
+ //if (c1->FindObject("hFake")) delete c1->FindObject("hFake");
+ hFake = new TH2D ("hFake", "hFake", 1, xmin, xmax, 1, ymin, ymax);
+ hFake->SetMaximum(aMax);
+ hFake->SetNdivisions(505,"Z");
+ hFake->SetStats(kFALSE);
+ }
+
+ TObject *stats = 0x0;
for (Int_t cath = 0; cath < 2; cath++) {
if (cath == 0) ModifyHistos();
if (fFind->GetNPads(cath) == 0) continue; // cluster on one cathode only
c1->cd(cath+1);
gPad->SetTheta(55);
gPad->SetPhi(30);
+ if (fModif) {
+ if (fHist[cath*2]) {
+ fHist[cath*2]->Draw();
+ gPad->Update();
+ stats = fHist[cath*2]->GetListOfFunctions()->FindObject("stats");
+ }
+ hFake->Draw("legoFb");
+ }
+
Double_t x, y, x0, y0, r1 = 999, r2 = 0;
if (fHist[cath*2+1]) {
//
cout << r1 << " " << r2 << endl;
} // if (fHist[cath*2+1])
if (r1 > r2) {
- //fHist[cath*2]->Draw("lego1");
- fHist[cath*2]->Draw("lego1Fb");
- //if (fHist[cath*2+1]) fHist[cath*2+1]->Draw("lego1SameAxisBb");
+ if (fModif) fHist[cath*2]->Draw("lego1FbSame");
+ else fHist[cath*2]->Draw("lego1Fb");
+ // Draw background contaminated charges
+ //TH2D *hBkg = GetBackground(cath*2);
+ //if (hBkg) hBkg->Draw("lego1FbBbSameAxis");
if (fHist[cath*2+1]) fHist[cath*2+1]->Draw("lego1SameAxisBbFb");
} else {
- //fHist[cath*2+1]->Draw("lego1");
- fHist[cath*2+1]->Draw("lego1Fb");
- //fHist[cath*2]->Draw("lego1SameAxisBb");
+ if (fModif) fHist[cath*2+1]->Draw("lego1FbSame");
+ else fHist[cath*2+1]->Draw("lego1Fb");
fHist[cath*2]->Draw("lego1SameAxisFbBb");
}
c1->Update();
+ if (fModif) stats->Draw();
} // for (Int_t cath = 0;
// Draw simulated and reconstructed hits
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::DrawHits()
{
- // Draw simulated and reconstructed hits
+/// Draw simulated and reconstructed hits
TView *view[2] = { 0x0, 0x0 };
- Double_t p1[3]={0}, p2[3], xNDC[6];
- TLine *line[99] = {0};
+ Double_t p1[3]={0}, p2[3], xNDC[6], xl, yl, zl;
+ TLine *line[199] = {0};
TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
if (c1) {
c1->cd(1);
// Draw simulated hits
cout << " *** Simulated hits *** " << endl;
- Int_t ntracks = (Int_t) fData->GetNtracks();
+ Int_t ntracks = 0;
+ if (fData->TreeH()) ntracks = (Int_t) fData->GetNtracks();
fnMu = 0;
Int_t ix, iy, iok, nLine = 0;
TClonesArray *hits = NULL;
for (Int_t ihit = 0; ihit < nhits; ihit++) {
mHit = (AliMUONHit*) hits->UncheckedAt(ihit);
if (mHit->Chamber() != fChamber+1) continue; // chamber number
- if (TMath::Abs(mHit->Z()-fFind->GetZpad()) > 1) continue; // different slat
- p2[0] = p1[0] = mHit->X(); // x-pos of hit
- p2[1] = p1[1] = mHit->Y(); // y-pos
+ if (mHit->DetElemId() != fidDE) continue; // det. elem. Id
+ AliMUONClusterInput::Instance()->Segmentation2(0)->GetTransformer()->
+ Global2Local(fidDE, mHit->X(), mHit->Y(), mHit->Z(), xl, yl, zl);
+ //if (TMath::Abs(zl-fFind->GetZpad()) > 1) continue; // different slat
+ p2[0] = p1[0] = xl; // x-pos of hit
+ p2[1] = p1[1] = yl; // y-pos
if (p1[0] < hist->GetXaxis()->GetXmin() ||
p1[0] > hist->GetXaxis()->GetXmax()) continue;
if (p1[1] < hist->GetYaxis()->GetXmin() ||
fxyMu[fnMu++][1] = p1[1];
}
}
- if (fDebug) printf(" X=%10.4f, Y=%10.4f, Z=%10.4f\n",p1[0],p1[1],mHit->Z());
+ printf(" Local coord.: X=%10.4f, Y=%10.4f\n",p1[0],p1[1]);
+ printf(" Global coord.: X=%10.4f, Y=%10.4f, Z=%10.4f\n",mHit->X(),mHit->Y(),mHit->Z());
if (view[0] || view[1]) {
// Take into account track angles
p2[0] += mHit->Tlength() * TMath::Sin(mHit->Theta()/180*TMath::Pi())
* TMath::Sin(mHit->Phi()/180*TMath::Pi()) / 2;
for (Int_t ipad = 1; ipad < 3; ipad++) {
c1->cd(ipad);
+ if (!view[ipad-1]) continue;
view[ipad-1]->WCtoNDC(p1, &xNDC[0]);
view[ipad-1]->WCtoNDC(p2, &xNDC[3]);
//c1->DrawLine(xpad[0],xpad[1],xpad[3],xpad[4]);
}
} // for (Int_t ihit = 0; ihit < nhits;
} // for (Int_t i = 0; i < ntracks;
+ fData->ResetHits();
// Draw reconstructed coordinates
- fData->GetRawClusters();
+ if (fData->TreeR()) fData->GetRawClusters();
TClonesArray *rawclust = fData->RawClusters(fChamber);
AliMUONRawCluster *mRaw;
gStyle->SetLineColor(3);
if (rawclust) {
for (Int_t i = 0; i < rawclust ->GetEntriesFast(); i++) {
mRaw = (AliMUONRawCluster*)rawclust ->UncheckedAt(i);
- if (TMath::Abs(mRaw->GetZ(0)-fFind->GetZpad()) > 1) continue; // different slat
- p2[0] = p1[0] = mRaw->GetX(0); // x-pos of hit
- p2[1] = p1[1] = mRaw->GetY(0); // y-pos
+ AliMUONClusterInput::Instance()->Segmentation2(0)->GetTransformer()->
+ Global2Local(fidDE, mRaw->GetX(0), mRaw->GetY(0), mRaw->GetZ(0), xl, yl, zl);
+ if (TMath::Abs(zl-fFind->GetZpad()) > 1) continue; // different slat
+ p2[0] = p1[0] = xl; // x-pos of hit
+ p2[1] = p1[1] = yl; // y-pos
if (p1[0] < hist->GetXaxis()->GetXmin() ||
p1[0] > hist->GetXaxis()->GetXmax()) continue;
if (p1[1] < hist->GetYaxis()->GetXmin() ||
if (fHist[ihist]->GetCellContent(ix,iy) > 0.5) {iok = 1; break;}
}
if (!iok) continue;
- if (fDebug) printf(" X=%10.4f, Y=%10.4f, Z=%10.4f\n",p1[0],p1[1],mRaw->GetZ(0));
+ printf(" Local coord.: X=%10.4f, Y=%10.4f\n",p1[0],p1[1]);
+ printf(" Global coord.: X=%10.4f, Y=%10.4f, Z=%10.4f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
if (view[0] || view[1]) {
for (Int_t ipad = 1; ipad < 3; ipad++) {
c1->cd(ipad);
+ if (!view[ipad-1]) continue;
view[ipad-1]->WCtoNDC(p1, &xNDC[0]);
view[ipad-1]->WCtoNDC(p2, &xNDC[3]);
line[nLine] = new TLine(xNDC[0],xNDC[1],xNDC[3],xNDC[4]);
}
} // for (Int_t i = 0; i < rawclust ->GetEntries();
} // if (rawclust)
+ if (fData->TreeR()) fData->ResetRawClusters();
c1->Update();
}
//_____________________________________________________________________________
Int_t AliMUONClusterDrawAZ::Next()
{
- // What to do next?
+/// What to do next?
+
// File
FILE *lun = 0;
//lun = fopen("pull.dat","w");
cout << " What is next? " << endl;
command[0] = ' ';
gets(command);
- if (command[0] == 'n' || command[0] == 'N') { fEvent++; fChamber = 0; } // next event
+ if (command[0] == 'n' || command[0] == 'N') { fEvent++; fChamber = fidDE = 0; } // next event
else if (command[0] == 'q' || command[0] == 'Q') { if (lun) fclose(lun); } // exit display
else if (command[0] == 'c' || command[0] == 'C') sscanf(command+1,"%d",&fChamber); // new chamber
- else if (command[0] == 'e' || command[0] == 'E') { sscanf(command+1,"%d",&fEvent); fChamber = 0; } // new event
+ else if (command[0] == 'e' || command[0] == 'E') { sscanf(command+1,"%d",&fEvent); fChamber = fidDE = 0; } // new event
+ else if (command[0] == 'd' || command[0] == 'D') { sscanf(command+1,"%d",&fidDE); fChamber = fidDE / 100 - 1; } // new DetElem.
else return 1; // Next precluster
return 0;
}
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::ModifyHistos(void)
{
- // Modify histograms to bring them to (approximately) the same size
+/// Modify histograms to bring them to (approximately) the same size
+
Int_t nhist = 0;
Float_t hlim[4][4], hbin[4][4]; // first index - xmin, xmax, ymin, ymax
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::AdjustHist(Double_t *xylim, const AliMUONPixel *pixPtr)
{
- // Adjust histogram limits for pixel drawing
+/// Adjust histogram limits for pixel drawing
Float_t xypads[4];
if (fHist[0]) {
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::DrawHist(const char* canvas, TH2D *hist)
{
- // Draw histogram in given canvas
+/// Draw histogram in given canvas
Int_t ix = 0;
//((TCanvas*)gROOT->FindObject("c2"))->cd();
gPad->SetPhi(30);
hist->Draw("lego1Fb");
gPad->Update();
- gets((char*)&ix);
+ //gets((char*)&ix);
+ if (fnMu) gets((char*)&ix);
}
//_____________________________________________________________________________
void AliMUONClusterDrawAZ::FillMuon(Int_t nfit, const Double_t *parOk, const Double_t *errOk)
{
- // Fill muon information
+/// Fill muon information
Int_t indx, imax;
Double_t cmax, rad;
}
}
+//_____________________________________________________________________________
+void AliMUONClusterDrawAZ::UpdateCluster(Int_t npad)
+{
+/// Update cluster after removing non-overlapped pads
+
+ Int_t cath = 0, ix = 0, iy = 0;
+ cout << " Update cluster " << endl;
+ gets((char*)&ix);
+ for (Int_t i = 0; i < npad; i++) {
+ if (TMath::Nint (fFind->GetXyq(2,i)) != -2) continue;
+ cath = fFind->GetIJ(0,i);
+ for (Int_t j = 0; j < 2; j++) {
+ Int_t ihist = cath * 2 + j;
+ if (!fHist[ihist]) continue;
+ ix = fHist[ihist]->GetXaxis()->FindBin(fFind->GetXyq(0,i));
+ iy = fHist[ihist]->GetYaxis()->FindBin(fFind->GetXyq(1,i));
+ Double_t cont = fHist[ihist]->GetCellContent(ix, iy);
+ if (cont < 0.1) continue;
+ fHist[ihist]->Fill(fFind->GetXyq(0,i), fFind->GetXyq(1,i), -cont);
+ }
+ }
+ TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
+ if (c1) {
+ c1->cd(1);
+ gPad->Modified();
+ gPad->Update();
+ c1->cd(2);
+ gPad->Modified();
+ gPad->Update();
+ }
+}
+
+//_____________________________________________________________________________
+TH2D* AliMUONClusterDrawAZ::GetBackground(Int_t iHist)
+{
+/// Build histogram with pads from the cluster contaminated by the background
+
+ //return 0x0;
+ Int_t cath = iHist / 2;
+ Double_t xmin = fHist[iHist]->GetXaxis()->GetXmin();
+ Double_t xmax = fHist[iHist]->GetXaxis()->GetXmax();
+ Double_t ymin = fHist[iHist]->GetYaxis()->GetXmin();
+ Double_t ymax = fHist[iHist]->GetYaxis()->GetXmax();
+
+ // Create histogram
+ char hName[4];
+ sprintf(hName,"Bkg%1d",iHist);
+ TH2D *hist = (TH2D*) gROOT->FindObject(hName);
+ if (hist) hist->Delete();
+ hist = (TH2D*) fHist[iHist]->Clone(hName);
+ hist->Reset();
+
+ // Loop over pads
+ Int_t digit = 0, iok = 0, ix = 0, iy = 0;
+ AliMUONDigit *mdig = 0x0;
+ Double_t cont = 0, x = 0, y = 0;
+ for (Int_t i = 0; i < fFind->GetNPads(0)+fFind->GetNPads(1); i++) {
+ if (fFind->GetIJ(0,i) != cath) continue;
+ x = fFind->GetXyq(0,i);
+ y = fFind->GetXyq(1,i);
+ if (x < xmin || x > xmax) continue;
+ if (y < ymin || y > ymax) continue;
+ digit = fFind->GetIJ(4,i);
+ if (digit >= 0) mdig = AliMUONClusterInput::Instance()->Digit(cath, digit);
+ else mdig = AliMUONClusterInput::Instance()->Digit(TMath::Even(cath), -digit-1);
+ if (mdig->Track(1) >= 0 || mdig->Track(0) >= 10000000) {
+ ix = fHist[iHist]->GetXaxis()->FindBin(x);
+ iy = fHist[iHist]->GetYaxis()->FindBin(y);
+ cont = fHist[iHist]->GetCellContent(ix, iy);
+ hist->Fill(x, y, cont);
+ iok = 1;
+ }
+ }
+ if (iok) {
+ hist->SetFillColor(5);
+ hist->SetMaximum(fHist[iHist]->GetMaximum());
+ return hist;
+ }
+ return 0x0;
+}