Helix indeed removed from repository
authorkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Mar 2007 13:51:43 +0000 (13:51 +0000)
committerkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Mar 2007 13:51:43 +0000 (13:51 +0000)
HMPID/AliHMPIDCluster.cxx
HMPID/AliHMPIDDigit.h
HMPID/AliHMPIDHelix.cxx [deleted file]
HMPID/AliHMPIDHelix.h [deleted file]
HMPID/AliHMPIDParam.cxx
HMPID/AliHMPIDReconstructor.cxx
HMPID/Hdisp.C
HMPID/Hmenu.C

index 009b0f86b1a515970681ce3c1781cfa42259c4bd..c1806924dbc1d76a0fd956cec54e0e2959bb7dc8 100644 (file)
@@ -71,7 +71,7 @@ void AliHMPIDCluster::CorrSin()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDCluster::Draw(Option_t*)
 {
-  TMarker *pMark=new TMarker(X(),Y(),5); pMark->SetMarkerColor(kBlue); pMark->Draw();
+  TMarker *pMark=new TMarker(X(),Y(),5); pMark->SetUniqueID(fSt);pMark->SetMarkerColor(kBlue); pMark->Draw();
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDCluster::FitFunc(Int_t &iNpars, Double_t *, Double_t &chi2, Double_t *par, Int_t )
index cddb49100a9363972fb626bdfc248cbb3a62ecf5..0efc0f88909e00a5c1c3b19685579ae0758cb353 100644 (file)
@@ -14,9 +14,9 @@ class TClonesArray;        //Hit2Sdi()
 class AliHMPIDDigit :public AliDigit //TObject-AliDigit-AliHMPIDDigit
 {
 public:
-  enum EChamberData{kMinCh=0,kMaxCh=6,kMinPc=0,kMaxPc=5};  
-  enum EPadxData{kPadPcX=80,kMinPx=0,kMaxPx=kPadPcX-1,kMaxPadChX=159};   //Segmentation structure along x
-  enum EPadyData{kPadPcY=48,kMinPy=0,kMaxPy=kPadPcY-1,kMaxPadChY=143};   //Segmentation structure along y
+  enum EChamberData{kMinCh=0,kMaxCh=6,kMinPc=0,kMaxPc=5};      //Segmenation     
+  enum EPadxData{kPadPcX=80,kMinPx=0,kMaxPx=79,kMaxPcx=159};   //Segmentation structure along x
+  enum EPadyData{kPadPcY=48,kMinPy=0,kMaxPy=47,kMaxPcy=143};   //Segmentation structure along y
 //ctor&dtor    
   AliHMPIDDigit(                          ):AliDigit( ),fPad(Abs(-1,-1,-1,-1)),fQ(-1)  {}                         //default ctor
   AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad             ),fQ(q )  {}                         //digit ctor
diff --git a/HMPID/AliHMPIDHelix.cxx b/HMPID/AliHMPIDHelix.cxx
deleted file mode 100644 (file)
index 0c92d2d..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-/* $Id$ */
-
-#include "AliHMPIDHelix.h" //class header
-#include <TPolyLine3D.h>  //Draw()
-
-ClassImp(AliHMPIDHelix)
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void  AliHMPIDHelix::Print(Option_t *opt) const
-{
-// Debug printout
-  Printf("%s helix for Q=%i in B=(0,0,%.2f) tesla",opt,fQ,fBz);
-  Printf("Helix parametrised  @ x0=(%6.2f,%6.2f,%6.2f) cm p0=(%6.2f,%6.2f,%6.2f) GeV  P=%.2f GeV Theta=%.2f Phi=%.2f degrees", 
-                                fX0.X(),fX0.Y(),fX0.Z(),    fP0.Px(),fP0.Py(),fP0.Pz(), fP0.Mag(),fP0.Theta()*TMath::RadToDeg(),fP0.Phi()*TMath::RadToDeg());
-}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDHelix::Draw(const Option_t *)
-{
-// Draw helix by a set of points seperated by 1 cm distance 
-  TVector3 pos,mom;
-  const Int_t kNpoints=500;
-  TPolyLine3D *pHelDraw = new TPolyLine3D(kNpoints); pHelDraw->SetLineColor(kGreen);
-  for(Int_t i=0;i<kNpoints;i++) {
-    Propagate(i,pos,mom);
-    pHelDraw->SetPoint(i,pos.X(),pos.Y(),pos.Z());
-  }  
-  pHelDraw->Draw();
-}
diff --git a/HMPID/AliHMPIDHelix.h b/HMPID/AliHMPIDHelix.h
deleted file mode 100644 (file)
index 6e29988..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef AliHMPIDHelix_h
-#define AliHMPIDHelix_h
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/* $Id$ */
-
-#include <TObject.h>              //base class
-#include <TVector3.h>             //used extensively
-#include <TMath.h>
-
-class AliHMPIDHelix: public TObject
-{
-public:
-  AliHMPIDHelix(                                                            ):TObject(),fX0(TVector3(0,0,0)),fP0(TVector3(0,0,0)),fQ(0),fBz(0 )  {}
-  AliHMPIDHelix(const TVector3 &x0,const TVector3 &p0,Int_t q=1,Double_t b=2):TObject(),fX0(x0             ),fP0(p0             ),fQ(q),fBz(b )  {}
-  AliHMPIDHelix(Double_t p,Double_t theta,Double_t phi,Double_t bz=2        ):TObject(),fX0(TVector3(0,0,0)),fP0(TVector3(0,0,0)),fQ(0),fBz(bz)  
-                   {fP0.SetMagThetaPhi(p,theta*TMath::DegToRad(),phi*TMath::DegToRad());} //p [GeV], theta,phi [deg], Bz [Tesla];
-  virtual ~AliHMPIDHelix()                                                                                                                   {}        
-           
-         void     Draw          (const Option_t *opt=""              );                              //from TObject, draw helix
-         void     Print    (const Option_t *opt=""              )const;                         //from TObject, print status
-//private part++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-  inline Bool_t   Intersect(            TVector3 &pnt,TVector3 &norm );          //intersection with plane given by point and normal vector
-  inline void     Propagate(Float_t len,TVector3 &x,  TVector3 &p    );          //propogate helix by given length along it            
-protected:
-  TVector3 fX0;            //helix position in point of definition, [cm]    in MARS
-  TVector3 fP0;            //helix momentum in point of definition, [GeV/c] in MARS
-  Int_t    fQ;             //sign of track charge  
-  Float_t  fBz;            //magnetic field along z, [kGaus] 
-  ClassDef(AliHMPIDHelix,0) //General helix
-};//class AliHMPIDHelix
-
-typedef AliHMPIDHelix AliRICHHelix; // for backward compatibility
-
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDHelix::Propagate(Float_t len,TVector3 &x,TVector3 &p)
-{
-// Propogates the helix from inintial point by a given distance along helix. Assumes uniform magnetic field along z direction.  
-// Arguments: len - distance to propagate by, [cm]
-//   Returns: none    
-  if(fBz==0){//no magnetic field->straight line
-    x=fX0+fP0.Unit()*len;   
-    p=fP0;
-  }else{
-    const Float_t c = 0.000299792458;//this speed of light value provides that coordinates are in [cm] momentum in [GeV/c] field in [kGaus]
-    Float_t a = -c*fBz*fQ;
-    Float_t rho = a/fP0.Mag();
-    x.SetX( fX0.X()+fP0.X()*TMath::Sin(rho*len)/a-fP0.Y()*(1-TMath::Cos(rho*len))/a  );
-    x.SetY( fX0.Y()+fP0.Y()*TMath::Sin(rho*len)/a+fP0.X()*(1-TMath::Cos(rho*len))/a  ); 
-    x.SetZ( fX0.Z()+fP0.Z()*len/fP0.Mag()                                            );
-    x.SetX( fP0.X()*TMath::Cos(rho*len)-fP0.Y()*TMath::Sin(rho*len)                  );
-    p.SetY( fP0.Y()*TMath::Cos(rho*len)+fP0.X()*TMath::Sin(rho*len)                  );
-    p.SetZ( fP0.Z()                                                                  );
-  }
-}//Propagate()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDHelix::Intersect(TVector3 &pnt,TVector3 &norm)
-{
-// Finds point of intersection (if exists) of the helix with the plane. Stores result in fX and fP.   
-// Arguments: pnt  - arbitrary point of the plane, [cm] in MARS
-//            norm - vector, normal to the plane, [cm] in MARS
-//   Returns:      - kTrue if helix intersects the plane, kFALSE otherwise.
-//                 - pnt contains the point of intersection, [cm] in MARS  
-  TVector3 x,p;                                                    //current helix position and momentum
-  Double_t s=(pnt-fX0)*norm,dist=99999,distPrev=dist;              //estimates initial distance to plane
-  while(TMath::Abs(dist)>0.00001){                                 //loop while the distance is less then precision   
-    Propagate(s,x,p);                                              //calculates helix at the distance s from x0 ALONG the helix
-    dist=(x-pnt)*norm;                                             //distance between current helix position and plane
-    if(TMath::Abs(dist) >= TMath::Abs(distPrev)) { return kFALSE;} //if distance increases then no intersection 
-    distPrev=dist;
-    s-=dist;
-  }  
-  norm=p;
-  pnt=x;                                    
-  return kTRUE;
-}//Intersect()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#endif
index f5bc54b6fb021221ffd7e434fbeacfb9b1986e18..b8822a541811a065f6408ead39c33e7861bb96e0 100644 (file)
@@ -22,7 +22,6 @@
 #include <AliRunLoader.h>  //Stack()
 #include <AliStack.h>      //Stack()
 #include <TParticle.h>     //Stack()    
-#include "AliHMPIDHelix.h"  //TestTrans()
 
 ClassImp(AliHMPIDParam)
 
index 51eefc49d8679b12d8d5819962d268f226b788e9..085124e9397be37659b1ba71396b369c11e0adc0 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "AliHMPIDReconstructor.h" //class header
 #include "AliHMPID.h"              //Reconstruct() 
-#include "AliHMPIDCluster.h"       //CluQA() 
+#include "AliHMPIDCluster.h"       //Dig2Clu()
 #include "AliHMPIDParam.h"         //FillEsd() 
 #include <AliESD.h>               //FillEsd()
 #include <AliRunLoader.h>         //Reconstruct() for simulated digits
@@ -32,9 +32,9 @@ void AliHMPIDReconstructor::Dig2Clu(TObjArray *pDigAll,TObjArray *pCluAll,Bool_t
 //            pCluAll     - list of clusters for all chambers
 //            isTryUnfold - flag to choose between CoG and Mathieson fitting  
 //  Returns: none    
-  TMatrixF padMap(AliHMPIDDigit::kMaxPadChX,AliHMPIDDigit::kMaxPadChY);                       //pads map for single chamber 0..159 x 0..143 
+  TMatrixF padMap(AliHMPIDDigit::kMinPx,AliHMPIDDigit::kMaxPcx,AliHMPIDDigit::kMinPy,AliHMPIDDigit::kMaxPcy);  //pads map for single chamber 0..159 x 0..143 
   
-  for(Int_t iCh=0;iCh<7;iCh++){                                                           //chambers loop 
+  for(Int_t iCh=AliHMPIDDigit::kMinCh;iCh<=AliHMPIDDigit::kMaxCh;iCh++){                  //chambers loop 
     TClonesArray *pDigCur=(TClonesArray*)pDigAll->At(iCh);                                //get list of digits for current chamber
     if(pDigCur->GetEntriesFast()==0) continue;                                            //no digits for current chamber
   
@@ -61,22 +61,21 @@ void AliHMPIDReconstructor::Dig2Clu(TObjArray *pDigAll,TObjArray *pCluAll,Bool_t
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void  AliHMPIDReconstructor::FormClu(AliHMPIDCluster *pClu,AliHMPIDDigit *pDig,TClonesArray *pDigLst,TMatrixF *pDigMap)
 {
-// Forms the initial cluster as a combination of all adjascent digits. Starts from the given digit
-// then calls itself recursevly  for all possible neighbours.
+// Forms the initial cluster as a combination of all adjascent digits. Starts from the given digit then calls itself recursevly  for all neighbours.
 // Arguments: pClu - pointer to cluster being formed
-//  Returns: none   
+//   Returns: none   
   pClu->DigAdd(pDig);//take this digit in cluster
 
   Int_t cnt=0,cx[4],cy[4];
   
-  if(pDig->PadPcX() != 0                       ){cx[cnt]=pDig->PadChX()-1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //left
-  if(pDig->PadPcX() != AliHMPIDDigit::kPadPcX-1){cx[cnt]=pDig->PadChX()+1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //right
-  if(pDig->PadPcY() != 0                       ){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()-1;cnt++;}       //down
-  if(pDig->PadPcY() != AliHMPIDDigit::kPadPcY-1){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()+1;cnt++;}       //up
+  if(pDig->PadPcX() != AliHMPIDDigit::kMinPx){cx[cnt]=pDig->PadChX()-1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //left
+  if(pDig->PadPcX() != AliHMPIDDigit::kMaxPx){cx[cnt]=pDig->PadChX()+1; cy[cnt]=pDig->PadChY()  ;cnt++;}       //right
+  if(pDig->PadPcY() != AliHMPIDDigit::kMinPy){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()-1;cnt++;}       //down
+  if(pDig->PadPcY() != AliHMPIDDigit::kMaxPy){cx[cnt]=pDig->PadChX()  ; cy[cnt]=pDig->PadChY()+1;cnt++;}       //up
   
-  for (Int_t i=0;i<cnt;i++)
+  for (Int_t i=0;i<cnt;i++){//neighbours loop
     if((pDig=UseDig(cx[i],cy[i],pDigLst,pDigMap))) FormClu(pClu,pDig,pDigLst,pDigMap);   //check if this neighbour pad fired and mark it as taken  
-  
+  }//neighbours loop  
 }//FormClu()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDReconstructor::Reconstruct(AliRunLoader *pAL)const
@@ -106,7 +105,7 @@ void AliHMPIDReconstructor::Reconstruct(AliRunLoader *pAL)const
     
   AliDebug(1,"Stop.");      
 }//Reconstruct(for simulated digits)
-//__________________________________________________________________________________________________
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDReconstructor::Reconstruct(AliRunLoader *pAL,AliRawReader* pRR)const
 {
 //Invoked  by AliReconstruction to convert raw digits from DDL files to clusters
@@ -146,7 +145,6 @@ void AliHMPIDReconstructor::Reconstruct(AliRunLoader *pAL,AliRawReader* pRR)cons
   pRL->UnloadRecPoints();  
 }//Reconstruct raw data
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 void AliHMPIDReconstructor::FillESD(AliRunLoader *, AliESD *pESD) const
 {
 // Calculates probability to be a electron-muon-pion-kaon-proton
@@ -168,9 +166,8 @@ void AliHMPIDReconstructor::FillESD(AliRunLoader *, AliESD *pESD) const
     for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++){
       Double_t mass = AliPID::ParticleMass(iPart);
       Double_t cosThetaTh = TMath::Sqrt(mass*mass+pmod*pmod)/(AliHMPIDParam::Instance()->MeanIdxRad()*pmod);
-      if(cosThetaTh<1) //calculate the height of theortical theta ckov on the gaus of experimental one
-        h[iPart] =TMath::Gaus(TMath::ACos(cosThetaTh),pTrk->GetHMPIDsignal(),TMath::Sqrt(pTrk->GetHMPIDchi2()),kTRUE);
-      
+      if(cosThetaTh<1) //calculate the height of theoretical theta ckov on the gaus of experimental one
+        h[iPart] =TMath::Gaus(TMath::ACos(cosThetaTh),pTrk->GetHMPIDsignal(),TMath::Sqrt(pTrk->GetHMPIDchi2()),kTRUE);      
       else             //beta < 1/ref. idx. => no light at all  
         h[iPart] =0 ;       
       hTot    +=h[iPart]; //total height of all theoretical heights for normalization
@@ -185,6 +182,5 @@ void AliHMPIDReconstructor::FillESD(AliRunLoader *, AliESD *pESD) const
         pid[iPart]=1.0/AliPID::kSPECIES; 
     pTrk->SetHMPIDpid(pid);
   }//ESD tracks loop
-  //last line is to check if the nearest thetacerenkov to the teorethical one is within 5 sigma, otherwise no response (equal prob to every particle
-}//FillESD
+}//FillESD()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
index 03a73943affba435d15dc60e70a74cba9e722f53..9491632dc5db5413bd84100b4cb36282105d6662 100644 (file)
@@ -1,4 +1,353 @@
-Hdisp()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void SimEsd(AliESD *pEsd)
+{
+  TParticle part; TLorentzVector mom;
+  for(Int_t iTrk=0;iTrk<25;iTrk++){//stack loop
+    part.SetPdgCode(kProton);
+    part.SetProductionVertex(0,0,0,0);  
+    Double_t eta= -0.4+gRandom->Rndm()*0.8; //rapidity is random [-0.4,+0.4]
+    Double_t phi= gRandom->Rndm()*1.4;      //phi is random      [ 0  , 80 ] degrees    
+    mom.SetPtEtaPhiM(2,eta,phi,part.GetMass());
+    part.SetMomentum(mom);
+    AliESDtrack trk(&part);
+    pEsd->AddTrack(&trk);
+  }//stack loop  
+}//EsdFromStack()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void EsdFromStack(AliESD *pEsd)
+{
+  al->LoadHeader();al->LoadKinematics();
+  AliStack *pStk=al->Stack();  
+  
+  for(Int_t iTrk=0;iTrk<pStk->GetNtrack();iTrk++){//stack loop
+    TParticle *pPart=pStk->Particle(iTrk);
+    if(pPart->GetPDG()->Charge()==0) continue; //neutral particles are not reconstructed
+    if(pPart->GetFirstMother()>0)    continue; //do not consider secondaries
+    AliESDtrack trk(pPart);
+    pEsd->AddTrack(&trk);
+  }//stack loop  
+}//EsdFromStack()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void HitsFromEsd(AliESD *pEsd, TClonesArray *pHitLst)
+{
+  AliHMPIDRecon rec;
+  const Int_t kCerenkov=50000050,kFeedback=50000051;
+  Int_t hc=0; TVector2 pos;
+  for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
+    AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
+    Float_t xRa,yRa;
+    Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
+    if(ch<0) continue; //this track does not hit HMPID
+    Float_t ckov=0.63;
+
+    Float_t th,ph,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,th,ph); rec.SetTrack(xRa,yRa,th,ph); 
+    
+    if(!AliHMPIDDigit::IsInDead(xPc,yPc)) new((*pHitLst)[hc++]) AliHMPIDHit(ch,200e-9,kProton  ,iTrk,xPc,yPc);                 //mip hit
+    for(int i=0;i<4;i++)  new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kFeedback,iTrk,gRandom->Rndm()*130,gRandom->Rndm()*126); //bkg hits 4 per track
+    for(int i=0;i<16;i++){
+      rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi(),pos);
+      new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());
+    }                      //photon hits  
+  }//tracks loop    
+}//HitsFromEsd()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void DrawSeg()
+{
+  TCanvas *pC=new TCanvas("seg","Segmentation as seen from electronics side");
+  DrawPc(1);
+
+  pC->ToggleEventStatus();
+  pC->SetEditable(0);
+  pC->AddExec("status","DrawStatus()");
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void DrawStatus()
+{// Show info about current cursur position in status bar of the canvas
+//  Printf("event %i",gPad->GetEvent()); return;
+  TPad *pad=gPad;
+  TCanvas *pC=(TCanvas*)pad; 
+  TRootCanvas *pRC= (TRootCanvas*)pC->GetCanvasImp();
+  TGStatusBar *pBar=pRC->GetStatusBar();
+  pBar->SetParts(5);
+  Float_t x=pad->AbsPixeltoX(pad->GetEventX()); Float_t y=pad->AbsPixeltoY(pad->GetEventY());
+  if(AliHMPIDDigit::IsInDead(x,y))
+    pBar->SetText("Out of sensitive area",4);    
+  else{
+    Int_t pc,px,py,w32,ddl,r,d,a;  AliHMPIDDigit::Lors2Pad(x,y,pc,px,py); AliHMPIDDigit dig; dig.Set(1,pc,px,py); dig.Raw(w32,ddl,r,d,a);
+    pBar->SetText(Form("(pc%i,px%i,py%i) (r%i,d%i,a%i) (%.2f,%.2f)",
+                         pc  ,px  ,py,    r  ,d  ,a   ,dig.LorsX(),dig.LorsY()),4);
+  }    
+//  if(pad->GetEvent()==1){
+//    new TCanvas("zoom",Form("Row %i DILOGIC %i",dig.Row(),dig.Dilogic()));  
+//  }
+}//DrawStatus()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void DrawPc(Bool_t isFill) 
+{ 
+  gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5); 
+  
+    
+  Float_t dX2=0.5*AliHMPIDDigit::SizePadX(),
+          dY2=0.5*AliHMPIDDigit::SizePadY() ;
+  
+  TLatex txt; txt.SetTextSize(0.01);
+  TLine *pL;
+  
+  AliHMPIDDigit dig;   UInt_t w32; Int_t ddl,r,d,a;    
+  
+  for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++){
+    TBox *pBox=new TBox(AliHMPIDDigit::fMinPcX[iPc],AliHMPIDDigit::fMinPcY[iPc],
+                        AliHMPIDDigit::fMaxPcX[iPc],AliHMPIDDigit::fMaxPcY[iPc]);
+    
+    if(iPc==0||iPc==2||iPc==4) pBox->SetFillColor(29);
+    else                       pBox->SetFillColor(41);
+    pBox->Draw();
+    
+    if(!isFill)  continue;
+    
+//    if(iPc%2) {dig.Set(0,iPc,79,25); txt.DrawText(dig.LorsX()+2,dig.LorsY(),Form("PC%i",dig.Pc()));}//print PC#    
+
+    txt.SetTextAlign(32);
+    for(Int_t iRow=0;iRow<8 ;iRow++){//draw row lines (horizontal)
+      dig.Set(0,iPc,0,iRow*6); dig.Raw(w32,ddl,r,d,a);  //set digit to the left-down pad of this row
+      
+      if(iPc%2) txt.DrawText(dig.LorsX()-1           ,dig.LorsY(),Form("%i",dig.PadPcY()));                  //print PadY#    
+                txt.DrawText(dig.LorsX()-1+(iPc%2)*67,dig.LorsY()+2,Form("r%i",r));                          //print Row#    
+      pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()+AliHMPIDDigit::SizePcX()-dX2,dig.LorsY()-dY2);//draw horizontal line 
+      if(iRow!=0) pL->Draw(); 
+    }//row loop  
+    
+    txt.SetTextAlign(13);
+    for(Int_t iDil=0;iDil<10;iDil++){//draw dilogic lines (vertical)
+      dig.Set(0,iPc,iDil*8,0); dig.Raw(w32,ddl,r,d,a);       //set this digit to the left-down pad of this dilogic        
+      
+                           txt.DrawText(dig.LorsX()  ,dig.LorsY()-1,Form("%i",dig.PadPcX()));                 //print PadX# 
+      if(iPc==4 || iPc==5) txt.DrawText(dig.LorsX()+2,dig.LorsY()+42,Form("d%i",d));              //print Dilogic#    
+      pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()-dX2,dig.LorsY()+AliHMPIDDigit::SizePcY()-dY2); //draw vertical line
+      if(iDil!=0)pL->Draw();
+    }//dilogic loop        
+  }//PC loop      
+}//DrawPc()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void Close_hed()
+{
+  TCanvas *pC = ((TCanvas*)gROOT->FindObject("hed"));if(!pC) return;
+  pC->Close();
+  pC=0x0;
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void ReadHits(TClonesArray *pHitLst)
+{
+  pHitLst->Delete();  Int_t cnt=0;
+  for(Int_t iEnt=0;iEnt<hl->TreeH()->GetEntries();iEnt++){       //TreeH loop
+    hl->TreeH()->GetEntry(iEnt);                                 //get current entry (prim)                
+    for(Int_t iHit=0;iHit<h->Hits()->GetEntries();iHit++){       //hits loop
+      AliHMPIDHit *pHit = (AliHMPIDHit*)h->Hits()->At(iHit);     //get current hit        
+      new((*pHitLst)[cnt++]) AliHMPIDHit(*pHit);
+    }//hits loop for this entry
+  }//tree entries loop
+  
+}//ReadHits()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void sed()
+{
+
+  static TCanvas *pC1=0;
+  
+  if(!pC1){
+    pC1=new TCanvas("hed","Simulated evets-View from electronics side, IP is behind the picture.",1000,900); pC1->Divide(3,3);
+    pC1->cd(7); TButton *pBtn=new TButton("Next","sed()",0,0,0.2,0.1);   pBtn->Draw(); 
+    pC1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, "","zoom(Int_t,Int_t,Int_t,TObject*)");
+  }
+
+  TClonesArray lh("AliHMPIDHit"); 
+  TClonesArray ls("AliHMPIDDigit"); 
+  TObjArray    ld(7); for(Int_t i=0;i<7;i++) ld.AddAt(new TClonesArray("AliHMPIDDigit"),i);
+  TObjArray    lc(7); for(Int_t i=0;i<7;i++) lc.AddAt(new TClonesArray("AliHMPIDCluster"),i);
+  AliESD esd;
+  
+  
+  SimEsd(&esd);
+  HitsFromEsd(&esd,&lh);
+             AliHMPIDv1::Hit2Sdi(&lh,&ls);                               
+      AliHMPIDDigitizer::Sdi2Dig(&ls,&ld);     
+  AliHMPIDReconstructor::Dig2Clu(&ld,&lc);
+//        AliHMPIDTracker::Recon(&esd,&cl);
+  
+  DrawEvt(pC1,&lh,&ld,&lc,&esd);  
+}//SimEvt()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void zoom(Int_t evt, Int_t pixx, Int_t pixy, TObject *obj)
+{
+  Printf("pad %i",gPad->GetNumber());
+  static Int_t lvl=32; //zoom level
+  if(evt!=5 && evt!=6) return;
+  if(evt==5&&lvl==2)  return; //max zoom in
+  if(evt==6&&lvl==32) return; //max zoom out
+  
+  Float_t x=gPad->AbsPixeltoX(pixx); Float_t y=gPad->AbsPixeltoY(pixy); 
+             
+  if(evt==5){ lvl=lvl/2; gPad->Range(x-lvl*2,y-lvl*2,x+lvl*2,y+lvl*2);} //zoom in
+  else      { lvl=32;    gPad->Range(-10,-10,150,140); } //zoom out 
+  ((TCanvas *)gTQSender)->SetTitle(Form("zoom %i",lvl));
+  gPad->Modified();
+  gPad->Update();                                              
+}
+void hed()
+{//event display from files
+  static TCanvas *pC=0;
+  static Int_t iEvt=0;
+  static Int_t iEvtTot=999;
+  static TFile *pEsdFl=0;
+  static TTree *pEsdTr=0;
+  static AliESD *pEsd=0;
+  
+  
+
+  
+  if(!pC&&iEvt<iEvtTot){
+    iEvt=0;
+    iEvtTot=999;
+    if(hl==0) {Printf("hed: no HMPID loader");return;}
+    Printf("Opening session");
+    pEsdFl=TFile::Open("AliESDs.root");     if(!pEsdFl || !pEsdFl->IsOpen()) return;//open AliESDs.root
+    pEsdTr=(TTree*) pEsdFl->Get("esdTree"); if(!pEsdTr)                      return;//get ESD tree
+    pEsdTr->SetBranchAddress("ESD", &pEsd);
+    hl->LoadHits(); hl->LoadDigits(); hl->LoadRecPoints();
+    iEvtTot=pEsdTr->GetEntries();
+    pC=new TCanvas("hed","View from electronics side, IP is behind the picture.",1000,900);  pC->ToggleEventStatus(); pC->Divide(3,3);
+    pC->cd(7); TButton *pBtn=new TButton("Next","hed()",0,0,0.2,0.1);   pBtn->Draw();
+    pC->cd(7); TButton *pBtn=new TButton("Quit","Close_hed()",0.2,0,0.4,0.1);   pBtn->Draw(); 
+    new TGedEditor(pC);
+  }
+  TLatex txt; txt.SetTextSize(0.1);
+  TClonesArray hits("AliHMPIDHit");
+      
+  if(iEvt<iEvtTot){
+    pEsdTr->GetEntry(iEvt); al->GetEvent(iEvt); 
+    hl->TreeD()->GetEntry(0); hl->TreeR()->GetEntry(0);
+    ReadHits(&hits); 
+     
+    pC->cd(3);  gPad->Clear(); txt.DrawLatex(0.2,0.2,Form("Event %i (total %i)",iEvt,iEvtTot));
+    DrawEvt(pC,&hits,h->DigLst(),h->CluLst(),pEsd);
+    
+    iEvt++;
+  }else{
+    Printf("--- No more events available...Bye.");
+    pC->Close();
+    pC=0x0;
+    iEvt=0;
+    iEvtTot=999;
+  }
+}//hed()
+
+
+
+
+
+
+
+
+
+
+
+
+
+void DrawEvt(TCanvas *pC,TClonesArray *pHitLst,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
+{//draws all the objects of current event in given canvas
+
+  AliHMPIDRecon rec;  
+  TPolyMarker *pTxC[7];  TPolyMarker *pRin[7]; //intesections and rings
+  for(Int_t ch=0;ch<7;ch++){
+    pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
+    pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
+  }
+  
+  
+  for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
+    AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
+    Int_t ch=pTrk->GetHMPIDcluIdx();
+    if(ch<0) continue; //this track does not hit HMPID
+    ch/=1000000; 
+    Float_t th,ph,xPc,yPc; pTrk->GetHMPIDtrk(xPc,yPc,th,ph);  //get info on current track
+    pTxC[ch]->SetNextPoint(xPc,yPc);                          //add new intersection point
+    
+    Float_t ckov=pTrk->GetHMPIDsignal();  Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
+    
+    if(ckov>0){
+      rec.SetTrack(xPc,yPc,th,ph);
+     TVector2 pos;  for(int j=0;j<100;j++){rec.TracePhot(ckov,j*0.0628,pos); pRin[ch]->SetNextPoint(pos.X(),pos.Y());}      
+    }
+  }//tracks loop
+      
+  for(Int_t iCh=0;iCh<7;iCh++){//chambers loop    
+    switch(iCh){
+      case 6: pC->cd(1); break; case 5: pC->cd(2); break;
+      case 4: pC->cd(4); break; case 3: pC->cd(5); break; case 2: pC->cd(6); break;
+                                case 1: pC->cd(8); break; case 0: pC->cd(9); break;
+    }
+    gPad->SetEditable(kTRUE); gPad->Clear(); 
+    DrawPc(0);
+    for(Int_t iHit=0;iHit<pHitLst->GetEntries();iHit++){
+      AliHMPIDHit *pHit=(AliHMPIDHit*)pHitLst->At(iHit);
+      if(pHit->Ch()==iCh)        pHit->Draw();  //draw hits
+    }
+    ((TClonesArray*)pDigLst->At(iCh))->Draw();  //draw digits
+    ((TClonesArray*)pCluLst->At(iCh))->Draw();  //draw clusters
+                            pTxC[iCh]->Draw();  //draw intersections
+                            pRin[iCh]->Draw();  //draw rings
+    gPad->SetEditable(kFALSE);
+  }//chambers loop
+  
+  
+//  TLatex txt; txt.SetTextSize(0.02);
+//  txt.DrawLatex(20,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,simCkov,simErr,simN));
+//  txt.DrawLatex(25,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,recCkov,recErr,recN));
+//  txt.DrawLatex(0 ,127,Form("#theta=%.2f#circ   #phi=%.2f#circ @(%.2f,%.2f) ",th*TMath::RadToDeg(),ph*TMath::RadToDeg(),radx,rady));
+//  Printf("DIG------DIG---------DIG--------DIG------DIG------DIG");pDigLst->Print();Printf("");                   
+}//DrawEvt()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Reve()
 {
   gSystem->Load("libMinuit.so");
   gSystem->Load("libVMC.so");
@@ -47,3 +396,24 @@ Hdisp()
   gReve->AddRenderElement(pHitPnt);
   gReve->Redraw3D();
 }
+
+
+
+void zzz(Int_t evt,Int_t px,Int_t py,TObject*o)
+{
+  Printf("evt %i (%i,%i) class %s",evt,px,py,o->IsA()->ClassName());
+}
+
+void Gui()
+{
+  TGMainFrame   *pMF     =new TGMainFrame(gClient->GetRoot(),300,400);//main frame
+//1 level widgets: button and 2 horizontal frames  
+  TRootEmbeddedCanvas *pDis;
+  pMF->AddFrame(pDis=new TRootEmbeddedCanvas("display",pMF,800,650));
+  pDis->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, "","zzz(Int_t,Int_t,Int_t,TObject*)");
+  
+  pMF->Layout();
+  pMF->MapSubwindows();
+  pMF->Resize(pMF->GetDefaultSize());
+  pMF->MapWindow();
+}                                                                      
index df24aea3f3a2439afd4b735aecb768ec1107752d..a867113478c24c0d45bcef2902823c23323b3541 100644 (file)
@@ -167,253 +167,8 @@ void PrintMap()
            ch,   pc,  px,   py,     ddl,   raw,      r,    d,    a); dd.Print(); 
   ddl=7;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=1;
 }//PrintMap()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void DrawSeg()
-{
-  TCanvas *pC=new TCanvas("seg","Segmentation as seen from electronics side");
-  DrawPc(1);
-  new TGedEditor(pC);
-  pC->ToggleEventStatus();
-  pC->SetEditable(0);
-  pC->AddExec("status","DrawStatus()");
-}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void DrawStatus()
-{// Show info about current cursur position in status bar of the canvas
-//  Printf("event %i",gPad->GetEvent()); return;
-  TPad *pad=gPad;
-  TCanvas *pC=(TCanvas*)pad; 
-  TRootCanvas *pRC= (TRootCanvas*)pC->GetCanvasImp();
-  TGStatusBar *pBar=pRC->GetStatusBar();
-  pBar->SetParts(5);
-  Float_t x=pad->AbsPixeltoX(pad->GetEventX()); Float_t y=pad->AbsPixeltoY(pad->GetEventY());
-  if(AliHMPIDDigit::IsInDead(x,y))
-    pBar->SetText("Out of sensitive area",4);    
-  else{
-    Int_t pc,px,py,w32,ddl,r,d,a;  AliHMPIDDigit::Lors2Pad(x,y,pc,px,py); AliHMPIDDigit dig; dig.Set(1,pc,px,py); dig.Raw(w32,ddl,r,d,a);
-    pBar->SetText(Form("(pc%i,px%i,py%i) (r%i,d%i,a%i) (%.2f,%.2f)",
-                         pc  ,px  ,py,    r  ,d  ,a   ,dig.LorsX(),dig.LorsY()),4);
-  }    
-//  if(pad->GetEvent()==1){
-//    new TCanvas("zoom",Form("Row %i DILOGIC %i",dig.Row(),dig.Dilogic()));  
-//  }
-}//DrawStatus()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void DrawPc(Bool_t isFill) 
-{ 
-  gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5); 
-  
-    
-  Float_t dX2=0.5*AliHMPIDDigit::SizePadX(),
-          dY2=0.5*AliHMPIDDigit::SizePadY() ;
-  
-  TLatex txt; txt.SetTextSize(0.01);
-  TLine *pL;
-  
-  AliHMPIDDigit dig;   UInt_t w32; Int_t ddl,r,d,a;    
-  
-  for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++){
-    TBox *pBox=new TBox(AliHMPIDDigit::fMinPcX[iPc],AliHMPIDDigit::fMinPcY[iPc],
-                        AliHMPIDDigit::fMaxPcX[iPc],AliHMPIDDigit::fMaxPcY[iPc]);
-    
-    if(iPc==0||iPc==2||iPc==4) pBox->SetFillColor(29);
-    else                       pBox->SetFillColor(41);
-    pBox->Draw();
-    
-    if(!isFill)  continue;
-    
-//    if(iPc%2) {dig.Set(0,iPc,79,25); txt.DrawText(dig.LorsX()+2,dig.LorsY(),Form("PC%i",dig.Pc()));}//print PC#    
 
-    txt.SetTextAlign(32);
-    for(Int_t iRow=0;iRow<8 ;iRow++){//draw row lines (horizontal)
-      dig.Set(0,iPc,0,iRow*6); dig.Raw(w32,ddl,r,d,a);  //set digit to the left-down pad of this row
-      
-      if(iPc%2) txt.DrawText(dig.LorsX()-1           ,dig.LorsY(),Form("%i",dig.PadPcY()));                  //print PadY#    
-                txt.DrawText(dig.LorsX()-1+(iPc%2)*67,dig.LorsY()+2,Form("r%i",r));                          //print Row#    
-      pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()+AliHMPIDDigit::SizePcX()-dX2,dig.LorsY()-dY2);//draw horizontal line 
-      if(iRow!=0) pL->Draw(); 
-    }//row loop  
-    
-    txt.SetTextAlign(13);
-    for(Int_t iDil=0;iDil<10;iDil++){//draw dilogic lines (vertical)
-      dig.Set(0,iPc,iDil*8,0); dig.Raw(w32,ddl,r,d,a);       //set this digit to the left-down pad of this dilogic        
-      
-                           txt.DrawText(dig.LorsX()  ,dig.LorsY()-1,Form("%i",dig.PadPcX()));                 //print PadX# 
-      if(iPc==4 || iPc==5) txt.DrawText(dig.LorsX()+2,dig.LorsY()+42,Form("d%i",d));              //print Dilogic#    
-      pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()-dX2,dig.LorsY()+AliHMPIDDigit::SizePcY()-dY2); //draw vertical line
-      if(iDil!=0)pL->Draw();
-    }//dilogic loop        
-  }//PC loop      
-}//DrawPc()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void hed()
-{//event display from files
-  static TCanvas *pC=0;
-  static Int_t iEvt=0;
-  static Int_t iEvtTot=999;
-  static TFile *pEsdFl=0;
-  static TTree *pEsdTr=0;
-  static AliESD *pEsd=0;
-  
-  
-
-  
-  if(!pC&&iEvt<iEvtTot){
-    iEvt=0;
-    iEvtTot=999;
-    if(hl==0) {Printf("hed: no HMPID loader");return;}
-    Printf("Opening session");
-    pEsdFl=TFile::Open("AliESDs.root");     if(!pEsdFl || !pEsdFl->IsOpen()) return;//open AliESDs.root
-    pEsdTr=(TTree*) pEsdFl->Get("esdTree"); if(!pEsdTr)                      return;//get ESD tree
-    pEsdTr->SetBranchAddress("ESD", &pEsd);
-    hl->LoadHits(); hl->LoadDigits(); hl->LoadRecPoints();
-    iEvtTot=pEsdTr->GetEntries();
-    pC=new TCanvas("hed","View from electronics side, IP is behind the picture.",1000,900);  pC->ToggleEventStatus(); pC->Divide(3,3);
-    pC->cd(7); TButton *pBtn=new TButton("Next","hed()",0,0,0.2,0.1);   pBtn->Draw();
-    pC->cd(7); TButton *pBtn=new TButton("Quit","Close_hed()",0.2,0,0.4,0.1);   pBtn->Draw(); 
-    new TGedEditor(pC);
-  }
-  TLatex txt; txt.SetTextSize(0.1);
-  TClonesArray hits("AliHMPIDHit");
-      
-  if(iEvt<iEvtTot){
-    pEsdTr->GetEntry(iEvt); al->GetEvent(iEvt); 
-    hl->TreeD()->GetEntry(0); hl->TreeR()->GetEntry(0);
-    ReadHits(&hits); 
-     
-    pC->cd(3);  gPad->Clear(); txt.DrawLatex(0.2,0.2,Form("Event %i (total %i)",iEvt,iEvtTot));
-    DrawEvt(pC,&hits,h->DigLst(),h->CluLst(),pEsd);
-    
-    iEvt++;
-  }else{
-    Printf("--- No more events available...Bye.");
-    pC->Close();
-    pC=0x0;
-    iEvt=0;
-    iEvtTot=999;
-  }
-}//hed()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void Close_hed()
-{
-  TCanvas *pC = ((TCanvas*)gROOT->FindObject("hed"));if(!pC) return;
-  pC->Close();
-  pC=0x0;
-}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void ReadHits(TClonesArray *pHitLst)
-{
-  pHitLst->Delete();  Int_t cnt=0;
-  for(Int_t iEnt=0;iEnt<hl->TreeH()->GetEntries();iEnt++){       //TreeH loop
-    hl->TreeH()->GetEntry(iEnt);                                 //get current entry (prim)                
-    for(Int_t iHit=0;iHit<h->Hits()->GetEntries();iHit++){       //hits loop
-      AliHMPIDHit *pHit = (AliHMPIDHit*)h->Hits()->At(iHit);     //get current hit        
-      new((*pHitLst)[cnt++]) AliHMPIDHit(*pHit);
-    }//hits loop for this entry
-  }//tree entries loop
-  
-}//ReadHits()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void sed()
-{
-
-  static TCanvas *pC1=0;
-  
-  if(!pC1){
-    pC1=new TCanvas("hed","Simulated evets-View from electronics side, IP is behind the picture.",1000,900); pC1->Divide(3,3);
-    pC1->cd(7); TButton *pBtn=new TButton("Next","sed()",0,0,0.2,0.1);   pBtn->Draw(); 
-  }
-
-
-  
-  AliHMPIDRecon rec;  
-
-  TClonesArray lh("AliHMPIDHit"); 
-  TClonesArray ls("AliHMPIDDigit"); 
-  TObjArray    ld(7); for(Int_t i=0;i<7;i++) ld.AddAt(new TClonesArray("AliHMPIDDigit"),i);
-  TObjArray    lc(7); for(Int_t i=0;i<7;i++) lc.AddAt(new TClonesArray("AliHMPIDCluster"),i);
-  AliESD esd;
-  
-  
-  SimEsd(&esd);
-  HitsFromEsd(&esd,&lh);
-  
-
-
-
-             AliHMPIDv1::Hit2Sdi(&lh,&ls);                               
-      AliHMPIDDigitizer::Sdi2Dig(&ls,&ld);     
-  AliHMPIDReconstructor::Dig2Clu(&ld,&lc);
-//        AliHMPIDTracker::Recon(&esd,&cl);
-  
-  DrawEvt(pC1,&lh,&ld,&lc,&esd);  
-}//SimEvt()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void DrawEvt(TCanvas *pC,TClonesArray *pHitLst,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
-{//draws all the objects of current event
-
-  AliHMPIDRecon rec;  
-  TPolyMarker *pTxC[7];  TPolyMarker *pRin[7]; //intesections and rings
-  for(Int_t ch=0;ch<7;ch++){
-    pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
-    pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
-  }
-  
-  
-  for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
-    AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
-    Int_t ch=pTrk->GetHMPIDcluIdx();
-    if(ch<0) continue; //this track does not hit HMPID
-    ch/=1000000; 
-    Float_t th,ph,xPc,yPc; pTrk->GetHMPIDtrk(xPc,yPc,th,ph);  //get info on current track
-    pTxC[ch]->SetNextPoint(xPc,yPc);                          //add new intersection point
-    
-    Float_t ckov=pTrk->GetHMPIDsignal();  Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
-    
-    if(ckov>0){
-      rec.SetTrack(xPc,yPc,th,ph);
-     TVector2 pos;  for(int j=0;j<100;j++){rec.TracePhot(ckov,j*0.0628,pos); pRin[ch]->SetNextPoint(pos.X(),pos.Y());}      
-    }
-  }//tracks loop
-      
-  for(Int_t iCh=0;iCh<7;iCh++){//chambers loop    
-    switch(iCh){
-      case 6: pC->cd(1); break; case 5: pC->cd(2); break;
-      case 4: pC->cd(4); break; case 3: pC->cd(5); break; case 2: pC->cd(6); break;
-                                case 1: pC->cd(8); break; case 0: pC->cd(9); break;
-    }
-    gPad->SetEditable(kTRUE); gPad->Clear();
-    DrawPc(0);
-    for(Int_t iHit=0;iHit<pHitLst->GetEntries();iHit++){
-      AliHMPIDHit *pHit=(AliHMPIDHit*)pHitLst->At(iHit);
-      if(pHit->Ch()==iCh)        pHit->Draw();  //draw hits
-    }
-    ((TClonesArray*)pDigLst->At(iCh))->Draw();  //draw digits
-    ((TClonesArray*)pCluLst->At(iCh))->Draw();  //draw clusters
-                            pTxC[iCh]->Draw();  //draw intersections
-                            pRin[iCh]->Draw();  //draw rings
-    gPad->SetEditable(kFALSE);
-//    gPad->AddExec("zoom","DrawZoom()");
-  }//chambers loop
-  
-  
-//  TLatex txt; txt.SetTextSize(0.02);
-//  txt.DrawLatex(20,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,simCkov,simErr,simN));
-//  txt.DrawLatex(25,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,recCkov,recErr,recN));
-//  txt.DrawLatex(0 ,127,Form("#theta=%.2f#circ   #phi=%.2f#circ @(%.2f,%.2f) ",th*TMath::RadToDeg(),ph*TMath::RadToDeg(),radx,rady));
-//  Printf("DIG------DIG---------DIG--------DIG------DIG------DIG");pDigLst->Print();Printf("");                   
-}//DrawEvt()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void DrawZoom()
-{
-  TPad *pad=gPad;  Float_t x=gPad->AbsPixeltoX(pad->GetEventX()); Float_t y=gPad->AbsPixeltoY(pad->GetEventY());
-  TCanvas *zoom = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("zoom");
-  if(!zoom) zoom=new TCanvas("zoom","");
-  zoom->SetTitle(Form("Zoom view around %.2f %.2f",x,y));
-  gPad->Range(x-20,y-20,x+20,y+20);
-  zoom->Update();
-}
 void t1(Int_t case=1)
 {
   AliHMPIDDigit *d[10]; for(Int_t i=0;i<10;i++) d[i]=new AliHMPIDDigit;
@@ -445,59 +200,7 @@ void t1(Int_t case=1)
   
   cl->Print();  
 }//t1()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void SimEsd(AliESD *pEsd)
-{
-  TParticle part; TLorentzVector mom;
-  for(Int_t iTrk=0;iTrk<25;iTrk++){//stack loop
-    part.SetPdgCode(kProton);
-    part.SetProductionVertex(0,0,0,0);  
-    Double_t eta= -0.4+gRandom->Rndm()*0.8; //rapidity is random [-0.4,+0.4]
-    Double_t phi= gRandom->Rndm()*1.4;      //phi is random      [ 0  , 80 ] degrees    
-    mom.SetPtEtaPhiM(2,eta,phi,part.GetMass());
-    part.SetMomentum(mom);
-    AliESDtrack trk(&part);
-    pEsd->AddTrack(&trk);
-  }//stack loop  
-}//EsdFromStack()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void EsdFromStack(AliESD *pEsd)
-{
-  al->LoadHeader();al->LoadKinematics();
-  AliStack *pStk=al->Stack();  
-  
-  for(Int_t iTrk=0;iTrk<pStk->GetNtrack();iTrk++){//stack loop
-    TParticle *pPart=pStk->Particle(iTrk);
-    if(pPart->GetPDG()->Charge()==0) continue; //neutral particles are not reconstructed
-    if(pPart->GetFirstMother()>0)    continue; //do not consider secondaries
-    AliESDtrack trk(pPart);
-    pEsd->AddTrack(&trk);
-  }//stack loop  
-}//EsdFromStack()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void HitsFromEsd(AliESD *pEsd, TClonesArray *pHitLst)
-{
-  AliHMPIDRecon rec;
-  const Int_t kCerenkov=50000050,kFeedback=50000051;
-  Int_t hc=0; TVector2 pos;
-  for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
-    AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
-    Float_t xRa,yRa;
-    Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
-    if(ch<0) continue; //this track does not hit HMPID
-    Float_t ckov=0.63;
-
-    Float_t th,ph,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,th,ph); rec.SetTrack(xRa,yRa,th,ph); 
-    
-    if(!AliHMPIDDigit::IsInDead(xPc,yPc)) new((*pHitLst)[hc++]) AliHMPIDHit(ch,200e-9,kProton  ,iTrk,xPc,yPc);                 //mip hit
-//    for(int i=0;i<4;i++)  new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kFeedback,iTrk,gRandom->Rndm()*130,gRandom->Rndm()*126); //bkg hits 4 per track
-//    for(int i=0;i<16;i++){
-//      rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi(),pos);
-//                          new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());}                      //photon hits  
-  }//tracks loop    
-}//HitsFromEsd()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void tst(Int_t nEvts=10000,Int_t type=999)
+void tst(Int_t nEvts=111,Int_t type=999)
 {
   
   TLegend *lQ=new TLegend(0.5,0.5,0.9,0.9);
@@ -512,15 +215,13 @@ void tst(Int_t nEvts=10000,Int_t type=999)
   TH1F *hCluFlg   =new TH1F("hCluFlg","Cluster flag",14,-1.5,12.5);                       hCluFlg->SetFillColor(5);
   TH1F *hCluRawSize= new TH1F("hCluRawSize","Raw cluster size ",100,0,100);
   
-  TH2F *pCluMapSi1=new TH2F("cluMSi1","Size 1 map",1700,-10,160,1700,-10,160);           
-  TH2F *pCluMapLo1=new TH2F("cluMLo1","Loc Max 1 map",1700,-10,160,1700,-10,160);        
-  TH2F *pCluMapEmp=new TH2F("cluMEmp","Should be empty",1700,-10,160,1700,-10,160);      
-  TH2F *pCluMapUnf=new TH2F("cluMUnf","Unfolded map",1700,-10,160,1700,-10,160);         
-  TH2F *pCluMapMax=new TH2F("cluMMax","Max Loc Max map",1700,-10,160,1700,-10,160);     
-  TH2F *pCluMapAbn=new TH2F("cluMAbn","Fit failed map",1700,-10,160,1700,-10,160);      
-  TH2F *pCluMapEdg=new TH2F("cluMEdg","On edge map",1700,-10,160,1700,-10,160);         
-  TH2F *pCluMapNoLoc=new TH2F("cluMNoLoc","No Loc  map",1700,-10,160,1700,-10,160);     
-  TH2F *pCluMapCoG=new TH2F("cluMCoG","CoG  map",1700,-10,160,1700,-10,160);            
+  TH2F *pCluMapSi1=new TH2F("cluMapSi1","Size 1 map"       ,1700,-10,160,1700,-10,160);           
+  TH2F *pCluMapLo0=new TH2F("cluMNoLo0","Loc Max 0 map"    ,1700,-10,160,1700,-10,160);     
+  TH2F *pCluMapLo1=new TH2F("cluMapLo1","Loc Max 1 map"    ,1700,-10,160,1700,-10,160);        
+  TH2F *pCluMapUnf=new TH2F("cluMapUnf","Unfolded map"     ,1700,-10,160,1700,-10,160);         
+  TH2F *pCluMapEdg=new TH2F("cluMapEdg","On edge map"      ,1700,-10,160,1700,-10,160);         
+  TH2F *pCluMapCoG=new TH2F("cluMapCoG","CoG  map"         ,1700,-10,160,1700,-10,160);            
+  TH2F *pCluMapEmp=new TH2F("cluMapEmp","undefined-empty"  ,1700,-10,160,1700,-10,160);      
 
   TH1F *hHitCluDifX = new TH1F("hHitCluDifX" ,";entries;x_{Hit}-x_{Clu} [cm]"   ,2000,-2,2);          hHitCluDifX->Sumw2();    hHitCluDifX->SetFillColor(kYellow);
   TH1F *hHitCluDifY = new TH1F("hHitCluDifY" ,";entries;y_{Hit}-y_{Clu} [cm]"   ,2000,-2,2);          hHitCluDifY->Sumw2();    hHitCluDifY->SetFillColor(kYellow);
@@ -529,18 +230,21 @@ void tst(Int_t nEvts=10000,Int_t type=999)
  
   Float_t e200=200e-9,e500=500e-9,e900=900e-9,e7=7e-9;//predefined  Eloss
   
+  
   AliHMPIDHit hit(0,0,kProton,0,0,0);
+  for(int i=0;i<10000;i++){hQ200->Fill(hit.QdcTot(e200));  hQ500->Fill(hit.QdcTot(e500));   hQ900->Fill(hit.QdcTot(e900));  hQ7  ->Fill(hit.QdcTot(e7));}
+  
   TClonesArray hits("AliHMPIDHit");  TClonesArray sdigs("AliHMPIDDigit");
   TObjArray digs(7); for(Int_t i=0;i<7;i++) digs.AddAt(new TClonesArray("AliHMPIDDigit"),i);
   TObjArray clus(7); for(Int_t i=0;i<7;i++) clus.AddAt(new TClonesArray("AliHMPIDCluster"),i);
   
     
   for(Int_t iEvt=0;iEvt<nEvts;iEvt++){//events loop
-    Printf("============> iEvt = %d ",iEvt);
-    Int_t nHits=(type==999)?1:40;
+    if(iEvt%500==0)Printf("============> iEvt = %d ",iEvt);
+    
     Int_t ch,pid; Float_t e,hitx,hity,hitq;
+    Int_t nHits=(type==999)?1:40;
     for(Int_t iHit=0;iHit<nHits;iHit++){//hits loop for the current event
-      Printf("In loop");
       switch(iHit){
         case 0:  ch=0;pid=kProton;e=e200;hitx=16.0+gRandom->Rndm()*0.8;hity= 16.8+gRandom->Rndm()*0.84;break; //mip ramdomly distributed in one pad in the middle
         case 1:  ch=0;pid=kProton;e=e200;hitx=0.4;hity=0.42;break; //mip in left-hand bottom coner of chamber 0
@@ -555,14 +259,8 @@ void tst(Int_t nEvts=10000,Int_t type=999)
       }
       new(hits[iHit]) AliHMPIDHit(ch,e,pid,iHit,hitx,hity);                          
       hitq=e;
-      hQ200->Fill(hit.QdcTot(e200));
-      hQ500->Fill(hit.QdcTot(e500));
-      hQ900->Fill(hit.QdcTot(e900));
-      hQ7  ->Fill(hit.QdcTot(e7));
     }//hits loop
     
-    hits.Print();
-                
     AliHMPIDv1::Hit2Sdi(&hits,&sdigs);
     AliHMPIDDigitizer::Sdi2Dig(&sdigs,&digs);     
     AliHMPIDReconstructor::Dig2Clu(&digs,&clus);
@@ -583,7 +281,6 @@ void tst(Int_t nEvts=10000,Int_t type=999)
             case AliHMPIDCluster::kSi1:   pCluMapSi1->Fill(clux,cluy); break;
             case AliHMPIDCluster::kLo1:   pCluMapLo1->Fill(clux,cluy); break;
             case AliHMPIDCluster::kUnf:   pCluMapUnf->Fill(clux,cluy); break; 
-            case AliHMPIDCluster::kAbn:   pCluMapAbn->Fill(clux,cluy); break;
             case AliHMPIDCluster::kMax:   pCluMapMax->Fill(clux,cluy); break;
             case AliHMPIDCluster::kEdg:   pCluMapEdg->Fill(clux,cluy); break;
             case AliHMPIDCluster::kCoG:   pCluMapCoG->Fill(clux,cluy); break;
@@ -594,7 +291,6 @@ void tst(Int_t nEvts=10000,Int_t type=999)
         hHitCluDifX->Fill(hitx-clux); hHitCluDifY->Fill(hity-cluy); hHitCluDifXY->Fill(hitx-clux,hity-cluy); hHitCluDifQ->Fill(hitq-cluq);
         
       }//clusters loop
-      
     }//chambers loop
       
     hits.Delete();  sdigs.Delete();  for(int i = 0;i<7;i++){((TClonesArray*)digs.At(i))->Delete();((TClonesArray*)clus.At(i))->Delete();}
@@ -615,7 +311,6 @@ void tst(Int_t nEvts=10000,Int_t type=999)
   pC1->cd(1);  pCluMapSi1->Draw();  DrawPc(kFALSE);
   pC1->cd(2);  pCluMapLo1->Draw();  DrawPc(kFALSE);
   pC1->cd(3);  pCluMapUnf->Draw();  DrawPc(kFALSE);
-  pC1->cd(4);  pCluMapAbn->Draw();  DrawPc(kFALSE);
   pC1->cd(5);  pCluMapMax->Draw();  DrawPc(kFALSE);
   pC1->cd(6);  pCluMapEdg->Draw(); DrawPc(kFALSE);
   pC1->cd(7);  pCluMapCoG->Draw(); DrawPc(kFALSE);
@@ -702,16 +397,16 @@ void cp(Int_t iEvt=0)
   Printf("totally %i clusters for event %i",iCluCnt,iEvt);
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void Gui()
+
+void ttt()
 {
-  TGMainFrame   *pMF     =new TGMainFrame(gClient->GetRoot(),300,400);//main frame
-//1 level widgets: button and 2 horizontal frames  
-  TGedFrame *pGedF;
-  pMF->AddFrame(pGedF=new TGedFrame(pMF),new TGLayoutHints(kLHintsExpandY));
-  pMF->AddFrame(pDis1=new TGEmbeddedCanvas(pMF,kSunkenFrame));
-  
-  pMF->Layout();
-  pMF->MapSubwindows();
-  pMF->Resize(pMF->GetDefaultSize());
-  pMF->MapWindow();
-}                                                                      
+  TClonesArray hits ("AliHMPIDDigit");
+  TClonesArray sdigs("AliHMPIDDigit");
+  
+  AliHMPIDHit hit(0,45e-9,kProton,33,0,0);
+  hit.Hit2Sdi(&sdigs);
+  sdigs.Print();
+}
+
+
+#include "Hdisp.C"