Do not include from subdirectories
[u/mrichter/AliRoot.git] / HMPID / Hconfig.C
index 0e64b37..abcce7d 100644 (file)
@@ -1,10 +1,8 @@
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
-//Change log:  21st June 2007 by Levente Molnar
-//             Detector description upgrade: ITS,ToF,Absorber, Dipole, V0, Emcal
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
 
 
 #include <TPDGCode.h>
+#include "AliHMPIDParam.h"
 
 Bool_t gGun1      =kFALSE;
 Bool_t gGun7      =kFALSE;
@@ -21,12 +19,12 @@ public:
           HmpConfig(const char*sFileName);
          ~HmpConfig()                    {Info("ctor","");Cleanup();}
          
-  enum EVersOpts  {kNo=101,kVer0,kVer1,kVer2,kTest, kDeclust=301,kSagita,kFeedback,kElNoise,kQe0=400,kQeNorm,kFlatIdx,kOptics};
+  enum EVersOpts  {kNo=101,kVer0,kVer1,kVer2,kVer3,kTest, kDeclust=301,kSagita,kFeedback,kElNoise,kQe0=400,kQeNorm,kFlatIdx,kOptics};
   enum EGenTypes  {kGunZ=1,kGun1,kGun7,kBox,kHijing,kHijingPara,kPythia,kHmpLib,kNotUsed=999};
   
   enum EDetectors {kPIPE=1,kITS,kTPC,kTRD,kTOF,kFRAME,kMAG,kACORDE,kHALL,kPHOS,kT0,kFMD,kABSO,kPMD,kDIPO,kEMCAL,kVZERO,kMUON,kZDC,kSHILD};
   enum EProcesses {kDCAY=1,kPAIR,kCOMP,kPHOT,kPFIS,kDRAY,kANNI,kBREM,kMUNU,kCKOV,kHADR,kLOSS,kMULS,kRAYL,kALL};
-  enum EBatchFlags{kAll=55,kHmp,kDdl,kDat,kRoo,kVtx,kTrk,kHlt,kPid,kAln};
+  enum EBatchFlags{kAll=55,kHmp,kDdl,kDat,kRoo,kVtx,kTrk,kHlt,kPid,kAln,kRecoPar};
   enum EMagField  {kFld0,kFld2,kFld4,kFld5,kFld_2,kFld_4,kFld_5};
   
   Float_t Eta2Theta      (Float_t arg)  const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
@@ -88,7 +86,8 @@ void HmpConfig::GuiHmp(TGHorizontalFrame *pMainHF)
     new TGRadioButton(fVerBG,   "No"         ,kNo       );   
     new TGRadioButton(fVerBG,   "ver0"       ,kVer0     );
     new TGRadioButton(fVerBG,   "ver1"       ,kVer1     );  
-    new TGRadioButton(fVerBG,   "ver2"       ,kVer2     ); fVerBG->SetButton(kVer2);
+    new TGRadioButton(fVerBG,   "ver2"       ,kVer2     ); 
+    new TGRadioButton(fVerBG,   "ver3"       ,kVer3     ); fVerBG->SetButton(kVer3);
   pHmpGF->AddFrame(fOptBG=new TGButtonGroup(pHmpGF,""));  fOptBG->Connect("Pressed(Int_t)" ,"HmpConfig",this,"HmpVerSlot(Int_t)");
     new TGCheckButton(fOptBG,"Test run position"   ,kTest);       
     new TGCheckButton(fOptBG,"Unfold cluster    "  ,kDeclust);      fOptBG->SetButton(kDeclust);
@@ -131,6 +130,7 @@ void HmpConfig::WriteHmp(FILE *pF)
     if     (fVerBG->GetButton(kVer0)->GetState())           fprintf(pF,"  new AliHMPIDv0(\"Gel %s\");\n\n",title.Data());    
     else if(fVerBG->GetButton(kVer1)->GetState())           fprintf(pF,"  new AliHMPIDv1(\"HMPID\",\"%s\");\n\n",title.Data());   
     else if(fVerBG->GetButton(kVer2)->GetState())           fprintf(pF,"  new AliHMPIDv2(\"HMPID\",\"%s\");\n\n",title.Data());   
+    else if(fVerBG->GetButton(kVer3)->GetState())           fprintf(pF,"  new AliHMPIDv3(\"HMPID\",\"%s\");\n\n",title.Data());   
   }
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -200,19 +200,22 @@ void HmpConfig::GuiGen(TGCompositeFrame *pMainF)
   fGenF->AddFrame(fGenBG=new TGButtonGroup(fGenF,"Gene"));//add type button group to vertical generator frame
   fGenBG->Connect("Pressed(Int_t)","HmpConfig",this,"GenAddSlot(Int_t)"); fGenBG->Connect("Released(Int_t)","HmpConfig",this,"GenRemSlot(Int_t)");
     new TGCheckButton(fGenBG,"gun along z"           ,kGunZ);
-    new TGCheckButton(fGenBG,"gun to 1 chamber"      ,kGun1);
-    new TGCheckButton(fGenBG,"gun to 7 chambers"     ,kGun7);
-    new TGCheckButton(fGenBG,"box HMPID phase space"  ,kBox );  
+    new TGCheckButton(fGenBG,"box in 1 chamber"      ,kGun1);
+    new TGCheckButton(fGenBG,"box in 7 chambers"     ,kGun7);
+    new TGCheckButton(fGenBG,"box HMPID phase space" ,kBox );  
     new TGCheckButton(fGenBG,"HIJING"                ,kHijing);
     new TGCheckButton(fGenBG,"HIJING para"           ,kHijingPara);
     new TGCheckButton(fGenBG,"Pythia"                ,kPythia);
-    new TGCheckButton(fGenBG,"HMPID lib"              ,kHmpLib);
+    new TGCheckButton(fGenBG,"HMPID lib"             ,kHmpLib);
 //N prims for box and Hijing para    
   fGenF->AddFrame(fGenNprimCO=new TGComboBox(fGenF,100)); //add N prims combo to generator vertical frame
   fGenNprimCO->AddEntry("not used"    ,kNotUsed);
   fGenNprimCO->AddEntry("N prim=1"    ,1);
   fGenNprimCO->AddEntry("N prim=2"    ,2);
   fGenNprimCO->AddEntry("N prim=5"    ,5);
+  fGenNprimCO->AddEntry("N prim=10"   ,10);
+  fGenNprimCO->AddEntry("N prim=20"   ,20);
+  fGenNprimCO->AddEntry("N prim=50"   ,50);
   fGenNprimCO->AddEntry("N prim=100"  ,100);
   fGenNprimCO->AddEntry("N prim=500"  ,500);
   fGenNprimCO->AddEntry("N prim=1000" ,1000);
@@ -243,7 +246,7 @@ void HmpConfig::GuiGen(TGCompositeFrame *pMainF)
 //Chamber number  
   fGenF->AddFrame(fGenChamCO=new TGComboBox(fGenF,100)); //add chamber number combo to generator vertical frame
   fGenChamCO->AddEntry("not used",kNotUsed);
-  for(int i=1;i<=7;i++) fGenChamCO->AddEntry(Form("Chamber %i",i),i);  fGenChamCO->Resize(160,20); fGenChamCO->Select(kNotUsed);
+  for(int i=1;i<=7;i++) fGenChamCO->AddEntry(Form("Chamber %i",i-1),i);  fGenChamCO->Resize(160,20); fGenChamCO->Select(kNotUsed);
 }//GuiGen()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void HmpConfig::GenAddSlot(Int_t id)
@@ -335,49 +338,36 @@ void HmpConfig::GenRemSlot(Int_t id)
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void HmpConfig::WriteGen(FILE *pF)
 {
+
+  CheckGeometry();
+  
+  AliHMPIDParam *pP = AliHMPIDParam::Instance();
+
   Int_t pid=fGenPidCO->GetSelected();
   Float_t pmin=0.1*fGenPminCO->GetSelected(); //particle momentum, GeV
   Float_t pmax=0.1*fGenPmaxCO->GetSelected(); //particle momentum, GeV
   
-  fprintf(pF,"  AliGenCocktail *pG=new AliGenCocktail();\n\n");
+  if(fGenBG->GetButton(kHijing)->GetState()==kButtonDown     ||
+     fGenBG->GetButton(kHijingPara)->GetState()==kButtonDown ||
+     fGenBG->GetButton(kPythia)->GetState()==kButtonDown) {;}
+  else {fprintf(pF,"  AliGenCocktail *pG=new AliGenCocktail();\n\n");}
   
   if(fGenBG->GetButton(kGunZ)->GetState()==kButtonDown)//1 particle along Z axis 
     fprintf(pF,"  AliGenFixed *pGz=new AliGenFixed(1); pGz->SetPart(%i); pGz->SetMomentum(%.1f); pGz->SetOrigin(0,0,-200); pG->AddGenerator(pGz,\"Gz\",1);\n",pid,pmin);
   
   if(fGenBG->GetButton(kGun1)->GetState()==kButtonDown){//1 gun towards 1 HMPID chamber
-    switch(fGenChamCO->GetSelected()){
-     case 1: fprintf(pF,"  AliGenFixed *pG1=new AliGenFixed(1); pG1->SetPart(%i); pG1->SetMomentum(%.1f);\n",pid,pmin); 
-             fprintf(pF,"               pG1->SetTheta(109.5);   pG1->SetPhi(10);  pG->AddGenerator(pG1,\"g1\",1);\n"); break;
-     case 2: fprintf(pF,"  AliGenFixed *pG2=new AliGenFixed(1); pG2->SetPart(%i); pG2->SetMomentum(%.1f);\n",pid,pmin);
-            fprintf(pF,"               pG2->SetTheta( 90.0);   pG2->SetPhi(10);  pG->AddGenerator(pG2,\"g2\",1);\n"); break;
-     case 3: fprintf(pF,"  AliGenFixed *pG3=new AliGenFixed(1); pG3->SetPart(%i); pG3->SetMomentum(%.1f);\n",pid,pmin);
-            fprintf(pF,"               pG3->SetTheta(109.5);   pG3->SetPhi(30);  pG->AddGenerator(pG3,\"g3\",1);\n"); break;
-     case 4: fprintf(pF,"  AliGenFixed *pG4=new AliGenFixed(1); pG4->SetPart(%i); pG4->SetMomentum(%.1f);\n",pid,pmin);
-             fprintf(pF,"               pG4->SetTheta( 87.0);   pG4->SetPhi(30);  pG->AddGenerator(pG4,\"g4\",1);\n"); break;
-     case 5: fprintf(pF,"  AliGenFixed *pG5=new AliGenFixed(1); pG5->SetPart(%i); pG5->SetMomentum(%.1f);\n",pid,pmin);
-             fprintf(pF,"               pG5->SetTheta( 70.5);   pG5->SetPhi(30);  pG->AddGenerator(pG5,\"g5\",1);\n"); break;
-     case 6: fprintf(pF,"  AliGenFixed *pG6=new AliGenFixed(1); pG6->SetPart(%i); pG6->SetMomentum(%.1f);\n",pid,pmin);
-             fprintf(pF,"               pG6->SetTheta( 90.0);   pG6->SetPhi(50);  pG->AddGenerator(pG6,\"g6\",1);\n"); break;
-     case 7: fprintf(pF,"  AliGenFixed *pG7=new AliGenFixed(1); pG7->SetPart(%i); pG7->SetMomentum(%.1f);\n",pid,pmin);
-             fprintf(pF,"               pG7->SetTheta( 70.5);   pG7->SetPhi(50);  pG->AddGenerator(pG7,\"g7\",1);\n"); break;
-    }    
+    Int_t ch = fGenChamCO->GetSelected()-1;
+    fprintf(pF,"  AliGenBox *pGB=new AliGenBox(1); pGB->SetPart(%i); pGB->SetMomentumRange(%.1f,%.1f);\n",pid,pmin,pmin+0.5); 
+    fprintf(pF,"   pGB->SetThetaRange(%.1f,%.1f);   pGB->SetPhiRange(%.1f,%.1f);  pG->AddGenerator(pGB,\"g\",1);//Chamber %i\n",
+                                                       pP->ChThMin(ch),pP->ChThMax(ch),pP->ChPhiMin(ch),pP->ChPhiMax(ch),ch);
   }
   
   if(fGenBG->GetButton(kGun7)->GetState()==kButtonDown){//7 guns towards 7 HMPID chambers
-    fprintf(pF,"  AliGenFixed *pG1=new AliGenFixed(1); pG1->SetPart(%i); pG1->SetMomentum(%.1f);pG1->SetTheta(109.5-3); pG1->SetPhi(10);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG1,\"g1\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG2=new AliGenFixed(1); pG2->SetPart(%i); pG2->SetMomentum(%.1f);pG2->SetTheta( 90.0-3); pG2->SetPhi(10);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG2,\"g2\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG3=new AliGenFixed(1); pG3->SetPart(%i); pG3->SetMomentum(%.1f);pG3->SetTheta(109.5-3); pG3->SetPhi(30);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG3,\"g3\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG4=new AliGenFixed(1); pG4->SetPart(%i); pG4->SetMomentum(%.1f);pG4->SetTheta( 90.0-3); pG4->SetPhi(30);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG4,\"g4\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG5=new AliGenFixed(1); pG5->SetPart(%i); pG5->SetMomentum(%.1f);pG5->SetTheta( 70.0-3); pG5->SetPhi(30);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG5,\"g5\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG6=new AliGenFixed(1); pG6->SetPart(%i); pG6->SetMomentum(%.1f);pG6->SetTheta( 90.0-3); pG6->SetPhi(50);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG6,\"g6\",1);\n");
-    fprintf(pF,"  AliGenFixed *pG7=new AliGenFixed(1); pG7->SetPart(%i); pG7->SetMomentum(%.1f);pG7->SetTheta( 70.0-3); pG7->SetPhi(50);\n",pid,pmin); 
-    fprintf(pF,"               pG->AddGenerator(pG7,\"g7\",1);\n");
+    for(Int_t ich=0;ich<7;ich++) {
+      fprintf(pF,"  AliGenBox *pGB%i=new AliGenBox(1); pGB%i->SetPart(%i); pGB%i->SetMomentumRange(%.1f,%.1f);\n",ich,ich,pid,ich,pmin,pmin+0.5); 
+      fprintf(pF,"   pGB%i->SetThetaRange(%.1f,%.1f);   pGB%i->SetPhiRange(%.1f,%.1f);  pG->AddGenerator(pGB%i,\"g%i\",1);//Chamber %i\n",
+                                        ich,pP->ChThMin(ich),pP->ChThMax(ich),ich,pP->ChPhiMin(ich),pP->ChPhiMax(ich),ich,ich,ich);
+    }
   }  
     
   if(fGenBG->GetButton(kBox)->GetState()==kButtonDown){// box towards HMPID phase space
@@ -386,27 +376,48 @@ void HmpConfig::WriteGen(FILE *pF)
   }     
   
   if(fGenBG->GetButton(kHijing)->GetState()==kButtonDown){//normal HIJING
-    fprintf(pF,"  AliGenHijing *pH=new AliGenHijing(-1);           pH->SetEnergyCMS(14000);        pH->SetReferenceFrame(\"CMS\");\n");
-    fprintf(pF,"                pH->SetProjectile(\"P\", 1, 1); pH->SetTarget(\"P\", 1, 1  ); pH->SetJetQuenching(0);\n");      
+    fprintf(pF,"  AliGenHijing *pH=new AliGenHijing(-1);           pH->SetEnergyCMS(5500);        pH->SetReferenceFrame(\"CMS\");\n");
+    fprintf(pF,"                pH->SetProjectile(\"A\", 208, 82);   pH->SetTarget(\"A\", 208, 82);   pH->SetJetQuenching(0);\n");      
     fprintf(pF,"                pH->SetShadowing(0);               pH->KeepFullEvent();           pH->SetSelectAll(0);\n");
     fprintf(pF,"                pH->SetImpactParameterRange(0, 5); //fermi\n");
-    fprintf(pF,"  pG->AddGenerator(pH,\"h\",1);\n\n");
+    fprintf(pF,"                AliGenerator *gener = (AliGenerator*)pH; \n");
+    fprintf(pF,"                gener->SetOrigin(0, 0, 0);    // vertex position \n");
+    fprintf(pF,"                gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position \n");
+    fprintf(pF,"                gener->SetCutVertexZ(1.);     // Truncate at 1 sigma \n");
+    fprintf(pF,"                gener->SetVertexSmear(kPerEvent);  \n");
+    fprintf(pF,"                gener->SetTrackingFlag(1); \n");
+    fprintf(pF,"                gener->Init(); \n\n");
   }
   
   if(fGenBG->GetButton(kHijingPara)->GetState()==kButtonDown){//parametrized HIJING 
     fprintf(pF,"  AliGenHIJINGpara *pHP=new AliGenHIJINGpara(%i);\n",(int)fGenNprimCO->GetSelected());
     fprintf(pF,"  pHP->SetMomentumRange(0,999); pHP->SetThetaRange(%f,%f); pHP->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
-    fprintf(pF,"  pG->AddGenerator(pHP,\"hp\",1);\n\n");
+    fprintf(pF,"                AliGenerator *gener = (AliGenerator*)pHP; \n");
+    fprintf(pF,"                gener->SetOrigin(0, 0, 0);    // vertex position \n");
+    fprintf(pF,"                gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position \n");
+    fprintf(pF,"                gener->SetCutVertexZ(1.);     // Truncate at 1 sigma \n");
+    fprintf(pF,"                gener->SetVertexSmear(kPerEvent);  \n");
+    fprintf(pF,"                gener->SetTrackingFlag(1); \n");
+    fprintf(pF,"                gener->Init(); \n\n");
   }
       
   if(fGenBG->GetButton(kPythia)->GetState()==kButtonDown){//Pythia
     fprintf(pF,"  AliGenPythia *pP=new AliGenPythia(-1);\n");
-    fprintf(pF,"  pP->SetMomentumRange(0,999); pP->SetPhiRange(20,80); pP->SetThetaRange(75,115);\n");
+    fprintf(pF,"  pP->SetMomentumRange(0,999);\n");
     fprintf(pF,"  pP->SetYRange(-12,12);  pP->SetPtRange(0,1000);      pP->SetStrucFunc(kCTEQ4L);\n");
     fprintf(pF,"  pP->SetProcess(kPyMb);  pP->SetEnergyCMS(14000);\n");      
-    fprintf(pF,"  pG->AddGenerator(pP,\"p\",1);\n\n");  
+    fprintf(pF,"                AliGenerator *gener = (AliGenerator*)pP; \n");
+    fprintf(pF,"                gener->SetOrigin(0, 0, 0);    // vertex position \n");
+    fprintf(pF,"                gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position \n");
+    fprintf(pF,"                gener->SetCutVertexZ(1.);     // Truncate at 1 sigma \n");
+    fprintf(pF,"                gener->SetVertexSmear(kPerEvent);  \n");
+    fprintf(pF,"                gener->SetTrackingFlag(1); \n");
+    fprintf(pF,"                gener->Init(); \n\n");
   }
-  fprintf(pF,"  pG->Init();\n\n");
+  if(fGenBG->GetButton(kHijing)->GetState()==kButtonDown     ||
+     fGenBG->GetButton(kHijingPara)->GetState()==kButtonDown ||
+     fGenBG->GetButton(kPythia)->GetState()==kButtonDown) continue;
+  else fprintf(pF,"  pG->Init();\n\n");
 }//WriteGenerator()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void HmpConfig::GuiDet(TGHorizontalFrame *pMainHF)
@@ -442,18 +453,7 @@ void HmpConfig::WriteDet(FILE *pF)
 //CORE detectors                  
   if(fDetBG->GetButton(kPIPE )->GetState()) fprintf(pF,"\n  new AliPIPEv3(\"PIPE\",\"Beam Pipe\");\n");
   if(fDetBG->GetButton(kSHILD)->GetState()) fprintf(pF,"\n  new AliSHILv3(\"SHIL\",\"Shielding Version 2\");\n");  
-  if(fDetBG->GetButton(kITS  )->GetState()){
-    fprintf(pF,"\n AliITSvPPRasymmFMD *ITS  = new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version with asymmetric services\");\n");
-    fprintf(pF,"\n  ITS->SetMinorVersion(2);\n");  
-    fprintf(pF,"\n  ITS->SetReadDet(kFALSE);\n");      
-    fprintf(pF,"\n  ITS->SetThicknessDet1(200.);\n"); 
-    fprintf(pF,"\n  ITS->SetThicknessDet2(200.); \n");
-    fprintf(pF,"\n  ITS->SetThicknessChip1(150.);\n");
-    fprintf(pF,"\n  ITS->SetThicknessChip2(150.);\n");
-    fprintf(pF,"\n  ITS->SetRails(0);\n");     
-    fprintf(pF,"\n  ITS->SetCoolingFluid(1);\n");
-    fprintf(pF,"\n  ITS->SetEUCLID(0);\n");
-  }  
+  if(fDetBG->GetButton(kITS  )->GetState()) fprintf(pF,"\n  new AliITSv11(\"ITS\",\"ITS v11\");\n");
   
   if(fDetBG->GetButton(kTPC  )->GetState())  fprintf(pF,"\n  new AliTPCv2(\"TPC\",\"Default\");\n");
   if(fDetBG->GetButton(kFRAME)->GetState())  fprintf(pF,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
@@ -478,7 +478,7 @@ void HmpConfig::WriteDet(FILE *pF)
 //different phase space detectors  
   if(fDetBG->GetButton(kPHOS )->GetState()) fprintf(pF,"\n  AliPHOS *PHOS = new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
   if(fDetBG->GetButton(kEMCAL)->GetState()) fprintf(pF,"\n  AliEMCAL *EMCAL = new AliEMCALv2(\"EMCAL\",\"SHISH_77_TRD1_2X2_FINAL_110DEG\");\n");
-  if(fDetBG->GetButton(kACORDE  )->GetState()) fprintf(pF,"\n  AliACORDE *ACORDE = new AliACORDEv0(\"ACORDE\",\"normal ACORDE\");\n");
+  if(fDetBG->GetButton(kACORDE  )->GetState()) fprintf(pF,"\n  AliACORDE *ACORDE = new AliACORDEv1(\"ACORDE\",\"normal ACORDE\");\n");
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void HmpConfig::GuiBatch(TGHorizontalFrame *pMainF)
@@ -513,6 +513,9 @@ void HmpConfig::GuiBatch(TGHorizontalFrame *pMainF)
     new TGRadioButton(fCluBG,  "No Clusters"     ,kNo     );  
     new TGRadioButton(fCluBG,  "Clusters CORE"   ,kAll    );  
     new TGRadioButton(fCluBG,  "Clusters HMPID"  ,kHmp    );   
+
+    new TGCheckButton(fTrkBG,  "Apply RecoParamV1" ,kRecoPar);  
+
     new TGCheckButton(fTrkBG,  "Load Align data" ,kAln    );  
     new TGCheckButton(fTrkBG,  "Prim vertex"     ,kVtx    );  
     new TGCheckButton(fTrkBG,  "ESD tracks"      ,kTrk    );  
@@ -569,6 +572,7 @@ void HmpConfig::SlotRec(Bool_t isChk)
     fCluBG->GetButton(kAll)->SetState(kButtonEngaged);
     fCluBG->GetButton(kHmp)->SetState(kButtonDown);
     
+    fTrkBG->GetButton(kRecoPar)->SetState(kButtonEngaged);
     fTrkBG->GetButton(kAln)->SetState(kButtonEngaged);
     fTrkBG->GetButton(kVtx)->SetState(kButtonEngaged);
     fTrkBG->GetButton(kTrk)->SetState(kButtonEngaged);
@@ -583,6 +587,7 @@ void HmpConfig::SlotRec(Bool_t isChk)
     fCluBG->GetButton(kAll)->SetState(kButtonDisabled);
     fCluBG->GetButton(kHmp)->SetState(kButtonDisabled);
     
+    fTrkBG->GetButton(kRecoPar)->SetState(kButtonDisabled);
     fTrkBG->GetButton(kAln)->SetState(kButtonDisabled);
     fTrkBG->GetButton(kVtx)->SetState(kButtonDisabled);
     fTrkBG->GetButton(kTrk)->SetState(kButtonDisabled);
@@ -610,10 +615,10 @@ void HmpConfig::WriteBatch()
   if(fDetBG->GetButton(kTRD  )->GetState())  det+="TRD ";
   if(fDetBG->GetButton(kTOF  )->GetState())  det+="TOF ";
   if(!fVerBG->GetButton(kNo)->GetState())    det+="HMPID ";
-  char *sBatchName="Hbatch";
-  FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateBatch","Cannot open output file: %s.C",sBatchName);return;}
+  char *sBatchName="sim";
+  FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateSim","Cannot open output file: %s.C",sBatchName);return;}
   
-                                                    fprintf(fp,"void %s(Int_t iNevt,Bool_t isDbg,char *sCfg)\n{\n",sBatchName);
+                                                    fprintf(fp,"void %s(Int_t iNevt=1,Bool_t isDbg=kFALSE,char *sCfg=\"Config.C\")\n{\n",sBatchName);
                                                     fprintf(fp,"  gSystem->Exec(\"rm -rf hlt hough gphysi* fort* ZZZ* raw*\");  //remove garbage\n"); 
                                                     fprintf(fp,"  gBenchmark->Start(\"ALICE\"); TDatime time;      //start benchmarking\n\n");
                                                        
@@ -637,12 +642,51 @@ void HmpConfig::WriteBatch()
     if     (fRawBG->GetButton(kDdl)->GetState())    fprintf(fp,"  pSim->SetWriteRawData(\"%s\");                  //raw data as DDL\n",det.Data());
     else if(fRawBG->GetButton(kDat)->GetState())    fprintf(fp,"  pSim->SetWriteRawData(\"%s\",\"raw.date\");     //raw data as DATE\n",det.Data());
     else if(fRawBG->GetButton(kRoo)->GetState())    fprintf(fp,"  pSim->SetWriteRawData(\"%s\",\"raw.root\");     //raw data as ROOT\n",det.Data());
-  
-                                                    fprintf(fp,"  pSim->Run(iNevt);                              //run iNevt events\n  delete pSim;\n\n");
-  }//sim section
 
+                                                    fprintf(fp,"  pSim->SetRunHLT(\"\");                           //no HLT stuff\n");   
+                                                    fprintf(fp,"  pSim->SetRunQA(\":\");                           //no QA\n");
+                                                    fprintf(fp,"  pSim->Run(iNevt);                                //run iNevt events\n  delete pSim;\n\n");
+  }//sim section
+                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <sim.C>: Start time: \";time.Print();\n");
+                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <sim.C>: Stop  time: \";time.Set();  time.Print();\n");
+                                                    fprintf(fp,"  gBenchmark->Show(\"ALICE\");\n");
+  
+                                                    fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______SSS\");\n");
+                                                    fprintf(fp,"  gSystem->Exec(\"aliroot -q rec.C &\");\n}\n");
+  fclose(fp);  
+// rec section
+  char *sBatchName="rec";
+  FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateRec","Cannot open output file: %s.C",sBatchName);return;}
+  
+                                                    fprintf(fp,"void %s()\n{\n",sBatchName);
+                                                    fprintf(fp,"  gSystem->Exec(\"rm -rf *RRR \");  //remove garbage\n"); 
   if(fRecB->GetState()){
+/*
+       if(fMagBG->GetButton(kFld0)->GetState())     fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2, 0,1,10.,2));//no field\n");
+  else if(fMagBG->GetButton(kFld2)->GetState())     fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2, 1,1,10,AliMagF::k2kG));//0.2 Tesla field\n");
+  else if(fMagBG->GetButton(kFld4)->GetState())     fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2, 1,1,10,AliMagF::k4kG));//0.4 Tesla field\n");
+  else if(fMagBG->GetButton(kFld5)->GetState())     fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2, 1,1,10,AliMagF::k5kG));//0.5 Tesla field\n");
+  else if(fMagBG->GetButton(kFld_2)->GetState())    fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2,-1,1,10,AliMagF::k2kG));//-0.2 Tesla field\n");
+  else if(fMagBG->GetButton(kFld_4)->GetState())    fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2,-1,1,10,AliMagF::k4kG));//-0.4 Tesla field\n");
+  else if(fMagBG->GetButton(kFld_5)->GetState())    fprintf(fp,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",2,-1,1,10,AliMagF::k5kG));//-0.5 Tesla field\n");
+*/  
                                                     fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
+                                                    fprintf(fp,"  gBenchmark->Start(\"ALICE\"); TDatime time;      //start benchmarking\n\n");
+                                                    
+    //---------------------------------------------
+    if     (fTrkBG->GetButton(kRecoPar)->GetState())
+      { 
+         fprintf(fp,"  AliHMPIDRecoParamV1 *hmpidRecoParam=AliHMPIDReconstructor::GetRecoParam();    //Get the HMPID reco param\n"); 
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(0,4);                                            //eg cut for UserCutSigma (Values: ch0)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(1,4);                                            //eg cut for UserCutSigma (Values: ch1)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(2,4);                                            //eg cut for UserCutSigma (Values: ch2)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(3,4);                                            //eg cut for UserCutSigma (Values: ch3)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(4,4);                                            //eg cut for UserCutSigma (Values: ch4)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(5,4);                                            //eg cut for UserCutSigma (Values: ch5)\n");
+         fprintf(fp,"  hmpidRecoParam->SetHmpUserCut(6,4);                                            //eg cut for UserCutSigma (Values: ch6)\n");
+         fprintf(fp,"  AliHMPIDReconstructor::SetRecoParam(hmpidRecoParam);                          //Pass the RecoPar to the Reconstructor\n");
+      }
+    //---------------------------------------------                                                    
                                                     
     if     (fInpBG->GetButton(kNo )->GetState())    fprintf(fp,"  pRec->SetInput(\"\");                       //from digits\n");   
     else if(fInpBG->GetButton(kDdl)->GetState())    fprintf(fp,"  pRec->SetInput(\"./\");                     //from raw data in DDL format\n");                                            
@@ -653,6 +697,8 @@ void HmpConfig::WriteBatch()
     else if(fCluBG->GetButton(kHmp) ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"HMPID\"); //clusters for HMPID only\n");
     else if(fCluBG->GetButton(kNo)  ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"\");      //no clusters\n");
     
+    
+    
     if     (fTrkBG->GetButton(kAln)->GetState())    fprintf(fp,"  pRec->SetLoadAlignData(\"%s\");            //with misalignment\n",det.Data());     
     else                                            fprintf(fp,"  pRec->SetLoadAlignData(\"\");               //no misalignment\n");     
   
@@ -668,11 +714,11 @@ void HmpConfig::WriteBatch()
                                                     fprintf(fp,"  pRec->Run();delete pRec;\n\n");         
   }//rec part                                                       
 //benchmarks  
-                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/Batch.C>: Start time: \";time.Print();\n");
-                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/Batch.C>: Stop  time: \";time.Set();  time.Print();\n");
+                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <rec.C>: Start time: \";time.Print();\n");
+                                                    fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <rec.C>: Stop  time: \";time.Set();  time.Print();\n");
                                                     fprintf(fp,"  gBenchmark->Show(\"ALICE\");\n");
   
-                                                    fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n}\n");
+                                                    fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______RRR\");\n}\n");
   fclose(fp);  
 }//WriteBatch()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -694,17 +740,22 @@ void HmpConfig::WriteConfig()
   fprintf(pF,"\n  ::Info(\"\\n\\n\\n----------> HMPID private config\",\"Start\");\n"); 
 //Random
   fprintf(pF,"  gRandom->SetSeed(123456);//put 0 to use system time\n\n");    
-//Geant  
-  fprintf(pF,"  gSystem->Load(\"libgeant321\");\n");
-  fprintf(pF,"  new TGeant3TGeo(\"C++ Interface to Geant3\");\n\n");
 //File
   fprintf(pF,"  AliRunLoader *pAL=AliRunLoader::Open(\"galice.root\",AliConfig::GetDefaultEventFolderName(),\"recreate\");\n");    
   fprintf(pF,"  pAL->SetCompressionLevel(2);\n");
   fprintf(pF,"  pAL->SetNumberOfEventsPerFile(1000);\n");
   fprintf(pF,"  gAlice->SetRunLoader(pAL);\n\n");
 //Decayer  
-  if(fDecayerB->GetState()==kButtonDown){   
-    fprintf(pF,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
+  if(fDecayerB->GetState()==kButtonDown){
+    fprintf(pF,"  gSystem->Load(\"liblhapdf\"); // Parton density functions \n");
+    fprintf(pF,"  gSystem->Load(\"libEGPythia6\");   // TGenerator interface \n");
+    fprintf(pF,"  gSystem->Load(\"libpythia6\");   // Pythia \n");
+    fprintf(pF,"  gSystem->Load(\"libAliPythia6\");   // ALICE specifics implementations \n\n");
+//Geant  
+    fprintf(pF,"  gSystem->Load(\"libgeant321\");\n");
+    fprintf(pF,"  new TGeant3TGeo(\"C++ Interface to Geant3\");\n\n");
+  
+    fprintf(pF,"  AliDecayer *pDecayer=new AliDecayerPythia();\n");
     fprintf(pF,"  pDecayer->SetForceDecay(kAll);\n"); 
     fprintf(pF,"  pDecayer->Init();\n"); 
     fprintf(pF,"  gMC->SetExternalDecayer(pDecayer);\n\n");
@@ -712,13 +763,13 @@ void HmpConfig::WriteConfig()
   WritePhys(pF); //physics processes
   
 //Field
-       if(fMagBG->GetButton(kFld0)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",0,1,10,0));       //no field\n\n");
-  else if(fMagBG->GetButton(kFld2)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,0));//0.2 Tesla field\n\n");
-  else if(fMagBG->GetButton(kFld4)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,1));//0.4 Tesla field\n\n");
-  else if(fMagBG->GetButton(kFld5)->GetState())     fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,1,10,2));//0.5 Tesla field\n\n");
-  else if(fMagBG->GetButton(kFld_2)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,0));//-0.2 Tesla field\n\n");
-  else if(fMagBG->GetButton(kFld_4)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,1));//-0.4 Tesla field\n\n");
-  else if(fMagBG->GetButton(kFld_5)->GetState())    fprintf(pF,"  gAlice->SetField(new AliMagFMaps(\"Maps\",\"Maps\",2,-1,10,2));//-0.5 Tesla field\n\n");
+       if(fMagBG->GetButton(kFld0)->GetState())     fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",0,0,AliMagF::k5kGUniform));// NO field\n");
+  else if(fMagBG->GetButton(kFld2)->GetState())     fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",1,1,AliMagF::k2kG));//0.2 Tesla field\n");
+       //  else if(fMagBG->GetButton(kFld4)->GetState())     fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",1,1,AliMagF::k4kG));//0.4 Tesla field\n");
+  else if(fMagBG->GetButton(kFld5)->GetState())     fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",1,1,AliMagF::k5kG));//0.5 Tesla field\n");
+  else if(fMagBG->GetButton(kFld_2)->GetState())    fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",-1,1,AliMagF::k2kG));//-0.2 Tesla field\n");
+       //  else if(fMagBG->GetButton(kFld_4)->GetState())    fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",-1,1,AliMagF::k4kG));//-0.4 Tesla field\n");
+  else if(fMagBG->GetButton(kFld_5)->GetState())    fprintf(pF,"  TGeoGlobalMagField::Instance()->SetField(new AliMagF(\"Maps\",\"Maps\",-1,1,AliMagF::k5kG));//-0.5 Tesla field\n");
   
   fprintf(pF,"  pAL->CdGAFile();\n\n");                                 //????       
 //Generator 
@@ -729,7 +780,8 @@ void HmpConfig::WriteConfig()
   WriteHmp(pF);  //private HMPID part
   WriteDet(pF);  //other detectors
 //end of Config.C file:  
-  fprintf(pF,"\n  ::Info(\"----------> HMPID private config\",\"Stop\\n\\n\\n\");\n"); 
+  fprintf(pF,"\n  ::Info(\"----------> HMPID private config\",\"Stop\\n\\n\\n\");\n");
+//
   fprintf(pF,"}\n");
   fclose(pF);  
 }//WriteConfig()
@@ -738,3 +790,13 @@ void Hconfig()
 {
    new HmpConfig("Config.C");
 }   
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void CheckGeometry()
+{
+  if(!(gSystem->IsFileInIncludePath("geometry.root"))) {
+    Printf("");
+    Printf("HConfig needs for the geometry.root file. Please put it in the current dir!. Bye.");
+    Printf("");
+    gApplication->Terminate(0);
+  }
+}