]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterDrawAZ.cxx
new lookup table for sim. data with numberof TRMs
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterDrawAZ.cxx
index 3823a57ec2bad7a083bcf36c688e000203e30562..53250865848b867b363418ce38d5d63ef24c3d0d 100644 (file)
 
 /* $Id$ */
 
-// Cluster drawing object for AZ cluster finder 
+// -------------------------------------
+// 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>
@@ -47,58 +51,47 @@ ClassImp(AliMUONClusterDrawAZ)
  
 //_____________________________________________________________________________
 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 = fidDE = 0;
-  fModif = 0; //0; 
   Init();
 }
 
 //_____________________________________________________________________________
 AliMUONClusterDrawAZ::~AliMUONClusterDrawAZ()
 {
-  // Destructor
+/// Destructor
 }
 
-//_____________________________________________________________________________
-AliMUONClusterDrawAZ::AliMUONClusterDrawAZ(const AliMUONClusterDrawAZ& rhs)
-  : TObject(rhs)
-{
-// Protected copy constructor
-
-  AliFatal("Not implemented.");
-}
-
-
-//_____________________________________________________________________________
-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);
@@ -120,7 +113,7 @@ void AliMUONClusterDrawAZ::Init()
 //_____________________________________________________________________________
 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) {
@@ -136,7 +129,7 @@ Bool_t AliMUONClusterDrawAZ::FindEvCh(Int_t nev, Int_t ch)
 //_____________________________________________________________________________
 void AliMUONClusterDrawAZ::DrawCluster()
 {
-  // Draw preclusters
+/// Draw preclusters
 
   TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
 
@@ -185,7 +178,6 @@ void AliMUONClusterDrawAZ::DrawCluster()
       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
@@ -238,7 +230,9 @@ void AliMUONClusterDrawAZ::DrawCluster()
   } // for (Int_t cath = 0;
        
   // Draw histograms and coordinates
-  TH2D *hFake = 0x0;
+  //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
@@ -251,8 +245,8 @@ void AliMUONClusterDrawAZ::DrawCluster()
       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", "", 1, xmin, xmax, 1, ymin, ymax);
+    //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);
@@ -309,6 +303,9 @@ void AliMUONClusterDrawAZ::DrawCluster()
     if (r1 > r2) {
       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 {
       if (fModif) fHist[cath*2+1]->Draw("lego1FbSame");
@@ -326,11 +323,11 @@ void AliMUONClusterDrawAZ::DrawCluster()
 //_____________________________________________________________________________
 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], xl, yl, zl;
-  TLine *line[99] = {0};
+  TLine *line[199] = {0};
   TCanvas *c1 = (TCanvas*) gROOT->GetListOfCanvases()->FindObject("c1");
   if (c1) {
     c1->cd(1);
@@ -358,9 +355,10 @@ void AliMUONClusterDrawAZ::DrawHits()
     for (Int_t ihit = 0; ihit < nhits; ihit++) {
       mHit = (AliMUONHit*) hits->UncheckedAt(ihit);
       if (mHit->Chamber() != fChamber+1) continue;  // chamber number
+      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
+      //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() || 
@@ -404,6 +402,7 @@ void AliMUONClusterDrawAZ::DrawHits()
       }
     } // for (Int_t ihit = 0; ihit < nhits;
   } // for (Int_t i = 0; i < ntracks;
+  fData->ResetHits();
 
   // Draw reconstructed coordinates
   if (fData->TreeR()) fData->GetRawClusters();
@@ -454,13 +453,15 @@ void AliMUONClusterDrawAZ::DrawHits()
       }
     } // 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");
@@ -495,7 +496,8 @@ Int_t AliMUONClusterDrawAZ::Next()
 //_____________________________________________________________________________
 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
 
@@ -601,7 +603,7 @@ void AliMUONClusterDrawAZ::ModifyHistos(void)
 //_____________________________________________________________________________
 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]) {
@@ -621,7 +623,7 @@ void AliMUONClusterDrawAZ::AdjustHist(Double_t *xylim, const AliMUONPixel *pixPt
 //_____________________________________________________________________________
 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();
@@ -637,7 +639,7 @@ void AliMUONClusterDrawAZ::DrawHist(const char* canvas, TH2D *hist)
 //_____________________________________________________________________________
 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;
@@ -663,7 +665,7 @@ void AliMUONClusterDrawAZ::FillMuon(Int_t nfit, const Double_t *parOk, const Dou
 //_____________________________________________________________________________
 void AliMUONClusterDrawAZ::UpdateCluster(Int_t npad)
 {
-  // Update cluster after removing non-overlapped pads
+/// Update cluster after removing non-overlapped pads
 
   Int_t cath = 0, ix = 0, iy = 0;
   cout << " Update cluster " << endl;
@@ -691,3 +693,52 @@ void AliMUONClusterDrawAZ::UpdateCluster(Int_t npad)
     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;
+}