]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDv2.cxx
Class AliHMPIDRecoParamV1 introduced (29-11-2009) as a copy of AliHMPIDRecoParam...
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDv2.cxx
index 974e510b76561a707a542cc800d2bfcf86000951..fea5c6b4c8d17c841d462da7f6c288c12b3816ed 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 <TLorentzVector.h>   //IsLostByFresnel() 
+#include <TTree.h>
+
 ClassImp(AliHMPIDv2)    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDv2::AddAlignableVolumes()const
@@ -43,7 +46,10 @@ void AliHMPIDv2::AddAlignableVolumes()const
 // Associates the symbolic volume name with the corresponding volume path. Interface method from AliModule invoked from AliMC
 // Arguments: none
 //   Returns: none   
-  
+
+  AliGeomManager::ELayerID idHMPID = AliGeomManager::kHMPID;
+  Int_t modUID, modnum = 0;
+
   TGeoHMatrix *pGm = new TGeoHMatrix;
   Double_t trans[3]={0.5*131.24,0.5*126.16,0};                            //translation from LORS to TGeo RS (half size AllX, half size allY,0)
   pGm->SetTranslation(trans);
@@ -51,26 +57,20 @@ void AliHMPIDv2::AddAlignableVolumes()const
   Double_t ph[7]={10.,10., 30.,30.,30. ,50.,50};
 
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-      gGeoManager->SetAlignableEntry(Form("/HMPID/Chamber%i",iCh),Form("ALIC_1/Hmp_%i",iCh));  //aligment without AliCluster3D
-      //Get Tracking To Local matrcies for alignment with AliCluster3D
-      TGeoPNEntry *eCh = gGeoManager->GetAlignableEntry(Form("/HMPID/Chamber%i",iCh));
-      if (eCh) {
-       const char *path = eCh->GetTitle();
-       if (!gGeoManager->cd(path)) {
-         AliFatal(Form("Volume path %s not valid!",path));
-       }
-      TGeoHMatrix *globMatrix = gGeoManager->GetCurrentMatrix();
-      //Double_t phi = 20.0 * ((iCh+1) / 3) + 10.0;
-      Double_t phi = ph[iCh];
-      TGeoHMatrix *t2l  = new TGeoHMatrix();
-      t2l->RotateZ(phi);
-      t2l->MultiplyLeft(&(globMatrix->Inverse()));
-      eCh->SetMatrix(t2l);
-    }//eCh
-    else {
-       AliError(Form("Alignable entry /HMPID/Chamber%i is not valid!",iCh));
-      }
-    }//iCh loop
+    modUID = AliGeomManager::LayerToVolUID(idHMPID,modnum++);
+    if(!gGeoManager->SetAlignableEntry(Form("/HMPID/Chamber%i",iCh),Form("ALIC_1/Hmp_%i",iCh),modUID))
+           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();
+
+    //Double_t phi = 20.0 * ((iCh+1) / 3) + 10.0;
+    Double_t phi = ph[iCh];
+    TGeoHMatrix *t2l  = new TGeoHMatrix();
+    t2l->RotateZ(phi);
+    t2l->MultiplyLeft(&(globMatrix->Inverse()));
+    eCh->SetMatrix(t2l);
+  }//iCh loop
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDv2::CreateMaterials()
@@ -97,8 +97,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]
@@ -130,12 +130,12 @@ void AliHMPIDv2::CreateMaterials()
     AliMaterial(++matId,"Al"  ,aAl  ,zAl  ,dAl  ,radAl  ,absAl  );  AliMedium(kAl  ,"Al"  , matId, unsens, itgfld, maxfld, tmaxfd, stemax, deemax, epsil, stmin);
     AliMaterial(++matId,"Ar"  ,aAr  ,zAr  ,dAr  ,radAr  ,absAr  );  AliMedium(kAr  ,"Ar"  , matId, unsens, itgfld, maxfld, tmaxfd, stemax, deemax, epsil, stmin);
 
-    InitProperties();
+    //InitProperties();
         
 }//void AliHMPID::CreateMaterials()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDv2::InitProperties()
-{
+//void AliHMPIDv2::InitProperties()
+//{
 /*
 * HMPID
 * ====
@@ -153,7 +153,7 @@ HMPID  9  1.e-5 1.e-5 1.e-4  -1.   1.e-4 -1.   -1.    5.e-5 5.e-5 -1.  -1   -1
 HMPID  6  1.e-5 1.e-5 1.e-4  -1.   1.e-4 -1.   -1.    5.e-5 5.e-5 -1.  -1   -1   -1   -1   1    -1   1    -1   -1   -1   -1 
 * PCB backplane   (>  50 keV delta-electrons)
 HMPID 12  1.e-5 1.e-5 1.e-4  -1.   1.e-4 -1.   -1.    5.e-5 5.e-5 -1.  -1   -1   -1   -1   1    -1   1    -1   -1   -1   -1 
-*/
+
     Int_t *idtmed = fIdtmed->GetArray();
     Int_t imed;
     
@@ -234,7 +234,7 @@ HMPID 12  1.e-5 1.e-5 1.e-4  -1.   1.e-4 -1.   -1.    5.e-5 5.e-5 -1.  -1   -1
     gMC->Gstpar(idtmed[imed], "DRAY",1);    
     gMC->Gstpar(idtmed[imed], "LOSS",1);    
     
-}
+}*/
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDv2::CreateGeometry()
 {
@@ -534,7 +534,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)
@@ -674,7 +674,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;
@@ -760,12 +760,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
@@ -820,8 +821,9 @@ void AliHMPIDv2::StepManager()
       Int_t   pid=     gMC->TrackPid();                                                          //take PID
       Float_t etot=    gMC->Etot();                                                              //total hpoton energy, [GeV] 
       Double_t x[3];   gMC->TrackPosition(x[0],x[1],x[2]);                                       //take MARS position at entrance to PC
+      Float_t hitTime= (Float_t)gMC->TrackTime();                                                         //hit formation time 
       Float_t xl,yl;   AliHMPIDParam::Instance()->Mars2Lors(copy,x,xl,yl);                       //take LORS position
-      new((*fHits)[fNhits++])AliHMPIDHit(copy,etot,pid,tid,xl,yl,x);                             //HIT for photon, position at P, etot will be set to Q
+      new((*fHits)[fNhits++])AliHMPIDHit(copy,etot,pid,tid,xl,yl,hitTime,x);                             //HIT for photon, position at P, etot will be set to Q
       if(fDoFeed) GenFee(etot);                                                                  //generate feedback photons etot is modified in hit ctor to Q of hit
     }//photon hit PC and DE >0 
   }//photon hit PC
@@ -841,11 +843,12 @@ void AliHMPIDv2::StepManager()
       Int_t tid=          gMC->GetStack()->GetCurrentTrackNumber();                               //take TID
       Int_t pid=          gMC->TrackPid();                                                        //take PID
       Double_t out[3];    gMC->TrackPosition(out[0],out[1],out[2]);                               //take MARS position at exit
+      Float_t hitTime= (Float_t)gMC->TrackTime();                                                         //hit formation time       
       out[0]=0.5*(out[0]+in[0]);                                                                  //>
       out[1]=0.5*(out[1]+in[1]);                                                                  //take hit position at the anod plane
       out[2]=0.5*(out[2]+in[2]);                                                                  //>
       Float_t xl,yl;AliHMPIDParam::Instance()->Mars2Lors(copy,out,xl,yl);                         //take LORS position
-      new((*fHits)[fNhits++])AliHMPIDHit(copy,eloss,pid,tid,xl,yl,out);                           //HIT for MIP, position near anod plane, eloss will be set to Q 
+      new((*fHits)[fNhits++])AliHMPIDHit(copy,eloss,pid,tid,xl,yl,hitTime,out);                   //HIT for MIP, position near anod plane, eloss will be set to Q 
       if(fDoFeed) GenFee(eloss);                                                                  //generate feedback photons 
     }else                                                                                         //just going inside
       eloss          += gMC->Edep();                                                              //collect this step eloss