No return in void function (Alpha)
[u/mrichter/AliRoot.git] / RICH / RichConfig.C
1 class RichConfig
2 {
3 RQ_OBJECT()
4 public:
5  
6           RichConfig(const char*sFileName);
7          ~RichConfig()                    {Info("ctor","");fMainFM->Cleanup(); delete fMainFM;}
8 //protected:
9   enum ERichVers  {kNoRich=-1,kNormalRich,kTestBeam,kTestRadio,kAerogel,kOnTop};
10   enum EGenTypes  {kProton15=100,kBox1,kGun7,kPythia7,kHijing,kHijingPara,kRichLib,kSignalHijing,kHijingPara2Proton};
11   
12   enum EDetectors {kPIPE=1,kITS,kTPC,kTRD,kTOF,kFRAME,kMAG,kCRT,kHALL,kPHOS,kSTART,kFMD,kABSO,kPMD,kDIPO,kEMCAL,kVZERO,kMUON,kZDC,kSHILD};
13   enum EProcesses {kDCAY=1,kPAIR,kCOMP,kPHOT,kPFIS,kDRAY,kANNI,kBREM,kMUNU,kCKOV,kHADR,kLOSS,kMULS,kRAYL,kALL};
14   
15   void    AddDetector(Int_t id)          {if(id==kTRD || id==kTOF) fDetBG->SetButton(kFRAME);}
16   void    RemoveDetector(Int_t id)       {if(id==kFRAME) {fDetBG->SetButton(kTRD,kFALSE);fDetBG->SetButton(kTOF,kFALSE);}}
17   
18   void    AddProcess(Int_t id)           {if(id==kALL) for(int i=1;i<=fProcBG->GetCount();i++) fProcBG->SetButton(i,kButtonDown);}
19   void    RemoveProcess(Int_t id)        {if(id==kALL) for(int i=1;i<=fProcBG->GetCount();i++) fProcBG->SetButton(i,kButtonUp);}
20   
21   Float_t Eta2Theta(Float_t arg)    const{return (180./TMath::Pi())*2.*TMath::ATan(TMath::Exp(-arg));}
22   void    CreateConfig();
23   void    CreateRichBatch();
24   void    Exit();
25      
26   TGMainFrame  *fMainFM;//main window poiter
27   TGComboBox   *fRichVerCombo;  TGButton *fRichDeclusterBC,*fRichSagBC,*fRichDebugBC,*fRichFeedbackBC;//RICH
28   TGButton     *fMagFldBC;                               //MAG
29   TGComboBox   *fGenTypeCombo,*fGenPartIdCombo,*fGenMinMomCombo,*fGenMaxMomCombo,*fGenChamberCombo; TGNumberEntry *fGenNprimEntry;//GEN
30   TGButtonGroup *fDetBG;       //DETECTORS
31   TGButtonGroup *fProcBG;      //PROCESSES
32   char         *fFileName;
33 };//class RichConfig
34 //__________________________________________________________________________________________________     
35 RichConfig::RichConfig(const char *sFileName)
36 {// creates configuration file  
37   fFileName=sFileName;
38 // Create main frame       
39   fMainFM=new TGMainFrame(gClient->GetRoot(),500,400);
40 //  fMain->Connect("CloseWindow()","RichConfig",this,"CloseWindow()");   
41   fMainFM->AddFrame(pHorFrame=new TGHorizontalFrame(fMainFM,100,200));
42 //RICH
43   pHorFrame->AddFrame(pVerFrame=new TGVerticalFrame(pHorFrame,100,200));  
44   pVerFrame->AddFrame(pRichFG=new TGGroupFrame(pHorFrame,"RICH"));
45   pRichFG->AddFrame(fRichVerCombo=new TGComboBox(pRichFG,100));
46     fRichVerCombo->AddEntry("no RICH"      ,kNoRich);
47     fRichVerCombo->AddEntry("normal RICH"  ,kNormalRich);
48     fRichVerCombo->AddEntry("RICH on top"  ,kOnTop);
49     fRichVerCombo->AddEntry("test beam"    ,kTestBeam);
50     fRichVerCombo->AddEntry("radio source" ,kTestRadio);
51     fRichVerCombo->AddEntry("aerogel"      ,kAerogel);
52     fRichVerCombo->Select(kNormalRich);  fRichVerCombo->Resize(150,20);
53     pRichFG->AddFrame(fRichDeclusterBC=new TGCheckButton(pRichFG,"Declustering"));       fRichDeclusterBC->SetState(kButtonDown);
54     pRichFG->AddFrame(fRichSagBC      =new TGCheckButton(pRichFG,"Wire sagita?"));       fRichSagBC      ->SetState(kButtonDown);
55     pRichFG->AddFrame(fRichDebugBC    =new TGCheckButton(pRichFG,"Debug StepManager?"));
56     pRichFG->AddFrame(fRichFeedbackBC =new TGCheckButton(pRichFG,"Generate feedbacks?"));fRichFeedbackBC ->SetState(kButtonDown); 
57 //Generator  
58   pVerFrame->AddFrame(pGenGrpFrm=new TGGroupFrame(pHorFrame,"Generator"));
59   pGenGrpFrm->AddFrame(fGenTypeCombo=new TGComboBox(pGenGrpFrm,100));
60   fGenTypeCombo->AddEntry("15 GeV proton to fixed pad",kProton15);  
61   fGenTypeCombo->AddEntry("box gun to single chamber",kBox1);  
62   fGenTypeCombo->AddEntry("gun to all chambers",kGun7);
63   fGenTypeCombo->AddEntry("7 guns+Pythia",kPythia7);
64   fGenTypeCombo->AddEntry("HIJING",kHijing);
65   fGenTypeCombo->AddEntry("parametrized HIJING",kHijingPara);
66   fGenTypeCombo->AddEntry("2 p+HIJING",kHijingPara2Proton);
67   fGenTypeCombo->AddEntry("Sr90 source",kSr90);
68   fGenTypeCombo->AddEntry("RICH lib",kRichLib);
69   fGenTypeCombo->AddEntry("RICH lib+HIJING",kSignalHijing);
70   fGenTypeCombo->Select(kHijingPara);
71   fGenTypeCombo->Resize(160,20);
72   
73   pGenGrpFrm->AddFrame(fGenPartIdCombo=new TGComboBox(pGenGrpFrm,100)); //PID for guns
74   fGenPartIdCombo->AddEntry("Pion+"     ,kPiPlus);
75   fGenPartIdCombo->AddEntry("Pion-"     ,kPiMinus);
76   fGenPartIdCombo->AddEntry("Kaon+"     ,kKPlus);
77   fGenPartIdCombo->AddEntry("Kaon-"     ,kKMinus);
78   fGenPartIdCombo->AddEntry("K0s"       ,kK0Short);    
79   fGenPartIdCombo->AddEntry("Proton"    ,kProton);
80   fGenPartIdCombo->AddEntry("ProtonBar" ,kProtonBar);
81   fGenPartIdCombo->AddEntry("Lambda"    ,kLambda0);
82   fGenPartIdCombo->AddEntry("LambdaBar" ,kLambda0Bar);
83   fGenPartIdCombo->Select(kProton);  fGenPartIdCombo->Resize(160,20);
84
85   pGenGrpFrm->AddFrame(fGenMinMomCombo=new TGComboBox(pGenGrpFrm,100)); //particle energy for guns
86   
87   for(Int_t i=5;i<=95;i+=5)
88     fGenMinMomCombo->AddEntry(Form("%3.1f GeV",0.1*i), i);
89   fGenMinMomCombo->Select(15);  fGenMinMomCombo->Resize(160,20);
90   
91   pGenGrpFrm->AddFrame(fGenMaxMomCombo=new TGComboBox(pGenGrpFrm,100)); //particle energy for guns
92   for(Int_t i=10;i<=95;i+=5)
93     fGenMaxMomCombo->AddEntry(Form("%3.1f GeV",0.1*i), i);
94   fGenMaxMomCombo->Select(40);  fGenMaxMomCombo->Resize(160,20);
95   
96   pGenGrpFrm->AddFrame(fGenChamberCombo=new TGComboBox(pGenGrpFrm,100)); //chamber number in case of gun1
97   for(int i=1;i<=7;i++) fGenChamberCombo->AddEntry(Form("Chamber %i",i),i);
98   fGenChamberCombo->Select(4); fGenChamberCombo->Resize(160,20);
99   
100   pGenGrpFrm->AddFrame(pGenNprimFrm=new TGGroupFrame(pGenGrpFrm,"Number of primaries"));//number of primiries in case of HIJING
101   pGenNprimFrm->AddFrame(fGenNprimEntry=new TGNumberEntry(pGenNprimFrm,500));
102   
103 // Magnetic Field
104   pVerFrame->AddFrame(pFldGrpFrm=new TGGroupFrame(pHorFrame,"Magnetic Field"));
105   pFldGrpFrm->AddFrame(fMagFldBC=new TGCheckButton(pFldGrpFrm,"On/Off"));
106   fMagFldBC->SetState(kButtonDown);
107 //Detectors
108   pHorFrame->AddFrame(fDetBG=new TGButtonGroup(pHorFrame,"Detectors"));
109   fDetBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"AddDetector(Int_t)");
110   fDetBG->Connect("Released(Int_t)","RichConfig",this,"RemoveDetector(Int_t)");
111     new TGCheckButton(fDetBG,"PIPE"  ,kPIPE));         
112     new TGCheckButton(fDetBG,"ITS"   ,kITS));         
113     new TGCheckButton(fDetBG,"TPC"   ,kTPC));
114     new TGCheckButton(fDetBG,"TRD"   ,kTRD));
115     new TGCheckButton(fDetBG,"TOF"   ,kTOF));         
116     new TGCheckButton(fDetBG,"FRAME" ,kFRAME));         
117     new TGCheckButton(fDetBG,"MAG"   ,kMAG));         
118     new TGCheckButton(fDetBG,"CRT"   ,kCRT));         
119     new TGCheckButton(fDetBG,"HALL"  ,kHALL));         
120     new TGCheckButton(fDetBG,"PHOS"  ,kPHOS));         
121     new TGCheckButton(fDetBG,"START" ,kSTART));         
122     new TGCheckButton(fDetBG,"FMD"   ,kFMD));         
123     new TGCheckButton(fDetBG,"ABSO"  ,kABSO));         
124     new TGCheckButton(fDetBG,"PMD"   ,kPMD));         
125     new TGCheckButton(fDetBG,"DIPO"  ,kDIPO));         
126     new TGCheckButton(fDetBG,"EMCAL" ,kEMCAL));         
127     new TGCheckButton(fDetBG,"VZERO" ,kVZERO));         
128     new TGCheckButton(fDetBG,"MUON"  ,kMUON));         
129     new TGCheckButton(fDetBG,"ZDC"   ,kZDC));         
130     new TGCheckButton(fDetBG,"SHILD" ,kSHILD));         
131 //Processes  
132   pHorFrame->AddFrame(fProcBG=new TGButtonGroup(pHorFrame,"Processes"));
133   fProcBG->Connect("Pressed(Int_t)" ,"RichConfig",this,"AddProcess(Int_t)");
134   fProcBG->Connect("Released(Int_t)","RichConfig",this,"RemoveProcess(Int_t)");
135     new TGCheckButton(fProcBG,"ALL  ON/OFF"                 ,kALL)) ;
136     new TGCheckButton(fProcBG,"DCAY Decay"                  ,kDCAY));  fProcBG->SetButton(kDCAY);       
137     new TGCheckButton(fProcBG,"PAIR Pair production"        ,kPAIR));  fProcBG->SetButton(kPAIR);       
138     new TGCheckButton(fProcBG,"COMP Compton"                ,kCOMP));  fProcBG->SetButton(kCOMP);
139     new TGCheckButton(fProcBG,"PHOT"                        ,kPHOT));  fProcBG->SetButton(kPHOT);
140     new TGCheckButton(fProcBG,"PFIS Photofission"           ,kPFIS));  
141     new TGCheckButton(fProcBG,"DRAY Delta electrons"        ,kDRAY));  
142     new TGCheckButton(fProcBG,"ANNI Annihilation"           ,kANNI));  fProcBG->SetButton(kANNI);       
143     new TGCheckButton(fProcBG,"BREM Bremstraslung"          ,kBREM));  fProcBG->SetButton(kBREM);       
144     new TGCheckButton(fProcBG,"MUNU Muon-Nuclear"           ,kMUNU));  fProcBG->SetButton(kMUNU);       
145     new TGCheckButton(fProcBG,"CKOV Cerenkovs"              ,kCKOV));  fProcBG->SetButton(kCKOV);       
146     new TGCheckButton(fProcBG,"HADR Hadronic interactions " ,kHADR));  fProcBG->SetButton(kHADR);       
147     new TGCheckButton(fProcBG,"LOSS Energy losses"          ,kLOSS));  fProcBG->SetButton(kLOSS);       
148     new TGCheckButton(fProcBG,"MULS Multiple scattering"    ,kMULS));  fProcBG->SetButton(kMULS);       
149     new TGCheckButton(fProcBG,"RAYL"                        ,kRAYL));  fProcBG->SetButton(kRAYL);       
150 //File    
151   fMainFM->AddFrame(pFileHorFrm=new TGHorizontalFrame(fMainFM,100,200));
152   pFileHorFrm->AddFrame(pCreateB=new TGTextButton(pFileHorFrm,"Create"));
153   pCreateB->Connect("Clicked()","RichConfig",this,"Exit()");                                 
154   pFileHorFrm->AddFrame(new TGLabel(pFileHorFrm,Form(" config file as %s",fFileName)));  
155   
156   fMainFM->MapSubwindows();   
157   fMainFM->Layout();
158   fMainFM->SetWindowName("Create AliROOT scripts");
159   fMainFM->MapWindow();      
160 }//KirCondig::ctor
161 //__________________________________________________________________________________________________          
162 void RichConfig::CreateConfig()
163 {   
164   FILE *fp=fopen(fFileName,"w"); if(!fp){Info("CreateConfigFile","Cannot open output file:%sn",fFileName);return;}
165   
166   fprintf(fp,"void Config()\n");
167   fprintf(fp,"{\n");
168   fprintf(fp,"  ::Info(\"RICH private config\",\"Start\");\n\n"); 
169 //Random
170   fprintf(fp,"  gRandom->SetSeed(123456);//put 0 to use system time\n\n");    
171 //Geant  
172   fprintf(fp,"  gSystem->Load(\"libgeant321\");\n");
173   fprintf(fp,"  new TGeant3(\"C++ Interface to Geant3\");\n\n");
174 //File
175   fprintf(fp,"  AliRunLoader *pAL=AliRunLoader::Open(\"galice.root\",AliConfig::GetDefaultEventFolderName(),\"recreate\");\n");    
176   fprintf(fp,"  pAL->SetCompressionLevel(2);\n");
177   fprintf(fp,"  pAL->SetNumberOfEventsPerFile(1000);\n");
178   fprintf(fp,"  gAlice->SetRunLoader(pAL);\n\n");
179 //Decayer  
180   fprintf(fp,"  TVirtualMCDecayer *pDecayer=new AliDecayerPythia();\n");
181   fprintf(fp,"  pDecayer->SetForceDecay(kAll);\n"); 
182   fprintf(fp,"  pDecayer->Init();\n"); 
183   fprintf(fp,"  gMC->SetExternalDecayer(pDecayer);\n\n");
184 //Physics
185   if(fProcBG->GetButton(kDCAY)->GetState()) fprintf(fp,"  gMC->SetProcess(\"DCAY\",1);");  else fprintf(fp,"  gMC->SetProcess(\"DCAY\",0);");
186   if(fProcBG->GetButton(kPAIR)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PAIR\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PAIR\",0);\n");
187   if(fProcBG->GetButton(kCOMP)->GetState()) fprintf(fp,"  gMC->SetProcess(\"COMP\",1);");  else fprintf(fp,"  gMC->SetProcess(\"COMP\",0);");
188   if(fProcBG->GetButton(kPHOT)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PHOT\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"PHOT\",0);\n");
189   if(fProcBG->GetButton(kPFIS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"PFIS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"PFIS\",0);");
190   if(fProcBG->GetButton(kDRAY)->GetState()) fprintf(fp,"  gMC->SetProcess(\"DRAY\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"DRAY\",0);\n");
191   if(fProcBG->GetButton(kANNI)->GetState()) fprintf(fp,"  gMC->SetProcess(\"ANNI\",1);");  else fprintf(fp,"  gMC->SetProcess(\"ANNI\",0);");
192   if(fProcBG->GetButton(kBREM)->GetState()) fprintf(fp,"  gMC->SetProcess(\"BREM\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"BREM\",0);\n");
193   if(fProcBG->GetButton(kMUNU)->GetState()) fprintf(fp,"  gMC->SetProcess(\"MUNU\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MUNU\",0);");
194   if(fProcBG->GetButton(kCKOV)->GetState()) fprintf(fp,"  gMC->SetProcess(\"CKOV\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"CKOV\",0);\n");
195   if(fProcBG->GetButton(kHADR)->GetState()) fprintf(fp,"  gMC->SetProcess(\"HADR\",1);");  else fprintf(fp,"  gMC->SetProcess(\"HADR\",0);");
196   if(fProcBG->GetButton(kLOSS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"LOSS\",2);\n");else fprintf(fp,"  gMC->SetProcess(\"LOSS\",0);\n");
197   if(fProcBG->GetButton(kMULS)->GetState()) fprintf(fp,"  gMC->SetProcess(\"MULS\",1);");  else fprintf(fp,"  gMC->SetProcess(\"MULS\",0);");
198   if(fProcBG->GetButton(kRAYL)->GetState()) fprintf(fp,"  gMC->SetProcess(\"RAYL\",1);\n");else fprintf(fp,"  gMC->SetProcess(\"RAYL\",0);\n");
199   
200   fprintf(fp,"\n");  
201   fprintf(fp,"  gMC->SetCut(\"CUTGAM\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"CUTELE\",0.001); ");
202   fprintf(fp,"  gMC->SetCut(\"CUTNEU\",0.001);\n"); fprintf(fp,"  gMC->SetCut(\"CUTHAD\",0.001); ");
203   fprintf(fp,"  gMC->SetCut(\"CUTMUO\",0.001); ");  fprintf(fp,"  gMC->SetCut(\"BCUTE\" ,0.001);\n");
204   fprintf(fp,"  gMC->SetCut(\"BCUTM\" ,0.001); ");  fprintf(fp,"  gMC->SetCut(\"DCUTE\" ,0.001); ");
205   fprintf(fp,"  gMC->SetCut(\"DCUTM\" ,0.001);\n"); fprintf(fp,"  gMC->SetCut(\"PPCUTM\",0.001); ");
206   fprintf(fp,"  gMC->SetCut(\"TOFMAX\",1e10);\n\n"); 
207 //Field
208   if(fMagFldBC->GetState()==kButtonDown) fprintf(fp,"  gAlice->SetField();\n\n");else fprintf(fp,"  gAlice->SetField(0);\n\n");
209   fprintf(fp,"  pAL->CdGAFile();\n\n");                                 //????       
210 //BODY-ALIC 
211   fprintf(fp,"  new AliBODY(\"BODY\",\"Alice envelop\");\n\n");
212 //RICH
213   if(fRichVerCombo->GetSelected() != kNoRich){  
214     TString richStr="RICH "; 
215     if(fRichDeclusterBC->GetState()!=kButtonDown){richStr+="no declustering "  ; fprintf(fp,"  AliRICHParam::SetDeclustering(kFALSE);\n");}
216     if(fRichSagBC->GetState()      !=kButtonDown){richStr+="no sagita "        ; fprintf(fp,"  AliRICHParam::SetWireSag(kFALSE);\n")     ;}
217     switch(fRichVerCombo->GetSelected()){//RICH
218       case kOnTop:      richStr+="top position";fprintf(fp,"  AliRICHParam::SetAngleRot(0);\n")      ;break;   
219       case kAerogel:    richStr+="aerogel"     ;fprintf(fp,"  AliRICHParam::SetAerogel(kTRUE);\n") ;break;   
220       case kTestRadio:  richStr+="radioactive" ;fprintf(fp,"  AliRICHParam::SetRadioSrc(kTRUE);\n");
221                                                 fprintf(fp,"  AliRICHParam::SetTestBeam(kTRUE);\n");break;   
222       case kTestBeam:   richStr+="test beam"   ;fprintf(fp,"  AliRICHParam::SetTestBeam(kTRUE);\n");break;   
223       case kNormalRich: richStr+="normal"      ;                                                    break;   
224     }
225     if(fRichDebugBC->GetState()    ==kButtonDown){
226       richStr+="+debug StepManager"; 
227       fprintf(fp,"  AliRICH *pRICH=new AliRICHv0(\"RICH\",\"%s\");\n\n",richStr.Data());
228     }else{
229       fprintf(fp,"  AliRICH *pRICH=new AliRICHv1(\"RICH\",\"%s\");\n\n",richStr.Data());
230     }
231   }//Rich not selected
232 //Generator
233   switch(fGenTypeCombo->GetSelected()){
234     case kHijingPara: 
235       fprintf(fp,"  AliGenHIJINGpara *pGen=new AliGenHIJINGpara(%i);\n",(int)fGenNprimEntry->GetNumber());
236       fprintf(fp,"  pGen->SetMomentumRange(0,999); pGen->SetThetaRange(%f,%f); pGen->SetPhiRange(0,360);\n",Eta2Theta(8),Eta2Theta(-8));
237       fprintf(fp,"  pGen->SetOrigin(0,0,0);  pGen->SetSigma(0,0,0);\n");
238       fprintf(fp,"  pGen->Init();\n");
239     break;
240     case kBox1:     
241       fprintf(fp,"  AliGenBox *pGen=new AliGenBox(1);\n");  
242       fprintf(fp,"  pGen->SetPart(%i); pGen->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());  
243       fprintf(fp,"  pGen->SetMomentumRange(%3.1f,%3.1f); \n",float(fGenMinMomCombo->GetSelected())/10,   float(fGenMaxMomCombo->GetSelected())/10);
244       fprintf(fp,"  pGen->SetThetaRange(pRICH->C(%i)->ThetaD()-3,pRICH->C(%i)->ThetaD()-1); \n",fGenChamberCombo->GetSelected(),fGenChamberCombo->GetSelected());
245       fprintf(fp,"  pGen->SetPhiRange(pRICH->C(%i)->PhiD()-1,pRICH->C(%i)->PhiD()+1); \n",fGenChamberCombo->GetSelected(),fGenChamberCombo->GetSelected());    
246       fprintf(fp,"  pGen->Init();\n");
247     break;    
248     case kProton15:   
249       fprintf(fp,"  AliGenFixed *pFixed=new AliGenFixed(1);\n");
250       fprintf(fp,"  pFixed->SetPart(kProton); pFixed->SetOrigin(0,0,0);\n");
251       fprintf(fp,"  pFixed->SetMomentum(15);  pFixed->SetTheta(113.37); pFixed->SetPhi(9.73);\n");                             
252       fprintf(fp,"  pFixed->Init();\n");
253     break;
254     case kGun7:   
255       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
256       fprintf(fp,"  for(int i=1;i<=7;i++){\n");
257       fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
258       fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(1.0+i*0.5); pFixed->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());
259       fprintf(fp,"    pFixed->SetPhi(pRICH->C(i)->PhiD()); pFixed->SetTheta(pRICH->C(i)->ThetaD()-2);\n");                             
260       fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
261       fprintf(fp,"  pCocktail->Init();\n");
262     break;
263     case kPythia7:      
264       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
265       fprintf(fp,"  for(int i=1;i<=7;i++){\n");
266       fprintf(fp,"    AliGenFixed *pFixed=new AliGenFixed(1);\n");
267       fprintf(fp,"    pFixed->SetPart(%i); pFixed->SetMomentum(2.5+i*0.4); pFixed->SetOrigin(0,0,0);\n",fGenPartIdCombo->GetSelected());
268       fprintf(fp,"    pFixed->SetPhiRange(pRICH->C(i)->PhiD()); pFixed->SetThetaRange(pRICH->C(i)->ThetaD()-2);\n");                             
269       fprintf(fp,"    pCocktail->AddGenerator(pFixed,Form(\"Fixed %i\",i),1);\n  }\n");  
270       fprintf(fp,"  AliGenPythia *pPythia = new AliGenPythia(-1);\n");
271       fprintf(fp,"  pPythia->SetMomentumRange(0,999999); pPythia->SetPhiRange(20,80); pPythia->SetThetaRange(75,115);\n");
272       fprintf(fp,"  pPythia->SetYRange(-12,12);  pPythia->SetPtRange(0,1000);  pPythia->SetStrucFunc(kCTEQ4L);\n");
273       fprintf(fp,"  pPythia->SetProcess(kPyMb);  pPythia->SetEnergyCMS(14000);\n");      
274       fprintf(fp,"  pCocktail->AddGenerator(pPythia,\"Pythia\",1);\n");  
275       fprintf(fp,"  pCocktail->Init();\n");
276     case kSr90:  
277       fprintf(fp,"  AliGenRadioactive *pGen=new AliGenRadioactive(kSr90,%i);\n",(int)fGenNprimEntry->GetNumber());
278       fprintf(fp,"  pGen->SetOrigin(0,0,0);  pGen->SetSigma(0.1,0.1,0.05);\n");      
279       fprintf(fp,"  pGen->Init();\n");
280     break;  
281     case kHijing:  
282       fprintf(fp,"  AliGenHijing *pGen=new AliGenHijing(-1); pGen->SetEnergyCMS(5500); pGen->SetReferenceFrame(\"CMS\");\n");
283       fprintf(fp,"  pGen->SetProjectile(\"A\", 208, 82); pGen->SetTarget(\"A\", 208, 82);\n");      
284       fprintf(fp,"  pGen->SetJetQuenching(0); pGen->SetShadowing(0);\n");
285       fprintf(fp,"  pGen->KeepFullEvent(); pGen->SetSelectAll(0); \n");
286       fprintf(fp,"  pGen->SetImpactParameterRange(0., 5.);\n");
287       fprintf(fp,"  pGen->Init();\n");
288     break;  
289     case kHijingPara2Proton:  
290       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
291       fprintf(fp,"  for(int i=1;i<=7;i++){\n");
292       fprintf(fp,"    AliGenFixed *pProton1=new AliGenFixed(1);\n");
293       fprintf(fp,"    AliGenFixed *pProton2=new AliGenFixed(1);\n");
294       fprintf(fp,"    pProton1->SetPart(kProton); pProton1->SetMomentum(2.0+i*0.5); pProton1->SetOrigin(0,0,0);\n");
295       fprintf(fp,"    pProton2->SetPart(kProton); pProton2->SetMomentum(2.0+i*0.5); pProton2->SetOrigin(0,0,0);\n");
296       fprintf(fp,"    pProton1->SetPhiRange(pRICH->C(i)->PhiD()); pProton1->SetThetaRange(pRICH->C(i)->ThetaD());\n");                             
297       fprintf(fp,"    pProton2->SetPhiRange(pRICH->C(i)->PhiD()); pProton2->SetThetaRange(pRICH->C(i)->ThetaD()-4);\n");                             
298       fprintf(fp,"    pCocktail->AddGenerator(pProton1,Form(\"proton1 %i\",i),1);\n");  
299       fprintf(fp,"    pCocktail->AddGenerator(pProton2,Form(\"proton2 %i\",i),1);\n  }\n");  
300       
301       fprintf(fp,"  AliGenHIJINGpara *pHijingPara=new AliGenHIJINGpara(510);\n");
302       fprintf(fp,"  pHijingPara->SetMomentumRange(0,99); pHijingPara->SetThetaRange(60,120); pHijingPara->SetPhiRange(0,60);\n");
303       fprintf(fp,"  pHijingPara->SetOrigin(0,0,0);  pHijingPara->SetSigma(0,0,0);\n");
304       fprintf(fp,"  pCocktail->AddGenerator(pHijingPara,\"HijingPara\",1);\n");  
305       fprintf(fp,"  pCocktail->Init();\n");
306     break;  
307      case kRichLib:
308       fprintf(fp,"  AliGenParam *pGen=new AliGenParam(2,new AliGenRICHlib,%i,\"EXP\"); \n",fGenPartIdCombo->GetSelected());
309       fprintf(fp,"  pGen->SetPtRange(%3.1f,%3.1f); \n",fGenMinMomCombo->GetSelected()/10,fGenMaxMomCombo->GetSelected()/10);
310       fprintf(fp,"  pGen->SetYRange(-0.6,0.6); \n");
311       fprintf(fp,"  pGen->SetPhiRange(0.,60.); \n");
312       fprintf(fp,"  pGen->SetForceDecay(kAll); \n");
313       fprintf(fp,"  pGen->Init();\n");
314     break;
315    case kSignalHijing:
316       fprintf(fp,"  AliGenParam *pRichLib=new AliGenParam(2,new AliGenRICHlib,%i,\"FLAT\"); \n",fGenPartIdCombo->GetSelected());
317       fprintf(fp,"  pRichLib->SetPtRange(%3.1f,%3.1f); \n",fGenMinMomCombo->GetSelected()/10,fGenMaxMomCombo->GetSelected()/10);
318       fprintf(fp,"  pRichLib->SetYRange(-0.6,0.6); \n");
319       fprintf(fp,"  pRichLib->SetPhiRange(0.,60.); \n");
320       fprintf(fp,"  pRichLib->SetForceDecay(kPhiKK); \n");
321
322       fprintf(fp,"  AliGenHijing *pHijing=new AliGenHijing(-1); pHijing->SetEnergyCMS(5500); pHijing->SetReferenceFrame(\"CMS\");\n");
323       fprintf(fp,"  pHijing->SetProjectile(\"A\", 208, 82); pHijing->SetTarget(\"A\", 208, 82);\n");
324       fprintf(fp,"  pHijing->SetJetQuenching(0); pHijing->SetShadowing(0);\n");
325       fprintf(fp,"  pHijing->KeepFullEvent(); pHijing->SetSelectAll(0); \n");
326       fprintf(fp,"  pHijing->SetImpactParameterRange(0., 5.);\n");
327
328       fprintf(fp,"  AliGenCocktail *pCocktail=new AliGenCocktail();\n");
329       fprintf(fp,"  pCocktail->AddGenerator(pRichLib,\"RichLib\",1);\n");
330       fprintf(fp,"  pCocktail->AddGenerator(pHijing,\"Hijing\",1);\n");
331       fprintf(fp,"  pCocktail->Init();\n");
332     break;
333   }
334 //central before RICH detectors                  
335   if(fDetBG->GetButton(kPIPE )->GetState()) fprintf(fp,"\n  new AliPIPEv0(\"PIPE\",\"Beam Pipe\");\n");
336   if(fDetBG->GetButton(kSHILD)->GetState()) fprintf(fp,"\n  new AliSHILv2(\"SHIL\",\"Shielding Version 2\");\n");  
337   if(fDetBG->GetButton(kITS  )->GetState()){
338     fprintf(fp,"\n  AliITSvPPRasymmFMD *pIts =new AliITSvPPRasymmFMD(\"ITS\",\"ITS PPR detailed version\");\n");
339     fprintf(fp,"  pIts->SetMinorVersion(2); pIts->SetReadDet(kTRUE);\n");
340     fprintf(fp,"  pIts->SetThicknessDet1(200.); pIts->SetThicknessDet2(200.);\n");
341     fprintf(fp,"  pIts->SetThicknessChip1(200.); pIts->SetThicknessChip2(200.);\n");
342     fprintf(fp,"  pIts->SetRails(0); pIts->SetCoolingFluid(1);\n");
343     fprintf(fp,"  pIts->SetEUCLID(0);\n");
344   }  
345   if(fDetBG->GetButton(kTPC  )->GetState()) {fprintf(fp,"\n  AliTPC *pTpc=new AliTPCv2(\"TPC\",\"Default\"); pTpc->SetSecAU(-1);pTpc->SetSecAL(-1);\n");}  
346   if(fDetBG->GetButton(kFRAME)->GetState())  fprintf(fp,"\n  AliFRAMEv2 *pFrame=new AliFRAMEv2(\"FRAME\",\"Space Frame\"); pFrame->SetHoles(1);\n");
347   if(fDetBG->GetButton(kTRD  )->GetState()) {
348     fprintf(fp,"\n  AliTRD *pTrd=new AliTRDv1(\"TRD\",\"TRD slow simulator\");\n");
349     fprintf(fp,"  pTrd->SetGasMix(1); pTrd->SetPHOShole(); pTrd->SetRICHhole();pTrd->CreateTR();\n");
350   }  
351   if(fDetBG->GetButton(kTOF  )->GetState()) fprintf(fp,"\n  new AliTOFv4T0(\"TOF\", \"normal TOF\");\n");
352 //central after RICH detectors  
353   if(fDetBG->GetButton(kMAG  )->GetState()) fprintf(fp,"\n  new AliMAG(\"MAG\",\"Magnet\");\n");  
354   if(fDetBG->GetButton(kHALL )->GetState()) fprintf(fp,"\n  new AliHALL(\"HALL\",\"Alice Hall\");\n");
355 //forward detectors  
356   if(fDetBG->GetButton(kFMD  )->GetState()) fprintf(fp,"\n  new AliFMDv1(\"FMD\",\"normal FMD\");\n");
357   if(fDetBG->GetButton(kABSO )->GetState()) fprintf(fp,"\n  new AliABSOv0(\"ABSO\",\"Muon absorber\");\n");
358   if(fDetBG->GetButton(kDIPO )->GetState()) fprintf(fp,"\n  new AliDIPOv2(\"DIPO\",\"Dipole version 2\");\n");
359   if(fDetBG->GetButton(kMUON )->GetState()) fprintf(fp,"\n  new AliMUONv1(\"MUON\",\"default\");\n");
360   if(fDetBG->GetButton(kPMD  )->GetState()) fprintf(fp,"\n  new AliPMDv1(\"PMD\",\"normal PMD\");\n");
361   if(fDetBG->GetButton(kSTART)->GetState()) fprintf(fp,"\n  new AliSTARTv1(\"START\",\"START Detector\");\n");
362   if(fDetBG->GetButton(kVZERO)->GetState()) fprintf(fp,"\n  new AliVZEROv2(\"VZERO\",\"normal VZERO\");\n");
363   if(fDetBG->GetButton(kZDC  )->GetState()) fprintf(fp,"\n  new AliZDCv2(\"ZDC\",\"normal ZDC\");\n");
364 //different phase space detectors  
365   if(fDetBG->GetButton(kPHOS )->GetState()) fprintf(fp,"\n  new AliPHOSv1(\"PHOS\",\"IHEP\");\n");
366   if(fDetBG->GetButton(kEMCAL)->GetState()) fprintf(fp,"\n  new AliEMCALv1(\"EMCAL\",\"G56_2_55_19_104_14\");\n");
367   if(fDetBG->GetButton(kCRT  )->GetState()) fprintf(fp,"\n  new AliCRTv0(\"CRT\",\"normal ACORDE\");\n");
368
369   fprintf(fp,"\n  ::Info(\"RICH private config\",\"Stop\");\n"); 
370   fprintf(fp,"}\n");
371 out:  
372   fclose(fp);  
373 //  fMain->CloseWindow();
374 }//CreateConfig
375 //__________________________________________________________________________________________________
376 void RichConfig::CreateRichBatch()
377 {//creates RichBatch.C file
378   FILE *fp=fopen("RichBatch.C","w"); if(!fp){Info("CreateRichBatch","Cannot open output file: RichBatch.C");return;}
379   
380   fprintf(fp,"void RichBatch(const Int_t iNevents,const Bool_t isDebug,const char *sConfigFileName)\n");
381   fprintf(fp,"{\n");
382   fprintf(fp,"  gSystem->Exec(\"rm -rf *.root hlt hough fort* ZZZ*\");\n");
383   fprintf(fp,"  if(isDebug)   AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
384   fprintf(fp,"  TStopwatch sw;TDatime time;\n\n");
385   
386   fprintf(fp,"  AliSimulation     *pSim=new AliSimulation(sConfigFileName);\n");
387   if(fGenTypeCombo->GetSelected()==kBox1||fGenTypeCombo->GetSelected()==kGun7) {
388     fprintf(fp,"  pSim->SetRegionOfInterest(kTRUE);\n");
389     fprintf(fp,"  pSim->SetMakeSDigits(\"TOF RICH\");\n");
390     fprintf(fp,"  pSim->SetMakeDigitsFromHits(\"ITS TPC TRD\");\n");
391   }
392   fprintf(fp,"  pSim->Run(iNevents); delete pSim;\n\n");
393   if(fRichVerCombo->GetSelected()==kNormalRich){
394     fprintf(fp,"  AliReconstruction *pRec=new AliReconstruction;\n");
395     fprintf(fp,"  pRec->SetRunLocalReconstruction(\"ITS TPC TRD TOF RICH\");\n");
396     fprintf(fp,"  pRec->SetFillESD(\"ITS TPC TRD TOF RICH\");\n");
397     fprintf(fp,"  pRec->Run();         delete pRec;\n\n");
398   }
399   
400   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Start time: \";time.Print();\n");
401   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Stop  time: \";time.Set();  time.Print();\n");
402   fprintf(fp,"  cout<<\"!!!!!!!!!!!!Info in <my/RichBatch.C>: Time  used: \";sw.Print();\n\n");
403   
404   fprintf(fp,"  gSystem->Exec(\"touch ZZZ______finished_______ZZZ\");\n");
405   fprintf(fp,"  gSystem->Exec(\"playwave ~/bin/end.wav\");\n");
406   fprintf(fp,"}\n");
407   
408   fclose(fp);  
409 }//CreateRichBatch()
410 //__________________________________________________________________________________________________
411 void RichConfig::Exit()
412 {
413 //slot to be invoked by clik on the Create button  
414   CreateConfig();
415   CreateRichBatch();
416 //  fMainFM->SendCloseMessage();
417 }
418 //__________________________________________________________________________________________________
419 RichConfig *rc;
420 void RichConfig()
421 {
422    rc=new RichConfig("Config.C");
423 }   
424