minor impovements
authorkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Oct 2005 12:12:14 +0000 (12:12 +0000)
committerkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Oct 2005 12:12:14 +0000 (12:12 +0000)
RICH/RichConfig.C
RICH/RichGeom.C

index 1512a4254e4a05fea33a8ba4e0aedbd3d3b68f99..6dc496fa1d8d8f3cd17daac951aef0cd86477587 100644 (file)
@@ -4,157 +4,112 @@ class RichConfig : public TGMainFrame
 {
 RQ_OBJECT()
 public:
           RichConfig(const char*sFileName);
          ~RichConfig()                    {Info("ctor","");Cleanup();}
-//protected:
-  enum EVersOpts  {kNo=-1,kVer0,kVer1,kTestBeam,kTestRadio,kOnTop,kDeclust=301,kSagita,kFeedback};
-  enum EGenTypes  {kGunAlongZ=100,kBox1,kBox7,kGun7,kPythia7,kHijing,kHijingPara,kRichLib,kSignalHijing,kHijingPara2Proton};
+         
+  enum EVersOpts  {kNo=101,kVer0,kVer1,kVer2,kTest, kDeclust=301,kSagita,kFeedback,kSecRad,kQe0=400,kQeNorm,kOptics};
+  enum EGenTypes  {kGunZ=1,kGun1,kGun7,kBox1,kBox7,kHijing,kHijingPara,kPythia,kRichLib,kNotUsed=999};
   
-  enum EDetectors {kPIPE=1,kITS,kTPC,kTRD,kTOF,kFRAME,kMAG,kCRT,kHALL,kPHOS,kSTART,kFMD,kABSO,kPMD,kDIPO,kEMCAL,kVZERO,kMUON,kZDC,kSHILD,kRICH};
+  enum EDetectors {kPIPE=1,kITS,kTPC,kTRD,kTOF,kFRAME,kMAG,kCRT,kHALL,kPHOS,kSTART,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{kNoRaw=0,kRawDdl,kRawDate,kRawRoot,kRecon,kFillEsd};
-//SLOTS  
-  void    AddDetector(Int_t id)          {if(id==kTRD || id==kTOF) fDetBG->SetButton(kFRAME);}
-  void    RemoveDetector(Int_t id)       {if(id==kFRAME) {fDetBG->SetButton(kTRD,kFALSE);fDetBG->SetButton(kTOF,kFALSE);}}
+  enum EBatchFlags{kPrim=555,kTransport,kAll,kOnly,kRawDdl,kRawDate,kRawRoot,kVertex,kTrack,kEsd};
   
-  void    AddProcess(Int_t id)           {if(id==kALL) for(int i=1;i<=fProcBG->GetCount();i++) fProcBG->SetButton(i,kButtonDown);}
-  void    RemoveProcess(Int_t id)        {if(id==kALL) for(int i=1;i<=fProcBG->GetCount();i++) fProcBG->SetButton(i,kButtonUp);}
-  void    GeneratorSlot(Int_t type);
-  void    VerSlot(Int_t ver)             {if(ver==kTestBeam){ fMagCB->SetState(kButtonUp); fGenTypeCO->Select(kGunAlongZ);}}        
+  Float_t Eta2Theta      (Float_t arg)  const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
   
-  Float_t Eta2Theta(Float_t arg)    const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
-  void    CreateConfig();      //create Config.C
-  void    Generator(FILE *pF); //write generatro part of Config.C
-  void    CreateRichBatch();   //create RichBatch.C
-  void    Exit();
+  void GuiRich (TGHorizontalFrame *pMainF);  void WriteRich (FILE *pF);  void RichSlot   (Int_t ver);
+  void GuiPhys (TGHorizontalFrame *pMainF);  void WritePhys (FILE *pF);  void PhysAddSlot(Int_t id); void PhysRemSlot(Int_t id);
+  void GuiGen  (TGCompositeFrame  *pMainF);  void WriteGen  (FILE *pF);  void GenAddSlot (Int_t id); void GenRemSlot (Int_t id);
+  void GuiDet  (TGHorizontalFrame *pMainF);  void WriteDet  (FILE *pF);  void DetAddSlot (Int_t id); void DetRemSlot (Int_t id);
+  void GuiBatch(TGHorizontalFrame *pMainF);  void WriteBatch(        );
+  
+  void    WriteConfig();
+  void    ExitSlot();
      
-  TGComboBox   *fRichCO;  TGButtonGroup *fRichBG;                                                                              //RICH
-  TGButton     *fMagCB;                                                                                                     //MAG
-  TGComboBox   *fGenTypeCO,*fGenPidCO,*fGenMinMomCO,*fGenMaxMomCO,*fGenChamberCO; TGGroupFrame *fGenGF,*fGenOptGF,*fGenPrimGF; TGNumberEntry *fGenPrimNE;             //GEN
-  TGButtonGroup *fDetBG;                                                                                                       //DETECTORS
-  TGButtonGroup *fProcBG;                                                                                                      //PROCESSES
-  TGButtonGroup *fRawBG;                                                                                                       //RAW 
-  TGButtonGroup *fRecoBG;                                                                                                      //RAW   
-  char         *fFileName;
+  TGButtonGroup *fVerBG,*fOptBG,*fQeBG; //Rich widgets  
+  TGButton      *fMagB;                 //magnet field widgets
+  
+  TGComboBox        *fGenPidCO,*fGenPminCO,*fGenPmaxCO,*fGenChamCO,*fGenNprimCO; //generator widgets combos
+  TGCompositeFrame  *fGenF;                                                     //generator widgets frames     
+  TGButtonGroup     *fGenBG;                                                    //generator widgets
+  
+  TGButtonGroup *fDetBG,*fProcBG;                                      //detectors and processes widgets
+  TGButtonGroup *fSimBG,*fSDigBG,*fDigBG,*fRawBG,*fClusBG,*fRecoBG;    //batch control widgets
+
+   char         *fFileName;
 };//class RichConfig
 //__________________________________________________________________________________________________    
 RichConfig::RichConfig(const char *sFileName):TGMainFrame(gClient->GetRoot(),700,400)
-{// creates configuration file  
+{
   fFileName=sFileName;
 
-//  --------------------  
-//  | |--------------------
-//  | ||-------|
-//  | ||       |
-//  | ||-------|
-//  | |  
-//  | ||-------|   
-  
-//  | |--------------------
-//  | ---------------------         
+  AddFrame(pMainF=new TGHorizontalFrame(this,100,200)); //main horizontal frame
   
-//  Connect("CloseWindow()","RichConfig",this,"CloseWindow()");   
-  AddFrame(pMainHF=new TGHorizontalFrame(this,100,200)); //main horizontal frame
-//Left vertical frame containing RICH and MagField  
-  pMainHF->AddFrame(pLeftVF=new TGVerticalFrame(pMainHF,100,200));  
-//RICH
-  pLeftVF->AddFrame(pRichGF=new TGGroupFrame(pLeftVF,"RICH"));
-  pRichGF->AddFrame(fRichCO=new TGComboBox(pRichGF,100));
-  fRichCO->Connect("Selected(Int_t)" ,"RichConfig",this,"VerSlot(Int_t)");
-    fRichCO->AddEntry("no RICH"      ,kNo);
-    fRichCO->AddEntry("debug RICH 0" ,kVer0);
-    fRichCO->AddEntry("normal RICH 1",kVer1);
-    fRichCO->AddEntry("RICH on top"  ,kOnTop);
-    fRichCO->AddEntry("test beam"    ,kTestBeam);
-    fRichCO->AddEntry("radio source" ,kTestRadio);
-    fRichCO->Select(kVer1); 
-    fRichCO->Resize(150,20);
-  pRichGF->AddFrame(fRichBG=new TGButtonGroup(pRichGF,"Options"));
-    new TGCheckButton(fRichBG,"Decluster?"   ,kDeclust);      fRichBG->SetButton(kDeclust);
-    new TGCheckButton(fRichBG,"Wire sagita?" ,kSagita);       fRichBG->SetButton(kSagita);
-    new TGCheckButton(fRichBG,"Feedbacks?"   ,kFeedback);     fRichBG->SetButton(kFeedback); 
 // Magnetic Field
-  pLeftVF->AddFrame(pMagGF=new TGGroupFrame(pLeftVF,"Magnetic Field"));
-  pMagGF->AddFrame(fMagCB=new TGCheckButton(pMagGF,"On/Off"));
-  fMagCB->SetState(kButtonDown);
-//Generator  
-  pMainHF->AddFrame(fGenGF=new TGGroupFrame(pMainHF,"Generator"));
-  fGenGF->AddFrame(fGenTypeCO=new TGComboBox(fGenGF,100));
-  fGenTypeCO->Connect("Selected(Int_t)" ,"RichConfig",this,"GeneratorSlot(Int_t)");
-  fGenTypeCO->AddEntry("gun along z"                  ,kGunAlongZ);  
-  fGenTypeCO->AddEntry("box gun to single chamber"    ,kBox1);  
-  fGenTypeCO->AddEntry("gun to all chambers"          ,kGun7);
-  fGenTypeCO->AddEntry("box to all chambers"          ,kBox7);
-  fGenTypeCO->AddEntry("7 guns+Pythia"                ,kPythia7);
-  fGenTypeCO->AddEntry("HIJING"                       ,kHijing);
-  fGenTypeCO->AddEntry("HIJING para"                  ,kHijingPara);
-  fGenTypeCO->AddEntry("2 p+HIJING"                   ,kHijingPara2Proton);
-  fGenTypeCO->AddEntry("RICH lib"                     ,kRichLib);
-  fGenTypeCO->AddEntry("RICH lib+HIJING"              ,kSignalHijing);
-  fGenTypeCO->Select(kHijing);
-  fGenTypeCO->Resize(160,20);
+  pMainF->AddFrame(fMagB=new TGCheckButton(pMainF,"Mag field On/Off"));  fMagB->SetState(kButtonDown);
   
+  GuiRich (pMainF);
+  GuiGen  (pMainF);   
+  GuiDet  (pMainF);
+  GuiPhys (pMainF);
+  GuiBatch(pMainF);  
   
-  fGenGF->AddFrame(fGenOptGF=new TGGroupFrame(fGenGF,"Options")); //PID for guns
-
-  
-  fGenOptGF->AddFrame(fGenPidCO=new TGComboBox(fGenOptGF,100)); //PID for guns
-  fGenPidCO->AddEntry("Pion+"     ,kPiPlus);
-  fGenPidCO->AddEntry("Pion-"     ,kPiMinus);
-  fGenPidCO->AddEntry("Kaon+"     ,kKPlus);
-  fGenPidCO->AddEntry("Kaon-"     ,kKMinus);
-  fGenPidCO->AddEntry("K0s"       ,kK0Short);    
-  fGenPidCO->AddEntry("Proton"    ,kProton);
-  fGenPidCO->AddEntry("ProtonBar" ,kProtonBar);
-  fGenPidCO->AddEntry("Lambda"    ,kLambda0);
-  fGenPidCO->AddEntry("LambdaBar" ,kLambda0Bar);
-  fGenPidCO->Select(kProton);  fGenPidCO->Resize(160,20);
-
-  fGenOptGF->AddFrame(fGenMinMomCO=new TGComboBox(fGenOptGF,100)); //particle energy for guns  
-  for(Int_t i=5;i<=95;i+=5)
-    fGenMinMomCO->AddEntry(Form("%3.1f GeV",0.1*i), i);
-  fGenMinMomCO->Select(15);  fGenMinMomCO->Resize(160,20);
-  
-  fGenOptGF->AddFrame(fGenMaxMomCO=new TGComboBox(fGenOptGF,100)); //particle energy for guns
-  for(Int_t i=10;i<=95;i+=5)
-    fGenMaxMomCO->AddEntry(Form("%3.1f GeV",0.1*i), i);
-  fGenMaxMomCO->Select(40);  fGenMaxMomCO->Resize(160,20);
-  
-  fGenOptGF->AddFrame(fGenChamberCO=new TGComboBox(fGenOptGF,100)); //chamber number in case of gun1
-  for(int i=1;i<=7;i++) fGenChamberCO->AddEntry(Form("Chamber %i",i),i);
-  fGenChamberCO->Select(4); fGenChamberCO->Resize(160,20);
+//File    
+  AddFrame(pFileHF=new TGHorizontalFrame(this,100,200));
+  pFileHF->AddFrame(pCrtTB=new TGTextButton(pFileHF,"Create"));
+  pCrtTB->Connect("Clicked()","RichConfig",this,"ExitSlot()");                                 
+  pFileHF->AddFrame(new TGLabel(pFileHF,Form(" config file as %s",fFileName)));  
   
-  fGenOptGF->AddFrame(fGenPrimGF=new TGGroupFrame(fGenOptGF,"Number of primaries"));
-  fGenPrimGF->AddFrame(fGenPrimNE=new TGNumberEntry(fGenPrimGF,500));  
-//Detectors
-  pMainHF->AddFrame(fDetBG=new TGButtonGroup(pMainHF,"Detectors"));
-  fDetBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"AddDetector(Int_t)");
-  fDetBG->Connect("Released(Int_t)","RichConfig",this,"RemoveDetector(Int_t)");
-    new TGCheckButton(fDetBG,"PIPE"  ,kPIPE));         
-    new TGCheckButton(fDetBG,"ITS"   ,kITS));         
-    new TGCheckButton(fDetBG,"TPC"   ,kTPC));
-    new TGCheckButton(fDetBG,"TRD"   ,kTRD));
-    new TGCheckButton(fDetBG,"TOF"   ,kTOF));         
-    new TGCheckButton(fDetBG,"FRAME" ,kFRAME));         
-    new TGCheckButton(fDetBG,"MAG"   ,kMAG));         
-    new TGCheckButton(fDetBG,"CRT"   ,kCRT));         
-    new TGCheckButton(fDetBG,"HALL"  ,kHALL));         
-    new TGCheckButton(fDetBG,"PHOS"  ,kPHOS));         
-    new TGCheckButton(fDetBG,"START" ,kSTART));         
-    new TGCheckButton(fDetBG,"FMD"   ,kFMD));         
-    new TGCheckButton(fDetBG,"ABSO"  ,kABSO));         
-    new TGCheckButton(fDetBG,"PMD"   ,kPMD));         
-    new TGCheckButton(fDetBG,"DIPO"  ,kDIPO));         
-    new TGCheckButton(fDetBG,"EMCAL" ,kEMCAL));         
-    new TGCheckButton(fDetBG,"VZERO" ,kVZERO));         
-    new TGCheckButton(fDetBG,"MUON"  ,kMUON));         
-    new TGCheckButton(fDetBG,"ZDC"   ,kZDC));         
-    new TGCheckButton(fDetBG,"SHILD" ,kSHILD));         
-//Processes  
+  MapSubwindows();   
+  Resize(GetDefaultSize());
+  SetWindowName("Create AliROOT scripts");
+  MapWindow(); 
+}//KirCondig::ctor
+//__________________________________________________________________________________________________          
+void RichConfig::GuiRich(TGHorizontalFrame *pMainHF)
+{
+  pMainHF->AddFrame(pLeftVF=new TGVerticalFrame(pMainHF,100,200));  
+  pLeftVF->AddFrame(pRichGF=new TGGroupFrame(pLeftVF,"RICH"));
+  pRichGF->AddFrame(fVerBG=new TGButtonGroup(pRichGF,""));  fVerBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"RichVerSlot(Int_t)");
+    new TGRadioButton(fVerBG,   "No"         ,kNo       ));   
+    new TGRadioButton(fVerBG,   "ver0"       ,kVer0     ));
+    new TGRadioButton(fVerBG,   "ver1"       ,kVer1     ));  fVerBG->SetButton(kVer1);
+    new TGRadioButton(fVerBG,   "ver2"       ,kVer2     ));
+  pRichGF->AddFrame(fOptBG=new TGButtonGroup(pRichGF,""));  fOptBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"RichVerSlot(Int_t)");
+    new TGCheckButton(fOptBG,"Test beam position?"  ,kTest);       
+    new TGCheckButton(fOptBG,"Second radiator?"     ,kSecRad);       
+    new TGCheckButton(fOptBG,"Decluster?"           ,kDeclust);      fOptBG->SetButton(kDeclust);
+    new TGCheckButton(fOptBG,"Wire sagita?"         ,kSagita);       fOptBG->SetButton(kSagita);
+    new TGCheckButton(fOptBG,"Feedbacks?"           ,kFeedback);     fOptBG->SetButton(kFeedback); 
+    new TGCheckButton(fOptBG,"Plot optics?"         ,kOptics);     
+  pRichGF->AddFrame(fQeBG=new TGButtonGroup(pRichGF,""));
+    new TGRadioButton(fQeBG,"QE=0"                 ,kQe0);       
+    new TGRadioButton(fQeBG,"QE normal"            ,kQeNorm);       fQeBG->SetButton(kQeNorm);
+}//Rich()
+//__________________________________________________________________________________________________
+void RichConfig::RichVerSlot(Int_t ver)  
+{
+  if(ver==kTest)    {fMagB->SetState(kButtonUp); fGenBG->SetButton(kGunZ); }
+} 
+//__________________________________________________________________________________________________
+void RichConfig::WriteRich(FILE *pF)
+{
+  if(!fVerBG->GetButton(kNo)->GetState()){
+    if( fOptBG->GetButton(kSecRad)->GetState())             fprintf(pF,"  AliRICHParam::fgIsSecondRadiator=kTRUE;\n");
+    if(!fOptBG->GetButton(kSagita)->GetState())             fprintf(pF,"  AliRICHParam::fgIsWireSagita=kFALSE;\n");
+    if( fOptBG->GetButton(kTest)  ->GetState())             fprintf(pF,"  AliRICHParam::fgIsTestBeam=kTRUE;\n");    
+    if( fOptBG->GetButton(kTest)  ->GetState())             fprintf(pF,"  AliRICHParam::fgIsOptDisp=kTRUE;\n");    
+    
+    if     (fVerBG->GetButton(kVer0)->GetState())           fprintf(pF,"  AliRICH *pRICH=new AliRICHv0(\"Debug\");\n\n");    
+    else if(fVerBG->GetButton(kVer1)->GetState())           fprintf(pF,"  AliRICH *pRICH=new AliRICHv1(\"RICH\",\"Normal RICH\");\n\n");   
+    else if(fVerBG->GetButton(kVer2)->GetState())           fprintf(pF,"  AliRICH *pRICH=new AliRICHv2(\"New Rich\");\n\n");   
+  }
+}
+//__________________________________________________________________________________________________
+void RichConfig::GuiPhys(TGHorizontalFrame *pMainHF)
+{
   pMainHF->AddFrame(fProcBG=new TGButtonGroup(pMainHF,"Processes"));
-  fProcBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"AddProcess(Int_t)");
-  fProcBG->Connect("Released(Int_t)","RichConfig",this,"RemoveProcess(Int_t)");
+  fProcBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"PhysAddSlot(Int_t)");
+  fProcBG->Connect("Released(Int_t)","RichConfig",this,"PhysRemSlot(Int_t)");
     new TGCheckButton(fProcBG,"ALL  ON/OFF"                 ,kALL)) ;
     new TGCheckButton(fProcBG,"DCAY Decay"                  ,kDCAY));  fProcBG->SetButton(kDCAY);       
     new TGCheckButton(fProcBG,"PAIR Pair production"        ,kPAIR));  fProcBG->SetButton(kPAIR);       
@@ -169,325 +124,472 @@ RichConfig::RichConfig(const char *sFileName):TGMainFrame(gClient->GetRoot(),700
     new TGCheckButton(fProcBG,"HADR Hadronic interactions " ,kHADR));  fProcBG->SetButton(kHADR);       
     new TGCheckButton(fProcBG,"LOSS Energy losses"          ,kLOSS));  fProcBG->SetButton(kLOSS);       
     new TGCheckButton(fProcBG,"MULS Multiple scattering"    ,kMULS));  fProcBG->SetButton(kMULS);       
-    new TGCheckButton(fProcBG,"RAYL"                        ,kRAYL));  fProcBG->SetButton(kRAYL);       
-//RichBatch part
-  pMainHF->AddFrame(pBatchVF=new TGVerticalFrame(pMainHF));    
-  pBatchVF->AddFrame(fRawBG=new TGButtonGroup(pBatchVF,"RichBatch"));
-    new TGRadioButton(fRawBG,"No RAW files"      ,kNoRaw)) ;   fRawBG->SetButton(kNoRaw);
-    new TGRadioButton(fRawBG,"RAW DDL"           ,kRawDdl)) ;
-    new TGRadioButton(fRawBG,"RAW DATE"          ,kRawDate)) ;
-    new TGRadioButton(fRawBG,"RAW ROOT"          ,kRawRoot)) ;
-  fRawBG->AddFrame(fRecoBG=new TGButtonGroup(fRawBG,""));
-    new TGCheckButton(fRecoBG,"Reconstruct"    ,kRecon)) ; fRecoBG->SetButton(kRecon);  
-    new TGCheckButton(fRecoBG,"Fill ESD"       ,kFillEsd)) ; fRecoBG->SetButton(kFillEsd);
-//File    
-  AddFrame(pFileHF=new TGHorizontalFrame(this,100,200));
-  pFileHF->AddFrame(pCrtTB=new TGTextButton(pFileHF,"Create"));
-  pCrtTB->Connect("Clicked()","RichConfig",this,"Exit()");                                 
-  pFileHF->AddFrame(new TGLabel(pFileHF,Form(" config file as %s",fFileName)));  
-  
-  MapSubwindows();   
-  //Layout(); 
-  Resize(GetDefaultSize());
-  SetWindowName("Create AliROOT scripts");
-  MapWindow();      
-}//KirCondig::ctor
+    new TGCheckButton(fProcBG,"RAYL Rayleigh scattering"    ,kRAYL));  fProcBG->SetButton(kRAYL);       
+}
 //__________________________________________________________________________________________________
-void RichConfig::GeneratorSlot(Int_t type)
-{//enable-disable generator widegets according to generator type
-  if(type==kHijing) fGenGF->HideFrame(fGenOptGF); 
+void RichConfig::PhysAddSlot(Int_t id)
+{//slot is invoked when any of physics check button is pressed
+  if(id==kALL)  //if the pressed check button is kALL then switch on all the buttons 
+    for(int i=1;i<=fProcBG->GetCount();i++) 
+      fProcBG->SetButton(i,kButtonDown);
+}
+//__________________________________________________________________________________________________
+void  RichConfig::PhysRemSlot(Int_t id)
+{//slot is invoked when any of physics check button is released
+  if(id==kALL) //if the released check button is kALL then switch off all the buttons 
+    for(int i=1;i<=fProcBG->GetCount();i++) 
+      fProcBG->SetButton(i,kButtonUp);
+}
+//__________________________________________________________________________________________________
+void RichConfig::WritePhys(FILE *pF)
+{
+  if(fProcBG->GetButton(kDCAY)->GetState()) fprintf(pF,"  gMC->SetProcess(\"DCAY\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"DCAY\",0);  ");
+  if(fProcBG->GetButton(kPAIR)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PAIR\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PAIR\",0);  ");
+  if(fProcBG->GetButton(kCOMP)->GetState()) fprintf(pF,"  gMC->SetProcess(\"COMP\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"COMP\",0);\n");
+  if(fProcBG->GetButton(kPHOT)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PHOT\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PHOT\",0);  ");
+  if(fProcBG->GetButton(kPFIS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"PFIS\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"PFIS\",0);  ");
+  if(fProcBG->GetButton(kDRAY)->GetState()) fprintf(pF,"  gMC->SetProcess(\"DRAY\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"DRAY\",0);\n");
+  if(fProcBG->GetButton(kANNI)->GetState()) fprintf(pF,"  gMC->SetProcess(\"ANNI\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"ANNI\",0);  ");
+  if(fProcBG->GetButton(kBREM)->GetState()) fprintf(pF,"  gMC->SetProcess(\"BREM\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"BREM\",0);  ");
+  if(fProcBG->GetButton(kMUNU)->GetState()) fprintf(pF,"  gMC->SetProcess(\"MUNU\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"MUNU\",0);\n");
+  if(fProcBG->GetButton(kCKOV)->GetState()) fprintf(pF,"  gMC->SetProcess(\"CKOV\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"CKOV\",0);  ");
+  if(fProcBG->GetButton(kHADR)->GetState()) fprintf(pF,"  gMC->SetProcess(\"HADR\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"HADR\",0);  ");
+  if(fProcBG->GetButton(kLOSS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"LOSS\",2);\n");else fprintf(pF,"  gMC->SetProcess(\"LOSS\",0);\n");
+  if(fProcBG->GetButton(kMULS)->GetState()) fprintf(pF,"  gMC->SetProcess(\"MULS\",1);  ");else fprintf(pF,"  gMC->SetProcess(\"MULS\",0);  ");
+  if(fProcBG->GetButton(kRAYL)->GetState()) fprintf(pF,"  gMC->SetProcess(\"RAYL\",1);\n");else fprintf(pF,"  gMC->SetProcess(\"RAYL\",0);\n");
   
-  if(type==kHijingPara){
-    fGenGF->ShowFrame(fGenOptGF);
-    fGenOptGF->ShowFrame(fGenPrimGF);        
-    fGenOptGF->HideFrame(fGenPidCO);
-    fGenOptGF->HideFrame(fGenMinMomCO);
-    fGenOptGF->HideFrame(fGenMaxMomCO);
-    fGenOptGF->HideFrame(fGenChamberCO);
+  fprintf(pF,"\n");  
+  fprintf(pF,"  gMC->SetCut(\"CUTGAM\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTELE\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTNEU\",0.001);\n"); 
+  fprintf(pF,"  gMC->SetCut(\"CUTHAD\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"CUTMUO\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"BCUTE\" ,0.001);\n");
+  fprintf(pF,"  gMC->SetCut(\"BCUTM\" ,0.001);  "); fprintf(pF,"  gMC->SetCut(\"DCUTE\" ,0.001);  "); fprintf(pF,"  gMC->SetCut(\"DCUTM\" ,0.001);\n"); 
+  fprintf(pF,"  gMC->SetCut(\"PPCUTM\",0.001);  "); fprintf(pF,"  gMC->SetCut(\"TOFMAX\",1e10);\n\n"); 
+}//WritePhys()
+//__________________________________________________________________________________________________
+void RichConfig::GuiGen(TGCompositeFrame *pMainF)
+{//generator configurator implemented as group of radio buttons
+  pMainF->AddFrame(fGenF=new TGVerticalFrame(pMainF));//add generator vertical frame to horizontal main frame
+  fGenF->AddFrame(fGenBG=new TGButtonGroup(fGenF,"Generator"));//add type button group to vertical generator frame
+  fGenBG->Connect("Pressed(Int_t)","RichConfig",this,"GenAddSlot(Int_t)"); fGenBG->Connect("Released(Int_t)","RichConfig",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 to 1 chamber"      ,kBox1);  
+    new TGCheckButton(fGenBG,"box to 7 chambers"     ,kBox7);
+    new TGCheckButton(fGenBG,"HIJING"                ,kHijing);
+    new TGCheckButton(fGenBG,"HIJING para"           ,kHijingPara);
+    new TGCheckButton(fGenBG,"Pythia"                ,kPythia);
+    new TGCheckButton(fGenBG,"RICH lib"              ,kRichLib);
+//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=500"  ,5);
+  fGenNprimCO->AddEntry("N prim=80000",80000);  fGenNprimCO->Resize(160,20);   fGenNprimCO->Select(kNotUsed);
+//PID    
+  fGenF->AddFrame(fGenPidCO=new TGComboBox(fGenF,100)); //add pid combo to generator vertical frame
+  fGenPidCO->AddEntry("not used"   ,kNotUsed);
+  fGenPidCO->AddEntry("electron"   ,kElectron);
+  fGenPidCO->AddEntry("positron"   ,kPositron);
+  fGenPidCO->AddEntry("pion +"     ,kPiPlus);
+  fGenPidCO->AddEntry("pion -"     ,kPiMinus);
+  fGenPidCO->AddEntry("kaon +"     ,kKPlus);
+  fGenPidCO->AddEntry("kaon -"     ,kKMinus);
+  fGenPidCO->AddEntry("kaon 0"     ,kK0Short);    
+  fGenPidCO->AddEntry("proton"     ,kProton);
+  fGenPidCO->AddEntry("antiproton" ,kProtonBar);
+  fGenPidCO->AddEntry("lambda"     ,kLambda0);
+  fGenPidCO->AddEntry("antilambda" ,kLambda0Bar);  fGenPidCO->Resize(160,20); fGenPidCO->Select(kNotUsed);
+//Pmin  
+  fGenF->AddFrame(fGenPminCO=new TGComboBox(fGenF,100)); //add Pmin combo to generator vertical frame  
+  fGenPminCO->AddEntry("not used",kNotUsed);
+  for(Int_t i=5;i<=295;i+=5) fGenPminCO->AddEntry(Form("Pmin=%3.1f GeV",0.1*i), i); fGenPminCO->Resize(160,20); fGenPminCO->Select(kNotUsed);
+//Pmax  
+  fGenF->AddFrame(fGenPmaxCO=new TGComboBox(fGenF,100)); //add Pmax combo to generator vertical frame
+  fGenPmaxCO->AddEntry("not used",kNotUsed);
+  for(Int_t i=10;i<=295;i+=5) fGenPmaxCO->AddEntry(Form("Pmax=%3.1f GeV",0.1*i), i);  fGenPmaxCO->Resize(160,20); fGenPmaxCO->Select(kNotUsed);
+//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);
+}//GuiGen()
+//__________________________________________________________________________________________________
+void RichConfig::GenAddSlot(Int_t id)
+{//is invoked when any of generator check button is pressed
+  if(id==kGunZ){
+    fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO);
+    fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);                                fGenPidCO->Select(kProton);
+    fGenBG->GetButton(kBox1)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenPmaxCO); fGenPminCO->Select(25);
+    fGenBG->GetButton(kBox7)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenChamCO); 
+  } 
+  if(id==kGun1){
+    fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO);
+    fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenPmaxCO); 
+    fGenBG->GetButton(kBox1)->SetEnabled(kFALSE);  
+    fGenBG->GetButton(kBox7)->SetEnabled(kFALSE);  fGenPidCO->Select(kProton); fGenPminCO->Select(25); fGenChamCO->Select(4);
   }
-  
-  if(type==kGunAlongZ) {
-    fGenGF->ShowFrame(fGenOptGF);
-    fGenOptGF->ShowFrame(fGenPidCO);
-    fGenOptGF->ShowFrame(fGenMinMomCO);
-    fGenOptGF->HideFrame(fGenMaxMomCO);
-    fGenOptGF->HideFrame(fGenChamberCO);
-    fGenOptGF->HideFrame(fGenPrimGF);    
+  if(id==kGun7){
+    fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenNprimCO);
+    fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPidCO->Select(kProton); 
+    fGenBG->GetButton(kBox1)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenPmaxCO); fGenPminCO->Select(25);
+    fGenBG->GetButton(kBox7)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenChamCO); 
+  } 
+  if(id==kBox1){
+    fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);                                fGenNprimCO->Select(1);
+    fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPidCO  ->Select(kProton);
+    fGenBG->GetButton(kGun7)->SetEnabled(kFALSE);                                fGenPminCO ->Select(5);        fGenPmaxCO->Select(25); 
+    fGenBG->GetButton(kBox7)->SetEnabled(kFALSE);                                fGenChamCO ->Select(4);
   }
-}//GeneratorSlot()        
-//__________________________________________________________________________________________________          
-void RichConfig::CreateConfig()
-{   
-  FILE *fp=fopen(fFileName,"w"); if(!fp){Info("CreateConfigFile","Cannot open output file:%sn",fFileName);return;}
-  
-  fprintf(fp,"void Config()\n");
-  fprintf(fp,"{\n");
-  fprintf(fp,"  ::Info(\"RICH private config\",\"Start\");\n\n"); 
-//Random
-  fprintf(fp,"  gRandom->SetSeed(123456);//put 0 to use system time\n\n");    
-//Geant  
-  fprintf(fp,"  gSystem->Load(\"libgeant321\");\n");
-  fprintf(fp,"  new TGeant3TGeo(\"C++ Interface to Geant3\");\n\n");
-//File
-  fprintf(fp,"  AliRunLoader *pAL=AliRunLoader::Open(\"galice.root\",AliConfig::GetDefaultEventFolderName(),\"recreate\");\n");    
-  fprintf(fp,"  pAL->SetCompressionLevel(2);\n");
-  fprintf(fp,"  pAL->SetNumberOfEventsPerFile(1000);\n");
-  fprintf(fp,"  gAlice->SetRunLoader(pAL);\n\n");
-//Decayer  
-  fprintf(fp,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
-  fprintf(fp,"  pDecayer->SetForceDecay(kAll);\n"); 
-  fprintf(fp,"  pDecayer->Init();\n"); 
-  fprintf(fp,"  gMC->SetExternalDecayer(pDecayer);\n\n");
-  Physics(fp);
-//Field
-  if(fMagCB->GetState()==kButtonDown) fprintf(fp,"  gAlice->SetField();\n\n");else fprintf(fp,"  gAlice->SetField(0);\n\n");
-  fprintf(fp,"  pAL->CdGAFile();\n\n");                                 //????       
-//BODY-ALIC 
-  fprintf(fp,"  new AliBODY(\"BODY\",\"Alice envelop\");\n\n");
-//RICH
-  if(!fRichBG->GetButton(kDeclust)->GetState()) fprintf(fp,"  AliRICHParam::SetDeclustering(kFALSE);\n");
-  if(!fRichBG->GetButton(kSagita)->GetState())  fprintf(fp,"  AliRICHParam::SetWireSag(kFALSE);\n")     ;
-  switch(fRichCO->GetSelected()){
-    case kNo:                                                                                                  break;
-    case kVer0:  fprintf(fp,"  AliRICH *pRICH=new AliRICHv0(\"RICH\",\"Rich with debug StepManager\");\n\n"); break;      
-    case kVer1:  fprintf(fp,"  AliRICH *pRICH=new AliRICHv1(\"RICH\",\"Normal\");\n\n");                 break;      
-  }//switch RICH
-//Generator
-  Generator(fp);
-//central before RICH detectors                  
-  if(fDetBG->GetButton(kPIPE )->GetState()) fprintf(fp,"\n  new AliPIPEv0(\"PIPE\",\"Beam Pipe\");\n");
-  if(fDetBG->GetButton(kSHILD)->GetState()) fprintf(fp,"\n  new AliSHILv2(\"SHIL\",\"Shielding Version 2\");\n");  
+  if(id==kBox7){
+    fGenBG->GetButton(kGunZ)->SetEnabled(kFALSE);                                fGenNprimCO->Select(1);
+    fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPidCO  ->Select(kProton); 
+    fGenBG->GetButton(kGun1)->SetEnabled(kFALSE);                                fGenPminCO ->Select(5);        fGenPmaxCO->Select(25);   
+    fGenBG->GetButton(kBox1)->SetEnabled(kFALSE);  fGenF->HideFrame(fGenChamCO);  
+  }
+  if(id==kHijing){
+    fGenBG->GetButton(kHijing)->ChangeBackground(0xff0000);
+    fGenBG->GetButton(kHijingPara)->SetEnabled(kFALSE);
+    fGenBG->GetButton(kPythia)->SetEnabled(kFALSE);
+  }
+  if(id==kHijingPara){
+    fGenBG->GetButton(kHijing)->SetEnabled(kFALSE);
+    fGenBG->GetButton(kPythia)->SetEnabled(kFALSE);
+  }
+  if(id==kPythia){
+    fGenBG->GetButton(kHijing)->SetEnabled(kFALSE);
+    fGenBG->GetButton(kHijingPara)->SetEnabled(kFALSE);
+  }
+}//GenAddSlot()
+//__________________________________________________________________________________________________
+void RichConfig::GenRemSlot(Int_t id)
+{//is invoked when any of generator check button is released
+  if(id==kGunZ){
+    fGenBG->GetButton(kGun1)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);                                                                  
+    fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
+    fGenBG->GetButton(kBox1)->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed);
+    fGenBG->GetButton(kBox7)->SetEnabled();  fGenF->ShowFrame(fGenChamCO); 
+  } 
+  if(id==kGun1){
+    fGenBG->GetButton(kGunZ)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);
+    fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
+    fGenBG->GetButton(kBox1)->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed);  
+    fGenBG->GetButton(kBox7)->SetEnabled();                                     fGenChamCO ->Select(kNotUsed);
+  }
+  if(id==kGun7){
+    fGenBG->GetButton(kGunZ)->SetEnabled();  fGenF->ShowFrame(fGenNprimCO);
+    fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
+    fGenBG->GetButton(kBox1)->SetEnabled();  fGenF->ShowFrame(fGenPmaxCO);      fGenPminCO ->Select(kNotUsed); 
+    fGenBG->GetButton(kBox7)->SetEnabled();  fGenF->ShowFrame(fGenChamCO); 
+  } 
+  if(id==kBox1){
+    fGenBG->GetButton(kGunZ)->SetEnabled();                                     fGenNprimCO->Select(kNotUsed);
+    fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);
+    fGenBG->GetButton(kGun7)->SetEnabled();                                     fGenPminCO ->Select(kNotUsed);   fGenPmaxCO->Select(kNotUsed);
+    fGenBG->GetButton(kBox7)->SetEnabled();                                     fGenChamCO ->Select(kNotUsed);
+  }
+  if(id==kBox7){
+    fGenBG->GetButton(kGunZ)->SetEnabled();                                     fGenNprimCO->Select(kNotUsed);
+    fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPidCO  ->Select(kNotUsed);                                   
+    fGenBG->GetButton(kGun1)->SetEnabled();                                     fGenPminCO ->Select(kNotUsed);   fGenPmaxCO->Select(kNotUsed);
+    fGenBG->GetButton(kBox1)->SetEnabled(); fGenF->ShowFrame(fGenChamCO);       
+  }
+  if(id==kHijing){
+    fGenBG->GetButton(kHijing)->ChangeBackground(0xbebebe);
+    fGenBG->GetButton(kHijingPara)->SetEnabled();
+    fGenBG->GetButton(kPythia)->SetEnabled();
+  }
+  if(id==kHijingPara){
+    fGenBG->GetButton(kHijing)->SetEnabled();
+    fGenBG->GetButton(kPythia)->SetEnabled();
+  }
+  if(id==kPythia){
+    fGenBG->GetButton(kHijing)->SetEnabled();
+    fGenBG->GetButton(kHijingPara)->SetEnabled();
+  }
+}//GenRemSlot()
+//__________________________________________________________________________________________________    
+void RichConfig::WriteGen(FILE *pF)
+{
+  fprintf(pF,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n\n");
+  if(fGenBG->GetButton(kGunZ)->GetState()==kButtonDown){//1 particle along Z axis 
+    fprintf(pF,"  AliGenFixed *pGunZ=new AliGenFixed(1);\n");
+    fprintf(pF,"  pGunZ->SetPart(%i); pGunZ->SetMomentum(%.1f); pGunZ->SetOrigin(0,0,-200);\n",fGenPidCO->GetSelected(),float(fGenPminCO->GetSelected())/10);
+    fprintf(pF,"  pCocktail->AddGenerator(pGunZ,\"gunZ\",1);\n\n");
+  }
+  if(fGenBG->GetButton(kGun1)->GetState()==kButtonDown){//1 gun towards 1 RICH chamber
+    fprintf(pF,"  AliGenFixed *pGun1=new AliGenFixed(1);\n");
+    fprintf(pF,"  pGun1->SetPart(%i); pGun1->SetMomentum(%.1f);\n",fGenPidCO->GetSelected(),float(fGenPminCO->GetSelected())/10);
+    fprintf(pF,"  pGun1->SetTheta(pRICH->C(%i)->ThetaD()-2); pGun1->SetPhi(pRICH->C(%i)->PhiD()-2); \n",fGenChamCO->GetSelected(),fGenChamCO->GetSelected());
+    fprintf(pF,"  pCocktail->AddGenerator(pGun1,\"gun1\",1);\n\n");
+  }
+  if(fGenBG->GetButton(kGun7)->GetState()==kButtonDown){//7 guns towards 7 RICH chambers
+    fprintf(pF,"  for(int i=1;i<=7;i++){\n");
+    fprintf(pF,"    AliGenFixed *pGun7=new AliGenFixed(1);\n");
+    fprintf(pF,"    pGun7->SetPart(%i); pGun7->SetMomentum(1.0+i*0.5);\n",fGenPidCO->GetSelected());
+    fprintf(pF,"    pGun7->SetTheta(pRICH->C(i)->ThetaD()-2); pGun7->SetPhi(pRICH->C(i)->PhiD()); \n");                             
+    fprintf(pF,"    pCocktail->AddGenerator(pGun7,Form(\"gun7-%%i\",i),1);\n  }\n\n");  
+  }    
+  if(fGenBG->GetButton(kBox1)->GetState()==kButtonDown){//1 box towards 1 RICH chamber  
+    fprintf(pF,"  AliGenBox *pBox1=new AliGenBox(1);\n");  
+    fprintf(pF,"  pBox1->SetPart(%i); pBox1->SetMomentumRange(%.1f,%.1f);\n",fGenPidCO->GetSelected(),float(fGenPminCO->GetSelected())/10,float(fGenPmaxCO->GetSelected())/10);
+    fprintf(pF,"  pBox1->SetThetaRange(pRICH->C(%i)->ThetaD()-3,pRICH->C(%i)->ThetaD()-1); \n",fGenChamCO->GetSelected(),fGenChamCO->GetSelected());
+    fprintf(pF,"  pBox1->SetPhiRange(pRICH->C(%i)->PhiD()-1,pRICH->C(%i)->PhiD()+1); \n",fGenChamCO->GetSelected(),fGenChamCO->GetSelected());    
+    fprintf(pF,"  pCocktail->AddGenerator(pBox1,\"box1\",1);\n\n");
+  }     
+  if(fGenBG->GetButton(kBox7)->GetState()==kButtonDown){//7 boxes towards 7 RICH chambers
+    fprintf(pF,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
+    fprintf(pF,"  for(int i=1;i<=7;i++){\n");
+    fprintf(pF,"    AliGenBox *pGen=new AliGenBox(1);\n");
+    fprintf(pF,"    pGen->SetPart(%i); pGen->SetMomentumRange(%.1f,%.1f); \n",fGenPidCO->GetSelected(),float(fGenPminCO->GetSelected())/10,float(fGenPmaxCO->GetSelected())/10);
+    fprintf(pF,"    pGen->SetThetaRange(pRICH->C(i)->ThetaD()-3,pRICH->C(i)->ThetaD()-1); pGen->SetPhiRange(pRICH->C(i)->PhiD()-1,pRICH->C(i)->PhiD()+1); \n");    
+    fprintf(pF,"    pCocktail->AddGenerator(pGen,Form(\"Box %i\",i),1);\n  }\n\n");  
+  }
+  if(fGenBG->GetButton(kHijing)->GetState()==kButtonDown){//normal HIJING
+    fprintf(pF,"  AliGenHijing *pHij=new AliGenHijing(-1); pHij->SetEnergyCMS(5500); pHij->SetReferenceFrame(\"CMS\");\n");
+    fprintf(pF,"  pHij->SetProjectile(\"A\", 208, 82); pHij->SetTarget(\"A\", 208, 82);\n");      
+    fprintf(pF,"  pHij->SetJetQuenching(0); pHij->SetShadowing(0);\n");
+    fprintf(pF,"  pHij->KeepFullEvent(); pHij->SetSelectAll(0); \n");
+    fprintf(pF,"  pHij->SetImpactParameterRange(0, 5); //fermi\n");
+    fprintf(pF,"  pCocktail->AddGenerator(pHij,\"hijing\",1);\n\n");
+  }
+  if(fGenBG->GetButton(kHijingPara)->GetState()==kButtonDown){//parametrized HIJING 
+    fprintf(pF,"  AliGenHIJINGpara *pGen=new AliGenHIJINGpara(%i);\n",(int)fGenNprimCO->GetSelected());
+    fprintf(pF,"  pHijPara->SetMomentumRange(0,999); pHijPara->SetThetaRange(%f,%f); pHijPara->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
+    fprintf(pF,"  pCocktail->AddGenerator(pHijPara,\"hijing para\",1);\n\n");
+  }    
+  if(fGenBG->GetButton(kPythia)->GetState()==kButtonDown){//Pythia + 7 guns towards 7 RICH chambers   
+    fprintf(pF,"  AliGenPythia *pPythia = new AliGenPythia(-1);\n");
+    fprintf(pF,"  pPythia->SetMomentumRange(0,999); pPythia->SetPhiRange(20,80); pPythia->SetThetaRange(75,115);\n");
+    fprintf(pF,"  pPythia->SetYRange(-12,12);  pPythia->SetPtRange(0,1000);  pPythia->SetStrucFunc(kCTEQ4L);\n");
+    fprintf(pF,"  pPythia->SetProcess(kPyMb);  pPythia->SetEnergyCMS(14000);\n");      
+    fprintf(pF,"  pCocktail->AddGenerator(pPythia,\"Pythia\",1);\n\n");  
+  }
+  fprintf(pF,"  pCocktail->Init();\n");
+}//WriteGenerator()
+//__________________________________________________________________________________________________
+void RichConfig::GuiDet(TGHorizontalFrame *pMainHF)
+{
+  pMainHF->AddFrame(fDetBG=new TGButtonGroup(pMainHF,"Detectors"));
+  fDetBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"DetAddSlot(Int_t)");
+  fDetBG->Connect("Released(Int_t)","RichConfig",this,"DetRemSlot(Int_t)");
+    new TGCheckButton(fDetBG,"PIPE"  ,kPIPE));     new TGCheckButton(fDetBG,"ITS"   ,kITS));   new TGCheckButton(fDetBG,"TPC"   ,kTPC));
+    new TGCheckButton(fDetBG,"TRD"   ,kTRD));      new TGCheckButton(fDetBG,"TOF"   ,kTOF));   new TGCheckButton(fDetBG,"FRAME" ,kFRAME));         
+    new TGCheckButton(fDetBG,"MAG"   ,kMAG));      new TGCheckButton(fDetBG,"CRT"   ,kCRT));   new TGCheckButton(fDetBG,"HALL"  ,kHALL));         
+    new TGCheckButton(fDetBG,"PHOS"  ,kPHOS));     new TGCheckButton(fDetBG,"START" ,kSTART)); new TGCheckButton(fDetBG,"FMD"   ,kFMD));         
+    new TGCheckButton(fDetBG,"ABSO"  ,kABSO));     new TGCheckButton(fDetBG,"PMD"   ,kPMD));   new TGCheckButton(fDetBG,"DIPO"  ,kDIPO));         
+    new TGCheckButton(fDetBG,"EMCAL" ,kEMCAL));    new TGCheckButton(fDetBG,"VZERO" ,kVZERO)); new TGCheckButton(fDetBG,"MUON"  ,kMUON));         
+    new TGCheckButton(fDetBG,"ZDC"   ,kZDC));      new TGCheckButton(fDetBG,"SHILD" ,kSHILD));         
+}
+//__________________________________________________________________________________________________
+void RichConfig::DetAddSlot(Int_t id)
+{//slot is invoked when any detector check button is pressed
+  if(id==kTRD || id==kTOF)     //TRD and TOF geometries depend on FRAME 
+    fDetBG->SetButton(kFRAME);
+}
+//__________________________________________________________________________________________________
+void RichConfig::DetRemSlot(Int_t id)
+{//slot is invoked when any detector check button is released
+  if(id==kFRAME){
+    fDetBG->SetButton(kTRD,kFALSE); //switch off TRD and TOF when FRAME is switched off by user hence TRD&TOF depend on FRAME
+    fDetBG->SetButton(kTOF,kFALSE);
+  }
+}
+//__________________________________________________________________________________________________
+void RichConfig::WriteDet(FILE *pF)
+{
+//central detectors                  
+  if(fDetBG->GetButton(kPIPE )->GetState()) fprintf(pF,"\n  new AliPIPEv0(\"PIPE\",\"Beam Pipe\");\n");
+  if(fDetBG->GetButton(kSHILD)->GetState()) fprintf(pF,"\n  new AliSHILv2(\"SHIL\",\"Shielding Version 2\");\n");  
   if(fDetBG->GetButton(kITS  )->GetState()){
-    fprintf(fp,"\n  AliITSvPPRasymmFMD *pIts =new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version\");\n");
-    fprintf(fp,"  pIts->SetMinorVersion(2); pIts->SetReadDet(kTRUE);\n");
-    fprintf(fp,"  pIts->SetThicknessDet1(200.); pIts->SetThicknessDet2(200.);\n");
-    fprintf(fp,"  pIts->SetThicknessChip1(200.); pIts->SetThicknessChip2(200.);\n");
-    fprintf(fp,"  pIts->SetRails(0); pIts->SetCoolingFluid(1);\n");
-    fprintf(fp,"  pIts->SetEUCLID(0);\n");
+    fprintf(pF,"\n  AliITSvPPRasymmFMD *pIts =new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version\");\n");
+    fprintf(pF,"  pIts->SetMinorVersion(2); pIts->SetReadDet(kTRUE);\n");
+    fprintf(pF,"  pIts->SetThicknessDet1(200.); pIts->SetThicknessDet2(200.);\n");
+    fprintf(pF,"  pIts->SetThicknessChip1(200.); pIts->SetThicknessChip2(200.);\n");
+    fprintf(pF,"  pIts->SetRails(0); pIts->SetCoolingFluid(1);\n");
+    fprintf(pF,"  pIts->SetEUCLID(0);\n");
   }  
-  if(fDetBG->GetButton(kTPC  )->GetState()) {fprintf(fp,"\n  AliTPC *pTpc=new AliTPCv2(\"TPC\",\"Default\"); pTpc->SetSecAU(-1);pTpc->SetSecAL(-1);\n");}  
-  if(fDetBG->GetButton(kFRAME)->GetState())  fprintf(fp,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
+  if(fDetBG->GetButton(kTPC  )->GetState()) {fprintf(pF,"\n  AliTPC *pTpc=new AliTPCv2(\"TPC\",\"Default\"); pTpc->SetSecAU(-1);pTpc->SetSecAL(-1);\n");}  
+  if(fDetBG->GetButton(kFRAME)->GetState())  fprintf(pF,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
   if(fDetBG->GetButton(kTRD  )->GetState()) {
-    fprintf(fp,"\n  AliTRD *pTrd=new AliTRDv1(\"TRD\",\"TRD slow simulator\");\n");
-    fprintf(fp,"  pTrd->SetGasMix(1); pTrd->SetPHOShole();pTrd->CreateTR();\n");
+    fprintf(pF,"\n  AliTRD *pTrd=new AliTRDv1(\"TRD\",\"TRD slow simulator\");\n");
+    fprintf(pF,"  pTrd->SetGasMix(1); pTrd->SetPHOShole(); pTrd->SetRICHhole();pTrd->CreateTR();\n");
   }  
-  if(fDetBG->GetButton(kTOF  )->GetState()) fprintf(fp,"\n  new AliTOFv4T0(\"TOF\", \"normal TOF\");\n");
-//central after RICH detectors  
-  if(fDetBG->GetButton(kMAG  )->GetState()) fprintf(fp,"\n  new AliMAG(\"MAG\",\"Magnet\");\n");  
-  if(fDetBG->GetButton(kHALL )->GetState()) fprintf(fp,"\n  new AliHALL(\"HALL\",\"Alice Hall\");\n");
+  if(fDetBG->GetButton(kTOF  )->GetState()) fprintf(pF,"\n  new AliTOFv4T0(\"TOF\", \"normal TOF\");\n");
+//central detectors  
+  if(fDetBG->GetButton(kMAG  )->GetState()) fprintf(pF,"\n  new AliMAG(\"MAG\",\"Magnet\");\n");  
+  if(fDetBG->GetButton(kHALL )->GetState()) fprintf(pF,"\n  new AliHALL(\"HALL\",\"Alice Hall\");\n");
 //forward detectors  
-  if(fDetBG->GetButton(kFMD  )->GetState()) fprintf(fp,"\n  new AliFMDv1(\"FMD\",\"normal FMD\");\n");
-  if(fDetBG->GetButton(kABSO )->GetState()) fprintf(fp,"\n  new AliABSOv0(\"ABSO\",\"Muon absorber\");\n");
-  if(fDetBG->GetButton(kDIPO )->GetState()) fprintf(fp,"\n  new AliDIPOv2(\"DIPO\",\"Dipole version 2\");\n");
-  if(fDetBG->GetButton(kMUON )->GetState()) fprintf(fp,"\n  new AliMUONv1(\"MUON\",\"default\");\n");
-  if(fDetBG->GetButton(kPMD  )->GetState()) fprintf(fp,"\n  new AliPMDv1(\"PMD\",\"normal PMD\");\n");
-  if(fDetBG->GetButton(kSTART)->GetState()) fprintf(fp,"\n  new AliSTARTv1(\"START\",\"START Detector\");\n");
-  if(fDetBG->GetButton(kVZERO)->GetState()) fprintf(fp,"\n  new AliVZEROv2(\"VZERO\",\"normal VZERO\");\n");
-  if(fDetBG->GetButton(kZDC  )->GetState()) fprintf(fp,"\n  new AliZDCv2(\"ZDC\",\"normal ZDC\");\n");
+  if(fDetBG->GetButton(kFMD  )->GetState()) fprintf(pF,"\n  new AliFMDv1(\"FMD\",\"normal FMD\");\n");
+  if(fDetBG->GetButton(kABSO )->GetState()) fprintf(pF,"\n  new AliABSOv0(\"ABSO\",\"Muon absorber\");\n");
+  if(fDetBG->GetButton(kDIPO )->GetState()) fprintf(pF,"\n  new AliDIPOv2(\"DIPO\",\"Dipole version 2\");\n");
+  if(fDetBG->GetButton(kMUON )->GetState()) fprintf(pF,"\n  new AliMUONv1(\"MUON\",\"default\");\n");
+  if(fDetBG->GetButton(kPMD  )->GetState()) fprintf(pF,"\n  new AliPMDv1(\"PMD\",\"normal PMD\");\n");
+  if(fDetBG->GetButton(kSTART)->GetState()) fprintf(pF,"\n  new AliSTARTv1(\"START\",\"START Detector\");\n");
+  if(fDetBG->GetButton(kVZERO)->GetState()) fprintf(pF,"\n  new AliVZEROv2(\"VZERO\",\"normal VZERO\");\n");
+  if(fDetBG->GetButton(kZDC  )->GetState()) fprintf(pF,"\n  new AliZDCv2(\"ZDC\",\"normal ZDC\");\n");
 //different phase space detectors  
-  if(fDetBG->GetButton(kPHOS )->GetState()) fprintf(fp,"\n  new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
-  if(fDetBG->GetButton(kEMCAL)->GetState()) fprintf(fp,"\n  new AliEMCALv1(\"EMCAL\",\"G56_2_55_19_104_14\");\n");
-  if(fDetBG->GetButton(kCRT  )->GetState()) fprintf(fp,"\n  new AliCRTv0(\"CRT\",\"normal ACORDE\");\n");
-
-  fprintf(fp,"\n  ::Info(\"RICH private config\",\"Stop\");\n"); 
-  fprintf(fp,"}\n");
-out:  
-  fclose(fp);  
-//  CloseWindow();
-}//CreateConfig
-//__________________________________________________________________________________________________
-void RichConfig::Physics(FILE *fp)
-{
-  if(fProcBG->GetButton(kDCAY)->GetState()) fprintf(fp,"  gMC->SetProcess(\"DCAY\",1);");  else fprintf(fp,"  gMC->SetProcess(\"DCAY\",0);");
-  if(fProcBG->GetButton(kPAIR)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PAIR\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PAIR\",0);\n");
-  if(fProcBG->GetButton(kCOMP)->GetState()) fprintf(fp,"  gMC->SetProcess(\"COMP\",1);");  else fprintf(fp,"  gMC->SetProcess(\"COMP\",0);");
-  if(fProcBG->GetButton(kPHOT)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PHOT\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PHOT\",0);\n");
-  if(fProcBG->GetButton(kPFIS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PFIS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"PFIS\",0);");
-  if(fProcBG->GetButton(kDRAY)->GetState()) fprintf(fp,"  gMC->SetProcess(\"DRAY\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"DRAY\",0);\n");
-  if(fProcBG->GetButton(kANNI)->GetState()) fprintf(fp,"  gMC->SetProcess(\"ANNI\",1);");  else fprintf(fp,"  gMC->SetProcess(\"ANNI\",0);");
-  if(fProcBG->GetButton(kBREM)->GetState()) fprintf(fp,"  gMC->SetProcess(\"BREM\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"BREM\",0);\n");
-  if(fProcBG->GetButton(kMUNU)->GetState()) fprintf(fp,"  gMC->SetProcess(\"MUNU\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MUNU\",0);");
-  if(fProcBG->GetButton(kCKOV)->GetState()) fprintf(fp,"  gMC->SetProcess(\"CKOV\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"CKOV\",0);\n");
-  if(fProcBG->GetButton(kHADR)->GetState()) fprintf(fp,"  gMC->SetProcess(\"HADR\",1);");  else fprintf(fp,"  gMC->SetProcess(\"HADR\",0);");
-  if(fProcBG->GetButton(kLOSS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"LOSS\",2);\n");else fprintf(fp,"  gMC->SetProcess(\"LOSS\",0);\n");
-  if(fProcBG->GetButton(kMULS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"MULS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MULS\",0);");
-  if(fProcBG->GetButton(kRAYL)->GetState()) fprintf(fp,"  gMC->SetProcess(\"RAYL\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"RAYL\",0);\n");
-  
-  fprintf(fp,"\n");  
-  fprintf(fp,"  gMC->SetCut(\"CUTGAM\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"CUTELE\",0.001); ");
-  fprintf(fp,"  gMC->SetCut(\"CUTNEU\",0.001);\n"); fprintf(fp,"  gMC->SetCut(\"CUTHAD\",0.001); ");
-  fprintf(fp,"  gMC->SetCut(\"CUTMUO\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"BCUTE\" ,0.001);\n");
-  fprintf(fp,"  gMC->SetCut(\"BCUTM\" ,0.001); ");  fprintf(fp,"  gMC->SetCut(\"DCUTE\" ,0.001); ");
-  fprintf(fp,"  gMC->SetCut(\"DCUTM\" ,0.001);\n"); fprintf(fp,"  gMC->SetCut(\"PPCUTM\",0.001); ");
-  fprintf(fp,"  gMC->SetCut(\"TOFMAX\",1e10);\n\n"); 
-}//Physics()
+  if(fDetBG->GetButton(kPHOS )->GetState()) fprintf(pF,"\n  new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
+  if(fDetBG->GetButton(kEMCAL)->GetState()) fprintf(pF,"\n  new AliEMCALv1(\"EMCAL\",\"G56_2_55_19_104_14\");\n");
+  if(fDetBG->GetButton(kCRT  )->GetState()) fprintf(pF,"\n  new AliCRTv0(\"CRT\",\"normal ACORDE\");\n");
+}
 //__________________________________________________________________________________________________
-void RichConfig::Generator(FILE *fp)
+void RichConfig::GuiBatch(TGHorizontalFrame *pMainF)
 {
-  switch(fGenTypeCO->GetSelected()){
-    case kHijingPara: 
-      fprintf(fp,"  AliGenHIJINGpara *pGen=new AliGenHIJINGpara(%i);\n",(int)fGenPrimNE->GetNumber());
-      fprintf(fp,"  pGen->SetMomentumRange(0,999); pGen->SetThetaRange(%f,%f); pGen->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
-      fprintf(fp,"  pGen->SetOrigin(0,0,0);  pGen->SetSigma(0,0,0);\n");
-      fprintf(fp,"  pGen->Init();\n");
-    break;
-    case kBox1:     
-      fprintf(fp,"  AliGenBox *pGen=new AliGenBox(1);\n");  
-      fprintf(fp,"  pGen->SetPart(%i); pGen->SetOrigin(0,0,0);\n",fGenPidCO->GetSelected());  
-      fprintf(fp,"  pGen->SetMomentumRange(%.1f,%.1f); \n",float(fGenMinMomCO->GetSelected())/10,   float(fGenMaxMomCO->GetSelected())/10);
-      fprintf(fp,"  pGen->SetThetaRange(pRICH->C(%i)->ThetaD()-3,pRICH->C(%i)->ThetaD()-1); \n",fGenChamberCO->GetSelected(),fGenChamberCO->GetSelected());
-      fprintf(fp,"  pGen->SetPhiRange(pRICH->C(%i)->PhiD()-1,pRICH->C(%i)->PhiD()+1); \n",fGenChamberCO->GetSelected(),fGenChamberCO->GetSelected());    
-      fprintf(fp,"  pGen->Init();\n");
-    break;    
-    case kBox7:   
-      fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
-      fprintf(fp,"  for(int i=1;i<=7;i++){\n");
-      fprintf(fp,"    AliGenBox *pBox=new AliGenBox(1);\n");
-      fprintf(fp,"    pBox->SetMomentumRange(%.1f,%.1f); \n",float(fGenMinMomCO->GetSelected())/10,   float(fGenMaxMomCO->GetSelected())/10);
-      fprintf(fp,"    pBox->SetPart(%i); pBox->SetOrigin(0,0,0);\n",fGenPidCO->GetSelected());
-      fprintf(fp,"    pBox->SetThetaRange(pRICH->C(i)->ThetaD()-3,pRICH->C(i)->ThetaD()-1); \n");
-      fprintf(fp,"    pBox->SetPhiRange(pRICH->C(i)->PhiD()-1,pRICH->C(i)->PhiD()+1); \n");    
-      fprintf(fp,"    pCocktail->AddGenerator(pBox,Form(\"Box %i\",i),1);\n  }\n");  
-      fprintf(fp,"  pCocktail->Init();\n");
-    break;
-    case kGunAlongZ:   
-      fprintf(fp,"  AliGenFixed *pGen=new AliGenFixed(1);\n");
-      fprintf(fp,"  pGen->SetPart(%i); pGen->SetOrigin(0,0,0); pGen->SetMomentum(%.1f); pGen->SetTheta(0);\n",fGenPidCO->GetSelected(),float(fGenMinMomCO->GetSelected())/10);
-      fprintf(fp,"  pGen->Init();\n");
-    break;
-    case kGun7:   
-      fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
-      fprintf(fp,"  for(int i=1;i<=7;i++){\n");
-      fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
-      fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(1.0+i*0.5); pFixed->SetOrigin(0,0,0);\n",fGenPidCO->GetSelected());
-      fprintf(fp,"    pFixed->SetPhi(pRICH->C(i)->PhiD()); pFixed->SetTheta(pRICH->C(i)->ThetaD()-2);\n");                             
-      fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
-      fprintf(fp,"  pCocktail->Init();\n");
-    break;
-    case kPythia7:      
-      fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
-      fprintf(fp,"  for(int i=1;i<=7;i++){\n");
-      fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
-      fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(2.5+i*0.4); pFixed->SetOrigin(0,0,0);\n",fGenPidCO->GetSelected());
-      fprintf(fp,"    pFixed->SetPhiRange(pRICH->C(i)->PhiD()); pFixed->SetThetaRange(pRICH->C(i)->ThetaD()-2);\n");                             
-      fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
-      fprintf(fp,"  AliGenPythia *pPythia = new AliGenPythia(-1);\n");
-      fprintf(fp,"  pPythia->SetMomentumRange(0,999999); pPythia->SetPhiRange(20,80); pPythia->SetThetaRange(75,115);\n");
-      fprintf(fp,"  pPythia->SetYRange(-12,12);  pPythia->SetPtRange(0,1000);  pPythia->SetStrucFunc(kCTEQ4L);\n");
-      fprintf(fp,"  pPythia->SetProcess(kPyMb);  pPythia->SetEnergyCMS(14000);\n");      
-      fprintf(fp,"  pCocktail->AddGenerator(pPythia,\"Pythia\",1);\n");  
-      fprintf(fp,"  pCocktail->Init();\n");
-    case kHijing:  
-      fprintf(fp,"  AliGenHijing *pGen=new AliGenHijing(-1); pGen->SetEnergyCMS(5500); pGen->SetReferenceFrame(\"CMS\");\n");
-      fprintf(fp,"  pGen->SetProjectile(\"A\", 208, 82); pGen->SetTarget(\"A\", 208, 82);\n");      
-      fprintf(fp,"  pGen->SetJetQuenching(0); pGen->SetShadowing(0);\n");
-      fprintf(fp,"  pGen->KeepFullEvent(); pGen->SetSelectAll(0); \n");
-      fprintf(fp,"  pGen->SetImpactParameterRange(0., 5.);\n");
-      fprintf(fp,"  pGen->Init();\n");
-    break;  
-    case kHijingPara2Proton:  
-      fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
-      fprintf(fp,"  for(int i=1;i<=7;i++){\n");
-      fprintf(fp,"    AliGenFixed *pProton1=new AliGenFixed(1);\n");
-      fprintf(fp,"    AliGenFixed *pProton2=new AliGenFixed(1);\n");
-      fprintf(fp,"    pProton1->SetPart(kProton); pProton1->SetMomentum(2.0+i*0.5); pProton1->SetOrigin(0,0,0);\n");
-      fprintf(fp,"    pProton2->SetPart(kProton); pProton2->SetMomentum(2.0+i*0.5); pProton2->SetOrigin(0,0,0);\n");
-      fprintf(fp,"    pProton1->SetPhiRange(pRICH->C(i)->PhiD()); pProton1->SetThetaRange(pRICH->C(i)->ThetaD());\n");                             
-      fprintf(fp,"    pProton2->SetPhiRange(pRICH->C(i)->PhiD()); pProton2->SetThetaRange(pRICH->C(i)->ThetaD()-4);\n");                             
-      fprintf(fp,"    pCocktail->AddGenerator(pProton1,Form(\"proton1 %i\",i),1);\n");  
-      fprintf(fp,"    pCocktail->AddGenerator(pProton2,Form(\"proton2 %i\",i),1);\n  }\n");  
-      
-      fprintf(fp,"  AliGenHIJINGpara *pHijingPara=new AliGenHIJINGpara(510);\n");
-      fprintf(fp,"  pHijingPara->SetMomentumRange(0,99); pHijingPara->SetThetaRange(60,120); pHijingPara->SetPhiRange(0,60);\n");
-      fprintf(fp,"  pHijingPara->SetOrigin(0,0,0);  pHijingPara->SetSigma(0,0,0);\n");
-      fprintf(fp,"  pCocktail->AddGenerator(pHijingPara,\"HijingPara\",1);\n");  
-      fprintf(fp,"  pCocktail->Init();\n");
-    break;  
-     case kRichLib:
-      fprintf(fp,"  AliGenParam *pGen=new AliGenParam(2,new AliGenRICHlib,%i,\"EXP\"); \n",fGenPidCO->GetSelected());
-      fprintf(fp,"  pGen->SetPtRange(%3.1f,%3.1f); \n",fGenMinMomCO->GetSelected()/10,fGenMaxMomCO->GetSelected()/10);
-      fprintf(fp,"  pGen->SetYRange(-0.6,0.6); \n");
-      fprintf(fp,"  pGen->SetPhiRange(0.,60.); \n");
-      fprintf(fp,"  pGen->SetForceDecay(kAll); \n");
-      fprintf(fp,"  pGen->Init();\n");
-    break;
-   case kSignalHijing:
-      fprintf(fp,"  AliGenParam *pRichLib=new AliGenParam(2,new AliGenRICHlib,%i,\"FLAT\"); \n",fGenPidCO->GetSelected());
-      fprintf(fp,"  pRichLib->SetPtRange(%3.1f,%3.1f); \n",fGenMinMomCO->GetSelected()/10,fGenMaxMomCO->GetSelected()/10);
-      fprintf(fp,"  pRichLib->SetYRange(-0.6,0.6); \n");
-      fprintf(fp,"  pRichLib->SetPhiRange(0.,60.); \n");
-      fprintf(fp,"  pRichLib->SetForceDecay(kPhiKK); \n");
-
-      fprintf(fp,"  AliGenHijing *pHijing=new AliGenHijing(-1); pHijing->SetEnergyCMS(5500); pHijing->SetReferenceFrame(\"CMS\");\n");
-      fprintf(fp,"  pHijing->SetProjectile(\"A\", 208, 82); pHijing->SetTarget(\"A\", 208, 82);\n");
-      fprintf(fp,"  pHijing->SetJetQuenching(0); pHijing->SetShadowing(0);\n");
-      fprintf(fp,"  pHijing->KeepFullEvent(); pHijing->SetSelectAll(0); \n");
-      fprintf(fp,"  pHijing->SetImpactParameterRange(0., 5.);\n");
-
-      fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
-      fprintf(fp,"  pCocktail->AddGenerator(pRichLib,\"RichLib\",1);\n");
-      fprintf(fp,"  pCocktail->AddGenerator(pHijing,\"Hijing\",1);\n");
-      fprintf(fp,"  pCocktail->Init();\n");
-    break;
-  }
-}//Generator()
-
-
+  TGGroupFrame *pSimF=new TGGroupFrame(pMainF,"Simu"); pMainF->AddFrame(pSimF);    
+  pSimF->AddFrame(fSimBG=new TGButtonGroup(pSimF,""    ));
+    new TGCheckButton(fSimBG,   "Primary"         ,kPrim     ));   fSimBG->SetButton(kPrim);
+    new TGCheckButton(fSimBG,   "Transport"       ,kTransport));   fSimBG->SetButton(kTransport);
+  pSimF->AddFrame (fSDigBG=new TGButtonGroup(pSimF,""  ));
+    new TGRadioButton(fSDigBG,  "No SDigits"      ,kNo       ));   
+    new TGRadioButton(fSDigBG,  "SDigits ALL"     ,kAll      ));  
+    new TGRadioButton(fSDigBG,  "SDigits RICH"    ,kOnly     ));   fSDigBG->SetButton(kOnly);
+  pSimF->AddFrame (fDigBG=new TGButtonGroup(pSimF,""   ));
+    new TGRadioButton(fDigBG,   "No Digits"       ,kNo       ));   
+    new TGRadioButton(fDigBG,   "Digits ALL"      ,kAll      ));  
+    new TGRadioButton(fDigBG,   "Digits RICH"     ,kOnly     ));   fDigBG->SetButton(kOnly); 
+  pSimF->AddFrame(fRawBG=new TGButtonGroup(pSimF,""    ));
+    new TGRadioButton(fRawBG,   "No RAW files"    ,kNo       ));   fRawBG->SetButton(kNo);
+    new TGRadioButton(fRawBG,   "RAW DDL"         ,kRawDdl   ));
+    new TGRadioButton(fRawBG,   "RAW DATE"        ,kRawDate  ));
+    new TGRadioButton(fRawBG,   "RAW ROOT"        ,kRawRoot  ));
+    
+  TGCompositeFrame *pRecF=new TGGroupFrame(pMainF,"Reco"); pMainF->AddFrame(pRecF);    
+  pRecF->AddFrame(fClusBG=new TGButtonGroup(pRecF,""   ));
+    new TGRadioButton(fClusBG,  "No Clusters"     ,kNo       ));  
+    new TGRadioButton(fClusBG,  "Clusters ALL"    ,kAll      ));  
+    new TGRadioButton(fClusBG,  "Clusters RICH"   ,kOnly     ));   fClusBG->SetButton(kOnly);
+  pRecF->AddFrame(fRecoBG=new TGButtonGroup(pRecF,""   ));
+    new TGCheckButton(fRecoBG,  "Find vertex"     ,kVertex   ));  
+    new TGCheckButton(fRecoBG,  "Find ESD tracks" ,kTrack    ));  
+    new TGCheckButton(fRecoBG,  "Add info ESD"    ,kEsd      ));
+}
 //__________________________________________________________________________________________________
-void RichConfig::CreateRichBatch()
-{//creates RichBatch.C file
-  FILE *fp=fopen("RichBatch.C","w"); if(!fp){Info("CreateRichBatch","Cannot open output file: RichBatch.C");return;}
+void RichConfig::WriteBatch()
+{//creates Batch.C file
+  char *sBatchName="RichBatch";
+  FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateBatch","Cannot open output file: %s.C",sBatchName);return;}
 //header and debug   
-  fprintf(fp,"void RichBatch(const Int_t iNevents,const Bool_t isDebug,const char *sConfigFileName)\n");
-  fprintf(fp,"{\n");
-  fprintf(fp,"  gSystem->Exec(\"rm -rf *.root hlt hough fort* raw* ZZZ*\");\n");
-  fprintf(fp,"  if(isDebug)   AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
-  fprintf(fp,"  gBenchmark->Start(\"ALICE\");\n  TDatime time;\n\n");
+                                                       fprintf(fp,"void %s(const Int_t iNevents,const Bool_t isDebug,const char *sConfigFileName)\n{\n",sBatchName);
+                                                       fprintf(fp,"  gSystem->Exec(\"rm -rf *.root hlt hough fort* raw* ZZZ*\");\n");
+                                                       fprintf(fp,"  if(isDebug)   AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
+                                                       fprintf(fp,"  gBenchmark->Start(\"ALICE\");\n  TDatime time;\n\n");
 //simulation section  
-  fprintf(fp,"  AliSimulation     *pSim=new AliSimulation(sConfigFileName);\n");
-  if(fGenTypeCO->GetSelected()==kBox1||fGenTypeCO->GetSelected()==kGun7) {
-    fprintf(fp,"  pSim->SetRegionOfInterest(kTRUE);\n");
-    fprintf(fp,"  pSim->SetMakeSDigits(\"TOF RICH\");\n");
-    fprintf(fp,"  pSim->SetMakeDigitsFromHits(\"ITS TPC TRD\");\n");
-  }
-//RAW data generation  
-  if     (fRawBG->GetButton(kRawDdl)->GetState())  fprintf(fp,"  pSim->SetWriteRawData(\"ALL\");\n");
-  else if(fRawBG->GetButton(kRawDate)->GetState()) fprintf(fp,"  pSim->SetWriteRawData(\"ALL\",\".date\");\n");
-  else if(fRawBG->GetButton(kRawRoot)->GetState()) fprintf(fp,"  pSim->SetWriteRawData(\"ALL\",\".root\");\n");
+                                                       fprintf(fp,"  AliSimulation     *pSim=new AliSimulation(sConfigFileName);\n");
+//generate initial kinematics  
+  if(fSimBG->GetButton(kPrim)->GetState()) 
+                                                       fprintf(fp,"  pSim->SetRunGeneration(kTRUE);           //initial kinematics generated\n");
+  else
+                                                       fprintf(fp,"  pSim->SetRunGeneration(kFALSE);          //no initial kinematics generated\n");
+//transport and hit creations  
+  if(fSimBG->GetButton(kTransport)->GetState()) 
+                                                       fprintf(fp,"  pSim->SetRunSimulation(kTRUE);           //transport and hits creation\n");
+  else
+                                                       fprintf(fp,"  pSim->SetRunSimulation(kFALSE);          //no transport and hits creation\n");
+//sdigits  
+  if     (fSDigBG->GetButton(kNo)    ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"\");              //no sdigits created\n");
+  else if(fSDigBG->GetButton(kAll)   ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"ALL\");           //sdigits created for ALL\n");
+  else if(fSDigBG->GetButton(kOnly)  ->GetState())     fprintf(fp,"  pSim->SetMakeSDigits(\"RICH\");          //sdigits created for RICH\n");
+//digits  
+  if     (fDigBG->GetButton(kNo)    ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"\");               //no digits created\n");
+  else if(fDigBG->GetButton(kAll)   ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"ALL\");            //digits created for all detectors\n");
+  else if(fDigBG->GetButton(kOnly)  ->GetState())      fprintf(fp,"  pSim->SetMakeDigits(\"RICH\");           //digits created for RICH\n");
+//raw data generation  
+  if     (fRawBG->GetButton(kRawDdl)->GetState())      fprintf(fp,"  pSim->SetWriteRawData(\"ALL\");          //raw data in DDL  format for ALL\n");
+  else if(fRawBG->GetButton(kRawDate)->GetState())     fprintf(fp,"  pSim->SetWriteRawData(\"ALL\",\".date\");//raw data in DATE format for ALL\n");
+  else if(fRawBG->GetButton(kRawRoot)->GetState())     fprintf(fp,"  pSim->SetWriteRawData(\"ALL\",\".root\");//raw data in ROOT format for ALL\n");
   
-  fprintf(fp,"  pSim->Run(iNevents);\n  delete pSim;\n\n");
+                                                       fprintf(fp,"  pSim->Run(iNevents);\n  delete pSim;\n\n");
 //reconstraction section  
-  if(fRecoBG->GetButton(kRecon)->GetState()){
-    fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
-    fprintf(fp,"  pRec->SetRunLocalReconstruction(\"ITS TPC TRD TOF RICH\");\n");
-    if(fRecoBG->GetButton(kFillEsd)->GetState())
-      fprintf(fp,"  pRec->SetFillESD(\"ITS TPC TRD TOF RICH\");\n");
-    fprintf(fp,"  pRec->Run();\n");         
-    fprintf(fp,"  delete pRec;\n\n");
+  if(!fClusBG->GetButton(kNo)->GetState()){
+                                                       fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
+    if     (fClusBG->GetButton(kAll)   ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"ALL\");        //run cluster creation for ALL\n");
+    else if(fClusBG->GetButton(kOnly)  ->GetState())   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"RICH\");       //run cluster creation for RICH\n");
+    
+    if(fRecoBG->GetButton(kVertex)->GetState())
+                                                       fprintf(fp,"  pRec->SetRunVertexFinder(kTRUE);                 //run ESD vertex task\n");
+    else
+                                                       fprintf(fp,"  pRec->SetRunVertexFinder(kFALSE);                //not run ESD vertex task\n");
+    
+    if(fRecoBG->GetButton(kTrack)->GetState())
+                                                       fprintf(fp,"  pRec->SetRunTracking(\"ITS TPC TRD TOF RICH\");  //run ESD track task\n");
+    else
+                                                       fprintf(fp,"  pRec->SetRunTracking(\"\");                      //not run ESD track task\n");
+    
+    if(fRecoBG->GetButton(kEsd)->GetState())
+                                                       fprintf(fp,"  pRec->SetFillESD(\"ITS TPC TRD TOF RICH\");      //run ESD add info task\n");      
+    else
+                                                       fprintf(fp,"  pRec->SetFillESD(\"\");                          //not run ESD add info task\n");
+    
+    
+                                                       fprintf(fp,"  pRec->Run();delete pRec;\n\n");         
   }
 //benchmarks  
-  fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Start time: \";time.Print();\n");
-  fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Stop  time: \";time.Set();  time.Print();\n");
-  fprintf(fp,"  gBenchmark->Show(\"ALICE\");\n");
-//indicate end of job  
-  fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n");
-  fprintf(fp,"  gSystem->Exec(\"playwave ~/bin/end.wav\");\n");
-  fprintf(fp,"}\n");
+                                                       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,"  gBenchmark->Show(\"ALICE\");\n");
   
+                                                       fprintf(fp,"  gSystem->Exec(\"play -c 2 ~/.kde/my/end.wav\");\n");
+                                                       fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n}\n");
   fclose(fp);  
-}//CreateRichBatch()
+}//WriteBatch()
 //__________________________________________________________________________________________________
-void RichConfig::Exit()
+void RichConfig::ExitSlot()
 {
 //slot to be invoked by clik on the Create button  
-  CreateConfig();
-  CreateRichBatch();
+  WriteConfig();
+  WriteBatch();
   SendCloseMessage();
+  gApplication->Terminate(0);
 }
 //__________________________________________________________________________________________________
-RichConfig *rc;
+void RichConfig::WriteConfig()
+{   
+  FILE *pF=fopen(fFileName,"w"); if(!pF){Info("CreateConfigFile","Cannot open output file:%sn",fFileName);return;}
+  
+  fprintf(pF,"void Config()\n");
+  fprintf(pF,"{\n");
+  fprintf(pF,"\n  ::Info(\"\\n\\n\\n----------> RICH 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  
+  fprintf(pF,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
+  fprintf(pF,"  pDecayer->SetForceDecay(kAll);\n"); 
+  fprintf(pF,"  pDecayer->Init();\n"); 
+  fprintf(pF,"  gMC->SetExternalDecayer(pDecayer);\n\n");
+  
+  WritePhys(pF); //physics processes
+  
+//Field
+  if(fMagB->GetState()==kButtonDown) 
+    fprintf(pF,"  gAlice->SetField();\n\n");
+  else 
+    fprintf(pF,"  gAlice->SetField(0);\n\n");
+  fprintf(pF,"  pAL->CdGAFile();\n\n");                                 //????       
+//BODY-ALIC 
+  fprintf(pF,"  new AliBODY(\"BODY\",\"Alice envelop\");\n\n");
+
+  WriteRich(pF);  //private RICH part
+  WriteGen(pF);//generator
+  WriteDet(pF);  //other detectors
+//end of Config.C file:  
+  fprintf(pF,"\n  ::Info(\"----------> RICH private config\",\"Stop\\n\\n\\n\");\n"); 
+  fprintf(pF,"}\n");
+  fclose(pF);  
+}//WriteConfig()
+
+
+RichConfig *kir=0;
+//__________________________________________________________________________________________________
 void RichConfig()
 {
-   rc=new RichConfig("Config.C");
+   kir=new RichConfig("Config.C");
 }   
-
index b07f98095b9ede9f37533cf76cc1ee1e23e74545..d9c94f6559560cfcf2f868cb9d3bfb6edad809e3 100644 (file)
@@ -4,9 +4,8 @@ Int_t copy; //volume copy number
 Double_t dx,dy,dz,r1,r2;//tmp vars for volume dimentions
 Double_t cm=1,m=100*cm,mm=0.1*cm,mkm=0.001*cm;//length units  
 
-void Geom()
+void RichGeom()
 {
-  AliRICHParam::SetRadioSrc(kTRUE);
   p=new AliRICHParam;
   
   //gSystem->Load("libGeom.so");  
@@ -76,8 +75,6 @@ void Rich(TGeoVolume *pTop)
                  Gap(pRich);           //anod wires
                  Frame3(pRich);        //cathode wires
                  Frame4(pRich);        //collection wires  
-  if(!p->IsRadioSrc())    Radiators(pRich);
-  else                    Sr90(pRich);
                  Sandbox(pRich);
 }//Rich()
 //__________________________________________________________________________________________________