additional entries
[u/mrichter/AliRoot.git] / RICH / CreateConfig.C
1 class RichConfig
2 {
3 RQ_OBJECT()
4 public:
5   enum EDetectors {kPIPE=1,kITS=2,kTPC=4,kTRD=8,kTOF=16,kFRAME=32,kMAG=64,kCRT=128,kHALL=256,kPHOS=512,kSTART=1024,kFMD=2048,kABSO=4096,
6                    kPMD=8192,kDIPO=16384,kEMCAL=32768,kVZERO=65536,kMUON=131072,kZDC=262144,kSHILD=524288};
7   enum EProcesses {kDCAY=1,kPAIR=2,kCOMP=4,kPHOT=8,kPFIS=16,kDRAY=32,kANNI=64,kBREM=128,kMUNU=256,kCKOV=512,kHADR=1024,kLOSS=2048,kMULS=4096,
8                    kRAYL=8192};
9   enum EGenTypes  {kGun1=100,kGun7,kPythia7,kHijing,kHijingPara};
10   
11           RichConfig(const char*sFileName);
12          ~RichConfig()                    {Info("ctor","");fMain->Cleanup(); delete fMain;}
13   void    AddDetector(Int_t id)          {fDetectors+=id; if(id==kTRD || id==kTOF) fDetButGrp->SetButton(kFRAME);}
14   void    RemoveDetector(Int_t id)       {fDetectors-=id; if(id==kFRAME) {fDetButGrp->SetButton(kTRD,kFALSE);fDetButGrp->SetButton(kTOF,kFALSE);}}
15   void    AddProcess(Int_t id)           {fProcesses+=id;}
16   void    RemoveProcess(Int_t id)        {fProcesses-=id;}
17   Bool_t  IsDetectorOn(Int_t id)    const{return fDetectors&id;}
18   Bool_t  IsProcessOn(Int_t id)     const{return fProcesses&id;}
19   Float_t Eta2Theta(Float_t arg)    const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
20   void    CreateConfigFile();
21 protected:
22   TGMainFrame  *fMain;//main window poiter
23   TGComboBox   *fRichVersionCombo;  TGButton *fRichTopChkBtn,*fRichDeclusterChkBtn,*fRichSagChkBtn,*fRichRadioSrcChkBtn;//RICH
24   TGButton     *fMagFldChkBtn;                               //MAG
25   TGComboBox   *fGenTypeCombo,*fGenPartIdCombo,*fGenMinMomCombo,*fGenMaxMomCombo,*fGenChamberCombo; TGNumberEntry *fGenNprimEntry;//GEN
26   Int_t         fDetectors; TGButtonGroup *fDetButGrp;       //DETECTORS
27   Int_t         fProcesses;
28   char         *fFileName;
29 };//class RichConfig
30          
31 RichConfig::RichConfig(const char *sFileName)
32 {   
33   fFileName=sFileName;
34   fDetectors=0;
35 // Create main frame       
36   fMain=new TGMainFrame(gClient->GetRoot(),500,400);
37 //  fMain->Connect("CloseWindow()","RichConfig",this,"CloseWindow()");   
38   fMain->AddFrame(pHorFrame=new TGHorizontalFrame(fMain,100,200));
39 //RICH
40   pHorFrame->AddFrame(pVerFrame=new TGVerticalFrame(pHorFrame,100,200));  
41   pVerFrame->AddFrame(pRichGrpFrm=new TGGroupFrame(pHorFrame,"RICH"));
42   pRichGrpFrm->AddFrame(fRichVersionCombo=new TGComboBox(pRichGrpFrm,100));
43   fRichVersionCombo->AddEntry("no RICH",-1);
44   fRichVersionCombo->AddEntry("version 0",0);  
45   fRichVersionCombo->AddEntry("version 1",1);
46   fRichVersionCombo->Select(1);  fRichVersionCombo->Resize(160,20);
47   pRichGrpFrm->AddFrame(fRichTopChkBtn=new TGCheckButton(pRichGrpFrm,"Rotate to Top?"));
48   pRichGrpFrm->AddFrame(fRichDeclusterChkBtn=new TGCheckButton(pRichGrpFrm,"Declustering")); fRichDeclusterChkBtn->SetState(kButtonDown);
49   pRichGrpFrm->AddFrame(fRichSagChkBtn=new TGCheckButton(pRichGrpFrm,"Wire sagita?"));       fRichSagChkBtn->SetState(kButtonDown);
50   pRichGrpFrm->AddFrame(fRichRadioSrcChkBtn=new TGCheckButton(pRichGrpFrm,"Radioactive source"));
51 //Generator  
52   pVerFrame->AddFrame(pGenGrpFrm=new TGGroupFrame(pHorFrame,"Generator"));
53   pGenGrpFrm->AddFrame(fGenTypeCombo=new TGComboBox(pGenGrpFrm,100));
54   fGenTypeCombo->AddEntry("gun to single chamber",kGun1);  
55   fGenTypeCombo->AddEntry("gun to all chambers",kGun7);
56   fGenTypeCombo->AddEntry("7 guns on top of Pythia",kPythia7);
57   fGenTypeCombo->AddEntry("HIJING",kHijing);
58   fGenTypeCombo->AddEntry("parametrized HIJING",kHijingPara);
59   fGenTypeCombo->AddEntry("Sr90 source",kSr90);
60   fGenTypeCombo->Select(kHijingPara);
61   fGenTypeCombo->Resize(160,20);
62   
63   pGenGrpFrm->AddFrame(fGenPartIdCombo=new TGComboBox(pGenGrpFrm,100)); //PID for guns
64   fGenPartIdCombo->AddEntry("Pion+",kPiPlus);
65   fGenPartIdCombo->AddEntry("Pion-",kPiMinus);
66   fGenPartIdCombo->AddEntry("Kaon+",kKPlus);
67   fGenPartIdCombo->AddEntry("Kaon-",kKMinus);
68   fGenPartIdCombo->AddEntry("Proton",kProton);
69   fGenPartIdCombo->AddEntry("AntiProton",kProtonBar);
70   fGenPartIdCombo->Select(kPiPlus);  fGenPartIdCombo->Resize(160,20);
71
72   pGenGrpFrm->AddFrame(fGenMinMomCombo=new TGComboBox(pGenGrpFrm,100)); //particle energy for guns
73   fGenMinMomCombo->AddEntry("1.0 GeV",10);
74   fGenMinMomCombo->AddEntry("1.5 GeV",15);
75   fGenMinMomCombo->AddEntry("2.0 Gev",20);
76   fGenMinMomCombo->AddEntry("2.5 GeV",25);
77   fGenMinMomCombo->AddEntry("3.0 GeV",30);
78   fGenMinMomCombo->AddEntry("3.5 GeV",35);
79   fGenMinMomCombo->AddEntry("4.0 GeV",40);
80   fGenMinMomCombo->AddEntry("4.5 GeV",45);
81   fGenMinMomCombo->Select(10);  fGenMinMomCombo->Resize(160,20);
82   
83   pGenGrpFrm->AddFrame(fGenMaxMomCombo=new TGComboBox(pGenGrpFrm,100)); //particle energy for guns
84   fGenMaxMomCombo->AddEntry("1.0 GeV",10);
85   fGenMaxMomCombo->AddEntry("1.5 GeV",15);
86   fGenMaxMomCombo->AddEntry("2.0 Gev",20);
87   fGenMaxMomCombo->AddEntry("2.5 GeV",25);
88   fGenMaxMomCombo->AddEntry("3.0 GeV",30);
89   fGenMaxMomCombo->AddEntry("3.5 GeV",35);
90   fGenMaxMomCombo->AddEntry("4.0 GeV",40);
91   fGenMaxMomCombo->AddEntry("4.5 GeV",45);
92   fGenMaxMomCombo->Select(40);  fGenMaxMomCombo->Resize(160,20);
93   
94   pGenGrpFrm->AddFrame(fGenChamberCombo=new TGComboBox(pGenGrpFrm,100)); //chamber number in case of gun1
95   for(int i=1;i<=7;i++) fGenChamberCombo->AddEntry(Form("Chamber %i",i),i);
96   fGenChamberCombo->Select(4); fGenChamberCombo->Resize(160,20);
97   
98   pGenGrpFrm->AddFrame(pGenNprimFrm=new TGGroupFrame(pGenGrpFrm,"Number of primaries"));//number of primiries in case of HIJING
99   pGenNprimFrm->AddFrame(fGenNprimEntry=new TGNumberEntry(pGenNprimFrm,500));
100   
101 // Magnetic Field
102   pVerFrame->AddFrame(pFldGrpFrm=new TGGroupFrame(pHorFrame,"Magnetic Field"));
103   pFldGrpFrm->AddFrame(fMagFldChkBtn=new TGCheckButton(pFldGrpFrm,"On/Off"));
104   fMagFldChkBtn->SetState(kButtonDown);
105 //Detectors
106   pHorFrame->AddFrame(fDetButGrp=new TGButtonGroup(pHorFrame,"Detectors"));
107   fDetButGrp->Connect("Pressed(Int_t)","RichConfig",this,"AddDetector(Int_t)");
108   fDetButGrp->Connect("Released(Int_t)","RichConfig",this,"RemoveDetector(Int_t)");
109   new TGCheckButton(fDetButGrp,"PIPE"  ,kPIPE));         
110   new TGCheckButton(fDetButGrp,"ITS"   ,kITS));         
111   new TGCheckButton(fDetButGrp,"TPC"   ,kTPC));
112   new TGCheckButton(fDetButGrp,"TRD"   ,kTRD));
113   new TGCheckButton(fDetButGrp,"TOF"   ,kTOF));         
114   new TGCheckButton(fDetButGrp,"FRAME" ,kFRAME));         
115   new TGCheckButton(fDetButGrp,"MAG"   ,kMAG));         
116   new TGCheckButton(fDetButGrp,"CRT"   ,kCRT));         
117   new TGCheckButton(fDetButGrp,"HALL"  ,kHALL));         
118   new TGCheckButton(fDetButGrp,"PHOS"  ,kPHOS));         
119   new TGCheckButton(fDetButGrp,"START" ,kSTART));         
120   new TGCheckButton(fDetButGrp,"FMD"   ,kFMD));         
121   new TGCheckButton(fDetButGrp,"ABSO"  ,kABSO));         
122   new TGCheckButton(fDetButGrp,"PMD"   ,kPMD));         
123   new TGCheckButton(fDetButGrp,"DIPO"  ,kDIPO));         
124   new TGCheckButton(fDetButGrp,"EMCAL" ,kEMCAL));         
125   new TGCheckButton(fDetButGrp,"VZERO" ,kVZERO));         
126   new TGCheckButton(fDetButGrp,"MUON"  ,kMUON));         
127   new TGCheckButton(fDetButGrp,"ZDC"   ,kZDC));         
128   new TGCheckButton(fDetButGrp,"SHILD" ,kSHILD));         
129 //Processes  
130   pHorFrame->AddFrame(pProcButGrp=new TGButtonGroup(pHorFrame,"Processes"));
131   pProcButGrp->Connect("Pressed(Int_t)","RichConfig",this,"AddProcess(Int_t)");
132   pProcButGrp->Connect("Released(Int_t)","RichConfig",this,"RemoveProcess(Int_t)");
133   new TGCheckButton(pProcButGrp,"DCAY decay",kDCAY));  pProcButGrp->SetButton(kDCAY);       
134   new TGCheckButton(pProcButGrp,"PAIR pair production",kPAIR));  pProcButGrp->SetButton(kPAIR);       
135   new TGCheckButton(pProcButGrp,"COMP Compton",kCOMP));  pProcButGrp->SetButton(kCOMP);
136   new TGCheckButton(pProcButGrp,"PHOT",kPHOT));  pProcButGrp->SetButton(kPHOT);
137   new TGCheckButton(pProcButGrp,"PFIS Photofission",kPFIS));  
138   new TGCheckButton(pProcButGrp,"DRAY delta electrons",kDRAY));  
139   new TGCheckButton(pProcButGrp,"ANNI annihilation",kANNI));  pProcButGrp->SetButton(kANNI);       
140   new TGCheckButton(pProcButGrp,"BREM Bremstraslung",kBREM));  pProcButGrp->SetButton(kBREM);       
141   new TGCheckButton(pProcButGrp,"MUNU",kMUNU));  pProcButGrp->SetButton(kMUNU);       
142   new TGCheckButton(pProcButGrp,"CKOV Cerenkovs",kCKOV));  pProcButGrp->SetButton(kCKOV);       
143   new TGCheckButton(pProcButGrp,"HADR Hadronic interactions ",kHADR));  pProcButGrp->SetButton(kHADR);       
144   new TGCheckButton(pProcButGrp,"LOSS",kLOSS));  pProcButGrp->SetButton(kLOSS);       
145   new TGCheckButton(pProcButGrp,"MULS",kMULS));  pProcButGrp->SetButton(kMULS);       
146   new TGCheckButton(pProcButGrp,"RAYL",kRAYL));  pProcButGrp->SetButton(kRAYL);       
147 //File    
148   fMain->AddFrame(pFileHorFrm=new TGHorizontalFrame(fMain,100,200));
149   pFileHorFrm->AddFrame(pCreateBtn=new TGTextButton(pFileHorFrm,"Create"));
150   pCreateBtn->Connect("Clicked()","RichConfig",this,"CreateConfigFile()");                                 
151   pFileHorFrm->AddFrame(new TGLabel(pFileHorFrm,Form(" config file as %s",fFileName)));  
152   
153   fMain->MapSubwindows();   
154   fMain->Layout();
155   fMain->SetWindowName("Create AliROOT Config script");
156   fMain->MapWindow();      
157 }//KirCondig::ctor
158           
159 void RichConfig::CreateConfigFile()
160 {   
161   FILE *fp=fopen(fFileName,"w"); if(!fp){Info("CreateConfigFile","Cannot open output file:%sn",fFileName);return;}
162   
163   fprintf(fp,"void Config()\n");
164   fprintf(fp,"{\n");
165   fprintf(fp,"  ::Info(\"RICH private config\",\"Start\");\n\n"); 
166 //Random
167   fprintf(fp,"  gRandom->SetSeed(123456);//put 0 to use system time\n\n");    
168 //Geant  
169   fprintf(fp,"  gSystem->Load(\"libgeant321\");\n");
170   fprintf(fp,"  new TGeant3(\"C++ Interface to Geant3\");\n\n");
171 //File
172   fprintf(fp,"  AliRunLoader *pAL=AliRunLoader::Open(\"galice.root\",AliConfig::GetDefaultEventFolderName(),\"recreate\");\n");    
173   fprintf(fp,"  pAL->SetCompressionLevel(2);\n");
174   fprintf(fp,"  pAL->SetNumberOfEventsPerFile(1000);\n");
175   fprintf(fp,"  gAlice->SetRunLoader(pAL);\n\n");
176 //Decayer  
177   fprintf(fp,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
178   fprintf(fp,"  pDecayer->SetForceDecay(kAll);\n"); 
179   fprintf(fp,"  pDecayer->Init();\n"); 
180   fprintf(fp,"  gMC->SetExternalDecayer(pDecayer);\n\n");
181 //Physics
182   if(IsProcessOn(kDCAY)) fprintf(fp,"  gMC->SetProcess(\"DCAY\",1);");  else fprintf(fp,"  gMC->SetProcess(\"DCAY\",0);");
183   if(IsProcessOn(kPAIR)) fprintf(fp,"  gMC->SetProcess(\"PAIR\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PAIR\",0);\n");
184   if(IsProcessOn(kCOMP)) fprintf(fp,"  gMC->SetProcess(\"COMP\",1);");  else fprintf(fp,"  gMC->SetProcess(\"COMP\",0);");
185   if(IsProcessOn(kPHOT)) fprintf(fp,"  gMC->SetProcess(\"PHOT\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PHOT\",0);\n");
186   if(IsProcessOn(kPFIS)) fprintf(fp,"  gMC->SetProcess(\"PFIS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"PFIS\",0);");
187   if(IsProcessOn(kDRAY)) fprintf(fp,"  gMC->SetProcess(\"DRAY\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"DRAY\",0);\n");
188   if(IsProcessOn(kANNI)) fprintf(fp,"  gMC->SetProcess(\"ANNI\",1);");  else fprintf(fp,"  gMC->SetProcess(\"ANNI\",0);");
189   if(IsProcessOn(kBREM)) fprintf(fp,"  gMC->SetProcess(\"BREM\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"BREM\",0);\n");
190   if(IsProcessOn(kMUNU)) fprintf(fp,"  gMC->SetProcess(\"MUNU\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MUNU\",0);");
191   if(IsProcessOn(kCKOV)) fprintf(fp,"  gMC->SetProcess(\"CKOV\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"CKOV\",0);\n");
192   if(IsProcessOn(kHADR)) fprintf(fp,"  gMC->SetProcess(\"HADR\",1);");  else fprintf(fp,"  gMC->SetProcess(\"HADR\",0);");
193   if(IsProcessOn(kLOSS)) fprintf(fp,"  gMC->SetProcess(\"LOSS\",2);\n");else fprintf(fp,"  gMC->SetProcess(\"LOSS\",0);\n");
194   if(IsProcessOn(kMULS)) fprintf(fp,"  gMC->SetProcess(\"MULS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MULS\",0);");
195   if(IsProcessOn(kRAYL)) fprintf(fp,"  gMC->SetProcess(\"RAYL\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"RAYL\",0);\n");
196   
197   fprintf(fp,"  gMC->SetCut(\"CUTGAM\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"CUTELE\",0.001); ");
198   fprintf(fp,"  gMC->SetCut(\"CUTNEU\",0.001);\n"); fprintf(fp,"  gMC->SetCut(\"CUTHAD\",0.001); ");
199   fprintf(fp,"  gMC->SetCut(\"CUTMUO\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"BCUTE\" ,0.001);\n");
200   fprintf(fp,"  gMC->SetCut(\"BCUTM\" ,0.001); ");  fprintf(fp,"  gMC->SetCut(\"DCUTE\" ,0.001); ");
201   fprintf(fp,"  gMC->SetCut(\"DCUTM\" ,0.001);\n");  fprintf(fp,"  gMC->SetCut(\"PPCUTM\",0.001); ");
202   fprintf(fp,"  gMC->SetCut(\"TOFMAX\",1e10);\n\n"); 
203 //Field
204   if(fMagFldChkBtn->GetState()==kButtonDown) fprintf(fp,"  gAlice->SetField();\n\n");else fprintf(fp,"  gAlice->SetField(0);\n\n");
205   fprintf(fp,"  pAL->CdGAFile();\n\n");                                 //????       
206 //BODY-ALIC 
207   fprintf(fp,"  new AliBODY(\"BODY\",\"Alice envelop\");\n\n");
208 //RICH
209   if(fRichVersionCombo->GetSelected() != -1){  
210     if(fRichTopChkBtn->GetState()==kButtonDown)       fprintf(fp,"  AliRICHParam::AngleRot(0);\n");
211     if(fRichDeclusterChkBtn->GetState()!=kButtonDown) fprintf(fp,"  AliRICHParam::SetDeclustering(kFALSE);\n");
212     if(fRichSagChkBtn->GetState()!=kButtonDown)       fprintf(fp,"  AliRICHParam::SetWireSag(kFALSE);\n");
213     if(fRichRadioSrcChkBtn->GetState()==kButtonDown)  fprintf(fp,"  AliRICHParam::SetRadioSrc(kTRUE);\n");
214     switch(fRichVersionCombo->GetSelected()){//RICH
215       case 0:   fprintf(fp,"  pRICH=new AliRICHv0(\"RICH\",\"RICH version 0\");\n"); break;   
216       case 1:   fprintf(fp,"  pRICH=new AliRICHv1(\"RICH\",\"RICH version 1\");\n"); break;   
217     }
218     fprintf(fp,"  ::Info(\"RICH private config\",\"version %i\");\n\n",fRichVersionCombo->GetSelected()); 
219   }
220 //Generator
221   switch(fGenTypeCombo->GetSelected()){
222     case kHijingPara: 
223       fprintf(fp,"  AliGenHIJINGpara *pGen=new AliGenHIJINGpara(%i);\n",(int)fGenNprimEntry->GetNumber());
224       fprintf(fp,"  pGen->SetMomentumRange(0,999); pGen->SetThetaRange(%f,%f); pGen->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
225       fprintf(fp,"  pGen->SetOrigin(0,0,0);  pGen->SetSigma(0,0,0);\n");
226       fprintf(fp,"  pGen->Init();\n");
227     break;
228     case kGun1:     
229       fprintf(fp,"  AliGenBox *pGen=new AliGenBox(1);\n");  
230       fprintf(fp,"  pGen->SetPart(%i); pGen->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());  
231       fprintf(fp,"  pGen->SetMomentumRange(%3.1f,%3.1f); \n",float(fGenMinMomCombo->GetSelected())/10,   float(fGenMaxMomCombo->GetSelected())/10);
232       fprintf(fp,"  pGen->SetThetaRange(pRICH->C(%i)->ThetaD()-3,pRICH->C(%i)->ThetaD()-1); \n",fGenChamberCombo->GetSelected(),fGenChamberCombo->GetSelected());
233       fprintf(fp,"  pGen->SetPhiRange(pRICH->C(%i)->PhiD()-1,pRICH->C(%i)->PhiD()+1); \n",fGenChamberCombo->GetSelected(),fGenChamberCombo->GetSelected());    
234       fprintf(fp,"  pGen->Init();\n");
235     break;    
236     case kGun7:   
237       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
238       fprintf(fp,"  for(int i=1;i<=7;i++){\n");
239       fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
240       fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(1.0+i*0.5); pFixed->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());
241       fprintf(fp,"    pFixed->SetPhi(pRICH->C(i)->PhiD()); pFixed->SetTheta(pRICH->C(i)->ThetaD()-2);\n");                             
242       fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
243       fprintf(fp,"  pCocktail->Init();\n");
244     break;
245     case kPythia7:      
246       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
247       fprintf(fp,"  for(int i=1;i<=7;i++){\n");
248       fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
249       fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(2.5+i*0.4); pFixed->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());
250       fprintf(fp,"    pFixed->SetPhiRange(pRICH->C(i)->PhiD()); pFixed->SetThetaRange(pRICH->C(i)->ThetaD()-2);\n");                             
251       fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
252       fprintf(fp,"  AliGenPythia *pPythia = new AliGenPythia(-1);\n");
253       fprintf(fp,"  pPythia->SetMomentumRange(0,999999); pPythia->SetPhiRange(20,80); pPythia->SetThetaRange(75,115);\n");
254       fprintf(fp,"  pPythia->SetYRange(-12,12);  pPythia->SetPtRange(0,1000);  pPythia->SetStrucFunc(kCTEQ4L);\n");
255       fprintf(fp,"  pPythia->SetProcess(kPyMb);  pPythia->SetEnergyCMS(14000);\n");      
256       fprintf(fp,"  pCocktail->AddGenerator(pPythia,\"Pythia\",1);\n");  
257       fprintf(fp,"  pCocktail->Init();\n");
258     case kSr90:  
259       fprintf(fp,"  AliGenRadioactive *pGen=new AliGenRadioactive(kSr90,%i);\n",(int)fGenNprimEntry->GetNumber());
260       fprintf(fp,"  pGen->SetOrigin(0,0,0);  pGen->SetSigma(0.1,0.1,0.05);\n");      
261       fprintf(fp,"  pGen->Init();\n");
262     break;  
263     case kHijing:  
264       fprintf(fp,"  AliGenHijing *pGen=new AliGenHijing(-1); pGen->SetEnergyCMS(5500); pGen->SetReferenceFrame(\"CMS\");\n");
265       fprintf(fp,"  pGen->SetProjectile(\"A\", 208, 82); pGen->SetTarget(\"A\", 208, 82);\n");      
266       fprintf(fp,"  pGen->SetJetQuenching(0); pGen->SetShadowing(0);\n");
267       fprintf(fp,"  pGen->KeepFullEvent(); pGen->SetSelectAll(0); \n");
268       fprintf(fp,"  pGen->SetImpactParameterRange(0., 5.);\n");
269       fprintf(fp,"  pGen->Init();\n");
270     break;  
271   }
272 //central before RICH detectors                  
273   if(IsDetectorOn(kPIPE)) fprintf(fp,"\n  new AliPIPEv0(\"PIPE\",\"Beam Pipe\");\n");
274   if(IsDetectorOn(kSHILD))fprintf(fp,"\n  new AliSHILv2(\"SHIL\",\"Shielding Version 2\");\n");  
275   if(IsDetectorOn(kITS)){
276     fprintf(fp,"\n  AliITSvPPRasymmFMD *pIts =new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version\");\n");
277     fprintf(fp,"  pIts->SetMinorVersion(2); pIts->SetReadDet(kTRUE);\n");
278     fprintf(fp,"  pIts->SetThicknessDet1(200.); pIts->SetThicknessDet2(200.);\n");
279     fprintf(fp,"  pIts->SetThicknessChip1(200.); pIts->SetThicknessChip2(200.);\n");
280     fprintf(fp,"  pIts->SetRails(0); pIts->SetCoolingFluid(1);\n");
281     fprintf(fp,"  pIts->SetEUCLID(0);\n");
282   }  
283   if(IsDetectorOn(kTPC)) {fprintf(fp,"\n  AliTPC *pTpc=new AliTPCv2(\"TPC\",\"Default\"); pTpc->SetSecAU(-1);pTpc->SetSecAL(-1);\n");}  
284   if(IsDetectorOn(kFRAME))fprintf(fp,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
285   if(IsDetectorOn(kTRD)){
286     fprintf(fp,"\n  AliTRD *pTrd=new AliTRDv1(\"TRD\",\"TRD slow simulator\");\n");
287     fprintf(fp,"  pTrd->SetGasMix(1); pTrd->SetPHOShole(); pTrd->SetRICHhole();pTrd->CreateTR();\n");
288   }  
289   if(IsDetectorOn(kTOF))   fprintf(fp,"\n  new AliTOFv4T0(\"TOF\", \"normal TOF\");\n");
290 //central after RICH detectors  
291   if(IsDetectorOn(kMAG))  fprintf(fp,"\n  new AliMAG(\"MAG\",\"Magnet\");\n");  
292   if(IsDetectorOn(kHALL)) fprintf(fp,"\n  new AliHALL(\"HALL\",\"Alice Hall\");\n");
293 //forward detectors  
294   if(IsDetectorOn(kFMD))   fprintf(fp,"\n  new AliFMDv1(\"FMD\",\"normal FMD\");\n");
295   if(IsDetectorOn(kABSO))  fprintf(fp,"\n  new AliABSOv0(\"ABSO\",\"Muon absorber\");\n");
296   if(IsDetectorOn(kDIPO))  fprintf(fp,"\n  new AliDIPOv2(\"DIPO\",\"Dipole version 2\");\n");
297   if(IsDetectorOn(kMUON))  fprintf(fp,"\n  new AliMUONv1(\"MUON\",\"default\");\n");
298   if(IsDetectorOn(kPMD))   fprintf(fp,"\n  new AliPMDv1(\"PMD\",\"normal PMD\");\n");
299   if(IsDetectorOn(kSTART)) fprintf(fp,"\n  new AliSTARTv1(\"START\",\"START Detector\");\n");
300   if(IsDetectorOn(kVZERO)) fprintf(fp,"\n  new AliVZEROv2(\"VZERO\",\"normal VZERO\");\n");
301   if(IsDetectorOn(kZDC))   fprintf(fp,"\n  new AliZDCv2(\"ZDC\",\"normal ZDC\");\n");
302 //different phase space detectors  
303   if(IsDetectorOn(kPHOS))  fprintf(fp,"\n  new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
304   if(IsDetectorOn(kEMCAL)) fprintf(fp,"\n  new AliEMCALv1(\"EMCAL\",\"G56_2_55_19_104_14\");\n");
305   if(IsDetectorOn(kCRT))   fprintf(fp,"\n  new AliCRTv0(\"CRT\",\"normal ACORDE\");\n");
306
307   fprintf(fp,"\n  ::Info(\"RICH private config\",\"Stop\");\n"); 
308   fprintf(fp,"}\n");
309   fclose(fp);  
310   CreateRichBatch();  
311 //  fMain->CloseWindow();
312 }//CreateConfigFile
313 //__________________________________________________________________________________________________
314 void RichConfig::CreateRichBatch()
315 {
316   FILE *fp=fopen("RichBatch.C","w"); if(!fp){Info("CreateRichBatch","Cannot open output file: RichBatch.C");return;}
317   
318   fprintf(fp,"void RichBatch(const Int_t iNevents,const Bool_t isDebug,const char *sConfigFileName)\n");
319   fprintf(fp,"{\n");
320   fprintf(fp,"  gSystem->Exec(\"rm -rf *.root hlt hough ZZZ*\");\n");
321   fprintf(fp,"  if(isDebug)   AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
322   fprintf(fp,"  TStopwatch sw;TDatime time;\n\n");
323   
324   fprintf(fp,"  AliSimulation     *pSim=new AliSimulation;\n");
325   if(fGenTypeCombo->GetSelected()==kGun1||fGenTypeCombo->GetSelected()==kGun7) {
326     fprintf(fp,"  pSim->SetRegionOfInterest(kTRUE);\n");
327     fprintf(fp,"  pSim->SetMakeSDigits(\"TOF RICH\");\n");
328     fprintf(fp,"  pSim->SetMakeDigitsFromHits(\"ITS TPC TRD\");\n");
329   }
330   fprintf(fp,"  pSim->Run(iNevents); delete pSim;\n\n");
331   
332   fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
333   fprintf(fp,"  pRec->SetRunLocalReconstruction(\"ITS TPC TRD TOF RICH\");\n");
334   fprintf(fp,"  pRec->SetFillESD(\"ITS TPC TRD TOF RICH\");\n");
335   fprintf(fp,"  pRec->Run();         delete pRec;\n\n");
336   
337   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Start time: \";time.Print();\n");
338   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Stop  time: \";time.Set();  time.Print();\n");
339   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Time  used: \";sw.Print();\n\n");
340   
341   fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n");
342   fprintf(fp,"  gSystem->Exec(\"playwave ~/bin/end.wav\");\n");
343   fprintf(fp,"}\n");
344   
345   fclose(fp);  
346 }//CreateRichBatch()
347 //__________________________________________________________________________________________________
348 RichConfig *p;
349 void CreateConfig()
350 {
351    p=new RichConfig("Config.C");
352 }   
353