]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDv1.cxx
Further fixes to the par file generation
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDv1.cxx
index 0c7cbcdfefba470ec36c51456fb8fcc5b0b1ea3c..0afc7266a24c516f6015a8600bc4d295468ac7b4 100644 (file)
@@ -18,6 +18,7 @@
 #include "AliHMPIDParam.h"  //StepManager()
 #include "AliHMPIDHit.h"    //Hits2SDigs(),StepManager()
 #include "AliHMPIDDigit.h"  //Digits2Raw(), Raw2SDigits()
+#include "AliHMPIDRawStream.h"  //Digits2Raw(), Raw2SDigits()
 #include "AliRawReader.h"  //Raw2SDigits()
 #include <TVirtualMC.h>    //StepManager() for gMC
 #include <TPDGCode.h>      //StepHistory() 
@@ -27,7 +28,7 @@
 #include <AliMC.h>            //StepManager()      
 #include <AliRun.h>           //CreateMaterials()    
 #include <AliMagF.h>          //CreateMaterials()
-#include <TGeoManager.h>      //CreateGeometry()
+//#include <TGeoManager.h>      //CreateGeometry()
 #include <TF1.h>              //DefineOpticalProperties()
 #include <TF2.h>              //DefineOpticalProperties()
 #include <TLorentzVector.h>   //IsLostByFresnel() 
@@ -200,11 +201,13 @@ void AliHMPIDv1::DefineOpticalProperties()
   const Int_t kNbins=30;       //number of photon energy points
   Float_t emin=5.5,emax=8.5;         //Photon energy range,[eV]
   Float_t aEckov [kNbins]; 
+  Double_t dEckov [kNbins]; 
   Float_t aAbsRad[kNbins], aAbsWin[kNbins], aAbsGap[kNbins], aAbsMet[kNbins];
   Float_t aIdxRad[kNbins], aIdxWin[kNbins], aIdxGap[kNbins], aIdxMet[kNbins], aIdxPc[kNbins]; 
   Float_t                                                    aQeAll [kNbins], aQePc [kNbins];
+  Double_t dReflMet[kNbins], dQePc[kNbins];
 
-  TF2 *pRaIF=new TF2("HidxRad","sqrt(1+0.554*(1239.84/x)^2/((1239.84/x)^2-5796)-0.0005*(y-20))"                                       ,emin,emax,0,50); //DiMauro mail temp 0-50 degrees C
+  TF2 *pRaIF=new TF2("HidxRad","sqrt(1+0.554*(1239.84/x)^2/((1239.84/x)^2-5769)-0.0005*(y-20))"                                       ,emin,emax,0,50); //DiMauro mail temp 0-50 degrees C
   TF1 *pWiIF=new TF1("HidxWin","sqrt(1+46.411/(10.666*10.666-x*x)+228.71/(18.125*18.125-x*x))"                                        ,emin,emax);      //SiO2 idx TDR p.35
   TF1 *pGaIF=new TF1("HidxGap","1+0.12489e-6/(2.62e-4 - x*x/1239.84/1239.84)"                                                         ,emin,emax);      //?????? from where  
 
@@ -218,13 +221,15 @@ void AliHMPIDv1::DefineOpticalProperties()
   for(Int_t i=0;i<kNbins;i++){
     Float_t eV=emin+0.1*i;  //Ckov energy in eV
     aEckov [i] =1e-9*eV;    //Ckov energy in GeV
+    dEckov [i] = aEckov[i];
     aAbsRad[i]=pRaAF->Eval(eV); aIdxRad[i]=1.292;//pRaIF->Eval(eV,20);      //Simulation for 20 degress C       
     aAbsWin[i]=pWiAF->Eval(eV); aIdxWin[i]=1.5787;//pWiIF->Eval(eV);
     aAbsGap[i]=pGaAF->Eval(eV); aIdxGap[i]=1.0005;//pGaIF->Eval(eV);   
     aQeAll[i] =1;                     //QE for all other materials except for PC must be 1.  
     aAbsMet[i] =0.0001;                aIdxMet[i]=0;                                             //metal ref idx must be 0 in order to reflect photon
                                        aIdxPc [i]=1;           aQePc [i]=pQeF->Eval(eV);         //PC ref idx must be 1 in order to apply photon to QE conversion 
-                                       
+    dQePc [i]=pQeF->Eval(eV);
+    dReflMet[i] = 0.;     // no reflection on the surface of the pc (?)                                       
   }
   gMC->SetCerenkov((*fIdtmed)[kC6F14]    , kNbins, aEckov, aAbsRad  , aQeAll , aIdxRad );    
   gMC->SetCerenkov((*fIdtmed)[kSiO2]     , kNbins, aEckov, aAbsWin  , aQeAll , aIdxWin );    
@@ -233,6 +238,13 @@ void AliHMPIDv1::DefineOpticalProperties()
   gMC->SetCerenkov((*fIdtmed)[kW]        , kNbins, aEckov, aAbsMet  , aQeAll , aIdxMet ); //n=0 means reflect photons       
   gMC->SetCerenkov((*fIdtmed)[kCsI]      , kNbins, aEckov, aAbsMet  , aQePc  , aIdxPc  ); //n=1 means convert photons    
   gMC->SetCerenkov((*fIdtmed)[kAl]       , kNbins, aEckov, aAbsMet  , aQeAll , aIdxMet );    
+
+  // Define a skin surface for the photocatode to enable 'detection' in G4
+  gMC->DefineOpSurface("surfPc", kGlisur /*kUnified*/,kDielectric_metal,kPolished, 0.);
+  gMC->SetMaterialProperty("surfPc", "EFFICIENCY", kNbins, dEckov, dQePc);
+  gMC->SetMaterialProperty("surfPc", "REFLECTIVITY", kNbins, dEckov, dReflMet);
+  gMC->SetSkinSurface("skinPc", "Rpc", "surfPc");
+
   delete pRaAF;delete pWiAF;delete pGaAF; delete pRaIF; delete pWiIF; delete pGaIF; delete pQeF;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -377,7 +389,9 @@ void AliHMPIDv1::Digits2Raw()
   }
   treeD->GetEntry(0);
   
-  AliHMPIDDigit::WriteRaw(DigLst());
+  //AliHMPIDDigit::WriteRaw(DigLst());
+   AliHMPIDRawStream *pRS=0x0;
+   pRS->WriteRaw(DigLst());
     
   GetLoader()->UnloadDigits();
   AliDebug(1,"Stop.");      
@@ -452,18 +466,20 @@ Bool_t AliHMPIDv1::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
-  pRR->Select("HMPID",0,13);//select all HMPID DDL files
-  UInt_t w32=0;
-  while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
-    UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
-    if(!sdi.Raw(ddl,w32,pRR)) continue;  
-    new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
-  }//raw records loop
+  AliHMPIDRawStream stream(pRR);
+  while(stream.Next())
+  {
+    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();
   return kTRUE;