]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDParam.cxx
Bugs soved by Peter Hristov.
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDParam.cxx
index 1fa574cfc266a12cd1e5c37f0f292f40a224d5be..7afbebfbb05ce175ff97be9cea23fa403445dc70 100644 (file)
 //  **************************************************************************
 #include "AliHMPIDParam.h"  //class header
 #include "AliHMPIDDigit.h"  //ctor
-#include <TCanvas.h>       //TestXXX() 
-#include <TLatex.h>        //TestTrans()  
-#include <TView.h>         //TestTrans()
-#include <TPolyMarker3D.h> //TestTrans()
+#include "AliLog.h"         //general
+#include <AliRunLoader.h>   //Stack()
+#include <AliStack.h>       //Stack()
+#include <TLatex.h>         //TestTrans()  
+#include <TView.h>          //TestTrans()
+#include <TPolyMarker3D.h>  //TestTrans()
 #include <TRotation.h>
-#include <AliRunLoader.h>  //Stack()
-#include <AliStack.h>      //Stack()
-#include <TParticle.h>     //Stack()    
-#include "AliHMPIDHelix.h"  //TestTrans()
-
+#include <TParticle.h>      //Stack()    
+#include <TGeoPhysicalNode.h> //ctor
+#include <TGeoBBox.h>
 ClassImp(AliHMPIDParam)
 
+
+Float_t AliHMPIDParam::fgkMinPcX[]={0.,0.,0.,0.,0.,0.};
+Float_t AliHMPIDParam::fgkMaxPcX[]={0.,0.,0.,0.,0.,0.};
+Float_t AliHMPIDParam::fgkMinPcY[]={0.,0.,0.,0.,0.,0.};
+Float_t AliHMPIDParam::fgkMaxPcY[]={0.,0.,0.,0.,0.,0.};
+
+Float_t AliHMPIDParam::fgCellX=0.;
+Float_t AliHMPIDParam::fgCellY=0.;
+
+Float_t AliHMPIDParam::fgPcX=0;
+Float_t AliHMPIDParam::fgPcY=0;
+
+Float_t AliHMPIDParam::fgAllX=0;
+Float_t AliHMPIDParam::fgAllY=0;
+
+Bool_t AliHMPIDParam::fgInstanceType=kTRUE;  
+
 AliHMPIDParam* AliHMPIDParam::fgInstance=0x0;        //singleton pointer               
+
+Int_t AliHMPIDParam::fgSigmas=4;
+
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-AliHMPIDParam::AliHMPIDParam():TNamed("RichParam","default version") 
+AliHMPIDParam::AliHMPIDParam(Bool_t noGeo=kFALSE):TNamed("HmpidParam","default version") 
 {
 // Here all the intitializition is taken place when AliHMPIDParam::Instance() is invoked for the first time.
-// In particulare, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.    
+// In particular, matrices to be used for LORS<->MARS trasnformations are initialized from TGeo structure.    
 // Note that TGeoManager should be already initialized from geometry.root file  
-  fX=0.5*AliHMPIDDigit::SizeAllX();
-  fY=0.5*AliHMPIDDigit::SizeAllY();
-  for(Int_t i=0;i<7;i++) fM[i]=(TGeoHMatrix*)gGeoManager->GetVolume("ALIC")->GetNode(Form("HMPID_%i",i))->GetMatrix();
+
+
+  fRadNmean = MeanIdxRad(); //initialization of the running ref. index of freon
+  
+  Float_t dead=2.6;// cm of the dead zones between PCs-> See 2CRC2099P1
+
+
+  if(noGeo==kTRUE) fgInstanceType=kFALSE;                                                   //instance from ideal geometry, no actual geom is present
+    
+  if(noGeo==kFALSE && !gGeoManager)  
+  {
+    TGeoManager::Import("geometry.root");
+    if(!gGeoManager) AliFatal("!!!!!!No geometry loaded!!!!!!!");
+  }
+  
+  fgCellX=0.8;fgCellY=0.84;
+  
+  if(!noGeo==kTRUE){
+    TGeoVolume *pCellVol = gGeoManager->GetVolume("Hcel");
+    if(pCellVol) {
+      TGeoBBox *bcell = (TGeoBBox *)pCellVol->GetShape();
+      fgCellX=2.*bcell->GetDX(); fgCellY = 2.*bcell->GetDY();  // overwrite the values with the read ones
+    }
+  }    
+  fgPcX=80.*fgCellX; fgPcY = 48.*fgCellY;
+  fgAllX=2.*fgPcX+dead;
+  fgAllY=3.*fgPcY+2.*dead;
+
+  fgkMinPcX[1]=fgPcX+dead; fgkMinPcX[3]=fgkMinPcX[1];  fgkMinPcX[5]=fgkMinPcX[3];
+  fgkMaxPcX[0]=fgPcX; fgkMaxPcX[2]=fgkMaxPcX[0];  fgkMaxPcX[4]=fgkMaxPcX[2];
+  fgkMaxPcX[1]=fgAllX; fgkMaxPcX[3]=fgkMaxPcX[1];  fgkMaxPcX[5]=fgkMaxPcX[3];
+
+  fgkMinPcY[2]=fgPcY+dead; fgkMinPcY[3]=fgkMinPcY[2];  
+  fgkMinPcY[4]=2.*fgPcY+2.*dead; fgkMinPcY[5]=fgkMinPcY[4];
+  fgkMaxPcY[0]=fgPcY; fgkMaxPcY[1]=fgkMaxPcY[0];  
+  fgkMaxPcY[2]=2.*fgPcY+dead; fgkMaxPcY[3]=fgkMaxPcY[2]; 
+  fgkMaxPcY[4]=fgAllY; fgkMaxPcY[5]=fgkMaxPcY[4];   
+    
+  fX=0.5*SizeAllX();
+  fY=0.5*SizeAllY();
+  
+  for(Int_t i=kMinCh;i<=kMaxCh;i++) 
+    if(gGeoManager && gGeoManager->IsClosed()) {
+      TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("/HMPID/Chamber%i",i));
+      if (!pne) {
+        AliErrorClass(Form("The symbolic volume %s does not correspond to any physical entry!",Form("HMPID_%i",i)));
+        fM[i]=new TGeoHMatrix;
+        IdealPosition(i,fM[i]);
+      } else {
+        TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
+        if(pnode) fM[i]=new TGeoHMatrix(*(pnode->GetMatrix()));
+        else {
+          fM[i]=new TGeoHMatrix;
+          IdealPosition(i,fM[i]);
+        }
+      }
+    } else{
+      fM[i]=new TGeoHMatrix;
+      IdealPosition(i,fM[i]);
+    } 
   fgInstance=this; 
 }//ctor
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -46,6 +123,30 @@ void AliHMPIDParam::Print(Option_t* opt) const
   for(Int_t i=0;i<7;i++) fM[i]->Print(opt);
 }//Print()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDParam::IdealPosition(Int_t iCh, TGeoHMatrix *pMatrix)
+{
+// Construct ideal position matrix for a given chamber
+// Arguments: iCh- chamber ID; pMatrix- pointer to precreated unity matrix where to store the results
+//   Returns: none
+  const Double_t kAngHor=19.5;        //  horizontal angle between chambers  19.5 grad
+  const Double_t kAngVer=20;          //  vertical angle between chambers    20   grad     
+  const Double_t kAngCom=30;          //  common HMPID rotation with respect to x axis  30   grad     
+  const Double_t kTrans[3]={490,0,0}; //  center of the chamber is on window-gap surface
+  pMatrix->RotateY(90);               //  rotate around y since initial position is in XY plane -> now in YZ plane
+  pMatrix->SetTranslation(kTrans);    //  now plane in YZ is shifted along x 
+  switch(iCh){
+    case 0:                pMatrix->RotateY(kAngHor);  pMatrix->RotateZ(-kAngVer);  break; //right and down 
+    case 1:                                            pMatrix->RotateZ(-kAngVer);  break; //down              
+    case 2:                pMatrix->RotateY(kAngHor);                               break; //right 
+    case 3:                                                                         break; //no rotation
+    case 4:                pMatrix->RotateY(-kAngHor);                              break; //left   
+    case 5:                                            pMatrix->RotateZ(kAngVer);   break; //up
+    case 6:                pMatrix->RotateY(-kAngHor); pMatrix->RotateZ(kAngVer);   break; //left and up 
+  }
+  pMatrix->RotateZ(kAngCom);     //apply common rotation  in XY plane    
+   
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
 {
 // Prints some useful info from stack
@@ -65,7 +166,8 @@ Int_t AliHMPIDParam::Stack(Int_t evt,Int_t tid)
     AliStack *pStack=pAL->Stack();  
     if(tid==-1){                        //print all tids for this event
       for(Int_t i=0;i<pStack->GetNtrack();i++) pStack->Particle(i)->Print();
-      Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
+          Printf("totally %i tracks including %i primaries for event %i out of %i event(s)",
+          pStack->GetNtrack(),pStack->GetNprimary(),iEvt,iNevt);
     }else{                              //print only this tid and it;s mothers
       if(tid<0 || tid>pStack->GetNtrack()) {Printf("Wrong tid, valid tid range for event %i is 0-%i",iEvt,pStack->GetNtrack());break;}
       TParticle *pTrack=pStack->Particle(tid); mtid=pTrack->GetFirstMother();
@@ -96,3 +198,119 @@ Int_t AliHMPIDParam::StackCount(Int_t pid,Int_t evt)
   return iCnt;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Double_t AliHMPIDParam::Sigma2(Double_t trkTheta,Double_t trkPhi,Double_t ckovTh, Double_t ckovPh)
+{
+// Analithical calculation of total error (as a sum of localization, geometrical and chromatic errors) on Cerenkov angle for a given Cerenkov photon 
+// created by a given MIP. Fromulae according to CERN-EP-2000-058 
+// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
+//            dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]        
+//            MIP beta
+//   Returns: absolute error on Cerenkov angle, [radians]    
+  
+  TVector3 v(-999,-999,-999);
+  Double_t trkBeta = 1./(TMath::Cos(ckovTh)*GetRefIdx());
+  
+  if(trkBeta > 1) trkBeta = 1;                 //protection against bad measured thetaCer  
+  if(trkBeta < 0) trkBeta = 0.0001;            //
+
+  v.SetX(SigLoc (trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
+  v.SetY(SigGeom(trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
+  v.SetZ(SigCrom(trkTheta,trkPhi,ckovTh,ckovPh,trkBeta));
+
+  return v.Mag2();
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Double_t AliHMPIDParam::SigLoc(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
+{
+// Analitical calculation of localization error (due to finite segmentation of PC) on Cerenkov angle for a given Cerenkov photon 
+// created by a given MIP. Fromulae according to CERN-EP-2000-058 
+// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
+//            dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]        
+//            MIP beta
+//   Returns: absolute error on Cerenkov angle, [radians]    
+  
+  Double_t phiDelta = phiC - trkPhi;
+
+  Double_t sint     = TMath::Sin(trkTheta);
+  Double_t cost     = TMath::Cos(trkTheta);
+  Double_t sinf     = TMath::Sin(trkPhi);
+  Double_t cosf     = TMath::Cos(trkPhi);
+  Double_t sinfd    = TMath::Sin(phiDelta);
+  Double_t cosfd    = TMath::Cos(phiDelta);
+  Double_t tantheta = TMath::Tan(thetaC);
+  
+  Double_t alpha =cost-tantheta*cosfd*sint;                                                 // formula (11)
+  Double_t k = 1.-GetRefIdx()*GetRefIdx()+alpha*alpha/(betaM*betaM);        // formula (after 8 in the text)
+  if (k<0) return 1e10;
+  Double_t mu =sint*sinf+tantheta*(cost*cosfd*sinf+sinfd*cosf);                             // formula (10)
+  Double_t e  =sint*cosf+tantheta*(cost*cosfd*cosf-sinfd*sinf);                             // formula (9)
+
+  Double_t kk = betaM*TMath::Sqrt(k)/(GapThick()*alpha);                            // formula (6) and (7)
+  Double_t dtdxc = kk*(k*(cosfd*cosf-cost*sinfd*sinf)-(alpha*mu/(betaM*betaM))*sint*sinfd); // formula (6)           
+  Double_t dtdyc = kk*(k*(cosfd*sinf+cost*sinfd*cosf)+(alpha* e/(betaM*betaM))*sint*sinfd); // formula (7)            pag.4
+
+  Double_t errX = 0.2,errY=0.25;                                                            //end of page 7
+  return  TMath::Sqrt(errX*errX*dtdxc*dtdxc + errY*errY*dtdyc*dtdyc);
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Double_t AliHMPIDParam::SigCrom(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
+{
+// Analitical calculation of chromatic error (due to lack of knowledge of Cerenkov photon energy) on Cerenkov angle for a given Cerenkov photon 
+// created by a given MIP. Fromulae according to CERN-EP-2000-058 
+// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
+//            dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]        
+//            MIP beta
+//   Returns: absolute error on Cerenkov angle, [radians]    
+  
+  Double_t phiDelta = phiC - trkPhi;
+
+  Double_t sint     = TMath::Sin(trkTheta);
+  Double_t cost     = TMath::Cos(trkTheta);
+  Double_t cosfd    = TMath::Cos(phiDelta);
+  Double_t tantheta = TMath::Tan(thetaC);
+  
+  Double_t alpha =cost-tantheta*cosfd*sint;                                                 // formula (11)
+  Double_t dtdn = cost*GetRefIdx()*betaM*betaM/(alpha*tantheta);                    // formula (12)
+            
+//  Double_t f = 0.00928*(7.75-5.635)/TMath::Sqrt(12.);
+  Double_t f = 0.0172*(7.75-5.635)/TMath::Sqrt(24.);
+
+  return f*dtdn;
+}//SigCrom()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Double_t AliHMPIDParam::SigGeom(Double_t trkTheta,Double_t trkPhi,Double_t thetaC, Double_t phiC,Double_t betaM)
+{
+// Analitical calculation of geometric error (due to lack of knowledge of creation point in radiator) on Cerenkov angle for a given Cerenkov photon 
+// created by a given MIP. Formulae according to CERN-EP-2000-058 
+// Arguments: Cerenkov and azimuthal angles for Cerenkov photon, [radians]
+//            dip and azimuthal angles for MIP taken at the entrance to radiator, [radians]        
+//            MIP beta
+//   Returns: absolute error on Cerenkov angle, [radians]    
+
+  Double_t phiDelta = phiC - trkPhi;
+
+  Double_t sint     = TMath::Sin(trkTheta);
+  Double_t cost     = TMath::Cos(trkTheta);
+  Double_t sinf     = TMath::Sin(trkPhi);
+  Double_t cosfd    = TMath::Cos(phiDelta);
+  Double_t costheta = TMath::Cos(thetaC);
+  Double_t tantheta = TMath::Tan(thetaC);
+  
+  Double_t alpha =cost-tantheta*cosfd*sint;                                                  // formula (11)
+  
+  Double_t k = 1.-GetRefIdx()*GetRefIdx()+alpha*alpha/(betaM*betaM);         // formula (after 8 in the text)
+  if (k<0) return 1e10;
+
+  Double_t eTr = 0.5*RadThick()*betaM*TMath::Sqrt(k)/(GapThick()*alpha);     // formula (14)
+  Double_t lambda = 1.-sint*sint*sinf*sinf;                                                  // formula (15)
+
+  Double_t c1 = 1./(1.+ eTr*k/(alpha*alpha*costheta*costheta));                              // formula (13.a)
+  Double_t c2 = betaM*TMath::Power(k,1.5)*tantheta*lambda/(GapThick()*alpha*alpha);  // formula (13.b)
+  Double_t c3 = (1.+eTr*k*betaM*betaM)/((1+eTr)*alpha*alpha);                                // formula (13.c)
+  Double_t c4 = TMath::Sqrt(k)*tantheta*(1-lambda)/(GapThick()*betaM);               // formula (13.d)
+  Double_t dtdT = c1 * (c2+c3*c4);
+  Double_t trErr = RadThick()/(TMath::Sqrt(12.)*cost);
+
+  return trErr*dtdT;
+}//SigGeom()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++