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