The Init method of AliITSreconstruction has to be called by the user. This was done...
[u/mrichter/AliRoot.git] / RICH / AliRICHPoints.cxx
index de61de7..771bc73 100644 (file)
 
 /*
   $Log$
+  Revision 1.9  2001/02/27 15:20:56  jbarbosa
+  Transition to SDigits.
+
+  Revision 1.8  2001/01/26 20:00:27  hristov
+  Major upgrade of AliRoot code
+
+  Revision 1.7  2000/11/02 09:10:57  jbarbosa
+  Removed AliRICHRecHit.h from include.
+
+  Revision 1.6  2000/10/03 21:44:09  morsch
+  Use AliSegmentation and AliHit abstract base classes.
+
+  Revision 1.5  2000/10/02 21:28:12  fca
+  Removal of useless dependecies via forward declarations
+
+  Revision 1.4  2000/10/02 15:50:43  jbarbosa
+  Fixed forward declarations.
+
+  Revision 1.3  2000/06/12 15:26:36  jbarbosa
+  Cleaned up version.
+
+  Revision 1.2  2000/05/18 13:43:54  jbarbosa
+  Added the ShowRing function.
+
+  Revision 1.1  2000/04/19 13:16:47  morsch
+  Minor changes on class names.
+
 */
 
 
 //                                                                           //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
+#include <TPad.h>
+#include <TTree.h>
+#include <TView.h>
+#include <TMath.h>
+#include <TPolyMarker3D.h>
+#include <TMarker3DBox.h>
+
+#include <AliRICH.h>
+#include "TParticle.h"
 #include "AliRICHDisplay.h"
 #include "AliRICHPoints.h"
 #include "AliRun.h"
-#include "TPad.h"
-#include "TView.h"
-#include "TMath.h"
+#include "AliRICHHit.h"
+#include "AliRICHCerenkov.h"
+#include "AliRICHSDigit.h"
+#include "AliRICHDigit.h"
+#include "AliRICHRawCluster.h"
 
-const Int_t MAX_Nipx=400, MAX_Nipy=800;
+const Int_t kMaxNipx=400, kMaxNipy=800;
  
 ClassImp(AliRICHPoints)
 
@@ -127,6 +165,15 @@ Int_t AliRICHPoints::GetTrackIndex()
   this->Inspect();
   return fTrackIndex;
 }
+//_____________________________________________________________________________
+TParticle *AliRICHPoints::GetParticle() const
+{
+  //
+  //   Returns pointer to particle index in AliRun::fParticles
+  //
+  if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
+  return gAlice->Particle(fIndex);
+}
 
 //_____________________________________________________________________________
 AliRICHHit *AliRICHPoints::GetHit() const
@@ -134,12 +181,12 @@ AliRICHHit *AliRICHPoints::GetHit() const
   //
   //   Returns pointer to hit index in AliRun::fParticles
   //
-  AliRICH *RICH  = (AliRICH*)gAlice->GetDetector("RICH");
+  AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
   gAlice->TreeH()->GetEvent(fTrackIndex);
-  TClonesArray *RICHhits  = RICH->Hits();
-  Int_t nhits = RICHhits->GetEntriesFast();
+  TClonesArray *pRICHhits  = pRICH->Hits();
+  Int_t nhits = pRICHhits->GetEntriesFast();
   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
-  return (AliRICHHit*)RICHhits->UncheckedAt(fHitIndex);
+  return (AliRICHHit*)pRICHhits->UncheckedAt(fHitIndex);
 }
 
 //_____________________________________________________________________________
@@ -153,141 +200,97 @@ AliRICHDigit *AliRICHPoints::GetDigit() const
   Int_t chamber=display->GetChamber();
   Int_t cathode=display->GetCathode();
    
-  AliRICH *RICH  = (AliRICH*)gAlice->GetDetector("RICH");
-  TClonesArray *RICHdigits  = RICH->DigitsAddress(chamber-1);
+  AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
+  TClonesArray *pRICHdigits  = pRICH->DigitsAddress(chamber-1);
   gAlice->TreeD()->GetEvent(cathode);
-  Int_t ndigits = RICHdigits->GetEntriesFast();
+  Int_t ndigits = pRICHdigits->GetEntriesFast();
   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
-  return (AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
+  return (AliRICHDigit*)pRICHdigits->UncheckedAt(fDigitIndex);
 }
-//_____________________________________________________________________________
-struct Bin {
-   const AliRICHDigit *dig;
-   int idx;
-   Bin() {dig=0; idx=-1;}
-};
-
-struct PreCluster : public AliRICHRawCluster {
-   const AliRICHDigit* summit;
-   int idx;
-   int cut;
-   int npeaks;
-   PreCluster() : AliRICHRawCluster() {cut=npeaks=0;}
-};
-//_____________________________________________________________________________
+//----------------------------------------------------------------------------
+void AliRICHPoints::ShowRing(Int_t highlight) {
 
-static void FindCluster(AliRICHChamber *iChamber, AliRICHSegmentation *segmentation, int i, int j, Bin bins[MAX_Nipx][MAX_Nipy], PreCluster &c) 
+//
+// Highlights all pads generated by the same mother particle
 
-{
+   
+  AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
+  AliRICHChamber*       iChamber;
+  AliSegmentation*      segmentation;
 
-  //
-  // Find clusters
-  //
+      
+  AliRICHPoints *points = 0;
+  TMarker3DBox  *marker = 0;
+    
+  AliRICHHit *mHit = GetHit();
 
-  printf("I'm in FindCluster \n"); 
+  printf("Hit %d on chamber: %d\n",fHitIndex, mHit->Chamber());
 
-  Bin& b=bins[i][j];
-  Int_t q=b.dig->fSignal;
-
-  printf("FindCluster - i j q %d %d %d\n",i,j,q);
-  
-  if (q<0) { 
-    q=-q;
-    c.cut=1;
-  } 
-  if (b.idx >= 0 && b.idx != c.idx) {
-    c.idx=b.idx;
-    c.npeaks++;
-  }
-  
-  if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
-
-  Int_t npx  = segmentation->Npx();
-  Int_t npy  = segmentation->Npy();
-  Float_t x,y;
-  segmentation->GetPadCxy(i-npx, j-npy, x,y);
-  printf("FindCluster - x  y %f %f \n",x,y);
+  TClonesArray *digits  = pRICH->DigitsAddress(mHit->Chamber() - 1);
+  iChamber = &(pRICH->Chamber(mHit->Chamber() - 1));
+  segmentation=iChamber->GetSegmentationModel();
 
+  Float_t dpx  = segmentation->Dpx();
+  Float_t dpy  = segmentation->Dpy();
 
-  c.fX += q*x;
-  c.fY += q*y;
-  c.fQ += q;
+  int ndigits=digits->GetEntriesFast();
   
-  b.dig = 0;  b.idx = c.idx;
+  printf("Show Ring called with %d digits\n",ndigits);
   
-  if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
-  if (bins[i][j-1].dig) FindCluster(iChamber,segmentation,i,j-1,bins,c);
-  if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
-  if (bins[i][j+1].dig) FindCluster(iChamber,segmentation,i,j+1,bins,c);
-
-}
-
-//_____________________________________________________________________________
-
-void AliRICHPoints::GetCenterOfGravity()
-{
-  //
-  // simple RICH cluster finder from digits -- finds neighbours and 
-  // calculates center of gravity for the cluster
-  //
-  const Int_t MAX_nipx=400, MAX_nipy=800;
-  printf("\n Hallo world");
-  AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
-  Int_t chamber=display->GetChamber();
-  Int_t cathode=display->GetCathode();
-   
-  AliRICH *RICH  = (AliRICH*)gAlice->GetDetector("RICH");
-  AliRICHChamber *iChamber;
-  AliRICHSegmentation *segmentation;
-  iChamber =&(RICH->Chamber(chamber-1));
-  segmentation=iChamber->GetSegmentationModel(cathode);
-  Int_t npx  = segmentation->Npx();
-  Int_t npy  = segmentation->Npy();
-  Float_t zpos=iChamber->ZPosition();
-  
-  TClonesArray *RICHdigits  = RICH->DigitsAddress(chamber-1);
-  gAlice->TreeD()->GetEvent(cathode);
-  Int_t ndigits = RICHdigits->GetEntriesFast();
-  if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
-
-  AliRICHDigit  *dig;
-  dig=(AliRICHDigit*)RICHdigits->UncheckedAt(fDigitIndex);
-  Int_t ipx=dig->fPadX;
-  Int_t ipy=dig->fPadY;
-  Bin bins[MAX_nipx][MAX_nipy]; 
-  bins[ipx+npx][ipy+npy].dig=dig;
+  for (int digit=0;digit<ndigits;digit++) {
+    AliRICHDigit *mdig = (AliRICHDigit*)digits->UncheckedAt(digit);
+    points = new AliRICHPoints(1);
     
-  int ndig;
-  int ncls=0;
-  for (ndig=0; ndig<ndigits; ndig++) {
-      dig = (AliRICHDigit*)RICHdigits->UncheckedAt(ndig);
-      int i=dig->fPadX, j=dig->fPadY;
-      bins[i+npx][j+npy].dig=dig;
+     //printf("Particle %d belongs to ring %d \n", fTrackIndex, mdig->fTracks[1]);
+
+    if (!points) continue;
+    if (fTrackIndex == mdig->Track(0)) {
+
+      printf("Digit %d from particle %d belongs to ring %d \n", digit, fTrackIndex, mdig->Track(0));
+
+      Int_t charge=mdig->Signal();
+      Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
+      Int_t color=701+index;
+      if (color>722) color=722;
+      points->SetMarkerColor(color);
+      points->SetMarkerStyle(21);
+      points->SetMarkerSize(.5);
+      Float_t xpad, ypad, zpad;
+      segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
+      Float_t vectorLoc[3]={xpad,6.276,ypad};
+      Float_t  vectorGlob[3];
+      points->SetParticle(-1);
+      points->SetHitIndex(-1);
+      points->SetTrackIndex(-1);
+      points->SetDigitIndex(digit);
+      iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
+      points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
+      
+      segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
+      Float_t theta = iChamber->GetRotMatrix()->GetTheta();
+      Float_t phi   = iChamber->GetRotMatrix()->GetPhi();         
+      marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
+                             dpy/2,0,dpx/2,theta,phi);
+      marker->SetLineColor(highlight);
+      marker->SetFillStyle(1001);
+      marker->SetFillColor(color);
+      marker->SetRefObject((TObject*)points);
+      points->Set3DMarker(0, marker);
+      
+      points->Draw("same");
+      for (Int_t im=0;im<3;im++) {
+       TMarker3DBox *marker=points->GetMarker(im);
+       if (marker)
+         marker->Draw();
+      }
+      TParticle *p = gAlice->Particle(fIndex);
+      printf("\nTrack index %d\n",fTrackIndex);
+      printf("Particle ID %d\n",p->GetPdgCode());
+      printf("Parent %d\n",p->GetFirstMother());
+      printf("First child %d\n",p->GetFirstDaughter());
+      printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
+    }
   }
-
-  PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
-  FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
-  if (c.npeaks>1) {
-      printf("GetCenterOfGravity -- more than one peak");
-  }
-  c.fX /= c.fQ;
-  c.fY /= c.fQ;
-  printf("GetCenterOfGravity - c.fX c.fY c.fQ %f %f %d \n",c.fX,c.fY,c.fQ);
-  
-  c.fTracks[0]=c.summit->fTracks[0];
-  c.fTracks[1]=c.summit->fTracks[1];
-  c.fTracks[2]=c.summit->fTracks[2];
-  ncls++;
-  AliRICHPoints *points = 0;
-  points = new AliRICHPoints(1);
-  points->SetMarkerColor(kYellow);
-  points->SetMarkerStyle(5);
-  points->SetMarkerSize(1.);
-  points->SetPoint(0,c.fX,c.fY,zpos);
-  points->Draw();
-  
-  printf("GetCenterOfGravity -- ncls %d \n",ncls);
-
 }
 
 //_____________________________________________________________________________