]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDv2.cxx
little improvements in online calibration
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDv2.cxx
index 8062339158cd95524628dc385dfe880872690662..bea66d628c1f1417ec9aa0aa031ca4328229493a 100644 (file)
 #include <AliMC.h>            //StepManager()      
 #include <AliRun.h>           //CreateMaterials()    
 #include <AliMagF.h>          //CreateMaterials()
-#include <TGeoManager.h>      //CreateGeometry()
+#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() 
+
 ClassImp(AliHMPIDv2)    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDv2::AddAlignableVolumes()const
@@ -44,7 +45,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);
@@ -52,26 +56,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()
@@ -98,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]
@@ -535,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)
@@ -675,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;
@@ -719,25 +717,19 @@ Bool_t AliHMPIDv2::Raw2SDigits(AliRawReader *pRR)
 // Interface methode ivoked from AliSimulation to create a list of sdigits from raw digits. Events loop is done in AliSimulation
 // Arguments: pRR- raw reader 
 //   Returns: kTRUE on success (currently ignored in AliSimulation::ConvertRaw2SDigits())      
-  AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
+  //AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
+  
   if(!GetLoader()->TreeS()) {MakeTree("S");  MakeBranch("S");}
     
   TClonesArray *pSdiLst=SdiLst(); Int_t iSdiCnt=0; //tmp list of sdigits for all chambers
   AliHMPIDRawStream stream(pRR);
   while(stream.Next())
   {
-   UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13 
-    for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
-     for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
-      for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
-          if(stream.GetCharge(ddl,row,dil,pad)<1) continue;
-          AliHMPIDDigit sdi(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
-          new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
-        }//pad
-      }//dil
-    }//row
-  }    
+    for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
+      AliHMPIDDigit sdi(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
+      new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
+    }
+  }
   
   GetLoader()->TreeS()->Fill(); GetLoader()->WriteSDigits("OVERWRITE");//write out sdigits
   SdiReset();
@@ -767,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