]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDv2.cxx
When calculating a*a-b*b the form (a-b)*(a+b) is usually more numerically stable.
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDv2.cxx
index 38fc2c73c56be17fb615101eeb52141b70dc3f38..bea66d628c1f1417ec9aa0aa031ca4328229493a 100644 (file)
 #include <AliMC.h>            //StepManager()      
 #include <AliRun.h>           //CreateMaterials()    
 #include <AliMagF.h>          //CreateMaterials()
+#include "AliGeomManager.h"   //AddAlignableVolumes()
+#include <AliCDBEntry.h>      //CreateMaterials()
+#include <AliCDBManager.h>    //CreateMaterials()
 #include <TF1.h>              //DefineOpticalProperties()
 #include <TF2.h>              //DefineOpticalProperties()
-#include <TLorentzVector.h>   //IsLostByFresnel() 
-#include <AliCDBManager.h>    //CreateMaterials()
-#include <AliCDBEntry.h>      //CreateMaterials()
+#include <TGeoGlobalMagField.h>
 #include <TGeoPhysicalNode.h> //AddAlignableVolumes()
-#include "AliGeomManager.h"   //AddAlignableVolumes()
+#include <TLorentzVector.h>   //IsLostByFresnel() 
 
 ClassImp(AliHMPIDv2)    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -57,7 +58,7 @@ void AliHMPIDv2::AddAlignableVolumes()const
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
     modUID = AliGeomManager::LayerToVolUID(idHMPID,modnum++);
     if(!gGeoManager->SetAlignableEntry(Form("/HMPID/Chamber%i",iCh),Form("ALIC_1/Hmp_%i",iCh),modUID))
-           AliFatal("AliHMPIDv3::Unable to set alignable entry!!");  //aligment without AliCluster3D
+           AliError("AliHMPIDv3::Unable to set alignable entry!!");  //aligment without AliCluster3D
     //Get Tracking To Local matricies for alignment with AliCluster3D
     TGeoPNEntry *eCh = gGeoManager->GetAlignableEntryByUID(modUID);
     TGeoHMatrix *globMatrix = eCh->GetGlobalOrig();
@@ -95,8 +96,8 @@ void AliHMPIDv2::CreateMaterials()
 
     Int_t   matId=0;                           //tmp material id number
     Int_t   unsens =  0, sens=1;               //sensitive or unsensitive medium
-    Int_t   itgfld = gAlice->Field()->Integ(); //type of field intergration 0 no field -1 user in guswim 1 Runge Kutta 2 helix 3 const field along z
-    Float_t maxfld = gAlice->Field()->Max();   //max field value
+    Int_t   itgfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); //type of field intergration 0 no field -1 user in guswim 1 Runge Kutta 2 helix 3 const field along z
+    Float_t maxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();   //max field value
     Float_t tmaxfd = -10.0;                    //max deflection angle due to magnetic field in one step
     Float_t deemax = - 0.2;                    //max fractional energy loss in one step   
     Float_t stemax = - 0.1;                    //max step allowed [cm]
@@ -532,7 +533,7 @@ void AliHMPIDv2::GenFee(Float_t qtot)
     gMC->GetRandom()->RndmArray(2,ranf);    //Sample direction
     cthf=ranf[0]*2-1.0;
     if(cthf<0) continue;
-    sthf = TMath::Sqrt((1 - cthf) * (1 + cthf));
+    sthf = TMath::Sqrt((1. - cthf) * (1. + cthf));
     phif = ranf[1] * 2 * TMath::Pi();
     
     if(Double_t randomNumber=gMC->GetRandom()->Rndm()<=0.57)
@@ -672,7 +673,7 @@ Float_t AliHMPIDv2::Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)
     //FORMULAE FROM HANDBOOK OF OPTICS, 33.23 OR
     //W.R. HUNTER, J.O.S.A. 54 (1964),15 , J.O.S.A. 55(1965),1197
 
-    Float_t sinin=TMath::Sqrt(1-pdoti*pdoti);
+    Float_t sinin=TMath::Sqrt((1.-pdoti)*(1.+pdoti));
     Float_t tanin=sinin/pdoti;
 
     Float_t c1=cn*cn-ck*ck-sinin*sinin;
@@ -758,12 +759,13 @@ void AliHMPIDv2::StepHistory()
   }
 
   TString flag="fanny combination";
-  if(gMC->IsTrackAlive())
-      if(gMC->IsTrackEntering())      flag="enters to";
-      else if(gMC->IsTrackExiting())  flag="exits from";
-      else if(gMC->IsTrackInside())   flag="inside";
-  else
-      if(gMC->IsTrackStop())          flag="stoped in";        
+  if(gMC->IsTrackAlive()) {
+    if(gMC->IsTrackEntering())      flag="enters to";
+    else if(gMC->IsTrackExiting())  flag="exits from";
+    else if(gMC->IsTrackInside())   flag="inside";
+  } else {
+    if(gMC->IsTrackStop())          flag="stopped in";
+  }
   
   Int_t vid=0,copy=0;
   TString path=gMC->CurrentVolName(); path.Prepend("-");path.Prepend(gMC->CurrentVolOffName(1));//current volume and his mother are always there