]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterDrawAZ.cxx
Former V2 renamed
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterDrawAZ.cxx
index bf1960165ddf416ad939dd6461bd25761d231ce0..f0c7d5e7e2eeec9ec607d129a11feb48412d81d6 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>
@@ -29,6 +33,7 @@
 
 #include "AliMUONClusterDrawAZ.h"
 #include "AliMUONClusterFinderAZ.h"
+#include "AliMUONGeometryModuleTransformer.h"
 #include "AliHeader.h"
 #include "AliRun.h"
 #include "AliMUON.h"
@@ -36,7 +41,7 @@
 #include "AliMUONDigit.h"
 #include "AliMUONHit.h"
 #include "AliMUONRawCluster.h"
-//#include "AliMUONClusterInput.h"
+#include "AliMUONClusterInput.h"
 #include "AliMUONPixel.h"
 //#include "AliMC.h"
 #include "AliMUONLoader.h"
@@ -46,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 = 0;
-  fModif = 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);
@@ -119,19 +113,23 @@ 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 && 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");
 
@@ -140,8 +138,10 @@ void AliMUONClusterDrawAZ::DrawCluster()
   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;
@@ -178,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
@@ -231,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
@@ -244,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);
@@ -302,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");
@@ -319,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];
-  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);
@@ -338,7 +342,8 @@ void AliMUONClusterDrawAZ::DrawHits()
 
   // 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;
@@ -350,9 +355,12 @@ 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 (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() || 
@@ -374,7 +382,8 @@ void AliMUONClusterDrawAZ::DrawHits()
          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()) 
@@ -393,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();
@@ -403,9 +413,11 @@ void AliMUONClusterDrawAZ::DrawHits()
   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() || 
@@ -427,7 +439,8 @@ void AliMUONClusterDrawAZ::DrawHits()
        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);
@@ -440,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");
@@ -468,10 +483,11 @@ Int_t AliMUONClusterDrawAZ::Next()
   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;
 }
@@ -480,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
 
@@ -586,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]) {
@@ -606,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();
@@ -615,13 +632,14 @@ void AliMUONClusterDrawAZ::DrawHist(const char* canvas, TH2D *hist)
   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;
@@ -647,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;
@@ -675,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;
+}